[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:07:43 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/static-gadt-con-info at Glasgow Haskell Compiler / GHC


Commits:
be3f199f by romes at 2023-03-22T21:53:08+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

- - - - -


1 changed file:

- compiler/GHC/StgToCmm/DataCon.hs


Changes:

=====================================
compiler/GHC/StgToCmm/DataCon.hs
=====================================
@@ -41,7 +41,7 @@ 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,7 +327,7 @@ 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))
 precomputedStaticConInfo_maybe cfg binder con [arg]
@@ -371,6 +371,15 @@ precomputedStaticConInfo_maybe cfg binder con [arg]
       | charClosure =  "stg_CHARLIKE"
       | otherwise = panic "precomputedStaticConInfo_maybe: Unknown closure type"
 
+    -- 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 (isZeroBitTy . scaledThing) . dataConRepArgTys
+
 precomputedStaticConInfo_maybe _ _ _ _ = Nothing
 
 ---------------------------------------------------------------



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be3f199fd4013d75a8ae6769fda98c143e677f00

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be3f199fd4013d75a8ae6769fda98c143e677f00
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/9188b31c/attachment-0001.html>


More information about the ghc-commits mailing list