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 f3fa0fb4e9
commit 77a7ad88f4
6 changed files with 39 additions and 19 deletions

View File

@@ -40,7 +40,7 @@ impl SubTest for TestDomtree {
// Extract our own dominator tree from
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
let func = func.borrow();
let cfg = ControlFlowGraph::new(func);
let cfg = ControlFlowGraph::with_function(func);
let domtree = DominatorTree::new(func, &cfg);
// Build an expected domtree from the source annotations.

View File

@@ -33,7 +33,7 @@ impl<'a> CFGPrinter<'a> {
pub fn new(func: &'a Function) -> CFGPrinter<'a> {
CFGPrinter {
func: func,
cfg: ControlFlowGraph::new(func),
cfg: ControlFlowGraph::with_function(func),
}
}