[llvm-commits] [llvm-gcc-4.2] r95317 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Devang Patel dpatel at apple.com
Thu Feb 4 10:21:55 PST 2010


Author: dpatel
Date: Thu Feb  4 12:21:54 2010
New Revision: 95317

URL: http://llvm.org/viewvc/llvm-project?rev=95317&view=rev
Log:
Creation of context description for a subprogram may indirectly create description for the subprogram itself (e.g. c++ methods), so check the SPCache one more time after creating context descriptor.


Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=95317&r1=95316&r2=95317&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Feb  4 12:21:54 2010
@@ -310,6 +310,33 @@
     return;
   } 
 
+  bool ArtificialFnWithAbstractOrigin = false;
+  // If this artificial function has abstract origin then put this function
+  // at module scope. The abstract copy will be placed in appropriate region.
+  if (DECL_ARTIFICIAL (FnDecl)
+      && DECL_ABSTRACT_ORIGIN (FnDecl)
+      && DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl)
+    ArtificialFnWithAbstractOrigin = true;
+
+  DIDescriptor SPContext = ArtificialFnWithAbstractOrigin ?
+    getOrCreateCompileUnit(main_input_filename) :
+    findRegion (DECL_CONTEXT(FnDecl));
+
+  // Creating context may have triggered creation of this SP descriptor. So
+  // check the cache again.
+  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);
@@ -328,20 +355,10 @@
     ContainingType = getOrCreateType(DECL_CONTEXT (FnDecl));
   }
 
-  bool ArtificialFnWithAbstractOrigin = false;
-  // If this artificial function has abstract origin then put this function
-  // at module scope. The abstract copy will be placed in appropriate region.
-  if (DECL_ARTIFICIAL (FnDecl)
-      && DECL_ABSTRACT_ORIGIN (FnDecl)
-      && DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl)
-    ArtificialFnWithAbstractOrigin = true;
-
   StringRef FnName = getFunctionName(FnDecl);
 
   DISubprogram SP = 
-    DebugFactory.CreateSubprogram(ArtificialFnWithAbstractOrigin ?
-                                  getOrCreateCompileUnit(main_input_filename) :
-                                  findRegion (DECL_CONTEXT(FnDecl)),
+    DebugFactory.CreateSubprogram(SPContext,
                                   FnName, FnName,
                                   LinkageName,
                                   getOrCreateCompileUnit(Loc.file), lineno,





More information about the llvm-commits mailing list