phase29aa: RcPlan + guard no cleanup on jump/branch

This commit is contained in:
2025-12-27 16:09:26 +09:00
parent b6e80943a3
commit 7be0b0c28e
5 changed files with 48 additions and 19 deletions

View File

@ -131,7 +131,7 @@ fn main() {
"return_cleanup",
);
// Case 4: Branch terminator should NOT inject block-end cleanup (unsafe cross-block)
// Case 4: Jump terminator should NOT inject block-end cleanup (unsafe cross-block)
let ptr = ValueId::new(400);
let v1 = ValueId::new(30);
@ -144,7 +144,33 @@ fn main() {
});
block.terminator_span = Some(Span::unknown());
let entry = block.id;
let module = build_module_with_block(block, "selfcheck_branch_skip", "selfcheck_mod4");
let module = build_module_with_block(block, "selfcheck_jump_skip", "selfcheck_mod4");
assert_release_inserted(
module,
"selfcheck_jump_skip",
entry,
0,
"jump_no_cleanup",
);
// Case 5: Branch terminator should NOT inject block-end cleanup (unsafe cross-block)
let ptr = ValueId::new(500);
let v1 = ValueId::new(40);
let cond = ValueId::new(41);
let mut block = BasicBlock::new(BasicBlockId::new(0));
block.instructions = vec![MirInstruction::Store { value: v1, ptr }];
block.instruction_spans = vec![Span::unknown()];
block.terminator = Some(MirInstruction::Branch {
condition: cond,
then_bb: BasicBlockId::new(1),
else_bb: BasicBlockId::new(2),
then_edge_args: None,
else_edge_args: None,
});
block.terminator_span = Some(Span::unknown());
let entry = block.id;
let module = build_module_with_block(block, "selfcheck_branch_skip", "selfcheck_mod5");
assert_release_inserted(
module,
"selfcheck_branch_skip",