[llvm-commits] [llvm] r139090 - in /llvm/trunk/lib/Transforms: InstCombine/InstructionCombining.cpp Scalar/SCCP.cpp
Bill Wendling
isanbard at gmail.com
Sun Sep 4 02:43:36 PDT 2011
Author: void
Date: Sun Sep 4 04:43:36 2011
New Revision: 139090
URL: http://llvm.org/viewvc/llvm-project?rev=139090&view=rev
Log:
Use Duncan's patch to delete the instructions in reverse order (minus the landingpad and terminator).
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=139090&r1=139089&r2=139090&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sun Sep 4 04:43:36 2011
@@ -1574,15 +1574,19 @@
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
if (Visited.count(BB)) continue;
- // Delete the instructions.
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
- Instruction *Inst = &*I++;
- if (isa<TerminatorInst>(Inst))
- break;
+ // Delete the instructions backwards, as it has a reduced likelihood of
+ // having to update as many def-use and use-def chains.
+ Instruction *EndInst = BB->getTerminator(); // Last not to be deleted.
+ while (EndInst != BB->begin()) {
+ // Delete the next to last instruction.
+ BasicBlock::iterator I = EndInst;
+ Instruction *Inst = --I;
if (!Inst->use_empty())
Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
- if (isa<LandingPadInst>(Inst))
+ if (isa<LandingPadInst>(Inst)) {
+ EndInst = Inst;
continue;
+ }
if (!isa<DbgInfoIntrinsic>(Inst)) {
++NumDeadInst;
MadeIRChange = true;
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=139090&r1=139089&r2=139090&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Sep 4 04:43:36 2011
@@ -1686,15 +1686,19 @@
if (isa<TerminatorInst>(BB->begin()))
return;
- // Delete the instructions.
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
- Instruction *Inst = &*I++;
- if (isa<TerminatorInst>(Inst))
- break;
+ // Delete the instructions backwards, as it has a reduced likelihood of having
+ // to update as many def-use and use-def chains.
+ Instruction *EndInst = BB->getTerminator(); // Last not to be deleted.
+ while (EndInst != BB->begin()) {
+ // Delete the next to last instruction.
+ BasicBlock::iterator I = EndInst;
+ Instruction *Inst = --I;
if (!Inst->use_empty())
Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
- if (isa<LandingPadInst>(Inst))
+ if (isa<LandingPadInst>(Inst)) {
+ EndInst = Inst;
continue;
+ }
BB->getInstList().erase(Inst);
++NumInstRemoved;
}
More information about the llvm-commits
mailing list