From bb534b15a9959cdb6dc03a64151f68f1293f7a28 Mon Sep 17 00:00:00 2001 From: Ben Dunbobbin Date: Fri, 22 Dec 2017 18:32:15 +0000 Subject: [ThinLTO][CachePruning] explicitly disable pruning In https://reviews.llvm.org/rL321077 and https://reviews.llvm.org/D41231 I fixed a regression in the c-api which prevented the pruning from being *effectively* disabled. However this approach, helpfully recommended by @labath, is cleaner. It is also nice to remove the weasel words about effectively disabling from the api comments. Differential Revision: https://reviews.llvm.org/D41497 llvm-svn: 321376 --- llvm/lib/Support/CachePruning.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Support/CachePruning.cpp') diff --git a/llvm/lib/Support/CachePruning.cpp b/llvm/lib/Support/CachePruning.cpp index e1ad8024096..141573c2a1c 100644 --- a/llvm/lib/Support/CachePruning.cpp +++ b/llvm/lib/Support/CachePruning.cpp @@ -155,8 +155,7 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) { SmallString<128> TimestampFile(Path); sys::path::append(TimestampFile, "llvmcache.timestamp"); sys::fs::file_status FileStatus; - const auto CurrentTime = - time_point_cast(system_clock::now()); + const auto CurrentTime = system_clock::now(); if (auto EC = sys::fs::status(TimestampFile, FileStatus)) { if (EC == errc::no_such_file_or_directory) { // If the timestamp file wasn't there, create one now. @@ -166,13 +165,14 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) { return false; } } else { + if (!Policy.Interval) + return false; if (Policy.Interval != seconds(0)) { // Check whether the time stamp is older than our pruning interval. // If not, do nothing. - const auto TimeStampModTime = time_point_cast( - FileStatus.getLastModificationTime()); + const auto TimeStampModTime = FileStatus.getLastModificationTime(); auto TimeStampAge = CurrentTime - TimeStampModTime; - if (TimeStampAge <= Policy.Interval) { + if (TimeStampAge <= *Policy.Interval) { DEBUG(dbgs() << "Timestamp file too recent (" << duration_cast(TimeStampAge).count() << "s old), do not prune.\n"); -- cgit v1.2.3