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:
@@ -75,7 +75,7 @@ impl Context {
|
|||||||
|
|
||||||
/// Run the legalizer for `isa` on the function.
|
/// Run the legalizer for `isa` on the function.
|
||||||
pub fn legalize(&mut self, isa: &TargetIsa) -> CtonResult {
|
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)
|
self.verify_if(isa)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
//! The legalizer does not deal with register allocation constraints. These constraints are derived
|
//! The legalizer does not deal with register allocation constraints. These constraints are derived
|
||||||
//! from the encoding recipes, and solved later by the register allocator.
|
//! from the encoding recipes, and solved later by the register allocator.
|
||||||
|
|
||||||
|
use dominator_tree::DominatorTree;
|
||||||
use flowgraph::ControlFlowGraph;
|
use flowgraph::ControlFlowGraph;
|
||||||
use ir::{Function, Cursor, DataFlowGraph, InstructionData, Opcode, InstBuilder};
|
use ir::{Function, Cursor, DataFlowGraph, InstructionData, Opcode, InstBuilder};
|
||||||
use ir::condcodes::IntCC;
|
use ir::condcodes::IntCC;
|
||||||
@@ -26,17 +27,19 @@ mod split;
|
|||||||
/// - Transform any instructions that don't have a legal representation in `isa`.
|
/// - Transform any instructions that don't have a legal representation in `isa`.
|
||||||
/// - Fill out `func.encodings`.
|
/// - 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);
|
boundary::legalize_signatures(func, isa);
|
||||||
|
|
||||||
func.encodings.resize(func.dfg.num_insts());
|
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);
|
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);
|
pos.goto_top(ebb);
|
||||||
|
|
||||||
// Keep track of the cursor position before the instruction being processed, so we can
|
// Keep track of the cursor position before the instruction being processed, so we can
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ impl LoopAnalysis {
|
|||||||
cfg: &ControlFlowGraph,
|
cfg: &ControlFlowGraph,
|
||||||
domtree: &DominatorTree,
|
domtree: &DominatorTree,
|
||||||
layout: &Layout) {
|
layout: &Layout) {
|
||||||
// We traverse the CFg in reverse postorder
|
// We traverse the CFG in reverse postorder
|
||||||
for &ebb in cfg.postorder_ebbs().iter().rev() {
|
for &ebb in domtree.cfg_postorder().iter().rev() {
|
||||||
for &(_, pred_inst) in cfg.get_predecessors(ebb) {
|
for &(_, pred_inst) in cfg.get_predecessors(ebb) {
|
||||||
// If the ebb dominates one of its predecessors it is a back edge
|
// If the ebb dominates one of its predecessors it is a back edge
|
||||||
if domtree.ebb_dominates(ebb, pred_inst, layout) {
|
if domtree.ebb_dominates(ebb, pred_inst, layout) {
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ pub fn do_simple_gvn(func: &mut Function, cfg: &mut ControlFlowGraph) {
|
|||||||
let domtree = DominatorTree::with_function(func, &cfg);
|
let domtree = DominatorTree::with_function(func, &cfg);
|
||||||
|
|
||||||
// Visit EBBs in a reverse post-order.
|
// Visit EBBs in a reverse post-order.
|
||||||
let mut postorder = cfg.postorder_ebbs();
|
|
||||||
let mut pos = Cursor::new(&mut func.layout);
|
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);
|
pos.goto_top(ebb);
|
||||||
|
|
||||||
while let Some(inst) = pos.next_inst() {
|
while let Some(inst) = pos.next_inst() {
|
||||||
|
|||||||
Reference in New Issue
Block a user