summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-09-14 15:23:51 +0100
committerZubin Duggal <zubin.duggal@gmail.com>2021-10-12 14:54:34 +0530
commita54e54fa4b121c0210f55e5d6e338d7af6e6922b (patch)
tree77761630e0eec64da33b7d104d9c70f8cf352481
parent49acdc6d5695e02ebd56ce2f4a3b58086b33963a (diff)
downloadhaskell-a54e54fa4b121c0210f55e5d6e338d7af6e6922b.tar.gz
Code Gen: Use strict map rather than lazy map in loop analysis
We were ending up with a big 1GB thunk spike as the `fmap` operation did not force the key values promptly. This fixes the high maximum memory consumption when compiling the mmark package. Compilation is still slow and allocates a lot more than previous releases. Related to #19471 (cherry picked from commit 9eff805a622db499be1fda304e11bb3e6c8d37f0)
-rw-r--r--compiler/GHC/CmmToAsm/CFG.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/GHC/CmmToAsm/CFG.hs b/compiler/GHC/CmmToAsm/CFG.hs
index 5db10ce93f..63b488d482 100644
--- a/compiler/GHC/CmmToAsm/CFG.hs
+++ b/compiler/GHC/CmmToAsm/CFG.hs
@@ -307,7 +307,9 @@ shortcutWeightMap cuts cfg =
applyMapping m (from, Just to) =
let updatedMap :: CFG
updatedMap
- = fmap (shortcutEdge (from,to)) $
+ -- Careful here to use a strict mapping function, the derived
+ -- Functor instance is lazy and leads to a large thunk build-up. #19471/!6523
+ = mapMap (shortcutEdge (from,to)) $
(mapDelete from m :: CFG )
--Sometimes we can shortcut multiple blocks like so:
-- A -> B -> C -> D -> E => A -> E