[llvm-branch-commits] [llvm-branch] r98995 - in /llvm/branches/Apple/Hermes: ./ include/llvm/CodeGen/MachineJumpTableInfo.h lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Bob Wilson bob.wilson at apple.com
Fri Mar 19 14:29:21 PDT 2010


Author: bwilson
Date: Fri Mar 19 16:29:21 2010
New Revision: 98995

URL: http://llvm.org/viewvc/llvm-project?rev=98995&view=rev
Log:
--- Merging r98845 into '.':
U    include/llvm/CodeGen/MachineJumpTableInfo.h
U    lib/CodeGen/MachineFunction.cpp
U    lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
--- Merging r98977 into '.':
G    include/llvm/CodeGen/MachineJumpTableInfo.h
U    lib/CodeGen/BranchFolding.cpp
G    lib/CodeGen/MachineFunction.cpp

Modified:
    llvm/branches/Apple/Hermes/   (props changed)
    llvm/branches/Apple/Hermes/include/llvm/CodeGen/MachineJumpTableInfo.h
    llvm/branches/Apple/Hermes/lib/CodeGen/BranchFolding.cpp
    llvm/branches/Apple/Hermes/lib/CodeGen/MachineFunction.cpp
    llvm/branches/Apple/Hermes/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Propchange: llvm/branches/Apple/Hermes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 19 16:29:21 2010
@@ -1 +1 @@
-/llvm/trunk:96521,96525,96572,96621,96775,96825,96827,96990,97025,97065,97071,97538,97707,97757,97782,97797,98210,98270,98395,98398,98402,98409,98416,98427,98561,98586
+/llvm/trunk:96521,96525,96572,96621,96775,96825,96827,96990,97025,97065,97071,97538,97707,97757,97782,97797,98210,98270,98395,98398,98402,98409,98416,98427,98561,98586,98845,98977

Modified: llvm/branches/Apple/Hermes/include/llvm/CodeGen/MachineJumpTableInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Hermes/include/llvm/CodeGen/MachineJumpTableInfo.h?rev=98995&r1=98994&r2=98995&view=diff
==============================================================================
--- llvm/branches/Apple/Hermes/include/llvm/CodeGen/MachineJumpTableInfo.h (original)
+++ llvm/branches/Apple/Hermes/include/llvm/CodeGen/MachineJumpTableInfo.h Fri Mar 19 16:29:21 2010
@@ -79,9 +79,9 @@
   /// getEntryAlignment - Return the alignment of each entry in the jump table.
   unsigned getEntryAlignment(const TargetData &TD) const;
   
-  /// getJumpTableIndex - Create a new jump table or return an existing one.
+  /// createJumpTableIndex - Create a new jump table.
   ///
-  unsigned getJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
+  unsigned createJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
   
   /// isEmpty - Return true if there are no jump tables.
   ///

Modified: llvm/branches/Apple/Hermes/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Hermes/lib/CodeGen/BranchFolding.cpp?rev=98995&r1=98994&r2=98995&view=diff
==============================================================================
--- llvm/branches/Apple/Hermes/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Hermes/lib/CodeGen/BranchFolding.cpp Fri Mar 19 16:29:21 2010
@@ -203,7 +203,7 @@
     MadeChange |= MadeChangeThisIteration;
   }
 
-  // See if any jump tables have become mergable or dead as the code generator
+  // See if any jump tables have become dead as the code generator
   // did its thing.
   MachineJumpTableInfo *JTI = MF.getJumpTableInfo();
   if (JTI == 0) {
@@ -211,27 +211,8 @@
     return MadeChange;
   }
   
-  const std::vector<MachineJumpTableEntry> &JTs = JTI->getJumpTables();
-  // Figure out how these jump tables should be merged.
-  std::vector<unsigned> JTMapping;
-  JTMapping.reserve(JTs.size());
-
-  // We always keep the 0th jump table.
-  JTMapping.push_back(0);
-
-  // Scan the jump tables, seeing if there are any duplicates.  Note that this
-  // is N^2, which should be fixed someday.
-  for (unsigned i = 1, e = JTs.size(); i != e; ++i) {
-    if (JTs[i].MBBs.empty())
-      JTMapping.push_back(i);
-    else
-      JTMapping.push_back(JTI->getJumpTableIndex(JTs[i].MBBs));
-  }
-
-  // If a jump table was merge with another one, walk the function rewriting
-  // references to jump tables to reference the new JT ID's.  Keep track of
-  // whether we see a jump table idx, if not, we can delete the JT.
-  BitVector JTIsLive(JTs.size());
+  // Walk the function to find jump tables that are live.
+  BitVector JTIsLive(JTI->getJumpTables().size());
   for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
        BB != E; ++BB) {
     for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end();
@@ -239,17 +220,14 @@
       for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) {
         MachineOperand &Op = I->getOperand(op);
         if (!Op.isJTI()) continue;
-        unsigned NewIdx = JTMapping[Op.getIndex()];
-        Op.setIndex(NewIdx);
 
         // Remember that this JT is live.
-        JTIsLive.set(NewIdx);
+        JTIsLive.set(Op.getIndex());
       }
   }
 
-  // Finally, remove dead jump tables.  This happens either because the
-  // indirect jump was unreachable (and thus deleted) or because the jump
-  // table was merged with some other one.
+  // Finally, remove dead jump tables.  This happens when the
+  // indirect jump was unreachable (and thus deleted).
   for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i)
     if (!JTIsLive.test(i)) {
       JTI->RemoveJumpTable(i);

Modified: llvm/branches/Apple/Hermes/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Hermes/lib/CodeGen/MachineFunction.cpp?rev=98995&r1=98994&r2=98995&view=diff
==============================================================================
--- llvm/branches/Apple/Hermes/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/branches/Apple/Hermes/lib/CodeGen/MachineFunction.cpp Fri Mar 19 16:29:21 2010
@@ -591,17 +591,15 @@
   return ~0;
 }
 
-/// getJumpTableIndex - Create a new jump table entry in the jump table info
-/// or return an existing one.
+/// createJumpTableIndex - Create a new jump table entry in the jump table info.
 ///
-unsigned MachineJumpTableInfo::getJumpTableIndex(
+unsigned MachineJumpTableInfo::createJumpTableIndex(
                                const std::vector<MachineBasicBlock*> &DestBBs) {
   assert(!DestBBs.empty() && "Cannot create an empty jump table!");
   JumpTables.push_back(MachineJumpTableEntry(DestBBs));
   return JumpTables.size()-1;
 }
 
-
 /// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update
 /// the jump tables to branch to New instead.
 bool MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old,

Modified: llvm/branches/Apple/Hermes/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Hermes/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=98995&r1=98994&r2=98995&view=diff
==============================================================================
--- llvm/branches/Apple/Hermes/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/branches/Apple/Hermes/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Mar 19 16:29:21 2010
@@ -1677,11 +1677,10 @@
     }
   }
 
-  // Create a jump table index for this jump table, or return an existing
-  // one.
+  // Create a jump table index for this jump table.
   unsigned JTEncoding = TLI.getJumpTableEncoding();
   unsigned JTI = CurMF->getOrCreateJumpTableInfo(JTEncoding)
-                       ->getJumpTableIndex(DestBBs);
+                       ->createJumpTableIndex(DestBBs);
 
   // Set the jump table information so that we can codegen it as a second
   // MachineBasicBlock





More information about the llvm-branch-commits mailing list