summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-lto2/llvm-lto2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-lto2/llvm-lto2.cpp')
-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