summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToByteCode.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-06-29 12:02:47 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-19 19:37:12 -0400
commit952ba18e596f406d08003a9ff07f95a5a94a2ede (patch)
treebdccdc0843b2e9d58f6eccc57fc2b4618d029451 /compiler/GHC/StgToByteCode.hs
parente5a4cfa51899e67db8fb17409660107b821d252d (diff)
downloadhaskell-952ba18e596f406d08003a9ff07f95a5a94a2ede.tar.gz
th: Weaken return type of myCoreToStgExpr
The previous code assumed properties of the CoreToStg translation, namely that a core let expression which be translated to a single non-recursive top-level STG binding. This assumption was false, as evidenced by #20060. The consequence of this was the need to modify the call sites of `myCoreToStgExpr`, the main one being in hscCompileCoreExpr', which the meant we had to use byteCodeGen instead of stgExprToBCOs to convert the returned value to bytecode. I removed the `stgExprToBCOs` function as it is no longer used in the compiler. There is still some partiallity with this patch (the lookup in hscCompileCoreExpr') but this should be more robust that before. Fixes #20060
Diffstat (limited to 'compiler/GHC/StgToByteCode.hs')
-rw-r--r--compiler/GHC/StgToByteCode.hs44
1 files changed, 1 insertions, 43 deletions
diff --git a/compiler/GHC/StgToByteCode.hs b/compiler/GHC/StgToByteCode.hs
index 64de0ff05e..78b24c97cd 100644
--- a/compiler/GHC/StgToByteCode.hs
+++ b/compiler/GHC/StgToByteCode.hs
@@ -11,7 +11,7 @@
--
-- | GHC.StgToByteCode: Generate bytecode from STG
-module GHC.StgToByteCode ( UnlinkedBCO, byteCodeGen, stgExprToBCOs ) where
+module GHC.StgToByteCode ( UnlinkedBCO, byteCodeGen) where
import GHC.Prelude
@@ -176,48 +176,6 @@ literals:
BcM and used when generating code for variable references.
-}
--- -----------------------------------------------------------------------------
--- Generating byte code for an expression
-
--- Returns: the root BCO for this expression
-stgExprToBCOs :: HscEnv
- -> Module
- -> Type
- -> StgRhs
- -> IO UnlinkedBCO
-stgExprToBCOs hsc_env this_mod expr_ty expr
- = withTiming logger
- (text "GHC.StgToByteCode"<+>brackets (ppr this_mod))
- (const ()) $ do
-
- -- the uniques are needed to generate fresh variables when we introduce new
- -- let bindings for ticked expressions
- us <- mkSplitUniqSupply 'y'
- (BcM_State _dflags _us _this_mod _final_ctr mallocd _ _ _, proto_bco)
- <- runBc hsc_env us this_mod Nothing emptyVarEnv $ do
- prepd_expr <- annBindingFreeVars <$>
- bcPrepBind (StgNonRec dummy_id expr)
- case prepd_expr of
- (StgNonRec _ cg_expr) -> schemeR [] (idName dummy_id, cg_expr)
- _ ->
- panic "GHC.StgByteCode.stgExprToBCOs"
-
- when (notNull mallocd)
- (panic "GHC.StgToByteCode.stgExprToBCOs: missing final emitBc?")
-
- putDumpFileMaybe logger Opt_D_dump_BCOs "Proto-BCOs" FormatByteCode
- (ppr proto_bco)
-
- assembleOneBCO interp profile proto_bco
- where dflags = hsc_dflags hsc_env
- logger = hsc_logger hsc_env
- profile = targetProfile dflags
- interp = hscInterp hsc_env
- -- we need an otherwise unused Id for bytecode generation
- dummy_id = mkSysLocal (fsLit "BCO_toplevel")
- (mkPseudoUniqueE 0)
- Many
- expr_ty
{-
Prepare the STG for bytecode generation: