Commit 304067a0 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan

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

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

- GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries.
- containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries.
parent fc746e98
Pipeline #9788 passed with stages
in 331 minutes and 25 seconds
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment