From: Eric Christopher Date: Wed, 16 Oct 2013 01:37:49 +0000 (+0000) Subject: Fix a pair of bugs in the emission of pubname tables: X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a486f55569c584d00cfdde43a8755d68cdb68c4f;p=oota-llvm.git Fix a pair of bugs in the emission of pubname tables: 1) Make sure we emit static member variables by checking at the end of createGlobalVariableDIE rather than piecemeal in the function. (As a note, createGlobalVariableDIE needs rewriting.) 2) Make sure we use the definition rather than declaration DIE for two things: a) determining linkage for gnu pubnames, and b) as the address of the DIE for global variables. (As a note, createGlobalVariableDIE really needs rewriting.) Adjust the testcase to make sure we're checking the correct DIEs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192761 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 732db20943e..b6ea6a4166d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1472,10 +1472,8 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { addType(VariableDIE, GTy); // Add scoping info. - if (!GV.isLocalToUnit()) { + if (!GV.isLocalToUnit()) addFlag(VariableDIE, dwarf::DW_AT_external); - addGlobalName(GV.getName(), VariableDIE); - } // Add line number info. addSourceLine(VariableDIE, GV); @@ -1568,6 +1566,10 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { if (GV.getLinkageName() != "" && GV.getName() != GV.getLinkageName()) addAccelName(GV.getLinkageName(), AddrDIE); } + + if (!GV.isLocalToUnit()) + addGlobalName(GV.getName(), + VariableSpecDIE ? VariableSpecDIE : VariableDIE); } /// constructSubrangeDIE - Construct subrange DIE from DISubrange. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index cee97c86b75..b7463c51682 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2356,9 +2356,17 @@ void DwarfDebug::emitAccelTypes() { /// computeIndexValue - Compute the gdb index value for the DIE and CU. static dwarf::PubIndexEntryDescriptor computeIndexValue(CompileUnit *CU, DIE *Die) { - dwarf::GDBIndexEntryLinkage Linkage = - Die->findAttribute(dwarf::DW_AT_external) ? dwarf::GIEL_EXTERNAL - : dwarf::GIEL_STATIC; + dwarf::GDBIndexEntryLinkage Linkage = dwarf::GIEL_STATIC; + + // We could have a specification DIE that has our most of our knowledge, + // look for that now. + DIEValue *SpecVal = Die->findAttribute(dwarf::DW_AT_specification); + if (SpecVal) { + DIE *SpecDIE = cast(SpecVal)->getEntry(); + if (SpecDIE->findAttribute(dwarf::DW_AT_external)) + Linkage = dwarf::GIEL_EXTERNAL; + } else if (Die->findAttribute(dwarf::DW_AT_external)) + Linkage = dwarf::GIEL_EXTERNAL; switch (Die->getTag()) { case dwarf::DW_TAG_class_type: diff --git a/test/DebugInfo/X86/gnu-public-names.ll b/test/DebugInfo/X86/gnu-public-names.ll index 2989dfe281c..af58558db6a 100644 --- a/test/DebugInfo/X86/gnu-public-names.ll +++ b/test/DebugInfo/X86/gnu-public-names.ll @@ -35,7 +35,7 @@ ; ASM: .section .debug_gnu_pubnames ; ASM: .byte 32 # Kind: VARIABLE, EXTERNAL -; ASM-NEXT: .asciz "global_namespace_variable" # External Name +; ASM-NEXT: .asciz "global_namespace_variable" # External Name ; ASM: .section .debug_gnu_pubtypes ; ASM: .byte 16 # Kind: TYPE, EXTERNAL @@ -44,44 +44,67 @@ ; CHECK: .debug_info contents: ; CHECK: DW_AT_GNU_pubnames [DW_FORM_sec_offset] (0x00000000) ; CHECK: DW_AT_GNU_pubtypes [DW_FORM_sec_offset] (0x00000000) -; CHECK: 0x0000002e: DW_TAG_base_type + +; CHECK: [[INT:[0-9a-f]+]]: DW_TAG_base_type ; CHECK-NEXT: DW_AT_name {{.*}} "int" -; CHECK: 0x0000003a: DW_TAG_structure_type + +; CHECK: [[C:[0-9a-f]+]]: DW_TAG_structure_type ; CHECK-NEXT: DW_AT_name {{.*}} "C" -; CHECK: 0x0000004e: DW_TAG_subprogram + +; CHECK: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member +; CHECK-NEXT: DW_AT_name {{.*}} "static_member_variable" + +; CHECK: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_name {{.*}} "member_function" -; CHECK: 0x00000060: DW_TAG_subprogram + +; CHECK: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_name {{.*}} "static_member_function" -; CHECK: 0x00000084: DW_TAG_variable + +; CHECK: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable +; CHECK-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]] + +; CHECK: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}} "global_variable" -; CHECK: 0x000000a0: DW_TAG_variable + +; CHECK: [[NS:[0-9a-f]+]]: DW_TAG_namespace +; CHECK-NEXT: DW_AT_name {{.*}} "ns" + +; CHECK: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}} "global_namespace_variable" -; CHECK: 0x000000af: DW_TAG_subprogram + +; CHECK: [[GLOB_NS_FUNC:[0-9a-f]+]]: DW_TAG_subprogram ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_name {{.*}} "global_namespace_function" -; CHECK: 0x000000ca: DW_TAG_subprogram -; CHECK-NEXT: DW_AT_specification {{.*}}0x0000004e} -; CHECK: 0x000000f2: DW_TAG_subprogram -; CHECK-NEXT: DW_AT_specification {{.*}}0x00000060} -; CHECK: 0x00000109: DW_TAG_subprogram + +; CHECK: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable +; CHECK-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]] + +; CHECK: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; CHECK-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]] + +; CHECK: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram +; CHECK-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]] + +; CHECK: [[GLOBAL_FUNC:[0-9a-f]+]]: DW_TAG_subprogram ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_name {{.*}} "global_function" ; CHECK-LABEL: .debug_gnu_pubnames contents: -; CHECK-NEXT: Length: 175 +; CHECK-NEXT: Length: 203 ; CHECK-NEXT: Version: 2 ; CHECK-NEXT: Offset in .debug_info: 0 ; CHECK-NEXT: Size: 327 ; CHECK-NEXT: Offset Linkage Kind Name -; CHECK-DAG: 0x00000099 EXTERNAL TYPE "ns" -; CHECK-DAG: 0x000000a0 EXTERNAL VARIABLE "global_namespace_variable" -; CHECK-DAG: 0x000000af EXTERNAL FUNCTION "global_namespace_function" -; CHECK-DAG: 0x000000f2 STATIC FUNCTION "static_member_function" -; CHECK-DAG: 0x00000084 EXTERNAL VARIABLE "global_variable" -; CHECK-DAG: 0x00000109 EXTERNAL FUNCTION "global_function" -; CHECK-DAG: 0x000000ca STATIC FUNCTION "member_function" +; CHECK-DAG: [[NS]] EXTERNAL TYPE "ns" +; CHECK-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "global_namespace_variable" +; CHECK-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "global_namespace_function" +; CHECK-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "static_member_variable" +; CHECK-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "static_member_function" +; CHECK-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable" +; CHECK-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function" +; CHECK-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "member_function" ; CHECK-LABEL: debug_gnu_pubtypes contents: ; CHECK-NEXT: Length: @@ -89,8 +112,8 @@ ; CHECK-NEXT: Offset in .debug_info: ; CHECK-NEXT: Size: ; CHECK-NEXT: Offset Linkage Kind Name -; CHECK-DAG: 0x0000003a EXTERNAL TYPE "C" -; CHECK-DAG: 0x0000002e STATIC TYPE "int" +; CHECK-DAG: [[C]] EXTERNAL TYPE "C" +; CHECK-DAG: [[INT]] STATIC TYPE "int" %struct.C = type { i8 }