diff options
author | Hans Wennborg <hans@chromium.org> | 2021-01-19 13:41:41 +0100 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2021-01-19 14:43:49 +0100 |
commit | ec877106a38b760229a2d676b7d2278b2bade8ab (patch) | |
tree | d6efd301d2a21371c71564bd4627c55d6317bc7a /llvm/lib/Support/CachePruning.cpp | |
parent | 1d37db6ef53db453534b9edfcc6a58c4f4f5c914 (diff) | |
download | llvm-ec877106a38b760229a2d676b7d2278b2bade8ab.zip llvm-ec877106a38b760229a2d676b7d2278b2bade8ab.tar.gz llvm-ec877106a38b760229a2d676b7d2278b2bade8ab.tar.bz2 |
[ThinLTO] Also prune Thin-* files from the ThinLTO cache
Such files (Thin-%%%%%%.tmp.o) are supposed to be deleted immediately
after they're used (either by renaming or deletion). However, we've seen
instances on Windows where this doesn't happen, probably due to the
filesystem being flaky. This is effectively a resource leak which has
prevented us from using the ThinLTO cache on Windows.
Since those temporary files are in the thinlto cache directory which we
prune periodically anyway, allowing them to be pruned too seems like a
tidy way to solve the problem.
Differential revision: https://reviews.llvm.org/D94962
Diffstat (limited to 'llvm/lib/Support/CachePruning.cpp')
-rw-r--r-- | llvm/lib/Support/CachePruning.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/CachePruning.cpp b/llvm/lib/Support/CachePruning.cpp index 7663644..5c5759f 100644 --- a/llvm/lib/Support/CachePruning.cpp +++ b/llvm/lib/Support/CachePruning.cpp @@ -211,11 +211,12 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) { // Walk all of the files within this directory. for (sys::fs::directory_iterator File(CachePathNative, EC), FileEnd; File != FileEnd && !EC; File.increment(EC)) { - // Ignore any files not beginning with the string "llvmcache-". This + // Ignore filenames not beginning with "llvmcache-" or "Thin-". This // includes the timestamp file as well as any files created by the user. // This acts as a safeguard against data loss if the user specifies the // wrong directory as their cache directory. - if (!sys::path::filename(File->path()).startswith("llvmcache-")) + StringRef filename = sys::path::filename(File->path()); + if (!filename.startswith("llvmcache-") && !filename.startswith("Thin-")) continue; // Look at this file. If we can't stat it, there's nothing interesting |