[Git][ghc/ghc][wip/romes/static-gadt-con-info] Account for all VoidRep types on precomputedStaticConInfo
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Wed Mar 22 22:43:40 UTC 2023
Rodrigo Mesquita pushed to branch wip/romes/static-gadt-con-info at Glasgow Haskell Compiler / GHC
Commits:
c26f67d3 by romes at 2023-03-22T22:43:24+00:00
Account for all VoidRep types on precomputedStaticConInfo
Previously, we were considering coercion values whose unlifted type
equality had a zerobit runtime representation (VoidRep) to be
constructor arguments when determining whether we should pre-compute a
staticConInfo for a data constructor.
This made it so that GADT constructors with type-equality constraints
that should have no runtime representation actually ended up impacting
the code generation.
Fixes #23158
- - - - -
2 changed files:
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/StgToCmm/DataCon.hs
Changes:
=====================================
compiler/GHC/Core/DataCon.hs
=====================================
@@ -1397,7 +1397,7 @@ dataConSourceArity (MkData { dcSourceArity = arity }) = arity
-- | Gives the number of actual fields in the /representation/ of the
-- data constructor. This may be more than appear in the source code;
--- the extra ones are the existentially quantified dictionaries
+-- the extra ones are the existentially quantified dictionaries. ROMES:TODO:
dataConRepArity :: DataCon -> Arity
dataConRepArity (MkData { dcRepArity = arity }) = arity
=====================================
compiler/GHC/StgToCmm/DataCon.hs
=====================================
@@ -37,11 +37,12 @@ import GHC.Runtime.Heap.Layout
import GHC.Types.CostCentre
import GHC.Unit
import GHC.Core.DataCon
+import GHC.Core.TyCo.Rep (scaledThing)
import GHC.Data.FastString
import GHC.Types.Id
import GHC.Types.Id.Info( CafInfo( NoCafRefs ) )
import GHC.Types.Name (isInternalName)
-import GHC.Types.RepType (countConRepArgs)
+import GHC.Types.RepType (countConRepArgs, isZeroBitTy)
import GHC.Types.Literal
import GHC.Builtin.Utils
import GHC.Utils.Panic
@@ -327,9 +328,19 @@ because they don't support cross package data references well.
precomputedStaticConInfo_maybe :: StgToCmmConfig -> Id -> DataCon -> [NonVoid StgArg] -> Maybe CgIdInfo
precomputedStaticConInfo_maybe cfg binder con []
-- Nullary constructors
- | isNullaryRepDataCon con
+ | isStgNullaryDataCon con
= Just $ litIdInfo (stgToCmmPlatform cfg) binder (mkConLFInfo con)
(CmmLabel (mkClosureLabel (dataConName con) NoCafRefs))
+ where
+ -- morally equivalent to (isNullaryRepDataCon con) at the Stg level, where we
+ -- doesn't consider types with no runtime representation to be constructor arguments.
+ --
+ -- isNullaryRepDataCon is not fit for checking whether the constructor is
+ -- nullary at the Stg level because the function 'dataConRepArgTys' it
+ -- depends on includes unlifted type equalities, whose runtime
+ -- representation is 'VoidRep', in the returned list.
+ isStgNullaryDataCon = null . filter (not . isZeroBitTy . scaledThing) . dataConRepArgTys
+
precomputedStaticConInfo_maybe cfg binder con [arg]
-- Int/Char values with existing closures in the RTS
| intClosure || charClosure
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c26f67d3028874a358de9baeae2e5ba39e468fa6
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c26f67d3028874a358de9baeae2e5ba39e468fa6
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/20230322/4aa97f6c/attachment-0001.html>
More information about the ghc-commits
mailing list