[PATCH] D41231: [Support][CachePruning] Fix regression that prevents disabling of pruning

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 09:04:03 PST 2017


bd1976llvm updated this revision to Diff 126977.
bd1976llvm added a comment.

I like your proposal.

However, as the cache code is shared between multiple api's and only the c api has this disabling behaviour for negative values a fix here is more appropriate..

I have updated the patch to be more defensive, hopefully this addresses your concerns.


https://reviews.llvm.org/D41231

Files:
  include/llvm/LTO/legacy/ThinLTOCodeGenerator.h


Index: include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
===================================================================
--- include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
+++ include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
@@ -149,10 +149,12 @@
   void setCacheDir(std::string Path) { CacheOptions.Path = std::move(Path); }
 
   /// Cache policy: interval (seconds) between two prune of the cache. Set to a
-  /// negative value (default) to disable pruning. A value of 0 will be ignored.
+  /// negative value to disable pruning. A value of 0 will be ignored.
   void setCachePruningInterval(int Interval) {
+    typedef decltype(CacheOptions.Policy.Interval) chrono_type;
     if (Interval)
-      CacheOptions.Policy.Interval = std::chrono::seconds(Interval);
+      CacheOptions.Policy.Interval =
+          Interval > 0 ? chrono_type(Interval) : chrono_type::max();
   }
 
   /// Cache policy: expiration (in seconds) for an entry.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41231.126977.patch
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171214/714fd69f/attachment.bin>


More information about the llvm-commits mailing list