Commit 3f0d4530 authored by Simon Peyton Jones's avatar Simon Peyton Jones

When removing unreachable code, remove unreachable info tables too

This bug only shows up when you are using proc-point splitting.
What was happening was:
  * We generate a proc-point for the stack check
  * And an info table
  * We eliminate the stack check because it's redundant
  * And the dangling info table caused a panic in
    CmmBuildInfoTables.bundle
parent aebc7e1b
......@@ -4,7 +4,6 @@ module CmmContFlowOpt
( cmmCfgOpts
, cmmCfgOptsProc
, removeUnreachableBlocksProc
, removeUnreachableBlocks
, replaceLabels
)
where
......@@ -394,11 +393,25 @@ predMap blocks = foldr add_preds mapEmpty blocks
-- Removing unreachable blocks
removeUnreachableBlocksProc :: CmmDecl -> CmmDecl
removeUnreachableBlocksProc (CmmProc info lbl live g)
= CmmProc info lbl live (removeUnreachableBlocks g)
removeUnreachableBlocks :: CmmGraph -> CmmGraph
removeUnreachableBlocks g
| length blocks < mapSize (toBlockMap g) = ofBlockList (g_entry g) blocks
| otherwise = g
where blocks = postorderDfs g
removeUnreachableBlocksProc proc@(CmmProc info lbl live g)
| length used_blocks < mapSize (toBlockMap g)
= CmmProc info' lbl live g'
| otherwise
= proc
where
g' = ofBlockList (g_entry g) used_blocks
info' = info { info_tbls = keep_used (info_tbls info) }
-- Remove any info_tbls for unreachable
keep_used :: BlockEnv CmmInfoTable -> BlockEnv CmmInfoTable
keep_used bs = mapFoldWithKey keep emptyBlockMap bs
keep :: Label -> CmmInfoTable -> BlockEnv CmmInfoTable -> BlockEnv CmmInfoTable
keep l i env | l `setMember` used_lbls = mapInsert l i env
| otherwise = env
used_blocks :: [CmmBlock]
used_blocks = postorderDfs g
used_lbls :: LabelSet
used_lbls = foldr (setInsert . entryLabel) setEmpty used_blocks
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