phase29ag(p0): use BoundaryCarrierLayout in coordinator remap
This commit is contained in:
@ -1,60 +1,30 @@
|
||||
# Phase 29ag P0: Coordinator uses BoundaryCarrierLayout — Instructions
|
||||
|
||||
Status: Ready for execution
|
||||
Scope: merge coordinator の param remap を BoundaryCarrierLayout に収束(仕様不変)
|
||||
Scope: merge/coordinator の carrier 順序参照を BoundaryCarrierLayout に統一(仕様不変)
|
||||
|
||||
## Goal
|
||||
|
||||
JoinIR merge の `coordinator.rs` が持っている “carrier順序に依存する remap” を、Phase 29af で確定した SSOT
|
||||
`BoundaryCarrierLayout` 参照に統一する。
|
||||
|
||||
- order の起点を boundary(layout SSOT)へ寄せる
|
||||
- `LoopHeaderPhiInfo::carrier_order` 依存を減らし、ズレの温床を減らす
|
||||
`src/mir/builder/control_flow/joinir/merge/coordinator.rs` の “carrier順序依存 remap” を
|
||||
BoundaryCarrierLayout SSOT参照へ統一し、順序の二重管理を解消する。
|
||||
|
||||
## Non-goals
|
||||
|
||||
- 挙動変更(release 既定挙動の変更)
|
||||
- env var の追加
|
||||
- contract_checks の追加(P4 で十分)
|
||||
|
||||
## Target
|
||||
|
||||
`src/mir/builder/control_flow/joinir/merge/coordinator.rs`
|
||||
|
||||
対象箇所(代表):
|
||||
- JoinIR main params の remap(param[i] を “carrier name” 経由で header PHI dst に写すところ)
|
||||
- latch args の index 推測など、順序に依存するロジックがあれば同様に置き換え
|
||||
- fixture/smoke の増加
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1) **BoundaryCarrierLayout を import**
|
||||
- `use crate::mir::builder::control_flow::joinir::merge::boundary_carrier_layout::BoundaryCarrierLayout;`
|
||||
1) coordinator の carrier order 参照を置換
|
||||
- `loop_step` param の index → carrier 名の対応を BoundaryCarrierLayout から取得
|
||||
- fallback の loop_var + carriers の順序も BoundaryCarrierLayout から取得
|
||||
|
||||
2) **carrier order の入力を boundary layout に切替**
|
||||
2) 既存 SSOT への依存は維持
|
||||
- header PHI の対応は LoopHeaderPhiInfo の carrier_phis を参照する
|
||||
|
||||
変更前(概念):
|
||||
- `for (idx, carrier_name) in loop_header_phi_info.carrier_order.iter().enumerate() { ... }`
|
||||
|
||||
変更後(概念):
|
||||
- `let layout = BoundaryCarrierLayout::from_boundary(boundary);`
|
||||
- `for (idx, carrier_name) in layout.ordered_names().iter().enumerate() { ... }`
|
||||
|
||||
3) **header PHI dst は LoopHeaderPhiInfo から取得**
|
||||
- `loop_header_phi_info.get_carrier_phi(carrier_name)` を使う
|
||||
- “idx と name の整合” は P4 の contract_checks が strict/dev で検出する前提
|
||||
|
||||
4) **docs / comments**
|
||||
- `coordinator.rs` の該当ブロックに “SSOT: BoundaryCarrierLayout” を明記(短く)
|
||||
- `docs/development/current/main/phases/phase-29ag/README.md` の P0 に実装済みを追記(完了時)
|
||||
- `docs/development/current/main/10-Now.md` を Phase 29ag に更新(完了時)
|
||||
|
||||
## Verification
|
||||
## Verification (SSOT)
|
||||
|
||||
- `cargo build --release`
|
||||
- `./tools/smokes/v2/run.sh --profile quick`
|
||||
- `./tools/smokes/v2/profiles/integration/joinir/phase29ae_regression_pack_vm.sh`
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- 回帰パックが PASS のまま(仕様不変)
|
||||
- coordinator の order 参照が boundary SSOT に寄る(review で確認可能)
|
||||
|
||||
@ -8,11 +8,11 @@ use std::collections::BTreeMap;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::{
|
||||
block_allocator, block_remapper, boundary_logging, carrier_init_builder, contract_checks,
|
||||
debug_assertions, entry_selector, exit_args_collector, exit_line, exit_phi_builder,
|
||||
expr_result_resolver, header_phi_prebuild, instruction_rewriter, loop_header_phi_builder,
|
||||
loop_header_phi_info, merge_result, phi_block_remapper, rewriter, tail_call_classifier,
|
||||
tail_call_lowering_policy, value_collector, value_remapper,
|
||||
block_allocator, block_remapper, boundary_carrier_layout, boundary_logging, carrier_init_builder,
|
||||
contract_checks, debug_assertions, entry_selector, exit_args_collector, exit_line,
|
||||
exit_phi_builder, expr_result_resolver, header_phi_prebuild, instruction_rewriter,
|
||||
loop_header_phi_builder, loop_header_phi_info, merge_result, phi_block_remapper, rewriter,
|
||||
tail_call_classifier, tail_call_lowering_policy, value_collector, value_remapper,
|
||||
};
|
||||
|
||||
/// Phase 49-3.2: Merge JoinIR-generated MIR blocks into current_function
|
||||
@ -460,6 +460,8 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
),
|
||||
verbose,
|
||||
);
|
||||
let layout = boundary_carrier_layout::BoundaryCarrierLayout::from_boundary(boundary);
|
||||
let layout_names = layout.ordered_names();
|
||||
if function_params.get(loop_step_func_name).is_none() {
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
@ -515,20 +517,16 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
);
|
||||
continue;
|
||||
}
|
||||
// Phase 177-STRUCT-2: Use carrier_order for index-based matching
|
||||
//
|
||||
// Problem: BTreeMap iterates in alphabetical order, but JoinIR
|
||||
// generates params in exit_bindings order.
|
||||
//
|
||||
// Solution: Use carrier_order (Vec<String>) which preserves insertion order.
|
||||
// Phase 29ag P0: Use BoundaryCarrierLayout for index-based matching.
|
||||
if let Some(param_idx) =
|
||||
loop_step_params.iter().position(|p| p == loop_step_param)
|
||||
{
|
||||
// Map params[i] to carrier_order[i]
|
||||
if let (Some(carrier_name), Some(entry)) = (
|
||||
loop_header_phi_info.get_carrier_at_index(param_idx),
|
||||
loop_header_phi_info.get_entry_at_index(param_idx),
|
||||
) {
|
||||
if let Some(carrier_name) = layout_names.get(param_idx) {
|
||||
let entry = match loop_header_phi_info.carrier_phis.get(*carrier_name) {
|
||||
Some(entry) => entry,
|
||||
None => continue,
|
||||
};
|
||||
trace.stderr_if(
|
||||
&format!(
|
||||
"[DEBUG-177] Phase 177-STRUCT-2: REMAP loop_step param[{}] {:?} → {:?} (carrier '{}')",
|
||||
@ -565,12 +563,12 @@ pub(in crate::mir::builder) fn merge_joinir_mir_blocks(
|
||||
);
|
||||
}
|
||||
}
|
||||
// Phase 177-STRUCT-2: Use carrier_order for deterministic iteration
|
||||
for (idx, carrier_name) in loop_header_phi_info.carrier_order.iter().enumerate() {
|
||||
if carrier_name == loop_var_name {
|
||||
// Phase 29ag P0: Use BoundaryCarrierLayout for deterministic iteration
|
||||
for (idx, carrier_name) in layout_names.iter().enumerate() {
|
||||
if *carrier_name == loop_var_name {
|
||||
continue;
|
||||
}
|
||||
let entry = match loop_header_phi_info.carrier_phis.get(carrier_name) {
|
||||
let entry = match loop_header_phi_info.carrier_phis.get(*carrier_name) {
|
||||
Some(e) => e,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user