[LTO] Share the optimization remarks setup between Thin/Full LTO.

llvm-svn: 294807
This commit is contained in:
Davide Italiano
2017-02-10 23:49:38 +00:00
parent c18de74165
commit 690ed9dec7
5 changed files with 35 additions and 42 deletions

View File

@@ -987,3 +987,27 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
return BackendProc->wait();
}
Expected<std::unique_ptr<tool_output_file>>
lto::setupOptimizationRemarks(LLVMContext &Context,
StringRef LTORemarksFilename,
bool LTOPassRemarksWithHotness, int Count) {
if (LTORemarksFilename.empty())
return nullptr;
std::string Filename = LTORemarksFilename;
if (Count != -1)
Filename += ".thin." + llvm::utostr(Count) + ".yaml";
std::error_code EC;
auto DiagnosticFile =
llvm::make_unique<tool_output_file>(Filename, EC, sys::fs::F_None);
if (EC)
return errorCodeToError(EC);
Context.setDiagnosticsOutputFile(
llvm::make_unique<yaml::Output>(DiagnosticFile->os()));
if (LTOPassRemarksWithHotness)
Context.setDiagnosticHotnessRequested(true);
DiagnosticFile->keep();
return std::move(DiagnosticFile);
}