1 ; Test that we can correctly handle vectors of pointers in statepoint
3 ; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
4 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
6 ; A non-vector relocation for comparison
7 define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" {
10 ; CHECK-NEXT: gc.relocate
12 ; CHECK-NEXT: ret i64 addrspace(1)*
13 ; A base vector from a argument
15 call void @do_safepoint() [ "deopt"() ]
16 ret i64 addrspace(1)* %obj
20 define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" {
22 ; CHECK-NEXT: gc.statepoint
23 ; CHECK-NEXT: gc.relocate
25 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*>
26 call void @do_safepoint() [ "deopt"() ]
27 ret <2 x i64 addrspace(1)*> %obj
31 define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
34 ; CHECK-NEXT: gc.statepoint
35 ; CHECK-NEXT: gc.relocate
37 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*>
39 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
40 call void @do_safepoint() [ "deopt"() ]
41 ret <2 x i64 addrspace(1)*> %obj
44 declare i32 @fake_personality_function()
46 ; When a statepoint is an invoke rather than a call
47 define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" personality i32 ()* @fake_personality_function {
50 ; CHECK-NEXT: gc.statepoint
52 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
53 invoke void @do_safepoint() [ "deopt"() ]
54 to label %normal_return unwind label %exceptional_return
56 normal_return: ; preds = %entry
57 ; CHECK-LABEL: normal_return:
60 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*>
61 ret <2 x i64 addrspace(1)*> %obj
63 exceptional_return: ; preds = %entry
64 ; CHECK-LABEL: exceptional_return:
67 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*>
68 %landing_pad4 = landingpad token
70 ret <2 x i64 addrspace(1)*> %obj
73 ; A newly created vector
74 define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) gc "statepoint-example" {
76 ; CHECK: insertelement
77 ; CHECK-NEXT: insertelement
78 ; CHECK-NEXT: gc.statepoint
79 ; CHECK-NEXT: gc.relocate
81 ; CHECK-NEXT: gc.relocate
83 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %vec.relocated.casted
85 %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0
86 call void @do_safepoint() [ "deopt"() ]
87 ret <2 x i64 addrspace(1)*> %vec
91 define <2 x i64 addrspace(1)*> @test6(i1 %cnd, <2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
94 br i1 %cnd, label %taken, label %untaken
96 taken: ; preds = %entry
97 %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
100 untaken: ; preds = %entry
101 %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
104 merge: ; preds = %untaken, %taken
105 ; CHECK-LABEL: merge:
108 ; CHECK-NEXT: gc.statepoint
109 ; CHECK-NEXT: gc.relocate
110 ; CHECK-NEXT: bitcast
111 ; CHECK-NEXT: gc.relocate
112 ; CHECK-NEXT: bitcast
113 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*>
114 %obj = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ]
115 call void @do_safepoint() [ "deopt"() ]
116 ret <2 x i64 addrspace(1)*> %obj
119 declare void @do_safepoint()