Author: Fangrui Song Date: 2021-01-14T11:46:22-08:00 New Revision: e3b9af92a4821fec25c207e2d1e443e09ff6b11e
URL: https://github.com/llvm/llvm-project/commit/e3b9af92a4821fec25c207e2d1e443e09ff6b11e DIFF: https://github.com/llvm/llvm-project/commit/e3b9af92a4821fec25c207e2d1e443e09ff6b11e.diff LOG: [Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for IR input This generalizes D94647 to IR input, as suggested by @tejohnson. Ideally the driver should just forward split dwarf options, but doing this currently will cause `clang -gsplit-dwarf -c a.c` to create a .dwo with just `.strtab`. Reviewed By: dblaikie, tejohnson Differential Revision: https://reviews.llvm.org/D94655 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/split-debug.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 0c821b85c229..8d6e8c42053f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3728,9 +3728,10 @@ static DwarfFissionKind getDebugFissionKind(const Driver &D, return DwarfFissionKind::None; } -static void RenderDebugOptions(const ToolChain &TC, const Driver &D, +static void renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, const ArgList &Args, - bool EmitCodeView, ArgStringList &CmdArgs, + bool EmitCodeView, bool IRInput, + ArgStringList &CmdArgs, codegenoptions::DebugInfoKind &DebugInfoKind, DwarfFissionKind &DwarfFission) { if (Args.hasFlag(options::OPT_fdebug_info_for_profiling, @@ -3754,12 +3755,10 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, Args.hasFlag(options::OPT_fsplit_dwarf_inlining, options::OPT_fno_split_dwarf_inlining, false); - // Normally -gsplit-dwarf is only useful with -gN. For -gsplit-dwarf in the - // backend phase of a distributed ThinLTO which does object file generation - // and no IR generation, -gN should not be needed. So allow -gsplit-dwarf with - // either -gN or -fthinlto-index=. - if (Args.hasArg(options::OPT_g_Group) || - Args.hasArg(options::OPT_fthinlto_index_EQ)) { + // Normally -gsplit-dwarf is only useful with -gN. For IR input, Clang does + // object file generation and no IR generation, -gN should not be needed. So + // allow -gsplit-dwarf with either -gN or IR input. + if (IRInput || Args.hasArg(options::OPT_g_Group)) { Arg *SplitDWARFArg; DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg); if (DwarfFission != DwarfFissionKind::None && @@ -4956,8 +4955,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); DwarfFissionKind DwarfFission = DwarfFissionKind::None; - RenderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, CmdArgs, - DebugInfoKind, DwarfFission); + renderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, + types::isLLVMIR(InputType), CmdArgs, DebugInfoKind, + DwarfFission); // Add the split debug info name to the command lines here so we // can propagate it to the backend. diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index 2ce4ca980c3f..d4511574da4d 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -26,11 +26,12 @@ /// ... unless -fthinlto-index= is specified. // RUN: echo > %t.bc -// RUN: %clang -### -c -target x86_64 -fthinlto-index=dummy -gsplit-dwarf %t.bc 2>&1 | FileCheck %s --check-prefix=THINLTO +// RUN: %clang -### -c -target x86_64 -fthinlto-index=dummy -gsplit-dwarf %t.bc 2>&1 | FileCheck %s --check-prefix=IR +// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -x ir %t.bc 2>&1 | FileCheck %s --check-prefix=IR -// THINLTO-NOT: "-debug-info-kind= -// THINLTO: "-ggnu-pubnames" -// THINLTO-SAME: "-split-dwarf-file" "{{.*}}.dwo" "-split-dwarf-output" "{{.*}}.dwo" +// IR-NOT: "-debug-info-kind= +// IR: "-ggnu-pubnames" +// IR-SAME: "-split-dwarf-file" "{{.*}}.dwo" "-split-dwarf-output" "{{.*}}.dwo" /// -gno-split-dwarf disables debug fission. // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -gno-split-dwarf %s 2>&1 | FileCheck %s --check-prefix=NOSPLIT _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits