[Git][ghc/ghc][wip/romes/fixes-2] task: Substitute some datatypes for newtypes
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Fri Jun 23 22:05:44 UTC 2023
Rodrigo Mesquita pushed to branch wip/romes/fixes-2 at Glasgow Haskell Compiler / GHC
Commits:
9d820cbc by Rodrigo Mesquita at 2023-06-23T23:05:32+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
=====================================
@@ -542,7 +542,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
=====================================
@@ -51,4 +51,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/9d820cbc2e8a7e61bded28be8d6710f73010d00a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d820cbc2e8a7e61bded28be8d6710f73010d00a
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230623/dd18d8d8/attachment-0001.html>
More information about the ghc-commits
mailing list