Make passes assert their dependencies consistently. (#156)
* Make passes assert their dependencies consistently. This avoids ambiguity about whose responsibility it is to run to compute cfg, domtree, and loop_analysis data. * Reset the `valid` flag in DominatorTree's `clear()`. * Remove the redundant assert from DominatorTree::with_function. * Remove the message strings from obvious asserts. This avoids having them spill out into multiple lines. * Refactor calls to `compute` on `Context` objects into helper functions.
This commit is contained in:
@@ -40,7 +40,7 @@ impl SubTest for TestLegalizer {
|
||||
comp_ctx.func = func.into_owned();
|
||||
let isa = context.isa.expect("legalizer needs an ISA");
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_cfg();
|
||||
comp_ctx.legalize(isa).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, e)
|
||||
})?;
|
||||
|
||||
@@ -38,6 +38,8 @@ impl SubTest for TestLICM {
|
||||
let mut comp_ctx = cretonne::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_loop_analysis();
|
||||
comp_ctx.licm();
|
||||
comp_ctx.verify(context.isa).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
|
||||
@@ -44,11 +44,12 @@ impl SubTest for TestRegalloc {
|
||||
let mut comp_ctx = cretonne::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.compute_cfg();
|
||||
// TODO: Should we have an option to skip legalization?
|
||||
comp_ctx.legalize(isa).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, e)
|
||||
})?;
|
||||
comp_ctx.compute_domtree();
|
||||
comp_ctx.regalloc(isa).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, e)
|
||||
})?;
|
||||
|
||||
@@ -38,6 +38,7 @@ impl SubTest for TestSimpleGVN {
|
||||
let mut comp_ctx = cretonne::Context::new();
|
||||
comp_ctx.func = func.into_owned();
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
comp_ctx.simple_gvn();
|
||||
comp_ctx.verify(context.isa).map_err(|e| {
|
||||
pretty_error(&comp_ctx.func, context.isa, Into::into(e))
|
||||
|
||||
@@ -158,6 +158,8 @@ fn handle_module(
|
||||
context.verify(None).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, None, err)
|
||||
})?;
|
||||
context.flowgraph();
|
||||
context.compute_loop_analysis();
|
||||
context.licm();
|
||||
context.verify(None).map_err(|err| {
|
||||
pretty_verifier_error(&context.func, None, err)
|
||||
|
||||
Reference in New Issue
Block a user