Krzysztof Gogolewski pushed to branch wip/krzysztof-cleanup at Glasgow Haskell Compiler / GHC
Commits:
-
101068c6
by Krzysztof Gogolewski at 2025-06-09T17:13:34+02:00
8 changed files:
- compiler/GHC/CoreToStg.hs
- compiler/GHC/Stg/Unarise.hs
- compiler/GHC/Stg/Utils.hs
- compiler/GHC/StgToCmm/Layout.hs
- compiler/GHC/Types/RepType.hs
- docs/users_guide/ghc_config.py.in
- libraries/ghc-internal/src/GHC/Internal/Data/Typeable/Internal.hs
- utils/check-exact/ExactPrint.hs
Changes:
| ... | ... | @@ -425,13 +425,11 @@ coreToStgExpr expr@(App _ _) |
| 425 | 425 | coreToStgExpr expr@(Lam _ _)
|
| 426 | 426 | = let
|
| 427 | 427 | (args, body) = myCollectBinders expr
|
| 428 | - in
|
|
| 429 | - case filterStgBinders args of
|
|
| 430 | - |
|
| 431 | - [] -> coreToStgExpr body
|
|
| 428 | + in assertPpr
|
|
| 429 | + (null (filterStgBinders args))
|
|
| 430 | + (text "coreToStgExpr: unexpected value lambda: " $$ ppr expr)
|
|
| 431 | + (coreToStgExpr body)
|
|
| 432 | 432 | |
| 433 | - _ -> pprPanic "coretoStgExpr" $
|
|
| 434 | - text "Unexpected value lambda:" $$ ppr expr
|
|
| 435 | 433 | |
| 436 | 434 | coreToStgExpr (Tick tick expr)
|
| 437 | 435 | = do
|
| ... | ... | @@ -391,7 +391,7 @@ import GHC.Types.Basic |
| 391 | 391 | import GHC.Core
|
| 392 | 392 | import GHC.Core.DataCon
|
| 393 | 393 | import GHC.Core.TyCon
|
| 394 | -import GHC.Data.FastString (FastString, mkFastString, fsLit)
|
|
| 394 | +import GHC.Data.FastString (FastString, fsLit)
|
|
| 395 | 395 | import GHC.Types.Id
|
| 396 | 396 | import GHC.Types.Literal
|
| 397 | 397 | import GHC.Core.Make (aBSENT_SUM_FIELD_ERROR_ID)
|
| ... | ... | @@ -681,7 +681,7 @@ elimCase rho args bndr (MultiValAlt _) [GenStgAlt{ alt_con = _ |
| 681 | 681 | |
| 682 | 682 | elimCase rho args@(tag_arg : real_args) bndr (MultiValAlt _) alts
|
| 683 | 683 | | isUnboxedSumBndr bndr
|
| 684 | - = do tag_bndr <- mkId (mkFastString "tag") tagTy
|
|
| 684 | + = do tag_bndr <- mkId (fsLit "tag") tagTy
|
|
| 685 | 685 | -- this won't be used but we need a binder anyway
|
| 686 | 686 | let rho1 = extendRho rho bndr (MultiVal args)
|
| 687 | 687 | scrut' = case tag_arg of
|
| ... | ... | @@ -871,10 +871,9 @@ mapSumIdBinders alt_bndr args rhs rho0 |
| 871 | 871 | -- text "rhs" <+> ppr rhs $$
|
| 872 | 872 | -- text "rhs_with_casts" <+> ppr rhs_with_casts
|
| 873 | 873 | -- ) $
|
| 874 | - if isMultiValBndr alt_bndr
|
|
| 875 | - then return (extendRho rho0 alt_bndr (MultiVal typed_id_args), rhs_with_casts rhs)
|
|
| 876 | - else assert (typed_id_args `lengthIs` 1) $
|
|
| 877 | - return (extendRho rho0 alt_bndr (UnaryVal (head typed_id_args)), rhs_with_casts rhs)
|
|
| 874 | + case typed_id_args of
|
|
| 875 | + [arg] -> return (extendRho rho0 alt_bndr (UnaryVal arg), rhs_with_casts rhs)
|
|
| 876 | + _ -> return (extendRho rho0 alt_bndr (MultiVal typed_id_args), rhs_with_casts rhs)
|
|
| 878 | 877 | |
| 879 | 878 | -- Convert the argument to the given type, and wrap the conversion
|
| 880 | 879 | -- around the given expression. Use the given Id as a name for the
|
| ... | ... | @@ -923,7 +922,7 @@ mkUbxSum dc ty_args args0 us |
| 923 | 922 | = let
|
| 924 | 923 | _ :| sum_slots = ubxSumRepType ty_args
|
| 925 | 924 | -- drop tag slot
|
| 926 | - field_slots = (mapMaybe (repSlotTy . stgArgRep) args0)
|
|
| 925 | + field_slots = (mapMaybe (repSlotTy . stgArgRep1) args0)
|
|
| 927 | 926 | tag = dataConTag dc
|
| 928 | 927 | layout' = layoutUbxSum sum_slots field_slots
|
| 929 | 928 | |
| ... | ... | @@ -1076,13 +1075,13 @@ unariseArgBinder is_con_arg rho x = |
| 1076 | 1075 | -- break the post-unarisation invariant that says unboxed tuple/sum
|
| 1077 | 1076 | -- binders should vanish. See Note [Post-unarisation invariants].
|
| 1078 | 1077 | | isUnboxedSumType (idType x) || isUnboxedTupleType (idType x)
|
| 1079 | - -> do x' <- mkId (mkFastString "us") (primRepToType rep)
|
|
| 1078 | + -> do x' <- mkId (fsLit "us") (primRepToType rep)
|
|
| 1080 | 1079 | return (extendRho rho x (MultiVal [StgVarArg x']), [x'])
|
| 1081 | 1080 | | otherwise
|
| 1082 | 1081 | -> return (extendRhoWithoutValue rho x, [x])
|
| 1083 | 1082 | |
| 1084 | 1083 | reps -> do
|
| 1085 | - xs <- mkIds (mkFastString "us") (map primRepToType reps)
|
|
| 1084 | + xs <- mkIds (fsLit "us") (map primRepToType reps)
|
|
| 1086 | 1085 | return (extendRho rho x (MultiVal (map StgVarArg xs)), xs)
|
| 1087 | 1086 | |
| 1088 | 1087 | --------------------------------------------------------------------------------
|
| ... | ... | @@ -1150,13 +1149,6 @@ mkIds fs tys = mkUnarisedIds fs tys |
| 1150 | 1149 | mkId :: FastString -> NvUnaryType -> UniqSM Id
|
| 1151 | 1150 | mkId s t = mkUnarisedId s t
|
| 1152 | 1151 | |
| 1153 | -isMultiValBndr :: Id -> Bool
|
|
| 1154 | -isMultiValBndr id
|
|
| 1155 | - | [_] <- typePrimRep (idType id)
|
|
| 1156 | - = False
|
|
| 1157 | - | otherwise
|
|
| 1158 | - = True
|
|
| 1159 | - |
|
| 1160 | 1152 | isUnboxedSumBndr :: Id -> Bool
|
| 1161 | 1153 | isUnboxedSumBndr = isUnboxedSumType . idType
|
| 1162 | 1154 |
| ... | ... | @@ -41,9 +41,6 @@ mkUnarisedIds fs tys = mapM (mkUnarisedId fs) tys |
| 41 | 41 | mkUnarisedId :: MonadUnique m => FastString -> NvUnaryType -> m Id
|
| 42 | 42 | mkUnarisedId s t = mkSysLocalM s ManyTy t
|
| 43 | 43 | |
| 44 | --- Checks if id is a top level error application.
|
|
| 45 | --- isErrorAp_maybe :: Id ->
|
|
| 46 | - |
|
| 47 | 44 | -- | Extract the default case alternative
|
| 48 | 45 | -- findDefaultStg :: [Alt b] -> ([Alt b], Maybe (Expr b))
|
| 49 | 46 | findDefaultStg
|
| ... | ... | @@ -390,12 +390,12 @@ slowArgs platform args sccProfilingEnabled -- careful: reps contains voids (V), |
| 390 | 390 | stg_ap_pat = mkCmmRetInfoLabel rtsUnitId arg_pat
|
| 391 | 391 | this_pat = (N, Just (mkLblExpr stg_ap_pat)) : call_args
|
| 392 | 392 | save_cccs = [(N, Just (mkLblExpr save_cccs_lbl)), (N, Just $ cccsExpr platform)]
|
| 393 | - save_cccs_lbl = mkCmmRetInfoLabel rtsUnitId (fsLit $ "stg_restore_cccs_" ++ arg_reps)
|
|
| 394 | - arg_reps = case maximum (fmap fst args1) of
|
|
| 395 | - V64 -> "v64"
|
|
| 396 | - V32 -> "v32"
|
|
| 397 | - V16 -> "v16"
|
|
| 398 | - _ -> "d"
|
|
| 393 | + save_cccs_lbl = mkCmmRetInfoLabel rtsUnitId label_name
|
|
| 394 | + label_name = case maximum (fmap fst args1) of
|
|
| 395 | + V64 -> fsLit "stg_restore_cccs_v64"
|
|
| 396 | + V32 -> fsLit "stg_restore_cccs_v32"
|
|
| 397 | + V16 -> fsLit "stg_restore_cccs_v16"
|
|
| 398 | + _ -> fsLit "stg_restore_cccs_d"
|
|
| 399 | 399 | |
| 400 | 400 | |
| 401 | 401 |
| ... | ... | @@ -295,11 +295,9 @@ instance Outputable SlotTy where |
| 295 | 295 | ppr FloatSlot = text "FloatSlot"
|
| 296 | 296 | ppr (VecSlot n e) = text "VecSlot" <+> ppr n <+> ppr e
|
| 297 | 297 | |
| 298 | -repSlotTy :: [PrimRep] -> Maybe SlotTy
|
|
| 299 | -repSlotTy reps = case reps of
|
|
| 300 | - [] -> Nothing
|
|
| 301 | - [rep] -> Just (primRepSlot rep)
|
|
| 302 | - _ -> pprPanic "repSlotTy" (ppr reps)
|
|
| 298 | +repSlotTy :: PrimOrVoidRep -> Maybe SlotTy
|
|
| 299 | +repSlotTy VoidRep = Nothing
|
|
| 300 | +repSlotTy (NVRep rep) = Just (primRepSlot rep)
|
|
| 303 | 301 | |
| 304 | 302 | primRepSlot :: PrimRep -> SlotTy
|
| 305 | 303 | primRepSlot (BoxedRep mlev) = case mlev of
|
| ... | ... | @@ -15,8 +15,6 @@ else: |
| 15 | 15 | |
| 16 | 16 | libs_base_uri = '../libraries'
|
| 17 | 17 | |
| 18 | -# N.B. If you add a package to this list be sure to also add a corresponding
|
|
| 19 | -# LIBRARY_VERSION macro call to configure.ac.
|
|
| 20 | 18 | lib_versions = {
|
| 21 | 19 | 'base': '@LIBRARY_base_UNIT_ID@',
|
| 22 | 20 | 'ghc-prim': '@LIBRARY_ghc_prim_UNIT_ID@',
|
| ... | ... | @@ -167,6 +167,9 @@ rnfKindRep (KindRepTypeLitD _ t) = rnfString t |
| 167 | 167 | |
| 168 | 168 | rnfRuntimeRep :: RuntimeRep -> ()
|
| 169 | 169 | rnfRuntimeRep (VecRep !_ !_) = ()
|
| 170 | +rnfRuntimeRep (TupleRep rs) = rnfList rnfRuntimeRep rs
|
|
| 171 | +rnfRuntimeRep (SumRep rs) = rnfList rnfRuntimeRep rs
|
|
| 172 | +rnfRuntimeRep (BoxedRep !_) = ()
|
|
| 170 | 173 | rnfRuntimeRep !_ = ()
|
| 171 | 174 | |
| 172 | 175 | rnfList :: (a -> ()) -> [a] -> ()
|
| ... | ... | @@ -2294,7 +2294,7 @@ instance ExactPrint (HsBind GhcPs) where |
| 2294 | 2294 | bind' <- markAnnotated bind
|
| 2295 | 2295 | return (PatSynBind x bind')
|
| 2296 | 2296 | |
| 2297 | - exact x = error $ "HsBind: exact for " ++ showAst x
|
|
| 2297 | + exact (VarBind x _ _) = dataConCantHappen x
|
|
| 2298 | 2298 | |
| 2299 | 2299 | -- ---------------------------------------------------------------------
|
| 2300 | 2300 |