[llvm] r188708 - Turn on pubnames by default on linux.

David Blaikie dblaikie at gmail.com
Mon Aug 19 14:19:22 PDT 2013


On Mon, Aug 19, 2013 at 2:07 PM, Eric Christopher <echristo at gmail.com> wrote:
> Author: echristo
> Date: Mon Aug 19 16:07:38 2013
> New Revision: 188708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=188708&view=rev
> Log:
> Turn on pubnames by default on linux.
>
> Until gdb supports the new accelerator tables we should add the
> pubnames section so that gdb_index can be generated from gold
> at link time. On darwin we already emit the accelerator tables
> and so don't need to worry about pubnames.
>
> Added:
>     llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll
>       - copied, changed from r188699, llvm/trunk/test/DebugInfo/dwarf-public-names.ll
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>     llvm/trunk/test/DebugInfo/dwarf-public-names.ll
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=188708&r1=188707&r2=188708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 19 16:07:38 2013
> @@ -58,11 +58,6 @@ static cl::opt<bool> UnknownLocations(
>      cl::init(false));
>
>  static cl::opt<bool>
> -GenerateDwarfPubNamesSection("generate-dwarf-pubnames", cl::Hidden,
> -                             cl::init(false),
> -                             cl::desc("Generate DWARF pubnames section"));
> -
> -static cl::opt<bool>
>  GenerateODRHash("generate-odr-hash", cl::Hidden,
>                  cl::desc("Add an ODR hash to external type DIEs."),
>                  cl::init(false));
> @@ -104,6 +99,14 @@ SplitDwarf("split-dwarf", cl::Hidden,
>                        clEnumVal(Disable, "Disabled"), clEnumValEnd),
>             cl::init(Default));
>
> +static cl::opt<DefaultOnOff>
> +DwarfPubNames("generate-dwarf-pubnames", cl::Hidden,
> +              cl::desc("Generate DWARF pubnames section"),
> +              cl::values(clEnumVal(Default, "Default for platform"),
> +                         clEnumVal(Enable, "Enabled"),
> +                         clEnumVal(Disable, "Disabled"), clEnumValEnd),
> +              cl::init(Default));
> +
>  namespace {
>    const char *const DWARFGroupName = "DWARF Emission";
>    const char *const DbgTimerName = "DWARF Debug Writer";
> @@ -225,6 +228,14 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Mo
>    else
>      HasSplitDwarf = SplitDwarf == Enable ? true : false;
>
> +  if (DwarfPubNames == Default) {
> +    if (IsDarwin)
> +      HasDwarfPubNames = false;
> +    else
> +      HasDwarfPubNames = true;
> +  } else
> +    HasDwarfPubNames = DwarfPubNames == Enable ? true : false;

Interestingly inconsistent in the assignment between the 'if' (using a
nested if) and the 'else' (using the conditional operator)

Though, being the terse individual that I am, I'd probably write this as:

if (DwarfPubNames == Default)
  HasDwarfPubNames = !IsDarwin;
else
  HasDwarfPubNames = DwarfPubNames == Enable;


Wrapping it into a single conditional might be a bit much:

HasDwarfPubNames = DwarfPubNames == Default ? !IsDarwin :
DwarfPubNames == Enable;

& you can leave it as written if you have a substantial preference
(though I still find the inconsistency between the two blocks
noteworthy, but the if/conditional/assign-from-bool choice of how you
implement them is ultimately up to you)

> +
>    DwarfVersion = getDwarfVersionFromModule(MMI->getModule());
>
>    {
> @@ -797,7 +808,7 @@ void DwarfDebug::constructSubprogramDIE(
>    TheCU->addToContextOwner(SubprogramDie, SP.getContext());
>
>    // Expose as global, if requested.
> -  if (GenerateDwarfPubNamesSection)
> +  if (HasDwarfPubNames)
>      TheCU->addGlobalName(SP.getName(), SubprogramDie);
>  }
>
> @@ -1146,7 +1157,7 @@ void DwarfDebug::endModule() {
>    }
>
>    // Emit info into a debug pubnames section, if requested.
> -  if (GenerateDwarfPubNamesSection)
> +  if (HasDwarfPubNames)
>      emitDebugPubnames();
>
>    // Emit info into a debug pubtypes section.
> @@ -1932,7 +1943,7 @@ void DwarfDebug::emitSectionLabels() {
>    DwarfLineSectionSym =
>      emitSectionSym(Asm, TLOF.getDwarfLineSection(), "section_line");
>    emitSectionSym(Asm, TLOF.getDwarfLocSection());
> -  if (GenerateDwarfPubNamesSection)
> +  if (HasDwarfPubNames)
>      emitSectionSym(Asm, TLOF.getDwarfPubNamesSection());
>    emitSectionSym(Asm, TLOF.getDwarfPubTypesSection());
>    DwarfStrSectionSym =
> @@ -2307,8 +2318,8 @@ void DwarfDebug::emitDebugPubnames() {
>        continue;
>
>      // Start the dwarf pubnames section.
> -    Asm->OutStreamer.SwitchSection(
> -      Asm->getObjFileLowering().getDwarfPubNamesSection());
> +    Asm->OutStreamer
> +        .SwitchSection(Asm->getObjFileLowering().getDwarfPubNamesSection());
>
>      Asm->OutStreamer.AddComment("Length of Public Names Info");
>      Asm->EmitLabelDifference(Asm->GetTempSymbol("pubnames_end", ID),
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=188708&r1=188707&r2=188708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 19 16:07:38 2013
> @@ -434,6 +434,7 @@ class DwarfDebug {
>    // DWARF5 Experimental Options
>    bool HasDwarfAccelTables;
>    bool HasSplitDwarf;
> +  bool HasDwarfPubNames;
>
>    unsigned DwarfVersion;
>
>
> Copied: llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll (from r188699, llvm/trunk/test/DebugInfo/dwarf-public-names.ll)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll?p2=llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll&p1=llvm/trunk/test/DebugInfo/dwarf-public-names.ll&r1=188699&r2=188708&rev=188708&view=diff
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/dwarf-public-names.ll (original)
> +++ llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll Mon Aug 19 16:07:38 2013
> @@ -1,7 +1,7 @@
> -; REQUIRES: object-emission
> -
> -; RUN: llc -generate-dwarf-pubnames -filetype=obj -o %t.o < %s
> -; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck %s
> +; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t.o < %s
> +; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck --check-prefix=LINUX %s
> +; RUN: llc -mtriple=x86_64-apple-darwin12 -filetype=obj -o %t.o < %s
> +; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck --check-prefix=DARWIN %s
>  ; ModuleID = 'dwarf-public-names.cpp'
>  ;
>  ; Generated from:
> @@ -35,16 +35,20 @@
>  ;   int global_namespace_variable = 1;
>  ; }
>
> +; Darwin shouldn't be generating the section by default
> +; DARWIN: debug_pubnames
> +; DARWIN: Size:                  0
> +
>  ; Skip the output to the header of the pubnames section.
> -; CHECK: debug_pubnames
> +; LINUX: debug_pubnames
>
>  ; Check for each name in the output.
> -; CHECK: global_namespace_variable
> -; CHECK: global_namespace_function
> -; CHECK: static_member_function
> -; CHECK: global_variable
> -; CHECK: global_function
> -; CHECK: member_function
> +; LINUX: global_namespace_variable
> +; LINUX: global_namespace_function
> +; LINUX: static_member_function
> +; LINUX: global_variable
> +; LINUX: global_function
> +; LINUX: member_function
>
>  %struct.C = type { i8 }
>
>
> Modified: llvm/trunk/test/DebugInfo/dwarf-public-names.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarf-public-names.ll?rev=188708&r1=188707&r2=188708&view=diff
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/dwarf-public-names.ll (original)
> +++ llvm/trunk/test/DebugInfo/dwarf-public-names.ll Mon Aug 19 16:07:38 2013
> @@ -1,6 +1,6 @@
>  ; REQUIRES: object-emission
>
> -; RUN: llc -generate-dwarf-pubnames -filetype=obj -o %t.o < %s
> +; RUN: llc -generate-dwarf-pubnames=Enable -filetype=obj -o %t.o < %s
>  ; RUN: llvm-dwarfdump -debug-dump=pubnames %t.o | FileCheck %s
>  ; ModuleID = 'dwarf-public-names.cpp'
>  ;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list