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>