1; REQUIRES: aarch64-registered-target
2
3; Test IPA over a single combined file
4; RUN: llvm-as %s -o %t0.bc
5; RUN: llvm-as %S/Inputs/ipa-alias.ll -o %t1.bc
6; RUN: llvm-link %t0.bc %t1.bc -o %t.combined.bc
7
8; RUN: opt -S -analyze -stack-safety-local %t.combined.bc | FileCheck %s --check-prefixes=CHECK,LOCAL
9; RUN: opt -S -passes="print<stack-safety-local>" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,LOCAL
10
11; RUN: opt -S -analyze -stack-safety %t.combined.bc | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
12; RUN: opt -S -passes="print-stack-safety" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
13
14; Do an end-to-test using the new LTO API
15; RUN: opt -module-summary %s -o %t.summ0.bc
16; RUN: opt -module-summary %S/Inputs/ipa-alias.ll -o %t.summ1.bc
17
18; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t.lto -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
19; RUN:  -r %t.summ0.bc,PreemptableAliasWrite1, \
20; RUN:  -r %t.summ0.bc,AliasToPreemptableAliasWrite1, \
21; RUN:  -r %t.summ0.bc,InterposableAliasWrite1, \
22; RUN:  -r %t.summ0.bc,AliasWrite1, \
23; RUN:  -r %t.summ0.bc,BitcastAliasWrite1, \
24; RUN:  -r %t.summ0.bc,AliasToBitcastAliasWrite1, \
25; RUN:  -r %t.summ0.bc,PreemptableAliasCall,px \
26; RUN:  -r %t.summ0.bc,InterposableAliasCall,px \
27; RUN:  -r %t.summ0.bc,AliasCall,px \
28; RUN:  -r %t.summ0.bc,BitcastAliasCall,px \
29; RUN:  -r %t.summ1.bc,PreemptableAliasWrite1,px \
30; RUN:  -r %t.summ1.bc,AliasToPreemptableAliasWrite1,px \
31; RUN:  -r %t.summ1.bc,InterposableAliasWrite1,px \
32; RUN:  -r %t.summ1.bc,AliasWrite1,px \
33; RUN:  -r %t.summ1.bc,BitcastAliasWrite1,px \
34; RUN:  -r %t.summ1.bc,AliasToBitcastAliasWrite1,px \
35; RUN:  -r %t.summ1.bc,Write1,px 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,LTO
36
37; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t-newpm.lto -stack-safety-print -stack-safety-run -save-temps -use-new-pm -thinlto-threads 1 -O0 \
38; RUN:  -r %t.summ0.bc,PreemptableAliasWrite1, \
39; RUN:  -r %t.summ0.bc,AliasToPreemptableAliasWrite1, \
40; RUN:  -r %t.summ0.bc,InterposableAliasWrite1, \
41; RUN:  -r %t.summ0.bc,AliasWrite1, \
42; RUN:  -r %t.summ0.bc,BitcastAliasWrite1, \
43; RUN:  -r %t.summ0.bc,AliasToBitcastAliasWrite1, \
44; RUN:  -r %t.summ0.bc,PreemptableAliasCall,px \
45; RUN:  -r %t.summ0.bc,InterposableAliasCall,px \
46; RUN:  -r %t.summ0.bc,AliasCall,px \
47; RUN:  -r %t.summ0.bc,BitcastAliasCall,px \
48; RUN:  -r %t.summ1.bc,PreemptableAliasWrite1,px \
49; RUN:  -r %t.summ1.bc,AliasToPreemptableAliasWrite1,px \
50; RUN:  -r %t.summ1.bc,InterposableAliasWrite1,px \
51; RUN:  -r %t.summ1.bc,AliasWrite1,px \
52; RUN:  -r %t.summ1.bc,BitcastAliasWrite1,px \
53; RUN:  -r %t.summ1.bc,AliasToBitcastAliasWrite1,px \
54; RUN:  -r %t.summ1.bc,Write1,px 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,LTO
55
56target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
57target triple = "aarch64-unknown-linux"
58
59attributes #0 = { sanitize_memtag "target-features"="+mte,+neon" }
60
61declare void @PreemptableAliasWrite1(i8* %p)
62declare void @AliasToPreemptableAliasWrite1(i8* %p)
63
64declare void @InterposableAliasWrite1(i8* %p)
65; Aliases to interposable aliases are not allowed
66
67declare void @AliasWrite1(i8* %p)
68
69declare void @BitcastAliasWrite1(i32* %p)
70declare void @AliasToBitcastAliasWrite1(i8* %p)
71
72; Call to dso_preemptable alias to a dso_local aliasee
73define void @PreemptableAliasCall() #0 {
74; CHECK-LABEL: @PreemptableAliasCall dso_preemptable{{$}}
75; CHECK-NEXT: args uses:
76; CHECK-NEXT: allocas uses:
77; LOCAL-NEXT: x1[1]: empty-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
78; GLOBAL-NEXT: x1[1]: full-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
79; LOCAL-NEXT: x2[1]: empty-set, @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
80; GLOBAL-NEXT: x2[1]: [0,1), @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
81; CHECK-NOT: ]:
82entry:
83  %x1 = alloca i8
84  call void @PreemptableAliasWrite1(i8* %x1)
85
86  %x2 = alloca i8
87; Alias to a preemptable alias is not preemptable
88  call void @AliasToPreemptableAliasWrite1(i8* %x2)
89  ret void
90}
91
92; Call to an interposable alias to a non-interposable aliasee
93define void @InterposableAliasCall() #0 {
94; CHECK-LABEL: @InterposableAliasCall dso_preemptable{{$}}
95; CHECK-NEXT: args uses:
96; CHECK-NEXT: allocas uses:
97; LOCAL-NEXT: x[1]: empty-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
98; NOLTO-NEXT: x[1]: full-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
99; LTO-NEXT: x[1]: [0,1), @InterposableAliasWrite1(arg0, [0,1)){{$}}
100; CHECK-NOT: ]:
101entry:
102  %x = alloca i8
103; ThinLTO can resolve the prevailing implementation for interposable definitions.
104  call void @InterposableAliasWrite1(i8* %x)
105  ret void
106}
107
108; Call to a dso_local/non-interposable alias/aliasee
109define void @AliasCall() #0 {
110; CHECK-LABEL: @AliasCall dso_preemptable{{$}}
111; CHECK-NEXT: args uses:
112; CHECK-NEXT: allocas uses:
113; LOCAL-NEXT: x[1]: empty-set, @AliasWrite1(arg0, [0,1)){{$}}
114; GLOBAL-NEXT: x[1]: [0,1), @AliasWrite1(arg0, [0,1)){{$}}
115; CHECK-NOT: ]:
116entry:
117  %x = alloca i8
118  call void @AliasWrite1(i8* %x)
119  ret void
120}
121
122; Call to a bitcasted dso_local/non-interposable alias/aliasee
123define void @BitcastAliasCall() #0 {
124; CHECK-LABEL: @BitcastAliasCall dso_preemptable{{$}}
125; CHECK-NEXT: args uses:
126; CHECK-NEXT: allocas uses:
127; LOCAL-NEXT: x1[4]: empty-set, @BitcastAliasWrite1(arg0, [0,1)){{$}}
128; GLOBAL-NEXT: x1[4]: [0,1), @BitcastAliasWrite1(arg0, [0,1)){{$}}
129; LOCAL-NEXT: x2[1]: empty-set, @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
130; GLOBAL-NEXT: x2[1]: [0,1), @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
131; CHECK-NOT: ]:
132entry:
133  %x1 = alloca i32
134  call void @BitcastAliasWrite1(i32* %x1)
135  %x2 = alloca i8
136  call void @AliasToBitcastAliasWrite1(i8* %x2)
137  ret void
138}
139
140; The rest is from Inputs/ipa-alias.ll
141
142; CHECK-LABEL: @Write1{{$}}
143; CHECK-NEXT: args uses:
144; CHECK-NEXT: p[]: [0,1){{$}}
145; CHECK-NEXT: allocas uses:
146; CHECK-NOT: ]:
147