summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCurran McConnell <curran@atidot.com>2022-08-16 03:10:56 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-21 02:58:01 -0400
commit8cd6f435e60f9dd14ad55a0002ff833536e9ccb2 (patch)
tree67096c26a87980089ba29908c478dfb8a59d9d76
parent1ebd521f848289a99993f95af4e2021023537ad5 (diff)
downloadhaskell-8cd6f435e60f9dd14ad55a0002ff833536e9ccb2.tar.gz
remove a no-warn directive from GHC.Cmm.ContFlowOpt
This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before).
-rw-r--r--compiler/GHC/Cmm/ContFlowOpt.hs13
-rw-r--r--compiler/GHC/Cmm/Pipeline.hs2
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/GHC/Cmm/ContFlowOpt.hs b/compiler/GHC/Cmm/ContFlowOpt.hs
index a9bb7b673e..59ed1e760b 100644
--- a/compiler/GHC/Cmm/ContFlowOpt.hs
+++ b/compiler/GHC/Cmm/ContFlowOpt.hs
@@ -1,6 +1,5 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE BangPatterns #-}
-{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Cmm.ContFlowOpt
( cmmCfgOpts
@@ -21,8 +20,10 @@ import GHC.Cmm
import GHC.Cmm.Utils
import GHC.Cmm.Switch (mapSwitchTargets, switchTargetsToList)
import GHC.Data.Maybe
-import GHC.Utils.Panic
+import GHC.Platform
import GHC.Utils.Misc
+import GHC.Utils.Outputable
+import GHC.Utils.Panic
import Control.Monad
@@ -422,9 +423,9 @@ predMap blocks = foldr add_preds mapEmpty blocks
add_preds block env = foldr add env (successors block)
where add lbl env = mapInsertWith (+) lbl 1 env
--- Removing unreachable blocks
-removeUnreachableBlocksProc :: CmmDecl -> CmmDecl
-removeUnreachableBlocksProc proc@(CmmProc info lbl live g)
+-- Remove unreachable blocks from procs
+removeUnreachableBlocksProc :: Platform -> CmmDecl -> CmmDecl
+removeUnreachableBlocksProc _ proc@(CmmProc info lbl live g)
| used_blocks `lengthLessThan` mapSize (toBlockMap g)
= CmmProc info' lbl live g'
| otherwise
@@ -446,3 +447,5 @@ removeUnreachableBlocksProc proc@(CmmProc info lbl live g)
used_lbls :: LabelSet
used_lbls = setFromList $ map entryLabel used_blocks
+removeUnreachableBlocksProc platform data'@(CmmData _ _) =
+ pprPanic "removeUnreachableBlocksProc: passed data declaration instead of procedure" (pdoc platform data')
diff --git a/compiler/GHC/Cmm/Pipeline.hs b/compiler/GHC/Cmm/Pipeline.hs
index 40383bff94..c0a37cd3bc 100644
--- a/compiler/GHC/Cmm/Pipeline.hs
+++ b/compiler/GHC/Cmm/Pipeline.hs
@@ -156,7 +156,7 @@ cpsTop logger platform cfg proc =
return $ if cmmOptControlFlow cfg
then map (cmmCfgOptsProc splitting_proc_points) g
else g
- g <- return (map removeUnreachableBlocksProc g)
+ g <- return $ map (removeUnreachableBlocksProc platform) g
-- See Note [unreachable blocks]
dumps Opt_D_dump_cmm_cfg "Post control-flow optimisations" g