X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreTidy.lhs;h=c928be4ca2157ad1cf8aa6b0248d35a52bf29fee;hb=14a496fd0b3aa821b69eb02736d5f41086576761;hp=11e45b154d9d55db333db473c7c903aecb9293b3;hpb=62eeda5aed31173b234b2965ccf4bd6979ffd9a4;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreTidy.lhs b/compiler/coreSyn/CoreTidy.lhs index 11e45b1..c928be4 100644 --- a/compiler/coreSyn/CoreTidy.lhs +++ b/compiler/coreSyn/CoreTidy.lhs @@ -17,12 +17,11 @@ import CoreSyn import CoreArity import Id import IdInfo -import Type +import TcType( tidyType, tidyTyVarBndr ) import Var import VarEnv import UniqFM import Name hiding (tidyNameOcc) -import OccName import SrcLoc import Maybes @@ -124,7 +123,7 @@ tidyVarOcc (_, var_env) v = lookupVarEnv var_env v `orElse` v -- tidyBndr is used for lambda and case binders tidyBndr :: TidyEnv -> Var -> (TidyEnv, Var) tidyBndr env var - | isTyVar var = tidyTyVarBndr env var + | isTyCoVar var = tidyTyVarBndr env var | otherwise = tidyIdBndr env var tidyBndrs :: TidyEnv -> [Var] -> (TidyEnv, [Var]) @@ -154,10 +153,10 @@ tidyLetBndr env (id,rhs) -- separate compilation boundaries final_id = new_id `setIdInfo` new_info idinfo = idInfo id - new_info = vanillaIdInfo + new_info = idInfo new_id `setArityInfo` exprArity rhs - `setAllStrictnessInfo` newStrictnessInfo idinfo - `setNewDemandInfo` newDemandInfo idinfo + `setStrictnessInfo` strictnessInfo idinfo + `setDemandInfo` demandInfo idinfo `setInlinePragInfo` inlinePragInfo idinfo -- Override the env we get back from tidyId with the new IdInfo @@ -167,7 +166,7 @@ tidyLetBndr env (id,rhs) -- Non-top-level variables tidyIdBndr :: TidyEnv -> Id -> (TidyEnv, Id) tidyIdBndr env@(tidy_env, var_env) id - = -- do this pattern match strictly, otherwise we end up holding on to + = -- Do this pattern match strictly, otherwise we end up holding on to -- stuff in the OccName. case tidyOccName tidy_env (getOccName id) of { (tidy_env', occ') -> let @@ -175,24 +174,36 @@ tidyIdBndr env@(tidy_env, var_env) id -- The SrcLoc isn't important now, -- though we could extract it from the Id -- - -- All nested Ids now have the same IdInfo, namely vanillaIdInfo, - -- which should save some space; except that we hang onto dead-ness - -- (at the moment, solely to make printing tidy core nicer) - -- But note that tidyLetBndr puts some of it back. ty' = tidyType env (idType id) name' = mkInternalName (idUnique id) occ' noSrcSpan id' = mkLocalIdWithInfo name' ty' new_info var_env' = extendVarEnv var_env id id' - new_info | isDeadOcc (idOccInfo id) = deadIdInfo - | otherwise = vanillaIdInfo + + -- Note [Tidy IdInfo] + new_info = vanillaIdInfo `setOccInfo` occInfo old_info + old_info = idInfo id in - ((tidy_env', var_env'), id') + ((tidy_env', var_env'), id') } - -deadIdInfo :: IdInfo -deadIdInfo = vanillaIdInfo `setOccInfo` IAmDead \end{code} +Note [Tidy IdInfo] +~~~~~~~~~~~~~~~~~~ +All nested Ids now have the same IdInfo, namely vanillaIdInfo, which +should save some space; except that we preserve occurrence info for +two reasons: + + (a) To make printing tidy core nicer + + (b) Because we tidy RULES and InlineRules, which may then propagate + via --make into the compilation of the next module, and we want + the benefit of that occurrence analysis when we use the rule or + or inline the function. In particular, it's vital not to lose + loop-breaker info, else we get an infinite inlining loop + +Note that tidyLetBndr puts more IdInfo back. + + \begin{code} (=:) :: a -> (a -> b) -> b m =: k = m `seq` k m