Simon Jakobi pushed to branch wip/sjakobi/clabel-monomorphic at Glasgow Haskell Compiler / GHC
WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.
Deleted commits:
-
bf52c492
by Simon Jakobi at 2026-06-11T08:50:35+02:00
3 changed files:
Changes:
| ... | ... | @@ -63,10 +63,16 @@ elimCommonBlocks :: CmmGraph -> CmmGraph |
| 63 | 63 | elimCommonBlocks g = replaceLabels env $ copyTicks env g
|
| 64 | 64 | where
|
| 65 | 65 | env = iterate mapEmpty blocks_with_key
|
| 66 | - -- The order of blocks doesn't matter here. While we could use
|
|
| 67 | - -- revPostorder which drops unreachable blocks this is done in
|
|
| 68 | - -- ContFlowOpt already which runs before this pass. So we use
|
|
| 69 | - -- toBlockList since it is faster.
|
|
| 66 | + -- The order of blocks doesn't matter here. Note that toBlockList
|
|
| 67 | + -- includes unreachable blocks (ContFlowOpt leaves them in the block
|
|
| 68 | + -- map, see Note [unreachable blocks] in GHC.Cmm.Pipeline), so we may
|
|
| 69 | + -- hash and merge dead blocks, and a live block may even be
|
|
| 70 | + -- substituted by an unreachable duplicate (resurrecting it). That is
|
|
| 71 | + -- semantically harmless since the blocks are identical, but it means
|
|
| 72 | + -- this pass both consumes and produces unreachable blocks; passes
|
|
| 73 | + -- between this one and the final removeUnreachableBlocksProc must
|
|
| 74 | + -- not let blocks that are unreachable here influence the reachable
|
|
| 75 | + -- part of the graph (see e.g. callProcPoints in GHC.Cmm.ProcPoint).
|
|
| 70 | 76 | groups = groupByInt hash_block (toBlockList g) :: [[CmmBlock]]
|
| 71 | 77 | blocks_with_key = [ [ (successors b, [b]) | b <- bs] | bs <- groups]
|
| 72 | 78 |
| ... | ... | @@ -352,10 +352,22 @@ _GLOBAL_OFFSET_TABLE_, regardless of which entry point we arrived via. |
| 352 | 352 | |
| 353 | 353 | {- Note [unreachable blocks]
|
| 354 | 354 | ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 355 | -The control-flow optimiser sometimes leaves unreachable blocks behind
|
|
| 356 | -containing junk code. These aren't necessarily a problem, but
|
|
| 357 | -removing them is good because it might save time in the native code
|
|
| 358 | -generator later.
|
|
| 355 | +The control-flow optimiser and the common block eliminator sometimes
|
|
| 356 | +leave unreachable blocks behind containing junk code; they are only
|
|
| 357 | +removed here, at the end of the pipeline. Removing them earlier would
|
|
| 358 | +cost extra reachability passes, but deferring the removal means every
|
|
| 359 | +pass in between runs on a block map that may contain unreachable
|
|
| 360 | +blocks, and must take care that they don't influence the reachable
|
|
| 361 | +part of the graph. In particular, the continuation of a call in an
|
|
| 362 | +unreachable block may itself be unreachable, so it must not be treated
|
|
| 363 | +as a proc point: stack layout only lays out reachable blocks, and an
|
|
| 364 | +info table attached (by attachContInfoTables) to a continuation
|
|
| 365 | +without a stack map makes setInfoTableStackMap panic. See
|
|
| 366 | +callProcPoints in GHC.Cmm.ProcPoint.
|
|
| 367 | + |
|
| 368 | +Beware also that the Cmm pretty-printer omits unreachable blocks, so
|
|
| 369 | +they do not show up in -ddump-cmm-* output; a dump can therefore look
|
|
| 370 | +consistent while the underlying block map is not.
|
|
| 359 | 371 | |
| 360 | 372 | -}
|
| 361 | 373 |
| ... | ... | @@ -173,8 +173,16 @@ procPointLattice = DataflowLattice unreached add_to |
| 173 | 173 | -- introduced because they're reachable from multiple proc points.
|
| 174 | 174 | --
|
| 175 | 175 | -- Extract the set of Continuation BlockIds, see Note [Continuation BlockIds].
|
| 176 | +--
|
|
| 177 | +-- We must consider only *reachable* blocks: the common block eliminator
|
|
| 178 | +-- leaves duplicated (hence unreachable) call blocks in the block map
|
|
| 179 | +-- (see Note [unreachable blocks] in GHC.Cmm.Pipeline), and the
|
|
| 180 | +-- continuation of such a dead call may itself be unreachable. Stack
|
|
| 181 | +-- layout only lays out reachable blocks, so a continuation collected
|
|
| 182 | +-- from a dead call would get an info table (attachContInfoTables) but
|
|
| 183 | +-- no stack map, making setInfoTableStackMap panic.
|
|
| 176 | 184 | callProcPoints :: CmmGraph -> ProcPointSet
|
| 177 | -callProcPoints g = foldlGraphBlocks add (setSingleton (g_entry g)) g
|
|
| 185 | +callProcPoints g = foldl' add (setSingleton (g_entry g)) (revPostorder g)
|
|
| 178 | 186 | where add :: LabelSet -> CmmBlock -> LabelSet
|
| 179 | 187 | add set b = case lastNode b of
|
| 180 | 188 | CmmCall {cml_cont = Just k} -> setInsert k set
|