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

Jim Laskey jlaskey at apple.com
Mon Oct 23 07:56:52 PDT 2006



Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.19 -> 1.20
DwarfWriter.cpp updated: 1.83 -> 1.84
MachineDebugInfo.cpp updated: 1.51 -> 1.52
---
Log message:

More complete solution to deleting blocks and debug info.

---
Diffs of the changes:  (+28 -14)

 BranchFolding.cpp    |    2 +-
 DwarfWriter.cpp      |   21 ++++++++++++++++++---
 MachineDebugInfo.cpp |   19 +++++++++----------
 3 files changed, 28 insertions(+), 14 deletions(-)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.19 llvm/lib/CodeGen/BranchFolding.cpp:1.20
--- llvm/lib/CodeGen/BranchFolding.cpp:1.19	Sat Oct 21 01:11:43 2006
+++ llvm/lib/CodeGen/BranchFolding.cpp	Mon Oct 23 09:56:37 2006
@@ -75,7 +75,7 @@
          I != E; ++I) {
       if ((unsigned)I->getOpcode() == DWARF_LABELOpc) {
         // The label ID # is always operand #0, an immediate.
-        MDI->RemoveLabelInfo(I->getOperand(0).getImm());
+        MDI->InvalidateLabel(I->getOperand(0).getImm());
       }
     }
   }


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.83 llvm/lib/CodeGen/DwarfWriter.cpp:1.84
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.83	Tue Oct 17 17:06:46 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Mon Oct 23 09:56:37 2006
@@ -1755,17 +1755,24 @@
     // FIXME - Ignore inlined functions for the time being.
     if (!Scope->getParent()) continue;
     
+    unsigned StartID = Scope->getStartLabelID();
+    unsigned EndID = Scope->getEndLabelID();
+    
+    // Throw out scope if block is discarded.
+    if (StartID && !DebugInfo->isLabelValid(StartID)) continue;
+    if (EndID && !DebugInfo->isLabelValid(EndID)) continue;
+    
     DIE *ScopeDie = new DIE(DW_TAG_lexical_block);
     
     // Add the scope bounds.
-    if (unsigned StartID = Scope->getStartLabelID()) {
+    if (StartID) {
       ScopeDie->AddLabel(DW_AT_low_pc, DW_FORM_addr,
                          DWLabel("loc", StartID));
     } else {
       ScopeDie->AddLabel(DW_AT_low_pc, DW_FORM_addr,
                          DWLabel("func_begin", SubprogramCount));
     }
-    if (unsigned EndID = Scope->getEndLabelID()) {
+    if (EndID) {
       ScopeDie->AddLabel(DW_AT_high_pc, DW_FORM_addr,
                          DWLabel("loc", EndID));
     } else {
@@ -1975,6 +1982,10 @@
   for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
     MachineMove *Move = Moves[i];
     unsigned LabelID = Move->getLabelID();
+    
+    // Throw out move if the label is invalid.
+    if (LabelID && !DebugInfo->isLabelValid(LabelID)) continue;
+    
     const MachineLocation &Dst = Move->getDestination();
     const MachineLocation &Src = Move->getSource();
     
@@ -2194,6 +2205,10 @@
     // Construct rows of the address, source, line, column matrix.
     for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
       const SourceLineInfo &LineInfo = LineInfos[i];
+      unsigned LabelID = LineInfo.getLabelID();
+      
+      // Throw out line info if label is invalid.
+      if (!DebugInfo->isLabelValid(LabelID)) continue;
       
       if (DwarfVerbose) {
         unsigned SourceID = LineInfo.getSourceID();
@@ -2210,7 +2225,7 @@
       EmitInt8(0); EOL("Extended Op");
       EmitInt8(4 + 1); EOL("Op size");
       EmitInt8(DW_LNE_set_address); EOL("DW_LNE_set_address");
-      EmitReference("loc",  LineInfo.getLabelID()); EOL("Location label");
+      EmitReference("loc",  LabelID); EOL("Location label");
       
       // If change of source, then switch to the new source.
       if (Source != LineInfo.getSourceID()) {


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.51 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.52
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.51	Fri Oct 20 02:07:24 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Mon Oct 23 09:56:37 2006
@@ -1451,6 +1451,7 @@
 , LabelID(0)
 , ScopeMap()
 , RootScope(NULL)
+, DeletedLabelIDs()
 , FrameMoves()
 {}
 MachineDebugInfo::~MachineDebugInfo() {
@@ -1543,20 +1544,18 @@
   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);
 }
 
-/// RemoveLabelInfo - Remove the specified label # from MachineDebugInfo, for
-/// example because the code was deleted.
-void MachineDebugInfo::RemoveLabelInfo(unsigned LabelUID) {
-  std::vector<SourceLineInfo>::iterator I =
-    std::lower_bound(Lines.begin(), Lines.end(), LabelUID, LabelUIDComparison);
-  assert(I != Lines.end() && "Didn't find label UID in MachineDebugInfo!");
-  Lines.erase(I);
+/// 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();
 }
 
-
 /// RecordSource - Register a source file with debug info. Returns an source
 /// ID.
 unsigned MachineDebugInfo::RecordSource(const std::string &Directory,






More information about the llvm-commits mailing list