[llvm-commits] [dragonegg] r92475 - in /dragonegg/trunk: llvm-debug.cpp llvm-debug.h

Duncan Sands baldrick at free.fr
Mon Jan 4 03:06:08 PST 2010


Author: baldrick
Date: Mon Jan  4 05:06:07 2010
New Revision: 92475

URL: http://llvm.org/viewvc/llvm-project?rev=92475&view=rev
Log:
Port commit 90256 (dpatel) from llvm-gcc.

Modified:
    dragonegg/trunk/llvm-debug.cpp
    dragonegg/trunk/llvm-debug.h

Modified: dragonegg/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=92475&r1=92474&r2=92475&view=diff

==============================================================================
--- dragonegg/trunk/llvm-debug.cpp (original)
+++ dragonegg/trunk/llvm-debug.cpp Mon Jan  4 05:06:07 2010
@@ -244,8 +244,8 @@
                                   true /*definition*/);
 
   // Push function on region stack.
-  RegionStack.push_back(SP);
-  RegionMap[FnDecl] = SP;
+  RegionStack.push_back(WeakVH(SP.getNode()));
+  RegionMap[FnDecl] = WeakVH(SP.getNode());
 }
 
   /// findRegion - Find tree_node N's region.
@@ -253,9 +253,10 @@
   if (Node == NULL_TREE)
     return getOrCreateCompileUnit(main_input_filename);
 
-  std::map<tree_node *, DIDescriptor>::iterator I = RegionMap.find(Node);
+  std::map<tree_node *, WeakVH>::iterator I = RegionMap.find(Node);
   if (I != RegionMap.end())
-    return I->second;
+    if (MDNode *R = dyn_cast_or_null<MDNode>(I->second))
+      return DIDescriptor(R);
 
   if (TYPE_P (Node)) {
     if (TYPE_CONTEXT (Node))
@@ -310,20 +311,21 @@
   expanded_location Loc = GetNodeLocation(decl, false);
 
   // Construct variable.
+  DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
   llvm::DIVariable D =
-    DebugFactory.CreateVariable(Tag, RegionStack.back(), Name, 
-                                getOrCreateCompileUnit(Loc.file),
+    DebugFactory.CreateVariable(Tag, VarScope,
+                                Name, getOrCreateCompileUnit(Loc.file),
                                 Loc.line, getOrCreateType(type));
 
   // Insert an llvm.dbg.declare into the current block.
   Instruction *Call = DebugFactory.InsertDeclare(AI, D, 
                                                  Builder.GetInsertBlock());
 
-  llvm::DIDescriptor DR = RegionStack.back();
-  llvm::DIScope DS = llvm::DIScope(DR.getNode());
+//  llvm::DIDescriptor DR = RegionStack.back();
+//  llvm::DIScope DS = llvm::DIScope(DR.getNode());
   llvm::DILocation DO(NULL);
   llvm::DILocation DL = 
-    DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO);
+    DebugFactory.CreateLocation(CurLineNo, 0 /* column */, VarScope, DO);
   Builder.SetDebugLocation(Call, DL.getNode());
 }
 
@@ -345,7 +347,7 @@
 
     if (RegionStack.empty())
       return;
-    llvm::DIDescriptor DR = RegionStack.back();
+    llvm::DIDescriptor DR(cast<MDNode>(RegionStack.back()));
     llvm::DIScope DS = llvm::DIScope(DR.getNode());
     llvm::DILocation DO(NULL);
     llvm::DILocation DL = 
@@ -641,6 +643,10 @@
   // Insert into the TypeCache so that recursive uses will find it.
   llvm::TrackingVH<llvm::MDNode> FwdDeclNode = FwdDecl.getNode();
   TypeCache[type] =  WeakVH(FwdDecl.getNode());
+
+  // Push the struct on region stack.
+  RegionStack.push_back(WeakVH(FwdDecl.getNode()));
+  RegionMap[type] = WeakVH(FwdDecl.getNode());
   
   // Convert all the elements.
   llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
@@ -676,7 +682,9 @@
         continue;
       
       /* Ignore nameless fields.  */
-      if (DECL_NAME (Member) == NULL_TREE)
+      if (DECL_NAME (Member) == NULL_TREE
+          && !(TREE_CODE (TREE_TYPE (Member)) == UNION_TYPE
+               || TREE_CODE (TREE_TYPE (Member)) == RECORD_TYPE))
         continue;
       
       // Get the location of the member.
@@ -731,6 +739,11 @@
   llvm::DIArray Elements =
     DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
 
+  RegionStack.pop_back();
+  std::map<tree_node *, WeakVH>::iterator RI = RegionMap.find(type);
+  if (RI != RegionMap.end())
+    RegionMap.erase(RI);
+
   llvm::DICompositeType RealDecl =
     DebugFactory.CreateCompositeType(Tag, findRegion(type),
                                      GetNodeName(type),
@@ -743,6 +756,7 @@
   // Now that we have a real decl for the struct, replace anything using the
   // old decl with the new one.  This will recursively update the debug info.
   llvm::DIDerivedType(FwdDeclNode).replaceAllUsesWith(RealDecl);
+
   return RealDecl;
 }
 

Modified: dragonegg/trunk/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.h?rev=92475&r1=92474&r2=92475&view=diff

==============================================================================
--- dragonegg/trunk/llvm-debug.h (original)
+++ dragonegg/trunk/llvm-debug.h Mon Jan  4 05:06:07 2010
@@ -61,10 +61,10 @@
   std::map<tree_node *, WeakVH > TypeCache;
                                         // Cache of previously constructed 
                                         // Types.
-  std::vector<DIDescriptor> RegionStack;
+  SmallVector<WeakVH, 4> RegionStack;
                                         // Stack to track declarative scopes.
   
-  std::map<tree_node *, DIDescriptor> RegionMap;
+  std::map<tree_node *, WeakVH> RegionMap;
 public:
   DebugInfo(Module *m);
 





More information about the llvm-commits mailing list