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