mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
[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
This commit is contained in:
parent
3166dbbf8b
commit
a96a2e7ce2
@ -41,6 +41,7 @@
|
|||||||
#include "llvm/ADT/StringSet.h"
|
#include "llvm/ADT/StringSet.h"
|
||||||
#include "llvm/IR/GlobalValue.h"
|
#include "llvm/IR/GlobalValue.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/ToolOutputFile.h"
|
#include "llvm/Support/ToolOutputFile.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
@ -206,7 +207,7 @@ private:
|
|||||||
void emitError(const std::string &ErrMsg);
|
void emitError(const std::string &ErrMsg);
|
||||||
void emitWarning(const std::string &ErrMsg);
|
void emitWarning(const std::string &ErrMsg);
|
||||||
|
|
||||||
bool setupOptimizationRemarks();
|
Expected<std::unique_ptr<tool_output_file>> setupOptimizationRemarks();
|
||||||
void finishOptimizationRemarks();
|
void finishOptimizationRemarks();
|
||||||
|
|
||||||
LLVMContext &Context;
|
LLVMContext &Context;
|
||||||
|
@ -506,23 +506,22 @@ void LTOCodeGenerator::verifyMergedModuleOnce() {
|
|||||||
report_fatal_error("Broken module found, compilation aborted!");
|
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)
|
if (LTOPassRemarksWithHotness)
|
||||||
Context.setDiagnosticHotnessRequested(true);
|
Context.setDiagnosticHotnessRequested(true);
|
||||||
|
return std::move(DiagnosticFile);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTOCodeGenerator::finishOptimizationRemarks() {
|
void LTOCodeGenerator::finishOptimizationRemarks() {
|
||||||
@ -540,8 +539,12 @@ bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
|
|||||||
if (!this->determineTarget())
|
if (!this->determineTarget())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setupOptimizationRemarks())
|
auto DiagFileOrErr = setupOptimizationRemarks();
|
||||||
return false;
|
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`
|
// We always run the verifier once on the merged module, the `DisableVerify`
|
||||||
// parameter only applies to subsequent verify.
|
// parameter only applies to subsequent verify.
|
||||||
|
Loading…
Reference in New Issue
Block a user