[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

Jim Laskey jlaskey at apple.com
Tue Oct 24 04:50:59 PDT 2006



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.84 -> 1.85
MachineDebugInfo.cpp updated: 1.52 -> 1.53
---
Log message:

Tighter data structure for deleted debug labels.

---
Diffs of the changes:  (+20 -4)

 DwarfWriter.cpp      |    3 +--
 MachineDebugInfo.cpp |   21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.84 llvm/lib/CodeGen/DwarfWriter.cpp:1.85
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.84	Mon Oct 23 09:56:37 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Tue Oct 24 06:50:43 2006
@@ -2207,8 +2207,7 @@
       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: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.52 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.53
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.52	Mon Oct 23 09:56:37 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Tue Oct 24 06:50:43 2006
@@ -1544,16 +1544,33 @@
   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






More information about the llvm-commits mailing list