<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On 21 May 2018, at 21:31, Peter Collingbourne via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: pcc<br class="">Date: Mon May 21 13:31:59 2018<br class="">New Revision: 332885<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=332885&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=332885&view=rev</a><br class="">Log:<br class="">CodeGen, Driver: Start using direct split dwarf emission in clang.<br class=""><br class="">Fixes PR37466.<br class=""><br class="">Differential Revision: <a href="https://reviews.llvm.org/D47093" class="">https://reviews.llvm.org/D47093</a><br class=""><br class="">Added:<br class=""> cfe/trunk/test/Misc/cc1as-split-dwarf.s<br class="">Modified:<br class=""> cfe/trunk/include/clang/Driver/CC1Options.td<br class=""> cfe/trunk/lib/CodeGen/BackendUtil.cpp<br class=""> cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br class=""> cfe/trunk/test/CodeGen/split-debug-filename.c<br class=""> cfe/trunk/test/Driver/split-debug.c<br class=""> cfe/trunk/test/Driver/split-debug.s<br class=""> cfe/trunk/tools/driver/cc1as_main.cpp<br class=""><br class="">Modified: cfe/trunk/include/clang/Driver/CC1Options.td<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Driver/CC1Options.td (original)<br class="">+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon May 21 13:31:59 2018<br class="">@@ -619,6 +619,8 @@ def version : Flag<["-"], "version">,<br class=""> HelpText<"Print the compiler version">;<br class=""> def main_file_name : Separate<["-"], "main-file-name">,<br class=""> HelpText<"Main file name to use for debug info">;<br class="">+def split_dwarf_file : Separate<["-"], "split-dwarf-file">,<br class="">+ HelpText<"File name to use for split dwarf debug info output">;<br class=""><br class=""> }<br class=""><br class="">@@ -628,8 +630,6 @@ def fexternc_nounwind : Flag<["-"], "fex<br class=""> HelpText<"Assume all functions with C linkage do not unwind">;<br class=""> def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">,<br class=""> HelpText<"Use split dwarf/Fission">;<br class="">-def split_dwarf_file : Separate<["-"], "split-dwarf-file">,<br class="">- HelpText<"File name to use for split dwarf debug info output">;<br class=""> def fno_wchar : Flag<["-"], "fno-wchar">,<br class=""> HelpText<"Disable C++ builtin type wchar_t">;<br class=""> def fconstant_string_class : Separate<["-"], "fconstant-string-class">,<br class=""><br class="">Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)<br class="">+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon May 21 13:31:59 2018<br class="">@@ -104,7 +104,17 @@ class EmitAssemblyHelper {<br class=""> ///<br class=""> /// \return True on success.<br class=""> bool AddEmitPasses(legacy::PassManager &CodeGenPasses, BackendAction Action,<br class="">- raw_pwrite_stream &OS);<br class="">+ raw_pwrite_stream &OS, raw_pwrite_stream *DwoOS);<br class="">+<br class="">+ std::unique_ptr<llvm::ToolOutputFile> openOutputFile(StringRef Path) {<br class="">+ std::error_code EC;<br class="">+ auto F = make_unique<llvm::ToolOutputFile>(Path, EC, llvm::sys::fs::F_None);<br class="">+ if (EC) {<br class="">+ Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();<br class="">+ F.reset();<br class="">+ }<br class="">+ return F;<br class="">+ }<br class=""><br class=""> public:<br class=""> EmitAssemblyHelper(DiagnosticsEngine &_Diags,<br class="">@@ -701,7 +711,8 @@ void EmitAssemblyHelper::CreateTargetMac<br class=""><br class=""> bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,<br class=""> BackendAction Action,<br class="">- raw_pwrite_stream &OS) {<br class="">+ raw_pwrite_stream &OS,<br class="">+ raw_pwrite_stream *DwoOS) {<br class=""> // Add LibraryInfo.<br class=""> llvm::Triple TargetTriple(TheModule->getTargetTriple());<br class=""> std::unique_ptr<TargetLibraryInfoImpl> TLII(<br class="">@@ -718,7 +729,7 @@ bool EmitAssemblyHelper::AddEmitPasses(l<br class=""> if (CodeGenOpts.OptimizationLevel > 0)<br class=""> CodeGenPasses.add(createObjCARCContractPass());<br class=""><br class="">- if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, CGFT,<br class="">+ if (TM->addPassesToEmitFile(CodeGenPasses, OS, DwoOS, CGFT,<br class=""> /*DisableVerify=*/!CodeGenOpts.VerifyModule)) {<br class=""> Diags.Report(diag::err_fe_unable_to_interface_with_target);<br class=""> return false;<br class="">@@ -757,7 +768,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba<br class=""> CodeGenPasses.add(<br class=""> createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));<br class=""><br class="">- std::unique_ptr<raw_fd_ostream> ThinLinkOS;<br class="">+ std::unique_ptr<llvm::ToolOutputFile> ThinLinkOS, DwoOS;<br class=""><br class=""> switch (Action) {<br class=""> case Backend_EmitNothing:<br class="">@@ -766,18 +777,12 @@ void EmitAssemblyHelper::EmitAssembly(Ba<br class=""> case Backend_EmitBC:<br class=""> if (CodeGenOpts.EmitSummaryIndex) {<br class=""> if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {<br class="">- std::error_code EC;<br class="">- ThinLinkOS.reset(new llvm::raw_fd_ostream(<br class="">- CodeGenOpts.ThinLinkBitcodeFile, EC,<br class="">- llvm::sys::fs::F_None));<br class="">- if (EC) {<br class="">- Diags.Report(diag::err_fe_unable_to_open_output) << CodeGenOpts.ThinLinkBitcodeFile<br class="">- << EC.message();<br class="">+ ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);<br class="">+ if (!ThinLinkOS)<br class=""> return;<br class="">- }<br class=""> }<br class="">- PerModulePasses.add(<br class="">- createWriteThinLTOBitcodePass(*OS, ThinLinkOS.get()));<br class="">+ PerModulePasses.add(createWriteThinLTOBitcodePass(<br class="">+ *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));<br class=""> }<br class=""> else<br class=""> PerModulePasses.add(<br class="">@@ -790,7 +795,13 @@ void EmitAssemblyHelper::EmitAssembly(Ba<br class=""> break;<br class=""><br class=""> default:<br class="">- if (!AddEmitPasses(CodeGenPasses, Action, *OS))<br class="">+ if (!CodeGenOpts.SplitDwarfFile.empty()) {<br class="">+ DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile);<br class="">+ if (!DwoOS)<br class="">+ return;<br class="">+ }<br class="">+ if (!AddEmitPasses(CodeGenPasses, Action, *OS,<br class="">+ DwoOS ? &DwoOS->os() : nullptr))<br class=""> return;<br class=""> }<br class=""><br class="">@@ -819,6 +830,11 @@ void EmitAssemblyHelper::EmitAssembly(Ba<br class=""> PrettyStackTraceString CrashInfo("Code generation");<br class=""> CodeGenPasses.run(*TheModule);<br class=""> }<br class="">+<br class="">+ if (ThinLinkOS)<br class="">+ ThinLinkOS->keep();<br class="">+ if (DwoOS)<br class="">+ DwoOS->keep();<br class=""> }<br class=""><br class=""> static PassBuilder::OptimizationLevel mapToLevel(const CodeGenOptions &Opts) {<br class="">@@ -971,7 +987,7 @@ void EmitAssemblyHelper::EmitAssemblyWit<br class=""> // create that pass manager here and use it as needed below.<br class=""> legacy::PassManager CodeGenPasses;<br class=""> bool NeedCodeGen = false;<br class="">- Optional<raw_fd_ostream> ThinLinkOS;<br class="">+ std::unique_ptr<llvm::ToolOutputFile> ThinLinkOS, DwoOS;<br class=""><br class=""> // Append any output we need to the pass manager.<br class=""> switch (Action) {<br class="">@@ -981,17 +997,12 @@ void EmitAssemblyHelper::EmitAssemblyWit<br class=""> case Backend_EmitBC:<br class=""> if (CodeGenOpts.EmitSummaryIndex) {<br class=""> if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {<br class="">- std::error_code EC;<br class="">- ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,<br class="">- llvm::sys::fs::F_None);<br class="">- if (EC) {<br class="">- Diags.Report(diag::err_fe_unable_to_open_output)<br class="">- << CodeGenOpts.ThinLinkBitcodeFile << EC.message();<br class="">+ ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);<br class="">+ if (!ThinLinkOS)<br class=""> return;<br class="">- }<br class=""> }<br class="">- MPM.addPass(<br class="">- ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));<br class="">+ MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()<br class="">+ : nullptr));<br class=""> } else {<br class=""> MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,<br class=""> CodeGenOpts.EmitSummaryIndex,<br class="">@@ -1009,7 +1020,13 @@ void EmitAssemblyHelper::EmitAssemblyWit<br class=""> NeedCodeGen = true;<br class=""> CodeGenPasses.add(<br class=""> createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));<br class="">- if (!AddEmitPasses(CodeGenPasses, Action, *OS))<br class="">+ if (!CodeGenOpts.SplitDwarfFile.empty()) {<br class="">+ DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile);<br class="">+ if (!DwoOS)<br class="">+ return;<br class="">+ }<br class="">+ if (!AddEmitPasses(CodeGenPasses, Action, *OS,<br class="">+ DwoOS ? &DwoOS->os() : nullptr))<br class=""> // FIXME: Should we handle this error differently?<br class=""> return;<br class=""> break;<br class="">@@ -1029,6 +1046,11 @@ void EmitAssemblyHelper::EmitAssemblyWit<br class=""> PrettyStackTraceString CrashInfo("Code generation");<br class=""> CodeGenPasses.run(*TheModule);<br class=""> }<br class="">+<br class="">+ if (ThinLinkOS)<br class="">+ ThinLinkOS->keep();<br class="">+ if (DwoOS)<br class="">+ DwoOS->keep();<br class=""> }<br class=""><br class=""> Expected<BitcodeModule> clang::FindThinLTOModule(MemoryBufferRef MBRef) {<br class=""><br class="">Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)<br class="">+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon May 21 13:31:59 2018<br class="">@@ -4802,12 +4802,6 @@ void Clang::ConstructJob(Compilation &C,<br class=""> C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));<br class=""> }<br class=""><br class="">- // Handle the debug info splitting at object creation time if we're<br class="">- // creating an object.<br class="">- // TODO: Currently only works on linux with newer objcopy.<br class="">- if (SplitDWARF && Output.getType() == types::TY_Object)<br class="">- SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDWARFOut);<br class="">-<br class=""> if (Arg *A = Args.getLastArg(options::OPT_pg))<br class=""> if (Args.hasArg(options::OPT_fomit_frame_pointer))<br class=""> D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"<br class="">@@ -5464,19 +5458,17 @@ void ClangAs::ConstructJob(Compilation &<br class=""> CmdArgs.push_back("-o");<br class=""> CmdArgs.push_back(Output.getFilename());<br class=""><br class="">+ if (Args.hasArg(options::OPT_gsplit_dwarf) &&<br class="">+ getToolChain().getTriple().isOSLinux()) {<br class="">+ CmdArgs.push_back("-split-dwarf-file");<br class="">+ CmdArgs.push_back(SplitDebugName(Args, Input));<br class="">+ }<br class="">+<br class=""> assert(Input.isFilename() && "Invalid input.");<br class=""> CmdArgs.push_back(Input.getFilename());<br class=""><br class=""> const char *Exec = getToolChain().getDriver().getClangProgramPath();<br class=""> C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));<br class="">-<br class="">- // Handle the debug info splitting at object creation time if we're<br class="">- // creating an object.<br class="">- // TODO: Currently only works on linux with newer objcopy.<br class="">- if (Args.hasArg(options::OPT_gsplit_dwarf) &&<br class="">- getToolChain().getTriple().isOSLinux())<br class="">- SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,<br class="">- SplitDebugName(Args, Input));<br class=""> }<br class=""><br class=""> // Begin OffloadBundler<br class=""><br class="">Modified: cfe/trunk/test/CodeGen/split-debug-filename.c<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-filename.c?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-filename.c?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/CodeGen/split-debug-filename.c (original)<br class="">+++ cfe/trunk/test/CodeGen/split-debug-filename.c Mon May 21 13:31:59 2018<br class="">@@ -1,5 +1,8 @@<br class=""> // RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck %s<br class=""> // 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<br class="">+// RUN: %clang_cc1 -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<br class="">+// RUN: llvm-objdump -section-headers %t.dwo | FileCheck --check-prefix=DWO %s<br class="">+<br class=""> int main (void) {<br class=""> return 0;<br class=""> }<br class="">@@ -10,3 +13,6 @@ int main (void) {<br class=""> // Testing to ensure that the dwo name is not output into the compile unit if<br class=""> // it's for vanilla split-dwarf rather than split-dwarf for implicit modules.<br class=""> // VANILLA-NOT: splitDebugFilename<br class="">+<br class="">+// O-NOT: .dwo<br class="">+// DWO: .dwo<br class=""><br class="">Modified: cfe/trunk/test/Driver/split-debug.c<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Driver/split-debug.c (original)<br class="">+++ cfe/trunk/test/Driver/split-debug.c Mon May 21 13:31:59 2018<br class="">@@ -3,8 +3,7 @@<br class=""> // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t<br class=""> // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s<br class=""> //<br class="">-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"<br class="">-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"<br class="">+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"<br class=""><br class=""><br class=""> // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t<br class=""><br class="">Modified: cfe/trunk/test/Driver/split-debug.s<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.s?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.s?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Driver/split-debug.s (original)<br class="">+++ cfe/trunk/test/Driver/split-debug.s Mon May 21 13:31:59 2018<br class="">@@ -3,8 +3,7 @@<br class=""> // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t<br class=""> // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s<br class=""> //<br class="">-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"<br class="">-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"<br class="">+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"<br class=""><br class=""><br class=""> // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t<br class=""><br class="">Added: cfe/trunk/test/Misc/cc1as-split-dwarf.s<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-split-dwarf.s?rev=332885&view=auto" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-split-dwarf.s?rev=332885&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Misc/cc1as-split-dwarf.s (added)<br class="">+++ cfe/trunk/test/Misc/cc1as-split-dwarf.s Mon May 21 13:31:59 2018<br class="">@@ -0,0 +1,25 @@<br class="">+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 -split-dwarf-file %t2<br class="">+// RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=O %s<br class="">+// RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DWO %s<br class="">+<br class="">+// O-NOT: Contents of section<br class="">+// O: Contents of section .strtab:<br class="">+// O-NOT: Contents of section<br class="">+// O: Contents of section .text:<br class="">+// O-NEXT: 0000 c3<br class="">+// O-NEXT: Contents of section .symtab:<br class="">+// O-NOT: Contents of section<br class="">+.globl main<br class="">+main:<br class="">+.Ltmp1:<br class="">+ret<br class="">+.Ltmp2:<br class="">+<br class="">+// DWO-NOT: Contents of section<br class="">+// DWO: Contents of section .strtab:<br class="">+// DWO-NOT: Contents of section<br class="">+// DWO: Contents of section .foo.dwo:<br class="">+// DWO-NEXT: 0000 01000000<br class="">+// DWO-NOT: Contents of section<br class="">+.section .foo.dwo<br class="">+.long .Ltmp2-.Ltmp1<br class=""><br class="">Modified: cfe/trunk/tools/driver/cc1as_main.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=332885&r1=332884&r2=332885&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=332885&r1=332884&r2=332885&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/tools/driver/cc1as_main.cpp (original)<br class="">+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon May 21 13:31:59 2018<br class="">@@ -97,6 +97,7 @@ struct AssemblerInvocation {<br class=""> llvm::DebugCompressionType CompressDebugSections =<br class=""> llvm::DebugCompressionType::None;<br class=""> std::string MainFileName;<br class="">+ std::string SplitDwarfFile;<br class=""><br class=""> /// @}<br class=""> /// @name Frontend Options<br class="">@@ -247,6 +248,7 @@ bool AssemblerInvocation::CreateFromArgs<br class=""> }<br class=""> Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);<br class=""> Opts.OutputPath = Args.getLastArgValue(OPT_o);<br class="">+ Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);<br class=""> if (Arg *A = Args.getLastArg(OPT_filetype)) {<br class=""> StringRef Name = A->getValue();<br class=""> unsigned OutputType = StringSwitch<unsigned>(Name)<br class="">@@ -282,22 +284,17 @@ bool AssemblerInvocation::CreateFromArgs<br class=""> }<br class=""><br class=""> static std::unique_ptr<raw_fd_ostream><br class="">-getOutputStream(AssemblerInvocation &Opts, DiagnosticsEngine &Diags,<br class="">- bool Binary) {<br class="">- if (Opts.OutputPath.empty())<br class="">- Opts.OutputPath = "-";<br class="">-<br class="">+getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {<br class=""> // Make sure that the Out file gets unlinked from the disk if we get a<br class=""> // SIGINT.<br class="">- if (Opts.OutputPath != "-")<br class="">- sys::RemoveFileOnSignal(Opts.OutputPath);<br class="">+ if (Path != "-")<br class="">+ sys::RemoveFileOnSignal(Path);<br class=""><br class=""> std::error_code EC;<br class=""> auto Out = llvm::make_unique<raw_fd_ostream>(<br class="">- Opts.OutputPath, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));<br class="">+ Path, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));<br class=""> if (EC) {<br class="">- Diags.Report(diag::err_fe_unable_to_open_output) << Opts.OutputPath<br class="">- << EC.message();<br class="">+ Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();<br class=""> return nullptr;<br class=""> }<br class=""><br class="">@@ -342,9 +339,15 @@ static bool ExecuteAssembler(AssemblerIn<br class=""> MAI->setRelaxELFRelocations(Opts.RelaxELFRelocations);<br class=""><br class=""> bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;<br class="">- std::unique_ptr<raw_fd_ostream> FDOS = getOutputStream(Opts, Diags, IsBinary);<br class="">+ if (Opts.OutputPath.empty())<br class="">+ Opts.OutputPath = "-";<br class="">+ std::unique_ptr<raw_fd_ostream> FDOS =<br class="">+ getOutputStream(Opts.OutputPath, Diags, IsBinary);<br class=""> if (!FDOS)<br class=""> return true;<br class="">+ std::unique_ptr<raw_fd_ostream> DwoOS;<br class="">+ if (!Opts.SplitDwarfFile.empty())<br class="">+ DwoOS = getOutputStream(Opts.SplitDwarfFile, Diags, IsBinary);<br class=""><br class=""> // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and<br class=""> // MCObjectFileInfo needs a MCContext reference in order to initialize itself.<br class="">@@ -427,7 +430,9 @@ static bool ExecuteAssembler(AssemblerIn<br class=""> MCTargetOptions MCOptions;<br class=""> std::unique_ptr<MCAsmBackend> MAB(<br class=""> TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));<br class="">- std::unique_ptr<MCObjectWriter> OW = MAB->createObjectWriter(*Out);<br class="">+ std::unique_ptr<MCObjectWriter> OW =<br class="">+ DwoOS ? MAB->createDwoObjectWriter(*Out, *DwoOS)<br class="">+ : MAB->createObjectWriter(*Out);<br class=""><br class=""> Triple T(Opts.Triple);<br class=""> Str.reset(TheTarget->createMCObjectStreamer(<br class="">@@ -476,8 +481,12 @@ static bool ExecuteAssembler(AssemblerIn<br class=""> FDOS.reset();<br class=""><br class=""> // Delete output file if there were errors.<br class="">- if (Failed && Opts.OutputPath != "-")<br class="">- sys::fs::remove(Opts.OutputPath);<br class="">+ if (Failed) {<br class="">+ if (Opts.OutputPath != "-")<br class="">+ sys::fs::remove(Opts.OutputPath);<br class="">+ if (!Opts.SplitDwarfFile.empty() && Opts.SplitDwarfFile != "-")<br class="">+ sys::fs::remove(Opts.SplitDwarfFile);<br class="">+ }<br class=""><br class=""> return Failed;<br class=""> }<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits<br class=""></div></div></blockquote></div><br class=""><div class="">Hi Peter,</div><div class=""><br class=""></div><div class="">Sorry but I had to revert this and the two follow on commits in r332971, r332972, r332973 as it broke several green dragon buildbots. For example: <a href="http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/45399/" class="">http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/45399/</a></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Amara</div></body></html>