rematerialize-derived-pointers.ll
28.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
declare void @use_obj16(i16 addrspace(1)*) "gc-leaf-function"
declare void @use_obj32(i32 addrspace(1)*) "gc-leaf-function"
declare void @use_obj64(i64 addrspace(1)*) "gc-leaf-function"
declare void @do_safepoint()
define void @test_gep_const(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_gep_const(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
}
define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" {
; CHECK-LABEL: @test_gep_idx(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 [[IDX:%.*]]
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 [[IDX]]
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
}
define void @test_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_bitcast(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = bitcast i32 addrspace(1)* [[BASE:%.*]] to i64 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_REMAT:%.*]] = bitcast i32 addrspace(1)* [[BASE_RELOCATED_CASTED]] to i64 addrspace(1)*
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj64(i64 addrspace(1)* %ptr)
ret void
}
define void @test_bitcast_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_bitcast_bitcast(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR1:%.*]] = bitcast i32 addrspace(1)* [[BASE:%.*]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR2:%.*]] = bitcast i64 addrspace(1)* [[PTR1]] to i16 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR1_REMAT:%.*]] = bitcast i32 addrspace(1)* [[BASE_RELOCATED_CASTED]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR2_REMAT:%.*]] = bitcast i64 addrspace(1)* [[PTR1_REMAT]] to i16 addrspace(1)*
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj16(i16 addrspace(1)* [[PTR2_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr1 = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
%ptr2 = bitcast i64 addrspace(1)* %ptr1 to i16 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj16(i16 addrspace(1)* %ptr2)
ret void
}
define void @test_addrspacecast_addrspacecast(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_addrspacecast_addrspacecast(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR1:%.*]] = addrspacecast i32 addrspace(1)* [[BASE:%.*]] to i32*
; CHECK-NEXT: [[PTR2:%.*]] = addrspacecast i32* [[PTR1]] to i32 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[PTR2]], i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[PTR2_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
; CHECK-NEXT: [[PTR2_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[PTR2_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR2_RELOCATED_CASTED]])
; CHECK-NEXT: ret void
;
entry:
%ptr1 = addrspacecast i32 addrspace(1)* %base to i32*
%ptr2 = addrspacecast i32* %ptr1 to i32 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj32(i32 addrspace(1)* %ptr2)
ret void
}
define void @test_bitcast_gep(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_bitcast_gep(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR_CAST:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i64 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT]] to i64 addrspace(1)*
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[BASE_RELOCATED_CASTED]])
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %base)
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
ret void
}
define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" {
; CHECK-LABEL: @test_intersecting_chains(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR_CAST:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_CAST2:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i16 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT1:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT1]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST2_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT]] to i16 addrspace(1)*
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_REMAT]])
; CHECK-NEXT: call void @use_obj16(i16 addrspace(1)* [[PTR_CAST2_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
%ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
}
define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" {
; CHECK-LABEL: @test_cost_threshold(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR_GEP2:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP]], i32 [[IDX1:%.*]]
; CHECK-NEXT: [[PTR_GEP3:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP2]], i32 [[IDX2:%.*]]
; CHECK-NEXT: [[PTR_GEP4:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP3]], i32 [[IDX3:%.*]]
; CHECK-NEXT: [[PTR_CAST:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP4]] to i64 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i64 addrspace(1)* [[PTR_CAST]], i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[PTR_CAST_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
; CHECK-NEXT: [[PTR_CAST_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[PTR_CAST_RELOCATED]] to i64 addrspace(1)*
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_RELOCATED_CASTED]])
; CHECK-NEXT: ret void
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1
%ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2
%ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
ret void
}
define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_two_derived(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR2:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE]], i32 12
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR2_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 12
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_REMAT]])
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR2_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %ptr)
call void @use_obj32(i32 addrspace(1)* %ptr2)
ret void
}
define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_gep_smallint_array(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR:%.*]] = getelementptr [3 x i32], [3 x i32] addrspace(1)* [[BASE:%.*]], i32 0, i32 2
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"([3 x i32] addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to [3 x i32] addrspace(1)*
; CHECK-NEXT: [[PTR_REMAT:%.*]] = getelementptr [3 x i32], [3 x i32] addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 0, i32 2
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %ptr)
ret void
}
declare i32 @fake_personality_function()
define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function {
; CHECK-LABEL: @test_invoke(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR_CAST:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_CAST2:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i16 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: to label [[NORMAL:%.*]] unwind label [[EXCEPTION:%.*]]
; CHECK: normal:
; CHECK-NEXT: [[BASE_RELOCATED6:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED6_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED6]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT3:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED6_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT3]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED6_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST2_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT]] to i16 addrspace(1)*
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_REMAT]])
; CHECK-NEXT: call void @use_obj16(i16 addrspace(1)* [[PTR_CAST2_REMAT]])
; CHECK-NEXT: ret void
; CHECK: exception:
; CHECK-NEXT: [[LANDING_PAD4:%.*]] = landingpad token
; CHECK-NEXT: cleanup
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[LANDING_PAD4]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT4:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST_REMAT5:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT4]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT1:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST2_REMAT2:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT1]] to i16 addrspace(1)*
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_REMAT5]])
; CHECK-NEXT: call void @use_obj16(i16 addrspace(1)* [[PTR_CAST2_REMAT2]])
; CHECK-NEXT: ret void
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
%ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
invoke void @do_safepoint() [ "deopt"() ]
to label %normal unwind label %exception
normal:
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
exception:
%landing_pad4 = landingpad token
cleanup
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
}
define void @test_loop(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_loop(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[DOT01:%.*]] = phi i32 addrspace(1)* [ [[PTR_GEP]], [[ENTRY:%.*]] ], [ [[PTR_GEP_REMAT:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[DOT0:%.*]] = phi i32 addrspace(1)* [ [[BASE]], [[ENTRY]] ], [ [[BASE_RELOCATED_CASTED:%.*]], [[LOOP]] ]
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[DOT01]])
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[DOT0]]) ]
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT]] = getelementptr i32, i32 addrspace(1)* [[BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: br label [[LOOP]]
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
br label %loop
loop: ; preds = %loop, %entry
call void @use_obj32(i32 addrspace(1)* %ptr.gep)
call void @do_safepoint() [ "deopt"() ]
br label %loop
}
define void @test_too_long(i32 addrspace(1)* %base) gc "statepoint-example" {
; CHECK-LABEL: @test_too_long(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASE:%.*]], i32 15
; CHECK-NEXT: [[PTR_GEP1:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP]], i32 15
; CHECK-NEXT: [[PTR_GEP2:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP1]], i32 15
; CHECK-NEXT: [[PTR_GEP3:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP2]], i32 15
; CHECK-NEXT: [[PTR_GEP4:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP3]], i32 15
; CHECK-NEXT: [[PTR_GEP5:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP4]], i32 15
; CHECK-NEXT: [[PTR_GEP6:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP5]], i32 15
; CHECK-NEXT: [[PTR_GEP7:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP6]], i32 15
; CHECK-NEXT: [[PTR_GEP8:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP7]], i32 15
; CHECK-NEXT: [[PTR_GEP9:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP8]], i32 15
; CHECK-NEXT: [[PTR_GEP10:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP9]], i32 15
; CHECK-NEXT: [[PTR_GEP11:%.*]] = getelementptr i32, i32 addrspace(1)* [[PTR_GEP10]], i32 15
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[PTR_GEP11]], i32 addrspace(1)* [[BASE]]) ]
; CHECK-NEXT: [[PTR_GEP11_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
; CHECK-NEXT: [[PTR_GEP11_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[PTR_GEP11_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
; CHECK-NEXT: [[BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_GEP11_RELOCATED_CASTED]])
; CHECK-NEXT: ret void
;
entry:
%ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
%ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15
%ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15
%ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15
%ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15
%ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15
%ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15
%ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15
%ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15
%ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15
%ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15
%ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15
call void @do_safepoint() [ "deopt"() ]
call void @use_obj32(i32 addrspace(1)* %ptr.gep11)
ret void
}
declare i32 addrspace(1)* @new_instance() nounwind "gc-leaf-function"
; remat the gep in presence of base pointer which is a phi node.
; FIXME: We should remove the extra basephi.base as well.
define void @contains_basephi(i1 %cond) gc "statepoint-example" {
; CHECK-LABEL: @contains_basephi(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[BASE1:%.*]] = call i32 addrspace(1)* @new_instance()
; CHECK-NEXT: [[BASE2:%.*]] = call i32 addrspace(1)* @new_instance()
; CHECK-NEXT: br i1 [[COND:%.*]], label [[HERE:%.*]], label [[THERE:%.*]]
; CHECK: here:
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: there:
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: [[BASEPHI_BASE:%.*]] = phi i32 addrspace(1)* [ [[BASE1]], [[HERE]] ], [ [[BASE2]], [[THERE]] ], !is_base_value !0
; CHECK-NEXT: [[BASEPHI:%.*]] = phi i32 addrspace(1)* [ [[BASE1]], [[HERE]] ], [ [[BASE2]], [[THERE]] ]
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASEPHI]], i32 15
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASEPHI_BASE]]) ]
; CHECK-NEXT: [[BASEPHI_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASEPHI_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASEPHI_BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASEPHI_BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: call void @use_obj32(i32 addrspace(1)* [[PTR_GEP_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%base1 = call i32 addrspace(1)* @new_instance()
%base2 = call i32 addrspace(1)* @new_instance()
br i1 %cond, label %here, label %there
here:
br label %merge
there:
br label %merge
merge:
%basephi = phi i32 addrspace(1)* [ %base1, %here ], [ %base2, %there ]
%ptr.gep = getelementptr i32, i32 addrspace(1)* %basephi, i32 15
call void @do_safepoint() ["deopt"() ]
call void @use_obj32(i32 addrspace(1)* %ptr.gep)
ret void
}
define void @test_intersecting_chains_with_phi(i1 %cond) gc "statepoint-example" {
; CHECK-LABEL: @test_intersecting_chains_with_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[BASE1:%.*]] = call i32 addrspace(1)* @new_instance()
; CHECK-NEXT: [[BASE2:%.*]] = call i32 addrspace(1)* @new_instance()
; CHECK-NEXT: br i1 [[COND:%.*]], label [[HERE:%.*]], label [[THERE:%.*]]
; CHECK: here:
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: there:
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: [[BASEPHI_BASE:%.*]] = phi i32 addrspace(1)* [ [[BASE1]], [[HERE]] ], [ [[BASE2]], [[THERE]] ], !is_base_value !0
; CHECK-NEXT: [[BASEPHI:%.*]] = phi i32 addrspace(1)* [ [[BASE1]], [[HERE]] ], [ [[BASE2]], [[THERE]] ]
; CHECK-NEXT: [[PTR_GEP:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASEPHI]], i32 15
; CHECK-NEXT: [[PTR_CAST:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_CAST2:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP]] to i16 addrspace(1)*
; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i32 addrspace(1)* [[BASEPHI_BASE]]) ]
; CHECK-NEXT: [[BASEPHI_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: [[BASEPHI_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[BASEPHI_BASE_RELOCATED]] to i32 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT1:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASEPHI_BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT1]] to i64 addrspace(1)*
; CHECK-NEXT: [[PTR_GEP_REMAT:%.*]] = getelementptr i32, i32 addrspace(1)* [[BASEPHI_BASE_RELOCATED_CASTED]], i32 15
; CHECK-NEXT: [[PTR_CAST2_REMAT:%.*]] = bitcast i32 addrspace(1)* [[PTR_GEP_REMAT]] to i16 addrspace(1)*
; CHECK-NEXT: call void @use_obj64(i64 addrspace(1)* [[PTR_CAST_REMAT]])
; CHECK-NEXT: call void @use_obj16(i16 addrspace(1)* [[PTR_CAST2_REMAT]])
; CHECK-NEXT: ret void
;
entry:
%base1 = call i32 addrspace(1)* @new_instance()
%base2 = call i32 addrspace(1)* @new_instance()
br i1 %cond, label %here, label %there
here:
br label %merge
there:
br label %merge
merge:
%basephi = phi i32 addrspace(1)* [ %base1, %here ], [ %base2, %there ]
%ptr.gep = getelementptr i32, i32 addrspace(1)* %basephi, i32 15
%ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
%ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
call void @do_safepoint() [ "deopt"() ]
call void @use_obj64(i64 addrspace(1)* %ptr.cast)
call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
ret void
}