1 ; RUN: opt -S -analyze -stack-safety-local < %s | FileCheck %s --check-prefixes=CHECK,LOCAL
2 ; RUN: opt -S -passes="print<stack-safety-local>" -disable-output < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LOCAL
3 ; RUN: opt -S -analyze -stack-safety < %s | FileCheck %s --check-prefixes=CHECK,GLOBAL
4 ; RUN: opt -S -passes="print-stack-safety" -disable-output < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL
6 ; Regression test that exercises a case when a AllocaOffsetRewritten SCEV
7 ; could return an empty-set range. This could occur with udiv SCEVs where the
8 ; RHS was re-written to 0.
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 @ExternalFn(i64)
15 define void @Test1() {
16 ; CHECK-LABEL: @Test1 dso_preemptable{{$}}
17 ; CHECK-NEXT: args uses:
18 ; CHECK-NEXT: allocas uses:
19 ; LOCAL-NEXT: x[1]: empty-set, @Divide1(arg0, full-set){{$}}
20 ; GLOBAL-NEXT: x[1]: full-set, @Divide1(arg0, full-set){{$}}
23 %int = ptrtoint i8* %x to i64
24 call void @Divide1(i64 %int)
28 define dso_local void @Divide1(i64 %arg) {
29 ; CHECK-LABEL: @Divide1{{$}}
30 ; CHECK-NEXT: args uses:
31 ; LOCAL-NEXT: arg[]: empty-set, @ExternalFn(arg0, full-set){{$}}
32 ; GLOBAL-NEXT: arg[]: full-set, @ExternalFn(arg0, full-set){{$}}
33 ; CHECK-NEXT: allocas uses:
35 %quotient = udiv i64 undef, %arg
36 call void @ExternalFn(i64 %quotient)
40 define void @Test2(i64 %arg) {
41 ; CHECK-LABEL: @Test2 dso_preemptable{{$}}
42 ; CHECK-NEXT: args uses:
43 ; CHECK-NEXT: arg[]: empty-set{{$}}
44 ; CHECK-NEXT: allocas uses:
45 ; LOCAL-NEXT: x[1]: empty-set, @Divide2(arg0, full-set){{$}}
46 ; GLOBAL-NEXT: x[1]: full-set, @Divide2(arg0, full-set){{$}}
49 %int = ptrtoint i8* %x to i64
50 call void @Divide2(i64 %int)
54 define dso_local void @Divide2(i64 %arg) {
55 ; CHECK-LABEL: @Divide2{{$}}
56 ; CHECK-NEXT: args uses:
57 ; CHECK-NEXT: arg[]: full-set{{$}}
58 ; CHECK-NEXT: allocas uses:
60 %x = inttoptr i64 %arg to i8*
61 %quotient = udiv i64 undef, %arg
62 %arrayidx = getelementptr i8, i8* %x, i64 %quotient
63 load i8, i8* %arrayidx