@@ -1995,6 +1995,10 @@ impl Function {
19951995
19961996 /// Replace `insn` with the new instruction `replacement`, which will get appended to `insns`.
19971997 fn make_equal_to ( & mut self , insn : InsnId , replacement : InsnId ) {
1998+ assert ! ( self . insns[ insn. 0 ] . has_output( ) ,
1999+ "Don't use make_equal_to for instruction with no output" ) ;
2000+ assert ! ( self . insns[ replacement. 0 ] . has_output( ) ,
2001+ "Can't replace instruction that has output with instruction that has no output" ) ;
19982002 // Don't push it to the block
19992003 self . union_find . borrow_mut ( ) . make_equal_to ( insn, replacement) ;
20002004 }
@@ -2960,9 +2964,8 @@ impl Function {
29602964 let offset = SIZEOF_VALUE_I32 * ivar_index as i32 ;
29612965 ( as_heap, offset)
29622966 } ;
2963- let replacement = self . push_insn ( block, Insn :: StoreField { recv : ivar_storage, id, offset, val } ) ;
2967+ self . push_insn ( block, Insn :: StoreField { recv : ivar_storage, id, offset, val } ) ;
29642968 self . push_insn ( block, Insn :: WriteBarrier { recv : self_val, val } ) ;
2965- self . make_equal_to ( insn_id, replacement) ;
29662969 }
29672970 _ => { self . push_insn_id ( block, insn_id) ; }
29682971 }
@@ -3520,11 +3523,9 @@ impl Function {
35203523 } ;
35213524 // If we're adding a new instruction, mark the two equivalent in the union-find and
35223525 // do an incremental flow typing of the new instruction.
3523- if insn_id != replacement_id {
3526+ if insn_id != replacement_id && self . insns [ replacement_id . 0 ] . has_output ( ) {
35243527 self . make_equal_to ( insn_id, replacement_id) ;
3525- if self . insns [ replacement_id. 0 ] . has_output ( ) {
3526- self . insn_types [ replacement_id. 0 ] = self . infer_type ( replacement_id) ;
3527- }
3528+ self . insn_types [ replacement_id. 0 ] = self . infer_type ( replacement_id) ;
35283529 }
35293530 new_insns. push ( replacement_id) ;
35303531 // If we've just folded an IfTrue into a Jump, for example, don't bother copying
0 commit comments