From ad41dcfd875e8d3421a5f0970b6a886b6e10b3b7 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 14 Sep 2012 10:30:42 +0000 Subject: [PATCH 1/1] Be a bit more aggressive in bailing out of this routine. Spotted by inspection by Duncan during review. My suspicion is that we would still have returned 0 anyways in this case, but doing it sooner is better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163895 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/SROA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 97c28d442ad..27808ea8c8b 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -1336,7 +1336,7 @@ static Value *getNaturalGEPRecursively(IRBuilder<> &IRB, const TargetData &TD, const StructLayout *SL = TD.getStructLayout(STy); uint64_t StructOffset = Offset.getZExtValue(); - if (StructOffset > SL->getSizeInBytes()) + if (StructOffset >= SL->getSizeInBytes()) return 0; unsigned Index = SL->getElementContainingOffset(StructOffset); Offset -= APInt(Offset.getBitWidth(), SL->getElementOffset(Index)); -- 2.34.1