aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTO.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-06-13 21:46:57 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-06-13 21:46:57 +0000
commit6e6e3af55bb97e1a4c97375c15a2b0099120c5a7 (patch)
tree4dc151e7deced1ab1a3ebab57fd420e8a0cf0138 /llvm/lib/LTO/LTO.cpp
parenta5b12be60f98012dc8b75933d6dc1210bd742054 (diff)
downloadllvm-6e6e3af55bb97e1a4c97375c15a2b0099120c5a7.zip
llvm-6e6e3af55bb97e1a4c97375c15a2b0099120c5a7.tar.gz
llvm-6e6e3af55bb97e1a4c97375c15a2b0099120c5a7.tar.bz2
[Remarks] Refactor optimization remarks setup
* Add a common function to setup opt-remarks * Rename common options to the same names * Add error types to distinguish between file errors and regex errors llvm-svn: 363328
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r--llvm/lib/LTO/LTO.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 882b155..fe1bdfc 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1338,34 +1338,22 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
}
Expected<std::unique_ptr<ToolOutputFile>>
-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)
+lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
+ StringRef RemarksPasses, bool RemarksWithHotness,
+ int Count) {
+ std::string Filename = RemarksFilename;
+ if (!Filename.empty() && Count != -1)
Filename += ".thin." + llvm::utostr(Count) + ".yaml";
- 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())));
+ auto ResultOrErr = llvm::setupOptimizationRemarks(
+ Context, Filename, RemarksPasses, RemarksWithHotness);
+ if (Error E = ResultOrErr.takeError())
+ return std::move(E);
- if (!LTORemarksPasses.empty())
- if (Error E = Context.getRemarkStreamer()->setFilter(LTORemarksPasses))
- return std::move(E);
+ if (*ResultOrErr)
+ (*ResultOrErr)->keep();
- DiagnosticFile->keep();
- return std::move(DiagnosticFile);
+ return ResultOrErr;
}
Expected<std::unique_ptr<ToolOutputFile>>