feat(joinir): Phase 246-EX Part 2 - Exit PHI & step scheduling fixes

Phase 246-EX Part 2 completes the _atoi JoinIR integration:

Key fixes:
- Exit PHI connection: ExitLineReconnector now correctly uses exit PHI dsts
- Jump args preservation: BasicBlock.jump_args field stores JoinIR exit values
- instruction_rewriter: Reads jump_args, remaps JoinIR→HOST values by carrier order
- step_schedule.rs: New module for body-local init step ordering

Files changed:
- reconnector.rs: Exit PHI connection improvements
- instruction_rewriter.rs: Jump args reading & carrier value mapping
- loop_with_break_minimal.rs: Refactored step scheduling
- step_schedule.rs: NEW - Step ordering logic extracted

Tests: 931/931 PASS (no regression)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-11 16:46:53 +09:00
parent e356524b0a
commit eb00d97fdb
16 changed files with 802 additions and 219 deletions

View File

@ -348,6 +348,7 @@ impl JoinIrBlockConverter {
args: &[ValueId],
cond: &Option<ValueId>,
) -> Result<(), JoinIrVmBridgeError> {
// Phase 246-EX: Preserve ALL Jump args as metadata for exit PHI construction
// Phase 27-shortterm S-4.4-A: Jump → Branch/Return
debug_log!(
"[joinir_block] Converting Jump args={:?}, cond={:?}",
@ -376,9 +377,15 @@ impl JoinIrBlockConverter {
branch_terminator,
);
// Exit block
// Phase 246-EX: Store all Jump args in exit block metadata
// Exit block: Create with all Jump args stored as metadata
let exit_value = args.first().copied();
let mut exit_block = crate::mir::BasicBlock::new(exit_block_id);
// Phase 246-EX: Store Jump args in a new metadata field
// This preserves carrier values for exit PHI construction
exit_block.jump_args = Some(args.to_vec());
exit_block.terminator = Some(MirInstruction::Return { value: exit_value });
mir_func.blocks.insert(exit_block_id, exit_block);