summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2018-11-23 16:24:18 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2018-11-23 16:26:02 +0100
commitb2950e03b551d82d62ec25eb232284aaf121b4e2 (patch)
tree9f60d45f9ffaf350173a3d2aab0beda622bc3da2 /compiler/codeGen
parent7856676b72526cd674e84c43064b61ff3a07a0a1 (diff)
downloadhaskell-b2950e03b551d82d62ec25eb232284aaf121b4e2.tar.gz
Implement late lambda lift
Summary: This implements a selective lambda-lifting pass late in the STG pipeline. Lambda lifting has the effect of avoiding closure allocation at the cost of having to make former free vars available at call sites, possibly enlarging closures surrounding call sites in turn. We identify beneficial cases by means of an analysis that estimates closure growth. There's a Wiki page at https://ghc.haskell.org/trac/ghc/wiki/LateLamLift. Reviewers: simonpj, bgamari, simonmar Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #9476 Differential Revision: https://phabricator.haskell.org/D5224
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmm.hs4
-rw-r--r--compiler/codeGen/StgCmmBind.hs7
-rw-r--r--compiler/codeGen/StgCmmExpr.hs4
3 files changed, 6 insertions, 9 deletions
diff --git a/compiler/codeGen/StgCmm.hs b/compiler/codeGen/StgCmm.hs
index 59ceba8706..acd2aee5f4 100644
--- a/compiler/codeGen/StgCmm.hs
+++ b/compiler/codeGen/StgCmm.hs
@@ -45,7 +45,7 @@ import Module
import Outputable
import Stream
import BasicTypes
-import VarSet ( isEmptyVarSet )
+import VarSet ( isEmptyDVarSet )
import OrdList
import MkGraph
@@ -156,7 +156,7 @@ cgTopRhs dflags _rec bndr (StgRhsCon _cc con args)
-- see Note [Post-unarisation invariants] in UnariseStg
cgTopRhs dflags rec bndr (StgRhsClosure fvs cc upd_flag args body)
- = ASSERT(isEmptyVarSet fvs) -- There should be no free variables
+ = ASSERT(isEmptyDVarSet fvs) -- There should be no free variables
cgTopRhsClosure dflags rec bndr cc upd_flag args body
diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs
index dba122fd0c..9e14311d42 100644
--- a/compiler/codeGen/StgCmmBind.hs
+++ b/compiler/codeGen/StgCmmBind.hs
@@ -44,7 +44,7 @@ import Name
import Module
import ListSetOps
import Util
-import UniqSet ( nonDetEltsUniqSet )
+import VarSet
import BasicTypes
import Outputable
import FastString
@@ -209,10 +209,7 @@ cgRhs id (StgRhsCon cc con args)
{- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -}
cgRhs id (StgRhsClosure fvs cc upd_flag args body)
= do dflags <- getDynFlags
- mkRhsClosure dflags id cc (nonVoidIds (nonDetEltsUniqSet fvs)) upd_flag args body
- -- It's OK to use nonDetEltsUniqSet here because we're not aiming for
- -- bit-for-bit determinism.
- -- See Note [Unique Determinism and code generation]
+ mkRhsClosure dflags id cc (nonVoidIds (dVarSetElems fvs)) upd_flag args body
------------------------------------------------------------------------
-- Non-constructor right hand sides
diff --git a/compiler/codeGen/StgCmmExpr.hs b/compiler/codeGen/StgCmmExpr.hs
index 2430a0ddf9..5844161fc1 100644
--- a/compiler/codeGen/StgCmmExpr.hs
+++ b/compiler/codeGen/StgCmmExpr.hs
@@ -81,8 +81,8 @@ cgExpr (StgTick t e) = cgTick t >> cgExpr e
cgExpr (StgLit lit) = do cmm_lit <- cgLit lit
emitReturn [CmmLit cmm_lit]
-cgExpr (StgLet binds expr) = do { cgBind binds; cgExpr expr }
-cgExpr (StgLetNoEscape binds expr) =
+cgExpr (StgLet _ binds expr) = do { cgBind binds; cgExpr expr }
+cgExpr (StgLetNoEscape _ binds expr) =
do { u <- newUnique
; let join_id = mkBlockId u
; cgLneBinds join_id binds