[llvm] r209311 - DebugInfo: Simplify subprogram declaration creation/references and accidentally refix PR11300.
David Blaikie
dblaikie at gmail.com
Wed May 21 11:04:34 PDT 2014
Author: dblaikie
Date: Wed May 21 13:04:33 2014
New Revision: 209311
URL: http://llvm.org/viewvc/llvm-project?rev=209311&view=rev
Log:
DebugInfo: Simplify subprogram declaration creation/references and accidentally refix PR11300.
Also simplifies the linkage name handling a little too.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll
llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll
llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll
llvm/trunk/test/DebugInfo/X86/pr11300.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=209311&r1=209310&r2=209311&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed May 21 13:04:33 2014
@@ -1384,40 +1384,37 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE
if (DIE *SPDie = getDIE(SP))
return SPDie;
- DISubprogram SPDecl = SP.getFunctionDeclaration();
- if (SPDecl.isSubprogram())
+ DIE *DeclDie = nullptr;
+ StringRef DeclLinkageName;
+ if (DISubprogram SPDecl = SP.getFunctionDeclaration()) {
// Add subprogram definitions to the CU die directly.
ContextDIE = &getUnitDie();
+ DeclDie = getOrCreateSubprogramDIE(SPDecl);
+ DeclLinkageName = SPDecl.getLinkageName();
+ }
// DW_TAG_inlined_subroutine may refer to this DIE.
DIE &SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP);
- DIE *DeclDie = nullptr;
- if (SPDecl.isSubprogram())
- DeclDie = getOrCreateSubprogramDIE(SPDecl);
// Add function template parameters.
addTemplateParams(SPDie, SP.getTemplateParams());
- if (DeclDie)
- // Refer function declaration directly.
- addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
-
// Add the linkage name if we have one and it isn't in the Decl.
StringRef LinkageName = SP.getLinkageName();
- if (!LinkageName.empty()) {
- if (SPDecl.isSubprogram() && !SPDecl.getLinkageName().empty())
- assert(SPDecl.getLinkageName() == SP.getLinkageName() &&
- "decl has a linkage name and it is different");
- else
- addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
- GlobalValue::getRealLinkageName(LinkageName));
- }
-
- // If this DIE is going to refer declaration info using AT_specification
- // then there is no need to add other attributes.
- if (DeclDie)
+ assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
+ LinkageName == DeclLinkageName) &&
+ "decl has a linkage name and it is different");
+ if (!LinkageName.empty() && DeclLinkageName.empty())
+ addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
+ GlobalValue::getRealLinkageName(LinkageName));
+
+ if (DeclDie) {
+ // Refer to the function declaration where all the other attributes will be
+ // found.
+ addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
return &SPDie;
+ }
// Constructors and operators for anonymous aggregates do not have names.
if (!SP.getName().empty())
Modified: llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll?rev=209311&r1=209310&r2=209311&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll Wed May 21 13:04:33 2014
@@ -18,12 +18,12 @@
; Test that we do emit a linkage name for a specific instance of it.
; CHECK: DW_TAG_subprogram
-; CHECK: [[A:.*]]: DW_TAG_subprogram
+; CHECK: [[A_DTOR:.*]]: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}} "~A"
; CHECK-NOT: DW_AT_MIPS_linkage_name
; CHECK: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_specification {{.*}}[[A]]
; CHECK-NEXT: DW_AT_MIPS_linkage_name {{.*}} "_ZN1AD2Ev"
+; CHECK-NEXT: DW_AT_specification {{.*}}[[A_DTOR]]
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
Modified: llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll?rev=209311&r1=209310&r2=209311&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll Wed May 21 13:04:33 2014
@@ -3,10 +3,10 @@
; test that the DW_AT_specification is a back edge in the file.
-; CHECK: DW_TAG_subprogram [{{[0-9]+}}] *
-; CHECK: DW_AT_specification [DW_FORM_ref4] (cu + 0x[[OFFSET:[0-9a-f]*]] => {0x0000[[OFFSET]]})
-; CHECK: 0x0000[[OFFSET]]: DW_TAG_subprogram [{{[0-9]+}}] *
-; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "bar")
+; CHECK: [[BAR_DECL:0x[0-9a-f]*]]: DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_MIPS_linkage_name {{.*}} "_ZN3foo3barEv"
+; CHECK: DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_specification {{.*}} {[[BAR_DECL]]}
@_ZZN3foo3barEvE1x = constant i32 0, align 4
Modified: llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll?rev=209311&r1=209310&r2=209311&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll Wed May 21 13:04:33 2014
@@ -11,8 +11,12 @@
; CHECK: DW_TAG_subprogram
; CHECK: [[ASSIGN_DECL:0x........]]: DW_TAG_subprogram
+; CHECK: DW_TAG_class_type
+; CHECK: [[RELEASE_DECL:0x........]]: DW_TAG_subprogram
+; CHECK: [[DTOR_DECL:0x........]]: DW_TAG_subprogram
+
; CHECK: [[RELEASE:0x........]]: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_specification {{.*}} {[[RELEASE_DECL:0x........]]}
+; CHECK: DW_AT_specification {{.*}} {[[RELEASE_DECL]]}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: NULL
; CHECK-NOT: DW_TAG
@@ -30,19 +34,14 @@
; CHECK: DW_TAG_inlined_subroutine
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[D2_ABS:0x........]]}
-; CHECK: DW_TAG_class_type
-; CHECK: [[RELEASE_DECL]]: DW_TAG_subprogram
-; CHECK: [[DTOR_DECL:0x........]]: DW_TAG_subprogram
-
-
; CHECK: [[D1_ABS]]: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_specification {{.*}} {[[DTOR_DECL]]}
; CHECK-NEXT: DW_AT_{{.*}}linkage_name
+; CHECK-NEXT: DW_AT_specification {{.*}} {[[DTOR_DECL]]}
; CHECK-NEXT: DW_AT_inline
; CHECK-NOT: DW_AT_inline
; CHECK: [[D2_ABS]]: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_specification {{.*}} {[[DTOR_DECL]]}
; CHECK-NEXT: DW_AT_{{.*}}linkage_name
+; CHECK-NEXT: DW_AT_specification {{.*}} {[[DTOR_DECL]]}
; CHECK-NEXT: DW_AT_inline
; CHECK-NOT: DW_AT_inline
; CHECK: DW_TAG
Modified: llvm/trunk/test/DebugInfo/X86/pr11300.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pr11300.ll?rev=209311&r1=209310&r2=209311&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/pr11300.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/pr11300.ll Wed May 21 13:04:33 2014
@@ -3,11 +3,13 @@
; test that the DW_AT_specification is a back edge in the file.
+; Skip the definition of zed(foo*)
; CHECK: DW_TAG_subprogram
-; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "zed")
+; CHECK: DW_TAG_class_type
+; CHECK: [[BAR_DECL:0x[0-9a-f]*]]: DW_TAG_subprogram
+; CHECK: DW_AT_MIPS_linkage_name {{.*}} "_ZN3foo3barEv"
; CHECK: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_specification [DW_FORM_ref4] (cu + {{.*}} => {[[BACK:0x[0-9a-f]*]]})
-; CHECK: [[BACK]]: DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_specification {{.*}} {[[BAR_DECL]]}
%struct.foo = type { i8 }
More information about the llvm-commits
mailing list