1 ; Test that we can correctly handle vectors of pointers in statepoint
2 ; rewriting. Currently, we scalarize, but that's an implementation detail.
3 ; RUN: opt %s -rewrite-statepoints-for-gc -S | FileCheck %s
5 ; A non-vector relocation for comparison
6 define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" {
9 ; CHECK-NEXT: gc.relocate
11 ; CHECK-NEXT: ret i64 addrspace(1)* %obj.relocated.casted
13 %safepoint_token = call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0)
14 ret i64 addrspace(1)* %obj
17 ; A base vector from a argument
18 define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" {
20 ; CHECK: extractelement
21 ; CHECK-NEXT: extractelement
22 ; CHECK-NEXT: gc.statepoint
23 ; CHECK-NEXT: gc.relocate
25 ; CHECK-NEXT: gc.relocate
27 ; CHECK-NEXT: insertelement
28 ; CHECK-NEXT: insertelement
29 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7
31 %safepoint_token = call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0)
32 ret <2 x i64 addrspace(1)*> %obj
35 ; A base vector from a load
36 define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
39 ; CHECK-NEXT: extractelement
40 ; CHECK-NEXT: extractelement
41 ; CHECK-NEXT: gc.statepoint
42 ; CHECK-NEXT: gc.relocate
44 ; CHECK-NEXT: gc.relocate
46 ; CHECK-NEXT: insertelement
47 ; CHECK-NEXT: insertelement
48 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7
50 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
51 %safepoint_token = call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0)
52 ret <2 x i64 addrspace(1)*> %obj
55 declare i32 @fake_personality_function()
57 ; When a statepoint is an invoke rather than a call
58 define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
61 ; CHECK-NEXT: extractelement
62 ; CHECK-NEXT: extractelement
63 ; CHECK-NEXT: gc.statepoint
65 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
66 invoke i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0)
67 to label %normal_return unwind label %exceptional_return
69 ; CHECK-LABEL: normal_return:
72 ; CHECK-NEXT: gc.relocate
74 ; CHECK-NEXT: insertelement
75 ; CHECK-NEXT: insertelement
76 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %8
77 normal_return: ; preds = %entry
78 ret <2 x i64 addrspace(1)*> %obj
80 ; CHECK-LABEL: exceptional_return:
83 ; CHECK-NEXT: gc.relocate
85 ; CHECK-NEXT: insertelement
86 ; CHECK-NEXT: insertelement
87 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %14
88 exceptional_return: ; preds = %entry
89 %landing_pad4 = landingpad { i8*, i32 } personality i32 ()* @fake_personality_function
91 ret <2 x i64 addrspace(1)*> %obj
94 ; Can we handle an insert element with a constant offset? This effectively
95 ; tests both the equal and inequal case since we have to relocate both indices
97 define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p)
98 gc "statepoint-example" {
100 ; CHECK: insertelement
101 ; CHECK-NEXT: extractelement
102 ; CHECK-NEXT: extractelement
103 ; CHECK-NEXT: gc.statepoint
104 ; CHECK-NEXT: gc.relocate
105 ; CHECK-NEXT: bitcast
106 ; CHECK-NEXT: gc.relocate
107 ; CHECK-NEXT: bitcast
108 ; CHECK-NEXT: gc.relocate
109 ; CHECK-NEXT: bitcast
110 ; CHECK-NEXT: insertelement
111 ; CHECK-NEXT: insertelement
112 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %7
114 %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0
115 %safepoint_token = call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @do_safepoint, i32 0, i32 0, i32 0, i32 0)
116 ret <2 x i64 addrspace(1)*> %vec
119 declare void @do_safepoint()
121 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)