summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-09-03 19:08:37 +0000
committerOwen Anderson <resistor@mac.com>2010-09-03 19:08:37 +0000
commitc72546224565f8a2aa2d6467b909c9fb428aa501 (patch)
tree38c2dfa02871a3790b8b260ecc71e0a7cacdf407 /llvm/lib/Analysis/LazyValueInfo.cpp
parent3fec2dd3740373e932b4b6bd2a48e377f3795ef4 (diff)
downloadbcm5719-llvm-c72546224565f8a2aa2d6467b909c9fb428aa501.tar.gz
bcm5719-llvm-c72546224565f8a2aa2d6467b909c9fb428aa501.zip
Add support for simplifying a load from a computed value to a load from a global when it
is provable that they're equivalent. This fixes PR4855. llvm-svn: 112994
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index b4923f9a717..e32dbc44471 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -452,14 +452,15 @@ LVILatticeVal LVIQuery::getBlockValue(BasicBlock *BB) {
// If this is a pointer, and there's a load from that pointer in this BB,
// then we know that the pointer can't be NULL.
+ bool NotNull = false;
if (Val->getType()->isPointerTy()) {
- const PointerType *PTy = cast<PointerType>(Val->getType());
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();BI != BE;++BI){
LoadInst *L = dyn_cast<LoadInst>(BI);
if (L && L->getPointerAddressSpace() == 0 &&
L->getPointerOperand()->getUnderlyingObject() ==
Val->getUnderlyingObject()) {
- return LVILatticeVal::getNot(ConstantPointerNull::get(PTy));
+ NotNull = true;
+ break;
}
}
}
@@ -475,11 +476,19 @@ LVILatticeVal LVIQuery::getBlockValue(BasicBlock *BB) {
if (Result.isOverdefined()) {
DEBUG(dbgs() << " compute BB '" << BB->getName()
<< "' - overdefined because of pred.\n");
+ // If we previously determined that this is a pointer that can't be null
+ // then return that rather than giving up entirely.
+ if (NotNull) {
+ const PointerType *PTy = cast<PointerType>(Val->getType());
+ Result = LVILatticeVal::getNot(ConstantPointerNull::get(PTy));
+ }
+
return Result;
}
++NumPreds;
}
+
// If this is the entry block, we must be asking about an argument. The
// value is overdefined.
if (NumPreds == 0 && BB == &BB->getParent()->front()) {
OpenPOWER on IntegriCloud