[clang] [lldb] [llvm] [BOLT][DWARF] Fix handling of DWARF5 DWP (PR #72729)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/72729 Fixed handling of DWP as input. Before BOLT crashed. Now it will write out correct CU, and all the TUs. Potential future improvement is to scan all the TUs used in this CU, and only include those. >From 80adaca72cf869f8735d7a3684a8d64bc438e5b6 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 1 Jun 2021 11:37:41 -0700 Subject: [PATCH 1/3] Rebase: [Facebook] Add clang driver options to test debug info and BOLT Summary: This is an essential piece of infrastructure for us to be continuously testing debug info with BOLT. We can't only make changes to a test repo because we need to change debuginfo tests to call BOLT, hence, this diff needs to sit in our opensource repo. But when upstreaming to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming, we need to git diff and check all folders that are being modified by our commits and discard this one (and leave as an internal diff). To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON. Then run check-lldb and check-debuginfo. Manual rebase conflict history: https://phabricator.intern.facebook.com/D29205224 https://phabricator.intern.facebook.com/D29564078 https://phabricator.intern.facebook.com/D33289118 https://phabricator.intern.facebook.com/D34957174 https://phabricator.intern.facebook.com/D35317341 Test Plan: tested locally Configured with: -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests" -DLLVM_TEST_BOLT=ON Ran test suite with: ninja check-debuginfo ninja check-lldb Reviewers: maks, #llvm-bolt Reviewed By: maks Subscribers: ayermolo, phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D46256657 Tasks: T92898286 --- clang/include/clang/Driver/Options.td | 4 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++ cross-project-tests/lit.cfg.py | 14 - cross-project-tests/lit.site.cfg.py.in | 4 lldb/test/API/lit.cfg.py | 5 + lldb/test/API/lit.site.cfg.py.in | 8 +++ lldb/test/Shell/helper/toolchain.py| 5 + lldb/test/Shell/lit.site.cfg.py.in | 9 llvm/CMakeLists.txt| 4 9 files changed, 81 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..31ad86bc098ec63 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5178,6 +5178,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, MarshallingInfoFlag>; def pipe : Flag<["-", "--"], "pipe">, HelpText<"Use pipes between commands, when possible">; +// Facebook T92898286 +def post_link_optimize : Flag<["--"], "post-link-optimize">, + HelpText<"Apply post-link optimizations using BOLT">; +// End Facebook T92898286 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">; def prebind : Flag<["-"], "prebind">; def preload : Flag<["-"], "preload">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index ba95ce9c5a28153..bf55d90f6dc704b 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -666,12 +666,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } + // Facebook T92898286 + if (Args.hasArg(options::OPT_post_link_optimize)) +CmdArgs.push_back("-q"); + // End Facebook T92898286 + Args.AddAllArgs(CmdArgs, options::OPT_T); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs, Output)); + // Facebook T92898286 + if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename()) +return; + + const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv")); + ArgStringList MoveCmdArgs; + MoveCmdArgs.push_back(Output.getFilename()); + const char *PreBoltBin = + Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt"); + MoveCmdArgs.push_back(PreBoltBin); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + MvExec, MoveCmdArgs, std::nullopt)); + + ArgStringList BoltCmdArgs; + const char *BoltExec = + Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt")); + BoltCmdArgs.push_back(PreBoltBin); + BoltCmdArgs.push_back("-reorder-blocks=reverse"); + BoltCmdArgs.push_back("-update-debug-sections"); + BoltCmdArgs.push_back("-o"); + BoltCmdArgs.push_back(Output.getFilename()); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + BoltExec, BoltCmdArgs, std::nullopt)); + // End Facebook T92898286 } void tools::gnutoo
[clang] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/70512 >From 1c6a604df93b833c3bb9c7d34f4f27415592dbe5 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Thu, 5 Oct 2023 12:39:02 -0700 Subject: [PATCH] [LLVM][DWARF] Add support for monolithic types in .debug_names Enable Type Units with DWARF5 accelerator tables for monolithic DWARF. Implementation relies on linker to tombstone offset in LocalTU list to -1 when it deduplciates type units using COMDAT. --- llvm/include/llvm/CodeGen/AccelTable.h| 64 +-- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp| 173 -- .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 2 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 37 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 12 +- llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 4 + llvm/lib/CodeGen/AsmPrinter/DwarfFile.h | 20 ++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 6 + llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 15 ++ llvm/lib/DWARFLinker/DWARFStreamer.cpp| 18 +- .../DWARFLinkerParallel/DWARFEmitterImpl.cpp | 13 +- .../test/DebugInfo/X86/accel-tables-dwarf5.ll | 1 - .../test/DebugInfo/X86/debug-names-dwarf64.ll | 8 +- .../X86/debug-names-types-monolithic.ll | 163 + .../DebugInfo/X86/debug-names-types-split.ll | 57 ++ .../ARM/dwarf5-dwarf4-combination-macho.test | 14 +- 16 files changed, 503 insertions(+), 104 deletions(-) create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h index d4e21b2ac8e7ebc..d948b7d82b85979 100644 --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -16,7 +16,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/STLFunctionalExtras.h" -#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/DIE.h" @@ -104,10 +103,13 @@ namespace llvm { class AsmPrinter; -class DwarfCompileUnit; +class DwarfUnit; class DwarfDebug; +class DwarfTypeUnit; class MCSymbol; class raw_ostream; +struct TypeUnitMetaInfo; +using TUVectorTy = SmallVector; /// Interface which the different types of accelerator table data have to /// conform. It serves as a base class for different values of the template @@ -197,6 +199,9 @@ template class AccelTable : public AccelTableBase { template void addName(DwarfStringPoolEntryRef Name, Types &&... Args); + void clear() { Entries.clear(); } + void addEntries(AccelTable &Table); + const StringEntries getEntries() const { return Entries; } }; template @@ -250,11 +255,21 @@ class AppleAccelTableData : public AccelTableData { /// emitDWARF5AccelTable function. class DWARF5AccelTableData : public AccelTableData { public: + struct AttributeEncoding { +dwarf::Index Index; +dwarf::Form Form; + }; static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); } - DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU); - DWARF5AccelTableData(uint64_t DieOffset, unsigned DieTag, unsigned CUIndex) - : OffsetVal(DieOffset), DieTag(DieTag), UnitID(CUIndex) {} + DWARF5AccelTableData(const DIE &Die, const DwarfUnit &CU, + const bool IsTU = false); + DWARF5AccelTableData(const uint64_t DieOffset, const unsigned DieTag, + const unsigned Index, const bool IsTU = false) + : OffsetVal(DieOffset) { +Data.DieTag = DieTag; +Data.UnitID = Index; +Data.IsTU = IsTU; + } #ifndef NDEBUG void print(raw_ostream &OS) const override; @@ -265,18 +280,25 @@ class DWARF5AccelTableData : public AccelTableData { "Accessing DIE Offset before normalizing."); return std::get(OffsetVal); } - unsigned getDieTag() const { return DieTag; } - unsigned getUnitID() const { return UnitID; } + unsigned getDieTag() const { return Data.DieTag; } + unsigned getUnitID() const { return Data.UnitID; } + bool isTU() const { return Data.IsTU; } void normalizeDIEToOffset() { assert(std::holds_alternative(OffsetVal) && "Accessing offset after normalizing."); OffsetVal = std::get(OffsetVal)->getOffset(); } + bool isNormalized() const { +return std::holds_alternative(OffsetVal); + } protected: std::variant OffsetVal; - unsigned DieTag; - unsigned UnitID; + struct MetaData { +uint32_t DieTag : 16; +uint32_t UnitID : 15; +uint32_t IsTU : 1; + } Data; uint64_t order() const override { return getDieOffset(); } }; @@ -288,7 +310,19 @@ class DWARF5AccelTable : public AccelTable { void convertDieToOffset() { for (auto &Entry : Entries) { for (AccelTableData *Value : Entry.second.Values) { -static_cast(Value)->normalize
[clang] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/70512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][DWARF] Fix accelerator swtiching with TU re-use (PR #77511)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/77511 This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). >From 5e6ee63fabac0dabc692c00d3c017e2542c98273 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 9 Jan 2024 10:51:55 -0800 Subject: [PATCH] [LLVM][DWARF] Fix accelerator swtiching with TU re-use This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). --- .../CodeGen/thinlto-debug-names-tu-reuse.ll | 58 +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 10 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll diff --git a/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll new file mode 100644 index 00..53aec43a050f8b --- /dev/null +++ b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll @@ -0,0 +1,58 @@ +; REQUIRES: asserts + +;; Tests that accelerator table switches correctly from TU to CU when a top level TU is re-used. +;; Assert is not triggered. +;; File1 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal; +;; FIle2 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal2; +;; clang++ .cpp -O0 -g2 -fdebug-types-section -gpubnames -S -emit-llvm -o .ll +;; llvm-link file1.ll file2.ll -S -o thinlto-debug-names-tu-reuse.ll + +; RUN: llc -O0 -dwarf-version=5 -generate-type-units -filetype=obj < %s -o %t.o +; RUN: llvm-readelf --sections %t.o | FileCheck --check-prefix=OBJ %s + +; OBJ: debug_names + +; ModuleID = 'llvm-link' +source_filename = "llvm-link" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Foo = type { i8 } + +@fGlobal = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !0 +@fGlobal2 = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !9 + +!llvm.dbg.cu = !{!2, !11} +!llvm.ident = !{!14, !14} +!llvm.module.flags = !{!15, !16, !17, !18, !19, !20, !21} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "fGlobal", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false) +!3 = !DIFile(filename: "main.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "4f1831504f0948b03880356fae49cb58") +!4 = !{!0} +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS3Foo") +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_member, name: "fChar", scope: !5, file: !3, line: 3, baseType: !8, size: 8) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) +!10 = distinct !DIGlobalVariable(name: "fGlobal2", scope: !11, file: !12, line: 5, type: !5, isLocal: false, isDefinition: true) +!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) +!12 = !DIFile(filename: "helper.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "014145d46991fd1eb6a2192d382feb75") +!13 = !{!9} +!14 = !{!"clang version 18.0.0git"} +!15 = !{i32 7, !"Dwarf Version", i32 5} +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{i32 1, !"wchar_size", i32 4} +!18 = !{i32 8, !"PIC Level", i32 2} +!19 = !{i32 7, !"PIE Level", i32 2} +!20 = !{i32 7, !"uwtable", i32 2} +!21 = !{i32 7, !"frame-pointer", i32 2} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 41afbea4561433..0a922fcd54a061 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3448,7 +3448,6 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitT
[clang] [llvm] [LLVM][DWARF] Fix accelerator swtiching with TU re-use (PR #77511)
ayermolo wrote: There is another bug on when we exit from addDwarfTypeUnitType. I need to construct a small repro for it. https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [LLVM][DWARF] Fix accelerator swtiching with TU re-use (PR #77511)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/77511 >From 5e6ee63fabac0dabc692c00d3c017e2542c98273 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 9 Jan 2024 10:51:55 -0800 Subject: [PATCH 1/2] [LLVM][DWARF] Fix accelerator swtiching with TU re-use This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). --- .../CodeGen/thinlto-debug-names-tu-reuse.ll | 58 +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 10 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll diff --git a/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll new file mode 100644 index 00..53aec43a050f8b --- /dev/null +++ b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll @@ -0,0 +1,58 @@ +; REQUIRES: asserts + +;; Tests that accelerator table switches correctly from TU to CU when a top level TU is re-used. +;; Assert is not triggered. +;; File1 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal; +;; FIle2 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal2; +;; clang++ .cpp -O0 -g2 -fdebug-types-section -gpubnames -S -emit-llvm -o .ll +;; llvm-link file1.ll file2.ll -S -o thinlto-debug-names-tu-reuse.ll + +; RUN: llc -O0 -dwarf-version=5 -generate-type-units -filetype=obj < %s -o %t.o +; RUN: llvm-readelf --sections %t.o | FileCheck --check-prefix=OBJ %s + +; OBJ: debug_names + +; ModuleID = 'llvm-link' +source_filename = "llvm-link" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Foo = type { i8 } + +@fGlobal = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !0 +@fGlobal2 = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !9 + +!llvm.dbg.cu = !{!2, !11} +!llvm.ident = !{!14, !14} +!llvm.module.flags = !{!15, !16, !17, !18, !19, !20, !21} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "fGlobal", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false) +!3 = !DIFile(filename: "main.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "4f1831504f0948b03880356fae49cb58") +!4 = !{!0} +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS3Foo") +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_member, name: "fChar", scope: !5, file: !3, line: 3, baseType: !8, size: 8) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) +!10 = distinct !DIGlobalVariable(name: "fGlobal2", scope: !11, file: !12, line: 5, type: !5, isLocal: false, isDefinition: true) +!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) +!12 = !DIFile(filename: "helper.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "014145d46991fd1eb6a2192d382feb75") +!13 = !{!9} +!14 = !{!"clang version 18.0.0git"} +!15 = !{i32 7, !"Dwarf Version", i32 5} +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{i32 1, !"wchar_size", i32 4} +!18 = !{i32 8, !"PIC Level", i32 2} +!19 = !{i32 7, !"PIE Level", i32 2} +!20 = !{i32 7, !"uwtable", i32 2} +!21 = !{i32 7, !"frame-pointer", i32 2} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 41afbea4561433..0a922fcd54a061 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3448,7 +3448,6 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &RefDie, const DICompositeType *CTy) { - setCurrentDWARF5AccelTable(DWARF5AccelTableKind::TU); // Fast path if we're building some type units and one has already used the // address pool we know we're going to throw away all this work anyway, so // don't bother building depend
[llvm] [clang] [LLVM][DWARF] Fix accelerator swtiching with TU re-use (PR #77511)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/77511 >From 5e6ee63fabac0dabc692c00d3c017e2542c98273 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 9 Jan 2024 10:51:55 -0800 Subject: [PATCH 1/3] [LLVM][DWARF] Fix accelerator swtiching with TU re-use This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). --- .../CodeGen/thinlto-debug-names-tu-reuse.ll | 58 +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 10 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll diff --git a/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll new file mode 100644 index 00..53aec43a050f8b --- /dev/null +++ b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll @@ -0,0 +1,58 @@ +; REQUIRES: asserts + +;; Tests that accelerator table switches correctly from TU to CU when a top level TU is re-used. +;; Assert is not triggered. +;; File1 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal; +;; FIle2 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal2; +;; clang++ .cpp -O0 -g2 -fdebug-types-section -gpubnames -S -emit-llvm -o .ll +;; llvm-link file1.ll file2.ll -S -o thinlto-debug-names-tu-reuse.ll + +; RUN: llc -O0 -dwarf-version=5 -generate-type-units -filetype=obj < %s -o %t.o +; RUN: llvm-readelf --sections %t.o | FileCheck --check-prefix=OBJ %s + +; OBJ: debug_names + +; ModuleID = 'llvm-link' +source_filename = "llvm-link" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Foo = type { i8 } + +@fGlobal = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !0 +@fGlobal2 = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !9 + +!llvm.dbg.cu = !{!2, !11} +!llvm.ident = !{!14, !14} +!llvm.module.flags = !{!15, !16, !17, !18, !19, !20, !21} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "fGlobal", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false) +!3 = !DIFile(filename: "main.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "4f1831504f0948b03880356fae49cb58") +!4 = !{!0} +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS3Foo") +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_member, name: "fChar", scope: !5, file: !3, line: 3, baseType: !8, size: 8) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) +!10 = distinct !DIGlobalVariable(name: "fGlobal2", scope: !11, file: !12, line: 5, type: !5, isLocal: false, isDefinition: true) +!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) +!12 = !DIFile(filename: "helper.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "014145d46991fd1eb6a2192d382feb75") +!13 = !{!9} +!14 = !{!"clang version 18.0.0git"} +!15 = !{i32 7, !"Dwarf Version", i32 5} +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{i32 1, !"wchar_size", i32 4} +!18 = !{i32 8, !"PIC Level", i32 2} +!19 = !{i32 7, !"PIE Level", i32 2} +!20 = !{i32 7, !"uwtable", i32 2} +!21 = !{i32 7, !"frame-pointer", i32 2} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 41afbea4561433..0a922fcd54a061 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3448,7 +3448,6 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &RefDie, const DICompositeType *CTy) { - setCurrentDWARF5AccelTable(DWARF5AccelTableKind::TU); // Fast path if we're building some type units and one has already used the // address pool we know we're going to throw away all this work anyway, so // don't bother building depend
[llvm] [clang] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/77511 >From 5e6ee63fabac0dabc692c00d3c017e2542c98273 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 9 Jan 2024 10:51:55 -0800 Subject: [PATCH 1/4] [LLVM][DWARF] Fix accelerator swtiching with TU re-use This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). --- .../CodeGen/thinlto-debug-names-tu-reuse.ll | 58 +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 10 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll diff --git a/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll new file mode 100644 index 00..53aec43a050f8b --- /dev/null +++ b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll @@ -0,0 +1,58 @@ +; REQUIRES: asserts + +;; Tests that accelerator table switches correctly from TU to CU when a top level TU is re-used. +;; Assert is not triggered. +;; File1 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal; +;; FIle2 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal2; +;; clang++ .cpp -O0 -g2 -fdebug-types-section -gpubnames -S -emit-llvm -o .ll +;; llvm-link file1.ll file2.ll -S -o thinlto-debug-names-tu-reuse.ll + +; RUN: llc -O0 -dwarf-version=5 -generate-type-units -filetype=obj < %s -o %t.o +; RUN: llvm-readelf --sections %t.o | FileCheck --check-prefix=OBJ %s + +; OBJ: debug_names + +; ModuleID = 'llvm-link' +source_filename = "llvm-link" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Foo = type { i8 } + +@fGlobal = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !0 +@fGlobal2 = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !9 + +!llvm.dbg.cu = !{!2, !11} +!llvm.ident = !{!14, !14} +!llvm.module.flags = !{!15, !16, !17, !18, !19, !20, !21} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "fGlobal", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false) +!3 = !DIFile(filename: "main.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "4f1831504f0948b03880356fae49cb58") +!4 = !{!0} +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS3Foo") +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_member, name: "fChar", scope: !5, file: !3, line: 3, baseType: !8, size: 8) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) +!10 = distinct !DIGlobalVariable(name: "fGlobal2", scope: !11, file: !12, line: 5, type: !5, isLocal: false, isDefinition: true) +!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) +!12 = !DIFile(filename: "helper.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "014145d46991fd1eb6a2192d382feb75") +!13 = !{!9} +!14 = !{!"clang version 18.0.0git"} +!15 = !{i32 7, !"Dwarf Version", i32 5} +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{i32 1, !"wchar_size", i32 4} +!18 = !{i32 8, !"PIC Level", i32 2} +!19 = !{i32 7, !"PIE Level", i32 2} +!20 = !{i32 7, !"uwtable", i32 2} +!21 = !{i32 7, !"frame-pointer", i32 2} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 41afbea4561433..0a922fcd54a061 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3448,7 +3448,6 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &RefDie, const DICompositeType *CTy) { - setCurrentDWARF5AccelTable(DWARF5AccelTableKind::TU); // Fast path if we're building some type units and one has already used the // address pool we know we're going to throw away all this work anyway, so // don't bother building depend
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
ayermolo wrote: @dwblaikie ping https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
ayermolo wrote: It's been 24 hours with no broken build bots. So I guess this one got it right. :) https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/82840 When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? >From 714cc804f2716bbd3c666d8922403299e4c19893 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 7 --- clang/test/Driver/split-debug.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6e1b7e8657d0dc..27a5aef17c8d71 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) +if (EffectiveDWARFVersion < 5 && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..1d5f0fa42fdeea 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/82840 >From 714cc804f2716bbd3c666d8922403299e4c19893 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH 1/2] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 7 --- clang/test/Driver/split-debug.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6e1b7e8657d0dc..27a5aef17c8d71 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) +if (EffectiveDWARFVersion < 5 && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..1d5f0fa42fdeea 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT >From 8784b440cd3792925179ea1e058b762397bcdf6a Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 17:35:36 -0800 Subject: [PATCH 2/2] changred to tunning, added test --- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/test/Driver/split-debug.c | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 27a5aef17c8d71..dbfc729bba24c7 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,7 +4479,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (EffectiveDWARFVersion < 5 && +if (DebuggerTuning != llvm::DebuggerKind::LLDB && (!PubnamesArg || (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && !PubnamesArg->getOption().matches(options::OPT_gno_pubnames diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 1d5f0fa42fdeea..a2a3dc02354503 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,6 +11,7 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" +// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT @@ -123,3 +124,8 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" + +/// Do not generate -ggnu-pubnames for -glldb +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT + +// GLLDBSPLIT-NOT: "-ggnu-pubnames" ___
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
ayermolo wrote: Changed to tunning. https://github.com/llvm/llvm-project/pull/82840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/82840 >From 1ac054cc8d5ee99169547ae09da0411b6e8e48e8 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH 1/2] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 7 --- clang/test/Driver/split-debug.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6e1b7e8657d0dc..27a5aef17c8d71 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) +if (EffectiveDWARFVersion < 5 && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..1d5f0fa42fdeea 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT >From 69028ca2940e6e033718a34c4acd6c079343c5d3 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 17:35:36 -0800 Subject: [PATCH 2/2] changred to tunning, added test --- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/test/Driver/split-debug.c | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 27a5aef17c8d71..dbfc729bba24c7 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,7 +4479,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (EffectiveDWARFVersion < 5 && +if (DebuggerTuning != llvm::DebuggerKind::LLDB && (!PubnamesArg || (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && !PubnamesArg->getOption().matches(options::OPT_gno_pubnames diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 1d5f0fa42fdeea..a2a3dc02354503 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,6 +11,7 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" +// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT @@ -123,3 +124,8 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" + +/// Do not generate -ggnu-pubnames for -glldb +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT + +// GLLDBSPLIT-NOT: "-ggnu-pubnames" ___
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/82840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
ayermolo wrote: > Looks this breaks tests on macOS: http://45.33.8.238/macm1/79435/step_7.txt > > Please take a look and revert for now if it takes a while to fix. > Looks this breaks tests on macOS: http://45.33.8.238/macm1/79435/step_7.txt > > Please take a look and revert for now if it takes a while to fix. Looks like it's just one test that checks for -ggnu-pubnames. Let me take a look. https://github.com/llvm/llvm-project/pull/82840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
ayermolo wrote: > It's been a few hours. Time to revert and analyze offline? I think I have a fix. Just takes forever to setup and build on my laptop to test it. Basically I think mac defaults to LLDB tuning, and test that fails explicitly passes the flag in. https://github.com/llvm/llvm-project/pull/82840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/83206 This is a fix for https://github.com/llvm/llvm-project/pull/82840. On mac tunning is by default LLDB. If the flag was passed in to clang after that PR it would not have been passed in by the driver. >From c7fb961e3a4dfa404187e62d32490c58977f212a Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 27 Feb 2024 14:54:22 -0800 Subject: [PATCH] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed This is a fix for https://github.com/llvm/llvm-project/pull/82840. On mac tunning is by default LLDB. If the flag was passed in to clang after that PR it would not have been passed in by the driver. --- clang/lib/Driver/ToolChains/Clang.cpp | 9 +++-- clang/test/Driver/split-debug.c | 5 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index dbfc729bba24c7..7b38450d0720ef 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4478,8 +4478,12 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || - (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (DebuggerTuning != llvm::DebuggerKind::LLDB && + (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) { +const bool OptionSet = +(PubnamesArg && + (PubnamesArg->getOption().matches(options::OPT_gpubnames) || + PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames))); +if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) && (!PubnamesArg || (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && !PubnamesArg->getOption().matches(options::OPT_gno_pubnames @@ -4487,6 +4491,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames) ? "-gpubnames" : "-ggnu-pubnames"); + } const auto *SimpleTemplateNamesArg = Args.getLastArg(options::OPT_gsimple_template_names, options::OPT_gno_simple_template_names); diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index a2a3dc02354503..57f3989ed7b510 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -129,3 +129,8 @@ // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT // GLLDBSPLIT-NOT: "-ggnu-pubnames" + +/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2 + +// GLLDBSPLIT2: "-ggnu-pubnames" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)
ayermolo wrote: Test passes on mac  https://github.com/llvm/llvm-project/pull/83206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)
ayermolo wrote: https://github.com/llvm/llvm-project/pull/83206 https://github.com/llvm/llvm-project/pull/82840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)
ayermolo wrote: > I don't know if this is correct. > > Maybe just add a triple to the problematic clang invocation for now and have > this reviewed by a local expert while trunk isn't broken? ok https://github.com/llvm/llvm-project/pull/83206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5." (PR #83214)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/83214 Reverts llvm/llvm-project#82840 >From 58007120dfbc69ccfdf04ae1eb71b30e3582b435 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich <43973793+ayerm...@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:40:45 -0800 Subject: [PATCH] =?UTF-8?q?Revert=20"[CLANG][DWARF]=20Do=20not=20emit=20-g?= =?UTF-8?q?gnu-pubnames=20for=20split=20dwarf=20version=205.=20=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b3ae6c205e4afcf1a9f7d7204a659a27ca700237. --- clang/lib/Driver/ToolChains/Clang.cpp | 7 +++ clang/test/Driver/split-debug.c | 5 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index dbfc729bba24c76..6e1b7e8657d0dc9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,10 +4479,9 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (DebuggerTuning != llvm::DebuggerKind::LLDB && -(!PubnamesArg || - (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames +if (!PubnamesArg || +(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index a2a3dc023545034..968f33b4cc035c5 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -124,8 +124,3 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" - -/// Do not generate -ggnu-pubnames for -glldb -// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT - -// GLLDBSPLIT-NOT: "-ggnu-pubnames" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)
ayermolo wrote: revert https://github.com/llvm/llvm-project/pull/83214 https://github.com/llvm/llvm-project/pull/83206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5." (PR #83214)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/83214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/83206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/83331 When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. This is used by GDB, but not by LLDB. Changed so that these sections are not emitted for LLDB tuning. >From 668819ef921ecb4d0ef704c2269ea07acd1b5334 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH 1/2] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 7 --- clang/test/Driver/split-debug.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 66c3a237c12117..da3930c1c9697b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) +if (EffectiveDWARFVersion < 5 && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..1d5f0fa42fdeea 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT >From b458d52dbaa3589b728969f6cb630c4602cf1216 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Wed, 28 Feb 2024 13:01:02 -0800 Subject: [PATCH 2/2] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. This is used by GDB, but not by LLDB. Changed so that these sections are not emitted for LLDB tuning, unless flag is passed explicitly. --- clang/lib/Driver/ToolChains/Clang.cpp | 9 +++-- clang/test/Driver/split-debug.c | 10 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index da3930c1c9697b..2dc42119973caf 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4478,8 +4478,12 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || - (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (EffectiveDWARFVersion < 5 && + (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) { +const bool OptionSet = +(PubnamesArg && + (PubnamesArg->getOption().matches(options::OPT_gpubnames) || + PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames))); +if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) && (!PubnamesArg || (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && !PubnamesArg->getOption().matches(options::OPT_gno_pubnames @@ -4487,6 +4491,7 @@
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
ayermolo wrote: Another attempt. Had to return original https://github.com/llvm/llvm-project/pull/82840 because it was breaking a test on mac. https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/83331 >From 668819ef921ecb4d0ef704c2269ea07acd1b5334 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 7 --- clang/test/Driver/split-debug.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 66c3a237c12117..da3930c1c9697b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) +if (EffectiveDWARFVersion < 5 && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..1d5f0fa42fdeea 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/83331 >From 7d58760a887fc935e2af670f8aa721cdd5946391 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 14 ++ clang/test/Driver/split-debug.c | 11 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 66c3a237c12117..2dc42119973caf 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4478,14 +4478,20 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || - (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) + (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) { +const bool OptionSet = +(PubnamesArg && + (PubnamesArg->getOption().matches(options::OPT_gpubnames) || + PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames))); +if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" : "-ggnu-pubnames"); + } const auto *SimpleTemplateNamesArg = Args.getLastArg(options::OPT_gsimple_template_names, options::OPT_gno_simple_template_names); diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..e297724931045c 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT @@ -124,3 +123,13 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" + +/// Do not generate -ggnu-pubnames for -glldb +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT + +// GLLDBSPLIT-NOT: "-ggnu-pubnames" + +/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2 + +// GLLDBSPLIT2: "-ggnu-pubnames" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
@@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" ayermolo wrote: Sorry not sure I follow. As discussed in original diff the idea is if -gsplit-dwarf with -glldb is used the -ggnu-pubnames wouldn't be passed in. Since LLDB doesn't benefit from it, and it just uses space. A fix from original is if someone does specify -ggnu-pubnames it will be generated. I added a test for it on linux side. There is also a test on mac side that used -gsplit-dwarf with -ggnu-pubnames. On mac LLDB tunning is the default. So equivalent of passing -glldb on linux. https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5 (PR #83331)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/83331 >From 7d58760a887fc935e2af670f8aa721cdd5946391 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 23 Feb 2024 14:52:04 -0800 Subject: [PATCH 1/2] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning? --- clang/lib/Driver/ToolChains/Clang.cpp | 14 ++ clang/test/Driver/split-debug.c | 11 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 66c3a237c12117..2dc42119973caf 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4478,14 +4478,20 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames, options::OPT_gpubnames, options::OPT_gno_pubnames); if (DwarfFission != DwarfFissionKind::None || - (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) -if (!PubnamesArg || -(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && - !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))) + (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) { +const bool OptionSet = +(PubnamesArg && + (PubnamesArg->getOption().matches(options::OPT_gpubnames) || + PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames))); +if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) && +(!PubnamesArg || + (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && + !PubnamesArg->getOption().matches(options::OPT_gno_pubnames CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( options::OPT_gpubnames) ? "-gpubnames" : "-ggnu-pubnames"); + } const auto *SimpleTemplateNamesArg = Args.getLastArg(options::OPT_gsimple_template_names, options::OPT_gno_simple_template_names); diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 968f33b4cc035c..e297724931045c 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT @@ -124,3 +123,13 @@ // G1_NOSPLIT: "-debug-info-kind=line-tables-only" // G1_NOSPLIT-NOT: "-split-dwarf-file" // G1_NOSPLIT-NOT: "-split-dwarf-output" + +/// Do not generate -ggnu-pubnames for -glldb +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT + +// GLLDBSPLIT-NOT: "-ggnu-pubnames" + +/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2 + +// GLLDBSPLIT2: "-ggnu-pubnames" >From d1097183a42b12cc7f5b8993b48d8a051926340e Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Fri, 1 Mar 2024 12:27:04 -0800 Subject: [PATCH 2/2] added a check that was dropped during internal merge --- clang/test/Driver/split-debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index e297724931045c..57f3989ed7b510 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -11,6 +11,7 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" +// SPLIT-SAME: "-ggnu-pubnames" // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT _
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
@@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" ayermolo wrote: Oh I see! Thanks for clarification. That check should be there. I think it snuck in when I tried to re-apply a patch internally and somehow got merged with original version of the first PR. https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
https://github.com/ayermolo edited https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (PR #83331)
@@ -11,7 +11,6 @@ // NOINLINE-NOT: "-fsplit-dwarf-inlining" // SPLIT-NOT: "-dumpdir" // SPLIT: "-debug-info-kind=constructor" -// SPLIT-SAME: "-ggnu-pubnames" ayermolo wrote: At least on my mac it passed. With that check. I double checked, and this is what I see: ./bin/clang -### -c -target x86_64 -gsplit-dwarf -g /Users/ayermolo/local/llvm-project/clang/test/Driver/split-debug.c "-dwarf-version=5" "-debugger-tuning=gdb" "-ggnu-pubnames" ./bin/clang -### -c -gsplit-dwarf -g /Users/ayermolo/local/llvm-project/clang/test/Driver/split-debug.c "-dwarf-version=4" "-debugger-tuning=lldb" https://github.com/llvm/llvm-project/pull/83331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [lld] [mlir] [flang] [clang-tools-extra] [libunwind] [clang] [openmp] [libcxx] [compiler-rt] [llvm] [libc] [pstl] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone in non-SHF_ALL
ayermolo wrote: Hmm, interesting. Thanks for the fix. https://github.com/llvm/llvm-project/pull/79238 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/77511 >From 5e6ee63fabac0dabc692c00d3c017e2542c98273 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Tue, 9 Jan 2024 10:51:55 -0800 Subject: [PATCH 1/5] [LLVM][DWARF] Fix accelerator swtiching with TU re-use This bug is triggered when a TU is already created, and we process the same DICompositeType at a top level. We would switch to TU accelerator table, but would not switch back on early exit. As the result we would add CU entries to the TU accelerator table. When we try to write out TUs and normalize entries, the offsets for DIEs that are part of a CU would not have been computed, and it would assert on getOffset(). --- .../CodeGen/thinlto-debug-names-tu-reuse.ll | 58 +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 10 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll diff --git a/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll new file mode 100644 index 00..53aec43a050f8b --- /dev/null +++ b/clang/test/CodeGen/thinlto-debug-names-tu-reuse.ll @@ -0,0 +1,58 @@ +; REQUIRES: asserts + +;; Tests that accelerator table switches correctly from TU to CU when a top level TU is re-used. +;; Assert is not triggered. +;; File1 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal; +;; FIle2 +;; struct Foo { +;; char fChar; +;; }; +;; Foo fGlobal2; +;; clang++ .cpp -O0 -g2 -fdebug-types-section -gpubnames -S -emit-llvm -o .ll +;; llvm-link file1.ll file2.ll -S -o thinlto-debug-names-tu-reuse.ll + +; RUN: llc -O0 -dwarf-version=5 -generate-type-units -filetype=obj < %s -o %t.o +; RUN: llvm-readelf --sections %t.o | FileCheck --check-prefix=OBJ %s + +; OBJ: debug_names + +; ModuleID = 'llvm-link' +source_filename = "llvm-link" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.Foo = type { i8 } + +@fGlobal = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !0 +@fGlobal2 = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !9 + +!llvm.dbg.cu = !{!2, !11} +!llvm.ident = !{!14, !14} +!llvm.module.flags = !{!15, !16, !17, !18, !19, !20, !21} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "fGlobal", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false) +!3 = !DIFile(filename: "main.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "4f1831504f0948b03880356fae49cb58") +!4 = !{!0} +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !6, identifier: "_ZTS3Foo") +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_member, name: "fChar", scope: !5, file: !3, line: 3, baseType: !8, size: 8) +!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) +!10 = distinct !DIGlobalVariable(name: "fGlobal2", scope: !11, file: !12, line: 5, type: !5, isLocal: false, isDefinition: true) +!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 18.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !13, splitDebugInlining: false) +!12 = !DIFile(filename: "helper.cpp", directory: "/smallTUReuse", checksumkind: CSK_MD5, checksum: "014145d46991fd1eb6a2192d382feb75") +!13 = !{!9} +!14 = !{!"clang version 18.0.0git"} +!15 = !{i32 7, !"Dwarf Version", i32 5} +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{i32 1, !"wchar_size", i32 4} +!18 = !{i32 8, !"PIC Level", i32 2} +!19 = !{i32 7, !"PIE Level", i32 2} +!20 = !{i32 7, !"uwtable", i32 2} +!21 = !{i32 7, !"frame-pointer", i32 2} diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 41afbea4561433..0a922fcd54a061 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3448,7 +3448,6 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &RefDie, const DICompositeType *CTy) { - setCurrentDWARF5AccelTable(DWARF5AccelTableKind::TU); // Fast path if we're building some type units and one has already used the // address pool we know we're going to throw away all this work anyway, so // don't bother building depend
[clang] [llvm] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
ayermolo wrote: > Could this be caused by the patch > https://lab.llvm.org/buildbot/#/builders/236/builds/8673 ? Passes for me locally. Also patch impacts .debug_names for DWARF. So highly unlikely it would cause this test to fail. https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)
ayermolo wrote: > However, the patch broke the [Solaris/sparcv9 > buildbot](https://lab.llvm.org/buildbot/#/builders/72/builds/1834): > > ``` > llc: error: unable to get target for 'x86_64-unknown-linux-gnu', see > --version and --triple. > ``` > > The bot is configured to do a Sparc-only build. oh. I think ; REQUIRES: x86-registered-target is missing. Let me add it https://github.com/llvm/llvm-project/pull/77511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D90507: [Driver] Add DWARF64 flag: -gdwarf64
From: David Blaikie via Phabricator Sent: Monday, December 7, 2020 11:08 AM To: Alexander Yermolovich ; llvm-comm...@lists.llvm.org Cc: Hongtao Yu ; jan_svob...@apple.com ; steve...@apple.com ; dany.grumb...@gmail.com ; Wenlei He ; dexonsm...@apple.com ; cfe-commits@lists.llvm.org ; mask...@google.com ; ikud...@accesssoftek.com ; bhuvanendra.kum...@amd.com ; mlek...@skidmore.edu ; blitzrak...@gmail.com ; shen...@google.com ; orlando.hy...@sony.com Subject: [PATCH] D90507: [Driver] Add DWARF64 flag: -gdwarf64 dblaikie added inline comments. Herald added a subscriber: hoy. Comment at: clang/include/clang/Basic/CodeGenOptions.def:35 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm. +CODEGENOPT(Dwarf64 , 1, 0) ///< -gdwarf64. CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments. ayermolo wrote: > dblaikie wrote: > > ayermolo wrote: > > > dblaikie wrote: > > > > ayermolo wrote: > > > > > dblaikie wrote: > > > > > > ayermolo wrote: > > > > > > > ikudrin wrote: > > > > > > > > dblaikie wrote: > > > > > > > > > Is there any precedent to draw from for this flag name? (Does > > > > > > > > > GCC support DWARF64? Does it support it under this flag name > > > > > > > > > or some other? (similarly with other gcc-like compilers > > > > > > > > > (Intel's? Whoever else... ))) > > > > > > > > It looks like we are pioneering in that area. To me, the > > > > > > > > proposed name looks consonant with other debug-related switches. > > > > > > > I didn't see any dwarf64 flags in gcc: > > > > > > > https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html > > > > > > > > > > > > > > I tried to follow clang convention for other dwarf flags. > > > > > > Huh - tried making really big binaries or anything (or checking the > > > > > > GCC source) to see if it does it implicitly under some conditions? > > > > > > Hmm - looks like this maybe came up at the Linux Plumbers > > > > > > Conference & the suggested flag was -fdwarf64/32: > > > > > > https://linuxplumbersconf.org/event/7/contributions/746/attachments/578/1018/DWARF5-64.pdf > > > > > > (this avoids the "does g imply debug info" and avoids the subtle > > > > > > distinction between "-gdwarf64 and -gdwarf-N" the presence of the > > > > > > '-' changing the meaning of the number quite significantly). Though > > > > > > hardly authoritative > > > > > > https://linuxplumbersconf.org/event/7/sessions/90/attachments/583/1201/dwarf-bof-notes-aug24-lpc-2020.txt > > > > > > - seems some other options were (are?) under consideration too. > > > > > > Might be worth touching base with the folks involved in those > > > > > > discussions to see where they're at with regard to naming/support? > > > > > > > > > > > > (they also touch on the "all units must agree" issue - so not sure > > > > > > if the same folks involved in those discussions have also been > > > > > > included in the discussions around debug info 32/64 sorting as > > > > > > another approach that may avoid the "all units must agree" > > > > > > constraint (I assume that's the reason they had that constraint)) > > > > > In the DWARFV5-64 pdf it says 64 bit support has no patches and is > > > > > after DWARF5. Although it's not clear if they are talking about > > > > > DWARF64 support for V5 or in general. > > > > > > > > > > I have not hacked our build system to use gcc for builds that can > > > > > overflow debug_info. I scanned through gcc code and was only able to > > > > > find references to dwarf 64 in go library, and in dwarf2out.c. In > > > > > latter it relies on DWARF_OFFSET_SIZE macro. > > > > > > > > > > I don't quite understand the "all [CU] units must agree" part either. > > > > > From DWARF perspective we are free to match on CU level DWARF32/64, > > > > > and consumer are free not to do anything beyond that. So if overflow > > > > > occurs, will so be it. What we are trying to do in linker with > > > > > sorting is being "nice" to the users, and kind of going beyond what > > > > > spec requires. > > > > > > > > > > Sounds like no conclusion was reached on their side, but only one of > > > > > them -gdwarf64 follows naming convention of other debug flags. > > > > > > * -fdwarf64/-fdwarf32 > > > > > > * or -gdwarf32 or -gdwarf64 > > > > > > * or -gdbdwarf=32/64 > > > > > > > > > > > > > > > > > > > > > > > > > only one of them -gdwarf64 follows naming convention of other debug > > > > > flags. > > > > > > > > There are many debug flags that don't use the '-g' prefix. > > > > (-fdebug-types-section comes to mind, but I think - this was discussed > > > > in depth earlier this year with regards to the -gsplit-dwarf flag, for > > > > instance: https://www.mail-archive.com/gcc@gcc.gnu.org/msg92495.html - > > > > though at least the DWARF64 flag doesn't have the legacy that > > > > -gsplit-dwarf has that complicates things further th
[clang] [codegen] Emit missing cleanups for stmt-expr and coro suspensions [take-2] (PR #85398)
ayermolo wrote: I think this commit is causing build failure when building clangd in debug mode with clang built in release mode. ``` Instruction does not dominate all uses! %K1104 = getelementptr inbounds %"struct.llvm::json::Object::KV", ptr %arrayinit.begin1100, i32 0, i32 0, !dbg !93928 call void @_ZN4llvm4json9ObjectKeyD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %K1104) #21, !dbg !93937 fatal error: error in backend: Broken module found, compilation aborted! PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /home/ayermolo/local/llvm-build-upstream-release/bin/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/extra/clangd -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd/../include-cleaner/include -Itools/clang/tools/extra/clangd/../clang-tidy -I/home/ayermolo/local/upstream-llvm/llvm-project/clang/include -Itools/clang/include -Iinclude -I/home/ayermolo/local/upstream-llvm/llvm-project/llvm/include -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/pseudo/lib/../include -isystem/home/ayermolo/local/llvm-build-upstream-llvm/build/lib/clang/19/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -g -std=c++17 -MD -MT /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o -MF /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o.d -o /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o -c /home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd/ClangdLSPServer.cpp ``` Dropping this commit and running above clang build command makes it pass. build command for easier reading: ``` COMP=/home/ayermolo/local/llvm-build-upstream-release/bin $COMP/clang++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \ -Itools/clang/tools/extra/clangd \ -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd \ -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd/../include-cleaner/include \ -Itools/clang/tools/extra/clangd/../clang-tidy \ -I/home/ayermolo/local/upstream-llvm/llvm-project/clang/include \ -Itools/clang/include \ -Iinclude \ -I/home/ayermolo/local/upstream-llvm/llvm-project/llvm/include \ -I/home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/pseudo/lib/../include \ -isystem/home/ayermolo/local/llvm-build-upstream-llvm/build/lib/clang/19/include \ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra \ -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi \ -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override \ -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual \ -Wno-nested-anon-types -g -std=c++17 -MD \ -MT /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o \ -MF /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o.d \ -o /home/ayermolo/local/llvm-build-upstream-debug/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o \ -c /home/ayermolo/local/upstream-llvm/llvm-project/clang-tools-extra/clangd/ClangdLSPServer.cpp ``` https://github.com/llvm/llvm-project/pull/85398 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [codegen] Emit missing cleanups for stmt-expr and coro suspensions [take-2] (PR #85398)
ayermolo wrote: @usx95 can you repro? Also is there ETA on a fix, and if not can you revert this? https://github.com/llvm/llvm-project/pull/85398 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] NFC: Make clang resource headers an interface library (PR #88317)
ayermolo wrote: I am seeing a cmake error in one of the build steps in our enviroment: ``` CMake Error at CMakeLists.txt:86 (get_property): get_property could not find TARGET clang-resource-headers. Perhaps it has not yet been created. ``` Reverting this diff internally made build pass. I'll try to create small repro, but in meantime can you revert? https://github.com/llvm/llvm-project/pull/88317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] Revert "NFC: Make clang resource headers an interface library (#88317)" (PR #89266)
ayermolo wrote: Thanks. It's failing internally in our automatic multi stage build. Trying to dig into it as part of my oncall. :) https://github.com/llvm/llvm-project/pull/89266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] Revert "NFC: Make clang resource headers an interface library (#88317)" (PR #89266)
ayermolo wrote: Fixed our internal foobar yesterday. Can close this. https://github.com/llvm/llvm-project/pull/89266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits