408 lines · plain
1# RUN: llc -mtriple=aarch64-apple-darwin -run-pass=aarch64-ldst-opt -verify-machineinstrs -o - %s | FileCheck %s2 3--- |4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"5 target triple = "arm64e-apple-ios13.0"6 7 %struct.widget = type { i64, i64, i32, i32, i64, i64, i64, i64, i64, i32, i32, i32, i16, i32, ptr, %struct.zot, %struct.zot, %struct.zot, %struct.zot, %struct.zot, i64, i64, i64, i32, i64, i32, i32, i32, ptr, %struct.baz, %struct.baz, i64, i64, ptr, %struct.zot, i32, i32, i32, i32, i32, i32, i32, [32 x i8], i64, i64, %struct.wombat, i32, i64, i64, i64, i64 }8 %struct.baz = type { [4 x i32] }9 %struct.snork = type { i32, i32, [1 x %struct.spam] }10 %struct.spam = type { %struct.baz, i32, i32 }11 %struct.zot = type { i64, i64 }12 %struct.wombat = type { [2 x i32] }13 %struct.wombat.0 = type { [200 x i32] }14 15 @__stack_chk_guard = external global ptr16 17 ; Function Attrs: noredzone ssp18 define hidden void @with_noredzone_80bytes() #0 {19 bb:20 %StackGuardSlot = alloca ptr, align 821 %0 = call ptr @llvm.stackguard()22 call void @llvm.stackprotector(ptr %0, ptr %StackGuardSlot)23 %tmp = alloca %struct.widget, align 1624 %tmp1 = alloca ptr, align 825 %tmp2 = alloca ptr, align 826 %tmp3 = alloca ptr, align 827 %tmp4 = alloca ptr, align 828 store ptr null, ptr %tmp3, align 829 store ptr null, ptr %tmp4, align 830 ret void31 }32 33 define hidden void @with_redzone_480bytes() #2 {34 bb:35 %StackGuardSlot = alloca ptr, align 836 %0 = call ptr @llvm.stackguard()37 call void @llvm.stackprotector(ptr %0, ptr %StackGuardSlot)38 %tmp = alloca %struct.widget, align 1639 %tmp1 = alloca ptr, align 840 %tmp2 = alloca ptr, align 841 %tmp3 = alloca ptr, align 842 %tmp4 = alloca ptr, align 843 store ptr null, ptr %tmp3, align 844 store ptr null, ptr %tmp4, align 845 ret void46 }47 48 define hidden void @with_noredzone_no_mem_between() #0 {49 bb:50 %StackGuardSlot = alloca ptr, align 851 %0 = call ptr @llvm.stackguard()52 call void @llvm.stackprotector(ptr %0, ptr %StackGuardSlot)53 %tmp = alloca %struct.widget, align 1654 %tmp1 = alloca ptr, align 855 %tmp2 = alloca ptr, align 856 %tmp3 = alloca ptr, align 857 %tmp4 = alloca ptr, align 858 store ptr null, ptr %tmp3, align 859 store ptr null, ptr %tmp4, align 860 ret void61 }62 63 ; Function Attrs: nofree nosync nounwind willreturn64 declare ptr @llvm.stackguard() #165 66 ; Function Attrs: nofree nosync nounwind willreturn67 declare void @llvm.stackprotector(ptr, ptr) #168 69 attributes #0 = { noredzone ssp "frame-pointer"="non-leaf" }70 attributes #1 = { nofree nosync nounwind willreturn }71 attributes #2 = { ssp "frame-pointer"="non-leaf" }72...73# Check that we don't try to combine the SUB with the STP using pre-index addressing74# if the function does not have redzone enabled.75# CHECK-LABEL: name: with_noredzone_80bytes76# CHECK-NOT: STPXpre $xzr, $xzr77---78name: with_noredzone_80bytes79alignment: 480exposesReturnsTwice: false81legalized: false82regBankSelected: false83selected: false84failedISel: false85tracksRegLiveness: true86hasWinCFI: false87registers: []88liveins: []89frameInfo:90 isFrameAddressTaken: false91 isReturnAddressTaken: false92 hasStackMap: false93 hasPatchPoint: false94 stackSize: 51295 offsetAdjustment: 096 maxAlignment: 1697 adjustsStack: true98 hasCalls: true99 stackProtector: '%stack.0.StackGuardSlot'100 maxCallFrameSize: 0101 cvBytesOfCalleeSavedRegisters: 0102 hasOpaqueSPAdjustment: false103 hasVAStart: false104 hasMustTailInVarArgFunc: false105 localFrameSize: 480106 savePoint: []107 restorePoint: []108fixedStack: []109stack:110 - { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8, 111 alignment: 8, stack-id: default, callee-saved-register: '', callee-saved-restored: true, 112 local-offset: -8, debug-info-variable: '', debug-info-expression: '', 113 debug-info-location: '' }114 - { id: 1, name: tmp, type: default, offset: -480, size: 440, alignment: 16, 115 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 116 local-offset: -448, debug-info-variable: '', debug-info-expression: '', 117 debug-info-location: '' }118 - { id: 2, name: tmp1, type: default, offset: -488, size: 8, alignment: 8, 119 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 120 local-offset: -456, debug-info-variable: '', debug-info-expression: '', 121 debug-info-location: '' }122 - { id: 3, name: tmp2, type: default, offset: -496, size: 8, alignment: 8, 123 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 124 local-offset: -464, debug-info-variable: '', debug-info-expression: '', 125 debug-info-location: '' }126 - { id: 4, name: tmp3, type: default, offset: -504, size: 8, alignment: 8, 127 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 128 local-offset: -472, debug-info-variable: '', debug-info-expression: '', 129 debug-info-location: '' }130 - { id: 5, name: tmp4, type: default, offset: -512, size: 8, alignment: 8, 131 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 132 local-offset: -480, debug-info-variable: '', debug-info-expression: '', 133 debug-info-location: '' }134 - { id: 6, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, 135 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true, 136 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }137 - { id: 7, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, 138 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true, 139 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }140 - { id: 8, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8, 141 stack-id: default, callee-saved-register: '$x27', callee-saved-restored: true, 142 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }143 - { id: 9, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8, 144 stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true, 145 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }146callSites: []147debugValueSubstitutions: []148constants: []149machineFunctionInfo:150 hasRedZone: false151body: |152 bb.0.bb:153 successors: %bb.1(0x7ffff800), %bb.2(0x00000800)154 liveins: $x27, $x28, $lr155 early-clobber $sp = frame-setup STPXpre killed $x28, killed $x27, $sp, -4 :: (store (s64) into %stack.9), (store (s64) into %stack.8)156 frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.7), (store (s64) into %stack.6)157 $fp = frame-setup ADDXri $sp, 16, 0158 $sp = frame-setup SUBXri $sp, 80, 0159 frame-setup CFI_INSTRUCTION def_cfa $w29, 16160 frame-setup CFI_INSTRUCTION offset $w30, -8161 frame-setup CFI_INSTRUCTION offset $w29, -16162 frame-setup CFI_INSTRUCTION offset $w27, -24163 frame-setup CFI_INSTRUCTION offset $w28, -32164 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard165 $x8 = LDRXui killed $x8, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @__stack_chk_guard166 $x8 = LDRXui killed $x8, 0 :: (dereferenceable invariant load (s64) from @__stack_chk_guard)167 STURXi killed renamable $x8, $fp, -24 :: (volatile store (s64) into %stack.0.StackGuardSlot)168 STRXui $xzr, $sp, 1 :: (store (s64) into %ir.tmp3)169 STRXui $xzr, $sp, 0 :: (store (s64) into %ir.tmp4)170 renamable $x8 = LDURXi $fp, -24 :: (volatile load (s64) from %stack.0.StackGuardSlot)171 $x9 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard172 $x9 = LDRXui killed $x9, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @__stack_chk_guard173 $x9 = LDRXui killed $x9, 0 :: (dereferenceable invariant load (s64) from @__stack_chk_guard)174 $xzr = SUBSXrs killed renamable $x9, killed renamable $x8, 0, implicit-def $nzcv, implicit-def $nzcv175 Bcc 1, %bb.2, implicit $nzcv176 177 bb.1.bb:178 $sp = frame-destroy ADDXri $sp, 480, 0179 $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.7), (load (s64) from %stack.6)180 early-clobber $sp, $x28, $x27 = frame-destroy LDPXpost $sp, 4 :: (load (s64) from %stack.9), (load (s64) from %stack.8)181 RET undef $lr182 183 bb.2.bb:184 BL &__stack_chk_fail, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp185 186...187# Check we don't try to fold a 480 byte offset, even if we have a 128 byte redzone.188# CHECK-LABEL: name: with_redzone_480bytes189# CHECK-NOT: STPXpre $xzr, $xzr190---191name: with_redzone_480bytes192alignment: 4193exposesReturnsTwice: false194legalized: false195regBankSelected: false196selected: false197failedISel: false198tracksRegLiveness: true199hasWinCFI: false200registers: []201liveins: []202frameInfo:203 isFrameAddressTaken: false204 isReturnAddressTaken: false205 hasStackMap: false206 hasPatchPoint: false207 stackSize: 512208 offsetAdjustment: 0209 maxAlignment: 16210 adjustsStack: true211 hasCalls: true212 stackProtector: '%stack.0.StackGuardSlot'213 maxCallFrameSize: 0214 cvBytesOfCalleeSavedRegisters: 0215 hasOpaqueSPAdjustment: false216 hasVAStart: false217 hasMustTailInVarArgFunc: false218 localFrameSize: 480219 savePoint: []220 restorePoint: []221fixedStack: []222stack:223 - { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8, 224 alignment: 8, stack-id: default, callee-saved-register: '', callee-saved-restored: true, 225 local-offset: -8, debug-info-variable: '', debug-info-expression: '', 226 debug-info-location: '' }227 - { id: 1, name: tmp, type: default, offset: -480, size: 440, alignment: 16, 228 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 229 local-offset: -448, debug-info-variable: '', debug-info-expression: '', 230 debug-info-location: '' }231 - { id: 2, name: tmp1, type: default, offset: -488, size: 8, alignment: 8, 232 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 233 local-offset: -456, debug-info-variable: '', debug-info-expression: '', 234 debug-info-location: '' }235 - { id: 3, name: tmp2, type: default, offset: -496, size: 8, alignment: 8, 236 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 237 local-offset: -464, debug-info-variable: '', debug-info-expression: '', 238 debug-info-location: '' }239 - { id: 4, name: tmp3, type: default, offset: -504, size: 8, alignment: 8, 240 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 241 local-offset: -472, debug-info-variable: '', debug-info-expression: '', 242 debug-info-location: '' }243 - { id: 5, name: tmp4, type: default, offset: -512, size: 8, alignment: 8, 244 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 245 local-offset: -480, debug-info-variable: '', debug-info-expression: '', 246 debug-info-location: '' }247 - { id: 6, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, 248 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true, 249 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }250 - { id: 7, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, 251 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true, 252 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }253 - { id: 8, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8, 254 stack-id: default, callee-saved-register: '$x27', callee-saved-restored: true, 255 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }256 - { id: 9, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8, 257 stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true, 258 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }259callSites: []260debugValueSubstitutions: []261constants: []262body: |263 bb.0.bb:264 successors: %bb.1(0x7ffff800), %bb.2(0x00000800)265 liveins: $x27, $x28, $lr266 early-clobber $sp = frame-setup STPXpre killed $x28, killed $x27, $sp, -4 :: (store (s64) into %stack.9), (store (s64) into %stack.8)267 frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.7), (store (s64) into %stack.6)268 $fp = frame-setup ADDXri $sp, 16, 0269 $sp = frame-setup SUBXri $sp, 480, 0270 frame-setup CFI_INSTRUCTION def_cfa $w29, 16271 frame-setup CFI_INSTRUCTION offset $w30, -8272 frame-setup CFI_INSTRUCTION offset $w29, -16273 frame-setup CFI_INSTRUCTION offset $w27, -24274 frame-setup CFI_INSTRUCTION offset $w28, -32275 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard276 $x8 = LDRXui killed $x8, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @__stack_chk_guard277 $x8 = LDRXui killed $x8, 0 :: (dereferenceable invariant load (s64) from @__stack_chk_guard)278 STURXi killed renamable $x8, $fp, -24 :: (volatile store (s64) into %stack.0.StackGuardSlot)279 STRXui $xzr, $sp, 1 :: (store (s64) into %ir.tmp3)280 STRXui $xzr, $sp, 0 :: (store (s64) into %ir.tmp4)281 renamable $x8 = LDURXi $fp, -24 :: (volatile load (s64) from %stack.0.StackGuardSlot)282 $x9 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard283 $x9 = LDRXui killed $x9, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @__stack_chk_guard284 $x9 = LDRXui killed $x9, 0 :: (dereferenceable invariant load (s64) from @__stack_chk_guard)285 $xzr = SUBSXrs killed renamable $x9, killed renamable $x8, 0, implicit-def $nzcv, implicit-def $nzcv286 Bcc 1, %bb.2, implicit $nzcv287 288 bb.1.bb:289 $sp = frame-destroy ADDXri $sp, 480, 0290 $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.7), (load (s64) from %stack.6)291 early-clobber $sp, $x28, $x27 = frame-destroy LDPXpost $sp, 4 :: (load (s64) from %stack.9), (load (s64) from %stack.8)292 RET undef $lr293 294 bb.2.bb:295 BL &__stack_chk_fail, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp296 297...298# Check we still do the opt if there are no mem ops between.299# CHECK-LABEL: name: with_noredzone_no_mem_between300# CHECK: STPXpre $xzr, $xzr301---302name: with_noredzone_no_mem_between303alignment: 4304exposesReturnsTwice: false305legalized: false306regBankSelected: false307selected: false308failedISel: false309tracksRegLiveness: true310hasWinCFI: false311registers: []312liveins: []313frameInfo:314 isFrameAddressTaken: false315 isReturnAddressTaken: false316 hasStackMap: false317 hasPatchPoint: false318 stackSize: 512319 offsetAdjustment: 0320 maxAlignment: 16321 adjustsStack: true322 hasCalls: true323 stackProtector: '%stack.0.StackGuardSlot'324 maxCallFrameSize: 0325 cvBytesOfCalleeSavedRegisters: 0326 hasOpaqueSPAdjustment: false327 hasVAStart: false328 hasMustTailInVarArgFunc: false329 localFrameSize: 480330 savePoint: []331 restorePoint: []332fixedStack: []333stack:334 - { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8, 335 alignment: 8, stack-id: default, callee-saved-register: '', callee-saved-restored: true, 336 local-offset: -8, debug-info-variable: '', debug-info-expression: '', 337 debug-info-location: '' }338 - { id: 1, name: tmp, type: default, offset: -480, size: 440, alignment: 16, 339 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 340 local-offset: -448, debug-info-variable: '', debug-info-expression: '', 341 debug-info-location: '' }342 - { id: 2, name: tmp1, type: default, offset: -488, size: 8, alignment: 8, 343 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 344 local-offset: -456, debug-info-variable: '', debug-info-expression: '', 345 debug-info-location: '' }346 - { id: 3, name: tmp2, type: default, offset: -496, size: 8, alignment: 8, 347 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 348 local-offset: -464, debug-info-variable: '', debug-info-expression: '', 349 debug-info-location: '' }350 - { id: 4, name: tmp3, type: default, offset: -504, size: 8, alignment: 8, 351 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 352 local-offset: -472, debug-info-variable: '', debug-info-expression: '', 353 debug-info-location: '' }354 - { id: 5, name: tmp4, type: default, offset: -512, size: 8, alignment: 8, 355 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 356 local-offset: -480, debug-info-variable: '', debug-info-expression: '', 357 debug-info-location: '' }358 - { id: 6, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, 359 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true, 360 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }361 - { id: 7, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, 362 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true, 363 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }364 - { id: 8, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8, 365 stack-id: default, callee-saved-register: '$x27', callee-saved-restored: true, 366 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }367 - { id: 9, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8, 368 stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true, 369 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }370callSites: []371debugValueSubstitutions: []372constants: []373machineFunctionInfo:374 hasRedZone: false375body: |376 bb.0.bb:377 successors: %bb.1(0x7ffff800), %bb.2(0x00000800)378 liveins: $x27, $x28, $lr379 early-clobber $sp = frame-setup STPXpre killed $x28, killed $x27, $sp, -4 :: (store (s64) into %stack.9), (store (s64) into %stack.8)380 frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.7), (store (s64) into %stack.6)381 $fp = frame-setup ADDXri $sp, 16, 0382 $sp = frame-setup SUBXri $sp, 480, 0383 frame-setup CFI_INSTRUCTION def_cfa $w29, 16384 frame-setup CFI_INSTRUCTION offset $w30, -8385 frame-setup CFI_INSTRUCTION offset $w29, -16386 frame-setup CFI_INSTRUCTION offset $w27, -24387 frame-setup CFI_INSTRUCTION offset $w28, -32388 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard389 STRXui $xzr, $sp, 1 :: (store (s64) into %ir.tmp3)390 STRXui $xzr, $sp, 0 :: (store (s64) into %ir.tmp4)391 renamable $x8 = LDURXi $fp, -24 :: (volatile load (s64) from %stack.0.StackGuardSlot)392 $x9 = ADRP target-flags(aarch64-page, aarch64-got) @__stack_chk_guard393 $x9 = LDRXui killed $x9, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @__stack_chk_guard394 $x9 = LDRXui killed $x9, 0 :: (dereferenceable invariant load (s64) from @__stack_chk_guard)395 $xzr = SUBSXrs killed renamable $x9, killed renamable $x8, 0, implicit-def $nzcv, implicit-def $nzcv396 Bcc 1, %bb.2, implicit $nzcv397 398 bb.1.bb:399 $sp = frame-destroy ADDXri $sp, 480, 0400 $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.7), (load (s64) from %stack.6)401 early-clobber $sp, $x28, $x27 = frame-destroy LDPXpost $sp, 4 :: (load (s64) from %stack.9), (load (s64) from %stack.8)402 RET undef $lr403 404 bb.2.bb:405 BL &__stack_chk_fail, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp406 407...408