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 @@ -1033,10 +1033,37 @@ void CodeGenAction::ExecuteAction() {
10331033 Ctx.setInlineAsmDiagnosticHandler (BitcodeInlineAsmDiagHandler,
10341034 &CI.getDiagnostics ());
10351035
1036+ const CodeGenOptions &CodeGenOpts = CI.getCodeGenOpts ();
1037+ DiagnosticsEngine &Diags = CI.getDiagnostics ();
1038+ std::unique_ptr<llvm::ToolOutputFile> OptRecordFile;
1039+
1040+ if (!CodeGenOpts.OptRecordFile .empty ()) {
1041+ std::error_code EC;
1042+ OptRecordFile =
1043+ llvm::make_unique<llvm::ToolOutputFile>(CodeGenOpts.OptRecordFile ,
1044+ EC, sys::fs::F_None);
1045+
1046+ if (EC) {
1047+ Diags.Report (diag::err_cannot_open_file) <<
1048+ CodeGenOpts.OptRecordFile << EC.message ();
1049+ return ;
1050+ }
1051+
1052+ Ctx.setDiagnosticsOutputFile (
1053+ llvm::make_unique<yaml::Output>(OptRecordFile->os ()));
1054+
1055+ if (CodeGenOpts.getProfileUse () != CodeGenOptions::ProfileNone)
1056+ Ctx.setDiagnosticsHotnessRequested (true );
1057+ }
1058+
10361059 EmitBackendOutput (CI.getDiagnostics (), CI.getHeaderSearchOpts (),
10371060 CI.getCodeGenOpts (), TargetOpts, CI.getLangOpts (),
10381061 CI.getTarget ().getDataLayout (), TheModule.get (), BA,
10391062 std::move (OS));
1063+
1064+ if (OptRecordFile)
1065+ OptRecordFile->keep ();
1066+
10401067 return ;
10411068 }
10421069
You can’t perform that action at this time.
0 commit comments