simplify this logic.
authorChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 22:46:09 +0000 (22:46 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 22:46:09 +0000 (22:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60189 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/DCE.cpp

index fb9a0e04fd6243a9380f2d2f0f902cbb8790854a..a5990ee79e89d863b79eafba4e40f1687b2351d3 100644 (file)
@@ -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;
     }