diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2015-11-29 22:49:46 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-29 22:50:06 +0100 |
commit | bcd55a94f234f5efa4bb4fd24429dafc79d93106 (patch) | |
tree | 9c81c3e07dc0ca2119ae0a4c80fa0b12d1e06ec7 | |
parent | f101a822966c52e96438db52c5fff2c7384f0c4c (diff) | |
download | haskell-bcd55a94f234f5efa4bb4fd24429dafc79d93106.tar.gz |
Some improvements on CoreToDos passed to plugins
This patch does two improvements:
- We now show ToDos in `CoreDoPasses`. This is pretty important,
otherwise `CoreDoPasses` makes debugging impossible in some cases.
- Before running ToDos we run a cleanup pass on ToDos to remove
`CoreDoNothing`s and flatten `CoreDoPasses`. This removes a lot of
noise from `[CoreToDo]` argument passed to plugins.
Reviewers: simonpj, bgamari, austin
Reviewed By: bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1548
-rw-r--r-- | compiler/simplCore/CoreMonad.hs | 2 | ||||
-rw-r--r-- | compiler/simplCore/SimplCore.hs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/simplCore/CoreMonad.hs b/compiler/simplCore/CoreMonad.hs index ce5286d08a..fa72834ef9 100644 --- a/compiler/simplCore/CoreMonad.hs +++ b/compiler/simplCore/CoreMonad.hs @@ -169,7 +169,7 @@ instance Outputable CoreToDo where ppr CoreDoPrintCore = ptext (sLit "Print core") ppr (CoreDoRuleCheck {}) = ptext (sLit "Rule check") ppr CoreDoNothing = ptext (sLit "CoreDoNothing") - ppr (CoreDoPasses {}) = ptext (sLit "CoreDoPasses") + ppr (CoreDoPasses passes) = ptext (sLit "CoreDoPasses") <+> ppr passes pprPassDetails :: CoreToDo -> SDoc pprPassDetails (CoreDoSimplify n md) = vcat [ ptext (sLit "Max iterations =") <+> int n diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 9207cf472a..8670e30a29 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -109,7 +109,7 @@ core2core hsc_env guts@(ModGuts { mg_module = mod getCoreToDo :: DynFlags -> [CoreToDo] getCoreToDo dflags - = core_todo + = flatten_todos core_todo where opt_level = optLevel dflags phases = simplPhases dflags @@ -322,6 +322,13 @@ getCoreToDo dflags maybe_rule_check (Phase 0) ] + -- Remove 'CoreDoNothing' and flatten 'CoreDoPasses' for clarity. + flatten_todos [] = [] + flatten_todos (CoreDoNothing : rest) = flatten_todos rest + flatten_todos (CoreDoPasses passes : rest) = + flatten_todos passes ++ flatten_todos rest + flatten_todos (todo : rest) = todo : flatten_todos rest + -- Loading plugins addPluginPasses :: [CoreToDo] -> CoreM [CoreToDo] |