summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2023-01-19 08:59:18 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-23 04:53:32 -0500
commit82884ce063180a39afed163590738f7095394583 (patch)
treef0f78e610d9f21b1007d6ab01d5610cf646105dd /compiler/GHC/Core
parent9a9bec5762920306656113f2a6e676adf6c65e23 (diff)
downloadhaskell-82884ce063180a39afed163590738f7095394583.tar.gz
Fix #22742
runtimeRepLevity_maybe was panicing unnecessarily; and the error printing code made use of the case when it should return Nothing rather than panicing. For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime peak-megagbytes-used, on a single architecture (alpine). See !9753 for commentary, but I'm going to accept it. Metric Increase: T21839r
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/Type.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/GHC/Core/Type.hs b/compiler/GHC/Core/Type.hs
index 81b0f1e31b..9e0d95b0d9 100644
--- a/compiler/GHC/Core/Type.hs
+++ b/compiler/GHC/Core/Type.hs
@@ -686,8 +686,8 @@ kindBoxedRepLevity_maybe ty
-- * False of type variables, type family applications,
-- and of other reps such as @IntRep :: RuntimeRep@.
isLiftedRuntimeRep :: RuntimeRepType -> Bool
-isLiftedRuntimeRep rep =
- runtimeRepLevity_maybe rep == Just Lifted
+isLiftedRuntimeRep rep
+ = runtimeRepLevity_maybe rep == Just Lifted
-- | Check whether a type of kind 'RuntimeRep' is unlifted.
--
@@ -779,7 +779,8 @@ isBoxedRuntimeRep_maybe rep
| otherwise
= Nothing
--- | Check whether a type of kind 'RuntimeRep' is lifted, unlifted, or unknown.
+-- | Check whether a type (usually of kind 'RuntimeRep') is lifted, unlifted,
+-- or unknown. Returns Nothing if the type isn't of kind 'RuntimeRep'.
--
-- `runtimeRepLevity_maybe rr` returns:
--
@@ -793,7 +794,9 @@ runtimeRepLevity_maybe rep
if (rr_tc `hasKey` boxedRepDataConKey)
then case args of
[lev] -> levityType_maybe lev
- _ -> pprPanic "runtimeRepLevity_maybe" (ppr rep)
+ _ -> Nothing -- Type isn't of kind RuntimeRep
+ -- The latter case happens via the call to isLiftedRuntimeRep
+ -- in GHC.Tc.Errors.Ppr.pprMisMatchMsg (#22742)
else Just Unlifted
-- Avoid searching all the unlifted RuntimeRep type cons
-- In the RuntimeRep data type, only LiftedRep is lifted