<div dir="ltr">This commit breaks our bot: <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/11854">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/11854</a>, please fix.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 22, 2017 at 10:32 AM, Ben Dunbobbin via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bd1976llvm<br>
Date: Fri Dec 22 10:32:15 2017<br>
New Revision: 321376<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=321376&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=321376&view=rev</a><br>
Log:<br>
[ThinLTO][CachePruning] explicitly disable pruning<br>
<br>
In <a href="https://reviews.llvm.org/rL321077" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>rL321077</a> and <a href="https://reviews.llvm.org/D41231" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D41231</a> I fixed a regression in the c-api which prevented the pruning from being *effectively* disabled.<br>
<br>
However this approach, helpfully recommended by @labath, is cleaner.<br>
It is also nice to remove the weasel words about effectively disabling from the api comments.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D41497" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D41497</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm-c/lto.<wbr>h<br>
    llvm/trunk/include/llvm/LTO/<wbr>legacy/ThinLTOCodeGenerator.h<br>
    llvm/trunk/include/llvm/<wbr>Support/CachePruning.h<br>
    llvm/trunk/lib/Support/<wbr>CachePruning.cpp<br>
<br>
Modified: llvm/trunk/include/llvm-c/lto.<wbr>h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=321376&r1=321375&r2=321376&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm-c/lto.h?rev=321376&r1=<wbr>321375&r2=321376&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm-c/lto.<wbr>h (original)<br>
+++ llvm/trunk/include/llvm-c/lto.<wbr>h Fri Dec 22 10:32:15 2017<br>
@@ -764,7 +764,7 @@ extern void thinlto_codegen_add_cross_re<br>
  * To avoid filling the disk space, a few knobs are provided:<br>
  *  - The pruning interval limits the frequency at which the garbage collector<br>
  *    will try to scan the cache directory to prune expired entries.<br>
- *    Setting to a negative number applies the maximum interval.<br>
+ *    Setting to a negative number disables the pruning.<br>
  *  - The pruning expiration time indicates to the garbage collector how old an<br>
  *    entry needs to be to be removed.<br>
  *  - Finally, the garbage collector can be instructed to prune the cache until<br>
@@ -782,9 +782,9 @@ extern void thinlto_codegen_set_cache_di<br>
                                           const char *cache_dir);<br>
<br>
 /**<br>
- * Sets the cache pruning interval (in seconds). A negative value sets the<br>
- * maximum possible pruning interval. An unspecified default value will be<br>
- * applied, and a value of 0 will be ignored.<br>
+ * Sets the cache pruning interval (in seconds). A negative value disables the<br>
+ * pruning. An unspecified default value will be applied, and a value of 0 will<br>
+ * be ignored.<br>
  *<br>
  * \since LTO_API_VERSION=18<br>
  */<br>
<br>
Modified: llvm/trunk/include/llvm/LTO/<wbr>legacy/ThinLTOCodeGenerator.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h?rev=321376&r1=321375&r2=321376&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/LTO/legacy/<wbr>ThinLTOCodeGenerator.h?rev=<wbr>321376&r1=321375&r2=321376&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/LTO/<wbr>legacy/ThinLTOCodeGenerator.h (original)<br>
+++ llvm/trunk/include/llvm/LTO/<wbr>legacy/ThinLTOCodeGenerator.h Fri Dec 22 10:32:15 2017<br>
@@ -148,16 +148,15 @@ public:<br>
   /// incremental build.<br>
   void setCacheDir(std::string Path) { CacheOptions.Path = std::move(Path); }<br>
<br>
-  /// Cache policy: interval (seconds) between two prunes of the cache. A<br>
-  /// negative value sets the maximum possible pruning interval. A value<br>
-  /// of 0 will be ignored.<br>
+  /// Cache policy: interval (seconds) between two prunes of the cache. Set to a<br>
+  /// negative value to disable pruning. A value of 0 will be ignored.<br>
   void setCachePruningInterval(int Interval) {<br>
-    static_assert(std::is_same<<wbr>decltype(CacheOptions.Policy.<wbr>Interval),<br>
-                               std::chrono::seconds>::value,<br>
-                  "ensure same types to avoid risk of overflow");<br>
-    if (Interval)<br>
-      CacheOptions.Policy.Interval = Interval > 0 ? std::chrono::seconds(Interval)<br>
-                                                  : std::chrono::seconds::max();<br>
+    if (Interval == 0)<br>
+      return;<br>
+    if(Interval < 0)<br>
+      CacheOptions.Policy.Interval.<wbr>reset();<br>
+    else<br>
+      CacheOptions.Policy.Interval = std::chrono::seconds(Interval)<wbr>;<br>
   }<br>
<br>
   /// Cache policy: expiration (in seconds) for an entry.<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>Support/CachePruning.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CachePruning.h?rev=321376&r1=321375&r2=321376&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Support/CachePruning.h?<wbr>rev=321376&r1=321375&r2=<wbr>321376&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>Support/CachePruning.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>Support/CachePruning.h Fri Dec 22 10:32:15 2017<br>
@@ -27,8 +27,9 @@ template <typename T> class Expected;<br>
 struct CachePruningPolicy {<br>
   /// The pruning interval. This is intended to be used to avoid scanning the<br>
   /// directory too often. It does not impact the decision of which file to<br>
-  /// prune. A value of 0 forces the scan to occur.<br>
-  std::chrono::seconds Interval = std::chrono::seconds(1200);<br>
+  /// prune. A value of 0 forces the scan to occur. A value of None disables<br>
+  /// pruning.<br>
+  llvm::Optional<std::chrono::<wbr>seconds> Interval = std::chrono::seconds(1200);<br>
<br>
   /// The expiration for a file. When a file hasn't been accessed for Expiration<br>
   /// seconds, it is removed from the cache. A value of 0 disables the<br>
<br>
Modified: llvm/trunk/lib/Support/<wbr>CachePruning.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CachePruning.cpp?rev=321376&r1=321375&r2=321376&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Support/CachePruning.cpp?rev=<wbr>321376&r1=321375&r2=321376&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Support/<wbr>CachePruning.cpp (original)<br>
+++ llvm/trunk/lib/Support/<wbr>CachePruning.cpp Fri Dec 22 10:32:15 2017<br>
@@ -155,8 +155,7 @@ bool llvm::pruneCache(StringRef Path, Ca<br>
   SmallString<128> TimestampFile(Path);<br>
   sys::path::append(<wbr>TimestampFile, "llvmcache.timestamp");<br>
   sys::fs::file_status FileStatus;<br>
-  const auto CurrentTime =<br>
-      time_point_cast<decltype(<wbr>Policy.Interval)>(system_<wbr>clock::now());<br>
+  const auto CurrentTime = system_clock::now();<br>
   if (auto EC = sys::fs::status(TimestampFile, FileStatus)) {<br>
     if (EC == errc::no_such_file_or_<wbr>directory) {<br>
       // If the timestamp file wasn't there, create one now.<br>
@@ -166,13 +165,14 @@ bool llvm::pruneCache(StringRef Path, Ca<br>
       return false;<br>
     }<br>
   } else {<br>
+    if (!Policy.Interval)<br>
+      return false;<br>
     if (Policy.Interval != seconds(0)) {<br>
       // Check whether the time stamp is older than our pruning interval.<br>
       // If not, do nothing.<br>
-      const auto TimeStampModTime = time_point_cast<decltype(<wbr>Policy.Interval)>(<br>
-          FileStatus.<wbr>getLastModificationTime());<br>
+      const auto TimeStampModTime = FileStatus.<wbr>getLastModificationTime();<br>
       auto TimeStampAge = CurrentTime - TimeStampModTime;<br>
-      if (TimeStampAge <= Policy.Interval) {<br>
+      if (TimeStampAge <= *Policy.Interval) {<br>
         DEBUG(dbgs() << "Timestamp file too recent ("<br>
                      << duration_cast<seconds>(<wbr>TimeStampAge).count()<br>
                      << "s old), do not prune.\n");<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>