summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-23 06:48:41 +0000
committerChris Lattner <sabre@nondot.org>2009-01-23 06:48:41 +0000
commite3ea48c71ea626c4c11bec2ffcdeca3e7042c06a (patch)
tree83d333ccf4f80cd58f7e498f1ebb5b5de3d872ed /llvm/lib/Analysis
parent9db227999a108f0da1db7cea0c7523908f6599c4 (diff)
downloadbcm5719-llvm-e3ea48c71ea626c4c11bec2ffcdeca3e7042c06a.tar.gz
bcm5719-llvm-e3ea48c71ea626c4c11bec2ffcdeca3e7042c06a.zip
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. llvm-svn: 62838
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index c84a51fb062..8670890cdb6 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -751,11 +751,9 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
// 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 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
// 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
OpenPOWER on IntegriCloud