[commit: ghc] wip/T7994-calledArity: Bugfix: Properly remove bound variables in returned CallArityEnv (1330874)

git at git.haskell.org git at git.haskell.org
Wed Jan 29 17:33:45 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T7994-calledArity
Link       : http://ghc.haskell.org/trac/ghc/changeset/13308749a51e2017c318d901409a8db8e485e865/ghc

>---------------------------------------------------------------

commit 13308749a51e2017c318d901409a8db8e485e865
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Jan 29 16:00:37 2014 +0000

    Bugfix: Properly remove bound variables in returned CallArityEnv


>---------------------------------------------------------------

13308749a51e2017c318d901409a8db8e485e865
 compiler/simplCore/CallArity.hs |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/compiler/simplCore/CallArity.hs b/compiler/simplCore/CallArity.hs
index 44250bb..2527db0 100644
--- a/compiler/simplCore/CallArity.hs
+++ b/compiler/simplCore/CallArity.hs
@@ -310,7 +310,8 @@ callArityAnal arity int (Let (NonRec v rhs) e)
   where
     (ae_rhs, rhs') = callArityAnal 0 int rhs
     (ae_body, e')  = callArityAnal arity int e
-    ae_final = forgetGoodCalls ae_rhs `lubEnv` ae_body
+    ae_body' = ae_body `delVarEnv` v
+    ae_final = forgetGoodCalls ae_rhs `lubEnv` ae_body'
 
 -- Non-recursive let. Find out how the body calls the rhs, analise that,
 -- and combine the results, convervatively using both
@@ -348,7 +349,7 @@ callArityAnal arity int (Let (Rec [(v,rhs)]) e)
   where
     (ae_rhs, rhs') = callArityAnal 0 int rhs
     (ae_body, e')  = callArityAnal arity int e
-    ae_final = forgetGoodCalls ae_rhs `lubEnv` ae_body
+    ae_final = (forgetGoodCalls ae_rhs `lubEnv` ae_body) `delVarEnv` v
 
 -- Recursive let.
 -- See Note [Recursion and fixpointing]
@@ -357,7 +358,7 @@ callArityAnal arity int (Let (Rec [(v,rhs)]) e)
     -- tail-call for everything
     | Just n <- rhs_arity
     = let (ae_rhs, rhs_arity', rhs') = callArityFix n int_body v rhs
-          final_ae = ae_rhs `lubEnv` ae_body'
+          final_ae = (ae_rhs `lubEnv` ae_body) `delVarEnv` v
           v'             = v `setIdCallArity` rhs_arity'
       in -- pprTrace "callArityAnal:LetRecTailCall"
          --          (vcat [ppr v, ppr arity, ppr n, ppr rhs_arity', ppr final_ae ])
@@ -366,7 +367,7 @@ callArityAnal arity int (Let (Rec [(v,rhs)]) e)
     -- tail-call information from there. No need to iterate there.
     | otherwise
     = let (ae_rhs, rhs') = callArityAnal 0 int_body rhs
-          final_ae = forgetGoodCalls ae_rhs `lubEnv` ae_body'
+          final_ae = (forgetGoodCalls ae_rhs `lubEnv` ae_body) `delVarEnv` v
           v'             = v `setIdCallArity` 0
       in -- pprTrace "callArityAnal:LetRecNonTailCall"
          --          (vcat [ppr v, ppr arity, ppr final_ae ])
@@ -374,7 +375,6 @@ callArityAnal arity int (Let (Rec [(v,rhs)]) e)
   where
     int_body = int `extendVarSet` v
     (ae_body, e') = callArityAnal arity int_body e
-    ae_body' = ae_body `delVarEnv` v
     rhs_arity = lookupWithDefaultVarEnv ae_body Nothing v
 
 -- Mutual recursion. Do nothing serious here, for now
@@ -385,7 +385,7 @@ callArityAnal arity int (Let (Rec binds) e)
     go (i,e) = let (ae,e') = callArityAnal 0 int e
                in (forgetGoodCalls ae, (i,e'))
     (ae, e') = callArityAnal arity int e
-    final_ae = foldl lubEnv ae aes
+    final_ae = foldl lubEnv ae aes `delVarEnvList` map fst binds
 
 -- Application. Increase arity for the called expresion, nothing to know about
 -- the second



More information about the ghc-commits mailing list