1 ; Test IPA over a single combined file
2 ; RUN: llvm-as %s -o %t0.bc
3 ; RUN: llvm-as %S/Inputs/ipa-alias.ll -o %t1.bc
4 ; RUN: llvm-link %t0.bc %t1.bc -o %t.combined.bc
5 ; RUN: opt -S -analyze -stack-safety-local %t.combined.bc | FileCheck %s --check-prefixes=CHECK,LOCAL
6 ; RUN: opt -S -passes="print<stack-safety-local>" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,LOCAL
7 ; RUN: opt -S -analyze -stack-safety %t.combined.bc | FileCheck %s --check-prefixes=CHECK,GLOBAL
8 ; RUN: opt -S -passes="print-stack-safety" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL
10 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11 target triple = "x86_64-unknown-linux-gnu"
13 declare void @PreemptableAliasWrite1(i8* %p)
14 declare void @AliasToPreemptableAliasWrite1(i8* %p)
16 declare void @InterposableAliasWrite1(i8* %p)
17 ; Aliases to interposable aliases are not allowed
19 declare void @AliasWrite1(i8* %p)
21 declare void @BitcastAliasWrite1(i32* %p)
22 declare void @AliasToBitcastAliasWrite1(i8* %p)
24 ; Call to dso_preemptable alias to a dso_local aliasee
25 define void @PreemptableAliasCall() {
26 ; CHECK-LABEL: @PreemptableAliasCall dso_preemptable{{$}}
27 ; CHECK-NEXT: args uses:
28 ; CHECK-NEXT: allocas uses:
29 ; LOCAL-NEXT: x1[1]: empty-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
30 ; GLOBAL-NEXT: x1[1]: full-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
31 ; LOCAL-NEXT: x2[1]: empty-set, @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
32 ; GLOBAL-NEXT: x2[1]: [0,1), @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
36 call void @PreemptableAliasWrite1(i8* %x1)
39 ; Alias to a preemptable alias is not preemptable
40 call void @AliasToPreemptableAliasWrite1(i8* %x2)
44 ; Call to an interposable alias to a non-interposable aliasee
45 define void @InterposableAliasCall() {
46 ; CHECK-LABEL: @InterposableAliasCall dso_preemptable{{$}}
47 ; CHECK-NEXT: args uses:
48 ; CHECK-NEXT: allocas uses:
49 ; LOCAL-NEXT: x[1]: empty-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
50 ; GLOBAL-NEXT: x[1]: full-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
54 ; ThinLTO can resolve the prevailing implementation for interposable definitions.
55 call void @InterposableAliasWrite1(i8* %x)
59 ; Call to a dso_local/non-interposable alias/aliasee
60 define void @AliasCall() {
61 ; CHECK-LABEL: @AliasCall dso_preemptable{{$}}
62 ; CHECK-NEXT: args uses:
63 ; CHECK-NEXT: allocas uses:
64 ; LOCAL-NEXT: x[1]: empty-set, @AliasWrite1(arg0, [0,1)){{$}}
65 ; GLOBAL-NEXT: x[1]: [0,1), @AliasWrite1(arg0, [0,1)){{$}}
69 call void @AliasWrite1(i8* %x)
73 ; Call to a bitcasted dso_local/non-interposable alias/aliasee
74 define void @BitcastAliasCall() {
75 ; CHECK-LABEL: @BitcastAliasCall dso_preemptable{{$}}
76 ; CHECK-NEXT: args uses:
77 ; CHECK-NEXT: allocas uses:
78 ; LOCAL-NEXT: x1[4]: empty-set, @BitcastAliasWrite1(arg0, [0,1)){{$}}
79 ; GLOBAL-NEXT: x1[4]: [0,1), @BitcastAliasWrite1(arg0, [0,1)){{$}}
80 ; LOCAL-NEXT: x2[1]: empty-set, @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
81 ; GLOBAL-NEXT: x2[1]: [0,1), @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
85 call void @BitcastAliasWrite1(i32* %x1)
87 call void @AliasToBitcastAliasWrite1(i8* %x2)
91 ; The rest is from Inputs/ipa-alias.ll
93 ; CHECK-LABEL: @Write1{{$}}
94 ; CHECK-NEXT: args uses:
95 ; CHECK-NEXT: p[]: [0,1){{$}}
96 ; CHECK-NEXT: allocas uses:
99 ; GLOBAL-LABEL: @InterposableAliasWrite1 interposable{{$}}
100 ; GLOBAL-NEXT: args uses:
101 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
102 ; GLOBAL-NEXT: allocas uses:
105 ; GLOBAL-LABEL: @PreemptableAliasWrite1 dso_preemptable{{$}}
106 ; GLOBAL-NEXT: args uses:
107 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
108 ; GLOBAL-NEXT: allocas uses:
111 ; GLOBAL-LABEL: @AliasToPreemptableAliasWrite1{{$}}
112 ; GLOBAL-NEXT: args uses:
113 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
114 ; GLOBAL-NEXT: allocas uses:
117 ; GLOBAL-LABEL: @AliasWrite1{{$}}
118 ; GLOBAL-NEXT: args uses:
119 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
120 ; GLOBAL-NEXT: allocas uses:
123 ; GLOBAL-LABEL: @BitcastAliasWrite1{{$}}
124 ; GLOBAL-NEXT: args uses:
125 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
126 ; GLOBAL-NEXT: allocas uses:
129 ; GLOBAL-LABEL: @AliasToBitcastAliasWrite1{{$}}
130 ; GLOBAL-NEXT: args uses:
131 ; GLOBAL-NEXT: <N/A>[]: [0,1), @Write1(arg0, [0,1)){{$}}
132 ; GLOBAL-NEXT: allocas uses: