diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-04-20 10:18:36 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-04-20 10:18:36 +0000 |
commit | d4332eb3b792f614d77d4e2a07e71a8cb42267a2 (patch) | |
tree | 1d1adb8ccc06bafe4e020006c2bfa609dbd356c5 /llvm/lib/LTO/LTO.cpp | |
parent | 4d79c580ce0dba69b240fb24110ff0dd88911cb4 (diff) | |
download | llvm-d4332eb3b792f614d77d4e2a07e71a8cb42267a2.zip llvm-d4332eb3b792f614d77d4e2a07e71a8cb42267a2.tar.gz llvm-d4332eb3b792f614d77d4e2a07e71a8cb42267a2.tar.bz2 |
[LTO] Add stats-file option to LTO/Config.h.
This patch adds a StatsFile option to LTO/Config.h and updates both
LLVMGold and llvm-lto2 to set it.
Reviewers: MatzeB, tejohnson, espindola
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D45531
llvm-svn: 330411
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index e4dffbf..186e3d2 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/LTO/LTO.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeReader.h" @@ -791,9 +792,26 @@ Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) { }; computeDeadSymbols(ThinLTO.CombinedIndex, GUIDPreservedSymbols, isPrevailing); - if (auto E = runRegularLTO(AddStream)) - return E; - return runThinLTO(AddStream, Cache); + // Setup output file to emit statistics. + std::unique_ptr<ToolOutputFile> StatsFile = nullptr; + if (!Conf.StatsFile.empty()) { + EnableStatistics(false); + std::error_code EC; + StatsFile = + llvm::make_unique<ToolOutputFile>(Conf.StatsFile, EC, sys::fs::F_None); + if (EC) + return errorCodeToError(EC); + StatsFile->keep(); + } + + Error Result = runRegularLTO(AddStream); + if (!Result) + Result = runThinLTO(AddStream, Cache); + + if (StatsFile) + PrintStatisticsJSON(StatsFile->os()); + + return Result; } Error LTO::runRegularLTO(AddStreamFn AddStream) { |