diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2017-08-18 14:14:19 +0200 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2017-08-18 14:16:03 +0200 |
commit | fee253fc48d80b0cbd29ec90b5377c1981eb888f (patch) | |
tree | ef2e65f9a73044bb0c3a2dfe844f01b85324b831 | |
parent | 02862140ee3fee6e522f0d73a1ac14e6cf29e501 (diff) | |
download | haskell-fee253fc48d80b0cbd29ec90b5377c1981eb888f.tar.gz |
CSE.cseOneExpr: Set InScopeSet correctly
because this is a convenience function for API users, calculate the
in-scope set from `exprFreeVars`.
-rw-r--r-- | compiler/simplCore/CSE.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index ccbdf3537d..ffbcdb4877 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -12,13 +12,14 @@ module CSE (cseProgram, cseOneExpr) where import CoreSubst import Var ( Var ) -import VarEnv ( elemInScopeSet ) +import VarEnv ( elemInScopeSet, mkInScopeSet ) import Id ( Id, idType, idInlineActivation, isDeadBinder , zapIdOccInfo, zapIdUsageInfo, idInlinePragma , isJoinId ) import CoreUtils ( mkAltExpr, eqExpr , exprIsLiteralString , stripTicksE, stripTicksT, mkTicks ) +import CoreFVs ( exprFreeVars ) import Type ( tyConAppArgs ) import CoreSyn import Outputable @@ -444,8 +445,13 @@ tryForCSE env expr -- top of the replaced sub-expression. This is probably not too -- useful in practice, but upholds our semantics. +-- | Runs CSE on a single expression. +-- +-- This entry point is not used in the compiler itself, but is provided +-- as a convenient entry point for users of the GHC API. cseOneExpr :: InExpr -> OutExpr -cseOneExpr = cseExpr emptyCSEnv +cseOneExpr e = cseExpr env e + where env = emptyCSEnv {cs_subst = mkEmptySubst (mkInScopeSet (exprFreeVars e)) } cseExpr :: CSEnv -> InExpr -> OutExpr cseExpr env (Type t) = Type (substTy (csEnvSubst env) t) |