Index: test/Transforms/Util/libcalls-opt-remarks.ll =================================================================== --- test/Transforms/Util/libcalls-opt-remarks.ll +++ test/Transforms/Util/libcalls-opt-remarks.ll @@ -1,8 +1,9 @@ -; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S -pass-remarks=instcombine \ -; RUN: 2>&1 | FileCheck %s +; RUN: opt < %s -instcombine -o /dev/null -pass-remarks-output=%t -S \ +; RUN: -pass-remarks=instcombine 2>&1 | FileCheck %s +; RUN: cat %t | FileCheck -check-prefix=YAML %s +; RUN: opt < %s -passes='require,instcombine' -o /dev/null \ +; RUN: -pass-remarks-output=%t -S -pass-remarks=instcombine 2>&1 | FileCheck %s ; RUN: cat %t | FileCheck -check-prefix=YAML %s -; RUN: opt < %s -passes='require,instcombine' -o /dev/null -S -pass-remarks=instcombine \ -; RUN: 2>&1 | FileCheck %s ; CHECK: remark: libcalls-opt-remarks.c:10:10: folded strlen(select) to select of constants{{$}} ; CHECK-NOT: remark: Index: tools/opt/NewPMDriver.h =================================================================== --- tools/opt/NewPMDriver.h +++ tools/opt/NewPMDriver.h @@ -53,8 +53,8 @@ /// nullptr. bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, tool_output_file *Out, tool_output_file *ThinLinkOut, - StringRef PassPipeline, opt_tool::OutputKind OK, - opt_tool::VerifierKind VK, + tool_output_file *OptRemarkFile, StringRef PassPipeline, + opt_tool::OutputKind OK, opt_tool::VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex, bool EmitModuleHash); Index: tools/opt/NewPMDriver.cpp =================================================================== --- tools/opt/NewPMDriver.cpp +++ tools/opt/NewPMDriver.cpp @@ -170,6 +170,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, tool_output_file *Out, tool_output_file *ThinLTOLinkOut, + tool_output_file *OptRemarkFile, StringRef PassPipeline, OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, @@ -266,5 +267,9 @@ if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut) ThinLTOLinkOut->keep(); } + + if (OptRemarkFile) + OptRemarkFile->keep(); + return true; } Index: tools/opt/opt.cpp =================================================================== --- tools/opt/opt.cpp +++ tools/opt/opt.cpp @@ -430,17 +430,17 @@ if (PassRemarksHotnessThreshold) Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold); - std::unique_ptr YamlFile; + std::unique_ptr OptRemarkFile; if (RemarksFilename != "") { std::error_code EC; - YamlFile = llvm::make_unique(RemarksFilename, EC, - sys::fs::F_None); + OptRemarkFile = llvm::make_unique(RemarksFilename, EC, + sys::fs::F_None); if (EC) { errs() << EC.message() << '\n'; return 1; } Context.setDiagnosticsOutputFile( - llvm::make_unique(YamlFile->os())); + llvm::make_unique(OptRemarkFile->os())); } // Load the input module... @@ -540,7 +540,8 @@ // string. Hand off the rest of the functionality to the new code for that // layer. return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(), - PassPipeline, OK, VK, PreserveAssemblyUseListOrder, + OptRemarkFile.get(), PassPipeline, OK, VK, + PreserveAssemblyUseListOrder, PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash) ? 0 @@ -767,8 +768,8 @@ "the compile-twice option\n"; Out->os() << BOS->str(); Out->keep(); - if (YamlFile) - YamlFile->keep(); + if (OptRemarkFile) + OptRemarkFile->keep(); return 1; } Out->os() << BOS->str(); @@ -778,8 +779,8 @@ if (!NoOutput || PrintBreakpoints) Out->keep(); - if (YamlFile) - YamlFile->keep(); + if (OptRemarkFile) + OptRemarkFile->keep(); if (ThinLinkOut) ThinLinkOut->keep();