llvm-project

Форк
0
387 строк · 25.8 Кб
1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2
; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck  %s
3

4

5
define ptr addrspace(1) @test(<2 x ptr addrspace(1)> %vec, i32 %idx) gc "statepoint-example" {
6
; Note that the second extractelement is actually redundant here.  A correct output would
7
; be to reuse the existing obj as a base since it is actually a base pointer.
8
; CHECK-LABEL: @test(
9
; CHECK-NEXT:  entry:
10
; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC:%.*]], i32 [[IDX:%.*]]
11
; 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]]) ]
12
; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
13
; CHECK-NEXT:    ret ptr addrspace(1) [[OBJ_RELOCATED]]
14
;
15
entry:
16
  %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx
17
  call void @do_safepoint() [ "deopt"() ]
18
  ret ptr addrspace(1) %obj
19
}
20

21
define ptr addrspace(1) @test2(ptr %ptr, i1 %cnd, i32 %idx1, i32 %idx2) gc "statepoint-example" {
22
; CHECK-LABEL: @test2(
23
; CHECK-NEXT:  entry:
24
; CHECK-NEXT:    br i1 [[CND:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
25
; CHECK:       taken:
26
; CHECK-NEXT:    [[OBJA:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR:%.*]], align 16
27
; CHECK-NEXT:    br label [[MERGE:%.*]]
28
; CHECK:       untaken:
29
; CHECK-NEXT:    [[OBJB:%.*]] = load <2 x ptr addrspace(1)>, ptr [[PTR]], align 16
30
; CHECK-NEXT:    br label [[MERGE]]
31
; CHECK:       merge:
32
; CHECK-NEXT:    [[VEC:%.*]] = phi <2 x ptr addrspace(1)> [ [[OBJA]], [[TAKEN]] ], [ [[OBJB]], [[UNTAKEN]] ]
33
; CHECK-NEXT:    br i1 [[CND]], label [[TAKEN2:%.*]], label [[UNTAKEN2:%.*]]
34
; CHECK:       taken2:
35
; CHECK-NEXT:    [[OBJ0:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 [[IDX1:%.*]]
36
; CHECK-NEXT:    br label [[MERGE2:%.*]]
37
; CHECK:       untaken2:
38
; CHECK-NEXT:    [[OBJ1:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 [[IDX2:%.*]]
39
; CHECK-NEXT:    br label [[MERGE2]]
40
; CHECK:       merge2:
41
; CHECK-NEXT:    [[OBJ:%.*]] = phi ptr addrspace(1) [ [[OBJ0]], [[TAKEN2]] ], [ [[OBJ1]], [[UNTAKEN2]] ]
42
; 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]]) ]
43
; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
44
; CHECK-NEXT:    ret ptr addrspace(1) [[OBJ_RELOCATED]]
45
;
46
entry:
47
  br i1 %cnd, label %taken, label %untaken
48

49
taken:                                            ; preds = %entry
50
  %obja = load <2 x ptr addrspace(1)>, ptr %ptr
51
  br label %merge
52

53
untaken:                                          ; preds = %entry
54
  %objb = load <2 x ptr addrspace(1)>, ptr %ptr
55
  br label %merge
56

57
merge:                                            ; preds = %untaken, %taken
58
  %vec = phi <2 x ptr addrspace(1)> [ %obja, %taken ], [ %objb, %untaken ]
59
  br i1 %cnd, label %taken2, label %untaken2
60

61
taken2:                                           ; preds = %merge
62
  %obj0 = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx1
63
  br label %merge2
64

65
untaken2:                                         ; preds = %merge
66
  %obj1 = extractelement <2 x ptr addrspace(1)> %vec, i32 %idx2
67
  br label %merge2
68

69
merge2:                                           ; preds = %untaken2, %taken2
70
  %obj = phi ptr addrspace(1) [ %obj0, %taken2 ], [ %obj1, %untaken2 ]
71
  call void @do_safepoint() [ "deopt"() ]
72
  ret ptr addrspace(1) %obj
73
}
74

75
define ptr addrspace(1) @test3(ptr addrspace(1) %ptr) gc "statepoint-example" {
76
; CHECK-LABEL: @test3(
77
; CHECK-NEXT:  entry:
78
; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[PTR:%.*]], i32 0, !is_base_value !0
79
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[PTR]], i32 0
80
; CHECK-NEXT:    [[OBJ_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
81
; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
82
; 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]], ptr addrspace(1) [[OBJ_BASE]]) ]
83
; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
84
; CHECK-NEXT:    [[OBJ_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
85
; CHECK-NEXT:    ret ptr addrspace(1) [[OBJ_RELOCATED]]
86
;
87
entry:
88
  %vec = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %ptr, i32 0
89
  %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 0
90
  call void @do_safepoint() [ "deopt"() ]
91
  ret ptr addrspace(1) %obj
92
}
93

94
define ptr addrspace(1) @test4(ptr addrspace(1) %ptr) gc "statepoint-example" {
95
; When we can optimize an extractelement from a known
96
; index and avoid introducing new base pointer instructions
97
; CHECK-LABEL: @test4(
98
; CHECK-NEXT:  entry:
99
; CHECK-NEXT:    [[DERIVED:%.*]] = getelementptr i64, ptr addrspace(1) [[PTR:%.*]], i64 16
100
; CHECK-NEXT:    [[VECA_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[PTR]], i32 0, !is_base_value !0
101
; CHECK-NEXT:    [[VECA:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[DERIVED]], i32 0
102
; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> [[VECA_BASE]], ptr addrspace(1) [[PTR]], i32 1, !is_base_value !0
103
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> [[VECA]], ptr addrspace(1) [[PTR]], i32 1
104
; CHECK-NEXT:    [[OBJ_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
105
; CHECK-NEXT:    [[OBJ:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
106
; 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]], ptr addrspace(1) [[OBJ_BASE]]) ]
107
; CHECK-NEXT:    [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
108
; CHECK-NEXT:    [[OBJ_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
109
; CHECK-NEXT:    ret ptr addrspace(1) [[OBJ_RELOCATED]]
110
;
111
entry:
112
  %derived = getelementptr i64, ptr addrspace(1) %ptr, i64 16
113
  %veca = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %derived, i32 0
114
  %vec = insertelement <2 x ptr addrspace(1)> %veca, ptr addrspace(1) %ptr, i32 1
115
  %obj = extractelement <2 x ptr addrspace(1)> %vec, i32 0
116
  call void @do_safepoint() [ "deopt"() ]
117
  ret ptr addrspace(1) %obj
118
}
119

120
declare void @use(ptr addrspace(1)) "gc-leaf-function"
121
declare void @use_vec(<4 x ptr addrspace(1)>) "gc-leaf-function"
122

123
define void @test5(i1 %cnd, ptr addrspace(1) %obj) gc "statepoint-example" {
124
; When we fundementally have to duplicate
125
; CHECK-LABEL: @test5(
126
; CHECK-NEXT:  entry:
127
; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
128
; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
129
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[GEP]], i32 0
130
; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i32 0, !is_base_value !0
131
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i32 0
132
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
133
; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
134
; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
135
; CHECK-NEXT:    call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
136
; CHECK-NEXT:    ret void
137
;
138
entry:
139
  %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
140
  %vec = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %gep, i32 0
141
  %bdv = extractelement <2 x ptr addrspace(1)> %vec, i32 0
142
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
143
  call void @use(ptr addrspace(1) %bdv)
144
  ret void
145
}
146

147
define void @test6(i1 %cnd, ptr addrspace(1) %obj, i64 %idx) gc "statepoint-example" {
148
; A more complicated example involving vector and scalar bases.
149
; This is derived from a failing test case when we didn't have correct
150
; insertelement handling.
151
; CHECK-LABEL: @test6(
152
; CHECK-NEXT:  entry:
153
; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
154
; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
155
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[GEP]], i32 0
156
; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
157
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX]]
158
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
159
; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
160
; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
161
; CHECK-NEXT:    call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
162
; CHECK-NEXT:    ret void
163
;
164
entry:
165
  %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
166
  %vec = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %gep, i32 0
167
  %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
168
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
169
  call void @use(ptr addrspace(1) %bdv)
170
  ret void
171
}
172

173
define ptr addrspace(1) @test7(i1 %cnd, ptr addrspace(1) %obj, ptr addrspace(1) %obj2) gc "statepoint-example" {
174
; CHECK-LABEL: @test7(
175
; CHECK-NEXT:  entry:
176
; CHECK-NEXT:    [[VEC_BASE:%.*]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2:%.*]], i32 0, !is_base_value !0
177
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[OBJ2]], i32 0
178
; CHECK-NEXT:    br label [[MERGE1:%.*]]
179
; CHECK:       merge1:
180
; CHECK-NEXT:    [[VEC2_BASE:%.*]] = phi <2 x ptr addrspace(1)> [ [[VEC_BASE]], [[ENTRY:%.*]] ], [ [[VEC3_BASE:%.*]], [[MERGE1]] ], !is_base_value !0
181
; CHECK-NEXT:    [[VEC2:%.*]] = phi <2 x ptr addrspace(1)> [ [[VEC]], [[ENTRY]] ], [ [[VEC3:%.*]], [[MERGE1]] ]
182
; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ2]], i64 1
183
; CHECK-NEXT:    [[VEC3_BASE]] = insertelement <2 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2]], i32 0, !is_base_value !0
184
; CHECK-NEXT:    [[VEC3]] = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) [[GEP]], i32 0
185
; CHECK-NEXT:    br i1 [[CND:%.*]], label [[MERGE1]], label [[NEXT1:%.*]]
186
; CHECK:       next1:
187
; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC2_BASE]], i32 0, !is_base_value !0
188
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC2]], i32 0
189
; CHECK-NEXT:    br label [[MERGE:%.*]]
190
; CHECK:       merge:
191
; CHECK-NEXT:    [[OBJB_BASE:%.*]] = phi ptr addrspace(1) [ [[OBJ:%.*]], [[NEXT1]] ], [ [[BDV_BASE]], [[MERGE]] ], !is_base_value !0
192
; CHECK-NEXT:    [[OBJB:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[NEXT1]] ], [ [[BDV]], [[MERGE]] ]
193
; CHECK-NEXT:    br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
194
; CHECK:       next:
195
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[OBJB]], ptr addrspace(1) [[OBJB_BASE]]) ]
196
; CHECK-NEXT:    [[OBJB_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
197
; CHECK-NEXT:    [[OBJB_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
198
; CHECK-NEXT:    ret ptr addrspace(1) [[OBJB_RELOCATED]]
199
;
200
entry:
201
  %vec = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %obj2, i32 0
202
  br label %merge1
203

204
merge1:                                           ; preds = %merge1, %entry
205
  %vec2 = phi <2 x ptr addrspace(1)> [ %vec, %entry ], [ %vec3, %merge1 ]
206
  %gep = getelementptr i64, ptr addrspace(1) %obj2, i64 1
207
  %vec3 = insertelement <2 x ptr addrspace(1)> undef, ptr addrspace(1) %gep, i32 0
208
  br i1 %cnd, label %merge1, label %next1
209

210
next1:                                            ; preds = %merge1
211
  %bdv = extractelement <2 x ptr addrspace(1)> %vec2, i32 0
212
  br label %merge
213

214
merge:                                            ; preds = %merge, %next1
215
  %objb = phi ptr addrspace(1) [ %obj, %next1 ], [ %bdv, %merge ]
216
  br i1 %cnd, label %merge, label %next
217

218
next:                                             ; preds = %merge
219
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
220
  ret ptr addrspace(1) %objb
221
}
222

223
; identify base for shufflevector
224
define void @test8(ptr addrspace(1) %obj, i64 %idx) gc "statepoint-example" {
225
; CHECK-LABEL: @test8(
226
; CHECK-NEXT:  entry:
227
; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ:%.*]], i64 1
228
; CHECK-NEXT:    [[GEP2:%.*]] = getelementptr i64, ptr addrspace(1) [[OBJ]], i64 2
229
; CHECK-NEXT:    [[VEC1_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 0, !is_base_value !0
230
; CHECK-NEXT:    [[VEC1:%.*]] = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) [[GEP]], i32 0
231
; CHECK-NEXT:    [[VEC2_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ]], i32 2, !is_base_value !0
232
; CHECK-NEXT:    [[VEC2:%.*]] = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) [[GEP2]], i32 2
233
; CHECK-NEXT:    [[VEC_BASE:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1_BASE]], <4 x ptr addrspace(1)> [[VEC2_BASE]], <2 x i32> <i32 0, i32 2>, !is_base_value !0
234
; CHECK-NEXT:    [[VEC:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1]], <4 x ptr addrspace(1)> [[VEC2]], <2 x i32> <i32 0, i32 2>
235
; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC_BASE]], i64 [[IDX:%.*]], !is_base_value !0
236
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX]]
237
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
238
; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
239
; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
240
; CHECK-NEXT:    call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
241
; CHECK-NEXT:    ret void
242
;
243
entry:
244
  %gep = getelementptr i64, ptr addrspace(1) %obj, i64 1
245
  %gep2 = getelementptr i64, ptr addrspace(1) %obj, i64 2
246
  %vec1 = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) %gep, i32 0
247
  %vec2 = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) %gep2, i32 2
248
  %vec = shufflevector <4 x ptr addrspace(1)> %vec1, <4 x ptr addrspace(1)> %vec2, <2 x i32> <i32 0, i32 2>
249
  %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
250
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
251
  call void @use(ptr addrspace(1) %bdv)
252
  ret void
253
}
254

255
; Since the same 'base' vector is used in the shuffle operands, we do not need
256
; create a shufflevector base.
257
define void @test9(<4 x ptr addrspace(1)> %vec1, i64 %idx) gc "statepoint-example" {
258
; CHECK-LABEL: @test9(
259
; CHECK-NEXT:  entry:
260
; CHECK-NEXT:    [[VEC:%.*]] = shufflevector <4 x ptr addrspace(1)> [[VEC1:%.*]], <4 x ptr addrspace(1)> [[VEC1]], <2 x i32> <i32 0, i32 2>
261
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <2 x ptr addrspace(1)> [[VEC]], i64 [[IDX:%.*]]
262
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]]) ]
263
; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
264
; CHECK-NEXT:    call void @use(ptr addrspace(1) [[BDV_RELOCATED]])
265
; CHECK-NEXT:    ret void
266
;
267
entry:
268
  ; shrinking vec1 into vec
269
  %vec = shufflevector <4 x ptr addrspace(1)> %vec1, <4 x ptr addrspace(1)> %vec1, <2 x i32> <i32 0, i32 2>
270
  %bdv = extractelement <2 x ptr addrspace(1)> %vec, i64 %idx
271
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
272
  call void @use(ptr addrspace(1) %bdv)
273
  ret void
274
}
275

276
; vector operand of shufflevector is a phi
277
define ptr addrspace(1) @test10(i1 %cnd, ptr addrspace(1) %obj, ptr addrspace(1) %obj2) gc "statepoint-example" {
278
; CHECK-LABEL: @test10(
279
; CHECK-NEXT:  entry:
280
; CHECK-NEXT:    [[VEC1_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ:%.*]], i32 0, !is_base_value !0
281
; CHECK-NEXT:    [[VEC1:%.*]] = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) [[OBJ]], i32 0
282
; CHECK-NEXT:    br i1 [[CND:%.*]], label [[HERE:%.*]], label [[MERGE:%.*]]
283
; CHECK:       here:
284
; CHECK-NEXT:    [[VEC2_BASE:%.*]] = insertelement <4 x ptr addrspace(1)> zeroinitializer, ptr addrspace(1) [[OBJ2:%.*]], i32 2, !is_base_value !0
285
; CHECK-NEXT:    [[VEC2:%.*]] = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) [[OBJ2]], i32 2
286
; CHECK-NEXT:    br label [[MERGE]]
287
; CHECK:       merge:
288
; CHECK-NEXT:    [[VEC_BASE:%.*]] = phi <4 x ptr addrspace(1)> [ [[VEC1_BASE]], [[ENTRY:%.*]] ], [ [[VEC2_BASE]], [[HERE]] ], [ [[VEC3_BASE:%.*]], [[MERGE]] ], !is_base_value !0
289
; CHECK-NEXT:    [[VEC:%.*]] = phi <4 x ptr addrspace(1)> [ [[VEC1]], [[ENTRY]] ], [ [[VEC2]], [[HERE]] ], [ [[VEC3:%.*]], [[MERGE]] ]
290
; CHECK-NEXT:    [[VEC3_BASE]] = shufflevector <4 x ptr addrspace(1)> [[VEC_BASE]], <4 x ptr addrspace(1)> [[VEC_BASE]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>, !is_base_value !0
291
; CHECK-NEXT:    [[VEC3]] = shufflevector <4 x ptr addrspace(1)> [[VEC]], <4 x ptr addrspace(1)> [[VEC]], <4 x i32> <i32 2, i32 0, i32 1, i32 3>
292
; CHECK-NEXT:    [[BDV_BASE:%.*]] = extractelement <4 x ptr addrspace(1)> [[VEC3_BASE]], i32 0, !is_base_value !0
293
; CHECK-NEXT:    [[BDV:%.*]] = extractelement <4 x ptr addrspace(1)> [[VEC3]], i32 0
294
; CHECK-NEXT:    br i1 [[CND]], label [[MERGE]], label [[NEXT:%.*]]
295
; CHECK:       next:
296
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[BDV]], ptr addrspace(1) [[BDV_BASE]]) ]
297
; CHECK-NEXT:    [[BDV_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
298
; CHECK-NEXT:    [[BDV_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
299
; CHECK-NEXT:    ret ptr addrspace(1) [[BDV_RELOCATED]]
300
;
301
entry:
302
  %vec1 = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) %obj, i32 0
303
  br i1 %cnd, label %here, label %merge
304

305
here:
306
  %vec2 = insertelement <4 x ptr addrspace(1)> undef, ptr addrspace(1) %obj2, i32 2
307
  br label %merge
308

309
merge:                                           ; preds = %merge, %entry, %here
310
  %vec = phi <4 x ptr addrspace(1)> [ %vec1, %entry ], [ %vec2, %here], [ %vec3, %merge]
311
  %vec3 = shufflevector <4 x ptr addrspace(1)> %vec, <4 x ptr addrspace(1)> %vec, <4 x i32> <i32 2, i32 0, i32 1, i32 3>
312
  %bdv = extractelement <4 x ptr addrspace(1)> %vec3, i32 0
313
  br i1 %cnd, label %merge, label %next
314

315
next:
316
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
317
  ret ptr addrspace(1) %bdv
318
}
319
declare void @do_safepoint()
320

321
define void @test11(<4 x ptr addrspace(1)> %vec1) gc "statepoint-example" {
322
; CHECK-LABEL: @test11(
323
; CHECK-NEXT:  entry:
324
; CHECK-NEXT:    [[VEC2:%.*]] = getelementptr i64, <4 x ptr addrspace(1)> [[VEC1:%.*]], i32 1024
325
; 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"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(<4 x ptr addrspace(1)> [[VEC1]]) ]
326
; CHECK-NEXT:    [[VEC1_RELOCATED:%.*]] = call coldcc <4 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v4p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
327
; CHECK-NEXT:    [[VEC2_REMAT:%.*]] = getelementptr i64, <4 x ptr addrspace(1)> [[VEC1_RELOCATED]], i32 1024
328
; CHECK-NEXT:    call void @use_vec(<4 x ptr addrspace(1)> [[VEC2_REMAT]])
329
; CHECK-NEXT:    ret void
330
;
331
entry:
332
  %vec2 = getelementptr i64, <4 x ptr addrspace(1)> %vec1, i32 1024
333
  call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
334
  call void @use_vec(<4 x ptr addrspace(1)> %vec2)
335
  ret void
336
}
337

338
declare <4 x ptr addrspace(1)> @def_vec() "gc-leaf-function"
339

340
define void @test12(<4 x ptr addrspace(1)> %vec1) gc "statepoint-example" {
341
; CHECK-LABEL: @test12(
342
; CHECK-NEXT:  entry:
343
; CHECK-NEXT:    [[VEC:%.*]] = call <4 x ptr addrspace(1)> @def_vec()
344
; 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"(<4 x ptr addrspace(1)> [[VEC]]) ]
345
; CHECK-NEXT:    [[VEC_RELOCATED:%.*]] = call coldcc <4 x ptr addrspace(1)> @llvm.experimental.gc.relocate.v4p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
346
; CHECK-NEXT:    call void @use_vec(<4 x ptr addrspace(1)> [[VEC_RELOCATED]])
347
; CHECK-NEXT:    ret void
348
;
349
entry:
350
  %vec = call <4 x ptr addrspace(1)> @def_vec()
351
  call void @do_safepoint() [ "deopt"() ]
352
  call void @use_vec(<4 x ptr addrspace(1)> %vec)
353
  ret void
354
}
355

356
define i32 @test13() gc "statepoint-example" {
357
; CHECK-LABEL: define i32 @test13() gc "statepoint-example" {
358
; CHECK-NEXT:  bb:
359
; CHECK-NEXT:    [[GETELEMENTPTR:%.*]] = getelementptr i8, <2 x ptr addrspace(1)> zeroinitializer, <2 x i64> <i64 948, i64 896>
360
; CHECK-NEXT:    [[SHUFFLEVECTOR_BASE:%.*]] = shufflevector <2 x ptr addrspace(1)> zeroinitializer, <2 x ptr addrspace(1)> zeroinitializer, <4 x i32> <i32 0, i32 3, i32 1, i32 2>, !is_base_value !0
361
; CHECK-NEXT:    [[SHUFFLEVECTOR:%.*]] = shufflevector <2 x ptr addrspace(1)> zeroinitializer, <2 x ptr addrspace(1)> [[GETELEMENTPTR]], <4 x i32> <i32 0, i32 3, i32 1, i32 2>
362
; CHECK-NEXT:    br label [[BB1:%.*]]
363
; CHECK:       bb1:
364
; CHECK-NEXT:    [[PHI_BASE:%.*]] = phi <4 x ptr addrspace(1)> [ [[SHUFFLEVECTOR_BASE]], [[BB:%.*]] ], [ zeroinitializer, [[BB1]] ], !is_base_value !0
365
; CHECK-NEXT:    [[PHI:%.*]] = phi <4 x ptr addrspace(1)> [ [[SHUFFLEVECTOR]], [[BB]] ], [ zeroinitializer, [[BB1]] ]
366
; CHECK-NEXT:    [[EXTRACTELEMENT_BASE:%.*]] = extractelement <4 x ptr addrspace(1)> [[PHI_BASE]], i32 0, !is_base_value !0
367
; CHECK-NEXT:    [[EXTRACTELEMENT:%.*]] = extractelement <4 x ptr addrspace(1)> [[PHI]], i32 0
368
; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @spam, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) [[EXTRACTELEMENT]], ptr addrspace(1) [[EXTRACTELEMENT_BASE]]) ]
369
; CHECK-NEXT:    [[EXTRACTELEMENT_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
370
; CHECK-NEXT:    [[EXTRACTELEMENT_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
371
; CHECK-NEXT:    [[LOAD:%.*]] = load i32, ptr addrspace(1) [[EXTRACTELEMENT_RELOCATED]], align 4
372
; CHECK-NEXT:    br label [[BB1]]
373
;
374
bb:
375
  %getelementptr = getelementptr i8, <2 x ptr addrspace(1)> zeroinitializer, <2 x i64> <i64 948, i64 896>
376
  %shufflevector = shufflevector <2 x ptr addrspace(1)> zeroinitializer, <2 x ptr addrspace(1)> %getelementptr, <4 x i32> <i32 0, i32 3, i32 1, i32 2>
377
  br label %bb1
378

379
bb1:                                              ; preds = %bb1, %bb
380
  %phi = phi <4 x ptr addrspace(1)> [ %shufflevector, %bb ], [ zeroinitializer, %bb1 ]
381
  %extractelement = extractelement <4 x ptr addrspace(1)> %phi, i32 0
382
  %call = call i32 @spam()
383
  %load = load i32, ptr addrspace(1) %extractelement, align 4
384
  br label %bb1
385
}
386

387
declare i32 @spam() gc "statepoint-example"

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.