From 7f92b7ad0aa69a961154b88df90474ac38f076ac Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 4 Jan 2013 22:17:31 +0000 Subject: [PATCH] Move an assertion so it doesn't dereference end(). The R600 target has test cases that exercises this code. llvm-svn: 171538 --- llvm/lib/CodeGen/MachineInstrBundle.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index ffca550f8b64..77bcd1d7c8e3 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -224,14 +224,13 @@ bool llvm::finalizeBundles(MachineFunction &MF) { bool Changed = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { MachineBasicBlock &MBB = *I; - MachineBasicBlock::instr_iterator MII = MBB.instr_begin(); - assert(!MII->isInsideBundle() && - "First instr cannot be inside bundle before finalization!"); - MachineBasicBlock::instr_iterator MIE = MBB.instr_end(); if (MII == MIE) continue; + assert(!MII->isInsideBundle() && + "First instr cannot be inside bundle before finalization!"); + for (++MII; MII != MIE; ) { if (!MII->isInsideBundle()) ++MII;