Tighter data structure for deleted debug labels.
authorJim Laskey <jlaskey@mac.com>
Tue, 24 Oct 2006 11:50:43 +0000 (11:50 +0000)
committerJim Laskey <jlaskey@mac.com>
Tue, 24 Oct 2006 11:50:43 +0000 (11:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31152 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineDebugInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/CodeGen/MachineDebugInfo.cpp

index 940adb7899691426259933fe3972bf4bee333196..39b2464072333df6c276ea8ed0b98672887aafb2 100644 (file)
@@ -30,8 +30,6 @@
 #ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
 #define LLVM_CODEGEN_MACHINEDEBUGINFO_H
 
-#include <set>
-
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/ADT/UniqueVector.h"
@@ -981,9 +979,9 @@ private:
   //
   DebugScope *RootScope;
   
-  // DeletedLabelIDs - List of label IDs that have been removed from the
+  // DeletedLabelIDs - Sorted list of label IDs that have been removed from the
   // module.
-  std::set<unsigned> DeletedLabelIDs;
+  std::vector<unsigned> DeletedLabelIDs;
   
   // FrameMoves - List of moves done by a function's prolog.  Used to construct
   // frame maps by debug consumers.
index c600edbdf831b943e58d59d86850768a262370e6..7e3e4831d1e581100f244e124293c4f0cf7fcfb1 100644 (file)
@@ -2207,8 +2207,7 @@ void DwarfWriter::EmitDebugLines() const {
       const SourceLineInfo &LineInfo = LineInfos[i];
       unsigned LabelID = LineInfo.getLabelID();
       
-      // Throw out line info if label is invalid.
-      if (!DebugInfo->isLabelValid(LabelID)) continue;
+      // Source line labels are validated at the MachineDebugInfo level.
       
       if (DwarfVerbose) {
         unsigned SourceID = LineInfo.getSourceID();
index 380b8a9656d3f3e4d6067c306a72d8d6817f0ddb..b895cd7727a551838d348e85485116b2c276ec76 100644 (file)
@@ -1544,16 +1544,33 @@ unsigned MachineDebugInfo::RecordLabel(unsigned Line, unsigned Column,
   return ID;
 }
 
+static bool LabelUIDComparison(const SourceLineInfo &LI, unsigned UID) {
+  return LI.getLabelID() < UID;
+}
 /// InvalidateLabel - Inhibit use of the specified label # from
 /// MachineDebugInfo, for example because the code was deleted.
 void MachineDebugInfo::InvalidateLabel(unsigned LabelID) {
-  DeletedLabelIDs.insert(LabelID);
+  // Check source line list first.  SourceLineInfo is sorted by LabelID.
+  std::vector<SourceLineInfo>::iterator I =
+    std::lower_bound(Lines.begin(), Lines.end(), LabelID, LabelUIDComparison);
+  if (I != Lines.end() && I->getLabelID() == LabelID) {
+    Lines.erase(I);
+    return;
+  }
+  
+  // Otherwise add for use by isLabelValid.
+  std::vector<unsigned>::iterator J =
+    std::lower_bound(DeletedLabelIDs.begin(), DeletedLabelIDs.end(), LabelID);
+  DeletedLabelIDs.insert(J, LabelID);
 }
 
 /// isLabelValid - Check to make sure the label is still valid before
 /// attempting to use.
 bool MachineDebugInfo::isLabelValid(unsigned LabelID) {
-  return DeletedLabelIDs.find(LabelID) == DeletedLabelIDs.end();
+  std::vector<unsigned>::iterator I =
+    std::lower_bound(DeletedLabelIDs.begin(), DeletedLabelIDs.end(), LabelID);
+  return I != DeletedLabelIDs.end() && *I == LabelID;
 }
 
 /// RecordSource - Register a source file with debug info. Returns an source