From b8aeec46b7fb0a88c74208a577dc0b441ed03cfe Mon Sep 17 00:00:00 2001 From: Ekaterina Romanova Date: Fri, 2 Mar 2018 03:51:27 +0000 Subject: [ThinLTO] Added a couple of C LTO API interfaces to control the cache policy. - thinlto_codegen_set_cache_size_bytes to control the absolute size of cache directory. - thinlto_codegen_set_cache_size_files the size and amount of files in cache directory. These functions have been supported in C++ LTO API for a long time, but were absent in C LTO API. Differential Revision: https://reviews.llvm.org/D42446 llvm-svn: 326537 --- llvm/include/llvm-c/lto.h | 24 +++++++++++++++++++++- .../include/llvm/LTO/legacy/ThinLTOCodeGenerator.h | 15 ++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'llvm/include') diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h index 4eee5f1f113..65d172dea18 100644 --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -44,7 +44,7 @@ typedef bool lto_bool_t; * @{ */ -#define LTO_API_VERSION 21 +#define LTO_API_VERSION 22 /** * \since prior to LTO_API_VERSION=3 @@ -816,6 +816,28 @@ extern void thinlto_codegen_set_final_cache_size_relative_to_available_space( extern void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg, unsigned expiration); +/** + * Sets the maximum size of the cache directory (in bytes). A value over the + * amount of available space on the disk will be reduced to the amount of + * available space. An unspecified default value will be applied. A value of 0 + * will be ignored. + * + * \since LTO_API_VERSION=22 + */ +extern void thinlto_codegen_set_cache_size_bytes(thinlto_code_gen_t cg, + unsigned max_size_bytes); + +/** + * Sets the maximum number of files in the cache directory. An unspecified + * default value will be applied. A value of 0 will be ignored. + * + * \since LTO_API_VERSION=22 + */ +extern void thinlto_codegen_set_cache_size_files(thinlto_code_gen_t cg, + unsigned max_size_files); + + + /** * @} // endgroup LLVMCTLTO_CACHING */ diff --git a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h index e47456445f0..b32a972542c 100644 --- a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h @@ -184,6 +184,21 @@ public: CacheOptions.Policy.MaxSizePercentageOfAvailableSpace = Percentage; } + /// Cache policy: the maximum size for the cache directory in bytes. A value + /// over the amount of available space on the disk will be reduced to the + /// amount of available space. A value of 0 will be ignored. + void setCacheMaxSizeBytes(unsigned MaxSizeBytes) { + if (MaxSizeBytes) + CacheOptions.Policy.MaxSizeBytes = MaxSizeBytes; + } + + /// Cache policy: the maximum number of files in the cache directory. A value + /// of 0 will be ignored. + void setCacheMaxSizeFiles(unsigned MaxSizeFiles) { + if (MaxSizeFiles) + CacheOptions.Policy.MaxSizeFiles = MaxSizeFiles; + } + /**@}*/ /// Set the path to a directory where to save temporaries at various stages of -- cgit v1.2.3