[llvm] r293515 - NewGVN: Instead of changeToUnreachable, insert an instruction SimplifyCFG will turn into unreachable when it runs
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 10:12:56 PST 2017
Author: dannyb
Date: Mon Jan 30 12:12:56 2017
New Revision: 293515
URL: http://llvm.org/viewvc/llvm-project?rev=293515&view=rev
Log:
NewGVN: Instead of changeToUnreachable, insert an instruction SimplifyCFG will turn into unreachable when it runs
Modified:
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
llvm/trunk/test/Transforms/NewGVN/pr31594.ll
llvm/trunk/test/Transforms/NewGVN/pr31758.ll
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=293515&r1=293514&r2=293515&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Mon Jan 30 12:12:56 2017
@@ -2106,10 +2106,6 @@ void NewGVN::deleteInstructionsInBlock(B
DEBUG(dbgs() << " BasicBlock Dead:" << *BB);
++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
// to update as many def-use and use-def chains. Start after the terminator.
auto StartPoint = BB->rbegin();
@@ -2126,6 +2122,11 @@ void NewGVN::deleteInstructionsInBlock(B
Inst.eraseFromParent();
++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) {
Modified: llvm/trunk/test/Transforms/NewGVN/pr31594.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NewGVN/pr31594.ll?rev=293515&r1=293514&r2=293515&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/NewGVN/pr31594.ll (original)
+++ llvm/trunk/test/Transforms/NewGVN/pr31594.ll Mon Jan 30 12:12:56 2017
@@ -77,6 +77,7 @@ define void @foo(i8* %arg) {
; CHECK-NEXT: i8 6, label [[BB8:%.*]]
; CHECK-NEXT: ]
; CHECK: bb8:
+; CHECK-NEXT: store i8 undef, i8* null
; CHECK-NEXT: br label [[BB4]]
; CHECK: bb9:
; CHECK-NEXT: store i8 0, i8* [[ARG]], !g !0
Modified: llvm/trunk/test/Transforms/NewGVN/pr31758.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NewGVN/pr31758.ll?rev=293515&r1=293514&r2=293515&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/NewGVN/pr31758.ll (original)
+++ llvm/trunk/test/Transforms/NewGVN/pr31758.ll Mon Jan 30 12:12:56 2017
@@ -15,6 +15,7 @@ define void @tinkywinky() {
; CHECK-NEXT: [[TMP136:%.*]] = load %struct.patatino*, %struct.patatino** [[TMP91]], align 8
; CHECK-NEXT: br label [[BB90]]
; CHECK: bb138:
+; CHECK-NEXT: store i8 undef, i8* null
; CHECK-NEXT: br label [[BB138:%.*]]
;
bb:
More information about the llvm-commits
mailing list