From 503eb2bb49f05c762fd79e42cb96ac6e86f0691e Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 9 Oct 2012 01:58:35 +0000 Subject: Fix PR14034, an infloop / heap corruption / crash bug in the new SROA. Thanks to Benjamin for the raw test case. This one took about 50 times longer to reduce than to fix. =/ llvm-svn: 165476 --- llvm/lib/Transforms/Scalar/SROA.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib/Transforms/Scalar/SROA.cpp') diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index b2793893b46..ca762514929 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -1786,6 +1786,8 @@ static Value *getNaturalGEPWithType(IRBuilder<> &IRB, const DataLayout &TD, ElementTy = SeqTy->getElementType(); Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(), 0))); } else if (StructType *STy = dyn_cast(ElementTy)) { + if (STy->element_begin() == STy->element_end()) + break; // Nothing left to descend into. ElementTy = *STy->element_begin(); Indices.push_back(IRB.getInt32(0)); } else { -- cgit v1.2.3