Commit Graph

3 Commits

Author SHA1 Message Date
d4f90976da refactor(joinir): Phase 244 - ConditionLoweringBox trait unification
Unify condition lowering logic across Pattern 2/4 with trait-based API.

New infrastructure:
- condition_lowering_box.rs: ConditionLoweringBox trait + ConditionContext (293 lines)
- ExprLowerer implements ConditionLoweringBox trait (+51 lines)

Pattern migrations:
- Pattern 2 (loop_with_break_minimal.rs): Use trait API
- Pattern 4 (loop_with_continue_minimal.rs): Use trait API

Benefits:
- Unified condition lowering interface
- Extensible for future lowering strategies
- Clean API boundary between patterns and lowering logic
- Zero code duplication

Test results: 911/911 PASS (+2 new tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-11 02:35:31 +09:00
76a36333c2 feat(joinir): Phase 204 PHI Contract Verifier complete
Phase 204-3/5/6/7: PHI inputs verification, integration, testing, docs

Implementation:
- verify_phi_inputs_defined(): Conservative sanity checks (ValueId < 100000)
- Integration: All verifiers in verify_joinir_contracts()
- Testing: 821 tests PASS, no regressions

Task Status:
-  204-1: Design document (phase204-phi-contract-verifier.md)
-  204-2: PHI dst overwrite detection
-  204-3: PHI inputs sanity checks
- ⚠️ 204-4: JoinValueSpace region verification (deferred to Phase 205+)
  - Rationale: Requires LoopHeaderPhiInfo extension (4+ files)
  - Alternative: Conservative threshold checks in verify_phi_inputs_defined()
-  204-5: Integration (verify_joinir_contracts)
-  204-6: Tests (821 PASS)
-  204-7: Documentation (phase204 doc + CURRENT_TASK.md)

Verification Coverage:
-  PHI exists (Phase 200-3)
-  PHI dst match (Phase 200-3)
-  PHI dst not overwritten (Phase 204-2) 
-  PHI inputs sanity (Phase 204-3) 
- ⚠️ PHI inputs DFA (Phase 205+)
- ⚠️ ValueId regions (Phase 205+)

Design Principles:
- Debug-only (#[cfg(debug_assertions)])
- Fail-Fast (panic on violation)
- Zero cost in release builds

Files Modified:
- src/mir/builder/control_flow/joinir/merge/mod.rs (+115 lines)
- src/mir/builder/control_flow/joinir/merge/exit_line/reconnector.rs (1 line)
- docs/development/current/main/phase204-phi-contract-verifier.md (updated)
- CURRENT_TASK.md (Phase 204 complete)

Success Criteria: 4/5 met (1 deferred with rationale)
2025-12-09 19:57:32 +09:00
0175e62d9e feat(joinir): Phase 204-2 PHI dst overwrite detection
Task 204-2: Implement verify_no_phi_dst_overwrite()
- Added PHI dst overwrite detection in merge/mod.rs
- Helper get_instruction_dst() extracts dst from MirInstruction
- Integrated into verify_joinir_contracts()
- Fixed pre-existing bugs:
  - entry_block_remapped → entry_block (line 592)
  - HashMap → BTreeMap in reconnector.rs (line 174)
- All instructions covered with wildcard pattern

Design:
- Debug-only (#[cfg(debug_assertions)])
- Fail-Fast panic on violation
- Checks PHI dst not overwritten by later instructions in header block

Status: Build SUCCESS (Task 204-2 complete)
Next: Task 204-3 (PHI inputs verification)
2025-12-09 19:53:33 +09:00