Changeset View
Standalone View
clang/lib/Driver/ToolChains/Clang.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 970 Lines • ▼ Show 20 Lines | case codegenoptions::DebugInfoConstructor: | ||||
CmdArgs.push_back("-debug-info-kind=constructor"); | CmdArgs.push_back("-debug-info-kind=constructor"); | ||||
break; | break; | ||||
case codegenoptions::LimitedDebugInfo: | case codegenoptions::LimitedDebugInfo: | ||||
CmdArgs.push_back("-debug-info-kind=limited"); | CmdArgs.push_back("-debug-info-kind=limited"); | ||||
break; | break; | ||||
case codegenoptions::FullDebugInfo: | case codegenoptions::FullDebugInfo: | ||||
CmdArgs.push_back("-debug-info-kind=standalone"); | CmdArgs.push_back("-debug-info-kind=standalone"); | ||||
break; | break; | ||||
case codegenoptions::UnusedTypeInfo: | |||||
CmdArgs.push_back("-debug-info-kind=unused-types"); | |||||
break; | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
if (DwarfVersion > 0) | if (DwarfVersion > 0) | ||||
CmdArgs.push_back( | CmdArgs.push_back( | ||||
Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion))); | Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion))); | ||||
switch (DebuggerTuning) { | switch (DebuggerTuning) { | ||||
case llvm::DebuggerKind::GDB: | case llvm::DebuggerKind::GDB: | ||||
▲ Show 20 Lines • Show All 2,786 Lines • ▼ Show 20 Lines | static void RenderDebugOptions(const ToolChain &TC, const Driver &D, | ||||
// We parse these two '-f' options whether or not they will be used, | // We parse these two '-f' options whether or not they will be used, | ||||
// to claim them even if you wrote "-fstandalone-debug -gline-tables-only" | // to claim them even if you wrote "-fstandalone-debug -gline-tables-only" | ||||
bool NeedFullDebug = Args.hasFlag( | bool NeedFullDebug = Args.hasFlag( | ||||
options::OPT_fstandalone_debug, options::OPT_fno_standalone_debug, | options::OPT_fstandalone_debug, options::OPT_fno_standalone_debug, | ||||
DebuggerTuning == llvm::DebuggerKind::LLDB || | DebuggerTuning == llvm::DebuggerKind::LLDB || | ||||
TC.GetDefaultStandaloneDebug()); | TC.GetDefaultStandaloneDebug()); | ||||
if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug)) | if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug)) | ||||
(void)checkDebugInfoOption(A, Args, D, TC); | (void)checkDebugInfoOption(A, Args, D, TC); | ||||
if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug) | if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug) | ||||
DebugInfoKind = codegenoptions::FullDebugInfo; | DebugInfoKind = codegenoptions::FullDebugInfo; | ||||
dblaikie: Re: https://reviews.llvm.org/D80242#inline-783632
This is the spot that seems like the place… | |||||
if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, | if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, | ||||
false)) { | false)) { | ||||
// Source embedding is a vendor extension to DWARF v5. By now we have | // Source embedding is a vendor extension to DWARF v5. By now we have | ||||
// checked if a DWARF version was stated explicitly, and have otherwise | // checked if a DWARF version was stated explicitly, and have otherwise | ||||
// fallen back to the target default, so if this is still not at least 5 | // fallen back to the target default, so if this is still not at least 5 | ||||
// we emit an error. | // we emit an error. | ||||
const Arg *A = Args.getLastArg(options::OPT_gembed_source); | const Arg *A = Args.getLastArg(options::OPT_gembed_source); | ||||
Show All 23 Lines | static void RenderDebugOptions(const ToolChain &TC, const Driver &D, | ||||
// Adjust the debug info kind for the given toolchain. | // Adjust the debug info kind for the given toolchain. | ||||
TC.adjustDebugInfoKind(DebugInfoKind, Args); | TC.adjustDebugInfoKind(DebugInfoKind, Args); | ||||
// When emitting remarks, we need at least debug lines in the output. | // When emitting remarks, we need at least debug lines in the output. | ||||
if (willEmitRemarks(Args) && | if (willEmitRemarks(Args) && | ||||
DebugInfoKind <= codegenoptions::DebugDirectivesOnly) | DebugInfoKind <= codegenoptions::DebugDirectivesOnly) | ||||
DebugInfoKind = codegenoptions::DebugLineTablesOnly; | DebugInfoKind = codegenoptions::DebugLineTablesOnly; | ||||
if (EmitDwarf && | |||||
Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types, | |||||
options::OPT_feliminate_unused_debug_types, false)) | |||||
DebugInfoKind = codegenoptions::UnusedTypeInfo; | |||||
dblaikieUnsubmitted How does GCC compose this with -gmlt, for instance? I'd suspect that the desired behavior might be for -gmlt to override this -f flag? So maybe this should be predicated on "if (EmitDwarf && DebugInfoKind >= codegenoptions::LimitedDebugInfo && ... "? (so if someone wants to use only -gmlt in certain parts of their build that doesn't get upgraded by the presence of this -f flag) dblaikie: How does GCC compose this with -gmlt, for instance? I'd suspect that the desired behavior might… | |||||
nickdesaulniersAuthorUnsubmitted GCC does not yet support -gmlt. IIUC, -gmlt ("minimum line tables") is meant to minimize the amount of debug info produced. I'm not sure what the user expects if they simultaneous ask for more debug info (via -fno-eliminate-unused-types) and less debug info (via -gmlt). The current behavior is that -fno-eliminate-unused-types "wins" out over -gmlt, resulting in the "fullest" amount of debug info being produced. (Would you like me to add tests for this behavior to clang/test/Driver/debug-options.c for this behavior?) If we don't want that behavior, we should reconsider whether we want UnusedTypeInfo to be part of the DebugInfoKind "progression." I also don't understand what the suggested added condition to the predicate is supposed to do; if EmitDebugInfo is set, doesn't the default value of DebugInfoConstructor (after 227db86a1b7dd6f96f7df14890fcd071bc4fe1f5, rebased this patch on top of) mean that we wouldn't use UnusedTypeInfo with `-g -fno-eliminate-unused-type-info? Or am I misunderstanding the suggestion? nickdesaulniers: GCC does not yet support `-gmlt`.
https://godbolt.org/z/Wrv6sK
IIUC, `-gmlt` ("minimum line… | |||||
dblaikieUnsubmitted GCC's nearest equivalent is -g1 by the looks of it - I'd hazard a guess that -fno-eliminate-unused-types has no effect when compiling with -g1 (as -fstandalone-debug has no effect when -gmlt is specified) I thin it's probably appropriate to implement similar behavior in Clang - that -fstandalone-debug/no-standalone-debug/no-eliminate-unused-types only applies to users that already asked for some kind of class debug info. It looks like that functionality's already implemented correctly (at least in one or two small cases I tested) for -fstandalone-debug and -fno-eliminate-unused-types should follow that. What should happen between -fstandalone-debug and -fno-eliminate-unused-types is an open question I don't feel too strongly about which order they work in. dblaikie: GCC's nearest equivalent is -g1 by the looks of it - I'd hazard a guess that -fno-eliminate… | |||||
nickdesaulniersAuthorUnsubmitted Oh! Indeed! gcc -g1 -fno-eliminate-unused-debug-types foo.c -c -o foo.o produces no additional debug info. -g2 does. Let me fix that and add tests. nickdesaulniers: Oh! Indeed!
gcc -g1 -fno-eliminate-unused-debug-types foo.c -c -o foo.o
produces no… | |||||
Would this be tidier if it were rolled into the if/checking around 380 since it's a very similar option? dblaikie: Would this be tidier if it were rolled into the if/checking around 380 since it's a very… | |||||
Sorry, I recently rebased, is 380 still where you were thinking...or...? (Maybe you can add some code context in case it moves again)? Maybe 490 (DebugLevelToInfoKind)? Otherwise I don't really see other patterns that check EmitDwarf. nickdesaulniers: Sorry, I recently rebased, is 380 still where you were thinking...or...? (Maybe you can add… | |||||
RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion, | RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion, | ||||
DebuggerTuning); | DebuggerTuning); | ||||
// -fdebug-macro turns on macro debug info generation. | // -fdebug-macro turns on macro debug info generation. | ||||
if (Args.hasFlag(options::OPT_fdebug_macro, options::OPT_fno_debug_macro, | if (Args.hasFlag(options::OPT_fdebug_macro, options::OPT_fno_debug_macro, | ||||
false)) | false)) | ||||
if (checkDebugInfoOption(Args.getLastArg(options::OPT_fdebug_macro), Args, | if (checkDebugInfoOption(Args.getLastArg(options::OPT_fdebug_macro), Args, | ||||
D, TC)) | D, TC)) | ||||
▲ Show 20 Lines • Show All 1,333 Lines • ▼ Show 20 Lines | #endif | ||||
Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden); | Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden); | ||||
Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden); | Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden); | ||||
Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ); | Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ); | ||||
// Forward -f (flag) options which we can pass directly. | // Forward -f (flag) options which we can pass directly. | ||||
Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); | Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); | ||||
Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); | Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); | ||||
Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs); | Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs); | ||||
Looks like this makes the "no" option take precedence, even if it comes before "yes" option. Should check for both in one call, so you really do take the last one: Args.AddLastArg(CmdArgs, options::OPT_feliminate_unused_debug_types, options::OPT_fno_eliminate_unused_debug_types); probinson: Looks like this makes the "no" option take precedence, even if it comes before "yes" option. | |||||
Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); | Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); | ||||
Args.AddLastArg(CmdArgs, options::OPT_femulated_tls, | Args.AddLastArg(CmdArgs, options::OPT_femulated_tls, | ||||
options::OPT_fno_emulated_tls); | options::OPT_fno_emulated_tls); | ||||
// AltiVec-like language extensions aren't relevant for assembling. | // AltiVec-like language extensions aren't relevant for assembling. | ||||
if (!isa<PreprocessJobAction>(JA) || Output.getType() != types::TY_PP_Asm) | if (!isa<PreprocessJobAction>(JA) || Output.getType() != types::TY_PP_Asm) | ||||
Args.AddLastArg(CmdArgs, options::OPT_fzvector); | Args.AddLastArg(CmdArgs, options::OPT_fzvector); | ||||
▲ Show 20 Lines • Show All 1,976 Lines • Show Last 20 Lines |
Re: https://reviews.llvm.org/D80242#inline-783632
This is the spot that seems like the place to handle UnusedTypeInfo, with something like: