This commit is contained in:
static
2025-05-08 10:19:04 +00:00
parent 82105057ad
commit 41f68116cb

View File

@@ -136,6 +136,8 @@ impl Optimize<FunctionDefinition> 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<FunctionDefinition> 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<Regis
replace_operand(lhs, replaces);
replace_operand(rhs, replaces);
}
Instruction::UnaryOp { operand, .. } => {
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);