[llvm] ff529e0 - [Statepoint] Fix signed vs unsigned in index handling

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 15:10:29 PDT 2020


Author: Philip Reames
Date: 2020-06-03T15:10:20-07:00
New Revision: ff529e0f2792e1383a602e4b8a466337fd0c2926

URL: https://github.com/llvm/llvm-project/commit/ff529e0f2792e1383a602e4b8a466337fd0c2926
DIFF: https://github.com/llvm/llvm-project/commit/ff529e0f2792e1383a602e4b8a466337fd0c2926.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/IR/Verifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 00225c22bbc5..3caad20b047c 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<ConstantInt>(Derived),
            "gc.relocate operand #3 must be integer offset", Call);
 
-    const int BaseIndex = cast<ConstantInt>(Base)->getZExtValue();
-    const int DerivedIndex = cast<ConstantInt>(Derived)->getZExtValue();
+    const uint64_t BaseIndex = cast<ConstantInt>(Base)->getZExtValue();
+    const uint64_t DerivedIndex = cast<ConstantInt>(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<ConstantInt>(StatepointCall.getArgOperand(3)),
              "gc.statement: number of call arguments must be constant integer");
-      const unsigned NumCallArgs =
+      const uint64_t NumCallArgs =
         cast<ConstantInt>(StatepointCall.getArgOperand(3))->getZExtValue();
       Assert(StatepointCall.arg_size() > NumCallArgs + 5,
              "gc.statepoint: mismatch in number of call arguments");
       Assert(isa<ConstantInt>(StatepointCall.getArgOperand(NumCallArgs + 5)),
              "gc.statepoint: number of transition arguments must be "
              "a constant integer");
-      const int NumTransitionArgs =
+      const uint64_t NumTransitionArgs =
           cast<ConstantInt>(StatepointCall.getArgOperand(NumCallArgs + 5))
               ->getZExtValue();
-      const int DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1;
+      const uint64_t DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1;
       Assert(isa<ConstantInt>(StatepointCall.getArgOperand(DeoptArgsStart)),
              "gc.statepoint: number of deoptimization arguments must be "
              "a constant integer");
-      const int NumDeoptArgs =
+      const uint64_t NumDeoptArgs =
           cast<ConstantInt>(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",


        


More information about the llvm-commits mailing list