[Git][ghc/ghc][wip/romes/isNullaryRepDataCon] WIP: Do the right thing; needs documentation

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Wed Apr 26 19:11:59 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/isNullaryRepDataCon at Glasgow Haskell Compiler / GHC


Commits:
b75b3f37 by Rodrigo Mesquita at 2023-04-26T20:11:54+01:00
WIP: Do the right thing; needs documentation

- - - - -


1 changed file:

- compiler/GHC/StgToCmm/DataCon.hs


Changes:

=====================================
compiler/GHC/StgToCmm/DataCon.hs
=====================================
@@ -41,6 +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.Var (varName)
 import GHC.Types.RepType (countConRepArgs)
 import GHC.Types.Literal
 import GHC.Builtin.Utils
@@ -328,16 +329,10 @@ precomputedStaticConInfo_maybe :: StgToCmmConfig -> Id -> DataCon -> [NonVoid St
 precomputedStaticConInfo_maybe cfg binder con []
   -- Nullary constructors (list of nonvoid args is null)
   = assert (hasNoNonZeroWidthArgs con) $
-    if isDataConWorkId binder && not (isNullaryRepDataCon con)
-       -- this data con worker (TODO: what about wrappers?) only has zero-width
-       -- args, so we point to its short con app closure instead of its
-       -- function ( rememeber, we generate 2 closures for a data con that only
-       -- has zero-width args: one for the function it actually is, another for
-       -- the precomputed static closure we can still have for it )
-       then Just $ litIdInfo (stgToCmmPlatform cfg) binder (mkConLFInfo con)
-                      (CmmLabel (mkShortConAppLabel (dataConName con) NoCafRefs))
-       else Just $ litIdInfo (stgToCmmPlatform cfg) binder (mkConLFInfo con)
-                (CmmLabel (mkClosureLabel (dataConName con) NoCafRefs))
+      Just $ litIdInfo (stgToCmmPlatform cfg) binder (mkConLFInfo con)
+                (CmmLabel (mkClosureLabel (varName $ dataConWrapId con) NoCafRefs)) -- ROMES:TODO: note about this
+                                                                                    -- the error was we now were falling in this branch for the wrappers too, but returning the dataConName instead of the wrapper.
+                                                                                    -- If we always return 'dataConWrapId' this works. If there is a wrapper for the nullary constructor, it is what we want to use; otherwise, dataConWrapId falls back to the worker just as we needed
 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/b75b3f37312493ad0acadffe88dc1b38ca8614c8

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


More information about the ghc-commits mailing list