summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/ValueTracking.h8
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
2 files changed, 10 insertions, 5 deletions
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 5a3e6346ad8..dd767217345 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -308,12 +308,12 @@ template <typename T> class ArrayRef;
bool isKnownNonNull(const Value *V);
/// Return true if this pointer couldn't possibly be null. If the context
- /// instruction is specified, perform context-sensitive analysis and return
- /// true if the pointer couldn't possibly be null at the specified
- /// instruction.
+ /// instruction and dominator tree are specified, perform context-sensitive
+ /// analysis and return true if the pointer couldn't possibly be null at the
+ /// specified instruction.
bool isKnownNonNullAt(const Value *V,
const Instruction *CtxI = nullptr,
- const DominatorTree *DT = nullptr);
+ const DominatorTree *DT = nullptr);
/// Return true if it is valid to use the assumptions provided by an
/// assume intrinsic, I, at the point in the control-flow identified by the
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 30bd08471d5..48f5c59ba61 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3368,6 +3368,8 @@ static bool isKnownNonNullFromDominatingCondition(const Value *V,
const DominatorTree *DT) {
assert(V->getType()->isPointerTy() && "V must be pointer type");
assert(!isa<ConstantData>(V) && "Did not expect ConstantPointerNull");
+ assert(CtxI && "Context instruction required for analysis");
+ assert(DT && "Dominator tree required for analysis");
unsigned NumUsesExplored = 0;
for (auto *U : V->users()) {
@@ -3410,7 +3412,10 @@ bool llvm::isKnownNonNullAt(const Value *V, const Instruction *CtxI,
if (isKnownNonNull(V))
return true;
- return CtxI ? ::isKnownNonNullFromDominatingCondition(V, CtxI, DT) : false;
+ if (!CtxI || !DT)
+ return false;
+
+ return ::isKnownNonNullFromDominatingCondition(V, CtxI, DT);
}
OverflowResult llvm::computeOverflowForUnsignedMul(const Value *LHS,
OpenPOWER on IntegriCloud