OSDN Git Service

Analysis: Return early in isKnownNonNullAt for ConstantData
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 24 Sep 2016 19:39:47 +0000 (19:39 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 24 Sep 2016 19:39:47 +0000 (19:39 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index df86a01..827e252 100644 (file)
@@ -3297,6 +3297,7 @@ static bool isKnownNonNullFromDominatingCondition(const Value *V,
                                                   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 isKnownNonNullFromDominatingCondition(const Value *V,
 
 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;