Make fold_redundant_jumps() feature-gated on basic-blocks

This commit is contained in:
Sean Stangl
2019-08-20 13:18:54 -06:00
committed by Benjamin Bouvier
parent 97996d79ce
commit e736367b8c

View File

@@ -31,7 +31,7 @@ use crate::binemit::{CodeInfo, CodeOffset};
use crate::cursor::{Cursor, FuncCursor};
use crate::dominator_tree::DominatorTree;
use crate::flowgraph::ControlFlowGraph;
use crate::ir::{Ebb, Function, Inst, InstructionData, Opcode, Value, ValueList};
use crate::ir::{Function, InstructionData, Opcode};
use crate::isa::{EncInfo, TargetIsa};
use crate::iterators::IteratorExtras;
use crate::regalloc::RegDiversions;
@@ -39,13 +39,16 @@ use crate::timing;
use crate::CodegenResult;
use log::debug;
#[cfg(feature = "basic-blocks")]
use crate::ir::{Ebb, Inst, Value, ValueList};
/// Relax branches and compute the final layout of EBB headers in `func`.
///
/// Fill in the `func.offsets` table so the function is ready for binary emission.
pub fn relax_branches(
func: &mut Function,
cfg: &mut ControlFlowGraph,
domtree: &mut DominatorTree,
_cfg: &mut ControlFlowGraph,
_domtree: &mut DominatorTree,
isa: &dyn TargetIsa,
) -> CodegenResult<CodeInfo> {
let _tt = timing::relax_branches();
@@ -57,8 +60,8 @@ pub fn relax_branches(
func.offsets.resize(func.dfg.num_ebbs());
// Start by removing redundant jumps.
// FIXME: Temporarily disabled due to #916.
/* fold_redundant_jumps(func, cfg, domtree); */
#[cfg(feature = "basic-blocks")]
fold_redundant_jumps(func, _cfg, _domtree);
// Convert jumps to fallthrough instructions where possible.
fallthroughs(func);
@@ -146,6 +149,7 @@ pub fn relax_branches(
/// Folds an instruction if it is a redundant jump.
/// Returns whether folding was performed (which invalidates the CFG).
#[cfg(feature = "basic-blocks")]
fn try_fold_redundant_jump(
func: &mut Function,
cfg: &mut ControlFlowGraph,
@@ -243,6 +247,7 @@ fn try_fold_redundant_jump(
/// Redirects `jump` instructions that point to other `jump` instructions to the final destination.
/// This transformation may orphan some blocks.
#[cfg(feature = "basic-blocks")]
fn fold_redundant_jumps(
func: &mut Function,
cfg: &mut ControlFlowGraph,