[llvm-branch-commits] [llvm-branch] r88815 - in /llvm/branches/Apple/Leela: include/llvm/CodeGen/MachineJumpTableInfo.h lib/CodeGen/MachineFunction.cpp lib/Target/ARM/ARMConstantIslandPass.cpp

Jim Grosbach grosbach at apple.com
Sat Nov 14 13:41:49 PST 2009


Author: grosbach
Date: Sat Nov 14 15:41:49 2009
New Revision: 88815

URL: http://llvm.org/viewvc/llvm-project?rev=88815&view=rev
Log:
merge 88804 88805 88806 88812

Modified:
    llvm/branches/Apple/Leela/include/llvm/CodeGen/MachineJumpTableInfo.h
    llvm/branches/Apple/Leela/lib/CodeGen/MachineFunction.cpp
    llvm/branches/Apple/Leela/lib/Target/ARM/ARMConstantIslandPass.cpp

Modified: llvm/branches/Apple/Leela/include/llvm/CodeGen/MachineJumpTableInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/CodeGen/MachineJumpTableInfo.h?rev=88815&r1=88814&r2=88815&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/CodeGen/MachineJumpTableInfo.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/CodeGen/MachineJumpTableInfo.h Sat Nov 14 15:41:49 2009
@@ -69,6 +69,11 @@
   /// the jump tables to branch to New instead.
   bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New);
 
+  /// ReplaceMBBInJumpTable - If Old is a target of the jump tables, update
+  /// the jump table to branch to New instead.
+  bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old,
+                             MachineBasicBlock *New);
+
   /// getEntrySize - Returns the size of an individual field in a jump table. 
   ///
   unsigned getEntrySize() const { return EntrySize; }

Modified: llvm/branches/Apple/Leela/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/MachineFunction.cpp?rev=88815&r1=88814&r2=88815&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/MachineFunction.cpp Sat Nov 14 15:41:49 2009
@@ -529,10 +529,6 @@
 unsigned MachineJumpTableInfo::getJumpTableIndex(
                                const std::vector<MachineBasicBlock*> &DestBBs) {
   assert(!DestBBs.empty() && "Cannot create an empty jump table!");
-  for (unsigned i = 0, e = JumpTables.size(); i != e; ++i)
-    if (JumpTables[i].MBBs == DestBBs)
-      return i;
-  
   JumpTables.push_back(MachineJumpTableEntry(DestBBs));
   return JumpTables.size()-1;
 }
@@ -544,14 +540,25 @@
                                              MachineBasicBlock *New) {
   assert(Old != New && "Not making a change?");
   bool MadeChange = false;
-  for (size_t i = 0, e = JumpTables.size(); i != e; ++i) {
-    MachineJumpTableEntry &JTE = JumpTables[i];
-    for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
-      if (JTE.MBBs[j] == Old) {
-        JTE.MBBs[j] = New;
-        MadeChange = true;
-      }
-  }
+  for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
+    ReplaceMBBInJumpTable(i, Old, New);
+  return MadeChange;
+}
+
+/// ReplaceMBBInJumpTable - If Old is a target of the jump tables, update
+/// the jump table to branch to New instead.
+bool
+MachineJumpTableInfo::ReplaceMBBInJumpTable(unsigned Idx,
+                                            MachineBasicBlock *Old,
+                                            MachineBasicBlock *New) {
+  assert(Old != New && "Not making a change?");
+  bool MadeChange = false;
+  MachineJumpTableEntry &JTE = JumpTables[Idx];
+  for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
+    if (JTE.MBBs[j] == Old) {
+      JTE.MBBs[j] = New;
+      MadeChange = true;
+    }
   return MadeChange;
 }
 

Modified: llvm/branches/Apple/Leela/lib/Target/ARM/ARMConstantIslandPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=88815&r1=88814&r2=88815&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Target/ARM/ARMConstantIslandPass.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Target/ARM/ARMConstantIslandPass.cpp Sat Nov 14 15:41:49 2009
@@ -48,7 +48,7 @@
 
 
 static cl::opt<bool>
-AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(false),
+AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(true),
           cl::desc("Adjust basic block layout to better use TB[BH]"));
 
 namespace {
@@ -1749,7 +1749,7 @@
         MachineBasicBlock *NewBB =
           AdjustJTTargetBlockForward(MBB, MI->getParent());
         if (NewBB)
-          MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB);
+          MJTI->ReplaceMBBInJumpTable(JTI, JTBBs[j], NewBB);
         MadeChange = true;
       }
     }
@@ -1772,16 +1772,16 @@
   int Size = BBSizes[BBI];
   MachineBasicBlock *TBB = 0, *FBB = 0;
   SmallVector<MachineOperand, 4> Cond;
-  // If the block terminator isn't analyzable, don't try to move the block
-  if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
-    return NULL;
-
   // If the block is small and ends in an unconditional branch, move it.
   if (Size < 50 && Cond.empty()) {
+    // If the block terminator isn't analyzable, don't try to move the block
+    if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
+      return NULL;
+
     MachineFunction::iterator OldPrior = prior(BB);
     BB->moveAfter(JTBB);
     OldPrior->updateTerminator();
-    //BB->updateTerminator();
+    BB->updateTerminator();
     ++NumJTMoved;
     return NULL;
   }
@@ -1798,14 +1798,14 @@
   assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?");
   BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB);
 
+  // Update internal data structures to account for the newly inserted MBB.
+  MF.RenumberBlocks(NewBB);
+
   // Update the CFG.
   NewBB->addSuccessor(BB);
   JTBB->removeSuccessor(BB);
   JTBB->addSuccessor(NewBB);
 
-  // Update internal data structures to account for the newly inserted MBB.
-  MF.RenumberBlocks();
-
   // Insert a size into BBSizes to align it properly with the (newly
   // renumbered) block numbers.
   BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0);





More information about the llvm-branch-commits mailing list