X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreFVs.lhs;h=a15362a5853b0e7cb587a90545efc47721475b09;hb=4f51ac1246f9a9b2bd172e2d6957d95942d12d23;hp=d2d1383e2b4cc23b978938619e66970a0462073f;hpb=7c0bfc36a39ab8e181cca97be3e5b21dda9be0cb;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreFVs.lhs b/compiler/coreSyn/CoreFVs.lhs index d2d1383..a15362a 100644 --- a/compiler/coreSyn/CoreFVs.lhs +++ b/compiler/coreSyn/CoreFVs.lhs @@ -16,6 +16,7 @@ Taken quite directly from the Peyton Jones/Lester paper. module CoreFVs ( -- * Free variables of expressions and binding groups exprFreeVars, -- CoreExpr -> VarSet -- Find all locally-defined free Ids or tyvars + exprFreeIds, -- CoreExpr -> IdSet -- Find all locally-defined free Ids exprsFreeVars, -- [CoreExpr] -> VarSet bindFreeVars, -- CoreBind -> VarSet @@ -25,7 +26,8 @@ module CoreFVs ( exprFreeNames, exprsFreeNames, -- * Free variables of Rules, Vars and Ids - idRuleVars, idFreeVars, varTypeTyVars, + idRuleVars, idRuleRhsVars, idFreeVars, idInlineFreeVars, + varTypeTyVars, ruleRhsFreeVars, rulesFreeVars, ruleLhsFreeNames, ruleLhsFreeIds, @@ -71,6 +73,10 @@ but not those that are free in the type of variable occurrence. exprFreeVars :: CoreExpr -> VarSet exprFreeVars = exprSomeFreeVars isLocalVar +-- | Find all locally-defined free Ids in an expression +exprFreeIds :: CoreExpr -> IdSet -- Find all locally-defined free Ids +exprFreeIds = exprSomeFreeVars isLocalId + -- | Find all locally-defined free Ids or type variables in several expressions exprsFreeVars :: [CoreExpr] -> VarSet exprsFreeVars = foldr (unionVarSet . exprFreeVars) emptyVarSet @@ -378,7 +384,24 @@ bndrRuleVars v | isTyVar v = emptyVarSet | otherwise = idRuleVars v idRuleVars ::Id -> VarSet -idRuleVars id = ASSERT( isId id) specInfoFreeVars (idSpecialisation id) +idRuleVars id = ASSERT( isId id) + specInfoFreeVars (idSpecialisation id) `unionVarSet` + idInlineFreeVars id -- And the variables in an INLINE rule + +idRuleRhsVars :: Id -> VarSet +-- Just the variables free on the *rhs* of a rule +-- See Note [Choosing loop breakers] in Simplify.lhs +idRuleRhsVars id = foldr (unionVarSet . ruleRhsFreeVars) + (idInlineFreeVars id) + (idCoreRules id) + +idInlineFreeVars :: Id -> VarSet +-- Produce free vars for an InlineRule, BUT NOT for an ordinary unfolding +-- An InlineRule behaves *very like* a RULE, and that is what we are after here +idInlineFreeVars id + = case idUnfolding id of + InlineRule { uf_tmpl = tmpl } -> exprFreeVars tmpl + _ -> emptyVarSet \end{code}