diff options
author | Dominik Peteler <haskell+gitlab@with-h.at> | 2022-07-04 23:47:16 +0200 |
---|---|---|
committer | Dominik Peteler <haskell+gitlab@with-h.at> | 2022-07-22 10:09:02 +0200 |
commit | 7b889fa968750224d6f82baa63bc81513f0a4049 (patch) | |
tree | 8a23c7313aabc80422100b1dc121666e59d77433 /compiler/GHC/Core/LateCC.hs | |
parent | e2f0094c315746ff15b8d9650cf318f81d8416d7 (diff) | |
download | haskell-wip/refactor-latecc.tar.gz |
Refactored Simplify passwip/refactor-latecc
* Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
namespace and GHC.Core.Opt.Stats.
Also removed services from configuration records.
* Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.
* Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
and moved the Simplify driver to GHC.Core.Opt.Simplify.
* Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.
* Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
in GHC.Core.Opt.Simplify.Monad.
* Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
Also added initialization functions for `SimplMode` to that module.
* Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
and the counting types and functions (`SimplCount` and `Tick`) to new
module GHC.Core.Opt.Stats.
* Added getter functions for the fields of `SimplMode`. The pedantic bottoms
option and the platform are retrieved from the ArityOpts and RuleOpts and the
getter functions allow us to retrieve values from `SpecEnv` without the
knowledge where the data is stored exactly.
* Moved the coercion optimization options from the top environment to
`SimplMode`. This way the values left in the top environment are those
dealing with monadic functionality, namely logging, IO related stuff and
counting. Added a note "The environments of the Simplify pass".
* Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
`CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.
* Prep work before removing `InteractiveContext` from `HscEnv`.
Diffstat (limited to 'compiler/GHC/Core/LateCC.hs')
-rw-r--r-- | compiler/GHC/Core/LateCC.hs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/compiler/GHC/Core/LateCC.hs b/compiler/GHC/Core/LateCC.hs index 634eabc4f6..2b4f810441 100644 --- a/compiler/GHC/Core/LateCC.hs +++ b/compiler/GHC/Core/LateCC.hs @@ -11,7 +11,6 @@ import GHC.Utils.Monad.State.Strict import Control.Monad import GHC.Prelude -import GHC.Driver.Session import GHC.Types.CostCentre import GHC.Types.CostCentre.State import GHC.Types.Name hiding (varName) @@ -21,22 +20,17 @@ import GHC.Types.Var import GHC.Unit.Types import GHC.Data.FastString import GHC.Core -import GHC.Core.Opt.Monad import GHC.Types.Id import GHC.Core.Utils (mkTick) -addLateCostCentres :: ModGuts -> CoreM ModGuts -addLateCostCentres guts = do - dflags <- getDynFlags - let env :: Env - env = Env - { thisModule = mg_module guts - , ccState = newCostCentreState - , dflags = dflags - } - let guts' = guts { mg_binds = doCoreProgram env (mg_binds guts) - } - return guts' +addLateCostCentres :: Bool -> ModGuts -> ModGuts +addLateCostCentres prof_count_entries guts = let + env = Env + { thisModule = mg_module guts + , ccState = newCostCentreState + , countEntries = prof_count_entries + } + in guts { mg_binds = doCoreProgram env (mg_binds guts) } doCoreProgram :: Env -> CoreProgram -> CoreProgram doCoreProgram env binds = flip evalState newCostCentreState $ do @@ -54,7 +48,7 @@ doBndr env bndr rhs = do let name = idName bndr name_loc = nameSrcSpan name cc_name = getOccFS name - count = gopt Opt_ProfCountEntries (dflags env) + count = countEntries env cc_flavour <- getCCExprFlavour cc_name let cc_mod = thisModule env bndrCC = NormalCC cc_flavour cc_name cc_mod name_loc @@ -70,8 +64,8 @@ getCCIndex' :: FastString -> M CostCentreIndex getCCIndex' name = state (getCCIndex name) data Env = Env - { thisModule :: Module - , dflags :: DynFlags - , ccState :: CostCentreState + { thisModule :: Module + , countEntries :: Bool + , ccState :: CostCentreState } |