## 🎉 完了項目 - ✅ 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>
38 lines
1.9 KiB
Markdown
38 lines
1.9 KiB
Markdown
# MIR PHI Invariants
|
||
|
||
Note
|
||
- Phase‑15 では PHI‑on が既定だよ。この資料の不変条件は MIR ビルダーが生成する PHI と、レガシーで `NYASH_MIR_NO_PHI=1` を指定したときに LLVM が補完するケースの両方へ適用するよ。詳しくは `phi_policy.md` を参照してね。
|
||
|
||
Scope: Builder/Bridge, PyVM, llvmlite (AOT)
|
||
|
||
Goal: Ensure deterministic PHI formation at control-flow merges so that
|
||
PyVM and LLVM backends agree for nested short-circuit, loop-if merges,
|
||
and chained ternary expressions.
|
||
|
||
Invariants
|
||
- If-merge ordering: Record incoming as [then, else] in this order when
|
||
both branches reach the merge. When a branch is structurally absent,
|
||
synthesize a carry-over from the pre-merge value.
|
||
- Loop latch snapshot: The latch (backedge) snapshot must be taken after
|
||
per-iteration merges (i.e., after any phi binding for variables assigned
|
||
in the loop body or nested if). Builder must bind the merged value to the
|
||
loop-carried variable map before capturing the end-of-body state.
|
||
- Self-carry handling: A PHI with self-carry is allowed only when there is
|
||
at least one non-self incoming. At finalize, map self-carry to the most
|
||
recent non-self source visible at the predecessor end.
|
||
|
||
Representative Cases
|
||
- Nested short-circuit: `a && (b || c)` with selective assignments in nested
|
||
branches. Expect single-eval per operand and deterministic merge order.
|
||
- Loop + if merge: A running sum updated in only one branch inside a while
|
||
loop. Expect the latch to capture the phi-merged value, not a pre-merge
|
||
temporary.
|
||
- Chained ternary: `cond1 ? (cond2 ? x : y) : z`. Expect linearized branches
|
||
with merge ordering preserved at each join.
|
||
|
||
Diagnostics
|
||
- Enable `NYASH_LLVM_TRACE_PHI=1` to record per-block snapshots and PHI
|
||
wiring in the LLVM path.
|
||
- Bridge verifier may allow `verify_allow_no_phi()` in PHI-off mode, but
|
||
the invariants above still apply to resolver synthesis order.
|