aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-08-25 10:46:39 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-08-25 10:46:39 +0000
commitba689b33152d195202e58471d16a49930c8435b3 (patch)
tree9a2dea6f47675a97299afbc6de1afac1bcaf4f1f /llvm/lib/IR/Value.cpp
parentb78df507c838e9c23afb9f8aa1bbbad85c1ef56a (diff)
downloadllvm-ba689b33152d195202e58471d16a49930c8435b3.zip
llvm-ba689b33152d195202e58471d16a49930c8435b3.tar.gz
llvm-ba689b33152d195202e58471d16a49930c8435b3.tar.bz2
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. llvm-svn: 189188
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index afa9291..6698f83 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -411,8 +411,10 @@ Value *Value::stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL,
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);