From: David Blaikie Date: Fri, 31 Jan 2020 18:32:28 +0000 (-0800) Subject: DebugInfo: Split DWARF: Hash non-member function child DIEs X-Git-Tag: llvmorg-12-init~16123 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b33e5f3c3e850fafcfa94a59da9cdee8eb5f855e;p=platform%2Fupstream%2Fllvm.git DebugInfo: Split DWARF: Hash non-member function child DIEs Significant missing hashing - as per the comment this was only meant to skip member functions (unspecified, but I think it's legible as member function declarations, not definitions) but was skipping all named subprograms (so only hashed child DIEs for member function definitions - because they didn't have a direct name, but only a name given indirectly in the DW_AT_specification-referenced DIE) --- diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp index bfac885..196e694 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -361,7 +361,7 @@ void DIEHash::computeHash(const DIE &Die) { for (auto &C : Die.children()) { // 7.27 Step 7 // If C is a nested type entry or a member function entry, ... - if (isType(C.getTag()) || C.getTag() == dwarf::DW_TAG_subprogram) { + if (isType(C.getTag()) || (C.getTag() == dwarf::DW_TAG_subprogram && isType(C.getParent()->getTag()))) { StringRef Name = getDIEStringAttr(C, dwarf::DW_AT_name); // ... and has a DW_AT_name attribute if (!Name.empty()) { diff --git a/llvm/test/DebugInfo/Inputs/fission-hash-local2.ll b/llvm/test/DebugInfo/Inputs/fission-hash-local2.ll new file mode 100644 index 0000000..56e9452 --- /dev/null +++ b/llvm/test/DebugInfo/Inputs/fission-hash-local2.ll @@ -0,0 +1,29 @@ +; Function Attrs: norecurse nounwind readnone uwtable +define dso_local void @_Z2f1v() local_unnamed_addr !dbg !7 { +entry: + call void @llvm.dbg.value(metadata i32 9, metadata !11, metadata !DIExpression()), !dbg !13 + ret void, !dbg !14 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (git@github.com:llvm/llvm-project.git edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "hash.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 11.0.0 (git@github.com:llvm/llvm-project.git edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6)"} +!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10) +!8 = !DISubroutineType(types: !9) +!9 = !{null} +!10 = !{!11} +!11 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 2, type: !12) +!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!13 = !DILocation(line: 0, scope: !7) +!14 = !DILocation(line: 3, column: 1, scope: !7) diff --git a/llvm/test/DebugInfo/X86/fission-hash-local.ll b/llvm/test/DebugInfo/X86/fission-hash-local.ll new file mode 100644 index 0000000..ff0eb40 --- /dev/null +++ b/llvm/test/DebugInfo/X86/fission-hash-local.ll @@ -0,0 +1,47 @@ +; RUN: llc -split-dwarf-file=foo.dwo -O0 < %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - \ +; RUN: | llvm-dwarfdump - | FileCheck --check-prefix=H1 %s +; RUN: llc -split-dwarf-file=foo.dwo -O0 < %p/../Inputs/fission-hash-local2.ll -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o - \ +; RUN: | llvm-dwarfdump - | FileCheck --check-prefix=H2 %s + +; Testing that the location of a local variable in a global function is hashed +; fission-hash-local2.ll is identical except for the value of the local +; variable (local.ll uses the constant 7 in the llvm.dbg.value below, local2.ll +; uses the constant 9) so it should have a different dwo_id, seen below. + +; Original source: +; void f1() { +; int i = 7; // or 9 +; } + +; H1: DW_AT_GNU_dwo_id (0x03a55a70550ee09b) +; H2: DW_AT_GNU_dwo_id (0x826fcafbddebc96b) + +; Function Attrs: norecurse nounwind readnone uwtable +define dso_local void @_Z2f1v() local_unnamed_addr !dbg !7 { +entry: + call void @llvm.dbg.value(metadata i32 7, metadata !11, metadata !DIExpression()), !dbg !13 + ret void, !dbg !14 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (git@github.com:llvm/llvm-project.git edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "hash.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 11.0.0 (git@github.com:llvm/llvm-project.git edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6)"} +!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10) +!8 = !DISubroutineType(types: !9) +!9 = !{null} +!10 = !{!11} +!11 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 2, type: !12) +!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!13 = !DILocation(line: 0, scope: !7) +!14 = !DILocation(line: 3, column: 1, scope: !7) diff --git a/llvm/test/DebugInfo/X86/sret.ll b/llvm/test/DebugInfo/X86/sret.ll index 24648df..c87b57c 100644 --- a/llvm/test/DebugInfo/X86/sret.ll +++ b/llvm/test/DebugInfo/X86/sret.ll @@ -1,16 +1,16 @@ ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t -; RUN: llvm-dwarfdump -v -all %t | FileCheck %s --check-prefix=CHECK-DWO +; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s --check-prefix=CHECK-DWO ; Based on the debuginfo-tests/sret.cpp code. -; CHECK-DWO: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x51ac5644b1937aa1) -; CHECK-DWO: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x51ac5644b1937aa1) +; CHECK-DWO: DW_AT_GNU_dwo_id (0x7e62530711b94622) +; CHECK-DWO: DW_AT_GNU_dwo_id (0x7e62530711b94622) -; RUN: llc -O0 -fast-isel=true -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s -; RUN: llc -O0 -fast-isel=false -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s +; RUN: llc -O0 -fast-isel=true -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s +; RUN: llc -O0 -fast-isel=false -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s ; CHECK: _ZN1B9AInstanceEv ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000 +; CHECK-NEXT: DW_AT_location (0x00000000 ; CHECK-NEXT: [{{.*}}, {{.*}}): DW_OP_breg5 RDI+0 ; CHECK-NEXT: [{{.*}}, {{.*}}): DW_OP_breg6 RBP-24, DW_OP_deref) ; CHECK-NEXT: DW_AT_name {{.*}}"a"