Move logic out of cton-util wasm.

Give LoopAnalysis `is_valid` and `ensure` functions similar to
DominatorTree and others, so that it can be computed on demand in the
same way.

This removes the last need for src/wasm.rs to have embedded knowledge
of the dependencies of the passes it's running.
This commit is contained in:
Dan Gohman
2017-09-12 16:15:22 -07:00
parent 9d0d6b5a1b
commit e2f0fe58d1
3 changed files with 23 additions and 16 deletions

View File

@@ -6,9 +6,6 @@
use cton_wasm::{translate_module, DummyRuntime, WasmRuntime};
use std::path::PathBuf;
use cretonne::loop_analysis::LoopAnalysis;
use cretonne::flowgraph::ControlFlowGraph;
use cretonne::dominator_tree::DominatorTree;
use cretonne::Context;
use cretonne::verifier;
use cretonne::settings::{self, Configurable};
@@ -156,18 +153,8 @@ fn handle_module(
vprint!(flag_verbose, "Optimizing... ");
terminal.reset().unwrap();
for func in &translation.functions {
let mut il = func.clone();
let mut loop_analysis = LoopAnalysis::new();
let mut cfg = ControlFlowGraph::new();
cfg.compute(&il);
let mut domtree = DominatorTree::new();
domtree.compute(&mut il, &cfg);
loop_analysis.compute(&mut il, &mut cfg, &mut domtree);
let mut context = Context::new();
context.func = il;
context.cfg = cfg;
context.domtree = domtree;
context.loop_analysis = loop_analysis;
context.func = func.clone();
verifier::verify_context(&context.func, &context.cfg, &context.domtree, None)
.map_err(|err| pretty_verifier_error(&context.func, None, err))?;
context.licm();