summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/Caching.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-03-20 16:41:57 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-03-20 16:41:57 +0000
commit25a17ba4c7cae20b301e01c6654c272fe38314b9 (patch)
tree5dd3af1e8aee5ca2f1c04b3be25ff320d90b2723 /llvm/lib/LTO/Caching.cpp
parente593049fb057a014e912973e8717463e060c9d60 (diff)
downloadbcm5719-llvm-25a17ba4c7cae20b301e01c6654c272fe38314b9.tar.gz
bcm5719-llvm-25a17ba4c7cae20b301e01c6654c272fe38314b9.zip
Support, LTO: When pruning a directory, ignore files matching a prefix.
This is a safeguard against data loss if the user specifies a directory that is not a cache directory. Teach the existing cache pruning clients to create files with appropriate names. Differential Revision: https://reviews.llvm.org/D31109 llvm-svn: 298271
Diffstat (limited to 'llvm/lib/LTO/Caching.cpp')
-rw-r--r--llvm/lib/LTO/Caching.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/LTO/Caching.cpp b/llvm/lib/LTO/Caching.cpp
index 16edbece145..00373ddd1c4 100644
--- a/llvm/lib/LTO/Caching.cpp
+++ b/llvm/lib/LTO/Caching.cpp
@@ -27,9 +27,11 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
return errorCodeToError(EC);
return [=](unsigned Task, StringRef Key) -> AddStreamFn {
- // First, see if we have a cache hit.
+ // This choice of file name allows the cache to be pruned (see pruneCache()
+ // in include/llvm/Support/CachePruning.h).
SmallString<64> EntryPath;
- sys::path::append(EntryPath, CacheDirectoryPath, Key);
+ sys::path::append(EntryPath, CacheDirectoryPath, "llvmcache-" + Key);
+ // First, see if we have a cache hit.
ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
MemoryBuffer::getFile(EntryPath);
if (MBOrErr) {
OpenPOWER on IntegriCloud