Commit bcd55a94 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Ben Gamari

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
parent f101a822
......@@ -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
......
......@@ -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]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment