From cb03f8547d9e0f4cf70d5eec226f2ccfbc8fdfe4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 27 Nov 2008 22:46:09 +0000 Subject: [PATCH] simplify this logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60189 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/DCE.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index fb9a0e04fd6..a5990ee79e8 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -39,12 +39,14 @@ namespace { DeadInstElimination() : BasicBlockPass(intptr_t(&ID)) {} virtual bool runOnBasicBlock(BasicBlock &BB) { bool Changed = false; - for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) - if (dceInstruction(DI)) { + for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) { + Instruction *Inst = DI++; + if (isInstructionTriviallyDead(Inst)) { + Inst->eraseFromParent(); Changed = true; ++DIEEliminated; - } else - ++DI; + } + } return Changed; }