diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-04-08 17:26:55 +0200 |
---|---|---|
committer | Sebastian Graf <sebastian.graf@kit.edu> | 2020-04-09 10:36:57 +0200 |
commit | 84f0448c56b4a8b37e34fc1ae6faca20c7c1729c (patch) | |
tree | a93e2cab653ecee91e6b4e4f2f7a6e7e801bdf3d /compiler/GHC/Core/TyCon.hs | |
parent | 255418da5d264fb2758bc70925adb2094f34adc3 (diff) | |
download | haskell-wip/smaller-coreView.tar.gz |
Special case `isConstraintKindCon` on `AlgTyCon`wip/smaller-coreView
Previously, the `tyConUnique` record selector would unfold into a huge
case expression that would be inlined in all call sites, such as the
`INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only
occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code
a lot more compact, but have to move it to GHC.Core.TyCon.
Metric Decrease:
T12150
T12234
Diffstat (limited to 'compiler/GHC/Core/TyCon.hs')
-rw-r--r-- | compiler/GHC/Core/TyCon.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs index 64782e02b4..d28d8b0f0c 100644 --- a/compiler/GHC/Core/TyCon.hs +++ b/compiler/GHC/Core/TyCon.hs @@ -45,7 +45,7 @@ module GHC.Core.TyCon( noTcTyConScopedTyVars, -- ** Predicates on TyCons - isAlgTyCon, isVanillaAlgTyCon, + isAlgTyCon, isVanillaAlgTyCon, isConstraintKindCon, isClassTyCon, isFamInstTyCon, isFunTyCon, isPrimTyCon, @@ -1868,6 +1868,15 @@ isVanillaAlgTyCon :: TyCon -> Bool isVanillaAlgTyCon (AlgTyCon { algTcParent = VanillaAlgTyCon _ }) = True isVanillaAlgTyCon _ = False +-- | Returns @True@ for the 'TyCon' of the 'Constraint' kind. +isConstraintKindCon :: TyCon -> Bool +-- NB: We intentionally match on AlgTyCon, because 'constraintKindTyCon' is +-- always an AlgTyCon (see 'pcTyCon' in TysWiredIn) and the record selector +-- for 'tyConUnique' would generate unreachable code for every other data +-- constructor of TyCon (see #18026). +isConstraintKindCon AlgTyCon { tyConUnique = u } = u == constraintKindTyConKey +isConstraintKindCon _ = False + isDataTyCon :: TyCon -> Bool -- ^ Returns @True@ for data types that are /definitely/ represented by -- heap-allocated constructors. These are scrutinised by Core-level |