DebugInfo: Use the scope of the function declaration, if any, to name a function...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 6 Jun 2014 22:29:05 +0000 (22:29 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 6 Jun 2014 22:29:05 +0000 (22:29 +0000)
This ensures that member functions, for example, are entered into
pubnames with their fully qualified name, rather than inside the global
namespace.

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

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.h
test/DebugInfo/X86/dwarf-public-names.ll
test/DebugInfo/dwarf-public-names.ll

index 39bff0d1f7d36d903ce56203496cd4e2f89653e5..433cc3769ed77b3511723d22279b6848251457d8 100644 (file)
@@ -531,8 +531,7 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
   // shouldn't be found by lookup.
   AbsDef = &SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE,
                                  DIDescriptor());
   // shouldn't be found by lookup.
   AbsDef = &SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE,
                                  DIDescriptor());
-  SPCU.applySubprogramAttributes(SP, *AbsDef);
-  SPCU.addGlobalName(SP.getName(), *AbsDef, resolve(SP.getContext()));
+  SPCU.applySubprogramAttributesToDefinition(SP, *AbsDef);
 
   SPCU.addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined);
   createAndAddScopeChildren(SPCU, Scope, *AbsDef);
 
   SPCU.addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined);
   createAndAddScopeChildren(SPCU, Scope, *AbsDef);
@@ -811,8 +810,7 @@ void DwarfDebug::finishSubprogramDefinitions() {
           // inlined versions during codegen.
           D = SPCU->getOrCreateSubprogramDIE(SP);
         // And attach the attributes
           // inlined versions during codegen.
           D = SPCU->getOrCreateSubprogramDIE(SP);
         // And attach the attributes
-        SPCU->applySubprogramAttributes(SP, *D);
-        SPCU->addGlobalName(SP.getName(), *D, resolve(SP.getContext()));
+        SPCU->applySubprogramAttributesToDefinition(SP, *D);
       }
     }
   }
       }
     }
   }
index 33cdcefb71ccc99592a2023aa43732a8f5a970ba..a42897f18f13863155d20e1b277f134bc619a3f1 100644 (file)
@@ -1401,6 +1401,13 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
   return &SPDie;
 }
 
   return &SPDie;
 }
 
+void DwarfUnit::applySubprogramAttributesToDefinition(DISubprogram SP, DIE &SPDie) {
+  DISubprogram SPDecl = SP.getFunctionDeclaration();
+  DIScope Context = resolve(SPDecl ? SPDecl.getContext() : SP.getContext());
+  applySubprogramAttributes(SP, SPDie);
+  addGlobalName(SP.getName(), SPDie, Context);
+}
+
 void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie) {
   DIE *DeclDie = nullptr;
   StringRef DeclLinkageName;
 void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie) {
   DIE *DeclDie = nullptr;
   StringRef DeclLinkageName;
index acb75283530f281b9e909fc33f8402d09d97a65f..71034442b204df9ed7397623bbe62361f2e7f849 100644 (file)
@@ -400,6 +400,7 @@ public:
   DIE *getOrCreateSubprogramDIE(DISubprogram SP);
 
   void applySubprogramAttributes(DISubprogram SP, DIE &SPDie);
   DIE *getOrCreateSubprogramDIE(DISubprogram SP);
 
   void applySubprogramAttributes(DISubprogram SP, DIE &SPDie);
+  void applySubprogramAttributesToDefinition(DISubprogram SP, DIE &SPDie);
 
   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
   /// given DIType.
 
   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
   /// given DIType.
index cbfba0e8055874f29d4109667c287880c950a99b..793971a5f89ffcd0754c54740ec96cebdb89afd4 100644 (file)
 
 ; Check for each name in the output.
 ; LINUX-DAG: "ns"
 
 ; Check for each name in the output.
 ; LINUX-DAG: "ns"
-; FIXME: This should be C::static_member_function
-; LINUX-DAG: "static_member_function"
+; LINUX-DAG: "C::static_member_function"
 ; LINUX-DAG: "global_variable"
 ; LINUX-DAG: "ns::global_namespace_variable"
 ; LINUX-DAG: "ns::global_namespace_function"
 ; LINUX-DAG: "global_function"
 ; LINUX-DAG: "C::static_member_variable"
 ; LINUX-DAG: "global_variable"
 ; LINUX-DAG: "ns::global_namespace_variable"
 ; LINUX-DAG: "ns::global_namespace_function"
 ; LINUX-DAG: "global_function"
 ; LINUX-DAG: "C::static_member_variable"
-; FIXME: This should be C::member_function
-; LINUX-DAG: "member_function"
+; LINUX-DAG: "C::member_function"
 
 %struct.C = type { i8 }
 
 
 %struct.C = type { i8 }
 
index bedfa183554971bcaa1f99dbd20758027008f5b7..72189641e3aa03ef68851f44b9fd09806de8c5de 100644 (file)
 
 ; Check for each name in the output.
 ; CHECK-DAG: "ns"
 
 ; Check for each name in the output.
 ; CHECK-DAG: "ns"
-; FIXME: This should be C::static_member_function
-; CHECK-DAG: "static_member_function"
+; CHECK-DAG: "C::static_member_function"
 ; CHECK-DAG: "global_variable"
 ; CHECK-DAG: "ns::global_namespace_variable"
 ; CHECK-DAG: "ns::global_namespace_function"
 ; CHECK-DAG: "global_function"
 ; CHECK-DAG: "C::static_member_variable"
 ; CHECK-DAG: "global_variable"
 ; CHECK-DAG: "ns::global_namespace_variable"
 ; CHECK-DAG: "ns::global_namespace_function"
 ; CHECK-DAG: "global_function"
 ; CHECK-DAG: "C::static_member_variable"
-; FIXME: This should be C::member_function
-; CHECK-DAG: "member_function"
+; CHECK-DAG: "C::member_function"
 
 %struct.C = type { i8 }
 
 
 %struct.C = type { i8 }