summaryrefslogtreecommitdiff
path: root/compiler/GHC/CoreToStg/Prep.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-06-30 15:06:25 -0400
committerBen Gamari <ben@smart-cactus.org>2022-07-15 18:16:28 -0400
commitd75c540d439510491b45f64c1113762dcb251ae1 (patch)
tree6fb957684ff84c94055ea246678679003aeec1a3 /compiler/GHC/CoreToStg/Prep.hs
parent3d5f9ba19fea5455d778d2ee9c3fdcaad77d1db7 (diff)
downloadhaskell-wip/T21708.tar.gz
Make keepAlive# out-of-linewip/T21708
This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203
Diffstat (limited to 'compiler/GHC/CoreToStg/Prep.hs')
-rw-r--r--compiler/GHC/CoreToStg/Prep.hs33
1 files changed, 0 insertions, 33 deletions
diff --git a/compiler/GHC/CoreToStg/Prep.hs b/compiler/GHC/CoreToStg/Prep.hs
index 583badce52..d03df0eedb 100644
--- a/compiler/GHC/CoreToStg/Prep.hs
+++ b/compiler/GHC/CoreToStg/Prep.hs
@@ -28,10 +28,7 @@ import GHC.Tc.Utils.Env
import GHC.Unit
import GHC.Builtin.Names
-import GHC.Builtin.PrimOps
-import GHC.Builtin.PrimOps.Ids (primOpId)
import GHC.Builtin.Types
-import GHC.Builtin.Types.Prim ( realWorldStatePrimTy )
import GHC.Core.Utils
import GHC.Core.Opt.Arity
@@ -1072,36 +1069,6 @@ cpeApp top_env expr
= let (terminal, args') = collect_args arg
in cpe_app env terminal (args' ++ args)
- -- See Note [keepAlive# magic].
- cpe_app env
- (Var f)
- args
- | Just KeepAliveOp <- isPrimOpId_maybe f
- , CpeApp (Type arg_lev)
- : CpeApp (Type _result_rep)
- : CpeApp (Type arg_ty)
- : CpeApp (Type result_ty)
- : CpeApp arg
- : CpeApp s0
- : CpeApp k
- : rest <- args
- = do { y <- newVar (cpSubstTy env result_ty)
- ; s2 <- newVar realWorldStatePrimTy
- ; -- beta reduce if possible
- ; (floats, k') <- case k of
- Lam s body -> cpe_app (extendCorePrepEnvExpr env s s0) body rest
- _ -> cpe_app env k (CpeApp s0 : rest)
- ; let touchId = primOpId TouchOp
- expr = Case k' y result_ty [Alt DEFAULT [] rhs]
- rhs = let scrut = mkApps (Var touchId) [Type arg_lev, Type arg_ty, arg, Var realWorldPrimId]
- in Case scrut s2 result_ty [Alt DEFAULT [] (Var y)]
- ; (floats', expr') <- cpeBody env expr
- ; return (floats `appendFloats` floats', expr')
- }
- | Just KeepAliveOp <- isPrimOpId_maybe f
- = pprPanic "invalid keepAlive# application" $
- vcat [ text "args:" <+> ppr args ]
-
-- runRW# magic
cpe_app env (Var f) (CpeApp _runtimeRep@Type{} : CpeApp _type@Type{} : CpeApp arg : rest)
| f `hasKey` runRWKey