diff options
author | Alexis King <lexi.lambda@gmail.com> | 2020-04-17 16:54:54 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-04-19 03:16:44 -0400 |
commit | eaed0a3289e4c24ff1a70c6fc4b7f8bae6cd2dd3 (patch) | |
tree | f4f40dd227d295319a747c66fb58474cdd9a1882 /compiler/GHC/Core | |
parent | 15312bbb53f247c9ed2c5cf75100a9f44c1c7227 (diff) | |
download | haskell-eaed0a3289e4c24ff1a70c6fc4b7f8bae6cd2dd3.tar.gz |
Add missing addInScope call for letrec binders in OccurAnal
This fixes #18044, where a shadowed variable was incorrectly substituted
by the binder swap on the RHS of a floated-in letrec. This can only
happen when the uniques line up *just* right, so writing a regression
test would be very difficult, but at least the fix is small and
straightforward.
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r-- | compiler/GHC/Core/Opt/OccurAnal.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/Core/Opt/OccurAnal.hs b/compiler/GHC/Core/Opt/OccurAnal.hs index cbc279cefb..4fe039cc52 100644 --- a/compiler/GHC/Core/Opt/OccurAnal.hs +++ b/compiler/GHC/Core/Opt/OccurAnal.hs @@ -843,7 +843,7 @@ occAnalNonRecBind env lvl imp_rule_edges bndr rhs body_usage occAnalRecBind :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> [(Var,CoreExpr)] -> UsageDetails -> (UsageDetails, [CoreBind]) occAnalRecBind env lvl imp_rule_edges pairs body_usage - = foldr (occAnalRec env lvl) (body_usage, []) sccs + = foldr (occAnalRec rhs_env lvl) (body_usage, []) sccs -- For a recursive group, we -- * occ-analyse all the RHSs -- * compute strongly-connected components @@ -856,9 +856,11 @@ occAnalRecBind env lvl imp_rule_edges pairs body_usage nodes :: [LetrecNode] nodes = {-# SCC "occAnalBind.assoc" #-} - map (makeNode env imp_rule_edges bndr_set) pairs + map (makeNode rhs_env imp_rule_edges bndr_set) pairs - bndr_set = mkVarSet (map fst pairs) + bndrs = map fst pairs + bndr_set = mkVarSet bndrs + rhs_env = env `addInScope` bndrs {- Note [Unfoldings and join points] |