[llvm] r262826 - [memdep] Switch a function to return true on success instead of false.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 04:45:08 PST 2016


Author: chandlerc
Date: Mon Mar  7 06:45:07 2016
New Revision: 262826

URL: http://llvm.org/viewvc/llvm-project?rev=262826&view=rev
Log:
[memdep] Switch a function to return true on success instead of false.

This is much more clear and less surprising IMO. It also makes things
more consistent with the increasingly large chunk of LLVM code that
assumes true-on-success.

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

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=262826&r1=262825&r2=262826&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Mar  7 06:45:07 2016
@@ -964,7 +964,7 @@ void MemoryDependenceAnalysis::getNonLoc
   // a block with multiple different pointers.  This can happen during PHI
   // translation.
   DenseMap<BasicBlock *, Value *> Visited;
-  if (!getNonLocalPointerDepFromBB(QueryInst, Address, Loc, isLoad, FromBB,
+  if (getNonLocalPointerDepFromBB(QueryInst, Address, Loc, isLoad, FromBB,
                                    Result, Visited, true))
     return;
   Result.clear();
@@ -1089,7 +1089,7 @@ SortNonLocalDepInfoCache(MemoryDependenc
 /// is true).  In this special case, it ignores the contents of the specified
 /// block and starts returning dependence info for its predecessors.
 ///
-/// This function returns false on success, or true to indicate that it could
+/// This function returns true on success, or false to indicate that it could
 /// not compute dependence information for some reason.  This should be treated
 /// as a clobber dependence on the first instruction in the predecessor block.
 bool MemoryDependenceAnalysis::getNonLocalPointerDepFromBB(
@@ -1174,10 +1174,10 @@ bool MemoryDependenceAnalysis::getNonLoc
         if (VI == Visited.end() || VI->second == Pointer.getAddr())
           continue;
 
-        // We have a pointer mismatch in a block.  Just return clobber, saying
+        // We have a pointer mismatch in a block.  Just return false, saying
         // that something was clobbered in this result.  We could also do a
         // non-fully cached query, but there is little point in doing this.
-        return true;
+        return false;
       }
     }
 
@@ -1197,7 +1197,7 @@ bool MemoryDependenceAnalysis::getNonLoc
       }
     }
     ++NumCacheCompleteNonLocalPtr;
-    return false;
+    return true;
   }
 
   // Otherwise, either this is a new block, a block with an invalid cache
@@ -1243,7 +1243,7 @@ bool MemoryDependenceAnalysis::getNonLoc
       // specific block queries) but we can't do the fastpath "return all
       // results from the set".  Clear out the indicator for this.
       CacheInfo->Pair = BBSkipFirstBlockPair();
-      return true;
+      return false;
     }
 
     // Skip the first block if we have it.
@@ -1395,7 +1395,7 @@ bool MemoryDependenceAnalysis::getNonLoc
       // result conflicted with the Visited list; we have to conservatively
       // assume it is unknown, but this also does not block PRE of the load.
       if (!CanTranslate ||
-          getNonLocalPointerDepFromBB(QueryInst, PredPointer,
+          !getNonLocalPointerDepFromBB(QueryInst, PredPointer,
                                       Loc.getWithNewPtr(PredPtrVal), isLoad,
                                       Pred, Result, Visited)) {
         // Add the entry to the Result list.
@@ -1450,7 +1450,7 @@ bool MemoryDependenceAnalysis::getNonLoc
     // incoming value.  Since we can't phi translate to one of the predecessors,
     // we have to bail out.
     if (SkipFirstBlock)
-      return true;
+      return false;
 
     bool foundBlock = false;
     for (NonLocalDepEntry &I : llvm::reverse(*Cache)) {
@@ -1473,7 +1473,7 @@ bool MemoryDependenceAnalysis::getNonLoc
   // Okay, we're done now.  If we added new values to the cache, re-sort it.
   SortNonLocalDepInfoCache(*Cache, NumSortedEntries);
   DEBUG(AssertSorted(*Cache));
-  return false;
+  return true;
 }
 
 /// If P exists in CachedNonLocalPointerInfo, remove it.




More information about the llvm-commits mailing list