fix(normalization): Phase 143 execution fix - Param region SSOT

Problem: normalized_helpers allocated env params as ValueId(1,2...)
in PHI Reserved region (0-99) instead of Param region (100-999)
per JoinValueSpace contract.

Root cause: All 4 normalized shadow modules started from
next_value_id=1, violating the Param region contract.

Solution:
- Add NormalizedHelperBox::alloc_env_params_param_region()
  that allocates params starting from PARAM_MIN (100)
- Update 4 normalized shadow files to use new API:
  - loop_true_if_break_continue.rs
  - loop_true_break_once.rs
  - if_as_last_join_k.rs
  - post_if_post_k.rs
- Fix instruction_rewriter.rs type mismatch
  (func.signature.params → func.params)

Verification:
- Unit tests: 69/69 PASS
- VM smoke: exit code 7 
- LLVM EXE smoke: exit code 7  (timeout resolved!)

ValueId Space Contract (Phase 201):
| Region       | Range    | Purpose                      |
|--------------|----------|------------------------------|
| PHI Reserved | 0-99     | Loop header PHI dst          |
| Param        | 100-999  | env params (flag, counter)   |
| Local        | 1000+    | Const, BinOp, condition      |

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-19 08:23:20 +09:00
parent 7030b110cb
commit 5e662eaaf6
9 changed files with 577 additions and 315 deletions

View File

@ -191,3 +191,58 @@ let available_inputs = AvailableInputsCollectorBox::collect(
### Diagnostics
- `OutOfScopeReason::IntrinsicNotWhitelisted` を追加し、`MethodCall` の out-of-scope 理由を精密化する。
---
## ValueId Space Contract (Phase 143 fix)
### 問題
Normalized shadow modules allocate env params using `alloc_value_id()` starting from 1, but JoinValueSpace contract requires Param region (100-999).
**Wrong** (before fix):
```rust
let mut next_value_id: u32 = 1;
let params = NormalizedHelperBox::alloc_env_params(&fields, &mut next_value_id);
// → [ValueId(1), ValueId(2), ...] — PHI Reserved region!
```
**Correct** (after fix):
```rust
let (params, mut next_local) = NormalizedHelperBox::alloc_env_params_param_region(&fields);
// → [ValueId(100), ValueId(101), ...] — Param region ✅
```
### Contract (Phase 201 SSOT)
```
0 100 1000 u32::MAX
├──────────┼──────────┼──────────────────────────┤
│ PHI │ Param │ Local │
│ Reserved│ Region │ Region │
└──────────┴──────────┴──────────────────────────┘
```
| Region | Range | Purpose |
|--------|-------|---------|
| PHI Reserved | 0-99 | Loop header PHI dst |
| **Param** | **100-999** | **env params (flag, counter, etc.)** |
| Local | 1000+ | Const, BinOp, condition results |
### SSOT
- Constants: `src/mir/join_ir/lowering/join_value_space.rs`
- `PARAM_MIN = 100`
- `LOCAL_MIN = 1000`
- API: `NormalizedHelperBox::alloc_env_params_param_region()`
- Location: `src/mir/control_tree/normalized_shadow/common/normalized_helpers.rs`
- Returns: `(Vec<ValueId>, u32)` — (params in 100+ range, next_local starting at 1000)
### Affected Files
- `loop_true_if_break_continue.rs`
- `loop_true_break_once.rs`
- `if_as_last_join_k.rs`
- `post_if_post_k.rs`
All normalized shadow modules must use `alloc_env_params_param_region()` instead of `alloc_env_params()` to ensure env params are in the correct region.