[llvm] r370001 - [Analysis] In EmitGEPOffset, use Constant::getUniqueInteger to handle struct indices in vector GEPs.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 18:07:37 PDT 2019
Author: ctopper
Date: Mon Aug 26 18:07:37 2019
New Revision: 370001
URL: http://llvm.org/viewvc/llvm-project?rev=370001&view=rev
Log:
[Analysis] In EmitGEPOffset, use Constant::getUniqueInteger to handle struct indices in vector GEPs.
We previously called getSplatValue if the index had a vector type,
but getSplatValue returns null for non-splats. This would cause
a nullptr dereference if it wasn't a splat.
Using getUniqueInteger gives us an assert if its a vector type,
but the value isn't a splat. This is what is used in
SelectionDAGBuilder's code that expands GEPs as well.
Modified:
llvm/trunk/include/llvm/Analysis/Utils/Local.h
Modified: llvm/trunk/include/llvm/Analysis/Utils/Local.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Utils/Local.h?rev=370001&r1=370000&r2=370001&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Analysis/Utils/Local.h Mon Aug 26 18:07:37 2019
@@ -51,10 +51,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builde
// Handle a struct index, which adds its field offset to the pointer.
if (StructType *STy = GTI.getStructTypeOrNull()) {
- if (OpC->getType()->isVectorTy())
- OpC = OpC->getSplatValue();
-
- uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
+ uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
Size = DL.getStructLayout(STy)->getElementOffset(OpValue);
if (Size)
More information about the llvm-commits
mailing list