[llvm-commits] [llvm] r152393 - /llvm/trunk/lib/CodeGen/MachineScheduler.cpp

Andrew Trick atrick at apple.com
Fri Mar 9 00:02:52 PST 2012


Author: atrick
Date: Fri Mar  9 02:02:51 2012
New Revision: 152393

URL: http://llvm.org/viewvc/llvm-project?rev=152393&view=rev
Log:
misched: handle scheduling region boundaries nicely.

Modified:
    llvm/trunk/lib/CodeGen/MachineScheduler.cpp

Modified: llvm/trunk/lib/CodeGen/MachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineScheduler.cpp?rev=152393&r1=152392&r2=152393&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineScheduler.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineScheduler.cpp Fri Mar  9 02:02:51 2012
@@ -141,12 +141,21 @@
   for (MachineFunction::iterator MBB = MF->begin(), MBBEnd = MF->end();
        MBB != MBBEnd; ++MBB) {
 
+    Scheduler->startBlock(MBB);
+
     // 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();) {
-      Scheduler->startBlock(MBB);
+      // Avoid decrementing RegionEnd for blocks with no terminator.
+      if (RegionEnd != MBB->end()
+          || TII->isSchedulingBoundary(llvm::prior(RegionEnd), MBB, *MF)) {
+        --RegionEnd;
+        // Count the boundary instruction.
+        --RemainingCount;
+      }
+
       // The next region starts above the previous region. Look backward in the
       // instruction stream until we find the nearest boundary.
       MachineBasicBlock::iterator I = RegionEnd;
@@ -160,11 +169,9 @@
 
       // Skip empty scheduling regions (0 or 1 schedulable instructions).
       if (I == RegionEnd || I == llvm::prior(RegionEnd)) {
-        RegionEnd = llvm::prior(RegionEnd);
-        if (I != RegionEnd)
-          --RemainingCount;
         // Close the current region. Bundle the terminator if needed.
         Scheduler->exitRegion();
+        RegionEnd = I;
         continue;
       }
       DEBUG(dbgs() << "MachineScheduling " << MF->getFunction()->getName()





More information about the llvm-commits mailing list