mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
Fix handling of forward unreachable but reverse-reachable blocks in MemorySSA construction
llvm-svn: 274606
This commit is contained in:
parent
849887c0a3
commit
e473c8b506
@ -201,8 +201,6 @@ MemoryAccess *MemorySSA::renameBlock(BasicBlock *BB,
|
||||
continue;
|
||||
AccessList *Accesses = It->second.get();
|
||||
auto *Phi = cast<MemoryPhi>(&Accesses->front());
|
||||
assert(std::find(succ_begin(BB), succ_end(BB), S) != succ_end(BB) &&
|
||||
"Must be at least one edge from Succ to BB!");
|
||||
Phi->addIncoming(IncomingVal, BB);
|
||||
}
|
||||
|
||||
@ -252,6 +250,22 @@ void MemorySSA::markUnreachableAsLiveOnEntry(BasicBlock *BB) {
|
||||
assert(!DT->isReachableFromEntry(BB) &&
|
||||
"Reachable block found while handling unreachable blocks");
|
||||
|
||||
// Make sure phi nodes in our reachable successors end up with a
|
||||
// LiveOnEntryDef for our incoming edge, even though our block is forward
|
||||
// unreachable. We could just disconnect these blocks from the CFG fully,
|
||||
// but we do not right now.
|
||||
for (const BasicBlock *S : successors(BB)) {
|
||||
if (!DT->isReachableFromEntry(S))
|
||||
continue;
|
||||
auto It = PerBlockAccesses.find(S);
|
||||
// Rename the phi nodes in our successor block
|
||||
if (It == PerBlockAccesses.end() || !isa<MemoryPhi>(It->second->front()))
|
||||
continue;
|
||||
AccessList *Accesses = It->second.get();
|
||||
auto *Phi = cast<MemoryPhi>(&Accesses->front());
|
||||
Phi->addIncoming(LiveOnEntryDef.get(), BB);
|
||||
}
|
||||
|
||||
auto It = PerBlockAccesses.find(BB);
|
||||
if (It == PerBlockAccesses.end())
|
||||
return;
|
||||
|
23
test/Transforms/Util/MemorySSA/forward-unreachable.ll
Normal file
23
test/Transforms/Util/MemorySSA/forward-unreachable.ll
Normal file
@ -0,0 +1,23 @@
|
||||
; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
||||
|
||||
define void @test() {
|
||||
entry:
|
||||
br i1 undef, label %split1, label %split2
|
||||
|
||||
split1:
|
||||
store i16 undef, i16* undef, align 2
|
||||
br label %merge
|
||||
split2:
|
||||
br label %merge
|
||||
forwardunreachable:
|
||||
br label %merge
|
||||
merge:
|
||||
; The forwardunreachable block still needs an entry in the phi node,
|
||||
; because it is reverse reachable, so the CFG still has it as a
|
||||
; predecessor of the block
|
||||
; CHECK: 3 = MemoryPhi({split1,1},{split2,liveOnEntry},{forwardunreachable,liveOnEntry})
|
||||
store i16 undef, i16* undef, align 2
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user