[ARM64] Set default CPU to generic instead of cyclone.
[oota-llvm.git] / test / CodeGen / ARM64 / stackmap.ll
1 ; RUN: llc < %s -mtriple=arm64-apple-darwin | FileCheck %s
2 ;
3 ; Note: Print verbose stackmaps using -debug-only=stackmaps.
4
5 ; We are not getting the correct stack alignment when cross compiling for arm64.
6 ; So specify a datalayout here.
7 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8
9 ; CHECK-LABEL:  .section  __LLVM_STACKMAPS,__llvm_stackmaps
10 ; CHECK-NEXT:  __LLVM_StackMaps:
11 ; Header
12 ; CHECK-NEXT:   .byte 1
13 ; CHECK-NEXT:   .byte 0
14 ; CHECK-NEXT:   .short 0
15 ; Num Functions
16 ; CHECK-NEXT:   .long 11
17 ; Num LargeConstants
18 ; CHECK-NEXT:   .long 2
19 ; Num Callsites
20 ; CHECK-NEXT:   .long 11
21
22 ; Functions and stack size
23 ; CHECK-NEXT:   .quad _constantargs
24 ; CHECK-NEXT:   .quad 16
25 ; CHECK-NEXT:   .quad _osrinline
26 ; CHECK-NEXT:   .quad 32
27 ; CHECK-NEXT:   .quad _osrcold
28 ; CHECK-NEXT:   .quad 16
29 ; CHECK-NEXT:   .quad _propertyRead
30 ; CHECK-NEXT:   .quad 16
31 ; CHECK-NEXT:   .quad _propertyWrite
32 ; CHECK-NEXT:   .quad 16
33 ; CHECK-NEXT:   .quad _jsVoidCall
34 ; CHECK-NEXT:   .quad 16
35 ; CHECK-NEXT:   .quad _jsIntCall
36 ; CHECK-NEXT:   .quad 16
37 ; CHECK-NEXT:   .quad _spilledValue
38 ; CHECK-NEXT:   .quad 160
39 ; CHECK-NEXT:   .quad _spilledStackMapValue
40 ; CHECK-NEXT:   .quad 128
41 ; CHECK-NEXT:   .quad _liveConstant
42 ; CHECK-NEXT:   .quad 16
43 ; CHECK-NEXT:   .quad _clobberLR
44 ; CHECK-NEXT:   .quad 112
45
46 ; Num LargeConstants
47 ; CHECK-NEXT:   .quad   4294967295
48 ; CHECK-NEXT:   .quad   4294967296
49
50 ; Constant arguments
51 ;
52 ; CHECK-NEXT:   .quad   1
53 ; CHECK-NEXT:   .long   L{{.*}}-_constantargs
54 ; CHECK-NEXT:   .short  0
55 ; CHECK-NEXT:   .short  4
56 ; SmallConstant
57 ; CHECK-NEXT:   .byte   4
58 ; CHECK-NEXT:   .byte   8
59 ; CHECK-NEXT:   .short  0
60 ; CHECK-NEXT:   .long   65535
61 ; SmallConstant
62 ; CHECK-NEXT:   .byte   4
63 ; CHECK-NEXT:   .byte   8
64 ; CHECK-NEXT:   .short  0
65 ; CHECK-NEXT:   .long   65536
66 ; SmallConstant
67 ; CHECK-NEXT:   .byte   5
68 ; CHECK-NEXT:   .byte   8
69 ; CHECK-NEXT:   .short  0
70 ; CHECK-NEXT:   .long   0
71 ; LargeConstant at index 0
72 ; CHECK-NEXT:   .byte   5
73 ; CHECK-NEXT:   .byte   8
74 ; CHECK-NEXT:   .short  0
75 ; CHECK-NEXT:   .long   1
76
77 define void @constantargs() {
78 entry:
79   %0 = inttoptr i64 244837814094590 to i8*
80   tail call void (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i64 1, i32 20, i8* %0, i32 0, i64 65535, i64 65536, i64 4294967295, i64 4294967296)
81   ret void
82 }
83
84 ; Inline OSR Exit
85 ;
86 ; CHECK-LABEL:  .long   L{{.*}}-_osrinline
87 ; CHECK-NEXT:   .short  0
88 ; CHECK-NEXT:   .short  2
89 ; CHECK-NEXT:   .byte   1
90 ; CHECK-NEXT:   .byte   8
91 ; CHECK-NEXT:   .short  {{[0-9]+}}
92 ; CHECK-NEXT:   .long   0
93 ; CHECK-NEXT:   .byte   1
94 ; CHECK-NEXT:   .byte   8
95 ; CHECK-NEXT:   .short  {{[0-9]+}}
96 ; CHECK-NEXT:   .long  0
97 define void @osrinline(i64 %a, i64 %b) {
98 entry:
99   ; Runtime void->void call.
100   call void inttoptr (i64 244837814094590 to void ()*)()
101   ; Followed by inline OSR patchpoint with 12-byte shadow and 2 live vars.
102   call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 3, i32 12, i64 %a, i64 %b)
103   ret void
104 }
105
106 ; Cold OSR Exit
107 ;
108 ; 2 live variables in register.
109 ;
110 ; CHECK-LABEL:  .long   L{{.*}}-_osrcold
111 ; CHECK-NEXT:   .short  0
112 ; CHECK-NEXT:   .short  2
113 ; CHECK-NEXT:   .byte   1
114 ; CHECK-NEXT:   .byte   8
115 ; CHECK-NEXT:   .short  {{[0-9]+}}
116 ; CHECK-NEXT:   .long   0
117 ; CHECK-NEXT:   .byte   1
118 ; CHECK-NEXT:   .byte   8
119 ; CHECK-NEXT:   .short  {{[0-9]+}}
120 ; CHECK-NEXT:   .long  0
121 define void @osrcold(i64 %a, i64 %b) {
122 entry:
123   %test = icmp slt i64 %a, %b
124   br i1 %test, label %ret, label %cold
125 cold:
126   ; OSR patchpoint with 12-byte nop-slide and 2 live vars.
127   %thunk = inttoptr i64 244837814094590 to i8*
128   call void (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i64 4, i32 20, i8* %thunk, i32 0, i64 %a, i64 %b)
129   unreachable
130 ret:
131   ret void
132 }
133
134 ; Property Read
135 ; CHECK-LABEL:  .long   L{{.*}}-_propertyRead
136 ; CHECK-NEXT:   .short  0
137 ; CHECK-NEXT:   .short  0
138 ;
139 ; FIXME: There are currently no stackmap entries. After moving to
140 ; AnyRegCC, we will have entries for the object and return value.
141 define i64 @propertyRead(i64* %obj) {
142 entry:
143   %resolveRead = inttoptr i64 244837814094590 to i8*
144   %result = call i64 (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.i64(i64 5, i32 20, i8* %resolveRead, i32 1, i64* %obj)
145   %add = add i64 %result, 3
146   ret i64 %add
147 }
148
149 ; Property Write
150 ; CHECK-LABEL:  .long   L{{.*}}-_propertyWrite
151 ; CHECK-NEXT:   .short  0
152 ; CHECK-NEXT:   .short  2
153 ; CHECK-NEXT:   .byte   1
154 ; CHECK-NEXT:   .byte   8
155 ; CHECK-NEXT:   .short  {{[0-9]+}}
156 ; CHECK-NEXT:   .long   0
157 ; CHECK-NEXT:   .byte   1
158 ; CHECK-NEXT:   .byte   8
159 ; CHECK-NEXT:   .short  {{[0-9]+}}
160 ; CHECK-NEXT:   .long   0
161 define void @propertyWrite(i64 %dummy1, i64* %obj, i64 %dummy2, i64 %a) {
162 entry:
163   %resolveWrite = inttoptr i64 244837814094590 to i8*
164   call anyregcc void (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i64 6, i32 20, i8* %resolveWrite, i32 2, i64* %obj, i64 %a)
165   ret void
166 }
167
168 ; Void JS Call
169 ;
170 ; 2 live variables in registers.
171 ;
172 ; CHECK-LABEL:  .long   L{{.*}}-_jsVoidCall
173 ; CHECK-NEXT:   .short  0
174 ; CHECK-NEXT:   .short  2
175 ; CHECK-NEXT:   .byte   1
176 ; CHECK-NEXT:   .byte   8
177 ; CHECK-NEXT:   .short  {{[0-9]+}}
178 ; CHECK-NEXT:   .long   0
179 ; CHECK-NEXT:   .byte   1
180 ; CHECK-NEXT:   .byte   8
181 ; CHECK-NEXT:   .short  {{[0-9]+}}
182 ; CHECK-NEXT:   .long   0
183 define void @jsVoidCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) {
184 entry:
185   %resolveCall = inttoptr i64 244837814094590 to i8*
186   call void (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i64 7, i32 20, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2)
187   ret void
188 }
189
190 ; i64 JS Call
191 ;
192 ; 2 live variables in registers.
193 ;
194 ; CHECK-LABEL:  .long   L{{.*}}-_jsIntCall
195 ; CHECK-NEXT:   .short  0
196 ; CHECK-NEXT:   .short  2
197 ; CHECK-NEXT:   .byte   1
198 ; CHECK-NEXT:   .byte   8
199 ; CHECK-NEXT:   .short  {{[0-9]+}}
200 ; CHECK-NEXT:   .long   0
201 ; CHECK-NEXT:   .byte   1
202 ; CHECK-NEXT:   .byte   8
203 ; CHECK-NEXT:   .short  {{[0-9]+}}
204 ; CHECK-NEXT:   .long   0
205 define i64 @jsIntCall(i64 %dummy1, i64* %obj, i64 %arg, i64 %l1, i64 %l2) {
206 entry:
207   %resolveCall = inttoptr i64 244837814094590 to i8*
208   %result = call i64 (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.i64(i64 8, i32 20, i8* %resolveCall, i32 2, i64* %obj, i64 %arg, i64 %l1, i64 %l2)
209   %add = add i64 %result, 3
210   ret i64 %add
211 }
212
213 ; Spilled stack map values.
214 ;
215 ; Verify 28 stack map entries.
216 ;
217 ; CHECK-LABEL:  .long L{{.*}}-_spilledValue
218 ; CHECK-NEXT:   .short 0
219 ; CHECK-NEXT:   .short 28
220 ;
221 ; Check that at least one is a spilled entry from RBP.
222 ; Location: Indirect FP + ...
223 ; CHECK:        .byte 3
224 ; CHECK-NEXT:   .byte 8
225 ; CHECK-NEXT:   .short 29
226 define void @spilledValue(i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27) {
227 entry:
228   call void (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i64 11, i32 20, i8* null, i32 5, i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27)
229   ret void
230 }
231
232 ; Spilled stack map values.
233 ;
234 ; Verify 23 stack map entries.
235 ;
236 ; CHECK-LABEL:  .long L{{.*}}-_spilledStackMapValue
237 ; CHECK-NEXT:   .short 0
238 ; CHECK-NEXT:   .short 30
239 ;
240 ; Check that at least one is a spilled entry from RBP.
241 ; Location: Indirect FP + ...
242 ; CHECK:        .byte 3
243 ; CHECK-NEXT:   .byte 8
244 ; CHECK-NEXT:   .short 29
245 define webkit_jscc void @spilledStackMapValue(i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27, i64 %l28, i64 %l29) {
246 entry:
247   call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 12, i32 16, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27, i64 %l28, i64 %l29)
248   ret void
249 }
250
251
252 ; Map a constant value.
253 ;
254 ; CHECK-LABEL:  .long L{{.*}}-_liveConstant
255 ; CHECK-NEXT:   .short 0
256 ; 1 location
257 ; CHECK-NEXT:   .short 1
258 ; Loc 0: SmallConstant
259 ; CHECK-NEXT:   .byte   4
260 ; CHECK-NEXT:   .byte   8
261 ; CHECK-NEXT:   .short  0
262 ; CHECK-NEXT:   .long   33
263
264 define void @liveConstant() {
265   tail call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 15, i32 8, i32 33)
266   ret void
267 }
268
269 ; Map a value when LR is the only free register.
270 ;
271 ; CHECK-LABEL:  .long L{{.*}}-_clobberLR
272 ; CHECK-NEXT:   .short 0
273 ; 1 location
274 ; CHECK-NEXT:   .short 1
275 ; Loc 0: Indirect FP (r29) - offset
276 ; CHECK-NEXT:   .byte   3
277 ; CHECK-NEXT:   .byte   4
278 ; CHECK-NEXT:   .short  29
279 ; CHECK-NEXT:   .long   -{{[0-9]+}}
280 define void @clobberLR(i32 %a) {
281   tail call void asm sideeffect "nop", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{x29},~{x31}"() nounwind
282   tail call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 16, i32 8, i32 %a)
283   ret void
284 }
285
286 declare void @llvm.experimental.stackmap(i64, i32, ...)
287 declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...)
288 declare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...)