feat(llvm): Phase 132 - Pattern 1 exit value parity fix + Box-First refactoring
## Phase 132: Exit PHI Value Parity Fix ### Problem Pattern 1 (Simple While) returned 0 instead of final loop variable value (3) - VM: RC: 3 ✅ (correct) - LLVM: Result: 0 ❌ (wrong) ### Root Cause (Two Layers) 1. **JoinIR/Boundary**: Missing exit_bindings → ExitLineReconnector not firing 2. **LLVM Python**: block_end_values snapshot dropping PHI values ### Fix **JoinIR** (simple_while_minimal.rs): - Jump(k_exit, [i_param]) passes exit value **Boundary** (pattern1_minimal.rs): - Added LoopExitBinding with carrier_name="i", role=LoopState - Enables ExitLineReconnector to update variable_map **LLVM** (block_lower.py): - Use predeclared_ret_phis for reliable PHI filtering - Protect builder.vmap PHIs from overwrites (SSOT principle) ### Result - ✅ VM: RC: 3 - ✅ LLVM: Result: 3 - ✅ VM/LLVM parity achieved ## Phase 132-Post: Box-First Refactoring ### Rust Side **JoinModule::require_function()** (mod.rs): - Encapsulate function search logic - 10 lines → 1 line (90% reduction) - Reusable for Pattern 2-5 ### Python Side **PhiManager Box** (phi_manager.py - new): - Centralized PHI lifecycle management - 47 lines → 8 lines (83% reduction) - SSOT: builder.vmap owns PHIs - Fail-Fast: No silent overwrites **Integration**: - LLVMBuilder: Added phi_manager - block_lower.py: Delegated to PhiManager - tagging.py: Register PHIs with manager ### Documentation **New Files**: - docs/development/architecture/exit-phi-design.md - docs/development/current/main/investigations/phase132-llvm-exit-phi-wrong-result.md - docs/development/current/main/phases/phase-132/ **Updated**: - docs/development/current/main/10-Now.md - docs/development/current/main/phase131-3-llvm-lowering-inventory.md ### Design Principles - Box-First: Logic encapsulated in classes/methods - SSOT: Single Source of Truth (builder.vmap for PHIs) - Fail-Fast: Early explicit failures, no fallbacks - Separation of Concerns: 3-layer architecture 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
詳細は `docs/development/current/main/` 以下の各 Phase 文書と、JoinIR の SSOT である
|
||||
`docs/development/current/main/joinir-architecture-overview.md` を参照してね。
|
||||
|
||||
最終更新: 2025-12-14
|
||||
最終更新: 2025-12-15
|
||||
|
||||
過去ログ(肥大化した旧 CURRENT_TASK)はここに退避したよ:
|
||||
- `docs/development/current/main/CURRENT_TASK_ARCHIVE_2025-12-13.md`
|
||||
@ -18,7 +18,10 @@
|
||||
- debug flag SSOT / DebugOutputBox 移行 / error tags 集約 / carrier init builder まで整備済み。
|
||||
- **LLVM exe line SSOT 確立**: `tools/build_llvm.sh` を使用した .hako → executable パイプライン標準化完了。
|
||||
- **LLVM AOT(Python llvmlite)ループ復旧**: `apps/tests/loop_min_while.hako` が EMIT/LINK/RUN まで到達(Phase 131-3..10)。
|
||||
- 残り: `loop(true)` + `break/continue` の JoinIR パターン穴(Case C)
|
||||
- Case C(`loop(true)` + break/continue)は Phase 131-11 で Pattern/shape guard の基盤まで到達。残りは Case C の parity/仕上げ(SSOT を見ながら詰める)。
|
||||
- **Phase 132 完了**: Pattern 1(Simple While)の `return i` が VM/LLVM で一致(3 を返す)まで根治。
|
||||
- JoinIR/Boundary: exit 値を境界に明示的に渡す
|
||||
- LLVM Python: PHI を落とす/上書きする経路を除去(PHI SSOT を保護)
|
||||
- **Phase 88 完了**: continue + 可変ステップ(i=i+const 差分)を dev-only fixture で固定、StepCalculator Box 抽出。
|
||||
- **Phase 89 完了**: P0(ContinueReturn detector)+ P1(lowering 実装)完了。
|
||||
- **Phase 90 完了**: ParseStringComposite + `Null` literal + ContinueReturn(同一値の複数 return-if)を dev-only fixture で固定。
|
||||
@ -35,6 +38,8 @@
|
||||
- `docs/development/current/main/phase131-2-box-resolution-map.md`
|
||||
- `docs/development/current/main/phase131-3-llvm-lowering-inventory.md`
|
||||
- `docs/development/current/main/phase131-5-taglink-fix-summary.md`
|
||||
- `docs/development/current/main/phases/phase-132/README.md`
|
||||
- `docs/development/current/main/investigations/phase132-llvm-exit-phi-wrong-result.md`
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user