[llvm-branch-commits] [llvm-branch] r70967 - in /llvm/branches/Apple/Dib/lib: Analysis/DebugInfo.cpp CodeGen/AsmPrinter/DwarfWriter.cpp

Bill Wendling isanbard at gmail.com
Mon May 4 22:05:43 PDT 2009


Author: void
Date: Tue May  5 00:05:43 2009
New Revision: 70967

URL: http://llvm.org/viewvc/llvm-project?rev=70967&view=rev
Log:
--- Merging r70964 into '.':
U    lib/Analysis/DebugInfo.cpp
U    lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Do not require variable debug info nodes to have a compile unit.
For implicit decls like "self" and "_cmd" in ObjC, these decls
should not have a location.

Modified:
    llvm/branches/Apple/Dib/lib/Analysis/DebugInfo.cpp
    llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Modified: llvm/branches/Apple/Dib/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Analysis/DebugInfo.cpp?rev=70967&r1=70966&r2=70967&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Analysis/DebugInfo.cpp Tue May  5 00:05:43 2009
@@ -295,7 +295,7 @@
     return false;
 
   DICompileUnit CU = getCompileUnit();
-  if (!CU.Verify()) 
+  if (!CU.isNull() && !CU.Verify()) 
     return false;
 
   DIType Ty = getType();
@@ -320,7 +320,6 @@
   if (!Ty.Verify())
     return false;
 
-
   return true;
 }
 

Modified: llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=70967&r1=70966&r2=70967&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Tue May  5 00:05:43 2009
@@ -1524,11 +1524,13 @@
   /// AddSourceLine - Add location information to specified debug information
   /// entry.
   void AddSourceLine(DIE *Die, const DIVariable *V) {
-    unsigned FileID = 0;
+    // If there is no compile unit specified, don't add a line #.
+    if (V->getCompileUnit().isNull())
+      return;
+
     unsigned Line = V->getLineNumber();
-    CompileUnit *Unit = FindCompileUnit(V->getCompileUnit());
-    FileID = Unit->getID();
-    assert (FileID && "Invalid file id");
+    unsigned FileID = FindCompileUnit(V->getCompileUnit()).getID();
+    assert(FileID && "Invalid file id");
     AddUInt(Die, DW_AT_decl_file, 0, FileID);
     AddUInt(Die, DW_AT_decl_line, 0, Line);
   }
@@ -1536,24 +1538,25 @@
   /// AddSourceLine - Add location information to specified debug information
   /// entry.
   void AddSourceLine(DIE *Die, const DIGlobal *G) {
-    unsigned FileID = 0;
+    // If there is no compile unit specified, don't add a line #.
+    if (G->getCompileUnit().isNull())
+      return;
     unsigned Line = G->getLineNumber();
-    CompileUnit *Unit = FindCompileUnit(G->getCompileUnit());
-    FileID = Unit->getID();
-    assert (FileID && "Invalid file id");
+    unsigned FileID = FindCompileUnit(G->getCompileUnit()).getID();
+    assert(FileID && "Invalid file id");
     AddUInt(Die, DW_AT_decl_file, 0, FileID);
     AddUInt(Die, DW_AT_decl_line, 0, Line);
   }
 
   void AddSourceLine(DIE *Die, const DIType *Ty) {
-    unsigned FileID = 0;
-    unsigned Line = Ty->getLineNumber();
+    // If there is no compile unit specified, don't add a line #.
     DICompileUnit CU = Ty->getCompileUnit();
     if (CU.isNull())
       return;
-    CompileUnit *Unit = FindCompileUnit(CU);
-    FileID = Unit->getID();
-    assert (FileID && "Invalid file id");
+    
+    unsigned Line = Ty->getLineNumber();
+    unsigned FileID = FindCompileUnit(CU).getID();
+    assert(FileID && "Invalid file id");
     AddUInt(Die, DW_AT_decl_file, 0, FileID);
     AddUInt(Die, DW_AT_decl_line, 0, Line);
   }
@@ -1953,10 +1956,11 @@
 
   /// FindCompileUnit - Get the compile unit for the given descriptor. 
   ///
-  CompileUnit *FindCompileUnit(DICompileUnit Unit) {
-    CompileUnit *DW_Unit = CompileUnitMap[Unit.getGV()];
-    assert(DW_Unit && "Missing compile unit.");
-    return DW_Unit;
+  CompileUnit &FindCompileUnit(DICompileUnit Unit) const {
+    DenseMap<Value *, CompileUnit *>::const_iterator I = 
+      CompileUnitMap.find(Unit.getGV());
+    assert(I != CompileUnitMap.end() && "Missing compile unit.");
+    return *I->second;
   }
 
   /// NewDbgScopeVariable - Create a new scope variable.
@@ -2118,7 +2122,7 @@
     // Get the compile unit context.
     CompileUnit *Unit = MainCU;
     if (!Unit)
-      Unit = FindCompileUnit(SPD.getCompileUnit());
+      Unit = &FindCompileUnit(SPD.getCompileUnit());
 
     // Get the subprogram die.
     DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());
@@ -2984,7 +2988,7 @@
     DIGlobalVariable DI_GV(GV);
     CompileUnit *DW_Unit = MainCU;
     if (!DW_Unit)
-      DW_Unit = FindCompileUnit(DI_GV.getCompileUnit());
+      DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit());
 
     // Check for pre-existence.
     DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV());
@@ -3040,7 +3044,7 @@
     DISubprogram SP(GV);
     CompileUnit *Unit = MainCU;
     if (!Unit)
-      Unit = FindCompileUnit(SP.getCompileUnit());
+      Unit = &FindCompileUnit(SP.getCompileUnit());
 
     // Check for pre-existence.
     DIE *&Slot = Unit->getDieMapSlotFor(GV);





More information about the llvm-branch-commits mailing list