diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2019-01-28 16:49:04 +0100 |
---|---|---|
committer | Sebastian Graf <sebastian.graf@kit.edu> | 2020-02-12 11:00:58 +0100 |
commit | 059c3c9d7c84fc37c69e9f414ff736d47081e72c (patch) | |
tree | da3c17ac002b9c6d31542af78553769fd40d5d65 /compiler/GHC/Iface | |
parent | f0c0ee7d9a942a19361e72553cd08f42cc12b04a (diff) | |
download | haskell-059c3c9d7c84fc37c69e9f414ff736d47081e72c.tar.gz |
Separate CPR analysis from the Demand analyserwip/sep-cpr
The reasons for that can be found in the wiki:
https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr
We now run CPR after demand analysis (except for after the final demand
analysis run just before code gen). CPR got its own dump flags
(`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to
activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`.
As explained on the wiki page, this step is necessary for a sane Nested
CPR analysis. And it has quite positive impact on compiler performance:
Metric Decrease:
T9233
T9675
T9961
T15263
Diffstat (limited to 'compiler/GHC/Iface')
-rw-r--r-- | compiler/GHC/Iface/Syntax.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Iface/Tidy.hs | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/compiler/GHC/Iface/Syntax.hs b/compiler/GHC/Iface/Syntax.hs index 9509cfe77c..45751424d6 100644 --- a/compiler/GHC/Iface/Syntax.hs +++ b/compiler/GHC/Iface/Syntax.hs @@ -49,6 +49,7 @@ import BinFingerprint import CoreSyn( IsOrphan, isOrphan ) import DynFlags( gopt, GeneralFlag (Opt_PrintAxiomIncomps) ) import Demand +import Cpr import Class import FieldLabel import NameSet @@ -344,6 +345,7 @@ data IfaceIdInfo data IfaceInfoItem = HsArity Arity | HsStrictness StrictSig + | HsCpr CprSig | HsInline InlinePragma | HsUnfold Bool -- True <=> isStrongLoopBreaker is true IfaceUnfolding -- See Note [Expose recursive functions] @@ -1394,7 +1396,8 @@ instance Outputable IfaceInfoItem where <> colon <+> ppr unf ppr (HsInline prag) = text "Inline:" <+> ppr prag ppr (HsArity arity) = text "Arity:" <+> int arity - ppr (HsStrictness str) = text "Strictness:" <+> pprIfaceStrictSig str + ppr (HsStrictness str) = text "Strictness:" <+> pprIfaceStrictSig str + ppr (HsCpr cpr) = text "CPR:" <+> ppr cpr ppr HsNoCafRefs = text "HasNoCafRefs" ppr HsLevity = text "Never levity-polymorphic" @@ -2168,6 +2171,7 @@ instance Binary IfaceInfoItem where put_ bh (HsInline ad) = putByte bh 3 >> put_ bh ad put_ bh HsNoCafRefs = putByte bh 4 put_ bh HsLevity = putByte bh 5 + put_ bh (HsCpr cpr) = putByte bh 6 >> put_ bh cpr get bh = do h <- getByte bh case h of @@ -2178,7 +2182,8 @@ instance Binary IfaceInfoItem where return (HsUnfold lb ad) 3 -> liftM HsInline $ get bh 4 -> return HsNoCafRefs - _ -> return HsLevity + 5 -> return HsLevity + _ -> HsCpr <$> get bh instance Binary IfaceUnfolding where put_ bh (IfCoreUnfold s e) = do @@ -2513,6 +2518,7 @@ instance NFData IfaceInfoItem where HsUnfold b unf -> rnf b `seq` rnf unf HsNoCafRefs -> () HsLevity -> () + HsCpr cpr -> cpr `seq` () instance NFData IfaceUnfolding where rnf = \case diff --git a/compiler/GHC/Iface/Tidy.hs b/compiler/GHC/Iface/Tidy.hs index 8da7700e0e..2b1a4b7108 100644 --- a/compiler/GHC/Iface/Tidy.hs +++ b/compiler/GHC/Iface/Tidy.hs @@ -40,6 +40,7 @@ import IdInfo import InstEnv import Type ( tidyTopType ) import Demand ( appIsBottom, isTopSig, isBottomingSig ) +import Cpr ( mkCprSig, botCpr ) import BasicTypes import Name hiding (varName) import NameSet @@ -1150,6 +1151,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold -- c.f. CoreTidy.tidyLetBndr `setArityInfo` arity `setStrictnessInfo` final_sig + `setCprInfo` final_cpr `setUnfoldingInfo` minimal_unfold_info -- See note [Preserve evaluatedness] -- in CoreTidy @@ -1157,6 +1159,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold = vanillaIdInfo `setArityInfo` arity `setStrictnessInfo` final_sig + `setCprInfo` final_cpr `setOccInfo` robust_occ_info `setInlinePragInfo` (inlinePragInfo idinfo) `setUnfoldingInfo` unfold_info @@ -1180,6 +1183,12 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold | Just (_, nsig) <- mb_bot_str = nsig | otherwise = sig + cpr = cprInfo idinfo + final_cpr | Just _ <- mb_bot_str + = mkCprSig arity botCpr + | otherwise + = cpr + _bottom_hidden id_sig = case mb_bot_str of Nothing -> False Just (arity, _) -> not (appIsBottom id_sig arity) |