summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmBuildInfoTables.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-07-31 11:47:16 +0100
committerSimon Marlow <marlowsd@gmail.com>2014-08-01 12:45:41 +0100
commit2989ffdcb88ab24e8a4e8b3d0454497a0db2652c (patch)
tree56f3ba6c42c1d4268c729c0becc4971f7c2dee1f /compiler/cmm/CmmBuildInfoTables.hs
parent6c06db13a670f156a79301c89b6bf2669d91af88 (diff)
downloadhaskell-2989ffdcb88ab24e8a4e8b3d0454497a0db2652c.tar.gz
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
Diffstat (limited to 'compiler/cmm/CmmBuildInfoTables.hs')
-rw-r--r--compiler/cmm/CmmBuildInfoTables.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/cmm/CmmBuildInfoTables.hs b/compiler/cmm/CmmBuildInfoTables.hs
index e10716a2ac..6521a84006 100644
--- a/compiler/cmm/CmmBuildInfoTables.hs
+++ b/compiler/cmm/CmmBuildInfoTables.hs
@@ -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 )