Skip to content

Commit

Permalink
Unconditionally reset 'cache' to zero, even if we don't need to resor…
Browse files Browse the repository at this point in the history
…t 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62838 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jan 23, 2009
1 parent c16d37e commit 4433a09
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/Analysis/MemoryDependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4433a09

Please sign in to comment.