[llvm-branch-commits] [llvm-gcc-branch] r90472 - in /llvm-gcc-4.2/branches/Apple/Zoidberg/gcc: llvm-debug.cpp llvm-debug.h

Devang Patel dpatel at apple.com
Thu Dec 3 11:02:01 PST 2009


Author: dpatel
Date: Thu Dec  3 13:02:01 2009
New Revision: 90472

URL: http://llvm.org/viewvc/llvm-project?rev=90472&view=rev
Log:
Merge debug info improvements from trunk.

$ svn merge -c 90284 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r90284 into '.':
U    gcc/llvm-debug.cpp
U    gcc/llvm-debug.h


Modified:
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp?rev=90472&r1=90471&r2=90472&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp Thu Dec  3 13:02:01 2009
@@ -232,6 +232,22 @@
 /// "llvm.dbg.func.start."
 void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
                                   BasicBlock *CurBB) {
+
+  DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
+
+  std::map<tree_node *, WeakVH >::iterator I = SPCache.find(FnDecl);
+  if (I != SPCache.end()) {
+    DISubprogram SPDecl(cast<MDNode>(I->second));
+    DISubprogram SP = 
+      DebugFactory.CreateSubprogramDefinition(SPDecl);
+    SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+
+    // Push function on region stack.
+    RegionStack.push_back(WeakVH(SP.getNode()));
+    RegionMap[FnDecl] = WeakVH(SP.getNode());
+    return;
+  } 
+
   // Gather location information.
   expanded_location Loc = GetNodeLocation(FnDecl, false);
   StringRef LinkageName = getLinkageName(FnDecl);
@@ -246,10 +262,12 @@
                                   lang_hooks.dwarf_name(FnDecl, 0),
                                   LinkageName,
                                   getOrCreateCompileUnit(Loc.file), lineno,
-                                  getOrCreateType(TREE_TYPE(FnDecl)),
+                                  FNType,
                                   Fn->hasInternalLinkage(),
                                   true /*definition*/);
 
+  SPCache[FnDecl] = WeakVH(SP.getNode());
+
   // Push function on region stack.
   RegionStack.push_back(WeakVH(SP.getNode()));
   RegionMap[FnDecl] = WeakVH(SP.getNode());
@@ -766,18 +784,23 @@
     // In C++, TEMPLATE_DECLs are marked Ignored, and should be.
     if (DECL_P (Member) && DECL_IGNORED_P (Member)) continue;
 
-    // Get the location of the member.
-    expanded_location MemLoc = GetNodeLocation(Member, false);
-    
-    const char *MemberName = lang_hooks.dwarf_name(Member, 0);        
-    StringRef LinkageName = getLinkageName(Member);
-    DIType SPTy = getOrCreateType(TREE_TYPE(Member));
-    DISubprogram SP = 
-      DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
-                                    LinkageName, 
-                                    getOrCreateCompileUnit(MemLoc.file),
-                                    MemLoc.line, SPTy, false, false);
-    EltTys.push_back(SP);
+    std::map<tree_node *, WeakVH >::iterator I = SPCache.find(Member);
+    if (I != SPCache.end())
+      EltTys.push_back(DISubprogram(cast<MDNode>(I->second)));
+    else {
+      // Get the location of the member.
+      expanded_location MemLoc = GetNodeLocation(Member, false);
+      const char *MemberName = lang_hooks.dwarf_name(Member, 0);        
+      StringRef LinkageName = getLinkageName(Member);
+      DIType SPTy = getOrCreateType(TREE_TYPE(Member));
+      DISubprogram SP = 
+        DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
+                                      LinkageName, 
+                                      getOrCreateCompileUnit(MemLoc.file),
+                                      MemLoc.line, SPTy, false, false);
+      EltTys.push_back(SP);
+      SPCache[Member] = WeakVH(SP.getNode());
+    }
   }
   
   llvm::DIArray Elements =

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h?rev=90472&r1=90471&r2=90472&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h Thu Dec  3 13:02:01 2009
@@ -65,6 +65,9 @@
   std::map<tree_node *, WeakVH > TypeCache;
                                         // Cache of previously constructed 
                                         // Types.
+  std::map<tree_node *, WeakVH > SPCache;
+                                        // Cache of previously constructed 
+                                        // Subprograms.
   SmallVector<WeakVH, 4> RegionStack;
                                         // Stack to track declarative scopes.
   





More information about the llvm-branch-commits mailing list