summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Value.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-17 22:25:10 +0000
committerDan Gohman <gohman@apple.com>2009-07-17 22:25:10 +0000
commit1d548d851a2b04138bf939ab65c0054bdba6052a (patch)
treedac728d9f0cd98c43f1135f9127cd8946d20ab2e /llvm/lib/VMCore/Value.cpp
parent93668002c48ec1eb45119c88aac4821693b425a2 (diff)
downloadbcm5719-llvm-1d548d851a2b04138bf939ab65c0054bdba6052a.tar.gz
bcm5719-llvm-1d548d851a2b04138bf939ab65c0054bdba6052a.zip
Make BasicAliasAnalysis and Value::getUnderlyingObject use
GEPOperator's hasNoPointer0verflow(), and make a few places in instcombine that create GEPs that may overflow clear the NoOverflow value. Among other things, this partially addresses PR2831. llvm-svn: 76252
Diffstat (limited to 'llvm/lib/VMCore/Value.cpp')
-rw-r--r--llvm/lib/VMCore/Value.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index b35ad507984..3322c681d8e 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -16,6 +16,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/InstrTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Operator.h"
#include "llvm/Module.h"
#include "llvm/ValueSymbolTable.h"
#include "llvm/Support/Debug.h"
@@ -372,15 +373,12 @@ Value *Value::getUnderlyingObject() {
Value *V = this;
unsigned MaxLookup = 6;
do {
- if (Instruction *I = dyn_cast<Instruction>(V)) {
- if (!isa<BitCastInst>(I) && !isa<GetElementPtrInst>(I))
+ if (Operator *O = dyn_cast<Operator>(V)) {
+ if (O->getOpcode() != Instruction::BitCast &&
+ (O->getOpcode() != Instruction::GetElementPtr ||
+ !cast<GEPOperator>(V)->hasNoPointerOverflow()))
return V;
- V = I->getOperand(0);
- } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
- if (CE->getOpcode() != Instruction::BitCast &&
- CE->getOpcode() != Instruction::GetElementPtr)
- return V;
- V = CE->getOperand(0);
+ V = O->getOperand(0);
} else {
return V;
}
OpenPOWER on IntegriCloud