## Summary Implemented fail-fast validation for PHI ordering and value resolution in strict mode. ## Changes ### P1-1: Strict mode for "PHI after terminator" - File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi` - Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator - Default: Warning only (no regression) ### P1-2: Strict mode for "fallback 0" - File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings` - Behavior: Strict mode forbids silent fallback to 0 (2 locations) - Location 1: Unresolvable incoming value - Location 2: Type coercion failure - Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64` ### P1-3: Connect verify_phi_ordering() to execution path - File: `src/llvm_py/builders/function_lower.py` - Behavior: Verify PHI ordering after all instructions emitted - Debug mode: Shows "✅ All N blocks have correct PHI ordering" - Strict mode: Raises RuntimeError with block list if violations found ## Testing ✅ Test 1: strict=OFF - passes without errors ✅ Test 2: strict=ON - passes without errors (no violations in test fixtures) ✅ Test 3: debug mode - verify_phi_ordering() connected and running ## Scope - LLVM harness (Python) changes only - No new environment variables (uses existing 3 from Phase 277 P2) - No JoinIR/Rust changes (root fix is Phase 279) - Default behavior unchanged (strict mode opt-in) ## Next Steps - Phase 278: Remove deprecated env var support - Phase 279: Root fix - unify "2本のコンパイラ" pipelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1.6 KiB
1.6 KiB
Phase 276 P0: Quick wins (LLVM harness maintainability)
Status: ✅ completed (2025-12-22)
This sheet documents what Phase 276 P0 targeted (and can be used to reproduce the intent for future refactors).
Reference completion:
docs/development/current/main/phases/phase-276/P0-COMPLETION.md
Non-goals:
- pipeline unification / order drift fixes (tracked as Phase 279)
- new language features
- new env vars
Task 1: Remove noisy debug leftovers
Target:
src/llvm_py/phi_wiring/wiring.py
Acceptance:
- no stacktrace spam in normal runs
Task 2: Consolidate PHI dst type lookup into SSOT
Create:
src/llvm_py/phi_wiring/type_helper.py
Provide:
get_phi_dst_type(...)(SSOT for “what is the intended type of this ValueId?”)dst_type_to_llvm_type(...)(SSOT for MIR dst_type → LLVM IR type)
Integrate (remove duplicate logic):
src/llvm_py/phi_wiring/tagging.pysrc/llvm_py/llvm_builder.pysrc/llvm_py/phi_wiring/wiring.py
Acceptance:
- the same ValueId gets the same effective type across these entry points
- adding a new MIR dst_type requires changing only
type_helper.py
Task 3: Make PHI type mismatch visible
Target:
src/llvm_py/phi_wiring/wiring.py
Policy:
- important mismatch warnings should be visible even without debug env vars
- keep the full trace behind the existing debug gate
Task 4: Confirm the change does not regress existing smokes
Minimum:
- build still succeeds
- representative LLVM harness runs still pass (no new failures)
Note:
- If a failure points to “two pipelines / ordering drift”, treat it as Phase 279 scope.