[llvm-commits] [llvm] r62838 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Chris Lattner sabre at nondot.org
Thu Jan 22 22:48:41 PST 2009


Author: lattner
Date: Fri Jan 23 00:48:41 2009
New Revision: 62838

URL: http://llvm.org/viewvc/llvm-project?rev=62838&view=rev
Log:
Unconditionally reset 'cache' to zero, even if we don't need to resort it.
This avoids using a dangling pointer.

Reset NumSortedEntries after restoring Cache to avoid extraneous sorts.
This fixes the reduced sqlite3 testcase, but apparently not the whole app.

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=62838&r1=62837&r2=62838&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Jan 23 00:48:41 2009
@@ -751,11 +751,9 @@
         // cache remains sorted.  Sort it now (if needed) so that recursive
         // invocations of getNonLocalPointerDepFromBB that could reuse the cache
         // value will only see properly sorted cache arrays.
-        if (Cache && NumSortedEntries != Cache->size()) {
+        if (Cache && NumSortedEntries != Cache->size())
           std::sort(Cache->begin(), Cache->end());
-          NumSortedEntries = Cache->size();
-          Cache = 0;
-        }
+        Cache = 0;
         
         // FIXME: it is entirely possible that PHI translating will end up with
         // the same value.  Consider PHI translating something like:
@@ -793,7 +791,8 @@
     // Refresh the CacheInfo/Cache pointer so that it isn't invalidated.
     CacheInfo = &NonLocalPointerDeps[CacheKey];
     Cache = &CacheInfo->second;
-    
+    NumSortedEntries = Cache->size();
+
     // Since we did phi translation, the "Cache" set won't contain all of the
     // results for the query.  This is ok (we can still use it to accelerate
     // specific block queries) but we can't do the fastpath "return all





More information about the llvm-commits mailing list