xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/aarch64-dynamic-stack-layout.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -disable-post-ra < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -mtriple=arm64-apple-ios -disable-fp-elim -disable-post-ra < %s | FileCheck %s --check-prefix=CHECK-MACHO
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; This test aims to check basic correctness of frame layout &
5*9880d681SAndroid Build Coastguard Worker; frame access code. There are 8 functions in this test file,
6*9880d681SAndroid Build Coastguard Worker; each function implements one element in the cartesian product
7*9880d681SAndroid Build Coastguard Worker; of:
8*9880d681SAndroid Build Coastguard Worker; . a function having a VLA/noVLA
9*9880d681SAndroid Build Coastguard Worker; . a function with dynamic stack realignment/no dynamic stack realignment.
10*9880d681SAndroid Build Coastguard Worker; . a function needing a frame pionter/no frame pointer,
11*9880d681SAndroid Build Coastguard Worker; since the presence/absence of these has influence on the frame
12*9880d681SAndroid Build Coastguard Worker; layout and which pointer to use to access various part of the
13*9880d681SAndroid Build Coastguard Worker; frame (bp,sp,fp).
14*9880d681SAndroid Build Coastguard Worker;
15*9880d681SAndroid Build Coastguard Worker; Furthermore: in every test function:
16*9880d681SAndroid Build Coastguard Worker; . there is always one integer and 1 floating point argument to be able
17*9880d681SAndroid Build Coastguard Worker;   to check those are accessed correctly.
18*9880d681SAndroid Build Coastguard Worker; . there is always one local variable to check that is accessed
19*9880d681SAndroid Build Coastguard Worker;   correctly
20*9880d681SAndroid Build Coastguard Worker;
21*9880d681SAndroid Build Coastguard Worker; The LLVM-IR below was produced by clang on the following C++ code:
22*9880d681SAndroid Build Coastguard Worker;extern "C" int g();
23*9880d681SAndroid Build Coastguard Worker;extern "C" int novla_nodynamicrealign_call(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
24*9880d681SAndroid Build Coastguard Worker;                                             double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
25*9880d681SAndroid Build Coastguard Worker;{
26*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
27*9880d681SAndroid Build Coastguard Worker;  volatile int l1;
28*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + g();
29*9880d681SAndroid Build Coastguard Worker;}
30*9880d681SAndroid Build Coastguard Worker;extern "C" int novla_nodynamicrealign_nocall(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
31*9880d681SAndroid Build Coastguard Worker;                                             double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
32*9880d681SAndroid Build Coastguard Worker;{
33*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
34*9880d681SAndroid Build Coastguard Worker;  volatile int l1;
35*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1;
36*9880d681SAndroid Build Coastguard Worker;}
37*9880d681SAndroid Build Coastguard Worker;extern "C" int novla_dynamicrealign_call(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
38*9880d681SAndroid Build Coastguard Worker;                                         double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
39*9880d681SAndroid Build Coastguard Worker;{
40*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
41*9880d681SAndroid Build Coastguard Worker;  alignas(128) volatile int l1;
42*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + g();
43*9880d681SAndroid Build Coastguard Worker;}
44*9880d681SAndroid Build Coastguard Worker;extern "C" int novla_dynamicrealign_nocall(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
45*9880d681SAndroid Build Coastguard Worker;                                           double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
46*9880d681SAndroid Build Coastguard Worker;{
47*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
48*9880d681SAndroid Build Coastguard Worker;  alignas(128) volatile int l1;
49*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1;
50*9880d681SAndroid Build Coastguard Worker;}
51*9880d681SAndroid Build Coastguard Worker;
52*9880d681SAndroid Build Coastguard Worker;extern "C" int vla_nodynamicrealign_call(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
53*9880d681SAndroid Build Coastguard Worker;                                         double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
54*9880d681SAndroid Build Coastguard Worker;{
55*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
56*9880d681SAndroid Build Coastguard Worker;  volatile int l1;
57*9880d681SAndroid Build Coastguard Worker;  volatile int vla[i1];
58*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + g() + vla[0];
59*9880d681SAndroid Build Coastguard Worker;}
60*9880d681SAndroid Build Coastguard Worker;extern "C" int vla_nodynamicrealign_nocall(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
61*9880d681SAndroid Build Coastguard Worker;                                           double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
62*9880d681SAndroid Build Coastguard Worker;{
63*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
64*9880d681SAndroid Build Coastguard Worker;  volatile int l1;
65*9880d681SAndroid Build Coastguard Worker;  volatile int vla[i1];
66*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + vla[0];
67*9880d681SAndroid Build Coastguard Worker;}
68*9880d681SAndroid Build Coastguard Worker;extern "C" int vla_dynamicrealign_call(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
69*9880d681SAndroid Build Coastguard Worker;                                       double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
70*9880d681SAndroid Build Coastguard Worker;{
71*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
72*9880d681SAndroid Build Coastguard Worker;  alignas(128) volatile int l1;
73*9880d681SAndroid Build Coastguard Worker;  volatile int vla[i1];
74*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + g() + vla[0];
75*9880d681SAndroid Build Coastguard Worker;}
76*9880d681SAndroid Build Coastguard Worker;extern "C" int vla_dynamicrealign_nocall(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
77*9880d681SAndroid Build Coastguard Worker;                                         double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
78*9880d681SAndroid Build Coastguard Worker;{
79*9880d681SAndroid Build Coastguard Worker;  // use an argument passed on the stack.
80*9880d681SAndroid Build Coastguard Worker;  alignas(128) volatile int l1;
81*9880d681SAndroid Build Coastguard Worker;  volatile int vla[i1];
82*9880d681SAndroid Build Coastguard Worker;  return i10 + (int)d10 + l1 + vla[0];
83*9880d681SAndroid Build Coastguard Worker;}
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Workerdefine i32 @novla_nodynamicrealign_call(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #0 {
88*9880d681SAndroid Build Coastguard Workerentry:
89*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 4
90*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
91*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
92*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 4
93*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
94*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @g()
95*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %call
96*9880d681SAndroid Build Coastguard Worker  ret i32 %add2
97*9880d681SAndroid Build Coastguard Worker}
98*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: novla_nodynamicrealign_call
99*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_startproc
100*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
101*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, sp, #32
102*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x19, x30, [sp, #16]
103*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
104*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 32
105*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w30, -8
106*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w19, -16
107*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through stack pointer
108*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [sp, #56]
109*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [sp, #40]
110*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through stack pointer
111*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [sp, #12]
112*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
113*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x19, x30, [sp, #16]
114*9880d681SAndroid Build Coastguard Worker; CHECK: ret
115*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_endproc
116*9880d681SAndroid Build Coastguard Worker
117*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO-LABEL: _novla_nodynamicrealign_call:
118*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_startproc
119*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
120*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	sp, sp, #48
121*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x20, x19, [sp, #16]
122*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
123*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x29, x30, [sp, #32]
124*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x29, sp, #32
125*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
126*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_def_cfa w29, 16
127*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w30, -8
128*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w29, -16
129*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w19, -24
130*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w20, -32
131*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
132*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	d[[DARG:[0-9]+]], [x29, #32]
133*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[IARG:[0-9]+]], [x29, #20]
134*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through stack pointer
135*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[ILOC:[0-9]+]], [sp, #12]
136*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
137*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x29, x30, [sp, #32]
138*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x20, x19, [sp, #16]
139*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ret
140*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_endproc
141*9880d681SAndroid Build Coastguard Worker
142*9880d681SAndroid Build Coastguard Worker
143*9880d681SAndroid Build Coastguard Workerdeclare i32 @g() #0
144*9880d681SAndroid Build Coastguard Worker
145*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
146*9880d681SAndroid Build Coastguard Workerdefine i32 @novla_nodynamicrealign_nocall(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #1 {
147*9880d681SAndroid Build Coastguard Workerentry:
148*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 4
149*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
150*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
151*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 4
152*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
153*9880d681SAndroid Build Coastguard Worker  ret i32 %add1
154*9880d681SAndroid Build Coastguard Worker}
155*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: novla_nodynamicrealign_nocall
156*9880d681SAndroid Build Coastguard Worker;   Check that space is reserved for one local variable on the stack.
157*9880d681SAndroid Build Coastguard Worker; CHECK:	sub	sp, sp, #16             // =16
158*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through stack pointer
159*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [sp, #40]
160*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [sp, #24]
161*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through stack pointer
162*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [sp, #12]
163*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
164*9880d681SAndroid Build Coastguard Worker; CHECK: add	sp, sp, #16             // =16
165*9880d681SAndroid Build Coastguard Worker; CHECK: ret
166*9880d681SAndroid Build Coastguard Worker
167*9880d681SAndroid Build Coastguard Worker
168*9880d681SAndroid Build Coastguard Workerdefine i32 @novla_dynamicrealign_call(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #0 {
169*9880d681SAndroid Build Coastguard Workerentry:
170*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 128
171*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
172*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
173*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 128
174*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
175*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @g()
176*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %call
177*9880d681SAndroid Build Coastguard Worker  ret i32 %add2
178*9880d681SAndroid Build Coastguard Worker}
179*9880d681SAndroid Build Coastguard Worker
180*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: novla_dynamicrealign_call
181*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_startproc
182*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
183*9880d681SAndroid Build Coastguard Worker; CHECK: str	x19, [sp, #-32]!
184*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
185*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #16]
186*9880d681SAndroid Build Coastguard Worker; CHECK: add	x29, sp, #16
187*9880d681SAndroid Build Coastguard Worker;   Check the dynamic realignment of the stack pointer to a 128-byte boundary
188*9880d681SAndroid Build Coastguard Worker; CHECK: sub	x9, sp, #96
189*9880d681SAndroid Build Coastguard Worker; CHECK: and	sp, x9, #0xffffffffffffff80
190*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
191*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa w29, 16
192*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w30, -8
193*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w29, -16
194*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w19, -32
195*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
196*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
197*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
198*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through re-aligned stack pointer
199*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [sp]
200*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
201*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
202*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, x29, #16            // =16
203*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp, #16]
204*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	x19, [sp], #32
205*9880d681SAndroid Build Coastguard Worker; CHECK: ret
206*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_endproc
207*9880d681SAndroid Build Coastguard Worker
208*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO-LABEL: _novla_dynamicrealign_call:
209*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_startproc
210*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
211*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x20, x19, [sp, #-32]!
212*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
213*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x29, x30, [sp, #16]
214*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x29, sp, #16
215*9880d681SAndroid Build Coastguard Worker;   Check the dynamic realignment of the stack pointer to a 128-byte boundary
216*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	x9, sp, #96
217*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	sp, x9, #0xffffffffffffff80
218*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
219*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_def_cfa w29, 16
220*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w30, -8
221*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w29, -16
222*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w19, -24
223*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w20, -32
224*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
225*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	d[[DARG:[0-9]+]], [x29, #32]
226*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[IARG:[0-9]+]], [x29, #20]
227*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through re-aligned stack pointer
228*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[ILOC:[0-9]+]], [sp]
229*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
230*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
231*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	sp, x29, #16
232*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x29, x30, [sp, #16]
233*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x20, x19, [sp], #32
234*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ret
235*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_endproc
236*9880d681SAndroid Build Coastguard Worker
237*9880d681SAndroid Build Coastguard Worker
238*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
239*9880d681SAndroid Build Coastguard Workerdefine i32 @novla_dynamicrealign_nocall(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #1 {
240*9880d681SAndroid Build Coastguard Workerentry:
241*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 128
242*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
243*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
244*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 128
245*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
246*9880d681SAndroid Build Coastguard Worker  ret i32 %add1
247*9880d681SAndroid Build Coastguard Worker}
248*9880d681SAndroid Build Coastguard Worker
249*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: novla_dynamicrealign_nocall
250*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
251*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #-16]!
252*9880d681SAndroid Build Coastguard Worker; CHECK: mov	x29, sp
253*9880d681SAndroid Build Coastguard Worker;   Check the dynamic realignment of the stack pointer to a 128-byte boundary
254*9880d681SAndroid Build Coastguard Worker; CHECK: sub	x9, sp, #112
255*9880d681SAndroid Build Coastguard Worker; CHECK: and	sp, x9, #0xffffffffffffff80
256*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
257*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
258*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
259*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable on the stack, through re-aligned stack pointer
260*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [sp]
261*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
262*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
263*9880d681SAndroid Build Coastguard Worker; CHECK: mov	sp, x29
264*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp], #16
265*9880d681SAndroid Build Coastguard Worker; CHECK: ret
266*9880d681SAndroid Build Coastguard Worker
267*9880d681SAndroid Build Coastguard Worker
268*9880d681SAndroid Build Coastguard Workerdefine i32 @vla_nodynamicrealign_call(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #0 {
269*9880d681SAndroid Build Coastguard Workerentry:
270*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 4
271*9880d681SAndroid Build Coastguard Worker  %0 = zext i32 %i1 to i64
272*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %0, align 4
273*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
274*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
275*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 4
276*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
277*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @g()
278*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %call
279*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i32, i32* %vla, align 4, !tbaa !1
280*9880d681SAndroid Build Coastguard Worker  %add3 = add nsw i32 %add2, %1
281*9880d681SAndroid Build Coastguard Worker  ret i32 %add3
282*9880d681SAndroid Build Coastguard Worker}
283*9880d681SAndroid Build Coastguard Worker
284*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vla_nodynamicrealign_call
285*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_startproc
286*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
287*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x20, x19, [sp, #-32]!
288*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
289*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #16]
290*9880d681SAndroid Build Coastguard Worker; CHECK: add	x29, sp, #16
291*9880d681SAndroid Build Coastguard Worker;   Check that space is reserved on the stack for the local variable,
292*9880d681SAndroid Build Coastguard Worker;   rounded up to a multiple of 16 to keep the stack pointer 16-byte aligned.
293*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, sp, #16
294*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
295*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa w29, 16
296*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w30, -8
297*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w29, -16
298*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w19, -24
299*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w20, -32
300*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
301*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
302*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
303*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
304*9880d681SAndroid Build Coastguard Worker; CHECK: mov	w9, w0
305*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 x10, sp
306*9880d681SAndroid Build Coastguard Worker; CHECK: lsl	x9, x9, #2
307*9880d681SAndroid Build Coastguard Worker; CHECK: add	x9, x9, #15
308*9880d681SAndroid Build Coastguard Worker; CHECK: and	x9, x9, #0x7fffffff0
309*9880d681SAndroid Build Coastguard Worker; CHECK: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
310*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 sp, x[[VLASPTMP]]
311*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through frame pointer
312*9880d681SAndroid Build Coastguard Worker; CHECK: ldur	w[[ILOC:[0-9]+]], [x29, #-20]
313*9880d681SAndroid Build Coastguard Worker;   Check correct accessing of the VLA variable through the base pointer
314*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
315*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
316*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
317*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, x29, #16            // =16
318*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp, #16]
319*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x20, x19, [sp], #32
320*9880d681SAndroid Build Coastguard Worker; CHECK: ret
321*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_endproc
322*9880d681SAndroid Build Coastguard Worker
323*9880d681SAndroid Build Coastguard Worker
324*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
325*9880d681SAndroid Build Coastguard Workerdefine i32 @vla_nodynamicrealign_nocall(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #1 {
326*9880d681SAndroid Build Coastguard Workerentry:
327*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 4
328*9880d681SAndroid Build Coastguard Worker  %0 = zext i32 %i1 to i64
329*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %0, align 4
330*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
331*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
332*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 4
333*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
334*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i32, i32* %vla, align 4, !tbaa !1
335*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %1
336*9880d681SAndroid Build Coastguard Worker  ret i32 %add2
337*9880d681SAndroid Build Coastguard Worker}
338*9880d681SAndroid Build Coastguard Worker
339*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vla_nodynamicrealign_nocall
340*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
341*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #-16]!
342*9880d681SAndroid Build Coastguard Worker; CHECK: mov	x29, sp
343*9880d681SAndroid Build Coastguard Worker;   Check that space is reserved on the stack for the local variable,
344*9880d681SAndroid Build Coastguard Worker;   rounded up to a multiple of 16 to keep the stack pointer 16-byte aligned.
345*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, sp, #16
346*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
347*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
348*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
349*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
350*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
351*9880d681SAndroid Build Coastguard Worker; CHECK: mov	w9, w0
352*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 x10, sp
353*9880d681SAndroid Build Coastguard Worker; CHECK: lsl	x9, x9, #2
354*9880d681SAndroid Build Coastguard Worker; CHECK: add	x9, x9, #15
355*9880d681SAndroid Build Coastguard Worker; CHECK: and	x9, x9, #0x7fffffff0
356*9880d681SAndroid Build Coastguard Worker; CHECK: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
357*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 sp, x[[VLASPTMP]]
358*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through frame pointer
359*9880d681SAndroid Build Coastguard Worker; CHECK: ldur	w[[ILOC:[0-9]+]], [x29, #-4]
360*9880d681SAndroid Build Coastguard Worker;   Check correct accessing of the VLA variable through the base pointer
361*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
362*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
363*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
364*9880d681SAndroid Build Coastguard Worker; CHECK: mov    sp, x29
365*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp], #16
366*9880d681SAndroid Build Coastguard Worker; CHECK: ret
367*9880d681SAndroid Build Coastguard Worker
368*9880d681SAndroid Build Coastguard Worker
369*9880d681SAndroid Build Coastguard Workerdefine i32 @vla_dynamicrealign_call(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #0 {
370*9880d681SAndroid Build Coastguard Workerentry:
371*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 128
372*9880d681SAndroid Build Coastguard Worker  %0 = zext i32 %i1 to i64
373*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %0, align 4
374*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
375*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
376*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 128
377*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
378*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @g()
379*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %call
380*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i32, i32* %vla, align 4, !tbaa !1
381*9880d681SAndroid Build Coastguard Worker  %add3 = add nsw i32 %add2, %1
382*9880d681SAndroid Build Coastguard Worker  ret i32 %add3
383*9880d681SAndroid Build Coastguard Worker}
384*9880d681SAndroid Build Coastguard Worker
385*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vla_dynamicrealign_call
386*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_startproc
387*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
388*9880d681SAndroid Build Coastguard Worker; CHECK: str	x21, [sp, #-48]!
389*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x20, x19, [sp, #16]
390*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
391*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #32]
392*9880d681SAndroid Build Coastguard Worker; CHECK: add	x29, sp, #32
393*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
394*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
395*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
396*9880d681SAndroid Build Coastguard Worker;   spill slots
397*9880d681SAndroid Build Coastguard Worker; CHECK: sub	x9, sp, #80            // =80
398*9880d681SAndroid Build Coastguard Worker; CHECK: and	sp, x9, #0xffffffffffffff80
399*9880d681SAndroid Build Coastguard Worker; CHECK: mov    x19, sp
400*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
401*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa w29, 16
402*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w30, -8
403*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w29, -16
404*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w19, -24
405*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w20, -32
406*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset w21, -48
407*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
408*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
409*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
410*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
411*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
412*9880d681SAndroid Build Coastguard Worker; CHECK: mov	w9, w0
413*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 x10, sp
414*9880d681SAndroid Build Coastguard Worker; CHECK: lsl	x9, x9, #2
415*9880d681SAndroid Build Coastguard Worker; CHECK: add	x9, x9, #15
416*9880d681SAndroid Build Coastguard Worker; CHECK: and	x9, x9, #0x7fffffff0
417*9880d681SAndroid Build Coastguard Worker; CHECK: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
418*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 sp, x[[VLASPTMP]]
419*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
420*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [x19]
421*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
422*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
423*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
424*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, x29, #32
425*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp, #32]
426*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x20, x19, [sp, #16]
427*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	x21, [sp], #48
428*9880d681SAndroid Build Coastguard Worker; CHECK: ret
429*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_endproc
430*9880d681SAndroid Build Coastguard Worker
431*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO-LABEL: _vla_dynamicrealign_call:
432*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_startproc
433*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
434*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x22, x21, [sp, #-48]!
435*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x20, x19, [sp, #16]
436*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
437*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x29, x30, [sp, #32]
438*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x29, sp, #32
439*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
440*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
441*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
442*9880d681SAndroid Build Coastguard Worker;   spill slots
443*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	x9, sp, #80
444*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	sp, x9, #0xffffffffffffff80
445*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov    x19, sp
446*9880d681SAndroid Build Coastguard Worker;   Check correctness of cfi pseudo-instructions
447*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_def_cfa w29, 16
448*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w30, -8
449*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w29, -16
450*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w19, -24
451*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w20, -32
452*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w21, -40
453*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_offset w22, -48
454*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
455*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[IARG:[0-9]+]], [x29, #20]
456*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	d[[DARG:[0-9]+]], [x29, #32]
457*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
458*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
459*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	w9, w0
460*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 x10, sp
461*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: lsl	x9, x9, #2
462*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x9, x9, #15
463*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	x9, x9, #0x7fffffff0
464*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
465*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 sp, x[[VLASPTMP]]
466*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
467*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[ILOC:[0-9]+]], [x19]
468*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
469*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
470*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
471*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	sp, x29, #32
472*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x29, x30, [sp, #32]
473*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x20, x19, [sp, #16]
474*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x22, x21, [sp], #48
475*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ret
476*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: .cfi_endproc
477*9880d681SAndroid Build Coastguard Worker
478*9880d681SAndroid Build Coastguard Worker
479*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
480*9880d681SAndroid Build Coastguard Workerdefine i32 @vla_dynamicrealign_nocall(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #1 {
481*9880d681SAndroid Build Coastguard Workerentry:
482*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 128
483*9880d681SAndroid Build Coastguard Worker  %0 = zext i32 %i1 to i64
484*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %0, align 4
485*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
486*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
487*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 128
488*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
489*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i32, i32* %vla, align 4, !tbaa !1
490*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %1
491*9880d681SAndroid Build Coastguard Worker  ret i32 %add2
492*9880d681SAndroid Build Coastguard Worker}
493*9880d681SAndroid Build Coastguard Worker
494*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vla_dynamicrealign_nocall
495*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
496*9880d681SAndroid Build Coastguard Worker; CHECK: str	x19, [sp, #-32]!
497*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
498*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #16]
499*9880d681SAndroid Build Coastguard Worker; CHECK: add	x29, sp, #16
500*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
501*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
502*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
503*9880d681SAndroid Build Coastguard Worker;   spill slots
504*9880d681SAndroid Build Coastguard Worker; CHECK: sub	x9, sp, #96
505*9880d681SAndroid Build Coastguard Worker; CHECK: and	sp, x9, #0xffffffffffffff80
506*9880d681SAndroid Build Coastguard Worker; CHECK: mov    x19, sp
507*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
508*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
509*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
510*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
511*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
512*9880d681SAndroid Build Coastguard Worker; CHECK: mov	w9, w0
513*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 x10, sp
514*9880d681SAndroid Build Coastguard Worker; CHECK: lsl	x9, x9, #2
515*9880d681SAndroid Build Coastguard Worker; CHECK: add	x9, x9, #15
516*9880d681SAndroid Build Coastguard Worker; CHECK: and	x9, x9, #0x7fffffff0
517*9880d681SAndroid Build Coastguard Worker; CHECK: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
518*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 sp, x[[VLASPTMP]]
519*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
520*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [x19]
521*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
522*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
523*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
524*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, x29, #16
525*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp, #16]
526*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	x19, [sp], #32
527*9880d681SAndroid Build Coastguard Worker; CHECK: ret
528*9880d681SAndroid Build Coastguard Worker
529*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO-LABEL: _vla_dynamicrealign_nocall:
530*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
531*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x20, x19, [sp, #-32]!
532*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
533*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x29, x30, [sp, #16]
534*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x29, sp, #16
535*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
536*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
537*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
538*9880d681SAndroid Build Coastguard Worker;   spill slots
539*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	x9, sp, #96
540*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	sp, x9, #0xffffffffffffff80
541*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov    x19, sp
542*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
543*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[IARG:[0-9]+]], [x29, #20]
544*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	d[[DARG:[0-9]+]], [x29, #32]
545*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
546*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
547*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	w9, w0
548*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 x10, sp
549*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: lsl	x9, x9, #2
550*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x9, x9, #15
551*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	x9, x9, #0x7fffffff0
552*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
553*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 sp, x[[VLASPTMP]]
554*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
555*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[ILOC:[0-9]+]], [x19]
556*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
557*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
558*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
559*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	sp, x29, #16
560*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x29, x30, [sp, #16]
561*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x20, x19, [sp], #32
562*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ret
563*9880d681SAndroid Build Coastguard Worker
564*9880d681SAndroid Build Coastguard Worker
565*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
566*9880d681SAndroid Build Coastguard Workerdefine i32 @vla_dynamicrealign_nocall_large_align(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, i32 %i10, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, double %d8, double %d9, double %d10) #1 {
567*9880d681SAndroid Build Coastguard Workerentry:
568*9880d681SAndroid Build Coastguard Worker  %l1 = alloca i32, align 32768
569*9880d681SAndroid Build Coastguard Worker  %0 = zext i32 %i1 to i64
570*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %0, align 4
571*9880d681SAndroid Build Coastguard Worker  %conv = fptosi double %d10 to i32
572*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %conv, %i10
573*9880d681SAndroid Build Coastguard Worker  %l1.0.l1.0. = load volatile i32, i32* %l1, align 32768
574*9880d681SAndroid Build Coastguard Worker  %add1 = add nsw i32 %add, %l1.0.l1.0.
575*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i32, i32* %vla, align 4, !tbaa !1
576*9880d681SAndroid Build Coastguard Worker  %add2 = add nsw i32 %add1, %1
577*9880d681SAndroid Build Coastguard Worker  ret i32 %add2
578*9880d681SAndroid Build Coastguard Worker}
579*9880d681SAndroid Build Coastguard Worker
580*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vla_dynamicrealign_nocall_large_align
581*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
582*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x28, x19, [sp, #-32]!
583*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
584*9880d681SAndroid Build Coastguard Worker; CHECK: stp	x29, x30, [sp, #16]
585*9880d681SAndroid Build Coastguard Worker; CHECK: add	x29, sp, #16
586*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
587*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
588*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
589*9880d681SAndroid Build Coastguard Worker;   spill slots
590*9880d681SAndroid Build Coastguard Worker; CHECK: sub	x9, sp, #7, lsl #12
591*9880d681SAndroid Build Coastguard Worker; CHECK: and	sp, x9, #0xffffffffffff8000
592*9880d681SAndroid Build Coastguard Worker; CHECK: mov    x19, sp
593*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
594*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[IARG:[0-9]+]], [x29, #24]
595*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	d[[DARG:[0-9]+]], [x29, #40]
596*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
597*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
598*9880d681SAndroid Build Coastguard Worker; CHECK: mov	w9, w0
599*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 x10, sp
600*9880d681SAndroid Build Coastguard Worker; CHECK: lsl	x9, x9, #2
601*9880d681SAndroid Build Coastguard Worker; CHECK: add	x9, x9, #15
602*9880d681SAndroid Build Coastguard Worker; CHECK: and	x9, x9, #0x7fffffff0
603*9880d681SAndroid Build Coastguard Worker; CHECK: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
604*9880d681SAndroid Build Coastguard Worker; CHECK: mov	 sp, x[[VLASPTMP]]
605*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
606*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	w[[ILOC:[0-9]+]], [x19]
607*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
608*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
609*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
610*9880d681SAndroid Build Coastguard Worker; CHECK: sub	sp, x29, #16
611*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x29, x30, [sp, #16]
612*9880d681SAndroid Build Coastguard Worker; CHECK: ldp	x28, x19, [sp], #32
613*9880d681SAndroid Build Coastguard Worker; CHECK: ret
614*9880d681SAndroid Build Coastguard Worker
615*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO-LABEL: _vla_dynamicrealign_nocall_large_align:
616*9880d681SAndroid Build Coastguard Worker;   Check that used callee-saved registers are saved
617*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x20, x19, [sp, #-32]!
618*9880d681SAndroid Build Coastguard Worker;   Check that the frame pointer is created:
619*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: stp	x29, x30, [sp, #16]
620*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x29, sp, #16
621*9880d681SAndroid Build Coastguard Worker;   Check that the stack pointer gets re-aligned to 128
622*9880d681SAndroid Build Coastguard Worker;   bytes & the base pointer (x19) gets initialized to
623*9880d681SAndroid Build Coastguard Worker;   this 128-byte aligned area for local variables &
624*9880d681SAndroid Build Coastguard Worker;   spill slots
625*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	x9, sp, #7, lsl #12
626*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	sp, x9, #0xffffffffffff8000
627*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov    x19, sp
628*9880d681SAndroid Build Coastguard Worker;   Check correct access to arguments passed on the stack, through frame pointer
629*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[IARG:[0-9]+]], [x29, #20]
630*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	d[[DARG:[0-9]+]], [x29, #32]
631*9880d681SAndroid Build Coastguard Worker;   Check correct reservation of 16-byte aligned VLA (size in w0) on stack
632*9880d681SAndroid Build Coastguard Worker;   and set-up of base pointer (x19).
633*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	w9, w0
634*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 x10, sp
635*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: lsl	x9, x9, #2
636*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: add	x9, x9, #15
637*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: and	x9, x9, #0x7fffffff0
638*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	 x[[VLASPTMP:[0-9]+]], x10, x9
639*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: mov	 sp, x[[VLASPTMP]]
640*9880d681SAndroid Build Coastguard Worker;   Check correct access to local variable, through base pointer
641*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	w[[ILOC:[0-9]+]], [x19]
642*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldr	 w[[VLA:[0-9]+]], [x[[VLASPTMP]]]
643*9880d681SAndroid Build Coastguard Worker;   Check epilogue:
644*9880d681SAndroid Build Coastguard Worker;     Check that stack pointer get restored from frame pointer.
645*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: sub	sp, x29, #16
646*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x29, x30, [sp, #16]
647*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ldp	x20, x19, [sp], #32
648*9880d681SAndroid Build Coastguard Worker; CHECK-MACHO: ret
649*9880d681SAndroid Build Coastguard Worker
650*9880d681SAndroid Build Coastguard Worker
651*9880d681SAndroid Build Coastguard Workerdefine void @realign_conditional(i1 %b) {
652*9880d681SAndroid Build Coastguard Workerentry:
653*9880d681SAndroid Build Coastguard Worker  br i1 %b, label %bb0, label %bb1
654*9880d681SAndroid Build Coastguard Worker
655*9880d681SAndroid Build Coastguard Workerbb0:
656*9880d681SAndroid Build Coastguard Worker  %MyAlloca = alloca i8, i64 64, align 32
657*9880d681SAndroid Build Coastguard Worker  br label %bb1
658*9880d681SAndroid Build Coastguard Worker
659*9880d681SAndroid Build Coastguard Workerbb1:
660*9880d681SAndroid Build Coastguard Worker  ret void
661*9880d681SAndroid Build Coastguard Worker}
662*9880d681SAndroid Build Coastguard Worker
663*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: realign_conditional
664*9880d681SAndroid Build Coastguard Worker; No realignment in the prologue.
665*9880d681SAndroid Build Coastguard Worker; CHECK-NOT:  and
666*9880d681SAndroid Build Coastguard Worker; CHECK-NOT:  0xffffffffffffffe0
667*9880d681SAndroid Build Coastguard Worker; CHECK:  tbz  {{.*}} .[[LABEL:.*]]
668*9880d681SAndroid Build Coastguard Worker; Stack is realigned in a non-entry BB.
669*9880d681SAndroid Build Coastguard Worker; CHECK:  sub  [[REG:x[01-9]+]], sp, #64
670*9880d681SAndroid Build Coastguard Worker; CHECK:  and  sp, [[REG]], #0xffffffffffffffe0
671*9880d681SAndroid Build Coastguard Worker; CHECK:  .[[LABEL]]:
672*9880d681SAndroid Build Coastguard Worker; CHECK:  ret
673*9880d681SAndroid Build Coastguard Worker
674*9880d681SAndroid Build Coastguard Worker
675*9880d681SAndroid Build Coastguard Workerdefine void @realign_conditional2(i1 %b) {
676*9880d681SAndroid Build Coastguard Workerentry:
677*9880d681SAndroid Build Coastguard Worker  %tmp = alloca i8, i32 16
678*9880d681SAndroid Build Coastguard Worker  br i1 %b, label %bb0, label %bb1
679*9880d681SAndroid Build Coastguard Worker
680*9880d681SAndroid Build Coastguard Workerbb0:
681*9880d681SAndroid Build Coastguard Worker  %MyAlloca = alloca i8, i64 64, align 32
682*9880d681SAndroid Build Coastguard Worker  br label %bb1
683*9880d681SAndroid Build Coastguard Worker
684*9880d681SAndroid Build Coastguard Workerbb1:
685*9880d681SAndroid Build Coastguard Worker  ret void
686*9880d681SAndroid Build Coastguard Worker}
687*9880d681SAndroid Build Coastguard Worker
688*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: realign_conditional2
689*9880d681SAndroid Build Coastguard Worker; Extra realignment in the prologue (performance issue).
690*9880d681SAndroid Build Coastguard Worker; CHECK:  tbz  {{.*}} .[[LABEL:.*]]
691*9880d681SAndroid Build Coastguard Worker; CHECK:  sub  x9, sp, #32            // =32
692*9880d681SAndroid Build Coastguard Worker; CHECK:  and  sp, x9, #0xffffffffffffffe0
693*9880d681SAndroid Build Coastguard Worker; CHECK:  mov   x19, sp
694*9880d681SAndroid Build Coastguard Worker; Stack is realigned in a non-entry BB.
695*9880d681SAndroid Build Coastguard Worker; CHECK:  sub  [[REG:x[01-9]+]], sp, #64
696*9880d681SAndroid Build Coastguard Worker; CHECK:  and  sp, [[REG]], #0xffffffffffffffe0
697*9880d681SAndroid Build Coastguard Worker; CHECK:  .[[LABEL]]:
698*9880d681SAndroid Build Coastguard Worker; CHECK:  ret
699*9880d681SAndroid Build Coastguard Worker
700*9880d681SAndroid Build Coastguard Workerattributes #0 = { "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
701*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
702*9880d681SAndroid Build Coastguard Worker
703*9880d681SAndroid Build Coastguard Worker!1 = !{!2, !2, i64 0}
704*9880d681SAndroid Build Coastguard Worker!2 = !{!"int", !3, i64 0}
705*9880d681SAndroid Build Coastguard Worker!3 = !{!"omnipotent char", !4, i64 0}
706*9880d681SAndroid Build Coastguard Worker!4 = !{!"Simple C/C++ TBAA"}
707