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/opt.cpp =================================================================== --- tools/opt/opt.cpp +++ tools/opt/opt.cpp @@ -433,14 +433,14 @@ std::unique_ptr YamlFile; 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... @@ -539,12 +539,17 @@ // The user has asked to use the new pass manager and provided a pipeline // 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, - PreserveBitcodeUseListOrder, EmitSummaryIndex, - EmitModuleHash) - ? 0 - : 1; + if (runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(), + PassPipeline, OK, VK, PreserveAssemblyUseListOrder, + PreserveBitcodeUseListOrder, EmitSummaryIndex, + EmitModuleHash)) { + + if (OptRemarkFile) + OptRemarkFile->keep(); + + return 0; + } else + return 1; } // Create a PassManager to hold and optimize the collection of passes we are @@ -767,8 +772,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 +783,8 @@ if (!NoOutput || PrintBreakpoints) Out->keep(); - if (YamlFile) - YamlFile->keep(); + if (OptRemarkFile) + OptRemarkFile->keep(); if (ThinLinkOut) ThinLinkOut->keep();