1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; Test that we can correctly handle vectors of pointers in statepoint
4 ; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
5 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
7 ; A non-vector relocation for comparison
8 define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" {
11 ; 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)* [[OBJ:%.*]]) ]
12 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
13 ; CHECK-NEXT: [[OBJ_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[OBJ_RELOCATED]] to i64 addrspace(1)*
14 ; CHECK-NEXT: ret i64 addrspace(1)* [[OBJ_RELOCATED_CASTED]]
16 ; A base vector from a argument
18 call void @do_safepoint() [ "deopt"() ]
19 ret i64 addrspace(1)* %obj
23 define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" {
24 ; CHECK-LABEL: @test2(
25 ; 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"(<2 x i64 addrspace(1)*> [[OBJ:%.*]]) ]
26 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
27 ; CHECK-NEXT: [[OBJ_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[OBJ_RELOCATED]] to <2 x i64 addrspace(1)*>
28 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[OBJ_RELOCATED_CASTED]]
30 call void @do_safepoint() [ "deopt"() ]
31 ret <2 x i64 addrspace(1)*> %obj
35 define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
36 ; CHECK-LABEL: @test3(
38 ; CHECK-NEXT: [[OBJ:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR:%.*]], align 16
39 ; 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"(<2 x i64 addrspace(1)*> [[OBJ]]) ]
40 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
41 ; CHECK-NEXT: [[OBJ_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[OBJ_RELOCATED]] to <2 x i64 addrspace(1)*>
42 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[OBJ_RELOCATED_CASTED]]
45 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
46 call void @do_safepoint() [ "deopt"() ]
47 ret <2 x i64 addrspace(1)*> %obj
50 declare i32 @fake_personality_function()
52 ; When a statepoint is an invoke rather than a call
53 define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" personality i32 ()* @fake_personality_function {
54 ; CHECK-LABEL: @test4(
56 ; CHECK-NEXT: [[OBJ:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR:%.*]], align 16
57 ; 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"(<2 x i64 addrspace(1)*> [[OBJ]]) ]
58 ; CHECK-NEXT: to label [[NORMAL_RETURN:%.*]] unwind label [[EXCEPTIONAL_RETURN:%.*]]
59 ; CHECK: normal_return:
60 ; CHECK-NEXT: [[OBJ_RELOCATED1:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
61 ; CHECK-NEXT: [[OBJ_RELOCATED1_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[OBJ_RELOCATED1]] to <2 x i64 addrspace(1)*>
62 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[OBJ_RELOCATED1_CASTED]]
63 ; CHECK: exceptional_return:
64 ; CHECK-NEXT: [[LANDING_PAD4:%.*]] = landingpad token
66 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[LANDING_PAD4]], i32 0, i32 0)
67 ; CHECK-NEXT: [[OBJ_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[OBJ_RELOCATED]] to <2 x i64 addrspace(1)*>
68 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[OBJ_RELOCATED_CASTED]]
71 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
72 invoke void @do_safepoint() [ "deopt"() ]
73 to label %normal_return unwind label %exceptional_return
75 normal_return: ; preds = %entry
76 ret <2 x i64 addrspace(1)*> %obj
78 exceptional_return: ; preds = %entry
79 %landing_pad4 = landingpad token
81 ret <2 x i64 addrspace(1)*> %obj
84 ; A newly created vector
85 define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) gc "statepoint-example" {
86 ; CHECK-LABEL: @test5(
88 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x i64 addrspace(1)*> zeroinitializer, i64 addrspace(1)* [[P:%.*]], i32 0, !is_base_value !0
89 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x i64 addrspace(1)*> poison, i64 addrspace(1)* [[P]], i32 0
90 ; 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"(<2 x i64 addrspace(1)*> [[VEC]], <2 x i64 addrspace(1)*> [[VEC_BASE]]) ]
91 ; CHECK-NEXT: [[VEC_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
92 ; CHECK-NEXT: [[VEC_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[VEC_RELOCATED]] to <2 x i64 addrspace(1)*>
93 ; CHECK-NEXT: [[VEC_BASE_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
94 ; CHECK-NEXT: [[VEC_BASE_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[VEC_BASE_RELOCATED]] to <2 x i64 addrspace(1)*>
95 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[VEC_RELOCATED_CASTED]]
98 %vec = insertelement <2 x i64 addrspace(1)*> poison, i64 addrspace(1)* %p, i32 0
99 call void @do_safepoint() [ "deopt"() ]
100 ret <2 x i64 addrspace(1)*> %vec
104 define <2 x i64 addrspace(1)*> @test6(i1 %cnd, <2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" {
105 ; CHECK-LABEL: @test6(
107 ; CHECK-NEXT: br i1 [[CND:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
109 ; CHECK-NEXT: [[OBJA:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR:%.*]], align 16
110 ; CHECK-NEXT: br label [[MERGE:%.*]]
112 ; CHECK-NEXT: [[OBJB:%.*]] = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* [[PTR]], align 16
113 ; CHECK-NEXT: br label [[MERGE]]
115 ; CHECK-NEXT: [[OBJ:%.*]] = phi <2 x i64 addrspace(1)*> [ [[OBJA]], [[TAKEN]] ], [ [[OBJB]], [[UNTAKEN]] ]
116 ; 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"(<2 x i64 addrspace(1)*> [[OBJ]]) ]
117 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x i8 addrspace(1)*> @llvm.experimental.gc.relocate.v2p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
118 ; CHECK-NEXT: [[OBJ_RELOCATED_CASTED:%.*]] = bitcast <2 x i8 addrspace(1)*> [[OBJ_RELOCATED]] to <2 x i64 addrspace(1)*>
119 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> [[OBJ_RELOCATED_CASTED]]
122 br i1 %cnd, label %taken, label %untaken
124 taken: ; preds = %entry
125 %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
128 untaken: ; preds = %entry
129 %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr
132 merge: ; preds = %untaken, %taken
133 %obj = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ]
134 call void @do_safepoint() [ "deopt"() ]
135 ret <2 x i64 addrspace(1)*> %obj
138 declare void @do_safepoint()