remove doConstantPropagation and dceInstruction, they are just
wrappers around the interesting code and use an obscure iterator
abstraction that dates back many many years.
Move EraseDeadInstructions to Transforms/Utils and name it
RecursivelyDeleteTriviallyDeadInstructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60191 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 9bf3991..e6b7497 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -454,26 +454,6 @@
return MadeChange;
}
-/// EraseDeadInstructions - Erase any dead instructions, recursively.
-static void EraseDeadInstructions(Value *V) {
- Instruction *I = dyn_cast<Instruction>(V);
- if (!I || !I->use_empty()) return;
-
- SmallPtrSet<Instruction*, 16> Insts;
- Insts.insert(I);
-
- while (!Insts.empty()) {
- I = *Insts.begin();
- Insts.erase(I);
- if (isInstructionTriviallyDead(I)) {
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
- Insts.insert(U);
- I->eraseFromParent();
- }
- }
-}
-
//===----------------------------------------------------------------------===//
// Addressing Mode Analysis and Optimization
//===----------------------------------------------------------------------===//
@@ -1234,7 +1214,7 @@
MemoryInst->replaceUsesOfWith(Addr, SunkAddr);
if (Addr->use_empty())
- EraseDeadInstructions(Addr);
+ RecursivelyDeleteTriviallyDeadInstructions(Addr);
return true;
}