155 lines · plain
1# RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -no-stack-coloring=false -run-pass stack-coloring -o - %s2# RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -no-stack-coloring=false -passes stack-coloring -o - %s3 4# Test to insure that the liveness analysis in the StackColoring5# pass gracefully handles statically unreachable blocks. See PR 37310.6 7# This MIR testcase was created by compiling the following test, first8# with "clang -emit-llvm -S" and then "llc -stop-before stack-coloring",9# and finally editing the resulting MIR by hand to introduce a statically10# 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).12 13# Original C code:14# extern int inita(int *);15# void foo(int x) {16# if (x != 3) {17# int q[128];18# inita(&q[0]);19# return;20# }21# int r[128];22# inita(&r[x]);23# }24 25--- |26 27 define void @foo(i32 %x) {28 entry:29 %q = alloca [128 x i32], align 1630 %r = alloca [128 x i32], align 1631 %cmp = icmp eq i32 %x, 332 br i1 %cmp, label %if.end, label %if.then33 34 if.then: ; preds = %entry35 %0 = bitcast ptr %q to ptr36 call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %0)37 %arrayidx2 = bitcast ptr %q to ptr38 %call = call i32 @inita(ptr nonnull %arrayidx2)39 call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %0)40 br label %return41 42 unreachable:43 br label %return44 45 if.end: ; preds = %entry46 %1 = bitcast ptr %r to ptr47 call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %1)48 %arrayidx1 = getelementptr inbounds [128 x i32], ptr %r, i64 0, i64 349 %call2 = call i32 @inita(ptr nonnull %arrayidx1)50 call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %1)51 br label %return52 53 return: ; preds = %if.end, %if.then54 ret void55 }56 57 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)58 59 declare i32 @inita(ptr)60 61 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)62 63 declare void @llvm.stackprotector(ptr, ptr)64 65...66---67name: foo68alignment: 1669exposesReturnsTwice: false70legalized: false71regBankSelected: false72selected: false73failedISel: false74tracksRegLiveness: true75registers: 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: '' }82liveins: 83 - { reg: '$edi' }84frameInfo: 85 isFrameAddressTaken: false86 isReturnAddressTaken: false87 hasStackMap: false88 hasPatchPoint: false89 stackSize: 090 offsetAdjustment: 091 maxAlignment: 1692 adjustsStack: false93 hasCalls: true94 stackProtector: ''95 maxCallFrameSize: 429496729596 hasOpaqueSPAdjustment: false97 hasVAStart: false98 hasMustTailInVarArgFunc: false99 localFrameSize: 0100 savePoint: []101 restorePoint: []102fixedStack: 103stack: 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: '' }110constants: 111body: |112 bb.0.entry:113 successors: %bb.3(0x40000000), %bb.1(0x40000000)114 liveins: $edi115 116 %0:gr32 = COPY $edi117 %1:gr32 = SUB32ri8 %0, 3, implicit-def $eflags118 JCC_1 %bb.3, 4, implicit $eflags119 JMP_1 %bb.1120 121 bb.1.if.then:122 successors: %bb.4(0x80000000)123 124 LIFETIME_START %stack.0.q125 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp126 %2:gr64 = LEA64r %stack.0.q, 1, $noreg, 0, $noreg127 $rdi = COPY %2128 CALL64pcrel32 @inita, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax129 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp130 %3:gr32 = COPY $eax131 LIFETIME_END %stack.0.q132 JMP_1 %bb.4133 134 bb.2.unreachable:135 successors: %bb.4(0x80000000)136 137 JMP_1 %bb.4138 139 bb.3.if.end:140 successors: %bb.4(0x80000000)141 142 LIFETIME_START %stack.1.r143 %4:gr64 = LEA64r %stack.1.r, 1, $noreg, 12, $noreg144 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp145 $rdi = COPY %4146 CALL64pcrel32 @inita, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax147 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp148 %5:gr32 = COPY $eax149 LIFETIME_END %stack.1.r150 151 bb.4.return:152 RET 0153 154...155