Print CFG edges from func.layout instead of cfg.predecessors_iter.

EBBs not in the layout should never be printed as part of the CFG.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-01 15:03:56 -07:00
parent e9cfcf4f78
commit 02c1bb8f2c

View File

@@ -41,8 +41,8 @@ impl<T: Write> CFGPrinter<T> {
self.header(func); self.header(func);
self.push_indent(); self.push_indent();
self.ebb_subgraphs(func); self.ebb_subgraphs(func);
let cfg = ControlFlowGraph::new(&func); let cfg = ControlFlowGraph::new(func);
self.cfg_connections(&cfg); self.cfg_connections(func, &cfg);
self.pop_indent(); self.pop_indent();
self.footer(); self.footer();
self.write() self.write()
@@ -145,9 +145,9 @@ impl<T: Write> CFGPrinter<T> {
} }
} }
fn cfg_connections(&mut self, cfg: &ControlFlowGraph) { fn cfg_connections(&mut self, func: &Function, cfg: &ControlFlowGraph) {
for (ref ebb, ref predecessors) in cfg.predecessors_iter() { for ebb in &func.layout {
for &(parent, inst) in *predecessors { for &(parent, inst) in cfg.get_predecessors(ebb) {
self.append(&format!("{}:{} -> {}", parent, inst, ebb)); self.append(&format!("{}:{} -> {}", parent, inst, ebb));
self.newline(); self.newline();
} }