From 304067a0cb01af1ce9986009065419e86788050c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 25 Jul 2019 10:33:50 +0300 Subject: Small optimization in the SRT algorithm Noticed by @simonmar in !1362: If the srtEntry is Nothing, then it should be safe to omit references to this SRT from other SRTs, even if it is a static function. When updating SRT map we don't omit references to static functions (see Note [Invalid optimisation: shortcutting]), but there's no reason to add an SRT entry for a static function if the function is not CAFFY. (Previously we'd add SRT entries for static functions even when they're not CAFFY) Using 9151b99e I checked sizes of all SRTs when building GHC and containers: - GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries. - containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries. --- compiler/cmm/CmmBuildInfoTables.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/cmm/CmmBuildInfoTables.hs b/compiler/cmm/CmmBuildInfoTables.hs index 9c05a8fe29..bde52de3af 100644 --- a/compiler/cmm/CmmBuildInfoTables.hs +++ b/compiler/cmm/CmmBuildInfoTables.hs @@ -727,7 +727,7 @@ oneSRT dflags staticFuns blockids lbls isCAF cafs = do -- important that we don't do this for static functions or CAFs, -- see Note [Invalid optimisation: shortcutting]. updateSRTMap srtEntry = - when (not isCAF && not isStaticFun) $ do + when (not isCAF && (not isStaticFun || isNothing srtEntry)) $ do let newSRTMap = Map.fromList [(cafLbl, srtEntry) | cafLbl <- lbls] put (Map.union newSRTMap srtMap) -- cgit v1.2.1