[llvm] r282333 - Analysis: Return early in isKnownNonNullAt for ConstantData

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 24 12:39:48 PDT 2016


Author: dexonsmith
Date: Sat Sep 24 14:39:47 2016
New Revision: 282333

URL: http://llvm.org/viewvc/llvm-project?rev=282333&view=rev
Log:
Analysis: Return early in isKnownNonNullAt for ConstantData

Check and return early for ConstantPointerNull and UndefValue
specifically in isKnownNonNullAt, and assert that ConstantData never
make it to isKnownNonNullFromDominatingCondition.

This confirms that isKnownNonNullFromDominatingCondition never walks
through the use-list of an instance of ConstantData.  Given that such
use-lists cross module boundaries, it never really made sense to do so,
and was potentially very expensive.

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=282333&r1=282332&r2=282333&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Sat Sep 24 14:39:47 2016
@@ -3297,6 +3297,7 @@ static bool isKnownNonNullFromDominating
                                                   const Instruction *CtxI,
                                                   const DominatorTree *DT) {
   assert(V->getType()->isPointerTy() && "V must be pointer type");
+  assert(!isa<ConstantData>(V) && "Did not expect ConstantPointerNull");
 
   unsigned NumUsesExplored = 0;
   for (auto *U : V->users()) {
@@ -3333,6 +3334,9 @@ static bool isKnownNonNullFromDominating
 
 bool llvm::isKnownNonNullAt(const Value *V, const Instruction *CtxI,
                             const DominatorTree *DT) {
+  if (isa<ConstantPointerNull>(V) || isa<UndefValue>(V))
+    return false;
+
   if (isKnownNonNull(V))
     return true;
 




More information about the llvm-commits mailing list