diff --git a/include/llvm/IR/Statepoint.h b/include/llvm/IR/Statepoint.h index 1ace39c1070..6ce15839df4 100644 --- a/include/llvm/IR/Statepoint.h +++ b/include/llvm/IR/Statepoint.h @@ -136,7 +136,7 @@ public: /// Return an end iterator of the arguments to the underlying call const_op_iterator actual_arg_end() const { auto I = actual_arg_begin() + actual_arg_size(); - assert((arg_end() - I) >= 0); + assert((arg_end() - I) == 2); return I; } /// range adapter for actual call arguments @@ -147,16 +147,12 @@ public: const_op_iterator gc_transition_args_begin() const { if (auto Opt = getOperandBundle(LLVMContext::OB_gc_transition)) return Opt->Inputs.begin(); - auto I = actual_arg_end() + 1; - assert((arg_end() - I) >= 0); - return I; + return arg_end(); } const_op_iterator gc_transition_args_end() const { if (auto Opt = getOperandBundle(LLVMContext::OB_gc_transition)) return Opt->Inputs.end(); - auto I = gc_transition_args_begin() + getNumDeoptArgs(); - assert((arg_end() - I) >= 0); - return I; + return arg_end(); } /// range adapter for GC transition arguments @@ -167,19 +163,12 @@ public: const_op_iterator deopt_begin() const { if (auto Opt = getOperandBundle(LLVMContext::OB_deopt)) return Opt->Inputs.begin(); - // The current format has two length prefix bundles between call args and - // start of gc args. This will be removed in the near future. - uint64_t NumTrans = getNumGCTransitionArgs(); - const_op_iterator I = actual_arg_end() + 2 + NumTrans; - assert((arg_end() - I) >= 0); - return I; + return arg_end(); } const_op_iterator deopt_end() const { if (auto Opt = getOperandBundle(LLVMContext::OB_deopt)) return Opt->Inputs.end(); - auto I = deopt_begin() + getNumDeoptArgs(); - assert((arg_end() - I) >= 0); - return I; + return arg_end(); } /// range adapter for vm state arguments @@ -192,30 +181,16 @@ public: const_op_iterator gc_args_begin() const { if (auto Opt = getOperandBundle(LLVMContext::OB_gc_live)) return Opt->Inputs.begin(); - - // The current format has two length prefix bundles between call args and - // start of gc args. This will be removed in the near future. - uint64_t NumTrans = getNumGCTransitionArgs(); - uint64_t NumDeopt = getNumDeoptArgs(); - auto I = actual_arg_end() + 2 + NumTrans + NumDeopt; - assert((arg_end() - I) >= 0); - return I; + return arg_end(); } /// Return an end iterator for the gc argument range const_op_iterator gc_args_end() const { if (auto Opt = getOperandBundle(LLVMContext::OB_gc_live)) return Opt->Inputs.end(); - return arg_end(); } - /// Return the operand index at which the gc args begin - unsigned gcArgsStartIdx() const { - assert(!getOperandBundle(LLVMContext::OB_gc_live)); - return gc_args_begin() - op_begin(); - } - /// range adapter for gc arguments iterator_range gc_args() const { return make_range(gc_args_begin(), gc_args_end()); @@ -236,19 +211,6 @@ public: return GRI; return nullptr; } - -private: - int getNumGCTransitionArgs() const { - const Value *NumGCTransitionArgs = *actual_arg_end(); - return cast(NumGCTransitionArgs)->getZExtValue(); - } - - int getNumDeoptArgs() const { - uint64_t NumTrans = getNumGCTransitionArgs(); - const_op_iterator trans_end = actual_arg_end() + 1 + NumTrans; - const Value *NumDeoptArgs = *trans_end; - return cast(NumDeoptArgs)->getZExtValue(); - } }; /// Common base class for representing values projected from a statepoint. diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 8a12dc5fe51..db52f36e4f1 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -4802,45 +4802,6 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) { "gc.relocate: statepoint base index out of bounds", Call); Assert(DerivedIndex < Opt->Inputs.size(), "gc.relocate: statepoint derived index out of bounds", Call); - } else { - Assert(BaseIndex < StatepointCall.arg_size(), - "gc.relocate: statepoint base index out of bounds", Call); - Assert(DerivedIndex < StatepointCall.arg_size(), - "gc.relocate: statepoint derived index out of bounds", Call); - - // Check that BaseIndex and DerivedIndex fall within the 'gc parameters' - // section of the statepoint's argument. - Assert(StatepointCall.arg_size() > 0, - "gc.statepoint: insufficient arguments"); - Assert(isa(StatepointCall.getArgOperand(3)), - "gc.statement: number of call arguments must be constant integer"); - const uint64_t NumCallArgs = - cast(StatepointCall.getArgOperand(3))->getZExtValue(); - Assert(StatepointCall.arg_size() > NumCallArgs + 5, - "gc.statepoint: mismatch in number of call arguments"); - Assert(isa(StatepointCall.getArgOperand(NumCallArgs + 5)), - "gc.statepoint: number of transition arguments must be " - "a constant integer"); - const uint64_t NumTransitionArgs = - cast(StatepointCall.getArgOperand(NumCallArgs + 5)) - ->getZExtValue(); - const uint64_t DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1; - Assert(isa(StatepointCall.getArgOperand(DeoptArgsStart)), - "gc.statepoint: number of deoptimization arguments must be " - "a constant integer"); - const uint64_t NumDeoptArgs = - cast(StatepointCall.getArgOperand(DeoptArgsStart)) - ->getZExtValue(); - const uint64_t GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs; - const uint64_t GCParamArgsEnd = StatepointCall.arg_size(); - Assert(GCParamArgsStart <= BaseIndex && BaseIndex < GCParamArgsEnd, - "gc.relocate: statepoint base index doesn't fall within the " - "'gc parameters' section of the statepoint call", - Call); - Assert(GCParamArgsStart <= DerivedIndex && DerivedIndex < GCParamArgsEnd, - "gc.relocate: statepoint derived index doesn't fall within the " - "'gc parameters' section of the statepoint call", - Call); } // Relocated value must be either a pointer type or vector-of-pointer type, diff --git a/test/Verifier/invalid-statepoint.ll b/test/Verifier/invalid-statepoint.ll index 6b4bc087b3e..c0e25c1aab3 100644 --- a/test/Verifier/invalid-statepoint.ll +++ b/test/Verifier/invalid-statepoint.ll @@ -1,6 +1,6 @@ ; RUN: not opt -verify 2>&1 < %s | FileCheck %s -; CHECK: gc.statepoint: mismatch in number of call arguments +; CHECK: gc.statepoint mismatch in number of call args declare zeroext i1 @return0i1() @@ -10,11 +10,11 @@ declare token @llvm.experimental.gc.statepoint.p0f0i1f(i64, i32, i1 ()*, i32, i3 ; Function Attrs: nounwind declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #0 -define i32 addrspace(1)* @0(i32 addrspace(1)* %dparam) { +define i32 addrspace(1)* @0(i32 addrspace(1)* %dparam) gc "statepoint-example" { %a00 = load i32, i32 addrspace(1)* %dparam - %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) - %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %to0, i32 2, i32 6) + %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)] + %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %to0, i32 0, i32 0) ret i32 addrspace(1)* %relocate } -attributes #0 = { nounwind } \ No newline at end of file +attributes #0 = { nounwind } diff --git a/test/Verifier/invalid-statepoint2.ll b/test/Verifier/invalid-statepoint2.ll deleted file mode 100644 index 10bcd4f4f31..00000000000 --- a/test/Verifier/invalid-statepoint2.ll +++ /dev/null @@ -1,18 +0,0 @@ -; RUN: not opt -S < %s -verify 2>&1 | FileCheck %s - -; CHECK: gc.statepoint: number of deoptimization arguments must be a constant integer - -declare void @use(...) -declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32, i32) -declare i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token, i32, i32) -declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) -declare i32 @"personality_function"() - -;; Basic usage -define i64 addrspace(1)* @test1(i8 addrspace(1)* %arg, i32 %val) gc "statepoint-example" { -entry: - %cast = bitcast i8 addrspace(1)* %arg to i64 addrspace(1)* - %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 %val, i32 0, i32 0, i32 0, i32 10, i32 0, i8 addrspace(1)* %arg, i64 addrspace(1)* %cast, i8 addrspace(1)* %arg, i8 addrspace(1)* %arg) - %reloc = call i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token %safepoint_token, i32 12, i32 13) - ret i64 addrspace(1)* %reloc -}