llvm.org GIT mirror llvm / 51f8033
Allow 0 to be a valid value pruning interval in C LTO API. Value 0 will cause garbage collector to run. This matches the behavior in C++ LTO API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325303 91177308-0d34-0410-b5e6-96231b3b80d8 Ekaterina Romanova 2 years ago
4 changed file(s) with 28 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
130130 * To avoid filling the disk space, a few knobs are provided:
131131 * - The pruning interval limit the frequency at which the garbage collector
132132 * will try to scan the cache directory to prune it from expired entries.
133 * Setting to -1 disable the pruning (default).
133 * Setting to -1 disable the pruning (default). Setting to 0 will force
134 * pruning to occur.
134135 * - The pruning expiration time indicates to the garbage collector how old
135136 * an entry needs to be to be removed.
136137 * - Finally, the garbage collector can be instructed to prune the cache till
148149 void setCacheDir(std::string Path) { CacheOptions.Path = std::move(Path); }
149150
150151 /// Cache policy: interval (seconds) between two prunes of the cache. Set to a
151 /// negative value to disable pruning. A value of 0 will be ignored.
152 /// negative value to disable pruning. A value of 0 will force pruning to
153 /// occur.
152154 void setCachePruningInterval(int Interval) {
153 if (Interval == 0)
154 return;
155155 if(Interval < 0)
156156 CacheOptions.Policy.Interval.reset();
157157 else
783783 /**
784784 * Sets the cache pruning interval (in seconds). A negative value disables the
785785 * pruning. An unspecified default value will be applied, and a value of 0 will
786 * be ignored.
786 * force prunning to occur.
787787 *
788788 * \since LTO_API_VERSION=18
789789 */
5858 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval -1
5959 ; RUN: ls %t.cache/llvmcache-foo
6060
61 ; Verify that the pruner doesn't run and a cache file is not deleted when:
62 ; default values for pruning interval and cache expiration are used,
63 ; llvmcache.timestamp is current,
64 ; cache file is older than default cache expiration value.
65 ; RUN: rm -Rf %t.cache && mkdir %t.cache
66 ; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
67 ; RUN: touch %t.cache/llvmcache.timestamp
68 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
69 ; RUN: ls %t.cache/llvmcache-foo
70
71 ; Verify that the pruner runs and a cache file is deleted when:
72 ; pruning interval has value 0 (i.e. run garbage collector now)
73 ; default value for cache expiration is used,
74 ; llvmcache.timestamp is current,
75 ; cache file is older than default cache expiration value.
76 ; RUN: rm -Rf %t.cache && mkdir %t.cache
77 ; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
78 ; RUN: touch %t.cache/llvmcache.timestamp
79 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval 0
80 ; RUN: not ls %t.cache/llvmcache-foo
81
6182 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6283 target triple = "x86_64-apple-macosx10.11.0"
6384
156156 ThinLTOCacheDir("thinlto-cache-dir", cl::desc("Enable ThinLTO caching."));
157157
158158 static cl::opt
159 ThinLTOCachePruningInterval("thinlto-cache-pruning-interval", cl::desc("Set ThinLTO cache pruning interval."));
159 ThinLTOCachePruningInterval("thinlto-cache-pruning-interval",
160 cl::init(1200), cl::desc("Set ThinLTO cache pruning interval."));
160161
161162 static cl::opt ThinLTOSaveTempsPrefix(
162163 "thinlto-save-temps",