[Git][ghc/ghc][wip/spj-reinstallable-base2] 3 commits: drop unused
Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: 3684a107 by Rodrigo Mesquita at 2026-05-11T13:49:39+01:00 drop unused - - - - - 2ae79b84 by Rodrigo Mesquita at 2026-05-11T15:30:44+01:00 fix callstack error Fixes - - - - - df000ae1 by Rodrigo Mesquita at 2026-05-11T15:31:21+01:00 Reapply "unsafeCoercePrimName" This reverts commit 95664bfbe31baca788611380776de0c9c4d060b5. - - - - - 7 changed files: - compiler/GHC/Builtin/KnownKeys.hs - compiler/GHC/HsToCore.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Utils/Concrete.hs - libraries/base/src/GHC/Essentials.hs - libraries/ghc-internal/src/GHC/Internal/Classes/IP.hs - libraries/ghc-internal/src/GHC/Internal/Stack/Types.hs Changes: ===================================== compiler/GHC/Builtin/KnownKeys.hs ===================================== @@ -271,6 +271,9 @@ knownKeyTable , (mkDataOcc ":$$:", typeErrorVAppendDataConKey) , (mkDataOcc "ShowType", typeErrorShowTypeDataConKey) + -- Unsafe coercion proofs + , (mkVarOcc "unsafeCoerce#", unsafeCoercePrimIdKey) + -- Plugins , (mkTcOcc "Plugin", pluginTyConKey) , (mkTcOcc "FrontendPlugin", frontendPluginTyConKey) @@ -368,8 +371,6 @@ knownKeyTable basicKnownKeyNames :: [Name] -- See Note [Known-key names] basicKnownKeyNames = [ - -- Unsafe coercion proofs - unsafeCoercePrimName ] @@ -416,25 +417,10 @@ bniVarQual str key = varQual gHC_INTERNAL_NUM_INTEGER (fsLit str) key -- End of ghc-bignum --------------------------------- - --- Class Typeable, and functions for constructing `Typeable` dictionaries -starKindRepName, starArrStarKindRepName, - starArrStarArrStarKindRepName, constraintKindRepName :: Name --- This is the Typeable 'Module' for GHC.Prim (which has no code, so we place in GHC.Types) --- See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable. -starKindRepName = varQual gHC_TYPES (fsLit "krepStar") starKindRepKey -starArrStarKindRepName = varQual gHC_TYPES (fsLit "krepStarArr") starArrStarKindRepKey -starArrStarArrStarKindRepName = varQual gHC_TYPES (fsLit "krepStarArrStarArr") starArrStarArrStarKindRepKey -constraintKindRepName = varQual gHC_TYPES (fsLit "krepConstraint") constraintKindRepKey - -- WithDict withDictClassName :: Name withDictClassName = clsQual gHC_MAGIC_DICT (fsLit "WithDict") withDictClassKey --- Unsafe coercion proofs -unsafeCoercePrimName:: Name -unsafeCoercePrimName = varQual gHC_INTERNAL_UNSAFE_COERCE (fsLit "unsafeCoerce#") unsafeCoercePrimIdKey - genericClassKeys :: [KnownKey] genericClassKeys = [genClassKey, gen1ClassKey] ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -86,7 +86,6 @@ import GHC.Types.SourceFile import GHC.Types.TypeEnv import GHC.Types.Name import GHC.Types.Name.Set -import GHC.Types.Name.Env import GHC.Types.Name.Ppr import GHC.Types.HpcInfo @@ -99,6 +98,7 @@ import Data.List (partition) import Data.IORef import GHC.Iface.Make (mkRecompUsageInfo) import GHC.Runtime.Interpreter (interpreterProfiled) +import GHC.Types.Unique.FM {- ************************************************************************ @@ -684,13 +684,14 @@ patchMagicDefns pairs -- optimization: check whether we're in a magic module before looking -- at all the ids = do { this_mod <- getModule + ; magicDefnModules <- mkMagicDefnModules ; if this_mod `elemModuleSet` magicDefnModules then traverse patchMagicDefn pairs else return pairs } patchMagicDefn :: (Id, CoreExpr) -> DsM (Id, CoreExpr) patchMagicDefn orig_pair@(orig_id, orig_rhs) - | Just mk_magic_pair <- lookupNameEnv magicDefnsEnv (getName orig_id) + | Just mk_magic_pair <- lookupUFM magicDefnsEnv (getUnique orig_id) = do { magic_pair@(magic_id, _) <- mk_magic_pair orig_id orig_rhs -- Patching should not change the Name or the type of the Id @@ -701,22 +702,25 @@ patchMagicDefn orig_pair@(orig_id, orig_rhs) | otherwise = return orig_pair -magicDefns :: [(Name, Id -> CoreExpr -- old Id and RHS +magicDefns :: [(KnownKey, Id -> CoreExpr -- old Id and RHS -> DsM (Id, CoreExpr) -- new Id and RHS )] -magicDefns = [ (unsafeCoercePrimName, mkUnsafeCoercePrimPair) ] +magicDefns = [ (unsafeCoercePrimIdKey, mkUnsafeCoercePrimPair) ] -magicDefnsEnv :: NameEnv (Id -> CoreExpr -> DsM (Id, CoreExpr)) -magicDefnsEnv = mkNameEnv magicDefns +magicDefnsEnv :: UniqFM KnownKey (Id -> CoreExpr -> DsM (Id, CoreExpr)) +magicDefnsEnv = listToUFM magicDefns -magicDefnModules :: ModuleSet -magicDefnModules = mkModuleSet $ map (nameModule . getName . fst) magicDefns +mkMagicDefnModules :: DsM ModuleSet +mkMagicDefnModules = do + mods <- mapM (fmap nameModule . dsLookupKnownKeyName . fst) magicDefns + pure $ mkModuleSet mods mkUnsafeCoercePrimPair :: Id -> CoreExpr -> DsM (Id, CoreExpr) -- See Note [Wiring in unsafeCoerce#] for the defn we are creating here mkUnsafeCoercePrimPair _old_id old_expr = do { unsafe_equality_proof_id <- dsLookupKnownKeyId unsafeEqualityProofIdKey ; unsafe_equality_tc <- dsLookupKnownKeyTyCon unsafeEqualityTyConKey + ; unsafeCoercePrimName <- dsLookupKnownKeyName unsafeCoercePrimIdKey ; let [unsafe_refl_data_con] = tyConDataCons unsafe_equality_tc ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2566,7 +2566,7 @@ tcGhciStmts stmts -- We use Any rather than a dummy type such as () because of -- the rules of unsafeCoerce#; see Unsafe/Coerce.hs for the details. - ; AnId unsafe_coerce_id <- tcLookupGlobal unsafeCoercePrimName + ; AnId unsafe_coerce_id <- tcLookupKnownKeyGlobal unsafeCoercePrimIdKey -- We use unsafeCoerce# here because of (U11) in -- Note [Implementing unsafeCoerce] in base:Unsafe.Coerce ===================================== compiler/GHC/Tc/Utils/Concrete.hs ===================================== @@ -18,7 +18,7 @@ module GHC.Tc.Utils.Concrete import GHC.Prelude -import GHC.Builtin.KnownKeys ( unsafeCoercePrimName ) +import GHC.Builtin.KnownKeys ( unsafeCoercePrimIdKey ) import GHC.Builtin.WiredIn.Types import GHC.Core.Coercion @@ -45,6 +45,7 @@ import GHC.Utils.Outputable import GHC.Data.FastString ( FastString, fsLit ) import Control.Monad ( void ) +import GHC.Types.Name (hasKnownKey) {- Note [Concrete overview] @@ -857,7 +858,7 @@ idConcreteTvs id -- in the correct information in the desugarer). -- So, for the time being, we manually inspect the type of the original, -- unpatched Id to retrieve which of its outer forall-d tyvars should be concrete. - | idName id == unsafeCoercePrimName + | id `hasKnownKey`unsafeCoercePrimIdKey , (a_rep:_b_rep:a:_b:_, _) <- tcSplitForAllTyVars $ idType id -- NB: only check the argument representation, not the result representation. -- This is because the following is OK: @@ -866,7 +867,7 @@ idConcreteTvs id -- unsafeCoerceWordRep = unsafeCoerce# = mkNameEnv [(tyVarName a_rep, ConcreteFRR $ FixedRuntimeRepOrigin (mkTyVarTy a) - $ FRRRepPolyId unsafeCoercePrimName RepPolyFunction + $ FRRRepPolyId (idName id) RepPolyFunction $ mkArgPos 1 Top)] | otherwise ===================================== libraries/base/src/GHC/Essentials.hs ===================================== @@ -161,7 +161,7 @@ module GHC.Essentials , CS.unpackAppendCStringUtf8#, CS.cstringLength# , eqString, inline - , UnsafeEquality( UnsafeRefl ), unsafeEqualityProof + , UnsafeEquality( UnsafeRefl ), unsafeEqualityProof, unsafeCoerce# -- Typeable and type representations , SomeTypeRep( SomeTypeRep ), TR.Module( Module ) ===================================== libraries/ghc-internal/src/GHC/Internal/Classes/IP.hs ===================================== @@ -7,7 +7,7 @@ -- LANGUAGE pragmas: see Note [IP: implicit parameter class] {-# OPTIONS_HADDOCK not-home #-} -{-# OPTIONS_GHC -fdefine-known-key-names -} +{-# OPTIONS_GHC -fdefines-known-key-names #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Internal.Classes.IP ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/Types.hs ===================================== @@ -53,6 +53,7 @@ import cycle, -} import GHC.Internal.Classes ( Eq( (==) ), (&&) ) +import GHC.Internal.Classes.IP as Rebindable import GHC.Internal.Types default () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/50ba27b54ab9efc70036655157d9cbb... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/50ba27b54ab9efc70036655157d9cbb... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)