summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToCmm/Closure.hs
diff options
context:
space:
mode:
authorRodrigo Mesquita <rodrigo.m.mesquita@gmail.com>2023-04-17 12:04:40 +0100
committerRodrigo Mesquita <rodrigo.m.mesquita@gmail.com>2023-04-28 17:18:55 +0100
commit7982d836b365ea35990b5064d0b71be410349edc (patch)
tree3e0f097b265aa1e810b566d598296a85d16fd843 /compiler/GHC/StgToCmm/Closure.hs
parent4eaf2c2a7682fa9933261f5eb25da9e2333c9608 (diff)
downloadhaskell-7982d836b365ea35990b5064d0b71be410349edc.tar.gz
Precompute static closures for DataCons with zero-width argswip/romes/isNullaryRepDataCon
Relax the predicate over nullary datacons that determines whether we can return a precomputed static closure for them, such that we give precomputed static closures to both datacon workers and wrappers as long as they only take zero-width arguments (and hence their closure is comprised of just the constructor info). Previously, we would only allow datacons that were nullary with regard to their Core representation, which prevented datacons workers with only zero-width arguments and wrappers with none from using a precomputed static closure. See Note [Precomputed static closures of nullary constructors] Closes #23158
Diffstat (limited to 'compiler/GHC/StgToCmm/Closure.hs')
-rw-r--r--compiler/GHC/StgToCmm/Closure.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/GHC/StgToCmm/Closure.hs b/compiler/GHC/StgToCmm/Closure.hs
index fc76664d94..56cd91596e 100644
--- a/compiler/GHC/StgToCmm/Closure.hs
+++ b/compiler/GHC/StgToCmm/Closure.hs
@@ -22,7 +22,7 @@ module GHC.StgToCmm.Closure (
argPrimRep,
NonVoid(..), fromNonVoid, nonVoidIds, nonVoidStgArgs,
- assertNonVoidIds, assertNonVoidStgArgs,
+ assertNonVoidIds, assertNonVoidStgArgs, hasNoNonZeroWidthArgs,
-- * LambdaFormInfo
LambdaFormInfo, -- Abstract
@@ -170,6 +170,12 @@ assertNonVoidStgArgs :: [StgArg] -> [NonVoid StgArg]
assertNonVoidStgArgs args = assert (not (any (isZeroBitTy . stgArgType) args)) $
coerce args
+-- | Returns whether there are any arguments with a non-zero-width runtime
+-- representation.
+--
+-- Returns True if the datacon has no or /just/ zero-width arguments.
+hasNoNonZeroWidthArgs :: DataCon -> Bool
+hasNoNonZeroWidthArgs = all (isZeroBitTy . scaledThing) . dataConRepArgTys
-----------------------------------------------------------------------------
-- Representations