fix(joinir): Phase 172 P0 - Remap PHI incoming Value IDs

Previously, PHI incoming values were not being remapped from JoinIR-local
ValueIds to Host ValueIds. Only the block IDs were remapped.

This fix ensures both block ID and value ID are remapped for PHI
instructions during JoinIR merge.

Note: trim still fails because condition variable exit values are not
being reflected in variable_map (Phase 172-4/5 work needed).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-07 01:50:13 +09:00
parent e30116f53d
commit 0dde30ceb8

View File

@ -194,10 +194,13 @@ pub(super) fn merge_and_rewrite(
type_hint: None,
} => MirInstruction::Phi {
dst,
// Phase 172: Fix P0 - Remap BOTH block ID AND value ID for PHI incoming
inputs: inputs
.iter()
.map(|(bb, val)| {
(local_block_map.get(bb).copied().unwrap_or(*bb), *val)
let remapped_bb = local_block_map.get(bb).copied().unwrap_or(*bb);
let remapped_val = remapper.remap_value(*val);
(remapped_bb, remapped_val)
})
.collect(),
type_hint: None,