mirror of https://github.com/microsoft/clang.git
DebugInfo: Add the ability to disable DWARF name tables entirely
This changes the current default behavior (from emitting pubnames by default, to not emitting them by default) & moves to matching GCC's behavior* with one significant difference: -gno(-gnu)-pubnames disables pubnames even in the presence of -gsplit-dwarf (though -gsplit-dwarf still by default enables -ggnu-pubnames). This allows users to disable pubnames (& the new DWARF5 accelerated access tables) when they might not be worth the size overhead. * GCC's behavior is that -ggnu-pubnames and -gpubnames override each other, and that -gno-gnu-pubnames and -gno-pubnames act as synonyms and disable either kind of pubnames if they come last. (eg: -gpubnames -gno-gnu-pubnames causes no pubnames (neither gnu or standard) to be emitted) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5c15d24300
commit
6eed53ab5d
|
@ -197,10 +197,6 @@ def dwarf_column_info : Flag<["-"], "dwarf-column-info">,
|
|||
HelpText<"Turn on column location information.">;
|
||||
def split_dwarf : Flag<["-"], "split-dwarf">,
|
||||
HelpText<"Split out the dwarf .dwo sections">;
|
||||
def gnu_pubnames : Flag<["-"], "gnu-pubnames">,
|
||||
HelpText<"Emit newer GNU style pubnames">;
|
||||
def arange_sections : Flag<["-"], "arange_sections">,
|
||||
HelpText<"Emit DWARF .debug_arange sections">;
|
||||
def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
|
||||
HelpText<"Generate debug info with external references to clang modules"
|
||||
" or precompiled headers">;
|
||||
|
|
|
@ -1807,6 +1807,8 @@ def gno_column_info : Flag<["-"], "gno-column-info">, Group<g_flags_Group>, Flag
|
|||
def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>;
|
||||
def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group<g_flags_Group>, Flags<[CC1Option]>;
|
||||
def gno_gnu_pubnames : Flag<["-"], "gno-gnu-pubnames">, Group<g_flags_Group>, Flags<[CC1Option]>;
|
||||
def gpubnames : Flag<["-"], "gpubnames">, Group<g_flags_Group>, Flags<[CC1Option]>;
|
||||
def gno_pubnames : Flag<["-"], "gno-pubnames">, Group<g_flags_Group>, Flags<[CC1Option]>;
|
||||
def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group<g_flags_Group>;
|
||||
def gmodules : Flag <["-"], "gmodules">, Group<gN_Group>,
|
||||
HelpText<"Generate debug info with external references to clang modules"
|
||||
|
|
|
@ -326,7 +326,7 @@ CODEGENOPT(DebugInfoForProfiling, 1, 0)
|
|||
CODEGENOPT(PreserveVec3Type, 1, 0)
|
||||
|
||||
/// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
|
||||
CODEGENOPT(GnuPubnames, 1, 0)
|
||||
CODEGENOPT(DebugNameTable, 2, 0)
|
||||
|
||||
CODEGENOPT(NoPLT, 1, 0)
|
||||
|
||||
|
|
|
@ -581,9 +581,8 @@ void CGDebugInfo::CreateCompileUnit() {
|
|||
0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
|
||||
CGM.getTarget().getTriple().isNVPTX()
|
||||
? llvm::DICompileUnit::DebugNameTableKind::None
|
||||
: CGOpts.GnuPubnames
|
||||
? llvm::DICompileUnit::DebugNameTableKind::GNU
|
||||
: llvm::DICompileUnit::DebugNameTableKind::Default);
|
||||
: static_cast<llvm::DICompileUnit::DebugNameTableKind>(
|
||||
CGOpts.DebugNameTable));
|
||||
}
|
||||
|
||||
llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
|
||||
|
|
|
@ -3060,11 +3060,18 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
|
|||
CmdArgs.push_back("-debug-info-macro");
|
||||
|
||||
// -ggnu-pubnames turns on gnu style pubnames in the backend.
|
||||
if (Args.hasFlag(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames,
|
||||
false))
|
||||
if (checkDebugInfoOption(Args.getLastArg(options::OPT_ggnu_pubnames), Args,
|
||||
D, TC))
|
||||
CmdArgs.push_back("-ggnu-pubnames");
|
||||
const auto *PubnamesArg =
|
||||
Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames,
|
||||
options::OPT_gpubnames, options::OPT_gno_pubnames);
|
||||
if (SplitDWARFArg ||
|
||||
(PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
|
||||
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"
|
||||
: "-ggnu-pubnames");
|
||||
|
||||
// -gdwarf-aranges turns on the emission of the aranges section in the
|
||||
// backend.
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/IR/DebugInfoMetadata.h"
|
||||
#include "llvm/Linker/Linker.h"
|
||||
#include "llvm/MC/MCTargetOptions.h"
|
||||
#include "llvm/Option/Arg.h"
|
||||
|
@ -643,7 +644,12 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
|
||||
Opts.DebugInfoForProfiling = Args.hasFlag(
|
||||
OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
|
||||
Opts.GnuPubnames = Args.hasArg(OPT_ggnu_pubnames);
|
||||
Opts.DebugNameTable = static_cast<unsigned>(
|
||||
Args.hasArg(OPT_ggnu_pubnames)
|
||||
? llvm::DICompileUnit::DebugNameTableKind::GNU
|
||||
: Args.hasArg(OPT_gpubnames)
|
||||
? llvm::DICompileUnit::DebugNameTableKind::Default
|
||||
: llvm::DICompileUnit::DebugNameTableKind::None);
|
||||
|
||||
setPGOInstrumentor(Opts, Args, Diags);
|
||||
Opts.InstrProfileOutput =
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// CHECK: @i = internal constant i32 1, align 4, !dbg ![[I:[0-9]+]]
|
||||
// CHECK: ![[I]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
|
||||
// CHECK: ![[VAR]] = distinct !DIGlobalVariable(name: "i",
|
||||
// CHECK: !DICompileUnit({{.*}}globals: ![[GLOBALS:[0-9]+]])
|
||||
// CHECK: !DICompileUnit({{.*}}globals: ![[GLOBALS:[0-9]+]]
|
||||
// CHECK: ![[GLOBALS]] = !{![[I]]}
|
||||
static const int i = 1;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
// NO_MACRO-NOT: DIMacro
|
||||
// NO_MACRO-NOT: DIMacroFile
|
||||
|
||||
// CHECK: !DICompileUnit({{.*}} macros: [[Macros:![0-9]+]])
|
||||
// CHECK: !DICompileUnit({{.*}} macros: [[Macros:![0-9]+]]
|
||||
// CHECK: [[EmptyMD:![0-9]+]] = !{}
|
||||
|
||||
// NO_PCH: [[Macros]] = !{[[MainMacroFile:![0-9]+]], [[BuiltinMacro:![0-9]+]], {{.*}}, [[DefineC1:![0-9]+]], [[DefineA:![0-9]+]], [[UndefC1:![0-9]+]]}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gpubnames | FileCheck --check-prefix=DEFAULT %s
|
||||
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -ggnu-pubnames | FileCheck --check-prefix=GNU %s
|
||||
|
||||
// CHECK: !DICompileUnit({{.*}}, nameTableKind: None
|
||||
// DEFAULT-NOT: !DICompileUnit({{.*}}, nameTableKind:
|
||||
// GNU: !DICompileUnit({{.*}}, nameTableKind: GNU
|
||||
|
||||
void f1() {
|
||||
}
|
|
@ -133,9 +133,18 @@
|
|||
// RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=GIGNORE %s
|
||||
//
|
||||
// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s
|
||||
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOGOPT %s
|
||||
// RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOGOPT %s
|
||||
// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GPUB %s
|
||||
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
// RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
// RUN: %clang -### -c -ggnu-pubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
//
|
||||
// RUN: %clang -### -c -gpubnames %s 2>&1 | FileCheck -check-prefix=PUB %s
|
||||
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
// RUN: %clang -### -c -gpubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
// RUN: %clang -### -c -gpubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
//
|
||||
// RUN: %clang -### -c -gsplit-dwarf %s 2>&1 | FileCheck -check-prefix=GPUB %s
|
||||
// RUN: %clang -### -c -gsplit-dwarf -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
|
||||
//
|
||||
// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
|
||||
//
|
||||
|
@ -229,8 +238,11 @@
|
|||
//
|
||||
// GIGNORE-NOT: "argument unused during compilation"
|
||||
//
|
||||
// GOPT: -ggnu-pubnames
|
||||
// NOGOPT-NOT: -ggnu-pubnames
|
||||
// GPUB: -ggnu-pubnames
|
||||
// NOPUB-NOT: -ggnu-pubnames
|
||||
// NOPUB-NOT: -gpubnames
|
||||
//
|
||||
// PUB: -gpubnames
|
||||
//
|
||||
// GARANGE: -generate-arange-section
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue