eliminate InvalidateLabel and LabelIDList from MMI and replace
authorChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2010 02:24:55 +0000 (02:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 14 Mar 2010 02:24:55 +0000 (02:24 +0000)
them with a counter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98462 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineModuleInfo.h
lib/CodeGen/BranchFolding.cpp
lib/CodeGen/MachineModuleInfo.cpp
lib/CodeGen/TailDuplication.cpp
lib/CodeGen/UnreachableBlockElim.cpp

index eba49bd7963f79147a39c51074ed5feeb6d6ebfc..9215b3354015c1962b8510827ed9918a981292d8 100644 (file)
@@ -102,11 +102,8 @@ class MachineModuleInfo : public ImmutablePass {
   /// want.
   MachineModuleInfoImpl *ObjFileMMI;
 
-  // LabelIDList - One entry per assigned label.  Normally the entry is equal to
-  // the list index(+1).  If the entry is zero then the label has been deleted.
-  // Any other value indicates the label has been deleted by is mapped to
-  // another label.
-  std::vector<unsigned> LabelIDList;
+  /// NextLabelIDToReturn - Unique ID counter for labels.
+  unsigned NextLabelIDToReturn;
   
   // FrameMoves - List of moves done by a function's prolog.  Used to construct
   // frame maps by debug and exception handling consumers.
@@ -207,23 +204,12 @@ public:
   /// NextLabelID - Return the next unique label id.
   ///
   unsigned NextLabelID() {
-    unsigned ID = (unsigned)LabelIDList.size() + 1;
-    LabelIDList.push_back(ID);
-    return ID;
+    return NextLabelIDToReturn++;
   }
   
   /// getLabelSym - Turn a label ID into a symbol.
   MCSymbol *getLabelSym(unsigned ID);
   
-  /// InvalidateLabel - Inhibit use of the specified label # from
-  /// MachineModuleInfo, for example because the code was deleted.
-  void InvalidateLabel(unsigned LabelID) {
-    // Remap to zero to indicate deletion.
-    assert(0 < LabelID && LabelID <= LabelIDList.size() &&
-           "Old label ID out of range.");
-    LabelIDList[LabelID - 1] = 0;
-  }
-  
   /// getFrameMoves - Returns a reference to a list of moves done in the current
   /// function's prologue.  Used to construct frame maps for debug and exception
   /// handling comsumers.
index 7e27bf5631eb2ca0c77d84f2119d95c376ae3cee..13ae43daf6ddda2d8eadda01420e811546b9a1e5 100644 (file)
@@ -105,17 +105,6 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {
   while (!MBB->succ_empty())
     MBB->removeSuccessor(MBB->succ_end()-1);
 
-  // If there are any labels in the basic block, unregister them from
-  // MachineModuleInfo.
-  if (MMI && !MBB->empty()) {
-    for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
-         I != E; ++I) {
-      if (I->isLabel())
-        // The label ID # is always operand #0, an immediate.
-        MMI->InvalidateLabel(I->getOperand(0).getImm());
-    }
-  }
-
   // Remove the block.
   MF->erase(MBB);
 }
index 27c138789dc5af3b0cf4b7e5784bccfbcc1b9d3b..42c6a7fef3f84e0d07b0a9d4cba8d82b076167d1 100644 (file)
@@ -41,8 +41,8 @@ MachineModuleInfoImpl::~MachineModuleInfoImpl() {}
 
 MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI)
 : ImmutablePass(&ID), Context(MAI),
-  ObjFileMMI(0), CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0),
-  DbgInfoAvailable(false) {
+  ObjFileMMI(0), NextLabelIDToReturn(1), 
+  CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), DbgInfoAvailable(false){
   // Always emit some info, by default "no personality" info.
   Personalities.push_back(NULL);
 }
index 3223e53d5dace53b72a8e17054c91a357602465d..fa3785dc0795f9a989cb1825b49cdf410925ead8 100644 (file)
@@ -648,17 +648,6 @@ void TailDuplicatePass::RemoveDeadBlock(MachineBasicBlock *MBB) {
   while (!MBB->succ_empty())
     MBB->removeSuccessor(MBB->succ_end()-1);
 
-  // If there are any labels in the basic block, unregister them from
-  // MachineModuleInfo.
-  if (MMI && !MBB->empty()) {
-    for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
-         I != E; ++I) {
-      if (I->isLabel())
-        // The label ID # is always operand #0, an immediate.
-        MMI->InvalidateLabel(I->getOperand(0).getImm());
-    }
-  }
-
   // Remove the block.
   MBB->eraseFromParent();
 }
index b0f0a07420c39fac6d0e0b1524e51ccbb2745350..7b338126d475f9201ef8cba7711e13df1b5b5e38 100644 (file)
@@ -165,20 +165,8 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
   }
 
   // Actually remove the blocks now.
-  for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
-    MachineBasicBlock *MBB = DeadBlocks[i];
-    // If there are any labels in the basic block, unregister them from
-    // MachineModuleInfo.
-    if (MMI && !MBB->empty()) {
-      for (MachineBasicBlock::iterator I = MBB->begin(),
-             E = MBB->end(); I != E; ++I) {
-        if (I->isLabel())
-          // The label ID # is always operand #0, an immediate.
-          MMI->InvalidateLabel(I->getOperand(0).getImm());
-      }
-    }
-    MBB->eraseFromParent();
-  }
+  for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i)
+    DeadBlocks[i]->eraseFromParent();
 
   // Cleanup PHI nodes.
   for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {