[llvm] 7f740be - [BasicAA] Don't assume DT is nonnull

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 03:23:09 PST 2023


Author: Nikita Popov
Date: 2023-11-21T12:22:13+01:00
New Revision: 7f740be4acddd8acf46796229c46117b735a9be8

URL: https://github.com/llvm/llvm-project/commit/7f740be4acddd8acf46796229c46117b735a9be8
DIFF: https://github.com/llvm/llvm-project/commit/7f740be4acddd8acf46796229c46117b735a9be8.diff

LOG: [BasicAA] Don't assume DT is nonnull

I thought DT is required in BasicAA, but apparently it can be null
in unit tests at least. This should fix the ubsan bot failures.

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 476028bd91b23cd..bf766ee67bb35bf 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -199,12 +199,12 @@ bool SimpleCaptureInfo::isNotCapturedBefore(const Value *Object,
   return isNonEscapingLocalObject(Object, &IsCapturedCache);
 }
 
-static bool isNotInCycle(const Instruction *I, const DominatorTree &DT,
+static bool isNotInCycle(const Instruction *I, const DominatorTree *DT,
                          const LoopInfo *LI) {
   BasicBlock *BB = const_cast<BasicBlock *>(I->getParent());
   SmallVector<BasicBlock *> Succs(successors(BB));
   return Succs.empty() ||
-         !isPotentiallyReachableFromMany(Succs, BB, nullptr, &DT, LI);
+         !isPotentiallyReachableFromMany(Succs, BB, nullptr, DT, LI);
 }
 
 bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
@@ -231,7 +231,7 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
   if (I == Iter.first->second) {
     if (OrAt)
       return false;
-    return isNotInCycle(I, DT, LI);
+    return isNotInCycle(I, &DT, LI);
   }
 
   return !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
@@ -1721,7 +1721,7 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
   if (!Inst || Inst->getParent()->isEntryBlock())
     return true;
 
-  return isNotInCycle(Inst, *DT, /*LI*/ nullptr);
+  return isNotInCycle(Inst, DT, /*LI*/ nullptr);
 }
 
 /// Computes the symbolic 
diff erence between two de-composed GEPs.


        


More information about the llvm-commits mailing list