1# RUN: llc -o - %s -mtriple=aarch64-windows -start-after=prologepilog \ 2# RUN: -filetype=obj | llvm-readobj --unwind - | FileCheck %s 3 4# Check that that the large stack allocation is correctly represented in .xdata. 5 6# CHECK: ExceptionData { 7# CHECK-NEXT: FunctionLength: 156 8# CHECK-NEXT: Version: 0 9# CHECK-NEXT: ExceptionData: No 10# CHECK-NEXT: EpiloguePacked: Yes 11# CHECK-NEXT: EpilogueOffset: 11 12# CHECK-NEXT: ByteCodeLength: 24 13# CHECK-NEXT: Prologue [ 14# CHECK-NEXT: 0xe002dac9 ; sub sp, #2993296 15# CHECK-NEXT: 0xe3 ; nop 16# CHECK-NEXT: 0xe3 ; nop 17# CHECK-NEXT: 0xe3 ; nop 18# CHECK-NEXT: 0x42 ; stp x29, x30, [sp, #16] 19# CHECK-NEXT: 0xd53f ; str x28, [sp, #-256]! 20# CHECK-NEXT: 0xe4 ; end 21# CHECK-NEXT: ] 22# CHECK-NEXT: Epilogue [ 23# CHECK-NEXT: 0xe002da00 ; add sp, #2990080 24# CHECK-NEXT: 0xc0c9 ; add sp, #3216 25# CHECK-NEXT: 0x42 ; ldp x29, x30, [sp, #16] 26# CHECK-NEXT: 0xd53f ; ldr x28, [sp], #256 27# CHECK-NEXT: 0xe4 ; end 28# CHECK-NEXT: ] 29# CHECK-NEXT: } 30 31 32--- | 33 target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" 34 target triple = "aarch64-unknown-windows-msvc19.11.0" 35 36 ; Function Attrs: noinline optnone 37 define dso_local i32 @"?func@@YAHH@Z"(i32 %i) #0 { 38 entry: 39 %retval = alloca i32, align 4 40 %i.addr = alloca i32, align 4 41 %A = alloca [748193 x i32], align 4 42 %a = alloca i32, align 4 43 %B = alloca [123 x i32], align 4 44 store i32 %i, ptr %i.addr, align 4 45 %0 = load i32, ptr %i.addr, align 4 46 %add = add nsw i32 %0, 2 47 store i32 %add, ptr %a, align 4 48 %call = call i32 @"?func2@@YAHXZ"() 49 %1 = load i32, ptr %i.addr, align 4 50 %cmp = icmp sgt i32 %1, 2 51 br i1 %cmp, label %if.then, label %if.else 52 53 if.then: ; preds = %entry 54 %call1 = call i32 @"?func2@@YAHXZ"() 55 store i32 %call1, ptr %retval, align 4 56 br label %return 57 58 if.else: ; preds = %entry 59 %arraydecay = getelementptr inbounds [123 x i32], ptr %B, i32 0, i32 0 60 %call2 = call i32 @"?func3@@YAHPEAH@Z"(ptr %arraydecay) 61 store i32 %call2, ptr %retval, align 4 62 br label %return 63 64 return: ; preds = %if.else, %if.then 65 %2 = load i32, ptr %retval, align 4 66 ret i32 %2 67 } 68 69 declare dso_local i32 @"?func2@@YAHXZ"() #1 70 71 declare dso_local i32 @"?func3@@YAHPEAH@Z"(ptr) #1 72 73 ; Function Attrs: nounwind 74 declare void @llvm.stackprotector(ptr, ptr) #2 75 76 attributes #0 = { noinline optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" } 77 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" } 78 attributes #2 = { nounwind } 79 80 !llvm.module.flags = !{!0} 81 82 !0 = !{i32 1, !"wchar_size", i32 2} 83 84... 85--- 86name: '?func@@YAHH@Z' 87alignment: 4 88exposesReturnsTwice: false 89legalized: true 90regBankSelected: true 91selected: true 92failedISel: false 93tracksRegLiveness: true 94hasWinCFI: true 95registers: 96liveins: 97frameInfo: 98 isFrameAddressTaken: false 99 isReturnAddressTaken: false 100 hasStackMap: false 101 hasPatchPoint: false 102 stackSize: 2993328 103 offsetAdjustment: 0 104 maxAlignment: 16 105 adjustsStack: true 106 hasCalls: true 107 stackProtector: '' 108 maxCallFrameSize: 0 109 hasOpaqueSPAdjustment: false 110 hasVAStart: false 111 hasMustTailInVarArgFunc: false 112 localFrameSize: 2993276 113 savePoint: '' 114 restorePoint: '' 115fixedStack: 116stack: 117 - { id: 0, name: retval, type: default, offset: -36, size: 4, alignment: 4, 118 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 119 local-offset: -4, debug-info-variable: '', debug-info-expression: '', 120 debug-info-location: '' } 121 - { id: 1, name: i.addr, type: default, offset: -40, size: 4, alignment: 4, 122 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 123 local-offset: -8, debug-info-variable: '', debug-info-expression: '', 124 debug-info-location: '' } 125 - { id: 2, name: A, type: default, offset: -2992812, size: 2992772, alignment: 4, 126 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 127 local-offset: -2992780, debug-info-variable: '', debug-info-expression: '', 128 debug-info-location: '' } 129 - { id: 3, name: a, type: default, offset: -2992816, size: 4, alignment: 4, 130 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 131 local-offset: -2992784, debug-info-variable: '', debug-info-expression: '', 132 debug-info-location: '' } 133 - { id: 4, name: B, type: default, offset: -2993308, size: 492, alignment: 4, 134 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 135 local-offset: -2993276, debug-info-variable: '', debug-info-expression: '', 136 debug-info-location: '' } 137 - { id: 5, name: '', type: spill-slot, offset: -2993320, size: 8, alignment: 8, 138 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 139 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 140 - { id: 6, name: '', type: spill-slot, offset: -2993324, size: 4, alignment: 4, 141 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 142 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 143 - { id: 7, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, 144 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true, 145 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 146 - { id: 8, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, 147 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true, 148 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 149 - { id: 9, name: '', type: spill-slot, offset: -32, size: 8, alignment: 16, 150 stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true, 151 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 152constants: 153body: | 154 bb.1.entry: 155 successors: %bb.2(0x40000000), %bb.3(0x40000000) 156 liveins: $w0, $x28, $fp, $lr 157 158 early-clobber $sp = frame-setup STRXpre killed $x28, $sp, -32 :: (store (s64) into %stack.9) 159 frame-setup SEH_SaveReg_X 28, -256 160 frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.7), (store (s64) into %stack.8) 161 frame-setup SEH_SaveFPLR 16 162 $x15 = frame-setup MOVZXi 56009, 0 163 frame-setup SEH_Nop 164 $x15 = frame-setup MOVKXi $x15, 2, 16 165 frame-setup SEH_Nop 166 frame-setup BL &__chkstk, implicit-def $lr, implicit $sp, implicit $x15 167 frame-setup SEH_Nop 168 $sp = frame-setup SUBXrx64 killed $sp, killed $x15, 28 169 frame-setup SEH_StackAlloc 2993296 170 frame-setup SEH_PrologEnd 171 $x8 = ADDXri $sp, 730, 12 172 $x8 = ADDXri $x8, 3208, 0 173 renamable $w9 = MOVi32imm 2 174 STRWui killed renamable $w0, renamable $x8, 0 :: (store (s32) into %ir.i.addr) 175 renamable $w0 = LDRWui renamable $x8, 0 :: (load (s32) from %ir.i.addr) 176 renamable $w0 = ADDWri killed renamable $w0, 2, 0 177 STRWui killed renamable $w0, $sp, 128 :: (store (s32) into %ir.a) 178 STRXui killed $x8, $sp, 1 :: (store (s64) into %stack.5) 179 STRWui killed $w9, $sp, 1 :: (store (s32) into %stack.6) 180 BL @"?func2@@YAHXZ", csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit-def $w0 181 $x8 = LDRXui $sp, 1 :: (load (s64) from %stack.5) 182 renamable $w9 = LDRWui killed renamable $x8, 0 :: (load (s32) from %ir.i.addr) 183 $w10 = LDRWui $sp, 1 :: (load (s32) from %stack.6) 184 $wzr = SUBSWrr killed renamable $w9, killed renamable $w10, implicit-def $nzcv 185 renamable $w9 = CSINCWr $wzr, $wzr, 13, implicit $nzcv 186 TBNZW killed renamable $w9, 0, %bb.2 187 B %bb.3 188 189 bb.2.if.then: 190 successors: %bb.4(0x80000000) 191 192 BL @"?func2@@YAHXZ", csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit-def $w0 193 $x8 = LDRXui $sp, 1 :: (load (s64) from %stack.5) 194 STRWui killed renamable $w0, killed renamable $x8, 1 :: (store (s32) into %ir.retval) 195 B %bb.4 196 197 bb.3.if.else: 198 successors: %bb.4(0x80000000) 199 200 $x8 = ADDXri $sp, 20, 0 201 $x0 = COPY killed renamable $x8 202 BL @"?func3@@YAHPEAH@Z", csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit killed $x0, implicit-def $w0 203 $x8 = LDRXui $sp, 1 :: (load (s64) from %stack.5) 204 STRWui killed renamable $w0, killed renamable $x8, 1 :: (store (s32) into %ir.retval) 205 206 bb.4.return: 207 $x8 = LDRXui $sp, 1 :: (load (s64) from %stack.5) 208 renamable $w0 = LDRWui killed renamable $x8, 1 :: (load (s32) from %ir.retval) 209 frame-destroy SEH_EpilogStart 210 $sp = frame-destroy ADDXri $sp, 730, 12 211 frame-destroy SEH_StackAlloc 2990080 212 $sp = frame-destroy ADDXri $sp, 3216, 0 213 frame-destroy SEH_StackAlloc 3216 214 $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.7), (load (s64) from %stack.8) 215 frame-destroy SEH_SaveFPLR 16 216 early-clobber $sp, $x28 = frame-destroy LDRXpost $sp, 32 :: (load (s64) from %stack.9) 217 frame-destroy SEH_SaveReg_X 28, -256 218 frame-destroy SEH_EpilogEnd 219 RET_ReallyLR implicit killed $w0 220 221... 222