mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-02 13:12:09 +00:00
ELF: Add cache pruning support.
This patch causes us to use pruneCache() to prune the ThinLTO cache after completing LTO. A new flag --thinlto-cache-policy allows users to configure the policy. Differential Revision: https://reviews.llvm.org/D31021 llvm-svn: 298036
This commit is contained in:
parent
8713bf69b6
commit
ee59e43f92
@ -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 VersionDefinition {
|
||||
struct Configuration {
|
||||
InputFile *FirstElf = nullptr;
|
||||
uint8_t OSABI = 0;
|
||||
llvm::CachePruningPolicy ThinLTOCachePolicy;
|
||||
llvm::StringMap<uint64_t> SectionStartMap;
|
||||
llvm::StringRef DynamicLinker;
|
||||
llvm::StringRef Entry;
|
||||
|
@ -585,6 +585,9 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
||||
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);
|
||||
|
@ -163,6 +163,9 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
|
||||
},
|
||||
Cache));
|
||||
|
||||
if (!Config->ThinLTOCacheDir.empty())
|
||||
pruneCache(Config->ThinLTOCacheDir, Config->ThinLTOCachePolicy);
|
||||
|
||||
for (unsigned I = 0; I != MaxTasks; ++I) {
|
||||
if (Buff[I].empty())
|
||||
continue;
|
||||
|
@ -394,4 +394,6 @@ def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
|
||||
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">;
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user