1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[NewGVN] Fix verification of MemoryPhis in verifyMemoryCongruency().

verifyMemoryCongruency() filters out trivially dead MemoryDef(s),
as we find them immediately dead, before moving from TOP to a new
congruence class.
This fixes the same problem for PHI(s) skipping MemoryPhis if all
the operands are dead.

Differential Revision:  https://reviews.llvm.org/D33044

llvm-svn: 303100
This commit is contained in:
Davide Italiano 2017-05-15 18:50:53 +00:00
parent db69675c48
commit a3335b259b
2 changed files with 42 additions and 0 deletions

View File

@ -2549,6 +2549,19 @@ void NewGVN::verifyMemoryCongruency() const {
return false;
if (auto *MemDef = dyn_cast<MemoryDef>(Pair.first))
return !isInstructionTriviallyDead(MemDef->getMemoryInst());
// We could have phi nodes which operands are all trivially dead,
// so we don't process them.
if (auto *MemPHI = dyn_cast<MemoryPhi>(Pair.first)) {
for (auto &U : MemPHI->incoming_values()) {
if (Instruction *I = dyn_cast<Instruction>(U.get())) {
if (!isInstructionTriviallyDead(I))
return true;
}
}
return false;
}
return true;
};

View File

@ -0,0 +1,29 @@
; Skip dead MemoryPhis when performing memory congruency verification
; in NewGVN.
; RUN: opt -S -newgvn %s | FileCheck %s
; REQUIRES: asserts
; CHECK: define void @tinkywinky() {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 false, label %body, label %end
; CHECK: body:
; CHECK-NEXT: store i8 undef, i8* null
; CHECK-NEXT: br label %end
; CHECK: end:
; CHECK-NEXT: ret void
; CHECK-NEXT: }
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
define void @tinkywinky() {
entry:
call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
br i1 false, label %body, label %end
body:
call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
br label %end
end:
ret void
}