diff --git a/lib/CodeGen/PostRAHazardRecognizer.cpp b/lib/CodeGen/PostRAHazardRecognizer.cpp index dd18704aeac..5bc5f7524db 100644 --- a/lib/CodeGen/PostRAHazardRecognizer.cpp +++ b/lib/CodeGen/PostRAHazardRecognizer.cpp @@ -79,18 +79,16 @@ bool PostRAHazardRecognizer::runOnMachineFunction(MachineFunction &Fn) { for (auto &MBB : Fn) { // We do not call HazardRec->reset() here to make sure we are handling noop // hazards at the start of basic blocks. - for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); - I != E; ++I) { - MachineInstr *MI = I; + for (MachineInstr &MI : MBB) { // If we need to emit noops prior to this instruction, then do so. - unsigned NumPreNoops = HazardRec->PreEmitNoops(MI); + unsigned NumPreNoops = HazardRec->PreEmitNoops(&MI); for (unsigned i = 0; i != NumPreNoops; ++i) { HazardRec->EmitNoop(); - TII->insertNoop(MBB, I); + TII->insertNoop(MBB, MachineBasicBlock::iterator(MI)); ++NumNoops; } - HazardRec->EmitInstruction(MI); + HazardRec->EmitInstruction(&MI); if (HazardRec->atIssueLimit()) { HazardRec->AdvanceCycle(); }