feat(joinir): Phase 135 P0 - ConditionLoweringBox allocator SSOT (ValueId collision fix)
## Summary Root cause: ConditionLoweringBox was bypassing ConditionContext.alloc_value (SSOT allocator), causing ValueId collisions between JoinIR condition params and lowered instructions. ## Changes 1. **ConditionLoweringBox (expr_lowerer.rs)**: Must use ConditionContext.alloc_value - Pass &mut ConditionContext to lower_condition (SSOT allocator) - Eliminates internal counter usage 2. **Allocator unification (condition_lowerer.rs, method_call_lowerer.rs)**: - Accept &mut dyn FnMut() -> ValueId as allocator parameter - Ensures all lowering paths use same SSOT allocator 3. **Boundary Copy deduplication (joinir_inline_boundary_injector.rs)**: - Deduplicate condition_bindings by dst - Fail-Fast if different sources target same dst (MIR SSA violation) 4. **Trim pattern fixes (trim_loop_lowering.rs, trim_pattern_validator.rs, stmts.rs)**: - Use builder.next_value_id() instead of value_gen.next() in function context - Ensures function-level ValueId allocation respects reserved PHI dsts ## Acceptance ✅ ./target/release/hakorune --verify apps/tests/phase133_json_skip_whitespace_min.hako ✅ Smoke: phase135_trim_mir_verify.sh - MIR SSA validation PASS ✅ Regression: phase132_exit_phi_parity.sh - 3/3 PASS ✅ Regression: phase133_json_skip_whitespace_llvm_exe.sh - compile-only PASS 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -5,8 +5,9 @@
|
||||
## 現在の Phase
|
||||
|
||||
- **Phase 132**: Exit Values Parity (VM == LLVM)
|
||||
- **Phase 131**: LLVM Lowering & InfiniteEarlyExit パターン実装 🚀
|
||||
- **Phase 33**: Box Theory Modularization
|
||||
- **Phase 133**: Promoted carrier join_id(Trim)修正
|
||||
- **Phase 134**: Plugin loader best-effort loading
|
||||
- **Phase 135**: ConditionLoweringBox allocator SSOT(ValueId 衝突の根治)
|
||||
|
||||
## Phase フォルダ構成(推奨)
|
||||
|
||||
|
||||
27
docs/development/current/main/phases/phase-135/README.md
Normal file
27
docs/development/current/main/phases/phase-135/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Phase 135: ConditionLoweringBox allocator SSOT(ValueId 衝突の根治)
|
||||
|
||||
## Status
|
||||
- 状態: ✅ 実装完了(動作確認はローカルで実施)
|
||||
- スコープ: JoinIR の条件 lowering が `JoinValueSpace` と同一の allocator(SSOT)を使うことを保証する
|
||||
|
||||
## Problem
|
||||
`apps/tests/phase133_json_skip_whitespace_min.hako` などで `--verify` が失敗し、MIR に以下の SSA 破綻が出ることがあった:
|
||||
- `Value %13/%14 defined multiple times`(ループ header PHI dst が後続命令で上書きされる)
|
||||
- `Value %18 defined multiple times`(同一 JoinIR ValueId への alias binding が Copy を重複注入する)
|
||||
|
||||
## Root Cause
|
||||
1. `ExprLowerer` が `ConditionLoweringBox` 実装で `ConditionContext.alloc_value` を無視し、内部カウンタで ValueId を発行していた。
|
||||
→ JoinIR 内で `main()` params(例: `ValueId(1000), ValueId(1001)`)と衝突し、merge の remap で header PHI dst に書き込む命令が生成される。
|
||||
2. `JoinInlineBoundary` の `condition_bindings` に同一 `join_value` が複数名で登録される場合があり、entry block への Copy 注入が同じ `dst` に重複する。
|
||||
→ MIR SSA を破壊する(`copy dst` が 2 回発生)。
|
||||
|
||||
## Fix
|
||||
- `ConditionLoweringBox` は `ConditionContext.alloc_value`(SSOT allocator)を必ず使う。
|
||||
- `ConditionLoweringBox::lower_condition` は `&mut ConditionContext` を受け取る(allocator の正当な可変借用のため)。
|
||||
- `condition_lowerer::lower_condition_to_joinir` は `&mut dyn FnMut() -> ValueId` を受理する。
|
||||
- `BoundaryInjector` は `condition_bindings` 注入を `dst` で重複排除し、異なる source が同一 dst に来る場合は Fail-Fast。
|
||||
|
||||
## Acceptance
|
||||
- `./target/release/hakorune --verify apps/tests/phase133_json_skip_whitespace_min.hako` が PASS
|
||||
- `./target/release/hakorune --dump-mir apps/tests/phase133_json_skip_whitespace_min.hako` のループ header で PHI dst の再定義がない
|
||||
|
||||
Reference in New Issue
Block a user