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

Jim Laskey jlaskey at apple.com
Wed Nov 29 08:56:12 PST 2006



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.102 -> 1.103
---
Log message:

Eliminate unnecessary scopes.

---
Diffs of the changes:  (+27 -21)

 DwarfWriter.cpp |   48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.102 llvm/lib/CodeGen/DwarfWriter.cpp:1.103
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.102	Tue Nov 28 18:39:47 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Nov 29 10:55:57 2006
@@ -1872,7 +1872,8 @@
   /// ConstructScope - Construct the components of a scope.
   ///
   void ConstructScope(DebugScope *ParentScope,
-                                   DIE *ParentDie, CompileUnit *Unit) {
+                      unsigned ParentStartID, unsigned ParentEndID,
+                      DIE *ParentDie, CompileUnit *Unit) {
     // Add variables to scope.
     std::vector<DebugVariable *> &Variables = ParentScope->getVariables();
     for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
@@ -1895,27 +1896,32 @@
       if (StartID == EndID && StartID != 0) continue;
       if (Scope->getScopes().empty() && Scope->getVariables().empty()) continue;
       
-      DIE *ScopeDie = new DIE(DW_TAG_lexical_block);
-      
-      // Add the scope bounds.
-      if (StartID) {
-        AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
-                           DWLabel("loc", StartID));
-      } else {
-        AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
-                           DWLabel("func_begin", SubprogramCount));
-      }
-      if (EndID) {
-        AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
-                           DWLabel("loc", EndID));
+      if (StartID == ParentStartID && EndID == ParentEndID) {
+        // Just add stuff to the parent scope.
+        ConstructScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit);
       } else {
-        AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
-                           DWLabel("func_end", SubprogramCount));
+        DIE *ScopeDie = new DIE(DW_TAG_lexical_block);
+        
+        // Add the scope bounds.
+        if (StartID) {
+          AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
+                             DWLabel("loc", StartID));
+        } else {
+          AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
+                             DWLabel("func_begin", SubprogramCount));
+        }
+        if (EndID) {
+          AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
+                             DWLabel("loc", EndID));
+        } else {
+          AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
+                             DWLabel("func_end", SubprogramCount));
+        }
+                           
+        // Add the scope contents.
+        ConstructScope(Scope, StartID, EndID, ScopeDie, Unit);
+        ParentDie->AddChild(ScopeDie);
       }
-                         
-      // Add the scope contents.
-      ConstructScope(Scope, ScopeDie, Unit);
-      ParentDie->AddChild(ScopeDie);
     }
   }
 
@@ -1943,7 +1949,7 @@
     MachineLocation Location(RI->getFrameRegister(*MF));
     AddAddress(SPDie, DW_AT_frame_base, Location);
 
-    ConstructScope(RootScope, SPDie, Unit);
+    ConstructScope(RootScope, 0, 0, SPDie, Unit);
   }
 
   /// EmitInitial - Emit initial Dwarf declarations.  This is necessary for cc






More information about the llvm-commits mailing list