1 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -no-stack-coloring=false -run-pass stack-coloring -o - %s
2 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -no-stack-coloring=false -passes stack-coloring -o - %s
4 # Test to insure that the liveness analysis in the StackColoring
5 # pass gracefully handles statically unreachable blocks. See PR 37310.
7 # This MIR testcase was created by compiling the following test, first
8 # with "clang -emit-llvm -S" and then "llc -stop-before stack-coloring",
9 # and finally editing the resulting MIR by hand to introduce a statically
10 # unreachable BB (to wit: rename all bb.3 to bb.4, rename bb.2 to bb.3,
11 # then add bb.2 with unconditional jump to bb.4).
14 # extern int inita(int *);
27 define void @foo(i32 %x) {
29 %q = alloca [128 x i32], align 16
30 %r = alloca [128 x i32], align 16
31 %cmp = icmp eq i32 %x, 3
32 br i1 %cmp, label %if.end, label %if.then
34 if.then: ; preds = %entry
35 %0 = bitcast ptr %q to ptr
36 call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %0)
37 %arrayidx2 = bitcast ptr %q to ptr
38 %call = call i32 @inita(ptr nonnull %arrayidx2)
39 call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %0)
45 if.end: ; preds = %entry
46 %1 = bitcast ptr %r to ptr
47 call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %1)
48 %arrayidx1 = getelementptr inbounds [128 x i32], ptr %r, i64 0, i64 3
49 %call2 = call i32 @inita(ptr nonnull %arrayidx1)
50 call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %1)
53 return: ; preds = %if.end, %if.then
57 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
59 declare i32 @inita(ptr)
61 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
63 declare void @llvm.stackprotector(ptr, ptr)
69 exposesReturnsTwice: false
71 regBankSelected: false
74 tracksRegLiveness: true
76 - { id: 0, class: gr32, preferred-register: '' }
77 - { id: 1, class: gr32, preferred-register: '' }
78 - { id: 2, class: gr64, preferred-register: '' }
79 - { id: 3, class: gr32, preferred-register: '' }
80 - { id: 4, class: gr64, preferred-register: '' }
81 - { id: 5, class: gr32, preferred-register: '' }
85 isFrameAddressTaken: false
86 isReturnAddressTaken: false
95 maxCallFrameSize: 4294967295
96 hasOpaqueSPAdjustment: false
98 hasMustTailInVarArgFunc: false
104 - { id: 0, name: q, type: default, offset: 0, size: 512, alignment: 16,
105 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
106 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
107 - { id: 1, name: r, type: default, offset: 0, size: 512, alignment: 16,
108 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
109 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
113 successors: %bb.3(0x40000000), %bb.1(0x40000000)
117 %1:gr32 = SUB32ri8 %0, 3, implicit-def $eflags
118 JCC_1 %bb.3, 4, implicit $eflags
122 successors: %bb.4(0x80000000)
124 LIFETIME_START %stack.0.q
125 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
126 %2:gr64 = LEA64r %stack.0.q, 1, $noreg, 0, $noreg
128 CALL64pcrel32 @inita, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax
129 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
131 LIFETIME_END %stack.0.q
135 successors: %bb.4(0x80000000)
140 successors: %bb.4(0x80000000)
142 LIFETIME_START %stack.1.r
143 %4:gr64 = LEA64r %stack.1.r, 1, $noreg, 12, $noreg
144 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
146 CALL64pcrel32 @inita, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax
147 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
149 LIFETIME_END %stack.1.r