obs(joinir): Phase 72 - PHI Reserved Region Observation Complete
## Summary Observed PHI dst ValueId distribution to determine if verifier can enforce reserved region (0-99). **Conclusion: Verifier strengthening NOT recommended.** ## Key Finding PHI dst allocation does NOT architecturally respect reserved region: - PHI dst comes from `builder.next_value_id()` (host MirBuilder) - Reserved region (0-99) is a JoinValueSpace contract for JoinIR lowering - These are separate allocation pools with no enforcement mechanism - Current stability is accidental (ValueId allocation ordering) ## Evidence Manual verification (`apps/tests/loop_min_while.hako`): - PHI dst = %3 (ValueId(3)) ✅ in reserved region - Works because PHI allocated early in function (0-20 typical) - JoinValueSpace allocates high (100+, 1000+) - Accidental separation, not enforced ## Implementation Added observation infrastructure (debug-only): - `src/mir/join_ir/verify_phi_reserved.rs` (266 lines) - PHI dst observer with distribution analyzer - Region classifier (Reserved/Param/Local) - Human-readable report generator - Instrumentation at PHI allocation points: - loop_header_phi_builder.rs:94, 151 - Debug-only `observe_phi_dst()` calls ## Test Results - Unit tests: ✅ 4/4 PASS (verify_phi_reserved module) - Lib tests: ✅ 950/950 PASS, 56 ignored - Normalized tests: ✅ 54/54 PASS - Manual verification: ✅ PHI dst in 0-99 observed ## Decision: Document, Don't Enforce **Rationale**: 1. No architectural mechanism to enforce PHI dst ∈ [0, 99] 2. Adding verifier creates false assumptions about allocation order 3. Current system stable through separate pools (950/950 tests) 4. Future architectural fix possible (Phase 73+) but not urgent ## Documentation - PHASE_72_SUMMARY.md: Executive summary and implementation record - phase72-phi-reserved-observation.md: Detailed findings and analysis - CURRENT_TASK.md: Phase 72 completion entry ## Next Steps - Phase 73: Update architecture overview with Phase 72 findings - Optional: Explicit PHI reserved pool (future enhancement) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -88,6 +88,11 @@ impl LoopHeaderPhiBuilder {
|
||||
|
||||
// Allocate PHI for loop variable
|
||||
let loop_var_phi_dst = builder.next_value_id();
|
||||
|
||||
// Phase 72: Observe PHI dst allocation
|
||||
#[cfg(debug_assertions)]
|
||||
crate::mir::join_ir::verify_phi_reserved::observe_phi_dst(loop_var_phi_dst);
|
||||
|
||||
info.carrier_phis.insert(
|
||||
loop_var_name.to_string(),
|
||||
CarrierPhiEntry {
|
||||
@ -145,6 +150,11 @@ impl LoopHeaderPhiBuilder {
|
||||
};
|
||||
|
||||
let phi_dst = builder.next_value_id();
|
||||
|
||||
// Phase 72: Observe PHI dst allocation
|
||||
#[cfg(debug_assertions)]
|
||||
crate::mir::join_ir::verify_phi_reserved::observe_phi_dst(phi_dst);
|
||||
|
||||
info.carrier_phis.insert(
|
||||
name.clone(),
|
||||
CarrierPhiEntry {
|
||||
|
||||
Reference in New Issue
Block a user