Commit 2989ffdc authored by Simon Marlow's avatar Simon Marlow
Browse files

A panic in CmmBuildInfoTables.bundle shouldn't be a panic (#9329)

Summary:
This code needs more comments, but I believe this is safe.  By
definition I can't have broken anything that was working by turning a
panic into a non-panic anyway.

Test Plan: validate

Reviewers: hvr, simonpj, austin

Subscribers: simonmar, relrod, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D105

GHC Trac Issues: #9329
parent 6c06db13
......@@ -286,7 +286,7 @@ bundle :: Map CLabel CAFSet
-> (CAFEnv, CmmDecl)
-> (CAFSet, Maybe CLabel)
-> (BlockEnv CAFSet, CmmDecl)
bundle flatmap (env, decl@(CmmProc infos lbl _ g)) (closure_cafs, mb_lbl)
bundle flatmap (env, decl@(CmmProc infos _lbl _ g)) (closure_cafs, mb_lbl)
= ( mapMapWithKey get_cafs (info_tbls infos), decl )
where
entry = g_entry g
......@@ -297,9 +297,13 @@ bundle flatmap (env, decl@(CmmProc infos lbl _ g)) (closure_cafs, mb_lbl)
get_cafs l _
| l == entry = entry_cafs
| otherwise = if not (mapMember l env)
then pprPanic "bundle" (ppr l <+> ppr lbl <+> ppr (info_tbls infos) $$ ppr env $$ ppr decl)
else flatten flatmap $ expectJust "bundle" $ mapLookup l env
| Just info <- mapLookup l env = flatten flatmap info
| otherwise = Set.empty
-- the label might not be in the env if the code corresponding to
-- this info table was optimised away (perhaps because it was
-- unreachable). In this case it doesn't matter what SRT we
-- infer, since the info table will not appear in the generated
-- code. See #9329.
bundle _flatmap (_, decl) _
= ( mapEmpty, decl )
......
foo ()
{
STK_CHK_GEN_N (8); /* panics */
return (0);
}
......@@ -24,3 +24,4 @@ test('T7574', [cmm_src, omit_ways(['llvm', 'optllvm'])], compile, [''])
test('T8205', normal, compile, ['-O0'])
test('T9155', normal, compile, ['-O2'])
test('T9303', normal, compile, ['-O2'])
test('T9329', [cmm_src], compile, [''])
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