Skip to content

Commit 25abd0e

Browse files
committed
[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. llvm-svn: 370001
1 parent f3f00b2 commit 25abd0e

File tree

1 file changed

+1
-4
lines changed
  • llvm/include/llvm/Analysis/Utils

1 file changed

+1
-4
lines changed

llvm/include/llvm/Analysis/Utils/Local.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP,
5151

5252
// Handle a struct index, which adds its field offset to the pointer.
5353
if (StructType *STy = GTI.getStructTypeOrNull()) {
54-
if (OpC->getType()->isVectorTy())
55-
OpC = OpC->getSplatValue();
56-
57-
uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
54+
uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
5855
Size = DL.getStructLayout(STy)->getElementOffset(OpValue);
5956

6057
if (Size)

0 commit comments

Comments
 (0)