Files
hakorune/docs/reference/mir/phi_policy.md
Selfhosting Dev f0608e9bb1 feat: Phase 2.4 レガシーアーカイブ整理完了(151MB削減)
## 🎉 完了項目
-  plugin_box_legacy.rs削除(7.7KB、参照ゼロ確認済み)
-  REMOVEDコメント整理(encode.rs簡潔化)
-  venv削除(143MB節約、.gitignoreは既存)
-  llvm_legacyスタブ化(8KB、compile_error!による安全化)

## 🏆 成果
- **リポジトリサイズ改善**: 151MB削減
- **コード整理**: レガシーコード安全にアーカイブ
- **プラグインファースト**: StrictPluginFirst継続動作

##  検証完了
- cargo build --release --features llvm (警告のみ、エラーなし)
- LLVMハーネス実行: print出力正常
- プラグイン動作: StringBox等正常動作

codex先生の戦略に従った安全な段階的削除を実行

Co-Authored-By: codex <noreply@anthropic.com>
2025-09-24 14:13:15 +09:00

2.2 KiB
Raw Blame History

MIR PHI Policy (Phase15)

Status

  • Default: PHIon. MIR builders always emit SSA Phi nodes at merge heads, and verifiers run with full dominance checks.
  • Legacy fallback: Set NYASH_MIR_NO_PHI=1 to enforce the former edgecopy mode (PHIoff) for targeted debug sessions.
  • LLVM: The llvmlite harness still validates and, when necessary, rewires PHIs, but it no longer compensates for missing SSA form in the input.

Rationale

  • Break/continue correctness: PHIoff exposed MIR generation bugs around loop exits; keeping PHIs generated in the core builder avoids silent value reuse mistakes.
  • ChatGPT Pro design review: external audit recommended shipping Phase15 with PHI enabled by default to minimize backend divergence and simplify documentation.
  • Maintained parity: PyVM and LLVM continue to share the same MIR stream; PHI nodes remain the single source of truth for join semantics.

Operational Rules (PHIon)

  • Merge blocks place PHIs first, with one incoming per predecessor, covering loop latches, break/continue exits, and structured control flow.
  • verify_allow_no_phi() mirrors NYASH_MIR_NO_PHI; with PHIon it stays strict and fails if SSA form is missing.
  • Use NYASH_LLVM_TRACE_PHI=1 to inspect wiring; traces now confirm the builders SSA layout instead of synthesizing it from edge copies.

Fallback Mode (PHIoff)

  • Toggle: NYASH_MIR_NO_PHI=1 (optionally pair with NYASH_VERIFY_ALLOW_NO_PHI=1).
  • Behavior: MIR builders revert to edge copies per predecessor and skip PHI emission. This path is retained only for diagnosing older JSON dumps.
  • Guardrails: tooling should mark PHIoff runs as legacy; new smokes and CI stay on PHIon unless explicitly overridden.

Backends

  • LLVM harness consumes the PHIrich MIR stream and validates incoming edges; no extra synthesis is performed unless legacy mode is forced.
  • Cranelift/JIT paths operate on the same MIR14 form; Phase15 keeps them secondary but expects PHIs to be present.

Acceptance

  • Default smokes/CI run with PHIon.
  • Legacy PHIoff runs must document the reason in CURRENT_TASK.md (e.g., reproducing historical MIR13 bugs) and avoid committing the override into shared scripts.