From 25a17ba4c7cae20b301e01c6654c272fe38314b9 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 20 Mar 2017 16:41:57 +0000 Subject: 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 --- llvm/lib/LTO/Caching.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/LTO/Caching.cpp') 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 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> MBOrErr = MemoryBuffer::getFile(EntryPath); if (MBOrErr) { -- cgit v1.2.3