From 76ff19ffa7c3dd899aee66ab737649bf1643f7f5 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 30 Sep 2014 21:28:32 +0000 Subject: [PATCH] Disable the -gmlt optimization implemented in r218129 under Darwin due to issues with dsymutil. r218129 omits DW_TAG_subprograms which have no inlined subroutines when emitting -gmlt data. This makes -gmlt very low cost for -O0 builds. Darwin's dsymutil reasonably considers a CU empty if it has no subprograms (which occurs with the above optimization in -O0 programs without any force_inline function calls) and drops the line table, CU, and everything in this situation, making backtraces impossible. Until dsymutil is modified to account for this, disable this optimization on Darwin to preserve the desired functionality. (see r218545, which should be reverted after this patch, for other discussion/details) Footnote: In the long term, it doesn't look like this scheme (of simplified debug info to describe inlining to enable backtracing) is tenable, it is far too size inefficient for optimized code (the DW_TAG_inlined_subprograms, even once compressed, are nearly twice as large as the line table itself (also compressed)) and we'll be considering things like Cary's two level line table proposal to encode all this information directly in the line table. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218702 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 5 ++--- lib/CodeGen/AsmPrinter/DwarfDebug.h | 1 + test/DebugInfo/gmlt.ll | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 7cd06931249..71d076eb480 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -171,6 +171,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) GlobalRangeCount(0), InfoHolder(A, "info_string", DIEValueAllocator), UsedNonDefaultText(false), SkeletonHolder(A, "skel_string", DIEValueAllocator), + IsDarwin(Triple(A->getTargetTriple()).isOSDarwin()), AccelNames(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)), AccelObjC(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, @@ -190,8 +191,6 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) // Turn on accelerator tables for Darwin by default, pubnames by // default for non-Darwin, and handle split dwarf. - bool IsDarwin = Triple(A->getTargetTriple()).isOSDarwin(); - if (DwarfAccelTables == Default) HasDwarfAccelTables = IsDarwin; else @@ -1698,7 +1697,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // Under -gmlt, skip building the subprogram if there are no inlined // subroutines inside it. if (TheCU.getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly && - LScopes.getAbstractScopesList().empty()) { + LScopes.getAbstractScopesList().empty() && !IsDarwin) { assert(ScopeVariables.empty()); assert(CurrentFnArguments.empty()); assert(DbgValues.empty()); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index f082373cbdb..d0b1ee8a274 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -319,6 +319,7 @@ class DwarfDebug : public AsmPrinterHandler { // True iff there are multiple CUs in this module. bool SingleCU; + bool IsDarwin; AddressPool AddrPool; diff --git a/test/DebugInfo/gmlt.ll b/test/DebugInfo/gmlt.ll index 3912134b2d1..a643931927f 100644 --- a/test/DebugInfo/gmlt.ll +++ b/test/DebugInfo/gmlt.ll @@ -1,5 +1,7 @@ ; REQUIRES: object-emission ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s +; RUN: %llc_dwarf -O0 -filetype=obj < %s -mtriple x86_64-apple-darwin | llvm-dwarfdump - \ +; RUN: | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s ; Generated from the following source compiled with clang++ -gmlt: ; void f1() {} @@ -17,6 +19,25 @@ ; CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000) ; CHECK-NOT: {{DW_TAG|NULL}} +; Omitting the subprograms without inlined subroutines is not possible +; currently on Darwin as dsymutil will drop the whole CU if it has no subprograms +; (which happens with this optimization if there are no inlined subroutines). + +; DARWIN: DW_TAG_subprogram +; DARWIN-NOT: DW_TAG +; DARWIN: DW_AT_name {{.*}} "f1" +; DARWIN-NOT: {{DW_TAG|NULL}} +; DARWIN: DW_TAG_subprogram +; DARWIN-NOT: DW_TAG +; DARWIN: DW_AT_name {{.*}} "f2" +; DARWIN-NOT: {{DW_TAG|NULL}} +; DARWIN: DW_TAG_subprogram +; DARWIN-NOT: DW_TAG +; Can't check the abstract_origin value across the DARWIN/CHECK checking and +; ordering, so don't bother - just trust me, it refers to f3 down there. +; DARWIN: DW_AT_abstract_origin +; DARWIN-NOT: {{DW_TAG|NULL}} + ; FIXME: Emitting separate abstract definitions is inefficient when we could ; just attach the DW_AT_name to the inlined_subroutine directly. Except that