summaryrefslogtreecommitdiff
path: root/compiler/GHC/Stg/Unarise.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-05-27 12:02:45 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-05 19:23:46 -0400
commit52a524f7c8c5701708a007a5946c27914703d045 (patch)
tree63e5417205788aa800e06ef679f96ca29a3586aa /compiler/GHC/Stg/Unarise.hs
parentea9a4ef69a382cf3cee28b78eca390a6a06c6965 (diff)
downloadhaskell-52a524f7c8c5701708a007a5946c27914703d045.tar.gz
Re-do rubbish literals
As #19882 pointed out, we were simply doing rubbish literals wrong. (I'll refrain from explaining the wrong-ness here -- see the ticket.) This patch fixes it by adding a Type (of kind RuntimeRep) as field of LitRubbish, rather than [PrimRep]. The Note [Rubbish literals] in GHC.Types.Literal explains the details.
Diffstat (limited to 'compiler/GHC/Stg/Unarise.hs')
-rw-r--r--compiler/GHC/Stg/Unarise.hs23
1 files changed, 11 insertions, 12 deletions
diff --git a/compiler/GHC/Stg/Unarise.hs b/compiler/GHC/Stg/Unarise.hs
index 6b41063f9b..b3ae7957d9 100644
--- a/compiler/GHC/Stg/Unarise.hs
+++ b/compiler/GHC/Stg/Unarise.hs
@@ -231,7 +231,7 @@ STG programs after unarisation have these invariants:
This means that it's safe to wrap `StgArg`s of DataCon applications with
`GHC.StgToCmm.Env.NonVoid`, for example.
- * Similar to unboxed tuples, Note [Rubbish values] of TupleRep may only
+ * Similar to unboxed tuples, Note [Rubbish literals] of TupleRep may only
appear in return position.
* Alt binders (binders in patterns) are always non-void.
@@ -390,7 +390,7 @@ unariseExpr rho (StgCase scrut bndr alt_ty alts)
, Just args' <- unariseMulti_maybe rho dc args ty_args
= elimCase rho args' bndr alt_ty alts
- -- See (3) of Note [Rubbish values] in GHC.Types.Literal
+ -- See (3) of Note [Rubbish literals] in GHC.Types.Literal
| StgLit lit <- scrut
, Just args' <- unariseRubbish_maybe lit
= elimCase rho args' bndr alt_ty alts
@@ -427,19 +427,18 @@ unariseMulti_maybe rho dc args ty_args
-- Doesn't return void args.
unariseRubbish_maybe :: Literal -> Maybe [OutStgArg]
-unariseRubbish_maybe lit
- | LitRubbish preps <- lit
- , [prep] <- preps
+unariseRubbish_maybe (LitRubbish rep)
+ | [prep] <- preps
, not (isVoidRep prep)
- -- Single, non-void PrimRep. Nothing to do!
- = Nothing
+ = Nothing -- Single, non-void PrimRep. Nothing to do!
- | LitRubbish preps <- lit
- -- Multiple reps, possibly with VoidRep. Eliminate!
- = Just [ StgLitArg (LitRubbish [prep]) | prep <- preps, not (isVoidRep prep) ]
+ | otherwise -- Multiple reps, possibly with VoidRep. Eliminate via elimCase
+ = Just [ StgLitArg (LitRubbish (primRepToType prep))
+ | prep <- preps, not (isVoidRep prep) ]
+ where
+ preps = runtimeRepPrimRep (text "unariseRubbish_maybe") rep
- | otherwise
- = Nothing
+unariseRubbish_maybe _ = Nothing
--------------------------------------------------------------------------------