summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
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
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')
-rw-r--r--llvm/lib/LTO/Caching.cpp6
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp5
2 files changed, 8 insertions, 3 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) {
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index b793d0c9e3e..aa4d32a9c57 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -348,7 +348,10 @@ public:
ArrayRef<uint8_t>((const uint8_t *)&Entry, sizeof(GlobalValue::GUID)));
}
- sys::path::append(EntryPath, CachePath, toHex(Hasher.result()));
+ // This choice of file name allows the cache to be pruned (see pruneCache()
+ // in include/llvm/Support/CachePruning.h).
+ sys::path::append(EntryPath, CachePath,
+ "llvmcache-" + toHex(Hasher.result()));
}
// Access the path to this entry in the cache.
OpenPOWER on IntegriCloud