[Git][ghc/ghc][master] task: Substitute some datatypes for newtypes
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: beae879b by Rodrigo Mesquita at 2025-12-03T15:42:37+01:00 task: Substitute some datatypes for newtypes * Substitutes some data type declarations for newtype declarations * Adds comment to `LlvmConfigCache`, which must decidedly not be a newtype. Fixes #23555 - - - - - 5 changed files: - compiler/GHC/CmmToAsm/AArch64/RegInfo.hs - compiler/GHC/CmmToAsm/PPC/RegInfo.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Driver/LlvmConfigCache.hs - compiler/GHC/Driver/Pipeline/Phases.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/RegInfo.hs ===================================== @@ -8,7 +8,7 @@ import GHC.Cmm import GHC.Utils.Outputable -data JumpDest = DestBlockId BlockId +newtype JumpDest = DestBlockId BlockId -- Debug Instance instance Outputable JumpDest where ===================================== compiler/GHC/CmmToAsm/PPC/RegInfo.hs ===================================== @@ -27,7 +27,7 @@ import GHC.Cmm.CLabel import GHC.Types.Unique import GHC.Utils.Outputable (ppr, text, Outputable, (<>)) -data JumpDest = DestBlockId BlockId +newtype JumpDest = DestBlockId BlockId -- Debug Instance instance Outputable JumpDest where ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -554,7 +554,7 @@ instance Eq (DeBruijn a) => Eq (DeBruijn (Maybe a)) where -- We also need to do the same for multiplicity! Which, since multiplicities are -- encoded simply as a 'Type', amounts to have a Trie for a pair of types. Tries -- of pairs are composition. -data BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a)) +newtype BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a)) -- TODO(22292): derive instance Functor BndrMap where ===================================== compiler/GHC/Driver/LlvmConfigCache.hs ===================================== @@ -18,6 +18,8 @@ import System.IO.Unsafe -- Currently implemented with unsafe lazy IO. But it could be implemented with -- an IORef as the exposed interface is in IO. data LlvmConfigCache = LlvmConfigCache LlvmConfig +-- NB: It is crucial for this to be a datatype, not a newtype. +-- Allocations can increase across the board over 20% otherwise (see the discussion on !10708 and non-final pipelines) initLlvmConfigCache :: FilePath -> IO LlvmConfigCache initLlvmConfigCache top_dir = pure $ LlvmConfigCache (unsafePerformIO $ initLlvmConfig top_dir) ===================================== compiler/GHC/Driver/Pipeline/Phases.hs ===================================== @@ -52,4 +52,4 @@ data TPhase res where T_MergeForeign :: PipeEnv -> HscEnv -> FilePath -> [FilePath] -> TPhase FilePath -- | A wrapper around the interpretation function for phases. -data PhaseHook = PhaseHook (forall a . TPhase a -> IO a) +newtype PhaseHook = PhaseHook (forall a . TPhase a -> IO a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/beae879bf676a4892aa5fbff0a79b078... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/beae879bf676a4892aa5fbff0a79b078... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)