packages feed

fusion-plugin 0.2.6 → 0.2.7

raw patch · 4 files changed

+90/−15 lines, 4 filesdep ~containersdep ~filepathdep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: containers, filepath, ghc, time

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.2.7++* Support ghc-9.6 and ghc-9.8+ ## 0.2.6  * Force inline on joins that consume fusible constructors
README.md view
@@ -52,7 +52,7 @@  ### Plugin options -Note: dump-core does not work for GHC-9.0.x.+Note: dump-core does not work for GHC-9.0.x, 9.6.x and 9.8.x.  `-fplugin-opt=Fusion.Plugin:dump-core`: dump core after each core-to-core transformation. Output from each transformation is printed
fusion-plugin.cabal view
@@ -1,7 +1,7 @@ cabal-version:       2.2  name:                fusion-plugin-version:             0.2.6+version:             0.2.7 synopsis:            GHC plugin to make stream fusion more predictable. description:   This plugin provides the programmer with a way to annotate certain@@ -24,8 +24,10 @@                    , GHC==8.8.4                    , GHC==8.10.7                    , GHC==9.0.2-                   , GHC==9.2.4-                   , GHC==9.4.2+                   , GHC==9.2.8+                   , GHC==9.4.7+                   , GHC==9.6.3+                   , GHC==9.8.1 author:              Pranay Sashank maintainer:          streamly@composewell.com copyright:           (c) 2019 Composewell Technologies@@ -46,10 +48,10 @@ library   exposed-modules:     Fusion.Plugin   build-depends:       base         >= 4.0     && <  5.0-                     , containers   >= 0.5.6.2 && <  0.7+                     , containers   >= 0.5.6.2 && <  0.8                      , directory    >= 1.2.2.0 && <  1.4                      , filepath     >= 1.4     && <  1.5-                     , ghc          >= 7.10.3  && <  9.5+                     , ghc          >= 7.10.3  && <  9.9                      , syb          >= 0.7     && <  0.8                      , time         >= 1.5     && <  1.14                      , transformers >= 0.4     && < 0.7
src/Fusion/Plugin.hs view
@@ -60,7 +60,15 @@ import qualified Data.List as DL  -- Imports for specific compiler versions-#if MIN_VERSION_ghc(9,2,0)+#if MIN_VERSION_ghc(9,6,0)+import GHC.Core.Lint.Interactive (interactiveInScope)+import GHC.Core.Opt.Simplify.Env (SimplMode(..))+import GHC.Core.Opt.Simplify (SimplifyOpts(..))+import GHC.Driver.Config.Core.Opt.Simplify (initSimplMode, initSimplifyOpts)+#endif++#if MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,2,0) import Data.Char (isSpace) import Text.Printf (printf) import GHC.Core.Ppr (pprCoreBindingsWithSize, pprRules)@@ -69,7 +77,8 @@ #endif  -- dump-core option related imports-#if MIN_VERSION_ghc(9,3,0)+#if MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,3,0) import GHC.Utils.Logger (putDumpFile, logFlags, LogFlags(..)) #elif MIN_VERSION_ghc(9,2,0) import GHC.Utils.Logger (putDumpMsg)@@ -91,8 +100,10 @@ #endif  -- Implicit imports-#if MIN_VERSION_ghc(9,0,0)+#if MIN_VERSION_ghc(9,6,0) import GHC.Plugins+#elif MIN_VERSION_ghc(9,0,0)+import GHC.Plugins import qualified GHC.Plugins as GhcPlugins #else import GhcPlugins@@ -263,7 +274,15 @@  unfoldCompulsory :: Arity -> Unfolding -> Unfolding unfoldCompulsory arity cuf@CoreUnfolding{} =-    cuf {uf_src=InlineStable, uf_guidance = UnfWhen arity True True}+    cuf+        { uf_src=+#if MIN_VERSION_ghc(9,6,0)+            StableSystemSrc+#else+            InlineStable+#endif+        , uf_guidance = UnfWhen arity True True+        } unfoldCompulsory _ x = x -- NoUnfolding  -- Sets the inline pragma on a bndr, and forgets the unfolding.@@ -689,6 +708,15 @@ -- Simplification pass after marking inline ------------------------------------------------------------------------------- +#if MIN_VERSION_ghc(9,6,0)+fusionSimplify :: RuleBase -> HscEnv -> DynFlags -> CoreToDo+fusionSimplify hpt_rules hsc_env dflags =+    let mode = initSimplMode dflags InitialPhase "Fusion Plugin Inlining"+        extra_vars = interactiveInScope (hsc_IC hsc_env)+     in CoreDoSimplify+            (initSimplifyOpts+                dflags extra_vars (maxSimplIterations dflags) mode hpt_rules)+#else fusionSimplify :: HscEnv -> DynFlags -> CoreToDo fusionSimplify _hsc_env dflags =     let mode =@@ -718,6 +746,7 @@ #else         (maxSimplIterations dflags) mode #endif+#endif  ------------------------------------------------------------------------------- -- Report unfused constructors@@ -858,8 +887,9 @@   where dump_style = mkDumpStyle dflags print_unqual #endif +-- XXX Need to fix for GHC-9.6 and above -- dump core not supported on 9.0.0, 9.0.0 does not export Logger-#if __GLASGOW_HASKELL__!=900+#if __GLASGOW_HASKELL__!=900 && !MIN_VERSION_ghc(9,6,0) -- Only for GHC versions >= 9.2.0 #if MIN_VERSION_ghc(9,2,0) dumpPassResult ::@@ -961,6 +991,7 @@ #endif #endif +#if !MIN_VERSION_ghc(9,6,0) dumpCore :: Int -> SDoc -> ModGuts -> CoreM ModGuts dumpCore counter title guts = do     dflags <- getDynFlags@@ -994,7 +1025,14 @@     go counter (todo:rest) =         todo : dumpCorePass counter (text "After " GhcPlugins.<> ppr todo)              : go (counter + 1) rest+#else+dumpCore :: Int -> SDoc -> ModGuts -> CoreM ModGuts+dumpCore _counter _title guts = return guts +_insertDumpCore :: [CoreToDo] -> [CoreToDo]+_insertDumpCore = id+#endif+ ------------------------------------------------------------------------------- -- Install our plugin core pass -------------------------------------------------------------------------------@@ -1008,7 +1046,18 @@   where     go False [] = error "Simplifier phase 0/\"main\" not found"     go True [] = []-#if MIN_VERSION_ghc(9,5,0)+#if MIN_VERSION_ghc(9,6,0)+    go _ (todo@(CoreDoSimplify+        (SimplifyOpts+            { so_mode =+                (SimplMode+                    { sm_phase = Phase 0+                    , sm_names = ["main"]+                    }+                )+            }+        )):todos)+#elif MIN_VERSION_ghc(9,5,0)     go _ (todo@(CoreDoSimplify (CoreDoSimplifyOpts _ SimplMode             { sm_phase = Phase 0             , sm_names = ["main"]@@ -1027,6 +1076,26 @@     options <- liftIO $ parseOptions args     dflags <- getDynFlags     hscEnv <- getHscEnv+#if MIN_VERSION_ghc(9,6,0)+    m <- getModule+    let+        home_pkg_rules =+            hptRules+                hscEnv+                (moduleUnitId m)+                (GWIB+                    { gwib_mod = moduleName m+                    , gwib_isBoot = NotBoot+                    }+                )+        hpt_rule_base = mkRuleBase home_pkg_rules+        -- XXX GHC should export getHomeRuleBase+        -- hpt_rule_base <- getHomeRuleBase+        simplify = fusionSimplify hpt_rule_base hscEnv dflags+#else+    let simplify = fusionSimplify hscEnv dflags+#endif+     -- We run our plugin once the simplifier finishes phase 0,     -- followed by a gentle simplifier which inlines and case-cases     -- twice.@@ -1043,11 +1112,11 @@         insertAfterSimplPhase0             todos             [ fusionMarkInline 1 ReportSilent False True-            , fusionSimplify hscEnv dflags+            , simplify             , fusionMarkInline 2 ReportSilent False True-            , fusionSimplify hscEnv dflags+            , simplify             , fusionMarkInline 3 ReportSilent False True-            , fusionSimplify hscEnv dflags+            , simplify             -- This lets us know what was left unfused after all the inlining             -- and case-of-case transformations.             , let mesg = "Check unfused (post inlining)"