summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/LTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2017-02-10 22:16:17 +0000
committerDavide Italiano <davide@freebsd.org>2017-02-10 22:16:17 +0000
commit46d72b1b7f73e39415122ab262b148683bd60e36 (patch)
tree954647d2020fdb9354a7ff2439036ba1a885480d /llvm/lib/LTO/LTOCodeGenerator.cpp
parentaa5adfa360673c8fff068bd8d6d851e9afb07b2a (diff)
downloadbcm5719-llvm-46d72b1b7f73e39415122ab262b148683bd60e36.tar.gz
bcm5719-llvm-46d72b1b7f73e39415122ab262b148683bd60e36.zip
[lib/LTO] Rework optimization remarkers setup.
This makes this code much more similar to what ThinLTO is using (also API wise), so now we can probably use a single code path instead of copying stuff around. llvm-svn: 294792
Diffstat (limited to 'llvm/lib/LTO/LTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 6af31e61f94..4853751e0e4 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -506,23 +506,22 @@ void LTOCodeGenerator::verifyMergedModuleOnce() {
report_fatal_error("Broken module found, compilation aborted!");
}
-bool LTOCodeGenerator::setupOptimizationRemarks() {
- if (LTORemarksFilename != "") {
- std::error_code EC;
- DiagnosticOutputFile = llvm::make_unique<tool_output_file>(
- LTORemarksFilename, EC, sys::fs::F_None);
- if (EC) {
- emitError(EC.message());
- return false;
- }
- Context.setDiagnosticsOutputFile(
- llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
- }
+Expected<std::unique_ptr<tool_output_file>>
+LTOCodeGenerator::setupOptimizationRemarks() {
+ if (LTORemarksFilename.empty())
+ return nullptr;
+
+ std::error_code EC;
+ auto DiagnosticFile = llvm::make_unique<tool_output_file>(
+ LTORemarksFilename, EC, sys::fs::F_None);
+ if (EC)
+ return errorCodeToError(EC);
+ Context.setDiagnosticsOutputFile(
+ llvm::make_unique<yaml::Output>(DiagnosticFile->os()));
if (LTOPassRemarksWithHotness)
Context.setDiagnosticHotnessRequested(true);
-
- return true;
+ return std::move(DiagnosticFile);
}
void LTOCodeGenerator::finishOptimizationRemarks() {
@@ -540,8 +539,12 @@ bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
if (!this->determineTarget())
return false;
- if (!setupOptimizationRemarks())
- return false;
+ auto DiagFileOrErr = setupOptimizationRemarks();
+ if (!DiagFileOrErr) {
+ errs() << "Error: " << toString(DiagFileOrErr.takeError()) << "\n";
+ report_fatal_error("Can't get an output file for the remarks");
+ }
+ DiagnosticOutputFile = std::move(*DiagFileOrErr);
// We always run the verifier once on the merged module, the `DisableVerify`
// parameter only applies to subsequent verify.
OpenPOWER on IntegriCloud