[llvm] r189188 - Fix a bug where we would corrupt the offset when evaluating
Chandler Carruth
chandlerc at gmail.com
Sun Aug 25 03:46:39 PDT 2013
Author: chandlerc
Date: Sun Aug 25 05:46:39 2013
New Revision: 189188
URL: http://llvm.org/viewvc/llvm-project?rev=189188&view=rev
Log:
Fix a bug where we would corrupt the offset when evaluating
a non-constant GEP.
I don't have any test case that demonstrates this, Nadav (indirectly)
pointed this out in code review. I'm not sure how possible it is to
contrive a test case for the current users of this code that triggers
the bad issue sadly.
Modified:
llvm/trunk/lib/IR/Value.cpp
Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=189188&r1=189187&r2=189188&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Sun Aug 25 05:46:39 2013
@@ -411,8 +411,10 @@ Value *Value::stripAndAccumulateInBounds
if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
if (!GEP->isInBounds())
return V;
- if (!GEP->accumulateConstantOffset(DL, Offset))
+ APInt GEPOffset(Offset);
+ if (!GEP->accumulateConstantOffset(DL, GEPOffset))
return V;
+ Offset = GEPOffset;
V = GEP->getPointerOperand();
} else if (Operator::getOpcode(V) == Instruction::BitCast) {
V = cast<Operator>(V)->getOperand(0);
More information about the llvm-commits
mailing list