summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BasicAliasAnalysis.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/Analysis/BasicAliasAnalysis.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/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index c10c6f3f279..dcb5903a14e 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -23,6 +23,7 @@
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
+#include "llvm/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/SmallVector.h"
@@ -38,10 +39,11 @@ using namespace llvm;
//===----------------------------------------------------------------------===//
static const User *isGEP(const Value *V) {
- if (isa<GetElementPtrInst>(V) ||
- (isa<ConstantExpr>(V) &&
- cast<ConstantExpr>(V)->getOpcode() == Instruction::GetElementPtr))
- return cast<User>(V);
+ if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V))
+ // For the purposes of BasicAliasAnalysis, if the GEP has overflow it
+ // could do crazy things.
+ if (GEP->hasNoPointerOverflow())
+ return GEP;
return 0;
}
OpenPOWER on IntegriCloud