refactor(mir): phase260 p0 edge-args plumbing (strangler) + ssot api + docs

This commit is contained in:
2025-12-21 04:34:22 +09:00
parent 4496b6243d
commit 4dfe3349bf
42 changed files with 1044 additions and 187 deletions

View File

@ -524,7 +524,7 @@ mod tests {
}
#[test]
fn test_dce_keeps_jump_args_values() {
fn test_dce_keeps_edge_args_values() {
let signature = FunctionSignature {
name: "main".to_string(),
params: vec![],
@ -533,6 +533,7 @@ mod tests {
};
let mut func = MirFunction::new(signature, BasicBlockId::new(0));
let bb0 = BasicBlockId::new(0);
let bb1 = BasicBlockId::new(1);
let mut b0 = BasicBlock::new(bb0);
let v0 = ValueId::new(0);
let v1 = ValueId::new(1);
@ -541,9 +542,17 @@ mod tests {
value: ConstValue::Integer(1),
});
b0.add_instruction(MirInstruction::Copy { dst: v1, src: v0 });
b0.add_instruction(MirInstruction::Return { value: None });
b0.jump_args = Some(vec![v1]);
b0.set_jump_with_edge_args(
bb1,
Some(crate::mir::EdgeArgs {
layout: crate::mir::join_ir::lowering::inline_boundary::JumpArgsLayout::CarriersOnly,
values: vec![v1],
}),
);
func.add_block(b0);
let mut exit_block = BasicBlock::new(bb1);
exit_block.set_terminator(MirInstruction::Return { value: None });
func.add_block(exit_block);
let mut module = MirModule::new("test".to_string());
module.add_function(func);
@ -555,7 +564,7 @@ mod tests {
.instructions
.iter()
.any(|inst| matches!(inst, MirInstruction::Copy { .. }));
assert!(has_copy, "Copy used only by jump_args should not be eliminated");
assert!(has_copy, "Copy used only by edge args should not be eliminated");
}
#[test]