Index: include/clang/Basic/CodeGenOptions.h =================================================================== --- include/clang/Basic/CodeGenOptions.h +++ include/clang/Basic/CodeGenOptions.h @@ -188,6 +188,10 @@ /// in the backend for setting the name in the skeleton cu. std::string SplitDwarfFile; + /// Overrides \ref SplitDwarfFile as value of DW_AT_[GNU_]dwo_name to be used + /// in the skeleton CU, if not empty. Does not change the output file name. + std::string SplitDwarfDwoNameAttr; + /// The name of the relocation model to use. llvm::Reloc::Model RelocationModel; Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1849,6 +1849,8 @@ Flags<[CC1Option]>, HelpText<"Use DWARF base address selection entries in debug_ranges">; def fno_debug_ranges_base_address: Flag <["-"], "fno-debug-ranges-base-address">, Group, Flags<[CC1Option]>; +def fsplit_dwarf_dwo_name_attr_EQ: Joined<["-"], "fsplit-dwarf-dwo-name-attr=">, Group, + Flags<[CC1Option]>, HelpText<"Set the name for the split debug info file to be used in the object file">; def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, Group, Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF">; def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group, Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -464,7 +464,9 @@ Options.EmitAddrsig = CodeGenOpts.Addrsig; if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission) - Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile; + Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfDwoNameAttr.empty() + ? CodeGenOpts.SplitDwarfFile + : CodeGenOpts.SplitDwarfDwoNameAttr; Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll; Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels; Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm; Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -714,6 +714,8 @@ Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables); Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); + Opts.SplitDwarfDwoNameAttr = + Args.getLastArgValue(OPT_fsplit_dwarf_dwo_name_attr_EQ); Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); if (Arg *A = Index: test/CodeGen/split-debug-dwo-name-attr.c =================================================================== --- /dev/null +++ test/CodeGen/split-debug-dwo-name-attr.c @@ -0,0 +1,8 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t -fsplit-dwarf-dwo-name-attr=foo.dwo -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s +// RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=DWO %s + +int f() { return 0; } + +// CHECK: DW_AT_GNU_dwo_name ("foo.dwo") +// DWO: .dwo