Give 'hasPath' a longer but clearer name 'isPotentiallyReachable'. Also expand
authorNick Lewycky <nicholas@mxc.ca>
Thu, 18 Jul 2013 02:34:51 +0000 (02:34 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 18 Jul 2013 02:34:51 +0000 (02:34 +0000)
the comment. No functionality change. This change broken out of
http://llvm-reviews.chandlerc.com/D996 .

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

lib/Analysis/AliasAnalysis.cpp

index 054930c0e1936c2ec64450dd89defbe6990b34e9..5be5613b124e8a1684b0cbb3018865202bbe6ed5 100644 (file)
@@ -361,9 +361,11 @@ AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc) {
 }
 
 namespace {
-  // Conservatively return true. Return false, if there is a single path
-  // starting from "From" and the path does not reach "To".
-  static bool hasPath(const BasicBlock *From, const BasicBlock *To) {
+  /// Determine whether there is a path from From to To within a single
+  /// function. Returns false only if we can prove that once 'From' has been
+  /// executed then 'To' can not be executed. Conservatively returns true.
+  static bool isPotentiallyReachable(const BasicBlock *From,
+                                     const BasicBlock *To) {
     const unsigned MaxCheck = 5;
     const BasicBlock *Current = From;
     for (unsigned I = 0; I < MaxCheck; I++) {
@@ -400,7 +402,7 @@ namespace {
       // there is no need to explore the use if BeforeHere dominates use.
       // Check whether there is a path from I to BeforeHere.
       if (BeforeHere != I && DT->dominates(BeforeHere, I) &&
-          !hasPath(BB, BeforeHere->getParent()))
+          !isPotentiallyReachable(BB, BeforeHere->getParent()))
         return false;
       return true;
     }
@@ -412,7 +414,7 @@ namespace {
       if (BeforeHere != I && !DT->isReachableFromEntry(BB))
         return false;
       if (BeforeHere != I && DT->dominates(BeforeHere, I) &&
-          !hasPath(BB, BeforeHere->getParent()))
+          !isPotentiallyReachable(BB, BeforeHere->getParent()))
         return false;
       Captured = true;
       return true;