From 6453e9ebe2a63763b4ad98e01ece680381b7d026 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 27 Aug 2019 01:07:37 +0000 Subject: [PATCH] [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 --- include/llvm/Analysis/Utils/Local.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/llvm/Analysis/Utils/Local.h b/include/llvm/Analysis/Utils/Local.h index acbdf5dca32..23e8ab271c5 100644 --- a/include/llvm/Analysis/Utils/Local.h +++ b/include/llvm/Analysis/Utils/Local.h @@ -51,10 +51,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, // 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(OpC)->getZExtValue(); + uint64_t OpValue = OpC->getUniqueInteger().getZExtValue(); Size = DL.getStructLayout(STy)->getElementOffset(OpValue); if (Size)