diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-04 09:43:36 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-04 09:43:36 +0000 |
commit | a268468d50a0c6f7de27299d50c6e387e404d685 (patch) | |
tree | 635addb107f9ec8faa2d3a411c69310f789f24a8 /lib/Transforms/InstCombine | |
parent | 66d1836380f128b07ef962dd7012ee6755884600 (diff) | |
download | external_llvm-a268468d50a0c6f7de27299d50c6e387e404d685.zip external_llvm-a268468d50a0c6f7de27299d50c6e387e404d685.tar.gz external_llvm-a268468d50a0c6f7de27299d50c6e387e404d685.tar.bz2 |
Use Duncan's patch to delete the instructions in reverse order (minus the landingpad and terminator).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r-- | lib/Transforms/InstCombine/InstructionCombining.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 51fe2e5..f64990f 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1574,15 +1574,19 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { 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; |