[PATCH] D37993: [ThinLTO/gold] Implement ThinLTO cache pruning support
Yi Kong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 12:52:42 PDT 2017
kongyi created this revision.
Herald added a subscriber: inglorion.
Repository:
rL LLVM
https://reviews.llvm.org/D37993
Files:
tools/gold/gold-plugin.cpp
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -22,6 +22,7 @@
#include "llvm/LTO/Caching.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Object/Error.h"
+#include "llvm/Support/CachePruning.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
@@ -174,6 +175,8 @@
static std::string thinlto_object_suffix_replace;
// Optional path to a directory for caching ThinLTO objects.
static std::string cache_dir;
+ // Optional pruning policy for ThinLTO caches.
+ static std::string cache_policy;
// Additional options to pass into the code generator.
// Note: This array will contain all plugin options which are not claimed
// as plugin exclusive to pass to the code generator.
@@ -222,6 +225,8 @@
"thinlto-object-suffix-replace expects 'old;new' format");
} else if (opt.startswith("cache-dir=")) {
cache_dir = opt.substr(strlen("cache-dir="));
+ } else if (opt.startswith("cache-policy=")) {
+ cache_policy = opt.substr(strlen("cache-policy="));
} else if (opt.size() == 2 && opt[0] == 'O') {
if (opt[1] < '0' || opt[1] > '3')
message(LDPL_FATAL, "Optimization level must be between 0 and 3");
@@ -971,5 +976,11 @@
EC.message().c_str());
}
+ // Prune cache
+ if (!options::cache_dir.empty()) {
+ CachePruningPolicy policy = check(parseCachePruningPolicy(options::cache_policy));
+ pruneCache(options::cache_dir, policy);
+ }
+
return LDPS_OK;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37993.115707.patch
Type: text/x-patch
Size: 1638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170918/6eade5db/attachment.bin>
More information about the llvm-commits
mailing list