Cache MBB->begin. It's possible the scheduler / bundler may change MBB->begin().
authorEvan Cheng <evan.cheng@apple.com>
Fri, 9 Mar 2012 00:24:29 +0000 (00:24 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 9 Mar 2012 00:24:29 +0000 (00:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152356 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineScheduler.cpp

index 203ddfd18bc7a7e223fcfbaaf0423d6b0625d375..80862157cc4813f1b2f2b373c20ac74a35568b5e 100644 (file)
@@ -128,13 +128,13 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
     // Break the block into scheduling regions [I, RegionEnd), and schedule each
     // region as soon as it is discovered.
     unsigned RemainingCount = MBB->size();
-    for(MachineBasicBlock::iterator RegionEnd = MBB->end();
-        RegionEnd != MBB->begin();) {
+    for(MachineBasicBlock::iterator RegionEnd = MBB->end(),
+          RegionStart = MBB->begin(); RegionEnd != RegionStart;) {
       Scheduler->startBlock(MBB);
       // The next region starts above the previous region. Look backward in the
       // instruction stream until we find the nearest boundary.
       MachineBasicBlock::iterator I = RegionEnd;
-      for(;I != MBB->begin(); --I, --RemainingCount) {
+      for(;I != RegionStart; --I, --RemainingCount) {
         if (TII->isSchedulingBoundary(llvm::prior(I), MBB, *MF))
           break;
       }