mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
NewGVN: Instead of changeToUnreachable, insert an instruction SimplifyCFG will turn into unreachable when it runs
llvm-svn: 293515
This commit is contained in:
parent
58721b2662
commit
4e849c7a11
@ -2106,10 +2106,6 @@ void NewGVN::deleteInstructionsInBlock(BasicBlock *BB) {
|
|||||||
DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
|
DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
|
||||||
++NumGVNBlocksDeleted;
|
++NumGVNBlocksDeleted;
|
||||||
|
|
||||||
// Check to see if there are non-terminating instructions to delete.
|
|
||||||
if (isa<TerminatorInst>(BB->begin()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Delete the instructions backwards, as it has a reduced likelihood of having
|
// Delete the instructions backwards, as it has a reduced likelihood of having
|
||||||
// to update as many def-use and use-def chains. Start after the terminator.
|
// to update as many def-use and use-def chains. Start after the terminator.
|
||||||
auto StartPoint = BB->rbegin();
|
auto StartPoint = BB->rbegin();
|
||||||
@ -2126,6 +2122,11 @@ void NewGVN::deleteInstructionsInBlock(BasicBlock *BB) {
|
|||||||
Inst.eraseFromParent();
|
Inst.eraseFromParent();
|
||||||
++NumGVNInstrDeleted;
|
++NumGVNInstrDeleted;
|
||||||
}
|
}
|
||||||
|
// Now insert something that simplifycfg will turn into an unreachable.
|
||||||
|
Type *Int8Ty = Type::getInt8Ty(BB->getContext());
|
||||||
|
new StoreInst(UndefValue::get(Int8Ty),
|
||||||
|
Constant::getNullValue(Int8Ty->getPointerTo()),
|
||||||
|
BB->getTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGVN::markInstructionForDeletion(Instruction *I) {
|
void NewGVN::markInstructionForDeletion(Instruction *I) {
|
||||||
|
@ -77,6 +77,7 @@ define void @foo(i8* %arg) {
|
|||||||
; CHECK-NEXT: i8 6, label [[BB8:%.*]]
|
; CHECK-NEXT: i8 6, label [[BB8:%.*]]
|
||||||
; CHECK-NEXT: ]
|
; CHECK-NEXT: ]
|
||||||
; CHECK: bb8:
|
; CHECK: bb8:
|
||||||
|
; CHECK-NEXT: store i8 undef, i8* null
|
||||||
; CHECK-NEXT: br label [[BB4]]
|
; CHECK-NEXT: br label [[BB4]]
|
||||||
; CHECK: bb9:
|
; CHECK: bb9:
|
||||||
; CHECK-NEXT: store i8 0, i8* [[ARG]], !g !0
|
; CHECK-NEXT: store i8 0, i8* [[ARG]], !g !0
|
||||||
|
@ -15,6 +15,7 @@ define void @tinkywinky() {
|
|||||||
; CHECK-NEXT: [[TMP136:%.*]] = load %struct.patatino*, %struct.patatino** [[TMP91]], align 8
|
; CHECK-NEXT: [[TMP136:%.*]] = load %struct.patatino*, %struct.patatino** [[TMP91]], align 8
|
||||||
; CHECK-NEXT: br label [[BB90]]
|
; CHECK-NEXT: br label [[BB90]]
|
||||||
; CHECK: bb138:
|
; CHECK: bb138:
|
||||||
|
; CHECK-NEXT: store i8 undef, i8* null
|
||||||
; CHECK-NEXT: br label [[BB138:%.*]]
|
; CHECK-NEXT: br label [[BB138:%.*]]
|
||||||
;
|
;
|
||||||
bb:
|
bb:
|
||||||
|
Loading…
Reference in New Issue
Block a user