[PATCH] D38677: [ConstantFold] Fix a crash when folding a GEP that has vector index

Haicheng Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 13:30:05 PDT 2017


haicheng added inline comments.


================
Comment at: lib/IR/ConstantFold.cpp:2259
     unsigned CommonExtendedWidth =
         std::max(PrevIdx->getType()->getIntegerBitWidth(),
                  Div->getType()->getIntegerBitWidth());
----------------
The crash happens here.   Type::getIntegerBitWidth() casts underlying type to IntegerType and crashes when the underlying type is a vector.


================
Comment at: lib/IR/ConstantFold.cpp:2265
     // overflow trouble.
     if (!PrevIdx->getType()->isIntegerTy(CommonExtendedWidth))
       PrevIdx = ConstantExpr::getSExt(
----------------
I think this line also does not expect a vector PrevIdx.


================
Comment at: lib/IR/ConstantFold.cpp:2272
 
     NewIdxs[i - 1] = ConstantExpr::getAdd(PrevIdx, Div);
   }
----------------
I think this line also does not expect a vector PrevIdx.



Repository:
  rL LLVM

https://reviews.llvm.org/D38677





More information about the llvm-commits mailing list