Debug Info: Move isSubprogramContext from DebugInfo to DwarfDebug.
authorManman Ren <manman.ren@gmail.com>
Mon, 9 Sep 2013 19:05:21 +0000 (19:05 +0000)
committerManman Ren <manman.ren@gmail.com>
Mon, 9 Sep 2013 19:05:21 +0000 (19:05 +0000)
This helper function needs the type identifier map when we switch
DIType::getContext to return DIScopeRef instead of DIScope.

Since isSubprogramContext is used by DwarfDebug only, We move it to DwarfDebug
to have easy access to the map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190325 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo.h
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/IR/DebugInfo.cpp

index e8cc79381fa78b4483cfb4ee381fe512102b0b6d..df9c0c782be88692df494c3ab3919962cb27deee 100644 (file)
@@ -729,10 +729,6 @@ namespace llvm {
   /// getDICompositeType - Find underlying composite type.
   DICompositeType getDICompositeType(DIType T);
 
-  /// isSubprogramContext - Return true if Context is either a subprogram
-  /// or another context nested inside a subprogram.
-  bool isSubprogramContext(const MDNode *Context);
-
   /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
   /// to hold function specific information.
   NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
index 15bfb7e5431f00c7b541a4b0d81bd1983d5221ca..6ec68834cf21d7f44d030a61f1b56c34ab7792d9 100644 (file)
@@ -1435,7 +1435,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
     // Do not create specification DIE if context is either compile unit
     // or a subprogram.
     if (GVContext && GV.isDefinition() && !GVContext.isCompileUnit() &&
-        !GVContext.isFile() && !isSubprogramContext(GVContext)) {
+        !GVContext.isFile() && !DD->isSubprogramContext(GVContext)) {
       // Create specification DIE.
       VariableSpecDIE = new DIE(dwarf::DW_TAG_variable);
       addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification,
index 885d4ba5cdc516f2e3b740f124864af13e68da0d..bdcb813e227b2eff0245f1795b81d6b4cfb32948 100644 (file)
@@ -332,6 +332,19 @@ static void addSubprogramNames(CompileUnit *TheCU, DISubprogram SP,
   }
 }
 
+/// isSubprogramContext - Return true if Context is either a subprogram
+/// or another context nested inside a subprogram.
+bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
+  if (!Context)
+    return false;
+  DIDescriptor D(Context);
+  if (D.isSubprogram())
+    return true;
+  if (D.isType())
+    return isSubprogramContext(DIType(Context).getContext());
+  return false;
+}
+
 // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
 // and DW_AT_high_pc attributes. If there are global variables in this
 // scope then create and insert DIEs for these variables.
index 5ccaf0fa484960d890188099f1d7d4993617bb71..f8c27d950ecc828d4c5e4aa93e470e99933a3c3b 100644 (file)
@@ -686,6 +686,10 @@ public:
   /// Find the MDNode for the given scope reference.
   DIScope resolve(DIScopeRef SRef) const;
 
+  /// isSubprogramContext - Return true if Context is either a subprogram
+  /// or another context nested inside a subprogram.
+  bool isSubprogramContext(const MDNode *Context);
+
 };
 } // End of namespace llvm
 
index 7f56f2fb1f9251bded0a54f26980e165a2272076..4546098bc3d0feafac016f4db59b5c413983f77e 100644 (file)
@@ -942,19 +942,6 @@ DICompositeType llvm::getDICompositeType(DIType T) {
   return DICompositeType();
 }
 
-/// isSubprogramContext - Return true if Context is either a subprogram
-/// or another context nested inside a subprogram.
-bool llvm::isSubprogramContext(const MDNode *Context) {
-  if (!Context)
-    return false;
-  DIDescriptor D(Context);
-  if (D.isSubprogram())
-    return true;
-  if (D.isType())
-    return isSubprogramContext(DIType(Context).getContext());
-  return false;
-}
-
 /// Update DITypeIdentifierMap by going through retained types of each CU.
 DITypeIdentifierMap llvm::generateDITypeIdentifierMap(
                               const NamedMDNode *CU_Nodes) {