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
14target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
15target triple = "aarch64-unknown-linux"
16
17attributes #0 = { sanitize_memtag "target-features"="+mte,+neon" }
18
19declare void @PreemptableAliasWrite1(i8* %p)
20declare void @AliasToPreemptableAliasWrite1(i8* %p)
21
22declare void @InterposableAliasWrite1(i8* %p)
23; Aliases to interposable aliases are not allowed
24
25declare void @AliasWrite1(i8* %p)
26
27declare void @BitcastAliasWrite1(i32* %p)
28declare void @AliasToBitcastAliasWrite1(i8* %p)
29
30; Call to dso_preemptable alias to a dso_local aliasee
31define void @PreemptableAliasCall() #0 {
32; CHECK-LABEL: @PreemptableAliasCall dso_preemptable{{$}}
33; CHECK-NEXT: args uses:
34; CHECK-NEXT: allocas uses:
35; LOCAL-NEXT: x1[1]: empty-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
36; GLOBAL-NEXT: x1[1]: full-set, @PreemptableAliasWrite1(arg0, [0,1)){{$}}
37; LOCAL-NEXT: x2[1]: empty-set, @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
38; GLOBAL-NEXT: x2[1]: [0,1), @AliasToPreemptableAliasWrite1(arg0, [0,1)){{$}}
39; CHECK-NOT: ]:
40entry:
41  %x1 = alloca i8
42  call void @PreemptableAliasWrite1(i8* %x1)
43
44  %x2 = alloca i8
45; Alias to a preemptable alias is not preemptable
46  call void @AliasToPreemptableAliasWrite1(i8* %x2)
47  ret void
48}
49
50; Call to an interposable alias to a non-interposable aliasee
51define void @InterposableAliasCall() #0 {
52; CHECK-LABEL: @InterposableAliasCall dso_preemptable{{$}}
53; CHECK-NEXT: args uses:
54; CHECK-NEXT: allocas uses:
55; LOCAL-NEXT: x[1]: empty-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
56; NOLTO-NEXT: x[1]: full-set, @InterposableAliasWrite1(arg0, [0,1)){{$}}
57; CHECK-NOT: ]:
58entry:
59  %x = alloca i8
60; ThinLTO can resolve the prevailing implementation for interposable definitions.
61  call void @InterposableAliasWrite1(i8* %x)
62  ret void
63}
64
65; Call to a dso_local/non-interposable alias/aliasee
66define void @AliasCall() #0 {
67; CHECK-LABEL: @AliasCall dso_preemptable{{$}}
68; CHECK-NEXT: args uses:
69; CHECK-NEXT: allocas uses:
70; LOCAL-NEXT: x[1]: empty-set, @AliasWrite1(arg0, [0,1)){{$}}
71; GLOBAL-NEXT: x[1]: [0,1), @AliasWrite1(arg0, [0,1)){{$}}
72; CHECK-NOT: ]:
73entry:
74  %x = alloca i8
75  call void @AliasWrite1(i8* %x)
76  ret void
77}
78
79; Call to a bitcasted dso_local/non-interposable alias/aliasee
80define void @BitcastAliasCall() #0 {
81; CHECK-LABEL: @BitcastAliasCall dso_preemptable{{$}}
82; CHECK-NEXT: args uses:
83; CHECK-NEXT: allocas uses:
84; LOCAL-NEXT: x1[4]: empty-set, @BitcastAliasWrite1(arg0, [0,1)){{$}}
85; GLOBAL-NEXT: x1[4]: [0,1), @BitcastAliasWrite1(arg0, [0,1)){{$}}
86; LOCAL-NEXT: x2[1]: empty-set, @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
87; GLOBAL-NEXT: x2[1]: [0,1), @AliasToBitcastAliasWrite1(arg0, [0,1)){{$}}
88; CHECK-NOT: ]:
89entry:
90  %x1 = alloca i32
91  call void @BitcastAliasWrite1(i32* %x1)
92  %x2 = alloca i8
93  call void @AliasToBitcastAliasWrite1(i8* %x2)
94  ret void
95}
96
97; The rest is from Inputs/ipa-alias.ll
98
99; CHECK-LABEL: @Write1{{$}}
100; CHECK-NEXT: args uses:
101; CHECK-NEXT: p[]: [0,1){{$}}
102; CHECK-NEXT: allocas uses:
103; CHECK-NOT: ]:
104