mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 04:39:44 +00:00
Move the re-sort of invalidated NonLocalPointerDeps cache earlier
so that all code paths get it. PR4256 was about a case where the phi translation loop would find all preds in the Visited cache, so it could get by without re-sorting the NonLocalPointerDeps cache. Fix this by resorting it earlier, there is no reason not to do this. This patch inspired by Jakub Staszak's patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75476 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
191cf2851b
commit
6fbc1969e9
@ -731,10 +731,22 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
|
||||
// If we do need to do phi translation, then there are a bunch of different
|
||||
// cases, because we have to find a Value* live in the predecessor block. We
|
||||
// know that PtrInst is defined in this block at least.
|
||||
|
||||
// We may have added values to the cache list before this PHI translation.
|
||||
// If so, we haven't done anything to ensure that the cache remains sorted.
|
||||
// Sort it now (if needed) so that recursive invocations of
|
||||
// getNonLocalPointerDepFromBB and other routines that could reuse the cache
|
||||
// value will only see properly sorted cache arrays.
|
||||
if (Cache && NumSortedEntries != Cache->size()) {
|
||||
std::sort(Cache->begin(), Cache->end());
|
||||
NumSortedEntries = Cache->size();
|
||||
}
|
||||
|
||||
// If this is directly a PHI node, just use the incoming values for each
|
||||
// pred as the phi translated version.
|
||||
if (PHINode *PtrPHI = dyn_cast<PHINode>(PtrInst)) {
|
||||
Cache = 0;
|
||||
|
||||
for (BasicBlock **PI = PredCache->GetPreds(BB); *PI; ++PI) {
|
||||
BasicBlock *Pred = *PI;
|
||||
Value *PredPtr = PtrPHI->getIncomingValueForBlock(Pred);
|
||||
@ -759,15 +771,6 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
|
||||
goto PredTranslationFailure;
|
||||
}
|
||||
|
||||
// We may have added values to the cache list before this PHI
|
||||
// translation. If so, we haven't done anything to ensure that the
|
||||
// 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())
|
||||
std::sort(Cache->begin(), Cache->end());
|
||||
Cache = 0;
|
||||
|
||||
// FIXME: it is entirely possible that PHI translating will end up with
|
||||
// the same value. Consider PHI translating something like:
|
||||
// X = phi [x, bb1], [y, bb2]. PHI translating for bb1 doesn't *need*
|
||||
@ -779,7 +782,7 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
|
||||
Result, Visited))
|
||||
goto PredTranslationFailure;
|
||||
}
|
||||
|
||||
|
||||
// Refresh the CacheInfo/Cache pointer so that it isn't invalidated.
|
||||
CacheInfo = &NonLocalPointerDeps[CacheKey];
|
||||
Cache = &CacheInfo->second;
|
||||
@ -806,11 +809,8 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
|
||||
CacheInfo = &NonLocalPointerDeps[CacheKey];
|
||||
Cache = &CacheInfo->second;
|
||||
NumSortedEntries = Cache->size();
|
||||
} else if (NumSortedEntries != Cache->size()) {
|
||||
std::sort(Cache->begin(), Cache->end());
|
||||
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
|
||||
|
67
test/Transforms/GVN/2009-07-13-MemDepSortFail.ll
Normal file
67
test/Transforms/GVN/2009-07-13-MemDepSortFail.ll
Normal file
@ -0,0 +1,67 @@
|
||||
; RUN: llvm-as < %s | opt -gvn | llvm-dis
|
||||
; PR4256
|
||||
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
|
||||
target triple = "i386-linux-gnu"
|
||||
%llvm.dbg.anchor.type = type { i32, i32 }
|
||||
%struct.cset = type { i8*, i8, i8, i32, i8* }
|
||||
%struct.lmat = type { %struct.re_guts*, i32, %llvm.dbg.anchor.type*, i8*, i8*, i8*, i8*, i8**, i32, i8*, i8*, i8*, i8*, i8* }
|
||||
%struct.re_guts = type { i32*, %struct.cset*, i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, i32, i32, [1 x i8] }
|
||||
|
||||
define i8* @lbackref(%struct.lmat* %m, i8* %start, i8* %stop, i32 %startst, i32 %stopst, i32 %lev, i32 %rec) nounwind {
|
||||
entry:
|
||||
br label %bb63
|
||||
|
||||
bb: ; preds = %bb63
|
||||
switch i32 0, label %bb62 [
|
||||
i32 268435456, label %bb2
|
||||
i32 805306368, label %bb9
|
||||
i32 -1610612736, label %bb51
|
||||
]
|
||||
|
||||
bb2: ; preds = %bb
|
||||
br label %bb62
|
||||
|
||||
bb9: ; preds = %bb
|
||||
%0 = load i8* %sp.1, align 1 ; <i8> [#uses=0]
|
||||
br label %bb62
|
||||
|
||||
bb51: ; preds = %bb
|
||||
%1 = load i8* %sp.1, align 1 ; <i8> [#uses=0]
|
||||
ret i8* null
|
||||
|
||||
bb62: ; preds = %bb9, %bb2, %bb
|
||||
br label %bb63
|
||||
|
||||
bb63: ; preds = %bb84, %bb69, %bb62, %entry
|
||||
%sp.1 = phi i8* [ null, %bb62 ], [ %sp.1.lcssa, %bb84 ], [ %start, %entry ], [ %sp.1.lcssa, %bb69 ] ; <i8*> [#uses=3]
|
||||
br i1 false, label %bb, label %bb65
|
||||
|
||||
bb65: ; preds = %bb63
|
||||
%sp.1.lcssa = phi i8* [ %sp.1, %bb63 ] ; <i8*> [#uses=4]
|
||||
br i1 false, label %bb66, label %bb69
|
||||
|
||||
bb66: ; preds = %bb65
|
||||
ret i8* null
|
||||
|
||||
bb69: ; preds = %bb65
|
||||
switch i32 0, label %bb108.loopexit2.loopexit.loopexit [
|
||||
i32 1342177280, label %bb63
|
||||
i32 1476395008, label %bb84
|
||||
i32 1879048192, label %bb104
|
||||
i32 2013265920, label %bb93
|
||||
]
|
||||
|
||||
bb84: ; preds = %bb69
|
||||
%2 = tail call i8* @lbackref(%struct.lmat* %m, i8* %sp.1.lcssa, i8* %stop, i32 0, i32 %stopst, i32 0, i32 0) nounwind ; <i8*> [#uses=0]
|
||||
br label %bb63
|
||||
|
||||
bb93: ; preds = %bb69
|
||||
ret i8* null
|
||||
|
||||
bb104: ; preds = %bb69
|
||||
%sp.1.lcssa.lcssa33 = phi i8* [ %sp.1.lcssa, %bb69 ] ; <i8*> [#uses=0]
|
||||
unreachable
|
||||
|
||||
bb108.loopexit2.loopexit.loopexit: ; preds = %bb69
|
||||
ret i8* null
|
||||
}
|
Loading…
Reference in New Issue
Block a user