Index: include/clang/Basic/CodeGenOptions.h =================================================================== --- include/clang/Basic/CodeGenOptions.h +++ include/clang/Basic/CodeGenOptions.h @@ -70,8 +70,6 @@ LocalExecTLSModel }; - enum DwarfFissionKind { NoFission, SplitFileFission, SingleFileFission }; - /// Clang versions with different platform ABI conformance. enum class ClangABI { /// Attempt to be ABI-compatible with code generated by Clang 3.8.x @@ -184,10 +182,12 @@ /// file, for example with -save-temps. std::string MainFileName; - /// The name for the split debug info file that we'll break out. This is used - /// in the backend for setting the name in the skeleton cu. + /// The name for the split debug info file used in the skeleton CU. std::string SplitDwarfFile; + /// Output filename for the split debug info, not used in the skeleton CU. + std::string SplitDwarfOutput; + /// The name of the relocation model to use. llvm::Reloc::Model RelocationModel; Index: include/clang/Basic/CodeGenOptions.def =================================================================== --- include/clang/Basic/CodeGenOptions.def +++ include/clang/Basic/CodeGenOptions.def @@ -260,7 +260,7 @@ ///< contain explicit imports for ///< anonymous namespaces -ENUM_CODEGENOPT(SplitDwarfMode, DwarfFissionKind, 2, NoFission) ///< DWARF fission mode to use. +CODEGENOPT(EnableSplitDwarf, 1, 0) ///< Whether to enable split DWARF. CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the ///< skeleton CU to allow for symbolication Index: include/clang/Driver/CC1Options.td =================================================================== --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -650,7 +650,7 @@ HelpText<"Print the compiler version">; def main_file_name : Separate<["-"], "main-file-name">, HelpText<"Main file name to use for debug info">; -def split_dwarf_file : Separate<["-"], "split-dwarf-file">, +def split_dwarf_output : Separate<["-"], "split-dwarf-output">, HelpText<"File name to use for split dwarf debug info output">; } @@ -661,8 +661,8 @@ HelpText<"Assume all functions with C linkage do not unwind">; def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">, HelpText<"Use DWARF fission in 'split' mode">; -def enable_split_dwarf_EQ : Joined<["-"], "enable-split-dwarf=">, - HelpText<"Set DWARF fission mode to either 'split' or 'single'">, Values<"split,single">; +def split_dwarf_file : Separate<["-"], "split-dwarf-file">, + HelpText<"File name for the split debug info to encode in the DWARF output">; def fno_wchar : Flag<["-"], "fno-wchar">, HelpText<"Disable C++ builtin type wchar_t">; def fconstant_string_class : Separate<["-"], "fconstant-string-class">, Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -464,7 +464,7 @@ Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection; Options.EmitAddrsig = CodeGenOpts.Addrsig; - if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission) + if (CodeGenOpts.EnableSplitDwarf) Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile; Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll; Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels; @@ -844,9 +844,8 @@ break; default: - if (!CodeGenOpts.SplitDwarfFile.empty() && - (CodeGenOpts.getSplitDwarfMode() == CodeGenOptions::SplitFileFission)) { - DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile); + if (CodeGenOpts.EnableSplitDwarf && !CodeGenOpts.SplitDwarfOutput.empty()) { + DwoOS = openOutputFile(CodeGenOpts.SplitDwarfOutput); if (!DwoOS) return; } @@ -1192,8 +1191,8 @@ NeedCodeGen = true; CodeGenPasses.add( createTargetTransformInfoWrapperPass(getTargetIRAnalysis())); - if (!CodeGenOpts.SplitDwarfFile.empty()) { - DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile); + if (!CodeGenOpts.SplitDwarfOutput.empty()) { + DwoOS = openOutputFile(CodeGenOpts.SplitDwarfOutput); if (!DwoOS) return; } @@ -1343,7 +1342,7 @@ Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness; Conf.RemarksFilename = CGOpts.OptRecordFile; Conf.RemarksPasses = CGOpts.OptRecordPasses; - Conf.DwoPath = CGOpts.SplitDwarfFile; + Conf.DwoPath = CGOpts.SplitDwarfOutput; switch (Action) { case Backend_EmitNothing: Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) { Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -610,9 +610,7 @@ LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "", LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO, CGOpts.DwarfDebugFlags, RuntimeVers, - (CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission) - ? "" - : CGOpts.SplitDwarfFile, + CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, CGM.getTarget().getTriple().isNVPTX() Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -3282,11 +3282,7 @@ if (DwarfFission != DwarfFissionKind::None) { if (DebugInfoKind == codegenoptions::NoDebugInfo) DebugInfoKind = codegenoptions::LimitedDebugInfo; - - if (DwarfFission == DwarfFissionKind::Single) - CmdArgs.push_back("-enable-split-dwarf=single"); - else - CmdArgs.push_back("-enable-split-dwarf"); + CmdArgs.push_back("-enable-split-dwarf"); } } @@ -4092,11 +4088,14 @@ TC.getTriple().isOSBinFormatELF() && (isa(JA) || isa(JA) || isa(JA)); - const char *SplitDWARFOut; if (SplitDWARF) { + const char* SplitDWARFOut = SplitDebugName(Args, Input, Output); CmdArgs.push_back("-split-dwarf-file"); - SplitDWARFOut = SplitDebugName(Args, Input, Output); CmdArgs.push_back(SplitDWARFOut); + if (DwarfFission == DwarfFissionKind::Split) { + CmdArgs.push_back("-split-dwarf-output"); + CmdArgs.push_back(SplitDWARFOut); + } } // Pass the linker version in use. @@ -6154,7 +6153,7 @@ Arg *A; if (getDebugFissionKind(D, Args, A) == DwarfFissionKind::Split && T.isOSBinFormatELF()) { - CmdArgs.push_back("-split-dwarf-file"); + CmdArgs.push_back("-split-dwarf-output"); CmdArgs.push_back(SplitDebugName(Args, Input, Output)); } Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -713,25 +713,10 @@ Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro); Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables); Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std); + Opts.EnableSplitDwarf = Args.hasArg(OPT_enable_split_dwarf); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); + Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output); Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); - - if (Arg *A = - Args.getLastArg(OPT_enable_split_dwarf, OPT_enable_split_dwarf_EQ)) { - if (A->getOption().matches(options::OPT_enable_split_dwarf)) { - Opts.setSplitDwarfMode(CodeGenOptions::SplitFileFission); - } else { - StringRef Name = A->getValue(); - if (Name == "single") - Opts.setSplitDwarfMode(CodeGenOptions::SingleFileFission); - else if (Name == "split") - Opts.setSplitDwarfMode(CodeGenOptions::SplitFileFission); - else - Diags.Report(diag::err_drv_invalid_value) - << A->getAsString(Args) << Name; - } - } - Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import); Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params); Index: test/CodeGen/split-debug-filename.c =================================================================== --- test/CodeGen/split-debug-filename.c +++ test/CodeGen/split-debug-filename.c @@ -1,7 +1,7 @@ // REQUIRES: x86-registered-target // RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck --check-prefix=VANILLA %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o - %s | llvm-objdump -section-headers - | FileCheck --check-prefix=O %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t.dwo -split-dwarf-output %t.dwo -emit-obj -o - %s | llvm-objdump -section-headers - | FileCheck --check-prefix=O %s // RUN: llvm-objdump -section-headers %t.dwo | FileCheck --check-prefix=DWO %s int main (void) { Index: test/CodeGen/split-debug-output.c =================================================================== --- /dev/null +++ test/CodeGen/split-debug-output.c @@ -0,0 +1,7 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s +// RUN: llvm-dwarfdump -debug-info %t | FileCheck %s + +int f() { return 0; } + +// CHECK: DW_AT_GNU_dwo_name ("foo.dwo") Index: test/CodeGen/split-debug-single-file.c =================================================================== --- test/CodeGen/split-debug-single-file.c +++ test/CodeGen/split-debug-single-file.c @@ -1,14 +1,15 @@ // REQUIRES: x86-registered-target -// Testing to ensure -enable-split-dwarf=single allows to place .dwo sections into regular output object. +// Testing to ensure that setting only -split-dwarf-file allows to place .dwo sections into regular output object. // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ -// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s +// RUN: -enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o %t.o %s // RUN: llvm-objdump -section-headers %t.o | FileCheck --check-prefix=MODE-SINGLE %s // MODE-SINGLE: .dwo -// Testing to ensure -enable-split-dwarf=split does not place .dwo sections into regular output object. +// Testing to ensure that setting both -split-dwarf-file and -split-dwarf-output +// does not place .dwo sections into regular output object. // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ -// RUN: -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o %s +// RUN: -enable-split-dwarf -split-dwarf-file %t.dwo -split-dwarf-output %t.dwo -emit-obj -o %t.o %s // RUN: llvm-objdump -section-headers %t.o | FileCheck --check-prefix=MODE-SPLIT %s // MODE-SPLIT-NOT: .dwo Index: test/Driver/split-debug.c =================================================================== --- test/Driver/split-debug.c +++ test/Driver/split-debug.c @@ -3,7 +3,7 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s // -// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" +// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s @@ -13,13 +13,15 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS-SINGLE-SPLIT < %t %s // -// CHECK-ACTIONS-SINGLE-SPLIT: "-enable-split-dwarf=single" +// CHECK-ACTIONS-SINGLE-SPLIT: "-enable-split-dwarf" // CHECK-ACTIONS-SINGLE-SPLIT: "-split-dwarf-file" "split-debug.o" +// CHECK-ACTIONS-SINGLE-SPLIT-NOT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### -o %tfoo.o %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SINGLE-SPLIT-FILENAME < %t %s // // CHECK-SINGLE-SPLIT-FILENAME: "-split-dwarf-file" "{{.*}}foo.o" +// CHECK-SINGLE-SPLIT-FILENAME-NOT: "-split-dwarf-output" // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s @@ -41,7 +43,7 @@ // RUN: %clang -target amdgcn-amd-amdhsa -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-OPTION < %t %s // -// CHECK-OPTION: "-split-dwarf-file" "split-debug.dwo" +// CHECK-OPTION: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ASM < %t %s @@ -59,6 +61,7 @@ // CHECK-GMLT-WITH-SPLIT: "-enable-split-dwarf" // CHECK-GMLT-WITH-SPLIT: "-debug-info-kind=line-tables-only" // CHECK-GMLT-WITH-SPLIT: "-split-dwarf-file" +// CHECK-GMLT-WITH-SPLIT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -g -fno-split-dwarf-inlining -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-NOINLINE-WITHOUT-SPLIT < %t %s @@ -87,12 +90,14 @@ // CHECK-GMLT-OVER-SPLIT-NOT: "-enable-split-dwarf" // CHECK-GMLT-OVER-SPLIT: "-debug-info-kind=line-tables-only" // CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-file" +// CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s // // CHECK-SPLIT-OVER-GMLT: "-enable-split-dwarf" "-debug-info-kind=limited" // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file" +// CHECK-SPLIT-OVER-GMLT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -fno-split-dwarf-inlining -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-G0-OVER-SPLIT < %t %s @@ -100,6 +105,7 @@ // CHECK-G0-OVER-SPLIT-NOT: "-enable-split-dwarf" // CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind // CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file" +// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-G0-OVER-SPLIT < %t %s @@ -107,9 +113,11 @@ // CHECK-G0-OVER-SPLIT-NOT: "-enable-split-dwarf" // CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind // CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file" +// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-G0 < %t %s // // CHECK-SPLIT-OVER-G0: "-enable-split-dwarf" "-debug-info-kind=limited" // CHECK-SPLIT-OVER-G0: "-split-dwarf-file" +// CHECK-SPLIT-OVER-G0: "-split-dwarf-output" Index: test/Driver/split-debug.s =================================================================== --- test/Driver/split-debug.s +++ test/Driver/split-debug.s @@ -3,7 +3,7 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s // -// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" +// CHECK-ACTIONS: "-split-dwarf-output" "split-debug.dwo" // Check we pass -split-dwarf-file to `as` if -gsplit-dwarf=split. // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -c -### %s 2> %t Index: test/Misc/cc1as-split-dwarf.s =================================================================== --- test/Misc/cc1as-split-dwarf.s +++ test/Misc/cc1as-split-dwarf.s @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 -split-dwarf-file %t2 +// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 -split-dwarf-output %t2 // RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=O %s // RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DWO %s Index: tools/driver/cc1as_main.cpp =================================================================== --- tools/driver/cc1as_main.cpp +++ tools/driver/cc1as_main.cpp @@ -98,7 +98,7 @@ llvm::DebugCompressionType CompressDebugSections = llvm::DebugCompressionType::None; std::string MainFileName; - std::string SplitDwarfFile; + std::string SplitDwarfOutput; /// @} /// @name Frontend Options @@ -258,7 +258,7 @@ } Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm); Opts.OutputPath = Args.getLastArgValue(OPT_o); - Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); + Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output); if (Arg *A = Args.getLastArg(OPT_filetype)) { StringRef Name = A->getValue(); unsigned OutputType = StringSwitch(Name) @@ -367,8 +367,8 @@ if (!FDOS) return true; std::unique_ptr DwoOS; - if (!Opts.SplitDwarfFile.empty()) - DwoOS = getOutputStream(Opts.SplitDwarfFile, Diags, IsBinary); + if (!Opts.SplitDwarfOutput.empty()) + DwoOS = getOutputStream(Opts.SplitDwarfOutput, Diags, IsBinary); // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and // MCObjectFileInfo needs a MCContext reference in order to initialize itself. @@ -527,8 +527,8 @@ if (Failed) { if (Opts.OutputPath != "-") sys::fs::remove(Opts.OutputPath); - if (!Opts.SplitDwarfFile.empty() && Opts.SplitDwarfFile != "-") - sys::fs::remove(Opts.SplitDwarfFile); + if (!Opts.SplitDwarfOutput.empty() && Opts.SplitDwarfOutput != "-") + sys::fs::remove(Opts.SplitDwarfOutput); } return Failed;