1 # RUN: llc -o - %s -mtriple=aarch64-windows -start-before=prologepilog \
2 # RUN: -stop-after=prologepilog | FileCheck %s
3 # Test that stack probe results in Nop unwind codes in the prologue. Test
4 # save_fplr, save_reg_x and stack_alloc with multiple updates
6 # CHECK: early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -2
7 # CHECK-NEXT: frame-setup SEH_SaveFPLR_X -16
8 # CHECK-NEXT: $fp = frame-setup ADDXri $sp, 0, 0
9 # CHECK-NEXT: frame-setup SEH_SetFP
10 # CHECK-NEXT: $sp = frame-setup SUBXri $sp, 32, 0
11 # CHECK-NEXT: frame-setup SEH_StackAlloc 32
12 # CHECK-NEXT: frame-setup SEH_PrologEnd
13 # CHECK: frame-destroy SEH_EpilogStart
14 # CHECK-NEXT: $sp = frame-destroy ADDXri $fp, 0, 0
15 # CHECK-NEXT: frame-destroy SEH_SetFP
16 # CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2
17 # CHECK-NEXT: frame-destroy SEH_SaveFPLR_X -16
18 # CHECK-NEXT: frame-destroy SEH_EpilogEnd
19 # CHECK-NEXT: RET_ReallyLR implicit killed $w0
21 target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
22 target triple = "aarch64-unknown-windows-msvc19.11.0"
24 ; Function Attrs: noinline optnone
25 define dso_local i32 @"?func@@YAHHHHH@Z"(i32 %n, i32 %idx, i32 %b, i32 %c) #0 {
27 %c.addr = alloca i32, align 4
28 %b.addr = alloca i32, align 4
29 %idx.addr = alloca i32, align 4
30 %n.addr = alloca i32, align 4
31 %a = alloca i32*, align 8
32 store i32 %c, i32* %c.addr, align 4
33 store i32 %b, i32* %b.addr, align 4
34 store i32 %idx, i32* %idx.addr, align 4
35 store i32 %n, i32* %n.addr, align 4
36 %0 = load i32, i32* %n.addr, align 4
37 %conv = sext i32 %0 to i64
38 %1 = alloca i8, i64 %conv, align 16
39 %2 = bitcast i8* %1 to i32*
40 store i32* %2, i32** %a, align 8
41 %3 = load i32*, i32** %a, align 8
42 call void @"?init@@YAXPEAH@Z"(i32* %3)
46 declare dso_local void @"?init@@YAXPEAH@Z"(i32*) #1
48 ; Function Attrs: nounwind
49 declare void @llvm.stackprotector(i8*, i8**) #2
51 attributes #0 = { noinline optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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" }
52 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
53 attributes #2 = { nounwind }
57 name: '?func@@YAHHHHH@Z'
59 exposesReturnsTwice: false
61 regBankSelected: false
64 tracksRegLiveness: true
68 - { reg: '$w0', virtual-reg: '' }
69 - { reg: '$w1', virtual-reg: '' }
70 - { reg: '$w2', virtual-reg: '' }
71 - { reg: '$w3', virtual-reg: '' }
73 isFrameAddressTaken: false
74 isReturnAddressTaken: false
84 cvBytesOfCalleeSavedRegisters: 0
85 hasOpaqueSPAdjustment: false
87 hasMustTailInVarArgFunc: false
93 - { id: 0, name: c.addr, type: default, offset: 0, size: 4, alignment: 4,
94 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
95 local-offset: -4, debug-info-variable: '', debug-info-expression: '',
96 debug-info-location: '' }
97 - { id: 1, name: b.addr, type: default, offset: 0, size: 4, alignment: 4,
98 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
99 local-offset: -8, debug-info-variable: '', debug-info-expression: '',
100 debug-info-location: '' }
101 - { id: 2, name: idx.addr, type: default, offset: 0, size: 4, alignment: 4,
102 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
103 local-offset: -12, debug-info-variable: '', debug-info-expression: '',
104 debug-info-location: '' }
105 - { id: 3, name: n.addr, type: default, offset: 0, size: 4, alignment: 4,
106 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
107 local-offset: -16, debug-info-variable: '', debug-info-expression: '',
108 debug-info-location: '' }
109 - { id: 4, name: a, type: default, offset: 0, size: 8, alignment: 8,
110 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
111 local-offset: -24, debug-info-variable: '', debug-info-expression: '',
112 debug-info-location: '' }
113 - { id: 5, name: '', type: variable-sized, offset: 0,
114 alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
115 local-offset: -24, debug-info-variable: '', debug-info-expression: '',
116 debug-info-location: '' }
117 - { id: 6, name: '', type: spill-slot, offset: 0, size: 8, alignment: 8,
118 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
119 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
123 liveins: $w0, $w1, $w2, $w3
125 STRWui killed renamable $w3, %stack.0.c.addr, 0 :: (store 4 into %ir.c.addr)
126 STRWui killed renamable $w2, %stack.1.b.addr, 0 :: (store 4 into %ir.b.addr)
127 STRWui killed renamable $w1, %stack.2.idx.addr, 0 :: (store 4 into %ir.idx.addr)
128 STRWui killed renamable $w0, %stack.3.n.addr, 0 :: (store 4 into %ir.n.addr)
129 renamable $x8 = LDRSWui %stack.3.n.addr, 0 :: (dereferenceable load 4 from %ir.n.addr)
130 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
131 renamable $x8 = nuw ADDXri killed renamable $x8, 15, 0
132 renamable $x8 = UBFMXri killed renamable $x8, 4, 63
133 $x15 = COPY renamable $x8
134 STRXui killed $x8, %stack.6, 0 :: (store 8 into %stack.6)
135 BL &__chkstk, csr_aarch64_stackprobe_windows, implicit-def dead $lr, implicit $sp, implicit killed $x15
136 renamable $x8 = COPY $sp
137 $x15 = LDRXui %stack.6, 0 :: (load 8 from %stack.6)
138 renamable $x8 = SUBSXrs killed renamable $x8, killed renamable $x15, 4, implicit-def dead $nzcv
139 $sp = COPY renamable $x8
140 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
141 STRXui killed renamable $x8, %stack.4.a, 0 :: (store 8 into %ir.a)
142 renamable $x0 = LDRXui %stack.4.a, 0 :: (dereferenceable load 8 from %ir.a)
143 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
144 BL @"?init@@YAXPEAH@Z", csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $x0, implicit-def $sp
145 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
146 renamable $w1 = COPY $wzr
147 $w0 = COPY killed renamable $w1
148 RET_ReallyLR implicit killed $w0