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 0d227fd230
commit f22461b4b3
4 changed files with 12 additions and 10 deletions

View File

@@ -75,7 +75,7 @@ impl Context {
/// Run the legalizer for `isa` on the function.
pub fn legalize(&mut self, isa: &TargetIsa) -> CtonResult {
legalize_function(&mut self.func, &mut self.cfg, isa);
legalize_function(&mut self.func, &mut self.cfg, &self.domtree, isa);
self.verify_if(isa)
}

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

View File

@@ -128,8 +128,8 @@ impl LoopAnalysis {
cfg: &ControlFlowGraph,
domtree: &DominatorTree,
layout: &Layout) {
// We traverse the CFg in reverse postorder
for &ebb in cfg.postorder_ebbs().iter().rev() {
// We traverse the CFG in reverse postorder
for &ebb in domtree.cfg_postorder().iter().rev() {
for &(_, pred_inst) in cfg.get_predecessors(ebb) {
// If the ebb dominates one of its predecessors it is a back edge
if domtree.ebb_dominates(ebb, pred_inst, layout) {

View File

@@ -19,10 +19,9 @@ pub fn do_simple_gvn(func: &mut Function, cfg: &mut ControlFlowGraph) {
let domtree = DominatorTree::with_function(func, &cfg);
// Visit EBBs in a reverse post-order.
let mut postorder = cfg.postorder_ebbs();
let mut pos = Cursor::new(&mut func.layout);
while let Some(ebb) = postorder.pop() {
for &ebb in domtree.cfg_postorder().iter().rev() {
pos.goto_top(ebb);
while let Some(inst) = pos.next_inst() {