xref: /aosp_15_r20/external/llvm/test/CodeGen/WebAssembly/userstack.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "wasm32-unknown-unknown"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdeclare void @ext_func(i64* %ptr)
7*9880d681SAndroid Build Coastguard Workerdeclare void @ext_func_i32(i32* %ptr)
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: alloca32:
10*9880d681SAndroid Build Coastguard Worker; Check that there is an extra local for the stack pointer.
11*9880d681SAndroid Build Coastguard Worker; CHECK: .local i32{{$}}
12*9880d681SAndroid Build Coastguard Workerdefine void @alloca32() noredzone {
13*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L4:.+]]=, 0{{$}}
14*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L1:.+]]=, 0{{$}}
15*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L2:.+]]=, __stack_pointer($pop[[L1]])
16*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L3:.+]]=, 16
17*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L8:.+]]=, $pop[[L2]], $pop[[L3]]
18*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $push[[L10:.+]]=, __stack_pointer($pop[[L4]]), $pop[[L8]]{{$}}
19*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local $push[[L9:.+]]=, $[[SP:.+]]=, $pop[[L10]]{{$}}
20*9880d681SAndroid Build Coastguard Worker %retval = alloca i32
21*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L0:.+]]=, 0
22*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.store {{.*}}=, 12($pop[[L9]]), $pop[[L0]]
23*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval
24*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L6:.+]]=, 0
25*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L5:.+]]=, 16
26*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[L7:.+]]=, $[[SP]], $pop[[L5]]
27*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $drop=, __stack_pointer($pop[[L6]]), $pop[[L7]]
28*9880d681SAndroid Build Coastguard Worker ret void
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: alloca3264:
32*9880d681SAndroid Build Coastguard Worker; CHECK: .local i32{{$}}
33*9880d681SAndroid Build Coastguard Workerdefine void @alloca3264() {
34*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L2:.+]]=, 0{{$}}
35*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L3:.+]]=, __stack_pointer($pop[[L2]])
36*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L4:.+]]=, 16
37*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L6:.+]]=, $pop[[L3]], $pop[[L4]]
38*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local $push[[L5:.+]]=, $[[SP:.+]]=, $pop[[L6]]
39*9880d681SAndroid Build Coastguard Worker %r1 = alloca i32
40*9880d681SAndroid Build Coastguard Worker %r2 = alloca double
41*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L0:.+]]=, 0
42*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $drop=, 12($pop[[L5]]), $pop[[L0]]
43*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %r1
44*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i64.const $push[[L1:.+]]=, 0
45*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i64.store $drop=, 0($[[SP]]), $pop[[L1]]
46*9880d681SAndroid Build Coastguard Worker store double 0.0, double* %r2
47*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: return
48*9880d681SAndroid Build Coastguard Worker ret void
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: allocarray:
52*9880d681SAndroid Build Coastguard Worker; CHECK: .local i32{{$}}
53*9880d681SAndroid Build Coastguard Workerdefine void @allocarray() {
54*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L7:.+]]=, 0{{$}}
55*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L4:.+]]=, 0{{$}}
56*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L5:.+]]=, __stack_pointer($pop[[L4]])
57*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L6:.+]]=, 144{{$}}
58*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, $pop[[L5]], $pop[[L6]]
59*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store ${{.+}}=, __stack_pointer($pop[[L7]]), $pop[[L11]]
60*9880d681SAndroid Build Coastguard Worker %r = alloca [33 x i32]
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker ; CHECK:      i32.const $push{{.+}}=, 24
63*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[L3:.+]]=, $[[SP]], $pop{{.+}}
64*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L1:.+]]=, 1{{$}}
65*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $push[[L0:.+]]=, 0($pop[[L3]]), $pop[[L1]]{{$}}
66*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $drop=, 12(${{.+}}), $pop[[L0]]{{$}}
67*9880d681SAndroid Build Coastguard Worker %p = getelementptr [33 x i32], [33 x i32]* %r, i32 0, i32 0
68*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %p
69*9880d681SAndroid Build Coastguard Worker %p2 = getelementptr [33 x i32], [33 x i32]* %r, i32 0, i32 3
70*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %p2
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L10:.+]]=, 0{{$}}
73*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L8:.+]]=, 144
74*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[L19:.+]]=, $[[SP]], $pop[[L8]]
75*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $drop=, __stack_pointer($pop[[L10]]), $pop[[L9]]
76*9880d681SAndroid Build Coastguard Worker ret void
77*9880d681SAndroid Build Coastguard Worker}
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: non_mem_use
80*9880d681SAndroid Build Coastguard Workerdefine void @non_mem_use(i8** %addr) {
81*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L1:.+]]=, 48
82*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, {{.+}}, $pop[[L1]]
83*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $[[SP:.+]]=, {{.+}}, $pop[[L11]]
84*9880d681SAndroid Build Coastguard Worker %buf = alloca [27 x i8], align 16
85*9880d681SAndroid Build Coastguard Worker %r = alloca i64
86*9880d681SAndroid Build Coastguard Worker %r2 = alloca i64
87*9880d681SAndroid Build Coastguard Worker ; %r is at SP+8
88*9880d681SAndroid Build Coastguard Worker ; CHECK: tee_local $push[[L12:.+]]=, $[[SP:.+]]=, $pop{{.+}}
89*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[OFF:.+]]=, 8
90*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[ARG1:.+]]=, $pop[[L12]], $pop[[OFF]]
91*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call ext_func@FUNCTION, $pop[[ARG1]]
92*9880d681SAndroid Build Coastguard Worker call void @ext_func(i64* %r)
93*9880d681SAndroid Build Coastguard Worker ; %r2 is at SP+0, no add needed
94*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call ext_func@FUNCTION, $[[SP]]
95*9880d681SAndroid Build Coastguard Worker call void @ext_func(i64* %r2)
96*9880d681SAndroid Build Coastguard Worker ; Use as a value, but in a store
97*9880d681SAndroid Build Coastguard Worker ; %buf is at SP+16
98*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[OFF:.+]]=, 16
99*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[VAL:.+]]=, $[[SP]], $pop[[OFF]]
100*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store {{.*}}=, 0($0), $pop[[VAL]]
101*9880d681SAndroid Build Coastguard Worker %gep = getelementptr inbounds [27 x i8], [27 x i8]* %buf, i32 0, i32 0
102*9880d681SAndroid Build Coastguard Worker store i8* %gep, i8** %addr
103*9880d681SAndroid Build Coastguard Worker ret void
104*9880d681SAndroid Build Coastguard Worker}
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: allocarray_inbounds:
107*9880d681SAndroid Build Coastguard Worker; CHECK: .local i32{{$}}
108*9880d681SAndroid Build Coastguard Workerdefine void @allocarray_inbounds() {
109*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L6:.+]]=, 0{{$}}
110*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L3:.+]]=, 0{{$}}
111*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L4:.+]]=, __stack_pointer($pop[[L3]])
112*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L5:.+]]=, 32{{$}}
113*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L10:.+]]=, $pop[[L4]], $pop[[L5]]
114*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store ${{.+}}=, __stack_pointer($pop[[L6]]), $pop[[L10]]{{$}}
115*9880d681SAndroid Build Coastguard Worker %r = alloca [5 x i32]
116*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L3:.+]]=, 1
117*9880d681SAndroid Build Coastguard Worker ; CHECK-DAG: i32.store $push{{.*}}=, 24(${{.+}}), $pop[[L3]]
118*9880d681SAndroid Build Coastguard Worker %p = getelementptr inbounds [5 x i32], [5 x i32]* %r, i32 0, i32 0
119*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %p
120*9880d681SAndroid Build Coastguard Worker ; This store should have both the GEP and the FI folded into it.
121*9880d681SAndroid Build Coastguard Worker ; CHECK-DAG: i32.store {{.*}}=, 12(${{.+}}), $pop
122*9880d681SAndroid Build Coastguard Worker %p2 = getelementptr inbounds [5 x i32], [5 x i32]* %r, i32 0, i32 3
123*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %p2
124*9880d681SAndroid Build Coastguard Worker call void @ext_func(i64* null);
125*9880d681SAndroid Build Coastguard Worker ; CHECK: call ext_func
126*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L6:.+]]=, 0{{$}}
127*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L5:.+]]=, 32{{$}}
128*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[L7:.+]]=, ${{.+}}, $pop[[L5]]
129*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store $drop=, __stack_pointer($pop[[L6]]), $pop[[L7]]
130*9880d681SAndroid Build Coastguard Worker ret void
131*9880d681SAndroid Build Coastguard Worker}
132*9880d681SAndroid Build Coastguard Worker
133*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: dynamic_alloca:
134*9880d681SAndroid Build Coastguard Workerdefine void @dynamic_alloca(i32 %alloc) {
135*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L7:.+]]=, 0{{$}}
136*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L1:.+]]=, 0{{$}}
137*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L13:.+]]=, __stack_pointer($pop[[L1]])
138*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local $push[[L12:.+]]=, [[SP:.+]], $pop[[L13]]{{$}}
139*9880d681SAndroid Build Coastguard Worker ; Target independent codegen bumps the stack pointer.
140*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.sub
141*9880d681SAndroid Build Coastguard Worker ; Check that SP is written back to memory after decrement
142*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.store $drop=, __stack_pointer($pop{{.+}}),
143*9880d681SAndroid Build Coastguard Worker %r = alloca i32, i32 %alloc
144*9880d681SAndroid Build Coastguard Worker ; Target-independent codegen also calculates the store addr
145*9880d681SAndroid Build Coastguard Worker ; CHECK: call ext_func_i32@FUNCTION
146*9880d681SAndroid Build Coastguard Worker call void @ext_func_i32(i32* %r)
147*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L3:.+]]=, 0{{$}}
148*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.store $drop=, __stack_pointer($pop[[L3]]), $pop{{.+}}
149*9880d681SAndroid Build Coastguard Worker ret void
150*9880d681SAndroid Build Coastguard Worker}
151*9880d681SAndroid Build Coastguard Worker
152*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: dynamic_alloca_redzone:
153*9880d681SAndroid Build Coastguard Workerdefine void @dynamic_alloca_redzone(i32 %alloc) {
154*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L8:.+]]=, 0{{$}}
155*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L13:.+]]=, __stack_pointer($pop[[L1]])
156*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local $push[[L12:.+]]=, [[SP:.+]], $pop[[L13]]{{$}}
157*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: copy_local [[FP:.+]]=, $pop[[L12]]{{$}}
158*9880d681SAndroid Build Coastguard Worker ; Target independent codegen bumps the stack pointer
159*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.sub
160*9880d681SAndroid Build Coastguard Worker %r = alloca i32, i32 %alloc
161*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local       $push[[L8:.+]]=, $0=, $pop
162*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: copy_local      $drop=, $pop[[L8]]{{$}}
163*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const       $push[[L6:.+]]=, 0{{$}}
164*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.store       $drop=, 0($0), $pop[[L6]]{{$}}
165*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %r
166*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: return
167*9880d681SAndroid Build Coastguard Worker ret void
168*9880d681SAndroid Build Coastguard Worker}
169*9880d681SAndroid Build Coastguard Worker
170*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: dynamic_static_alloca:
171*9880d681SAndroid Build Coastguard Workerdefine void @dynamic_static_alloca(i32 %alloc) noredzone {
172*9880d681SAndroid Build Coastguard Worker ; Decrement SP in the prolog by the static amount and writeback to memory.
173*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L7:.+]]=, 0{{$}}
174*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L8:.+]]=, 0{{$}}
175*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L9:.+]]=, 0{{$}}
176*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.load $push[[L10:.+]]=, __stack_pointer($pop[[L9]])
177*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.const $push[[L11:.+]]=, 16
178*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L20:.+]]=, $pop[[L10]], $pop[[L11]]
179*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: tee_local $push[[L19:.+]]=, $[[FP:.+]]=, $pop[[L20]]
180*9880d681SAndroid Build Coastguard Worker ; CHECK:      i32.store $push[[L0:.+]]=, __stack_pointer($pop{{.+}}), $pop{{.+}}
181*9880d681SAndroid Build Coastguard Worker ; Decrement SP in the body by the dynamic amount.
182*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.sub
183*9880d681SAndroid Build Coastguard Worker ; Writeback to memory.
184*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.store $drop=, __stack_pointer($pop{{.+}}), $pop{{.+}}
185*9880d681SAndroid Build Coastguard Worker %r1 = alloca i32
186*9880d681SAndroid Build Coastguard Worker %r = alloca i32, i32 %alloc
187*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %r
188*9880d681SAndroid Build Coastguard Worker ; CHEC: i32.store $drop=, 0($pop{{.+}}), $pop{{.+}}
189*9880d681SAndroid Build Coastguard Worker ret void
190*9880d681SAndroid Build Coastguard Worker}
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Worker; The use of the alloca in a phi causes a CopyToReg DAG node to be generated,
193*9880d681SAndroid Build Coastguard Worker; which has to have special handling because CopyToReg can't have a FI operand
194*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: copytoreg_fi:
195*9880d681SAndroid Build Coastguard Workerdefine void @copytoreg_fi(i1 %cond, i32* %b) {
196*9880d681SAndroid Build Coastguard Workerentry:
197*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[L1:.+]]=, 16
198*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.sub $push[[L3:.+]]=, {{.+}}, $pop[[L1]]
199*9880d681SAndroid Build Coastguard Worker %addr = alloca i32
200*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.const $push[[OFF:.+]]=, 12
201*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: i32.add $push[[ADDR:.+]]=, $pop[[L3]], $pop[[OFF]]
202*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: copy_local [[COPY:.+]]=, $pop[[ADDR]]
203*9880d681SAndroid Build Coastguard Worker br label %body
204*9880d681SAndroid Build Coastguard Workerbody:
205*9880d681SAndroid Build Coastguard Worker %a = phi i32* [%addr, %entry], [%b, %body]
206*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %a
207*9880d681SAndroid Build Coastguard Worker ; CHECK: i32.store {{.*}}, 0([[COPY]]),
208*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %body, label %exit
209*9880d681SAndroid Build Coastguard Workerexit:
210*9880d681SAndroid Build Coastguard Worker ret void
211*9880d681SAndroid Build Coastguard Worker}
212*9880d681SAndroid Build Coastguard Worker
213*9880d681SAndroid Build Coastguard Workerdeclare void @use_i8_star(i8*)
214*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.frameaddress(i32)
215*9880d681SAndroid Build Coastguard Worker
216*9880d681SAndroid Build Coastguard Worker; Test __builtin_frame_address(0).
217*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: frameaddress_0:
218*9880d681SAndroid Build Coastguard Worker; CHECK: i32.const $push[[L0:.+]]=, 0{{$}}
219*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: i32.load $push[[L3:.+]]=, __stack_pointer($pop[[L0]])
220*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: copy_local $push[[L4:.+]]=, $pop[[L3]]{{$}}
221*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: tee_local $push[[L2:.+]]=, $[[FP:.+]]=, $pop[[L4]]{{$}}
222*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call use_i8_star@FUNCTION, $pop[[L2]]
223*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: i32.const $push[[L1:.+]]=, 0{{$}}
224*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: i32.store $drop=, __stack_pointer($pop[[L1]]), $[[FP]]
225*9880d681SAndroid Build Coastguard Workerdefine void @frameaddress_0() {
226*9880d681SAndroid Build Coastguard Worker  %t = call i8* @llvm.frameaddress(i32 0)
227*9880d681SAndroid Build Coastguard Worker  call void @use_i8_star(i8* %t)
228*9880d681SAndroid Build Coastguard Worker  ret void
229*9880d681SAndroid Build Coastguard Worker}
230*9880d681SAndroid Build Coastguard Worker
231*9880d681SAndroid Build Coastguard Worker; Test __builtin_frame_address(1).
232*9880d681SAndroid Build Coastguard Worker
233*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: frameaddress_1:
234*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: i32.const $push0=, 0{{$}}
235*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call use_i8_star@FUNCTION, $pop0{{$}}
236*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: return{{$}}
237*9880d681SAndroid Build Coastguard Workerdefine void @frameaddress_1() {
238*9880d681SAndroid Build Coastguard Worker  %t = call i8* @llvm.frameaddress(i32 1)
239*9880d681SAndroid Build Coastguard Worker  call void @use_i8_star(i8* %t)
240*9880d681SAndroid Build Coastguard Worker  ret void
241*9880d681SAndroid Build Coastguard Worker}
242*9880d681SAndroid Build Coastguard Worker
243*9880d681SAndroid Build Coastguard Worker; Test a stack address passed to an inline asm.
244*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: inline_asm:
245*9880d681SAndroid Build Coastguard Worker; CHECK:       __stack_pointer
246*9880d681SAndroid Build Coastguard Worker; CHECK:       #APP
247*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  # %{{[0-9]+}}{{$}}
248*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  #NO_APP
249*9880d681SAndroid Build Coastguard Workerdefine void @inline_asm() {
250*9880d681SAndroid Build Coastguard Worker  %tmp = alloca i8
251*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "# %0", "r"(i8* %tmp)
252*9880d681SAndroid Build Coastguard Worker  ret void
253*9880d681SAndroid Build Coastguard Worker}
254*9880d681SAndroid Build Coastguard Worker
255*9880d681SAndroid Build Coastguard Worker; TODO: test over-aligned alloca
256