fix(joinir): Phase 287 P2 - Pattern6 nested loop latch overwrite fix

Fix infinite loop in Pattern6 (nested loop minimal) caused by main→loop_step
overwriting k_inner_exit→loop_step latch values.

Root cause: JoinIR main entry block was incorrectly treated as BackEdge,
causing it to overwrite the correct latch incoming values set by the true
back edge (k_inner_exit → loop_step).

Solution:
- Restrict latch recording to TailCallKind::BackEdge only
- Treat only MAIN's entry block as entry-like (not loop_step's entry block)
- Add debug_assert! to detect double latch set in future

Refactoring:
- Extract latch recording to latch_incoming_recorder module (SSOT)
- Add boundary.loop_header_func_name for explicit header identification
- Strengthen tail_call_classifier with is_source_entry_like parameter

Tests: apps/tests/phase1883_nested_minimal.hako → RC:9 (was infinite loop)
Smoke: 154/154 PASS, no regressions

🤖 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-27 09:39:29 +09:00
parent bbfc3c1d94
commit a04b48416e
20 changed files with 401 additions and 171 deletions

View File

@ -1,13 +1,19 @@
# Self Current Task — Now (main)
## Current Focus: Phase 188.3 (Nested Loop Lowering)
## Current Focus: Post Phase 188.3 (Refactoring Window)
**2025-12-27: Phase 188.3 完了**
- Pattern6NestedLoopMinimal: `apps/tests/phase1883_nested_minimal.hako` が RC=9
- Merge SSOTlatch/entry-like/double latchを固定BackEdgeのみlatch記録、main entry blockのみentry-like、二重latchはdebug_assert
- `./tools/smokes/v2/run.sh --profile quick` 154/154 PASS 維持
- 入口: `docs/development/current/main/phases/phase-188.3/README.md`
- 次の指示書refactor挟み込み: `docs/development/current/main/phases/phase-188.3/P2-REFACTORING-INSTRUCTIONS.md`
**2025-12-27: Phase 188.2 完了**
- StepTreeの `max_loop_depth` を SSOT に採用Option A
- strict mode で depth > 2 を明示エラー化Fail-Fast
- quick 154/154 PASS、integration selfhost FAIL=0 維持
- 次: `docs/development/current/main/phases/phase-188.3/README.md`depth=2 を JoinIR lowering で通す / “最小write-back”は carrier として明示
- 実装導線(手順書): `docs/development/current/main/phases/phase-188.3/P1-INSTRUCTIONS.md`merge/rewriter の “undef ValueId” 典型罠もここに固定)
- 次: `docs/development/current/main/phases/phase-188.3/P2-REFACTORING-INSTRUCTIONS.md`(意味論不変での整理を優先
**2025-12-27: Phase S0.1 完了**
- integration selfhost を「落ちない状態」に収束FAIL=0