DebugLabelFolder ruthlessly deletes redundant labels. However, sometimes the redundan...
authorDevang Patel <dpatel@apple.com>
Fri, 10 Apr 2009 18:58:59 +0000 (18:58 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 10 Apr 2009 18:58:59 +0000 (18:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68813 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineModuleInfo.h
lib/CodeGen/MachineModuleInfo.cpp

index 75956058c457041816b488a4ebf2ea7e1f5aab2d..e5f7c6a9a2831918f92fb503a4611ca53142c4f3 100644 (file)
@@ -37,6 +37,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/UniqueVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/GlobalValue.h"
@@ -115,6 +116,9 @@ private:
   // searchable format.
   SmallPtrSet<const Function *, 32> UsedFunctions;
 
+  /// UsedDbgLabels - labels are used by debug info entries.
+  SmallSet<unsigned, 8> UsedDbgLabels;
+
   bool CallsEHReturn;
   bool CallsUnwindInit;
  
@@ -195,6 +199,19 @@ public:
     return LabelID ? LabelIDList[LabelID - 1] : 0;
   }
 
+  /// isDbgLabelUsed - Return true if label with LabelID is used by
+  /// DwarfWriter.
+  bool isDbgLabelUsed(unsigned LabelID) {
+    return UsedDbgLabels.count(LabelID);
+  }
+  
+  /// RecordUsedDbgLabel - Mark label with LabelID as used. This is used
+  /// by DwarfWriter to inform DebugLabelFolder that certain labels are
+  /// not to be deleted.
+  void RecordUsedDbgLabel(unsigned LabelID) {
+    UsedDbgLabels.insert(LabelID);
+  }
+
   /// 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 4bbc4dd985a77ae8466cd8bcfe3bb1886b823c17..1d8109eb8d9954549854278d3229269e81054ddf 100644 (file)
@@ -333,7 +333,7 @@ bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) {
     // Iterate through instructions.
     for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
       // Is it a label.
-      if (I->isDebugLabel(){
+      if (I->isDebugLabel() && !MMI->isDbgLabelUsed(I->getOperand(0).getImm())){
         // The label ID # is always operand #0, an immediate.
         unsigned NextLabel = I->getOperand(0).getImm();