Simon Jakobi pushed to branch wip/sjakobi/cbe-delete-losers at Glasgow Haskell Compiler / GHC Commits: ea872409 by Simon Jakobi at 2026-11-20T14:12:14+01:00 Cmm: drop eliminated blocks from the graph in CBE Previously, common block elimination only made the eliminated blocks unreachable. They stayed in the graph until stack layout discarded them. Removing these blocks right away reduces the potential for confusion (e.g. #27368). It does not appear to make any significant difference to compiler allocations. Assisted-by: Claude Opus 5.5 - - - - - 1 changed file: - compiler/GHC/Cmm/CommonBlockElim.hs Changes: ===================================== compiler/GHC/Cmm/CommonBlockElim.hs ===================================== @@ -64,7 +64,7 @@ elimCommonBlocks :: CmmGraph -> CmmGraph elimCommonBlocks g = assert (g_entry g == g_entry g') g' where - g' = replaceLabels env $ copyTicks env g + g' = replaceLabels env $ dropEliminatedBlocks env $ copyTicks env g env = iterate mapEmpty blocks_with_key blocks_with_key = [ [ (successors b, [b]) | b <- bs] | bs <- groups] groups = groupByInt hash_block candidates :: [[CmmBlock]] @@ -322,6 +322,12 @@ copyTicks env g in CmmEntry lbl (combineTickScopes scp0 scp1) `blockJoinHead` foldr blockCons code (map CmmTick ticks) +-- | Remove the blocks eliminated by the substitution from the graph. +dropEliminatedBlocks :: Subst -> CmmGraph -> CmmGraph +dropEliminatedBlocks env g + | mapNull env = g + | otherwise = ofBlockMap (g_entry g) (toBlockMap g `mapDifference` env) + -- Group by [Label] -- See Note [Compressed TrieMap] in GHC.Core.Map.Expr about the usage of GenMap. groupByLabel :: [(Key, DistinctBlocks)] -> [(Key, NonEmpty DistinctBlocks)] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea872409e20ca89b575a6db3aa535724... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea872409e20ca89b575a6db3aa535724... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help