44//! instructions.
55
66use crate :: entity:: { PrimaryMap , SecondaryMap } ;
7- use crate :: ir;
8- use crate :: ir:: JumpTables ;
97use crate :: ir:: {
10- instructions:: BranchInfo , Block , DynamicStackSlot , DynamicStackSlotData , DynamicType ,
11- ExtFuncData , FuncRef , GlobalValue , GlobalValueData , Inst , InstructionData , JumpTable ,
12- JumpTableData , Opcode , SigRef , StackSlot , StackSlotData , Table , TableData , Type ,
8+ self , Block , DataFlowGraph , DynamicStackSlot , DynamicStackSlotData , DynamicStackSlots ,
9+ DynamicType , ExtFuncData , FuncRef , GlobalValue , GlobalValueData , Inst , InstructionData ,
10+ JumpTable , JumpTableData , JumpTables , Layout , Opcode , SigRef , Signature , SourceLocs , StackSlot ,
11+ StackSlotData , StackSlots , Table , TableData , Type ,
1312} ;
14- use crate :: ir:: { DataFlowGraph , Layout , Signature } ;
15- use crate :: ir:: { DynamicStackSlots , SourceLocs , StackSlots } ;
1613use crate :: isa:: CallConv ;
1714use crate :: value_label:: ValueLabelsRanges ;
1815use crate :: write:: write_function;
@@ -280,16 +277,21 @@ impl FunctionStencil {
280277 /// Rewrite the branch destination to `new_dest` if the destination matches `old_dest`.
281278 /// Does nothing if called with a non-jump or non-branch instruction.
282279 pub fn rewrite_branch_destination ( & mut self , inst : Inst , old_dest : Block , new_dest : Block ) {
283- match self . dfg . analyze_branch ( inst) {
284- BranchInfo :: SingleDest ( dest) => {
280+ match self . dfg . insts [ inst] {
281+ InstructionData :: Jump {
282+ destination : dest, ..
283+ } => {
285284 if dest. block ( & self . dfg . value_lists ) == old_dest {
286285 for block in self . dfg . insts [ inst] . branch_destination_mut ( ) {
287286 block. set_block ( new_dest, & mut self . dfg . value_lists )
288287 }
289288 }
290289 }
291290
292- BranchInfo :: Conditional ( block_then, block_else) => {
291+ InstructionData :: Brif {
292+ blocks : [ block_then, block_else] ,
293+ ..
294+ } => {
293295 if block_then. block ( & self . dfg . value_lists ) == old_dest {
294296 if let InstructionData :: Brif {
295297 blocks : [ block_then, _] ,
@@ -315,7 +317,11 @@ impl FunctionStencil {
315317 }
316318 }
317319
318- BranchInfo :: Table ( table, default_dest) => {
320+ InstructionData :: BranchTable {
321+ table,
322+ destination : default_dest,
323+ ..
324+ } => {
319325 self . jump_tables [ table] . iter_mut ( ) . for_each ( |entry| {
320326 if * entry == old_dest {
321327 * entry = new_dest;
@@ -335,7 +341,7 @@ impl FunctionStencil {
335341 }
336342 }
337343
338- BranchInfo :: NotABranch => { }
344+ _ => { }
339345 }
340346 }
341347
0 commit comments