grimar updated this revision to Diff 171480. grimar added a comment. Ping.
- Rebased. https://reviews.llvm.org/D52296 Files: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/BackendUtil.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/MinGW.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/split-debug-single-file.c test/Driver/split-debug.c test/Driver/split-debug.s
Index: test/Driver/split-debug.s =================================================================== --- test/Driver/split-debug.s +++ test/Driver/split-debug.s @@ -5,6 +5,9 @@ // // CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" +// Check we do not pass any -split-dwarf commands to `as` if -gsingle-file-split-dwarf is specified. +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gsingle-file-split-dwarf -c -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s Index: test/Driver/split-debug.c =================================================================== --- test/Driver/split-debug.c +++ test/Driver/split-debug.c @@ -5,6 +5,16 @@ // // CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gsingle-file-split-dwarf -c -### %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-ACTIONS-SINGLE-SPLIT < %t %s +// +// CHECK-ACTIONS-SINGLE-SPLIT: "-single-file-split-dwarf" +// CHECK-ACTIONS-SINGLE-SPLIT: "-split-dwarf-file" "split-debug.o" + +// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gsingle-file-split-dwarf -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" // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s Index: test/CodeGen/split-debug-single-file.c =================================================================== --- test/CodeGen/split-debug-single-file.c +++ test/CodeGen/split-debug-single-file.c @@ -0,0 +1,16 @@ +// REQUIRES: x86-registered-target + +// Testing to ensure -single-file-split-dwarf 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 -split-dwarf-file %t.o -emit-obj -single-file-split-dwarf -o %t.o %s +// RUN: llvm-objdump -section-headers %t.o | FileCheck --check-prefix=SINGLE-FILE-SPLIT %s +// SINGLE-FILE-SPLIT: .dwo + +// Testing to ensure that the dwo name gets output into the compile unit. +// RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.o -single-file-split-dwarf \ +// RUN: -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWONAME +// DWONAME: !DICompileUnit({{.*}}, splitDebugFilename: "foo.o" + +int main (void) { + return 0; +} Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -598,6 +598,8 @@ Opts.EnableSplitDwarf = Args.hasArg(OPT_enable_split_dwarf); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining); + Opts.SingleFileSplitDwarf = Args.hasArg(OPT_single_file_split_dwarf); + 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: lib/Driver/ToolChains/MinGW.cpp =================================================================== --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -54,7 +54,7 @@ if (Args.hasArg(options::OPT_gsplit_dwarf)) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, - SplitDebugName(Args, Inputs[0])); + SplitDebugName(Args, Inputs[0], Output)); } void tools::MinGW::Linker::AddLibGCC(const ArgList &Args, Index: lib/Driver/ToolChains/Gnu.cpp =================================================================== --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -817,7 +817,7 @@ if (Args.hasArg(options::OPT_gsplit_dwarf) && getToolChain().getTriple().isOSLinux()) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, - SplitDebugName(Args, Inputs[0])); + SplitDebugName(Args, Inputs[0], Output)); } namespace { Index: lib/Driver/ToolChains/CommonArgs.h =================================================================== --- lib/Driver/ToolChains/CommonArgs.h +++ lib/Driver/ToolChains/CommonArgs.h @@ -59,7 +59,7 @@ const Tool &T); const char *SplitDebugName(const llvm::opt::ArgList &Args, - const InputInfo &Input); + const InputInfo &Input, const InputInfo &Output); void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T, const JobAction &JA, const llvm::opt::ArgList &Args, Index: lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -774,7 +774,11 @@ return false; } -const char *tools::SplitDebugName(const ArgList &Args, const InputInfo &Input) { +const char *tools::SplitDebugName(const ArgList &Args, const InputInfo &Input, + const InputInfo &Output) { + if (Args.hasArg(options::OPT_gsingle_file_split_dwarf)) + return Args.MakeArgString(Output.getFilename()); + Arg *FinalOutput = Args.getLastArg(options::OPT_o); if (FinalOutput && Args.hasArg(options::OPT_c)) { SmallString<128> T(FinalOutput->getValue()); Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -3134,6 +3134,9 @@ if (DebugInfoKind == codegenoptions::NoDebugInfo) DebugInfoKind = codegenoptions::LimitedDebugInfo; CmdArgs.push_back("-enable-split-dwarf"); + + if (Args.hasArg(options::OPT_gsingle_file_split_dwarf)) + CmdArgs.push_back("-single-file-split-dwarf"); } } @@ -3899,7 +3902,7 @@ const char *SplitDWARFOut; if (SplitDWARF) { CmdArgs.push_back("-split-dwarf-file"); - SplitDWARFOut = SplitDebugName(Args, Input); + SplitDWARFOut = SplitDebugName(Args, Input, Output); CmdArgs.push_back(SplitDWARFOut); } @@ -5849,11 +5852,11 @@ CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - const llvm::Triple &T = getToolChain().getTriple(); - if (Args.hasArg(options::OPT_gsplit_dwarf) && - (T.isOSLinux() || T.isOSFuchsia())) { + if (!Args.hasArg(options::OPT_gsingle_file_split_dwarf) && + Args.hasArg(options::OPT_gsplit_dwarf) && + getToolChain().getTriple().isOSLinux()) { CmdArgs.push_back("-split-dwarf-file"); - CmdArgs.push_back(SplitDebugName(Args, Input)); + CmdArgs.push_back(SplitDebugName(Args, Input, Output)); } assert(Input.isFilename() && "Invalid input."); Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -832,7 +832,8 @@ break; default: - if (!CodeGenOpts.SplitDwarfFile.empty()) { + if (!CodeGenOpts.SplitDwarfFile.empty() && + !CodeGenOpts.SingleFileSplitDwarf) { DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile); if (!DwoOS) return; Index: include/clang/Frontend/CodeGenOptions.h =================================================================== --- include/clang/Frontend/CodeGenOptions.h +++ include/clang/Frontend/CodeGenOptions.h @@ -176,6 +176,10 @@ /// in the backend for setting the name in the skeleton cu. std::string SplitDwarfFile; + /// The flag shows if we want to split the debug info, but keep it + /// in the object file. + bool SingleFileSplitDwarf; + /// 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 @@ -1831,6 +1831,7 @@ def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group<g_flags_Group>; def gcolumn_info : Flag<["-"], "gcolumn-info">, Group<g_flags_Group>, Flags<[CoreOption]>; def gno_column_info : Flag<["-"], "gno-column-info">, Group<g_flags_Group>, Flags<[CoreOption]>; +def gsingle_file_split_dwarf: Flag <["-"], "gsingle-file-split-dwarf">, Group<g_flags_Group>; 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]>; Index: include/clang/Driver/CC1Options.td =================================================================== --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -646,6 +646,8 @@ HelpText<"Assume all functions with C linkage do not unwind">; def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">, HelpText<"Use split dwarf/Fission">; +def single_file_split_dwarf : Flag<["-"], "single-file-split-dwarf">, + HelpText<"Use single file split dwarf">; def fno_wchar : Flag<["-"], "fno-wchar">, HelpText<"Disable C++ builtin type wchar_t">; def fconstant_string_class : Separate<["-"], "fconstant-string-class">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits