summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-07-25 10:33:50 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2019-08-29 09:38:25 -0400
commit304067a0cb01af1ce9986009065419e86788050c (patch)
treecec8951accc993b833d0b3cd6c2986dc1c416aca
parentfc746e98d8ee7ac22224ba7d7fd1c38e16dfad30 (diff)
downloadhaskell-304067a0cb01af1ce9986009065419e86788050c.tar.gz
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.
-rw-r--r--compiler/cmm/CmmBuildInfoTables.hs2
1 files changed, 1 insertions, 1 deletions
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)