[llvm] r294807 - [LTO] Share the optimization remarks setup between Thin/Full LTO.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 15:49:38 PST 2017
Author: davide
Date: Fri Feb 10 17:49:38 2017
New Revision: 294807
URL: http://llvm.org/viewvc/llvm-project?rev=294807&view=rev
Log:
[LTO] Share the optimization remarks setup between Thin/Full LTO.
Modified:
llvm/trunk/include/llvm/LTO/LTO.h
llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
Modified: llvm/trunk/include/llvm/LTO/LTO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTO.h?rev=294807&r1=294806&r2=294807&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTO.h (original)
+++ llvm/trunk/include/llvm/LTO/LTO.h Fri Feb 10 17:49:38 2017
@@ -26,6 +26,7 @@
#include "llvm/Linker/IRMover.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/thread.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
@@ -69,6 +70,11 @@ std::string getThinLTOOutputFile(const s
const std::string &OldPrefix,
const std::string &NewPrefix);
+/// Setup optimization remarks.
+Expected<std::unique_ptr<tool_output_file>>
+setupOptimizationRemarks(LLVMContext &Context, StringRef LTORemarksFilename,
+ bool LTOPassRemarksWithHotness, int Count = -1);
+
class LTO;
struct SymbolResolution;
class ThinBackendProc;
Modified: llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h?rev=294807&r1=294806&r2=294807&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h (original)
+++ llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h Fri Feb 10 17:49:38 2017
@@ -207,7 +207,6 @@ private:
void emitError(const std::string &ErrMsg);
void emitWarning(const std::string &ErrMsg);
- Expected<std::unique_ptr<tool_output_file>> setupOptimizationRemarks();
void finishOptimizationRemarks();
LLVMContext &Context;
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=294807&r1=294806&r2=294807&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Fri Feb 10 17:49:38 2017
@@ -987,3 +987,27 @@ Error LTO::runThinLTO(AddStreamFn AddStr
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);
+}
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=294807&r1=294806&r2=294807&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Fri Feb 10 17:49:38 2017
@@ -35,6 +35,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
+#include "llvm/LTO/LTO.h"
#include "llvm/LTO/legacy/LTOModule.h"
#include "llvm/LTO/legacy/UpdateCompilerUsed.h"
#include "llvm/Linker/Linker.h"
@@ -506,24 +507,6 @@ void LTOCodeGenerator::verifyMergedModul
report_fatal_error("Broken module found, compilation aborted!");
}
-
-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 std::move(DiagnosticFile);
-}
-
void LTOCodeGenerator::finishOptimizationRemarks() {
if (DiagnosticOutputFile) {
DiagnosticOutputFile->keep();
@@ -539,7 +522,8 @@ bool LTOCodeGenerator::optimize(bool Dis
if (!this->determineTarget())
return false;
- auto DiagFileOrErr = setupOptimizationRemarks();
+ auto DiagFileOrErr = lto::setupOptimizationRemarks(
+ Context, LTORemarksFilename, LTOPassRemarksWithHotness);
if (!DiagFileOrErr) {
errs() << "Error: " << toString(DiagFileOrErr.takeError()) << "\n";
report_fatal_error("Can't get an output file for the remarks");
Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=294807&r1=294806&r2=294807&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Fri Feb 10 17:49:38 2017
@@ -73,27 +73,6 @@ namespace {
static cl::opt<int>
ThreadCount("threads", cl::init(llvm::heavyweight_hardware_concurrency()));
-Expected<std::unique_ptr<tool_output_file>>
-setupOptimizationRemarks(LLVMContext &Ctx, int Count) {
- if (LTOPassRemarksWithHotness)
- Ctx.setDiagnosticHotnessRequested(true);
-
- if (LTORemarksFilename.empty())
- return nullptr;
-
- std::string FileName =
- LTORemarksFilename + ".thin." + llvm::utostr(Count) + ".yaml";
- std::error_code EC;
- auto DiagnosticOutputFile =
- llvm::make_unique<tool_output_file>(FileName, EC, sys::fs::F_None);
- if (EC)
- return errorCodeToError(EC);
- Ctx.setDiagnosticsOutputFile(
- llvm::make_unique<yaml::Output>(DiagnosticOutputFile->os()));
- DiagnosticOutputFile->keep();
- return std::move(DiagnosticOutputFile);
-}
-
// Simple helper to save temporary files for debug.
static void saveTempBitcode(const Module &TheModule, StringRef TempDir,
unsigned count, StringRef Suffix) {
@@ -988,7 +967,8 @@ void ThinLTOCodeGenerator::run() {
LLVMContext Context;
Context.setDiscardValueNames(LTODiscardValueNames);
Context.enableDebugTypeODRUniquing();
- auto DiagFileOrErr = setupOptimizationRemarks(Context, count);
+ auto DiagFileOrErr = lto::setupOptimizationRemarks(
+ Context, LTORemarksFilename, LTOPassRemarksWithHotness, count);
if (!DiagFileOrErr) {
errs() << "Error: " << toString(DiagFileOrErr.takeError()) << "\n";
report_fatal_error("ThinLTO: Can't get an output file for the "
More information about the llvm-commits
mailing list