[commit: ghc] wip/T14152: Exitification: Capture variables in the right order (d43f6f5)

git at git.haskell.org git at git.haskell.org
Wed Sep 20 20:25:23 UTC 2017


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

On branch  : wip/T14152
Link       : http://ghc.haskell.org/trac/ghc/changeset/d43f6f564a40b89c8d420fe364c0faacb6054652/ghc

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

commit d43f6f564a40b89c8d420fe364c0faacb6054652
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Sep 20 16:21:30 2017 -0400

    Exitification: Capture variables in the right order
    
    (this commit will be squashed before merging)


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

d43f6f564a40b89c8d420fe364c0faacb6054652
 compiler/simplCore/Exitify.hs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/compiler/simplCore/Exitify.hs b/compiler/simplCore/Exitify.hs
index 6b41510..032e498 100644
--- a/compiler/simplCore/Exitify.hs
+++ b/compiler/simplCore/Exitify.hs
@@ -173,7 +173,7 @@ exitify in_scope pairs =
     -- Case right hand sides are in tail-call position
     go captured (_, AnnCase scrut bndr ty alts) = do
         alts' <- forM alts $ \(dc, pats, rhs) -> do
-            rhs' <- go (pats ++ bndr : captured) rhs
+            rhs' <- go (captured ++ [bndr] ++ pats) rhs
             return (dc, pats, rhs')
         return $ Case (deAnnotate scrut) bndr ty alts'
 
@@ -182,9 +182,9 @@ exitify in_scope pairs =
         | AnnNonRec j rhs <- ann_bind
         , Just join_arity <- isJoinId_maybe j
         = do let (params, join_body) = collectNAnnBndrs join_arity rhs
-             join_body' <- go (params ++ captured) join_body
+             join_body' <- go (captured ++ params) join_body
              let rhs' = mkLams params join_body'
-             body' <- go (j : captured) body
+             body' <- go (captured ++ [j]) body
              return $ Let (NonRec j rhs') body'
 
         -- rec join point, RHSs and body are in tail-call position
@@ -194,15 +194,15 @@ exitify in_scope pairs =
              pairs' <- forM pairs $ \(j,rhs) -> do
                  let join_arity = idJoinArity j
                      (params, join_body) = collectNAnnBndrs join_arity rhs
-                 join_body' <- go (params ++ js ++ captured) join_body
+                 join_body' <- go (captured ++ js ++ params) join_body
                  let rhs' = mkLams params join_body'
                  return (j, rhs')
-             body' <- go (js ++ captured) body
+             body' <- go (captured ++ js) body
              return $ Let (Rec pairs') body'
 
         -- normal Let, only the body is in tail-call position
         | otherwise
-        = do body' <- go (bindersOf bind ++ captured) body
+        = do body' <- go (captured ++ bindersOf bind ) body
              return $ Let bind body'
       where bind = deAnnBind ann_bind
 



More information about the ghc-commits mailing list