22753f8cc3
fix(llvm): Phase 131-7 - Multi-pass vmap sync 修正(Branch bug 解消)
...
Phase 131-7: Multi-pass block lowering の vmap sync バグ修正
問題:
- Pass A (body instructions) が vmap_cur に値を保存
- Pass C (deferred terminators) が builder.vmap を参照
- → Pass A の値が Pass C に届かない
- → Branch condition が 0 に fallback → 無限ループ
修正:
- src/llvm_py/builders/block_lower.py (lines 237-248):
- PHI-only フィルタを削除
- 全ての値を global vmap に sync
変更ファイル:
- src/llvm_py/builders/block_lower.py: vmap sync 修正
- src/llvm_py/instructions/controlflow/branch.py: trace logging 追加
- src/llvm_py/instructions/unop.py: trace logging 追加
- src/llvm_py/llvm_builder.py: debug helpers 追加
- src/llvm_py/phi_wiring/wiring.py: trace logging 追加
- src/runner/modes/common_util/exec.rs: Python stdout 転送
結果:
- ✅ Branch bug 修正: ループが正しく終了
- ✅ 出力: 無限ループ → 3回で停止
- ❌ 新 bug 発見: ExternCall が null を受け取る(PHI 値の代わりに)
Next: Phase 131-8 (ExternCall argument handling 修正)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-14 07:38:21 +09:00
e4eedef34f
feat(llvm): Phase 132 - Fix PHI instruction ordering bug
...
Structural fix for LLVM backend PHI placement issue discovered in Phase 131.
Changes:
- Modified ensure_phi() to position PHI before existing instructions
- Enhanced setup_phi_placeholders() with debug mode
- Created phi_placement.py utility for validation
- Added test script for representative cases
Technical approach:
- PHI creation during setup (before block lowering)
- Explicit positioning with position_before(instrs[0])
- Debug infrastructure via NYASH_PHI_ORDERING_DEBUG=1
Design principles:
- PHI must be created when blocks are empty
- finalize_phis only wires, never creates
- llvmlite API constraints respected
Phase 132 complete. Ready for Phase 133 (ConsoleBox integration).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-04 11:28:55 +09:00
7b1f791395
feat(phase21.5): Loop FORCE direct assembly + PHI/compare fixes
...
## Loop FORCE Direct Assembly ✅
- Added: Direct MIR assembly bypass when HAKO_MIR_BUILDER_LOOP_FORCE_JSONFRAG=1
- Implementation: Extracts limit from Program(JSON), generates minimal while-form
- Structure: entry(0) → loop(1) → body(2) → exit(3)
- PHI: i = {i0, entry} | {i_next, body}
- Location: tools/hakorune_emit_mir.sh:70-126
- Tag: [selfhost-direct:ok] Direct MIR assembly (FORCE=1)
## PHI/Compare Fixes (ny-llvmc) ✅
- Fixed: vmap maintenance for PHI results across instructions
- Fixed: PHI placeholder name consistency (bytes vs str)
- Fixed: ensure_phi_alloca creates unique placeholders per block
- Fixed: resolve_i64_strict properly looks up PHI results
- Files:
- src/llvm_py/phi_wiring/tagging.py
- src/llvm_py/phi_wiring/wiring.py
- src/llvm_py/instructions/compare.py
- src/llvm_py/resolver.py
## Testing Results
- VM backend: ✅ rc=10 (correct)
- Direct assembly MIR: ✅ Structurally correct
- Crate backend: ⚠️ PHI/compare issues (being investigated)
## Implementation Principles
- 既定挙動不変 (FORCE=1 gated)
- Dev toggle controlled
- Minimal diff, surgical changes
- Bypasses using resolution when FORCE=1
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-11 17:04:33 +09:00
7dfd55bfdb
pyvm: implement TypeOp(check) + strict match-guard smokes; parser: guard support in match; llvm: PHI wiring at block head + incoming normalization; docs: AGENTS LLVM/PHI + guard policy; add tests; plan: refactor parse_box_declaration + TODO triage + clone reduction + CLI split + LLVM builder split; update CURRENT_TASK.md
2025-09-19 10:52:57 +09:00
5e818eeb7e
stage3: unify to cleanup; MIR return-defer; docs+smokes updated; LLVM(harness): finalize_phis ownership, ret.py simplified, uses-predeclare; cleanup return override green; method-postfix cleanup return WIP (PHI head)
2025-09-19 02:07:38 +09:00