@@ -277,14 +277,12 @@ impl FunctionStencil {
277277 /// Rewrite the branch destination to `new_dest` if the destination matches `old_dest`.
278278 /// Does nothing if called with a non-jump or non-branch instruction.
279279 pub fn rewrite_branch_destination ( & mut self , inst : Inst , old_dest : Block , new_dest : Block ) {
280- match self . dfg . insts [ inst] {
280+ match & mut self . dfg . insts [ inst] {
281281 InstructionData :: Jump {
282282 destination : dest, ..
283283 } => {
284284 if dest. block ( & self . dfg . value_lists ) == old_dest {
285- for block in self . dfg . insts [ inst] . branch_destination_mut ( ) {
286- block. set_block ( new_dest, & mut self . dfg . value_lists )
287- }
285+ dest. set_block ( new_dest, & mut self . dfg . value_lists )
288286 }
289287 }
290288
@@ -293,27 +291,11 @@ impl FunctionStencil {
293291 ..
294292 } => {
295293 if block_then. block ( & self . dfg . value_lists ) == old_dest {
296- if let InstructionData :: Brif {
297- blocks : [ block_then, _] ,
298- ..
299- } = & mut self . dfg . insts [ inst]
300- {
301- block_then. set_block ( new_dest, & mut self . dfg . value_lists ) ;
302- } else {
303- unreachable ! ( ) ;
304- }
294+ block_then. set_block ( new_dest, & mut self . dfg . value_lists ) ;
305295 }
306296
307297 if block_else. block ( & self . dfg . value_lists ) == old_dest {
308- if let InstructionData :: Brif {
309- blocks : [ _, block_else] ,
310- ..
311- } = & mut self . dfg . insts [ inst]
312- {
313- block_else. set_block ( new_dest, & mut self . dfg . value_lists ) ;
314- } else {
315- unreachable ! ( ) ;
316- }
298+ block_else. set_block ( new_dest, & mut self . dfg . value_lists ) ;
317299 }
318300 }
319301
@@ -322,22 +304,14 @@ impl FunctionStencil {
322304 destination : default_dest,
323305 ..
324306 } => {
325- self . jump_tables [ table] . iter_mut ( ) . for_each ( |entry| {
307+ self . jump_tables [ * table] . iter_mut ( ) . for_each ( |entry| {
326308 if * entry == old_dest {
327309 * entry = new_dest;
328310 }
329311 } ) ;
330312
331- if default_dest == old_dest {
332- match & mut self . dfg . insts [ inst] {
333- InstructionData :: BranchTable { destination, .. } => {
334- * destination = new_dest;
335- }
336- _ => panic ! (
337- "Unexpected instruction {} having default destination" ,
338- self . dfg. display_inst( inst)
339- ) ,
340- }
313+ if * default_dest == old_dest {
314+ * default_dest = new_dest;
341315 }
342316 }
343317
0 commit comments