Skip to content

Commit 6b21054

Browse files
committed
[Statepoint] Remove code related to inline operand bundles
This code becomes dead for valid IR after 48f4312 and a96fc46. The reason for the test change is that the verifier reports the first verification error encountered, in some non-specified visit order. By removing the verification code in gc.relocates for a statepoint with inline gc operands, I change the error the verifier reports. And in one case, the checked for error is no longer possible with the bundle representation, so I simply delete the file.
1 parent 48f4312 commit 6b21054

File tree

4 files changed

+11
-106
lines changed

4 files changed

+11
-106
lines changed

llvm/include/llvm/IR/Statepoint.h

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class GCStatepointInst : public CallBase {
136136
/// Return an end iterator of the arguments to the underlying call
137137
const_op_iterator actual_arg_end() const {
138138
auto I = actual_arg_begin() + actual_arg_size();
139-
assert((arg_end() - I) >= 0);
139+
assert((arg_end() - I) == 2);
140140
return I;
141141
}
142142
/// range adapter for actual call arguments
@@ -147,16 +147,12 @@ class GCStatepointInst : public CallBase {
147147
const_op_iterator gc_transition_args_begin() const {
148148
if (auto Opt = getOperandBundle(LLVMContext::OB_gc_transition))
149149
return Opt->Inputs.begin();
150-
auto I = actual_arg_end() + 1;
151-
assert((arg_end() - I) >= 0);
152-
return I;
150+
return arg_end();
153151
}
154152
const_op_iterator gc_transition_args_end() const {
155153
if (auto Opt = getOperandBundle(LLVMContext::OB_gc_transition))
156154
return Opt->Inputs.end();
157-
auto I = gc_transition_args_begin() + getNumDeoptArgs();
158-
assert((arg_end() - I) >= 0);
159-
return I;
155+
return arg_end();
160156
}
161157

162158
/// range adapter for GC transition arguments
@@ -167,19 +163,12 @@ class GCStatepointInst : public CallBase {
167163
const_op_iterator deopt_begin() const {
168164
if (auto Opt = getOperandBundle(LLVMContext::OB_deopt))
169165
return Opt->Inputs.begin();
170-
// The current format has two length prefix bundles between call args and
171-
// start of gc args. This will be removed in the near future.
172-
uint64_t NumTrans = getNumGCTransitionArgs();
173-
const_op_iterator I = actual_arg_end() + 2 + NumTrans;
174-
assert((arg_end() - I) >= 0);
175-
return I;
166+
return arg_end();
176167
}
177168
const_op_iterator deopt_end() const {
178169
if (auto Opt = getOperandBundle(LLVMContext::OB_deopt))
179170
return Opt->Inputs.end();
180-
auto I = deopt_begin() + getNumDeoptArgs();
181-
assert((arg_end() - I) >= 0);
182-
return I;
171+
return arg_end();
183172
}
184173

185174
/// range adapter for vm state arguments
@@ -192,30 +181,16 @@ class GCStatepointInst : public CallBase {
192181
const_op_iterator gc_args_begin() const {
193182
if (auto Opt = getOperandBundle(LLVMContext::OB_gc_live))
194183
return Opt->Inputs.begin();
195-
196-
// The current format has two length prefix bundles between call args and
197-
// start of gc args. This will be removed in the near future.
198-
uint64_t NumTrans = getNumGCTransitionArgs();
199-
uint64_t NumDeopt = getNumDeoptArgs();
200-
auto I = actual_arg_end() + 2 + NumTrans + NumDeopt;
201-
assert((arg_end() - I) >= 0);
202-
return I;
184+
return arg_end();
203185
}
204186

205187
/// Return an end iterator for the gc argument range
206188
const_op_iterator gc_args_end() const {
207189
if (auto Opt = getOperandBundle(LLVMContext::OB_gc_live))
208190
return Opt->Inputs.end();
209-
210191
return arg_end();
211192
}
212193

213-
/// Return the operand index at which the gc args begin
214-
unsigned gcArgsStartIdx() const {
215-
assert(!getOperandBundle(LLVMContext::OB_gc_live));
216-
return gc_args_begin() - op_begin();
217-
}
218-
219194
/// range adapter for gc arguments
220195
iterator_range<const_op_iterator> gc_args() const {
221196
return make_range(gc_args_begin(), gc_args_end());
@@ -236,19 +211,6 @@ class GCStatepointInst : public CallBase {
236211
return GRI;
237212
return nullptr;
238213
}
239-
240-
private:
241-
int getNumGCTransitionArgs() const {
242-
const Value *NumGCTransitionArgs = *actual_arg_end();
243-
return cast<ConstantInt>(NumGCTransitionArgs)->getZExtValue();
244-
}
245-
246-
int getNumDeoptArgs() const {
247-
uint64_t NumTrans = getNumGCTransitionArgs();
248-
const_op_iterator trans_end = actual_arg_end() + 1 + NumTrans;
249-
const Value *NumDeoptArgs = *trans_end;
250-
return cast<ConstantInt>(NumDeoptArgs)->getZExtValue();
251-
}
252214
};
253215

254216
/// Common base class for representing values projected from a statepoint.

llvm/lib/IR/Verifier.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,45 +4802,6 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
48024802
"gc.relocate: statepoint base index out of bounds", Call);
48034803
Assert(DerivedIndex < Opt->Inputs.size(),
48044804
"gc.relocate: statepoint derived index out of bounds", Call);
4805-
} else {
4806-
Assert(BaseIndex < StatepointCall.arg_size(),
4807-
"gc.relocate: statepoint base index out of bounds", Call);
4808-
Assert(DerivedIndex < StatepointCall.arg_size(),
4809-
"gc.relocate: statepoint derived index out of bounds", Call);
4810-
4811-
// Check that BaseIndex and DerivedIndex fall within the 'gc parameters'
4812-
// section of the statepoint's argument.
4813-
Assert(StatepointCall.arg_size() > 0,
4814-
"gc.statepoint: insufficient arguments");
4815-
Assert(isa<ConstantInt>(StatepointCall.getArgOperand(3)),
4816-
"gc.statement: number of call arguments must be constant integer");
4817-
const uint64_t NumCallArgs =
4818-
cast<ConstantInt>(StatepointCall.getArgOperand(3))->getZExtValue();
4819-
Assert(StatepointCall.arg_size() > NumCallArgs + 5,
4820-
"gc.statepoint: mismatch in number of call arguments");
4821-
Assert(isa<ConstantInt>(StatepointCall.getArgOperand(NumCallArgs + 5)),
4822-
"gc.statepoint: number of transition arguments must be "
4823-
"a constant integer");
4824-
const uint64_t NumTransitionArgs =
4825-
cast<ConstantInt>(StatepointCall.getArgOperand(NumCallArgs + 5))
4826-
->getZExtValue();
4827-
const uint64_t DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1;
4828-
Assert(isa<ConstantInt>(StatepointCall.getArgOperand(DeoptArgsStart)),
4829-
"gc.statepoint: number of deoptimization arguments must be "
4830-
"a constant integer");
4831-
const uint64_t NumDeoptArgs =
4832-
cast<ConstantInt>(StatepointCall.getArgOperand(DeoptArgsStart))
4833-
->getZExtValue();
4834-
const uint64_t GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs;
4835-
const uint64_t GCParamArgsEnd = StatepointCall.arg_size();
4836-
Assert(GCParamArgsStart <= BaseIndex && BaseIndex < GCParamArgsEnd,
4837-
"gc.relocate: statepoint base index doesn't fall within the "
4838-
"'gc parameters' section of the statepoint call",
4839-
Call);
4840-
Assert(GCParamArgsStart <= DerivedIndex && DerivedIndex < GCParamArgsEnd,
4841-
"gc.relocate: statepoint derived index doesn't fall within the "
4842-
"'gc parameters' section of the statepoint call",
4843-
Call);
48444805
}
48454806

48464807
// Relocated value must be either a pointer type or vector-of-pointer type,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: not opt -verify 2>&1 < %s | FileCheck %s
22

3-
; CHECK: gc.statepoint: mismatch in number of call arguments
3+
; CHECK: gc.statepoint mismatch in number of call args
44

55
declare zeroext i1 @return0i1()
66

@@ -10,11 +10,11 @@ declare token @llvm.experimental.gc.statepoint.p0f0i1f(i64, i32, i1 ()*, i32, i3
1010
; Function Attrs: nounwind
1111
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #0
1212

13-
define i32 addrspace(1)* @0(i32 addrspace(1)* %dparam) {
13+
define i32 addrspace(1)* @0(i32 addrspace(1)* %dparam) gc "statepoint-example" {
1414
%a00 = load i32, i32 addrspace(1)* %dparam
15-
%to0 = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f0i1f(i64 0, i32 0, i1 ()* @return0i1, i32 9, i32 0, i2 0, i32 addrspace(1)* %dparam)
16-
%relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %to0, i32 2, i32 6)
15+
%to0 = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f0i1f(i64 0, i32 0, i1 ()* @return0i1, i32 9, i32 0, i2 0) ["gc-live" (i32 addrspace(1)* %dparam)]
16+
%relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %to0, i32 0, i32 0)
1717
ret i32 addrspace(1)* %relocate
1818
}
1919

20-
attributes #0 = { nounwind }
20+
attributes #0 = { nounwind }

llvm/test/Verifier/invalid-statepoint2.ll

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)