Make the ControlFlowGraph reusable.

Move the flow graph computation into a compute method which can be
called with multiple functions.

This allows us to reuse the ControlFlowGraph memory and keep an instance
in the Context.
This commit is contained in:
Jakob Stoklund Olesen
2017-02-17 12:16:48 -08:00
parent 793b3a140a
commit 0f29fc7a52
6 changed files with 39 additions and 19 deletions

View File

@@ -203,7 +203,7 @@ mod test {
#[test]
fn empty() {
let func = Function::new();
let cfg = ControlFlowGraph::new(&func);
let cfg = ControlFlowGraph::with_function(&func);
let dtree = DominatorTree::new(&func, &cfg);
assert_eq!(0, dtree.nodes.keys().count());
}
@@ -238,7 +238,7 @@ mod test {
cur.insert_ebb(ebb0);
}
let cfg = ControlFlowGraph::new(&func);
let cfg = ControlFlowGraph::with_function(&func);
let dt = DominatorTree::new(&func, &cfg);
assert_eq!(func.layout.entry_block().unwrap(), ebb3);