summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-08-23 21:30:12 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-08-23 21:30:12 +0000
commitadc0e26bef6e2436363784d711732ec37e6a3db7 (patch)
treeb1bc776b5a5a99d589d1174145a77ee25b4687dc /llvm/tools
parentdcac0dfca99cb1688f67c4a3d68245de3ee569ea (diff)
downloadbcm5719-llvm-adc0e26bef6e2436363784d711732ec37e6a3db7.tar.gz
bcm5719-llvm-adc0e26bef6e2436363784d711732ec37e6a3db7.zip
[ThinLTO] Add caching to the new LTO API
Add the ability to plug a cache on the LTO API. I tried to write such that a linker implementation can control the cache backend. This is intrusive and I'm not totally happy with it, but I can't figure out a better design right now. Differential Revision: https://reviews.llvm.org/D23599 llvm-svn: 279576
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index b2a83213bb8..722eec677ef 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -16,6 +16,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/LTO/Caching.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TargetSelect.h"
@@ -31,6 +32,9 @@ static cl::opt<std::string> OutputFilename("o", cl::Required,
cl::desc("Output filename"),
cl::value_desc("filename"));
+static cl::opt<std::string> CacheDir("cache-dir", cl::desc("Cache Directory"),
+ cl::value_desc("directory"));
+
static cl::opt<bool> SaveTemps("save-temps", cl::desc("Save temporary files"));
static cl::opt<bool>
@@ -187,9 +191,16 @@ int main(int argc, char **argv) {
if (HasErrors)
return 1;
- auto AddOutput = [&](size_t Task) {
+ auto AddOutput =
+ [&](size_t Task) -> std::unique_ptr<lto::NativeObjectOutput> {
std::string Path = OutputFilename + "." + utostr(Task);
- return llvm::make_unique<LTOOutput>(std::move(Path));
+ if (CacheDir.empty())
+ return llvm::make_unique<LTOOutput>(std::move(Path));
+
+ return llvm::make_unique<CacheObjectOutput>(
+ CacheDir, [Path](std::unique_ptr<MemoryBuffer> Buffer) {
+ *LTOOutput(Path).getStream() << Buffer->getBuffer();
+ });
};
check(Lto.run(AddOutput), "LTO::run failed");
OpenPOWER on IntegriCloud