xref: /llvm-project/llvm/test/CodeGen/AArch64/wineh-frame6.mir (revision 1ee315ae7964c8433b772e0b5d667834994ba753)
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
5
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: frame-setup SEH_PrologEnd
11# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 32, 0
12# CHECK:      frame-destroy SEH_EpilogStart
13# CHECK-NEXT: $sp = frame-destroy ADDXri $fp, 0, 0
14# CHECK-NEXT: frame-destroy SEH_SetFP
15# CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2
16# CHECK-NEXT: frame-destroy SEH_SaveFPLR_X -16
17# CHECK-NEXT: frame-destroy SEH_EpilogEnd
18# CHECK-NEXT: RET_ReallyLR implicit killed $w0
19--- |
20  target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
21  target triple = "aarch64-unknown-windows-msvc19.11.0"
22
23  ; Function Attrs: noinline optnone
24  define dso_local i32 @"?func@@YAHHHHH@Z"(i32 %n, i32 %idx, i32 %b, i32 %c) #0 {
25  entry:
26    %c.addr = alloca i32, align 4
27    %b.addr = alloca i32, align 4
28    %idx.addr = alloca i32, align 4
29    %n.addr = alloca i32, align 4
30    %a = alloca ptr, align 8
31    store i32 %c, ptr %c.addr, align 4
32    store i32 %b, ptr %b.addr, align 4
33    store i32 %idx, ptr %idx.addr, align 4
34    store i32 %n, ptr %n.addr, align 4
35    %0 = load i32, ptr %n.addr, align 4
36    %conv = sext i32 %0 to i64
37    %1 = alloca i8, i64 %conv, align 16
38    %2 = bitcast ptr %1 to ptr
39    store ptr %2, ptr %a, align 8
40    %3 = load ptr, ptr %a, align 8
41    call void @"?init@@YAXPEAH@Z"(ptr %3)
42    ret i32 0
43  }
44
45  declare dso_local void @"?init@@YAXPEAH@Z"(ptr) #1
46
47  ; Function Attrs: nounwind
48  declare void @llvm.stackprotector(ptr, ptr) #2
49
50  attributes #0 = { noinline optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
51  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" }
52  attributes #2 = { nounwind }
53
54...
55---
56name:            '?func@@YAHHHHH@Z'
57alignment:       4
58exposesReturnsTwice: false
59legalized:       false
60regBankSelected: false
61selected:        false
62failedISel:      false
63tracksRegLiveness: true
64hasWinCFI:       false
65registers:
66liveins:
67  - { reg: '$w0', virtual-reg: '' }
68  - { reg: '$w1', virtual-reg: '' }
69  - { reg: '$w2', virtual-reg: '' }
70  - { reg: '$w3', virtual-reg: '' }
71frameInfo:
72  isFrameAddressTaken: false
73  isReturnAddressTaken: false
74  hasStackMap:     false
75  hasPatchPoint:   false
76  stackSize:       0
77  offsetAdjustment: 0
78  maxAlignment:    8
79  adjustsStack:    true
80  hasCalls:        true
81  stackProtector:  ''
82  maxCallFrameSize: 0
83  cvBytesOfCalleeSavedRegisters: 0
84  hasOpaqueSPAdjustment: false
85  hasVAStart:      false
86  hasMustTailInVarArgFunc: false
87  localFrameSize:  24
88  savePoint:       ''
89  restorePoint:    ''
90fixedStack:
91stack:
92  - { id: 0, name: c.addr, type: default, offset: 0, size: 4, alignment: 4,
93      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
94      local-offset: -4, debug-info-variable: '', debug-info-expression: '',
95      debug-info-location: '' }
96  - { id: 1, name: b.addr, type: default, offset: 0, size: 4, alignment: 4,
97      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
98      local-offset: -8, debug-info-variable: '', debug-info-expression: '',
99      debug-info-location: '' }
100  - { id: 2, name: idx.addr, type: default, offset: 0, size: 4, alignment: 4,
101      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
102      local-offset: -12, debug-info-variable: '', debug-info-expression: '',
103      debug-info-location: '' }
104  - { id: 3, name: n.addr, type: default, offset: 0, size: 4, alignment: 4,
105      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
106      local-offset: -16, debug-info-variable: '', debug-info-expression: '',
107      debug-info-location: '' }
108  - { id: 4, name: a, type: default, offset: 0, size: 8, alignment: 8,
109      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
110      local-offset: -24, debug-info-variable: '', debug-info-expression: '',
111      debug-info-location: '' }
112  - { id: 5, name: '', type: variable-sized, offset: 0,
113      alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
114      local-offset: -24, debug-info-variable: '', debug-info-expression: '',
115      debug-info-location: '' }
116  - { id: 6, name: '', type: spill-slot, offset: 0, size: 8, alignment: 8,
117      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
118      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
119constants:
120body:             |
121  bb.0.entry:
122    liveins: $w0, $w1, $w2, $w3
123
124    STRWui killed renamable $w3, %stack.0.c.addr, 0 :: (store (s32) into %ir.c.addr)
125    STRWui killed renamable $w2, %stack.1.b.addr, 0 :: (store (s32) into %ir.b.addr)
126    STRWui killed renamable $w1, %stack.2.idx.addr, 0 :: (store (s32) into %ir.idx.addr)
127    STRWui killed renamable $w0, %stack.3.n.addr, 0 :: (store (s32) into %ir.n.addr)
128    renamable $x8 = LDRSWui %stack.3.n.addr, 0 :: (dereferenceable load (s32) from %ir.n.addr)
129    ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
130    renamable $x8 = nuw ADDXri killed renamable $x8, 15, 0
131    renamable $x8 = UBFMXri killed renamable $x8, 4, 63
132    $x15 = COPY renamable $x8
133    STRXui killed $x8, %stack.6, 0 :: (store (s64) into %stack.6)
134    BL &__chkstk, csr_aarch64_stackprobe_windows, implicit-def dead $lr, implicit $sp, implicit killed $x15
135    renamable $x8 = COPY $sp
136    $x15 = LDRXui %stack.6, 0 :: (load (s64) from %stack.6)
137    renamable $x8 = SUBSXrs killed renamable $x8, killed renamable $x15, 4, implicit-def dead $nzcv
138    $sp = COPY renamable $x8
139    ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
140    STRXui killed renamable $x8, %stack.4.a, 0 :: (store (s64) into %ir.a)
141    renamable $x0 = LDRXui %stack.4.a, 0 :: (dereferenceable load (s64) from %ir.a)
142    ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
143    BL @"?init@@YAXPEAH@Z", csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $x0, implicit-def $sp
144    ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
145    renamable $w1 = COPY $wzr
146    $w0 = COPY killed renamable $w1
147    RET_ReallyLR implicit killed $w0
148
149...
150