Abort AdjustBBOffsetsAfter early when possible.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 6 Jan 2012 21:40:15 +0000 (21:40 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 6 Jan 2012 21:40:15 +0000 (21:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147685 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMConstantIslandPass.cpp

index 2a7721bc74c2ff0b4b0f9c29b7864e1964295876..b73acd184c6a366e9ee2e5ea441347f3b1ef52c9 100644 (file)
@@ -1035,14 +1035,22 @@ static bool BBIsJumpedOver(MachineBasicBlock *MBB) {
 #endif // NDEBUG
 
 void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB) {
-  for(unsigned i = BB->getNumber() + 1, e = MF->getNumBlockIDs(); i < e; ++i) {
+  unsigned BBNum = BB->getNumber();
+  for(unsigned i = BBNum + 1, e = MF->getNumBlockIDs(); i < e; ++i) {
     // Get the offset and known bits at the end of the layout predecessor.
     // Include the alignment of the current block.
     unsigned LogAlign = MF->getBlockNumbered(i)->getAlignment();
     unsigned Offset = BBInfo[i - 1].postOffset(LogAlign);
     unsigned KnownBits = BBInfo[i - 1].postKnownBits(LogAlign);
 
-    // This is where block i begins.
+    // This is where block i begins.  Stop if the offset is already correct,
+    // and we have updated 2 blocks.  This is the maximum number of blocks
+    // changed before calling this function.
+    if (i > BBNum + 2 &&
+        BBInfo[i].Offset == Offset &&
+        BBInfo[i].KnownBits == KnownBits)
+      break;
+
     BBInfo[i].Offset = Offset;
     BBInfo[i].KnownBits = KnownBits;
   }