Stop using cfg.postorder_ebbs().

Switch to the new domtree.cfg_postorder() which returns a reference to a
pre-computed post-order instead of allocating memory and computing a new
post-order.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-07 13:38:27 -07:00
parent d94bd8c236
commit 94872cc971
4 changed files with 12 additions and 10 deletions

View File

@@ -13,6 +13,7 @@
//! The legalizer does not deal with register allocation constraints. These constraints are derived
//! from the encoding recipes, and solved later by the register allocator.
use dominator_tree::DominatorTree;
use flowgraph::ControlFlowGraph;
use ir::{Function, Cursor, DataFlowGraph, InstructionData, Opcode, InstBuilder};
use ir::condcodes::IntCC;
@@ -26,17 +27,19 @@ mod split;
/// - Transform any instructions that don't have a legal representation in `isa`.
/// - Fill out `func.encodings`.
///
pub fn legalize_function(func: &mut Function, cfg: &mut ControlFlowGraph, isa: &TargetIsa) {
pub fn legalize_function(func: &mut Function,
cfg: &mut ControlFlowGraph,
domtree: &DominatorTree,
isa: &TargetIsa) {
boundary::legalize_signatures(func, isa);
func.encodings.resize(func.dfg.num_insts());
// Process EBBs in a reverse post-order. This minimizes the number of split instructions we
// need.
let mut postorder = cfg.postorder_ebbs();
let mut pos = Cursor::new(&mut func.layout);
while let Some(ebb) = postorder.pop() {
// Process EBBs in a reverse post-order. This minimizes the number of split instructions we
// need.
for &ebb in domtree.cfg_postorder().iter().rev() {
pos.goto_top(ebb);
// Keep track of the cursor position before the instruction being processed, so we can