mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Use Duncan's patch to delete the instructions in reverse order (minus the landingpad and terminator).
llvm-svn: 139090
This commit is contained in:
parent
dbea8de893
commit
0506959970
@ -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;
|
||||
|
@ -1686,15 +1686,19 @@ static void DeleteInstructionInBlock(BasicBlock *BB) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user