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 -passes=rewrite-statepoints-for-gc -S | FileCheck %s
6 ; A non-vector relocation for comparison
7 define ptr addrspace(1) @test(ptr addrspace(1) %obj) gc "statepoint-example" {
10 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) [[OBJ:%.*]]) ]
11 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
12 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ_RELOCATED]]
14 ; A base vector from a argument
16 call void @do_safepoint() [ "deopt"() ]
17 ret ptr addrspace(1) %obj
21 define <2 x ptr addrspace(1)> @test2(<2 x ptr addrspace(1)> %obj) gc "statepoint-example" {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<2 x ptr addrspace(1)> [[OBJ:%.*]]) ]
24 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
25 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[OBJ_RELOCATED]]
27 call void @do_safepoint() [ "deopt"() ]
28 ret <2 x ptr addrspace(1)> %obj
32 define <2 x ptr addrspace(1)> @test3(ptr %ptr) gc "statepoint-example" {
33 ; CHECK-LABEL: @test3(
35 ; CHECK-NEXT: [[OBJ:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR:%.*]], align 16
36 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<2 x ptr addrspace(1)> [[OBJ]]) ]
37 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
38 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[OBJ_RELOCATED]]
41 %obj = load <2 x ptr addrspace(1)>, ptr %ptr
42 call void @do_safepoint() [ "deopt"() ]
43 ret <2 x ptr addrspace(1)> %obj
46 declare i32 @fake_personality_function()
48 ; When a statepoint is an invoke rather than a call
49 define <2 x ptr addrspace(1)> @test4(ptr %ptr) gc "statepoint-example" personality ptr @fake_personality_function {
50 ; CHECK-LABEL: @test4(
52 ; CHECK-NEXT: [[OBJ:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR:%.*]], align 16
53 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<2 x ptr addrspace(1)> [[OBJ]]) ]
54 ; CHECK-NEXT: to label [[NORMAL_RETURN:%.*]] unwind label [[EXCEPTIONAL_RETURN:%.*]]
55 ; CHECK: normal_return:
56 ; CHECK-NEXT: [[OBJ_RELOCATED1:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
57 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[OBJ_RELOCATED1]]
58 ; CHECK: exceptional_return:
59 ; CHECK-NEXT: [[LANDING_PAD4:%.*]] = landingpad token
61 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[LANDING_PAD4]], i32 0, i32 0)
62 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[OBJ_RELOCATED]]
65 %obj = load <2 x ptr addrspace(1)>, ptr %ptr
66 invoke void @do_safepoint() [ "deopt"() ]
67 to label %normal_return unwind label %exceptional_return
69 normal_return: ; preds = %entry
70 ret <2 x ptr addrspace(1)> %obj
72 exceptional_return: ; preds = %entry
73 %landing_pad4 = landingpad token
75 ret <2 x ptr addrspace(1)> %obj
78 ; A newly created vector
79 define <2 x ptr addrspace(1)> @test5(ptr addrspace(1) %p) gc "statepoint-example" {
80 ; CHECK-LABEL: @test5(
82 ; CHECK-NEXT: [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[P:%.*]], i32 0, !is_base_value !0
83 ; CHECK-NEXT: [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[P]], i32 0
84 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<2 x ptr addrspace(1)> [[VEC]], <2 x ptr addrspace(1)> [[VEC_BASE]]) ]
85 ; CHECK-NEXT: [[VEC_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
86 ; CHECK-NEXT: [[VEC_BASE_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
87 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[VEC_RELOCATED]]
90 %vec = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %p, i32 0
91 call void @do_safepoint() [ "deopt"() ]
92 ret <2 x ptr addrspace(1)> %vec
96 define <2 x ptr addrspace(1)> @test6(i1 %cnd, ptr %ptr) gc "statepoint-example" {
97 ; CHECK-LABEL: @test6(
99 ; CHECK-NEXT: br i1 [[CND:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
101 ; CHECK-NEXT: [[OBJA:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR:%.*]], align 16
102 ; CHECK-NEXT: br label [[MERGE:%.*]]
104 ; CHECK-NEXT: [[OBJB:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR]], align 16
105 ; CHECK-NEXT: br label [[MERGE]]
107 ; CHECK-NEXT: [[OBJ:%.*]] = phi <2 x ptr addrspace(1)> [ [[OBJA]], [[TAKEN]] ], [ [[OBJB]], [[UNTAKEN]] ]
108 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(<2 x ptr addrspace(1)> [[OBJ]]) ]
109 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
110 ; CHECK-NEXT: ret <2 x ptr addrspace(1)> [[OBJ_RELOCATED]]
113 br i1 %cnd, label %taken, label %untaken
115 taken: ; preds = %entry
116 %obja = load <2 x ptr addrspace(1)>, ptr %ptr
119 untaken: ; preds = %entry
120 %objb = load <2 x ptr addrspace(1)>, ptr %ptr
123 merge: ; preds = %untaken, %taken
124 %obj = phi <2 x ptr addrspace(1)> [ %obja, %taken ], [ %objb, %untaken ]
125 call void @do_safepoint() [ "deopt"() ]
126 ret <2 x ptr addrspace(1)> %obj
129 declare void @do_safepoint()