From ff529e0f2792e1383a602e4b8a466337fd0c2926 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Wed, 3 Jun 2020 15:09:03 -0700 Subject: [PATCH] [Statepoint] Fix signed vs unsigned in index handling As noted in a comment on D80937, all of these are specified as unsigned values, but the verifier code was using signed. Given the practical values involved, the different in range didn't matter, but we might as well clean it up. --- llvm/lib/IR/Verifier.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 00225c2..3caad20 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4748,19 +4748,19 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) { Assert(isa(Derived), "gc.relocate operand #3 must be integer offset", Call); - const int BaseIndex = cast(Base)->getZExtValue(); - const int DerivedIndex = cast(Derived)->getZExtValue(); + const uint64_t BaseIndex = cast(Base)->getZExtValue(); + const uint64_t DerivedIndex = cast(Derived)->getZExtValue(); // Check the bounds if (auto Opt = StatepointCall.getOperandBundle(LLVMContext::OB_gc_live)) { - Assert(0 <= BaseIndex && BaseIndex < (int)Opt->Inputs.size(), + Assert(BaseIndex < Opt->Inputs.size(), "gc.relocate: statepoint base index out of bounds", Call); - Assert(0 <= DerivedIndex && DerivedIndex < (int)Opt->Inputs.size(), + Assert(DerivedIndex < Opt->Inputs.size(), "gc.relocate: statepoint derived index out of bounds", Call); } else { - Assert(0 <= BaseIndex && BaseIndex < (int)StatepointCall.arg_size(), + Assert(BaseIndex < StatepointCall.arg_size(), "gc.relocate: statepoint base index out of bounds", Call); - Assert(0 <= DerivedIndex && DerivedIndex < (int)StatepointCall.arg_size(), + Assert(DerivedIndex < StatepointCall.arg_size(), "gc.relocate: statepoint derived index out of bounds", Call); // Check that BaseIndex and DerivedIndex fall within the 'gc parameters' @@ -4769,25 +4769,25 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) { "gc.statepoint: insufficient arguments"); Assert(isa(StatepointCall.getArgOperand(3)), "gc.statement: number of call arguments must be constant integer"); - const unsigned NumCallArgs = + 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 int NumTransitionArgs = + const uint64_t NumTransitionArgs = cast(StatepointCall.getArgOperand(NumCallArgs + 5)) ->getZExtValue(); - const int DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1; + 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 int NumDeoptArgs = + const uint64_t NumDeoptArgs = cast(StatepointCall.getArgOperand(DeoptArgsStart)) ->getZExtValue(); - const int GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs; - const int GCParamArgsEnd = StatepointCall.arg_size(); + 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", -- 2.7.4