240 lines · plain
1--- |2 ; pr374723 ; These test verify that shrink-wrap does not set the restore point4 ; to a position where the stack might still be accessed by a load or store5 6 ; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s7 ; RUN: llc -x=mir -simplify-mir -passes='shrink-wrap' -o - %s | FileCheck %s8 ; CHECK: name: compiler_pop_stack9 ; CHECK: frameInfo:10 ; CHECK: savePoint:11 ; CHECK-NEXT: - point: '%bb.1'12 ; CHECK: restorePoint:13 ; CHECK-NEXT: - point: '%bb.7'14 ; CHECK: name: compiler_pop_stack_no_memoperands15 ; CHECK: frameInfo:16 ; CHECK: savePoint:17 ; CHECK-NEXT: - point: '%bb.1'18 ; CHECK: restorePoint:19 ; CHECK-NEXT: - point: '%bb.7'20 ; CHECK: name: f21 ; CHECK: frameInfo:22 ; CHECK: savePoint:23 ; CHECK-NEXT: - point: '%bb.2'24 ; CHECK: restorePoint:25 ; CHECK-NEXT: - point: '%bb.4'26 ; CHECK: stack:27 28 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"29 target triple = "aarch64"30 31 %struct.S = type { i32, i32 }32 33 ; Test from: https://bugs.llvm.org/show_bug.cgi?id=4213634 define void @compiler_pop_stack(i32 %num, i32 %dec) {35 entry:36 %rstack = alloca [16 x i32], align 437 %idxprom = zext i32 %dec to i6438 %arrayidx2 = getelementptr inbounds [16 x i32], ptr %rstack, i64 0, i64 %idxprom39 %sunkaddr = mul i64 %idxprom, 440 %sunkaddr2 = getelementptr inbounds i8, ptr %rstack, i64 %sunkaddr41 ret void42 }43 44 define void @compiler_pop_stack_no_memoperands(i32 %num, i32 %dec) {45 entry:46 %rstack = alloca [16 x i32], align 447 %idxprom = zext i32 %dec to i6448 %arrayidx2 = getelementptr inbounds [16 x i32], ptr %rstack, i64 0, i64 %idxprom49 %sunkaddr = mul i64 %idxprom, 450 %sunkaddr2 = getelementptr inbounds i8, ptr %rstack, i64 %sunkaddr51 ret void52 }53 54 55 ; Test from: https://bugs.llvm.org/show_bug.cgi?id=3747256 define i32 @f(ptr nocapture %arg, i32 %arg1) {57 bb:58 %tmp = alloca [4 x i8], align 159 %tmp6 = getelementptr inbounds [4 x i8], ptr %tmp, i64 0, i64 360 %sunkaddr = getelementptr inbounds i8, ptr %tmp, i64 361 %tmp14 = getelementptr inbounds %struct.S, ptr %arg, i64 0, i32 162 ret i32 063 }64 65...66---67name: compiler_pop_stack68alignment: 469tracksRegLiveness: true70liveins:71 - { reg: '$w0' }72frameInfo:73 maxAlignment: 474 maxCallFrameSize: 075 localFrameSize: 6476stack:77 - { id: 0, name: rstack, size: 64, alignment: 4, stack-id: default, local-offset: -64 }78machineFunctionInfo: {}79body: |80 bb.0:81 liveins: $w082 83 dead $wzr = SUBSWri renamable $w0, 2, 0, implicit-def $nzcv84 Bcc 3, %bb.6, implicit killed $nzcv85 B %bb.186 87 bb.1:88 liveins: $w089 90 STRWui killed renamable $w0, %stack.0.rstack, 0 :: (volatile store (s32) into %ir.rstack)91 renamable $w9 = MOVi32imm 192 renamable $x8 = ADDXri %stack.0.rstack, 0, 093 94 bb.2:95 successors: %bb.3(0x30000000), %bb.4(0x50000000)96 liveins: $w9, $x897 98 renamable $w10 = SUBWri renamable $w9, 1, 0, implicit-def $x1099 renamable $w11 = LDRWroW renamable $x8, renamable $w10, 0, 1 :: (volatile load (s32) from %ir.arrayidx2)100 CBNZW renamable $w11, %bb.4101 102 bb.3:103 liveins: $x8, $x10104 105 renamable $w9 = COPY renamable $w10, implicit killed $x10106 B %bb.5107 108 bb.4:109 liveins: $w9, $w11, $x8, $x10110 111 STRWroX killed renamable $w11, renamable $x8, killed renamable $x10, 0, 1 :: (volatile store (s32) into %ir.sunkaddr2)112 113 bb.5:114 successors: %bb.6(0x04000000), %bb.2(0x7c000000)115 liveins: $w9, $x8116 117 CBNZW renamable $w9, %bb.2118 B %bb.6119 120 bb.6:121 RET_ReallyLR122 123...124# Like compiler_pop_stack, but with the memory operands dropped from the125# machine instructions.126---127name: compiler_pop_stack_no_memoperands128alignment: 4129tracksRegLiveness: true130liveins:131 - { reg: '$w0' }132frameInfo:133 maxAlignment: 4134 maxCallFrameSize: 0135 localFrameSize: 64136stack:137 - { id: 0, name: rstack, size: 64, alignment: 4, stack-id: default, local-offset: -64 }138machineFunctionInfo: {}139body: |140 bb.0:141 liveins: $w0142 143 dead $wzr = SUBSWri renamable $w0, 2, 0, implicit-def $nzcv144 Bcc 3, %bb.6, implicit killed $nzcv145 B %bb.1146 147 bb.1:148 liveins: $w0149 150 STRWui killed renamable $w0, %stack.0.rstack, 0151 renamable $w9 = MOVi32imm 1152 renamable $x8 = ADDXri %stack.0.rstack, 0, 0153 154 bb.2:155 successors: %bb.3(0x30000000), %bb.4(0x50000000)156 liveins: $w9, $x8157 158 renamable $w10 = SUBWri renamable $w9, 1, 0, implicit-def $x10159 renamable $w11 = LDRWroW renamable $x8, renamable $w10, 0, 1160 CBNZW renamable $w11, %bb.4161 162 bb.3:163 liveins: $x8, $x10164 165 renamable $w9 = COPY renamable $w10, implicit killed $x10166 B %bb.5167 168 bb.4:169 liveins: $w9, $w11, $x8, $x10170 171 STRWroX killed renamable $w11, renamable $x8, killed renamable $x10, 0, 1172 173 bb.5:174 successors: %bb.6(0x04000000), %bb.2(0x7c000000)175 liveins: $w9, $x8176 177 CBNZW renamable $w9, %bb.2178 B %bb.6179 180 bb.6:181 RET_ReallyLR182 183...184 185---186name: f187alignment: 4188tracksRegLiveness: true189liveins:190 - { reg: '$x0' }191 - { reg: '$w1' }192frameInfo:193 maxAlignment: 4194 maxCallFrameSize: 0195 localFrameSize: 4196stack:197 - { id: 0, name: tmp, size: 4, alignment: 4, stack-id: default, local-offset: -4 }198machineFunctionInfo: {}199body: |200 bb.0:201 successors: %bb.1, %bb.2202 liveins: $w1, $x0203 204 dead $wzr = SUBSWri renamable $w1, 4, 0, implicit-def $nzcv205 Bcc 9, %bb.2, implicit killed $nzcv206 207 bb.1:208 renamable $w0 = MOVi32imm 1209 B %bb.5210 211 bb.2:212 successors: %bb.3, %bb.4213 liveins: $w1, $x0214 215 renamable $w9 = MOVi32imm 67305985216 renamable $w8 = ORRWrs $wzr, renamable $w1, 0, implicit-def $x8217 STRWui killed renamable $w9, %stack.0.tmp, 0 :: (volatile store (s32) into %ir.tmp)218 renamable $x9 = ADDXri %stack.0.tmp, 0, 0219 renamable $w10 = LDRBBroX renamable $x9, renamable $x8, 0, 0 :: (volatile load (s8) from %ir.arg)220 dead $wzr = SUBSWri killed renamable $w1, 2, 0, implicit-def $nzcv221 STRWui killed renamable $w10, renamable $x0, 0 :: (store (s32) into %ir.arg)222 Bcc 8, %bb.4, implicit killed $nzcv223 B %bb.3224 225 bb.3:226 liveins: $x0, $x8, $x9227 228 renamable $w8 = LDRBBroX killed renamable $x9, killed renamable $x8, 0, 0 :: (volatile load (s8) from %ir.sunkaddr)229 STRWui killed renamable $w8, killed renamable $x0, 1 :: (store (s32) into %ir.tmp14)230 231 bb.4:232 renamable $w0 = COPY $wzr233 234 bb.5:235 liveins: $w0236 237 RET_ReallyLR implicit $w0238 239...240