1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
4 declare void @do_safepoint()
5 declare ptr addrspace(1) @def_ptr()
7 define ptr addrspace(1) @test1(ptr addrspace(1) %base1, <2 x i64> %offsets, i1 %c) gc "statepoint-example" {
10 ; CHECK-NEXT: br i1 [[C:%.*]], label [[FIRST:%.*]], label [[SECOND:%.*]]
12 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(ptr addrspace(1) ()) @def_ptr, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
13 ; CHECK-NEXT: [[BASE21:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token [[STATEPOINT_TOKEN]])
14 ; CHECK-NEXT: br label [[SECOND]]
16 ; CHECK-NEXT: [[PHI:%.*]] = phi ptr addrspace(1) [ [[BASE1:%.*]], [[ENTRY:%.*]] ], [ [[BASE21]], [[FIRST]] ]
17 ; CHECK-NEXT: [[DOTSPLATINSERT_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[PHI]], i64 0, !is_base_value !0
18 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[PHI]], i64 0
19 ; CHECK-NEXT: [[DOTSPLAT_BASE:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT_BASE]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer, !is_base_value !0
20 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer
21 ; CHECK-NEXT: [[VEC:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[DOTSPLAT]], <2 x i64> [[OFFSETS:%.*]]
22 ; CHECK-NEXT: [[PTR_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[DOTSPLAT_BASE]], i32 1, !is_base_value !0
23 ; CHECK-NEXT: [[PTR:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 1
24 ; CHECK-NEXT: [[STATEPOINT_TOKEN2:%.*]] = 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[PTR]], ptr addrspace(1) [[PTR_BASE]]) ]
25 ; CHECK-NEXT: [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN2]], i32 1, i32 0)
26 ; CHECK-NEXT: [[PTR_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN2]], i32 1, i32 1)
27 ; CHECK-NEXT: ret ptr addrspace(1) [[PTR_RELOCATED]]
30 br i1 %c, label %first, label %second
33 %base2 = call ptr addrspace(1) @def_ptr() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
37 %phi = phi ptr addrspace(1) [ %base1, %entry ], [ %base2, %first ]
38 %vec = getelementptr i32, ptr addrspace(1) %phi, <2 x i64> %offsets
39 %ptr = extractelement <2 x ptr addrspace(1)> %vec, i32 1
40 call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
41 ret ptr addrspace(1) %ptr
44 define ptr addrspace(1) @test2(ptr addrspace(1) %base, <2 x i64> %offsets) gc "statepoint-example" {
45 ; CHECK-LABEL: @test2(
47 ; CHECK-NEXT: [[DOTSPLATINSERT_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[BASE:%.*]], i64 0, !is_base_value !0
48 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[BASE]], i64 0
49 ; CHECK-NEXT: [[DOTSPLAT_BASE:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT_BASE]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer, !is_base_value !0
50 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer
51 ; CHECK-NEXT: [[VEC:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[DOTSPLAT]], <2 x i64> [[OFFSETS:%.*]]
52 ; CHECK-NEXT: [[PTR_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[DOTSPLAT_BASE]], i32 1, !is_base_value !0
53 ; CHECK-NEXT: [[PTR:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 1
54 ; 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) [ "gc-live"(ptr addrspace(1) [[PTR]], ptr addrspace(1) [[PTR_BASE]]) ]
55 ; CHECK-NEXT: [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
56 ; CHECK-NEXT: [[PTR_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
57 ; CHECK-NEXT: ret ptr addrspace(1) [[PTR_RELOCATED]]
60 %vec = getelementptr i32, ptr addrspace(1) %base, <2 x i64> %offsets
61 %ptr = extractelement <2 x ptr addrspace(1)> %vec, i32 1
62 call void @do_safepoint()
63 ret ptr addrspace(1) %ptr
66 define ptr addrspace(1) @test3(<2 x ptr addrspace(1)> %base, <2 x i64> %offsets) gc "statepoint-example" {
67 ; CHECK-LABEL: @test3(
69 ; CHECK-NEXT: [[BASE_I32:%.*]] = bitcast <2 x ptr addrspace(1)> [[BASE:%.*]] to <2 x ptr addrspace(1)>
70 ; CHECK-NEXT: [[VEC:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[BASE_I32]], <2 x i64> [[OFFSETS:%.*]]
71 ; CHECK-NEXT: [[BASE_EE:%.*]] = extractelement <2 x ptr addrspace(1)> [[BASE]], i32 1, !is_base_value !0
72 ; CHECK-NEXT: [[PTR:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 1
73 ; 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) [ "gc-live"(ptr addrspace(1) [[PTR]], ptr addrspace(1) [[BASE_EE]]) ]
74 ; CHECK-NEXT: [[PTR_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
75 ; CHECK-NEXT: [[BASE_EE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
76 ; CHECK-NEXT: ret ptr addrspace(1) [[PTR_RELOCATED]]
79 %base.i32 = bitcast <2 x ptr addrspace(1)> %base to <2 x ptr addrspace(1)>
80 %vec = getelementptr i32, <2 x ptr addrspace(1)> %base.i32, <2 x i64> %offsets
81 %ptr = extractelement <2 x ptr addrspace(1)> %vec, i32 1
82 call void @do_safepoint()
83 ret ptr addrspace(1) %ptr
86 define ptr addrspace(1) @test4(ptr addrspace(1) %base, <2 x i64> %offsets) gc "statepoint-example" {
87 ; CHECK-LABEL: @test4(
89 ; CHECK-NEXT: [[DOTSPLATINSERT_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[BASE:%.*]], i64 0, !is_base_value !0
90 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <2 x ptr addrspace(1)> poison, ptr addrspace(1) [[BASE]], i64 0
91 ; CHECK-NEXT: [[DOTSPLAT_BASE:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT_BASE]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer, !is_base_value !0
92 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <2 x ptr addrspace(1)> [[DOTSPLATINSERT]], <2 x ptr addrspace(1)> poison, <2 x i32> zeroinitializer
93 ; CHECK-NEXT: [[VEC:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[DOTSPLAT]], <2 x i64> [[OFFSETS:%.*]]
94 ; 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) [ "gc-live"(<2 x ptr addrspace(1)> [[VEC]], <2 x ptr addrspace(1)> [[DOTSPLAT_BASE]]) ]
95 ; CHECK-NEXT: [[VEC_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
96 ; CHECK-NEXT: [[DOTSPLAT_BASE_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
97 ; CHECK-NEXT: [[PTR:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_RELOCATED]], i32 1
98 ; CHECK-NEXT: ret ptr addrspace(1) [[PTR]]
101 %vec = getelementptr i32, ptr addrspace(1) %base, <2 x i64> %offsets
102 call void @do_safepoint()
103 %ptr = extractelement <2 x ptr addrspace(1)> %vec, i32 1
104 ret ptr addrspace(1) %ptr
107 define ptr addrspace(1) @test5(<2 x ptr addrspace(1)> %base, <2 x i64> %offsets) gc "statepoint-example" {
108 ; CHECK-LABEL: @test5(
110 ; CHECK-NEXT: [[BASE_I32:%.*]] = bitcast <2 x ptr addrspace(1)> [[BASE:%.*]] to <2 x ptr addrspace(1)>
111 ; CHECK-NEXT: [[VEC:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[BASE_I32]], <2 x i64> [[OFFSETS:%.*]]
112 ; 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) [ "gc-live"(<2 x ptr addrspace(1)> [[BASE]]) ]
113 ; CHECK-NEXT: [[BASE_RELOCATED:%.*]] = call coldcc <2 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v2p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
114 ; CHECK-NEXT: [[BASE_I32_REMAT:%.*]] = bitcast <2 x ptr addrspace(1)> [[BASE_RELOCATED]] to <2 x ptr addrspace(1)>
115 ; CHECK-NEXT: [[VEC_REMAT:%.*]] = getelementptr i32, <2 x ptr addrspace(1)> [[BASE_I32_REMAT]], <2 x i64> [[OFFSETS]]
116 ; CHECK-NEXT: [[PTR:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_REMAT]], i32 0
117 ; CHECK-NEXT: ret ptr addrspace(1) [[PTR]]
120 %base.i32 = bitcast <2 x ptr addrspace(1)> %base to <2 x ptr addrspace(1)>
121 %vec = getelementptr i32, <2 x ptr addrspace(1)> %base.i32, <2 x i64> %offsets
122 call void @do_safepoint()
123 %ptr = extractelement <2 x ptr addrspace(1)> %vec, i32 0
124 ret ptr addrspace(1) %ptr
127 define void @test6(i1 %c) gc "statepoint-example" {
128 ; CHECK-LABEL: @test6(
130 ; CHECK-NEXT: br label [[HEADER:%.*]]
132 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr addrspace(1) [ [[TMP6:%.*]], [[LATCH:%.*]] ], [ poison, [[BB:%.*]] ]
133 ; CHECK-NEXT: br label [[BB10:%.*]]
135 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @spam, i32 0, i32 0, i32 0, i32 0) [ "deopt"(ptr addrspace(1) [[TMP]]), "gc-live"(ptr addrspace(1) [[TMP]]) ]
136 ; CHECK-NEXT: [[TMP_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
137 ; CHECK-NEXT: br label [[BB25:%.*]]
139 ; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(<2 x ptr addrspace(1)> ()) @baz, i32 0, i32 0, i32 0, i32 0)
140 ; CHECK-NEXT: [[TMP262:%.*]] = call <2 x ptr addrspace(1)> @llvm.experimental.gc.result.v2p1(token [[STATEPOINT_TOKEN1]])
141 ; CHECK-NEXT: [[TMP27:%.*]] = extractelement <2 x ptr addrspace(1)> [[TMP262]], i32 0
142 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB7:%.*]], label [[LATCH]]
144 ; CHECK-NEXT: br label [[LATCH]]
146 ; CHECK-NEXT: [[TMP6]] = phi ptr addrspace(1) [ [[TMP27]], [[BB25]] ], [ [[TMP27]], [[BB7]] ]
147 ; CHECK-NEXT: br label [[HEADER]]
152 header: ; preds = %latch, %bb
153 %tmp = phi ptr addrspace(1) [ %tmp6, %latch ], [ poison, %bb ]
157 call void @spam() [ "deopt"(ptr addrspace(1) %tmp) ]
160 bb25: ; preds = %bb24
161 %tmp26 = call <2 x ptr addrspace(1)> @baz()
162 %tmp27 = extractelement <2 x ptr addrspace(1)> %tmp26, i32 0
163 br i1 %c, label %bb7, label %latch
168 latch: ; preds = %bb25, %bb7
169 %tmp6 = phi ptr addrspace(1) [ %tmp27, %bb25 ], [ %tmp27, %bb7 ]
174 declare <2 x ptr addrspace(1)> @baz()