Add a fold_redundant_jumps() pass to the branch relaxation phase. (#887)
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::entity::{PrimaryMap, SecondaryMap};
|
||||
use crate::ir;
|
||||
use crate::ir::{DataFlowGraph, ExternalName, Layout, Signature};
|
||||
use crate::ir::{
|
||||
Ebb, ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Heap, HeapData, JumpTable,
|
||||
Ebb, ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Heap, HeapData, Inst, JumpTable,
|
||||
JumpTableData, SigRef, StackSlot, StackSlotData, Table, TableData,
|
||||
};
|
||||
use crate::ir::{EbbOffsets, InstEncodings, SourceLocs, StackSlots, ValueLocations};
|
||||
@@ -20,7 +20,7 @@ use crate::write::write_function;
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "basic-blocks")]
|
||||
use crate::ir::{Inst, Opcode};
|
||||
use crate::ir::Opcode;
|
||||
|
||||
/// A function.
|
||||
///
|
||||
@@ -223,6 +223,15 @@ impl Function {
|
||||
self.dfg.collect_debug_info();
|
||||
}
|
||||
|
||||
/// Changes the destination of a jump or branch instruction.
|
||||
/// Does nothing if called with a non-jump or non-branch instruction.
|
||||
pub fn change_branch_destination(&mut self, inst: Inst, new_dest: Ebb) {
|
||||
match self.dfg[inst].branch_destination_mut() {
|
||||
None => (),
|
||||
Some(inst_dest) => *inst_dest = new_dest,
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that the specified EBB can be encoded as a basic block.
|
||||
///
|
||||
/// On error, returns the first invalid instruction and an error message.
|
||||
|
||||
Reference in New Issue
Block a user