[llvm-commits] [dragonegg] r97387 - /dragonegg/trunk/llvm-debug.cpp

Duncan Sands baldrick at free.fr
Sun Feb 28 05:06:15 PST 2010


Author: baldrick
Date: Sun Feb 28 07:06:15 2010
New Revision: 97387

URL: http://llvm.org/viewvc/llvm-project?rev=97387&view=rev
Log:
Port commit 95317 (dpatel) from llvm-gcc:
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:
    dragonegg/trunk/llvm-debug.cpp

Modified: dragonegg/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=97387&r1=97386&r2=97387&view=diff
==============================================================================
--- dragonegg/trunk/llvm-debug.cpp (original)
+++ dragonegg/trunk/llvm-debug.cpp Sun Feb 28 07:06:15 2010
@@ -266,6 +266,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);
@@ -283,20 +310,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