[PATCH] D31021: ELF: Add cache pruning support.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 19:36:23 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298036: ELF: Add cache pruning support. (authored by pcc).
Changed prior to commit:
https://reviews.llvm.org/D31021?vs=91969&id=92101#toc
Repository:
rL LLVM
https://reviews.llvm.org/D31021
Files:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/LTO.cpp
lld/trunk/ELF/Options.td
lld/trunk/test/ELF/lto/cache.ll
Index: lld/trunk/test/ELF/lto/cache.ll
===================================================================
--- lld/trunk/test/ELF/lto/cache.ll
+++ lld/trunk/test/ELF/lto/cache.ll
@@ -3,10 +3,13 @@
; RUN: opt -module-hash -module-summary %s -o %t.o
; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
-; RUN: rm -Rf %t.cache
-; RUN: ld.lld --thinlto-cache-dir=%t.cache -o %t3 %t2.o %t.o
+; RUN: rm -Rf %t.cache && mkdir %t.cache
+; Create a file that will be removed by cache pruning due to age.
+; RUN: touch -d 1970-01-01 %t.cache/foo
+; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=1h -o %t3 %t2.o %t.o
-; RUN: ls %t.cache | count 2
+; Two cached objects, plus a timestamp file, minus the file we removed.
+; RUN: ls %t.cache | count 3
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Index: lld/trunk/ELF/Config.h
===================================================================
--- lld/trunk/ELF/Config.h
+++ lld/trunk/ELF/Config.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/CachePruning.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ELF.h"
@@ -72,6 +73,7 @@
struct Configuration {
InputFile *FirstElf = nullptr;
uint8_t OSABI = 0;
+ llvm::CachePruningPolicy ThinLTOCachePolicy;
llvm::StringMap<uint64_t> SectionStartMap;
llvm::StringRef DynamicLinker;
llvm::StringRef Entry;
Index: lld/trunk/ELF/LTO.cpp
===================================================================
--- lld/trunk/ELF/LTO.cpp
+++ lld/trunk/ELF/LTO.cpp
@@ -163,6 +163,9 @@
},
Cache));
+ if (!Config->ThinLTOCacheDir.empty())
+ pruneCache(Config->ThinLTOCacheDir, Config->ThinLTOCachePolicy);
+
for (unsigned I = 0; I != MaxTasks; ++I) {
if (Buff[I].empty())
continue;
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -585,6 +585,9 @@
Config->Target1Rel = getArg(Args, OPT_target1_rel, OPT_target1_abs, false);
Config->Target2 = getTarget2(Args);
Config->ThinLTOCacheDir = getString(Args, OPT_thinlto_cache_dir);
+ Config->ThinLTOCachePolicy =
+ check(parseCachePruningPolicy(getString(Args, OPT_thinlto_cache_policy)),
+ "--thinlto-cache-policy: invalid cache policy");
Config->ThinLTOJobs = getInteger(Args, OPT_thinlto_jobs, -1u);
Config->Threads = getArg(Args, OPT_threads, OPT_no_threads, true);
Config->Trace = Args.hasArg(OPT_trace);
Index: lld/trunk/ELF/Options.td
===================================================================
--- lld/trunk/ELF/Options.td
+++ lld/trunk/ELF/Options.td
@@ -394,4 +394,6 @@
def save_temps: F<"save-temps">;
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
HelpText<"Path to ThinLTO cached object file directory">;
+def thinlto_cache_policy: S<"thinlto-cache-policy">,
+ HelpText<"Pruning policy for the ThinLTO cache">;
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31021.92101.patch
Type: text/x-patch
Size: 3149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/d912883a/attachment.bin>
More information about the llvm-commits
mailing list