// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Peephole::DeleteDeadInstructions(Function* function) { // We process the blocks from last to first, and the instructions // in the blocks from last to first too, because it allows deleting // more dead instructions than processing from first to last. Block* block = function->LastBlock(); while(block) { Instruction* instr = block->LastInstruction(); while(instr) { Instruction* prevInstr = instr->PreviousInstruction(); DebugValidator::AreNotEqual(prevInstr, instr); // Delete the instruction if we're certain it's dead. if(GetSafetyInfo()->IsDefinitelyDead(instr)) { block->RemoveInstruction(instr, true /* free */); } instr = prevInstr; } block = block->PreviousBlock(); } }