Skip to content

Commit ca875cb

Browse files
committed
[ThinLTO] a ThinLTO warning is added if cache_size_bytes or cache_size_files is too small for the current link job. The warning recommends the user to consider adjusting --thinlto-cache-policy.
A specific case for ThinLTO cache pruning is that the current build is huge, and the cache wasn't big enough to hold the intermediate object files of that build. So in doing that build, a file would be cached, and later in that same build it would be evicted. This was significantly decreasing the effectiveness of the cache. By giving this warning, the user could identify the required cache size/files and improve ThinLTO link speed. Differential Revision: https://reviews.llvm.org/D135590
1 parent eb05da5 commit ca875cb

File tree

11 files changed

+230
-8
lines changed

11 files changed

+230
-8
lines changed

Diff for: lld/COFF/LTO.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ std::vector<InputFile *> BitcodeCompiler::compile(COFFLinkerContext &ctx) {
202202
}
203203

204204
if (!config->ltoCache.empty())
205-
pruneCache(config->ltoCache, config->ltoCachePolicy);
205+
pruneCache(config->ltoCache, config->ltoCachePolicy, files);
206206

207207
std::vector<InputFile *> ret;
208208
for (unsigned i = 0; i != maxTasks; ++i) {

Diff for: lld/ELF/LTO.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
367367
}
368368

369369
if (!config->thinLTOCacheDir.empty())
370-
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy);
370+
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
371371

372372
if (!config->ltoObjPath.empty()) {
373373
saveBuffer(buf[0], config->ltoObjPath);

Diff for: lld/MachO/LTO.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ std::vector<ObjFile *> BitcodeCompiler::compile() {
141141
cache));
142142

143143
if (!config->thinLTOCacheDir.empty())
144-
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy);
144+
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
145145

146146
// In ThinLTO mode, Clang passes a temporary directory in -object_path_lto,
147147
// while the argument is a single file in FullLTO mode.

Diff for: lld/test/COFF/lto-cache-warnings.ll

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; REQUIRES: x86, shell
2+
3+
; RUN: opt -module-hash -module-summary %s -o %t.o
4+
; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o
5+
6+
; RUN: rm -rf %t && mkdir %t
7+
8+
;; Check cache policies of the number of files.
9+
;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning.
10+
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_files=0 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck --implicit-check-not=warning: %s
11+
;; Case 2: If the total number of the files created by the current link job is less than the maximum number of files, there is no warning.
12+
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_files=3 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --implicit-check-not=warning:
13+
;; Case 3: If the total number of the files created by the current link job exceeds the maximum number of files, a warning is given.
14+
; RUN: lld-link /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_files=1 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefix=NUM
15+
16+
;; Check cache policies of the cache size.
17+
;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning.
18+
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=0 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --implicit-check-not=warning:
19+
20+
;; Get the total size of created cache files.
21+
; RUN: rm -rf %t && mkdir %t && cd %t
22+
; RUN: lld-link /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=32k /out:%t3 /entry:main %t2.o %t.o 2>&1
23+
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
24+
25+
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
26+
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --implicit-check-not=warning:
27+
28+
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
29+
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefix=SIZE
30+
31+
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
32+
; RUN: lld-link /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_files=1:cache_size_bytes=1 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE
33+
34+
; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy
35+
; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy
36+
37+
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
38+
target triple = "x86_64-pc-windows-msvc"
39+
40+
define void @globalfunc() #0 {
41+
entry:
42+
ret void
43+
}

Diff for: lld/test/ELF/lto/cache-warnings.ll

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; REQUIRES: x86, shell
2+
3+
; RUN: opt -module-hash -module-summary %s -o %t.o
4+
; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
5+
6+
; RUN: rm -rf %t && mkdir %t
7+
8+
;; Check cache policies of the number of files.
9+
;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning.
10+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
11+
;; Case 2: If the total number of the files created by the current link job is less than the maximum number of files, there is no warning.
12+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=3 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
13+
;; Case 3: If the total number of the files created by the current link job exceeds the maximum number of files, a warning is given.
14+
; RUN: ld.lld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,WARN
15+
16+
;; Check cache policies of the cache size.
17+
;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning.
18+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
19+
20+
;; Get the total size of created cache files.
21+
; RUN: rm -rf %t && mkdir %t && cd %t
22+
; RUN: ld.lld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t2.o %t.o -o %t3 2>&1
23+
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
24+
25+
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
26+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
27+
28+
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
29+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
30+
31+
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
32+
; RUN: ld.lld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN
33+
34+
; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy
35+
; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy
36+
; WARN-NOT: warning: ThinLTO cache pruning happens{{.*}}--thinlto-cache-policy
37+
38+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39+
target triple = "x86_64-unknown-linux-gnu"
40+
41+
define void @globalfunc() {
42+
entry:
43+
ret void
44+
}

Diff for: lld/test/MachO/lto-cache-warnings.ll

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
; REQUIRES: x86, shell
2+
3+
; RUN: rm -rf %t; split-file %s %t
4+
; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o
5+
; RUN: opt -module-hash -module-summary %t/bar.ll -o %t/bar.o
6+
7+
;; Check cache policies of the number of files.
8+
;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning.
9+
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_files=0 -o %t/test %t/foo.o %t/bar.o 2>&1 | FileCheck %s --implicit-check-not=warning:
10+
;; Case 2: If the total number of the files created by the current link job is less than the maximum number of files, there is no warning.
11+
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_files=3 %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --implicit-check-not=warning:
12+
;; Case 3: If the total number of the files created by the current link job exceeds the maximum number of files, a warning is given.
13+
; RUN: %lld -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1 %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=NUM,WARN
14+
15+
;; Check cache policies of the cache size.
16+
;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning.
17+
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=0 %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --implicit-check-not=warning:
18+
19+
;; Get the total size of created cache files.
20+
; RUN: cd %t
21+
; RUN: %lld -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t/foo.o %t/bar.o -o %t/test 2>&1
22+
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
23+
24+
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
25+
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --implicit-check-not=warning:
26+
27+
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
28+
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
29+
30+
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
31+
; RUN: %lld -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN
32+
33+
; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy
34+
; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy
35+
; WARN-NOT: warning: ThinLTO cache pruning happens{{.*}}--thinlto-cache-policy
36+
37+
;--- foo.ll
38+
39+
target triple = "x86_64-apple-macosx10.15.0"
40+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41+
42+
define void @globalfunc() #0 {
43+
entry:
44+
ret void
45+
}
46+
47+
48+
;--- bar.ll
49+
50+
target triple = "x86_64-apple-macosx10.15.0"
51+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
52+
53+
define i32 @main() {
54+
entry:
55+
call void (...) @globalfunc()
56+
ret i32 0
57+
}
58+
59+
declare void @globalfunc(...)

Diff for: lld/test/wasm/lto/cache-warnings.ll

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; REQUIRES: shell
2+
3+
; RUN: opt -module-hash -module-summary %s -o %t.o
4+
; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
5+
6+
; RUN: rm -rf %t && mkdir %t
7+
8+
;; Check cache policies of the number of files.
9+
;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning.
10+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
11+
;; Case 2: If the total number of the files created by the current link job is less than the maximum number of files, there is no warning.
12+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=3 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
13+
;; Case 3: If the total number of the files created by the current link job exceeds the maximum number of files, a warning is given.
14+
; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,WARN
15+
16+
;; Check cache policies of the cache size.
17+
;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning.
18+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
19+
20+
;; Get the total size of created cache files.
21+
; RUN: rm -rf %t && mkdir %t && cd %t
22+
; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t2.o %t.o -o %t3 2>&1
23+
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
24+
25+
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
26+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
27+
28+
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
29+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
30+
31+
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
32+
; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN
33+
34+
; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy
35+
; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy
36+
; WARN-NOT: warning: ThinLTO cache pruning happens{{.*}}--thinlto-cache-policy
37+
38+
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128"
39+
target triple = "wasm32-unknown-unknown-wasm"
40+
41+
define void @globalfunc() #0 {
42+
entry:
43+
ret void
44+
}

Diff for: lld/wasm/LTO.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ std::vector<StringRef> BitcodeCompiler::compile() {
142142
cache));
143143

144144
if (!config->thinLTOCacheDir.empty())
145-
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy);
145+
pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
146146

147147
std::vector<StringRef> ret;
148148
for (unsigned i = 0; i != maxTasks; ++i) {

Diff for: llvm/include/llvm/Support/CachePruning.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_SUPPORT_CACHEPRUNING_H
1616

1717
#include "llvm/ADT/Optional.h"
18+
#include "llvm/Support/MemoryBuffer.h"
1819
#include <chrono>
1920

2021
namespace llvm {
@@ -70,11 +71,16 @@ Expected<CachePruningPolicy> parseCachePruningPolicy(StringRef PolicyStr);
7071
/// Peform pruning using the supplied policy, returns true if pruning
7172
/// occurred, i.e. if Policy.Interval was expired.
7273
///
74+
/// Check whether cache pruning happens using the supplied policy, adds a
75+
/// ThinLTO warning if cache_size_bytes or cache_size_files is too small for the
76+
/// current link job. The warning recommends the user to consider adjusting
77+
/// --thinlto-cache-policy.
78+
///
7379
/// As a safeguard against data loss if the user specifies the wrong directory
7480
/// as their cache directory, this function will ignore files not matching the
7581
/// pattern "llvmcache-*".
76-
bool pruneCache(StringRef Path, CachePruningPolicy Policy);
77-
82+
bool pruneCache(StringRef Path, CachePruningPolicy Policy,
83+
const std::vector<std::unique_ptr<MemoryBuffer>> &Files = {});
7884
} // namespace llvm
7985

8086
#endif

Diff for: llvm/lib/LTO/ThinLTOCodeGenerator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ void ThinLTOCodeGenerator::run() {
12171217
}
12181218
}
12191219

1220-
pruneCache(CacheOptions.Path, CacheOptions.Policy);
1220+
pruneCache(CacheOptions.Path, CacheOptions.Policy, ProducedBinaries);
12211221

12221222
// If statistics were requested, print them out now.
12231223
if (llvm::AreStatisticsEnabled())

Diff for: llvm/lib/Support/CachePruning.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/Support/Error.h"
1818
#include "llvm/Support/FileSystem.h"
1919
#include "llvm/Support/Path.h"
20+
#include "llvm/Support/WithColor.h"
2021
#include "llvm/Support/raw_ostream.h"
2122

2223
#define DEBUG_TYPE "cache-pruning"
@@ -141,7 +142,8 @@ llvm::parseCachePruningPolicy(StringRef PolicyStr) {
141142
}
142143

143144
/// Prune the cache of files that haven't been accessed in a long time.
144-
bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) {
145+
bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy,
146+
const std::vector<std::unique_ptr<MemoryBuffer>> &Files) {
145147
using namespace std::chrono;
146148

147149
if (Path.empty())
@@ -258,6 +260,17 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) {
258260
++FileInfo;
259261
};
260262

263+
// files.size() is greater the number of inputs by one. However, a timestamp
264+
// file is created and stored in the cache directory if --thinlto-cache-policy
265+
// option is used. Therefore, files.size() is used as ActualNums.
266+
const size_t ActualNums = Files.size();
267+
if (Policy.MaxSizeFiles && ActualNums > Policy.MaxSizeFiles)
268+
WithColor::warning()
269+
<< "ThinLTO cache pruning happens since the number of created files ("
270+
<< ActualNums << ") exceeds the maximum number of files ("
271+
<< Policy.MaxSizeFiles
272+
<< "); consider adjusting --thinlto-cache-policy\n";
273+
261274
// Prune for number of files.
262275
if (Policy.MaxSizeFiles)
263276
while (NumFiles > Policy.MaxSizeFiles)
@@ -285,6 +298,19 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) {
285298
<< Policy.MaxSizePercentageOfAvailableSpace << "%, "
286299
<< Policy.MaxSizeBytes << " bytes\n");
287300

301+
size_t ActualSizes = 0;
302+
for (const auto &File : Files)
303+
if (File)
304+
ActualSizes += File->getBufferSize();
305+
306+
if (ActualSizes > TotalSizeTarget)
307+
WithColor::warning()
308+
<< "ThinLTO cache pruning happens since the total size of the cache "
309+
"files consumed by the current link job ("
310+
<< ActualSizes << " bytes) exceeds maximum cache size ("
311+
<< TotalSizeTarget
312+
<< " bytes); consider adjusting --thinlto-cache-policy\n";
313+
288314
// Remove the oldest accessed files first, till we get below the threshold.
289315
while (TotalSize > TotalSizeTarget && FileInfo != FileInfos.end())
290316
RemoveCacheFile();

0 commit comments

Comments
 (0)