[TTI] getTypeBasedIntrinsicInstrCost - add basic handling for strided load/store...
[llvm-project.git] / llvm / test / CodeGen / AArch64 / cgdata-outline-gvar.ll
blob63ba1d491f9c73666d2e2f8fe7b1fb5822613ffd
1 ; This test verifies that global variables are hashed based on their initial contents,
2 ; allowing them to be outlined even if they appear different due to their names.
4 ; RUN: split-file %s %t
6 ; The outlined function is created locally.
7 ; Note that `.str.3` is commonly used in both `f1()` and `f2()`.
8 ; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-generate -aarch64-enable-collect-loh=false  \
9 ; RUN:   %t/local-two.ll -o -  | FileCheck %s --check-prefix=WRITE
11 ; WRITE-LABEL: _OUTLINED_FUNCTION_{{.*}}:
12 ; WRITE:      adrp x1, l_.str.3
13 ; WRITE-NEXT: add x1, x1, l_.str.3
14 ; WRITE-NEXT: mov w2
15 ; WRITE-NEXT: mov w3
16 ; WRITE-NEXT: mov w4
17 ; WRITE-NEXT: b
19 ; Create an object file and merge it into the cgdata.
20 ; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-generate -aarch64-enable-collect-loh=false \
21 ; RUN:   -filetype=obj %t/local-two.ll -o %t_write_base
22 ; RUN: llvm-cgdata --merge %t_write_base -o %t_cgdata_base
24 ; Read the cgdata in the machine outliner for optimistically outlining in local-one.ll.
25 ; Note that the hash of `.str.5` in local-one.ll matches that of `.str.3` in an outlined tree in the cgdata.
27 ; RUN: llc -mtriple=arm64-apple-darwin -enable-machine-outliner -codegen-data-use-path=%t_cgdata_base  -aarch64-enable-collect-loh=false \
28 ; RUN:   %t/local-one.ll -o -  | FileCheck %s --check-prefix=READ
30 ; READ-LABEL: _OUTLINED_FUNCTION_{{.*}}:
31 ; READ:      adrp x1, l_.str.5
32 ; READ-NEXT: add x1, x1, l_.str.5
33 ; READ-NEXT: mov w2
34 ; READ-NEXT: mov w3
35 ; READ-NEXT: mov w4
36 ; READ-NEXT: b
38 ;--- local-two.ll
39 @.str.1 = private unnamed_addr constant [3 x i8] c"f1\00", align 1
40 @.str.2 = private unnamed_addr constant [3 x i8] c"f2\00", align 1
41 @.str.3 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
43 declare noundef i32 @goo(ptr noundef, ptr noundef, i32, i32, i32)
44 define i32 @f1() minsize {
45 entry:
46   %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3, i32 1, i32 2, i32 3)
47   ret i32 %call
49 define i32 @f2() minsize {
50 entry:
51   %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 1, i32 2, i32 3)
52   ret i32 %call
55 ;--- local-one.ll
56 @.str.4 = private unnamed_addr constant [3 x i8] c"f3\00", align 1
57 @.str.5 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
59 declare noundef i32 @goo(ptr noundef, ptr noundef, i32, i32, i32)
60 define i32 @f1() minsize {
61 entry:
62   %call = tail call noundef i32 @goo(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, i32 1, i32 2, i32 3)
63   ret i32 %call