From 5b5d262052b4f0380c1abbf028144354856b269c Mon Sep 17 00:00:00 2001 From: Ben Dunbobbin Date: Tue, 19 Dec 2017 14:42:38 +0000 Subject: [Support][CachePruning] Disable cache pruning regression fix borked by: rL284966 (see: https://reviews.llvm.org/D25730). Previously, Interval was unsigned (see: CachePruning.h), replacing the type with std::chrono::seconds (which is signed) causes a regression in behaviour because the c-api intends negative values to translate to large positive intervals to *effectively* disable the pruning (see comments on: setCachePruningInterval()). Differential Revision: https://reviews.llvm.org/D41231 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321077 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/legacy/ThinLTOCodeGenerator.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h index 14f0c48266f..2c842ecf96a 100644 --- a/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h +++ b/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h @@ -151,8 +151,12 @@ public: /// 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. void setCachePruningInterval(int Interval) { + static_assert(std::is_same::value, + "ensure same types to avoid risk of overflow"); if (Interval) - CacheOptions.Policy.Interval = std::chrono::seconds(Interval); + CacheOptions.Policy.Interval = Interval > 0 ? std::chrono::seconds(Interval) + : std::chrono::seconds::max(); } /// Cache policy: expiration (in seconds) for an entry. -- cgit v1.2.3