Move an assertion so it doesn't dereference end().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 4 Jan 2013 22:17:31 +0000 (22:17 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 4 Jan 2013 22:17:31 +0000 (22:17 +0000)
The R600 target has test cases that exercises this code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171538 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineInstrBundle.cpp

index ffca550f8b64ec4b079ae42ed809e0b115f3e96e..77bcd1d7c8e30a05620ab1a246d625ec9885de61 100644 (file)
@@ -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;