In the default address space, any GEP off of null results in a trap value if you try to load it. Thus,
any load in the default address space that completes implies that the base value that it GEP'd from
was not null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112015 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index e4cd867..31ca2de 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -457,10 +457,11 @@
// then we know that the pointer can't be NULL.
if (Val->getType()->isPointerTy()) {
const PointerType *PTy = cast<PointerType>(Val->getType());
- for (Value::use_iterator UI = Val->use_begin(), UE = Val->use_end();
- UI != UE; ++UI) {
- LoadInst *L = dyn_cast<LoadInst>(*UI);
- if (L && L->getParent() == BB && L->getPointerAddressSpace() == 0) {
+ 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));
}
}