File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1020,10 +1020,37 @@ void CodeGenAction::ExecuteAction() {
10201020 Ctx.setInlineAsmDiagnosticHandler (BitcodeInlineAsmDiagHandler,
10211021 &CI.getDiagnostics ());
10221022
1023+ const CodeGenOptions &CodeGenOpts = CI.getCodeGenOpts ();
1024+ DiagnosticsEngine &Diags = CI.getDiagnostics ();
1025+ std::unique_ptr<llvm::ToolOutputFile> OptRecordFile;
1026+
1027+ if (!CodeGenOpts.OptRecordFile .empty ()) {
1028+ std::error_code EC;
1029+ OptRecordFile =
1030+ llvm::make_unique<llvm::ToolOutputFile>(CodeGenOpts.OptRecordFile ,
1031+ EC, sys::fs::F_None);
1032+
1033+ if (EC) {
1034+ Diags.Report (diag::err_cannot_open_file) <<
1035+ CodeGenOpts.OptRecordFile << EC.message ();
1036+ return ;
1037+ }
1038+
1039+ Ctx.setDiagnosticsOutputFile (
1040+ llvm::make_unique<yaml::Output>(OptRecordFile->os ()));
1041+
1042+ if (CodeGenOpts.getProfileUse () != CodeGenOptions::ProfileNone)
1043+ Ctx.setDiagnosticsHotnessRequested (true );
1044+ }
1045+
10231046 EmitBackendOutput (CI.getDiagnostics (), CI.getHeaderSearchOpts (),
10241047 CI.getCodeGenOpts (), TargetOpts, CI.getLangOpts (),
10251048 CI.getTarget ().getDataLayout (), TheModule.get (), BA,
10261049 std::move (OS));
1050+
1051+ if (OptRecordFile)
1052+ OptRecordFile->keep ();
1053+
10271054 return ;
10281055 }
10291056
You can’t perform that action at this time.
0 commit comments