## Summary Completed Phase 284 P1: Enable return statements in Pattern4/5 loops via JoinInst::Ret infrastructure (100% pre-existing, no new infrastructure needed). **Critical Bug Fix**: Block ID remap priority - Fixed: local_block_map must take precedence over skipped_entry_redirects - Root cause: Function-local block IDs can collide with global remap entries (example: loop_step:bb4 vs k_exit:bb4 after merge allocation) - Impact: Conditional Jump else branches were incorrectly redirected to exit - Solution: Check local_block_map FIRST, then skipped_entry_redirects ## Implementation ### New Files - `src/mir/join_ir/lowering/return_collector.rs` - Return detection SSOT (top-level only, P1 scope) - `apps/tests/phase284_p1_return_in_loop_min.hako` - Test fixture (exit code 7) - Smoke test scripts (VM/LLVM) ### Modified Files - `loop_with_continue_minimal.rs`: Return condition check + Jump generation - `pattern4_with_continue.rs`: K_RETURN registration in continuation_funcs - `canonical_names.rs`: K_RETURN constant - `instruction_rewriter.rs`: Fixed Branch remap priority (P1 fix) - `terminator.rs`: Fixed Jump/Branch remap priority (P1 fix) - `conversion_pipeline.rs`: Return normalization support ## Testing ✅ VM: exit=7 PASS ✅ LLVM: exit=7 PASS ✅ Baseline: 46 PASS, 1 FAIL (pre-existing emit issue) ✅ Zero regression ## Design Notes - JoinInst::Ret infrastructure was 100% complete before P1 - Bridge automatically converts JoinInst::Ret → MIR Return terminator - Pattern4/5 now properly merge k_return as non-skippable continuation - Correct semantics: true condition → return, false → continue loop ## Next Phase (P2+) - Refactor: Block remap SSOT (block_remapper.rs) - Refactor: Return jump emitter extraction - Scope: Nested if/loop returns, multiple returns - Design: Standardize early exit pattern (return/break/continue as Jump with cond) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1.4 KiB
1.4 KiB
Phase 286 P0(docs-only): JoinIR Line Absorption SSOT
目的: 「JoinIR line が第2の lowerer として残っている」状態を、設計で終わらせる(収束点の SSOT を固定する)。
このP0でやること(コード変更なし)
- 収束点(1本化ポイント)を SSOT として決める
- 禁止事項(散布・二重SSOT)を文章で固定する
- Phase 284(Return)/ Phase 285(Box lifecycle)と整合する責務マップを作る
README に必ず入れる事項(チェックリスト)
- 「Plan line / JoinIR line」の現状と、なぜ二重化が危険か(迷子の原因)
- 収束後の SSOT フロー(
Extractor → PlanFreeze → Lowerer → Frag/emit_frag) - JoinIR の将来位置づけ(DomainPlan生成補助 / もしくは撤去までの段階)
- 禁止事項(pattern側へ return/break/continue を散布しない、Ok(None)黙殺禁止)
- 次フェーズ(P1 investigation / P2 PoC)の観測点と最小成功条件
SSOTリンク
- Router(SSOT=extract / safety valve):
docs/development/current/main/phases/phase-282/README.md - Frag/compose/emit SSOT:
docs/development/current/main/design/edgecfg-fragments.md - JoinIR line 共通入口:
src/mir/builder/control_flow/joinir/patterns/conversion_pipeline.rs - Plan line SSOT:
docs/development/current/main/phases/phase-273/README.md