diff --git a/src/opt/simplify_cfg.rs b/src/opt/simplify_cfg.rs index 6f4be0c..a3764c9 100644 --- a/src/opt/simplify_cfg.rs +++ b/src/opt/simplify_cfg.rs @@ -136,6 +136,8 @@ impl Optimize for SimplifyCfgMerge { } } + code.blocks.retain(|bid, _| !merged_to.contains_key(bid)); + for (bid, block) in &mut code.blocks { for inst in block.instructions.iter_mut() { replace_instruction_operands(inst, &replaces); @@ -143,7 +145,6 @@ impl Optimize for SimplifyCfgMerge { replace_exit_operands(&mut block.exit, &replaces); } - code.blocks.retain(|bid, _| !merged_to.contains_key(bid)); !merged_to.is_empty() } } @@ -290,25 +291,19 @@ fn replace_instruction_operands(inst: &mut Instruction, replaces: &HashMap { - replace_operand(operand, replaces); - } + Instruction::UnaryOp { operand, .. } => replace_operand(operand, replaces), Instruction::Store { ptr, value } => { replace_operand(ptr, replaces); replace_operand(value, replaces); } - Instruction::Load { ptr } => { - replace_operand(ptr, replaces); - } + Instruction::Load { ptr } => replace_operand(ptr, replaces), Instruction::Call { callee, args, .. } => { replace_operand(callee, replaces); for arg in args.iter_mut() { replace_operand(arg, replaces); } } - Instruction::TypeCast { value, .. } => { - replace_operand(value, replaces); - } + Instruction::TypeCast { value, .. } => replace_operand(value, replaces), Instruction::GetElementPtr { ptr, offset, .. } => { replace_operand(ptr, replaces); replace_operand(offset, replaces);