summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-06-14 00:05:56 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-06-14 00:05:56 +0000
commite4147ea1ef4d24e266f71a2700fa7478d2fdc6ba (patch)
treea3c3123cebc1d13386b8e2e9c621e0741c506b5a /llvm/lib/LTO
parent1e4882c8906f3a31031e47dd5010f4078a9c4702 (diff)
downloadbcm5719-llvm-e4147ea1ef4d24e266f71a2700fa7478d2fdc6ba.tar.gz
bcm5719-llvm-e4147ea1ef4d24e266f71a2700fa7478d2fdc6ba.zip
Revert "[Remarks] Refactor optimization remarks setup"
This reverts commit 6e6e3af55bb97e1a4c97375c15a2b0099120c5a7. This breaks greendragon. llvm-svn: 363343
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTO.cpp36
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp3
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp27
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp11
4 files changed, 43 insertions, 34 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index fe1bdfcaa96..882b15525c1 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1338,22 +1338,34 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
}
Expected<std::unique_ptr<ToolOutputFile>>
-lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
- StringRef RemarksPasses, bool RemarksWithHotness,
- int Count) {
- std::string Filename = RemarksFilename;
- if (!Filename.empty() && Count != -1)
+lto::setupOptimizationRemarks(LLVMContext &Context,
+ StringRef LTORemarksFilename,
+ StringRef LTORemarksPasses,
+ bool LTOPassRemarksWithHotness, int Count) {
+ if (LTOPassRemarksWithHotness)
+ Context.setDiagnosticsHotnessRequested(true);
+ if (LTORemarksFilename.empty())
+ return nullptr;
+
+ std::string Filename = LTORemarksFilename;
+ if (Count != -1)
Filename += ".thin." + llvm::utostr(Count) + ".yaml";
- auto ResultOrErr = llvm::setupOptimizationRemarks(
- Context, Filename, RemarksPasses, RemarksWithHotness);
- if (Error E = ResultOrErr.takeError())
- return std::move(E);
+ std::error_code EC;
+ auto DiagnosticFile =
+ llvm::make_unique<ToolOutputFile>(Filename, EC, sys::fs::F_None);
+ if (EC)
+ return errorCodeToError(EC);
+ Context.setRemarkStreamer(llvm::make_unique<RemarkStreamer>(
+ Filename,
+ llvm::make_unique<remarks::YAMLSerializer>(DiagnosticFile->os())));
- if (*ResultOrErr)
- (*ResultOrErr)->keep();
+ if (!LTORemarksPasses.empty())
+ if (Error E = Context.getRemarkStreamer()->setFilter(LTORemarksPasses))
+ return std::move(E);
- return ResultOrErr;
+ DiagnosticFile->keep();
+ return std::move(DiagnosticFile);
}
Expected<std::unique_ptr<ToolOutputFile>>
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 317d0163674..9c2d0ed5d54 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -22,7 +22,6 @@
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/IR/RemarkStreamer.h"
#include "llvm/IR/Verifier.h"
#include "llvm/LTO/LTO.h"
#include "llvm/MC/SubtargetFeature.h"
@@ -33,9 +32,9 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/ThreadPool.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index ebc4cc5794a..f6d955d59c6 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -33,7 +33,6 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassTimingInfo.h"
-#include "llvm/IR/RemarkStreamer.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/LTO/LTO.h"
@@ -81,21 +80,21 @@ cl::opt<bool> LTODiscardValueNames(
#endif
cl::Hidden);
-cl::opt<bool> RemarksWithHotness(
- "lto-pass-remarks-with-hotness",
- cl::desc("With PGO, include profile count in optimization remarks"),
- cl::Hidden);
-
cl::opt<std::string>
- RemarksFilename("lto-pass-remarks-output",
- cl::desc("Output filename for pass remarks"),
- cl::value_desc("filename"));
+ LTORemarksFilename("lto-pass-remarks-output",
+ cl::desc("Output filename for pass remarks"),
+ cl::value_desc("filename"));
cl::opt<std::string>
- RemarksPasses("lto-pass-remarks-filter",
- cl::desc("Only record optimization remarks from passes whose "
- "names match the given regular expression"),
- cl::value_desc("regex"));
+ LTORemarksPasses("lto-pass-remarks-filter",
+ cl::desc("Only record optimization remarks from passes "
+ "whose names match the given regular expression"),
+ cl::value_desc("regex"));
+
+cl::opt<bool> LTOPassRemarksWithHotness(
+ "lto-pass-remarks-with-hotness",
+ cl::desc("With PGO, include profile count in optimization remarks"),
+ cl::Hidden);
cl::opt<std::string> LTOStatsFile(
"lto-stats-file",
@@ -518,7 +517,7 @@ bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
return false;
auto DiagFileOrErr = lto::setupOptimizationRemarks(
- Context, RemarksFilename, RemarksPasses, RemarksWithHotness);
+ Context, LTORemarksFilename, LTORemarksPasses, LTOPassRemarksWithHotness);
if (!DiagFileOrErr) {
errs() << "Error: " << toString(DiagFileOrErr.takeError()) << "\n";
report_fatal_error("Can't get an output file for the remarks");
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 5d9aa8e571b..df18dd3f9ca 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -29,7 +29,6 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/PassTimingInfo.h"
-#include "llvm/IR/RemarkStreamer.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LTO/LTO.h"
@@ -70,9 +69,9 @@ using namespace llvm;
namespace llvm {
// Flags -discard-value-names, defined in LTOCodeGenerator.cpp
extern cl::opt<bool> LTODiscardValueNames;
-extern cl::opt<std::string> RemarksFilename;
-extern cl::opt<std::string> RemarksPasses;
-extern cl::opt<bool> RemarksWithHotness;
+extern cl::opt<std::string> LTORemarksFilename;
+extern cl::opt<std::string> LTORemarksPasses;
+extern cl::opt<bool> LTOPassRemarksWithHotness;
}
namespace {
@@ -1020,8 +1019,8 @@ void ThinLTOCodeGenerator::run() {
Context.setDiscardValueNames(LTODiscardValueNames);
Context.enableDebugTypeODRUniquing();
auto DiagFileOrErr = lto::setupOptimizationRemarks(
- Context, RemarksFilename, RemarksPasses,
- RemarksWithHotness, count);
+ Context, LTORemarksFilename, LTORemarksPasses,
+ LTOPassRemarksWithHotness, count);
if (!DiagFileOrErr) {
errs() << "Error: " << toString(DiagFileOrErr.takeError()) << "\n";
report_fatal_error("ThinLTO: Can't get an output file for the "
OpenPOWER on IntegriCloud