[commit: ghc] ghc-8.2: Zap Call Arity info in the simplifier (d88d025)
git at git.haskell.org
git at git.haskell.org
Wed Mar 29 02:37:19 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.2
Link : http://ghc.haskell.org/trac/ghc/changeset/d88d0258204bf8d4aadd57280b8322890e5b98b3/ghc
>---------------------------------------------------------------
commit d88d0258204bf8d4aadd57280b8322890e5b98b3
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Tue Mar 28 16:19:16 2017 -0400
Zap Call Arity info in the simplifier
As #13479 shows, there are corner cases where the simplifier decides to
not eta-expand a function as much as its call arity would suggest, but
instead transforms the code that the call arity annotation becomes a
lie.
As the call arity information is only meant to be used by the
immediatelly following simplifier run, it makes sense to simply zap the
information there.
Differential Revision: https://phabricator.haskell.org/D3390
(cherry picked from commit e07211f752b9b98e2bd6957f126bd537d178041a)
>---------------------------------------------------------------
d88d0258204bf8d4aadd57280b8322890e5b98b3
compiler/basicTypes/IdInfo.hs | 5 ++++-
compiler/simplCore/Simplify.hs | 7 ++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/compiler/basicTypes/IdInfo.hs b/compiler/basicTypes/IdInfo.hs
index f29fba7..bd6ec8f 100644
--- a/compiler/basicTypes/IdInfo.hs
+++ b/compiler/basicTypes/IdInfo.hs
@@ -29,7 +29,7 @@ module IdInfo (
-- ** Zapping various forms of Info
zapLamInfo, zapFragileInfo,
zapDemandInfo, zapUsageInfo, zapUsageEnvInfo, zapUsedOnceInfo,
- zapTailCallInfo,
+ zapTailCallInfo, zapCallArityInfo,
-- ** The ArityInfo type
ArityInfo,
@@ -553,6 +553,9 @@ zapTailCallInfo info
where
safe_occ = occ { occ_tail = NoTailCallInfo }
+zapCallArityInfo :: IdInfo -> IdInfo
+zapCallArityInfo info = setCallArityInfo info 0
+
{-
************************************************************************
* *
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs
index 3a52fbe..977fa25 100644
--- a/compiler/simplCore/Simplify.hs
+++ b/compiler/simplCore/Simplify.hs
@@ -797,7 +797,12 @@ completeBind env top_lvl is_rec mb_cont old_bndr new_bndr new_rhs
| otherwise
= info2
- final_id = new_bndr `setIdInfo` info3
+ -- Zap call arity info. We have used it by now (via
+ -- `tryEtaExpandRhs`), and the simplifier can invalidate this
+ -- information, leading to broken code later (e.g. #13479)
+ info4 = zapCallArityInfo info3
+
+ final_id = new_bndr `setIdInfo` info4
; -- pprTrace "Binding" (ppr final_id <+> ppr new_unfolding) $
return (addNonRec env final_id final_rhs) } }
More information about the ghc-commits
mailing list