93022e7e10
fix(pattern2): abort entire Pattern2 on unpromoted LoopBodyLocal instead of partial execution
...
Phase 263 P0: Pattern2 で処理できない LoopBodyLocal を検出したら Pattern2 全体を早期終了
Changes:
- promote_step_box.rs: 戻り値を Result<Option<_>, String> に変更
- Reject を二分化: 対象外(not_readonly等)→ Ok(None)、対象だが未対応 → Err
- pattern2_lowering_orchestrator.rs: Ok(None) 検出で早期 return
- apps/tests/phase263_p0_pattern2_seg_min.hako: test simplification
後続経路(legacy binding等)へ fallback させる(detection→extract→lower SSOT 維持)
Fail-Fast 原則: 対象外は Ok(None) で後続経路へ、対象だが未対応は Err で即座に失敗
Fixes: core_direct_array_oob_set_rc_vm smoke test FAIL
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-21 10:23:38 +09:00
a15821cb17
Revert "fix(pattern2): return Ok(None) for unpromoted LoopBodyLocal instead of Err"
...
This reverts commit e0278405c0 .
2025-12-21 10:21:05 +09:00
e0278405c0
fix(pattern2): return Ok(None) for unpromoted LoopBodyLocal instead of Err
...
- Pattern2 で処理できない LoopBodyLocal は Err ではなく処理続行
- Pattern1 等に fallback させる(detection→extract→lower SSOT 維持)
- out-of-scope 変数(reassigned body-local)はreject不要
Fixes: core_direct_array_oob_set_rc_vm smoke test FAIL
Fixes: phase263_p0_pattern2_seg_min (新規テスト)
2025-12-21 09:56:56 +09:00
c0334f8b7e
refactor(mir): phase260 p0.2 hide legacy edge-args reads behind BasicBlock API
...
- Add block.return_env() getter for Return env metadata
- Update instruction_rewriter.rs to use block.return_env()
- Update exit_collection.rs to use block.return_env()
- Prepare for Phase 260 P2 (jump_args deletion)
This consolidates all legacy edge-args reads through BasicBlock API,
enabling clean deletion of jump_args field in P2.
2025-12-21 09:01:35 +09:00
aa3fdf3c18
refactor(joinir): Phase 260 P0.1 Step 6b - fix tests and add TODO
...
- Fix helpers.rs tests to use new MirFunction::new(FunctionSignature, BasicBlockId) API
- Update continuation_contract.rs import path to use rewriter::helpers
- Add TODO comment for future exit_collection integration
- All 6 rewriter tests pass
The exit_collection module is complete and tested but full integration
with instruction_rewriter.rs deferred (80/20 rule - logging context
and flow control require careful refactoring).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-21 06:33:11 +09:00
cbed040a74
refactor(joinir): Phase 260 P0.1 Step 6 - extract exit_collection.rs
...
Extract exit value collection logic from instruction_rewriter.rs into
dedicated rewriter/exit_collection.rs module (~305 lines).
New functions:
- collect_exit_values_from_legacy_edge_args(): Phase 246-EX collection
- add_carrier_values_to_inputs(): carrier values → carrier_inputs map
- handle_fallback_exit_collection(): Phase 246-EX/131 P1.5 fallback
- collect_k_exit_values(): k_exit tail call lowering (Phase 131)
Key changes:
- ExitCollectionResult struct for structured return values
- Uses Vec<(String, (BasicBlockId, ValueId))> for carrier_values
(matching ExitArgsCollectorBox output format)
- Logging removed from helpers (caller handles via local log! macro)
- 3 unit tests for add_carrier_values_to_inputs
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-21 06:28:09 +09:00
15b3352e21
refactor(joinir): Phase 260 P0.1 Step 5 - Extract terminator.rs (Jump/Branch remapping)
...
Extract Jump/Branch terminator remapping to dedicated module.
3 clean functions: remap_jump, remap_branch, apply_remapped_terminator.
Changes:
- NEW: rewriter/terminator.rs - 3 functions (145 lines)
- remap_jump(): Jump block ID + edge_args remapping
- remap_branch(): Branch block ID + condition + edge_args remapping
- apply_remapped_terminator(): Apply remapped terminator with edge_args handling
- CHANGED: instruction_rewriter.rs - use terminator module (deleted local logic)
- Deleted remap_edge_args closure (lines 902-911)
- Replaced Jump remapping (lines 1056-1067) → remap_jump()
- Replaced Branch remapping (lines 1069-1094) → remap_branch()
- Replaced terminator setting (lines 1098-1127) → apply_remapped_terminator()
- CHANGED: rewriter/mod.rs - declare terminator module
Benefits:
- Phase 259 P0 FIX: skipped_entry_redirects handling centralized
- Testable in isolation (pure block ID/ValueId mapping)
- Reduces instruction_rewriter.rs by ~40 lines
Reduction:
- instruction_rewriter.rs: 1396 → ~1356 lines (-40)
Next: Extract exit_collection.rs (Return→Jump + exit value collection)
2025-12-21 06:17:14 +09:00
d9ff3f60ff
refactor(joinir): Phase 260 P0.1 Step 4 - Extract type_propagation.rs (70 lines)
...
Extract propagate_value_type_for_inst to dedicated type_propagation module.
Handles type info flow from JoinIR→MIR merge (SSOT + fallback inference).
Changes:
- NEW: rewriter/type_propagation.rs - propagate_value_type_for_inst
- CHANGED: instruction_rewriter.rs - import from type_propagation (deleted local fn)
- CHANGED: rewriter/mod.rs - declare type_propagation module
Design:
- SSOT: Prefer type info from JoinIR source function metadata
- Fallback: Infer from instruction structure (Const/Copy/BinOp/Compare)
- LLVM: Ensures '+' stays numeric (not concat_hh_mixed)
Reduction:
- instruction_rewriter.rs: 1466 → 1396 lines (-70)
Next: Start terminator.rs extraction (Branch/Jump/Return remapping)
2025-12-21 06:11:53 +09:00
e555b4ad31
refactor(joinir): Phase 260 P0.1 Step 3 - Extract helpers.rs (is_skippable_continuation)
...
Extract is_skippable_continuation to dedicated helpers module.
Small pure function (12 lines) with comprehensive tests (3 test cases).
Changes:
- NEW: rewriter/helpers.rs - is_skippable_continuation + 3 tests
- CHANGED: instruction_rewriter.rs - import from helpers (deleted local definition)
- CHANGED: rewriter/mod.rs - re-export from helpers
Benefits:
- Testable in isolation (pure function)
- Clear module boundary (structural checks)
- instruction_rewriter.rs: 1477 → 1466 lines (-11)
Tests:
- test_is_skippable_continuation_pure_stub ✅
- test_is_skippable_continuation_has_instructions ✅
- test_is_skippable_continuation_multiple_blocks ✅
Next: Extract type_propagation.rs (propagate_value_type_for_inst - 70 lines)
2025-12-21 06:09:45 +09:00
b87760e247
refactor(joinir): Phase 260 P0.1 Step 2 - Extract logging.rs (DEBUG-177 style)
...
Extract logging utilities into dedicated module (safest first split).
Provides log_if() function + rewriter_log!() macro as alternatives to local log! macro.
Changes:
- NEW: rewriter/logging.rs - log_if() + rewriter_log!() macro
- CHANGED: rewriter/mod.rs - declare logging module
Design:
- log_if(trace, enabled, msg): Function form for explicit control
- rewriter_log!(): Macro form for format!() convenience
- Both wrap JoinLoopTrace::stderr_if() (existing infrastructure)
Status:
- instruction_rewriter.rs still uses local log! macro (unchanged)
- Future: Gradually migrate to logging::log_if() or rewriter_log!()
- cargo check PASS ✅
Next: Extract is_skippable_continuation to helpers.rs (smallest function)
2025-12-21 06:06:29 +09:00
4bc469239d
refactor(joinir): Phase 260 P0.1 Step 1 - Create rewriter/ skeleton (box-first modularization)
...
Create rewriter/ directory with re-export skeleton for instruction_rewriter.rs.
This enables gradual refactoring without breaking existing code.
Changes:
- NEW: src/.../joinir/merge/rewriter/mod.rs (re-exports instruction_rewriter)
- CHANGED: merge/mod.rs - route calls through rewriter module
- STRATEGY: Keep instruction_rewriter.rs intact, split later into:
- terminator.rs (Branch/Jump/Return remapping)
- exit_line.rs (ExitLine/exit-phi wiring)
- carriers.rs (loop_invariants, exit_bindings)
- logging.rs (DEBUG-177 style verbose logs)
Acceptance:
- cargo check PASS ✅
- No behavior change (挙動変更なし)
- Backward compatible (instruction_rewriter.rs still exists)
Next: Extract terminator.rs (smallest, safest first split)
2025-12-21 06:03:43 +09:00
1fe5be347d
refactor(mir): phase260 p0.1 strangler hardening + smoke fixtures
2025-12-21 05:47:37 +09:00
4dfe3349bf
refactor(mir): phase260 p0 edge-args plumbing (strangler) + ssot api + docs
2025-12-21 04:34:22 +09:00
4496b6243d
feat(joinir): Phase 259 P0 complete - Pattern8 final fixes + docs (pre-block-params migration)
...
Phase 259 P0: Pattern8 (BoolPredicateScan) 完全完了
is_integer/1 を Pattern8 で受理し、VM/LLVM EXE 両方で動作確認完了。
次の大工事(block-parameterized CFG への移行)前のマイルストーンとして記録。
## Key Fixes Applied
1. **skipped_entry_redirects** (instruction_rewriter.rs)
- k_exit のスキップ時、entry block 参照を exit_block_id へリダイレクト
- BasicBlockId not found エラーを根治
2. **loop_var_name** (pattern8_scan_bool_predicate.rs)
- merge_entry_block 選択に使用(`Some(parts.loop_var.clone())`)
- 未設定時の誤った entry block 選択を修正
3. **loop_invariants** (pattern8_scan_bool_predicate.rs)
- PHI-free 不変量パラメータ(`[(me, me_host), (s, s_host)]`)
- loop_var_name 設定時、BoundaryInjector が join_inputs Copy を全スキップするため必要
- Pattern6 と同じ設計(header PHI で不変量を保持)
4. **expr_result** (pattern8_scan_bool_predicate.rs)
- k_exit からの返り値を明示設定(`Some(join_exit_value)`)
- Pattern7 style(推測ではなく明示)
5. **Smoke test scripts**
- set +e パターンで exit code 7 をキャプチャ
- LLVM EXE スクリプトにコメント追加(tools/build_llvm.sh 経由の明記)
## Contract Documentation
- join-explicit-cfg-construction.md に Pattern8 契約の具体例を追加
- "pattern増でも推測増にしない" の実例として記録
- loop_var_name / loop_invariants / expr_result / jump_args_layout の契約を明示
- 20-Decisions.md に正規化(Semantic/Plumbing)の分離方針を追記
- DOCS_LAYOUT.md に重要ドキュメントへの参照を追加
## Test Results
- ✅ VM smoke test: `[PASS] phase259_p0_is_integer_vm` (exit 7)
- ✅ LLVM EXE: tools/build_llvm.sh 経由で exit 7 確認
- ✅ --verify: PASS
## Next FAIL (Phase 260+)
- Function: `Main.main/0` in `apps/examples/json_lint/main.hako`
- Error: `[cf_loop/pattern2] Failed to extract break condition from loop body`
- Pattern: Nested loop(外側 loop + 内側 loop with break)
🚀 次の大工事: block-parameterized CFG への移行を開始します。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-21 03:21:22 +09:00
a767f0f3a9
feat(joinir): Phase 259 P0 - Pattern8 BoolPredicateScan + Copy binding fix
...
Pattern8 (Boolean Predicate Scan) implementation for is_integer/1:
- New pattern detection for `loop + if not predicate() { return false }`
- JoinIR lowerer with main/loop_step/k_exit structure
- Me receiver passed as param (by-name 禁止)
Key fixes:
1. expr_result = Some(join_exit_value) (Pattern7 style)
2. Tail-call: dst: None (no extra Ret instruction)
3. instruction_rewriter: Add `&& is_loop_header_with_phi` check
- Pattern8 has no carriers → no PHIs → MUST generate Copy bindings
- Without this, ValueId(103/104/105) were undefined
Status: Copy instructions now generated correctly, but exit block
creation issue remains (next step: Step A-C in指示書).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-21 02:40:07 +09:00
23531bf643
feat(joinir): Phase 258 P0 dynamic needle window scan
2025-12-21 00:29:50 +09:00
73ddc5f58d
feat(joinir): Phase 257 P1.1/P1.2/P1.3 - Pattern6 SSOT + LoopHeaderPhi CFG fix
...
P1.1: Pattern6 false positive fix (SSOT approach)
- can_lower() now calls extract_scan_with_init_parts() for SSOT
- index_of_string/2 no longer triggers false positive
- Graceful fall-through with Ok(None)
P1.2: LoopHeaderPhi CFG-based correction
- Step 0: Manual successor update from terminators
- CFG-based entry predecessor computation (header_preds - latch)
- Multi-entry-pred support (bb0 host + bb10 JoinIR main)
- Explicit host_entry_block addition (emit_jump runs after finalize)
P1.3: Smoke script validation
- phase254_p0_index_of_vm.sh: --verify + VM error detection
- phase257 smokes updated
Acceptance criteria (all PASS):
✅ phase254_p0_index_of_min.hako verify
✅ phase257_p0_last_index_of_min.hako verify
✅ ./tools/smokes/v2/run.sh --profile quick (no Pattern6 false positive)
Technical discovery:
- Host entry block (bb0) Jump set in Phase 6 (after finalize)
- instruction_rewriter bypasses set_terminator(), skips successor update
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-20 23:30:27 +09:00
9ba89bada2
feat(pattern6): support reverse scan for last_index_of
...
Extend Pattern6 (ScanWithInit) to handle both forward and reverse scans:
- Forward: i=0, loop(i < len), i=i+1 (existing)
- Reverse: i=len-1, loop(i >= 0), i=i-1 (NEW)
Implementation:
- Added ScanDirection enum (Forward/Reverse)
- Updated extract_scan_with_init_parts() to detect both patterns
- Created lower_scan_with_init_reverse() lowerer
- Pattern6 now selects appropriate lowerer based on scan direction
Files modified:
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/join_ir/lowering/scan_with_init_reverse.rs (new)
- src/mir/join_ir/lowering/mod.rs
Known issue (pre-existing):
- PHI predecessor mismatch bug exists in Pattern6 (both forward and reverse)
- This bug existed BEFORE Phase 257 P0 implementation
- Out of scope for Phase 257 P0 - will be addressed separately
Phase 257 P0
2025-12-20 20:28:41 +09:00
636b1406bc
refactor(joinir): extract get_entry_function helper
...
Phase 256.8.5: Eliminate duplication of entry function extraction logic
across Pattern2/4/6/7.
Changes:
- Add patterns/common/joinir_helpers.rs with get_entry_function() helper
- Refactor 4 files to use shared helper (eliminate ~40 lines of duplication)
- Consistent error messages across all patterns
Benefits:
- DRY principle: Single source of truth for entry function extraction
- Maintainability: Future changes only need to happen once
- Consistency: All patterns use identical logic and error messages
- Testability: Can be tested independently
Files refactored:
- pattern2_steps/emit_joinir_step_box.rs
- pattern4_with_continue.rs
- pattern6_scan_with_init.rs
- pattern7_split_scan.rs
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-20 20:10:48 +09:00
edc7355937
refactor(joinir): unify boundary join_inputs SSOT (pattern4/6/7)
...
Apply Phase 256.8 SSOT fix to Pattern4/6/7:
- Use join_module.entry.params.clone() instead of hardcoded ValueIds
- Add fail-fast validation for params count mismatch
- Remove ValueId(0), ValueId(PARAM_MIN + k) patterns
- Clean up unused PARAM_MIN imports
This prevents entry_param_mismatch errors structurally and maintains
consistency with Pattern2/3.
Changes:
- pattern4_with_continue.rs: Lines 442-476 (SSOT extraction + validation)
- pattern6_scan_with_init.rs: Lines 447-471 (SSOT extraction + validation)
- pattern7_split_scan.rs: Lines 495-526 (SSOT extraction + validation)
All patterns now use the same SSOT principle:
1. Extract entry function (priority: join_module.entry → fallback "main")
2. Use params as SSOT: join_inputs = entry_func.params.clone()
3. Build host_inputs in expected order (pattern-specific)
4. Fail-fast validation: join_inputs.len() == host_inputs.len()
Verification:
- cargo build --release: ✅ PASS (no PARAM_MIN warnings)
- Quick profile: ✅ First FAIL still json_lint_vm (baseline maintained)
- Pattern6 smoke: ✅ PASS (index_of test)
- Pattern7 smoke: Pre-existing phi pred mismatch (not introduced by SSOT)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-20 20:05:11 +09:00
4439d64da3
refactor(joinir): make jump_args layout explicit (Phase 256)
2025-12-20 13:04:24 +09:00
1028bd419c
fix(joinir): stabilize Phase 256 merge (jump_args, DCE, func names)
2025-12-20 11:01:48 +09:00
2c4268b691
wip(joinir): Phase 256 P1.10 - classify_tail_call continuation support
...
## 修正内容
- classify_tail_call に is_target_continuation パラメータ追加
- k_exit 呼び出しを ExitJump として分類(BackEdge に誤分類されるのを防止)
- entry_func_name の決定ロジックを修正(loop_step を正しく識別)
- Continuation param bindings の Copy 生成ロジック追加
## 残存問題
bb8/bb9 の instructions が 0 になる問題
- add_block 時は 4 instructions ある
- printer 時は instructions=0, spans=4
- 原因調査中
🔍 WIP - ChatGPT レビュー用
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-20 10:25:13 +09:00
077657b7a1
feat(joinir): Phase 256 P1.5-P1.7 contracts and naming SSOT
2025-12-20 06:38:21 +09:00
bfd324d7b9
feat(joinir): Phase 256 P1.5 - JoinInst::Select 命令サポート(根治)
...
## 変更内容
Task 1(既完了): boundary パラメータを bridge 経路全体に伝播
- conversion_pipeline.rs, bridge.rs(複数箇所), meta.rs, routing_legacy_binding.rs, execute_box.rs
Task 2-A~2-D: Select 命令の実装
- 2-A: MirInstruction::Select バリアント追加
- 2-B: JoinIR Select → MIR Select 直接変換(branch+phi展開廃止)
- 2-C: ⭐ joinir_id_remapper に Select remap case(ValueId変換の根治)
- 2-D: value_collector に Select case
## 根本原因解決
Pattern7 の JoinInst::Select が JoinIR→MIR で未対応
→ ValueId(1002) → ValueId(57) のリマップが行われず
→ "use of undefined value ValueId(57)" エラー
## 現在地
✅ cargo check: 0 errors
⏳ Pattern7/6 VM test(Task 2-E LLVM実装後)
🧠 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-20 03:11:58 +09:00
64f679354a
fix(joinir): Phase 256 P1 - Carrier PHI wiring and parameter mapping (in progress)
...
**Status**: Core carrier PHI issue partially resolved, debugging loop body
**Progress**:
✅ Task 1: split_scan_minimal.rs Carriers-First ordering (6 locations)
✅ Task 2: pattern7_split_scan.rs boundary configuration (host/join inputs, exit_bindings, expr_result)
✅ Result now flows from k_exit to post-loop code (RC issue resolved)
⚠️ Loop body instruction execution needs review
**Key Fixes**:
1. Fixed host_inputs/join_inputs to match main() params Carriers-First order
2. Added result to exit_bindings (CarrierRole::LoopState)
3. Added result back to loop_invariants for variable initialization
4. Added expr_result=join_exit_value_result for loop expression return
5. Fixed jump args to k_exit to include all 4 params [i, start, result, s]
**Current Issue**:
- Loop body type errors resolved (String vs Integer fixed)
- New issue: Loop body computations (sep_len) undefined in certain blocks
- Likely cause: JoinIR→MIR conversion of local variables needs review
**Next Steps**:
- Review JoinValueSpace allocation and ValueId mapping in conversion
- Verify loop_step instruction ordering and block structure
- May need to refactor bound computation or revisit split algorithm
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-20 01:24:04 +09:00
575a5d750f
refactor(joinir): Phase 255 P2 - loop_invariants + var() unification + Phase 256 prep
...
## Task A: Loop Invariants Architecture (Option A - Boundary Extension)
Introduced explicit loop_invariants concept for variables that are:
- Used in loop body but never modified (e.g., substring needle in index_of)
- Need header PHI (all iterations use same value)
- Do NOT need exit PHI (not a LoopState)
Implementation:
- Added `loop_invariants: Vec<(String, ValueId)>` field to JoinInlineBoundary
- Added `with_loop_invariants()` method to JoinInlineBoundaryBuilder
- Modified Pattern 6 to use loop_invariants instead of ConditionOnly misuse
* s (haystack) and ch (needle) now properly classified
* exit_bindings simplified to only LoopState carriers
- Extended LoopHeaderPhiBuilder to generate invariant PHIs
* Entry PHI: from host
* Latch PHI: self-reference (same value every iteration)
- Updated instruction_rewriter to handle invariant latch incoming
Files Modified:
- src/mir/join_ir/lowering/inline_boundary.rs (structure + builder)
- src/mir/join_ir/lowering/inline_boundary_builder.rs (builder method)
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/builder/control_flow/joinir/merge/loop_header_phi_builder.rs
- src/mir/builder/control_flow/joinir/merge/mod.rs
- src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs
## Task B: Code Quality - var() Helper Unification
Created common module to eliminate var() duplication:
- New module: src/mir/builder/control_flow/joinir/patterns/common/
- Centralized var() helper in ast_helpers.rs
- Updated Pattern 6 and Pattern 2 to use common var()
- Test code (5 occurrences) deferred to Phase 256+ per 80/20 rule
Result: Eliminated 2 duplicate var() functions, 5 test occurrences remain
Files Created:
- src/mir/builder/control_flow/joinir/patterns/common/ast_helpers.rs
- src/mir/builder/control_flow/joinir/patterns/common/mod.rs
Files Modified:
- src/mir/builder/control_flow/joinir/patterns/mod.rs
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/builder/control_flow/joinir/patterns/policies/balanced_depth_scan_policy.rs
## Task C: Documentation - PostLoopEarlyReturnPlan Usage Examples
Enhanced post_loop_early_return_plan.rs with:
- Architecture explanation (exit PHI usage prevents DCE)
- Pattern 2 example (Less: balanced_depth_scan)
- Pattern 6 example (NotEqual: index_of)
- Builder defer decision: when 4+ patterns emerge, add builder
Files Modified:
- src/mir/builder/control_flow/joinir/patterns/policies/post_loop_early_return_plan.rs
## Task D: Phase 256 Preparation
Analyzed next failure from smoke tests:
- `StringUtils.split/2` with variable-step loop
- Not constant step (i += len or similar)
- Three implementation options identified
Created Phase 256 README with:
- Minimal reproduction code
- Root cause analysis
- Implementation options with trade-offs
- Clear next steps
Files Created:
- docs/development/current/main/phases/phase-256/README.md
## Verification Results
✅ All tests passing:
- pattern254_p0_index_of_vm.sh: PASS
- No regression in Pattern 1-5
- Smoke test progresses past json_lint_vm to next failure
✅ Architecture achievements:
- Semantic clarity: loop_invariants vs exit_bindings properly separated
- ConditionOnly misuse eliminated
- PHI generation correct for all carrier types
- Code quality: var() duplication reduced
- Next phase clearly defined
## Summary
Phase 255 P2 achieves root-cause fix for multi-param loop support:
- Boundary concept expanded (loop_invariants field)
- Pattern 6 architecture corrected (no ConditionOnly misuse)
- Code quality improved (var() centralized)
- Next pattern (variable-step) is now the challenge
✨ Box-first principles maintained: clean separation, explicit roles, minimal coupling
🧠 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-19 23:48:49 +09:00
2d9c6ea3c6
feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix
...
## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering
Pattern 6 detects index_of/find/contains-style loops:
- Loop condition: i < x.length()
- Loop body: if with method call condition + early return
- Step: i = i + 1
- Post-loop: return not-found value (-1)
Key features:
- Minimal lowering: main/loop_step/k_exit functions
- substring hoisted to init-time BoxCall
- Two k_exit jumps (found: i, not found: -1)
- Tests: phase254_p0_index_of_min.hako
## Phase 255 P0: Multi-param Loop CarrierInfo
Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i):
- i: LoopState (header PHI + exit PHI)
- s, ch: ConditionOnly (header PHI only)
- Alphabetical ordering for determinism
- All 3 PHI nodes created correctly
- Eliminates "undefined ValueId" errors
## Phase 255 P1: Exit PHI DCE Fix
Prevents exit PHI from being deleted by DCE:
- PostLoopEarlyReturnStepBox emits post-loop guard
- if (i != -1) { return i } forces exit PHI usage
- Proven pattern from Pattern 2 (balanced_depth_scan)
- VM/LLVM backends working
## Test Results
✅ pattern254_p0_index_of_vm.sh: PASS (exit code 1)
✅ pattern254_p0_index_of_llvm_exe.sh: PASS (mock)
✅ Quick profile: json_lint_vm PASS (progresses past index_of)
✅ Pattern 1-5: No regressions
## Files Added
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/join_ir/lowering/scan_with_init_minimal.rs
- apps/tests/phase254_p0_index_of_min.hako
- docs/development/current/main/phases/phase-254/README.md
- docs/development/current/main/phases/phase-255/README.md
🧠 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-19 23:32:25 +09:00
6a3b6deb20
feat(anf): Phase 145 P0/P1/P2 - ANF (A-Normal Form) transformation
...
Implement ANF transformation for impure expressions to fix evaluation order:
Phase 145 P0 (Skeleton):
- Add anf/ module with contract/plan/execute 3-layer separation
- AnfDiagnosticTag, AnfOutOfScopeReason, AnfPlan enums
- Stub execute_box (always returns Ok(None))
- 11 unit tests pass
Phase 145 P1 (Minimal success):
- String.length() whitelist implementation
- BinaryOp + MethodCall pattern: x + s.length() → t = s.length(); result = x + t
- Exit code 12 verification (VM + LLVM EXE)
- 17 unit tests pass
Phase 145 P2 (Generalization):
- Recursive ANF for compound expressions
- Left-to-right, depth-first evaluation order
- Patterns: x + s.length() + z, s1.length() + s2.length()
- ANF strict mode (HAKO_ANF_STRICT=1)
- Diagnostic tags (joinir/anf/*)
- 21 unit tests pass, 0 regression
Also includes Phase 143 P2 (else symmetry) completion.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 16:19:49 +09:00
845ae70cb7
chore: Remove unused imports in normalized_shadow modules
...
Cleaned up unused imports after Phase 143 execution fix (5e662eaaf ).
**Priority files (Phase 143)**:
- if_as_last_join_k.rs: removed ValueId, BTreeMap
- loop_true_break_once.rs: added #[cfg(test)] for test-only imports
- post_if_post_k.rs: removed ValueId, BTreeMap
- normalized_helpers.rs: added #[cfg(test)] for Span
**Additional cleanup**:
- contract_checks.rs: removed BasicBlockId
- joinir/mod.rs: removed Info struct re-exports (functions kept)
- patterns/mod.rs: removed Info struct re-exports (functions kept)
- ast_feature_extractor.rs: removed EscapeSkipPatternInfo
- plan_box.rs: added #[cfg(test)] for PlanKind
**Verification**:
- 0 unused import warnings (was 20+)
- All 69 normalized_shadow tests pass
- Clean build with --release
Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 08:36:45 +09:00
5e662eaaf6
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 >
2025-12-19 08:23:20 +09:00
4082abb30c
feat(normalization): Phase 142 P0 - Loop statement-level normalization
...
Phase 142-loopstmt P0: Statement-level normalization
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-19 05:28:49 +09:00
275fe45ba4
feat(normalization): Phase 142 P0 - Statement-level normalization
...
## Summary
Changed normalization unit from "block suffix" to "statement (loop only)"
to prevent pattern explosion.
## Changes
1. **PlanBox** (`plan_box.rs`):
- Always return `loop_only()` for any `loop(true)`, regardless of what follows
- Subsequent statements (return, assignments) handled by normal MIR lowering
- ~70 lines reduced, 7 unit tests updated
2. **build_block** (`stmts.rs`):
- Removed `break` after consumed=1 from suffix_router
- Continue processing subsequent statements normally
- Phase 142 P0 comments added
3. **Tests**:
- Fixture: `phase142_loop_stmt_only_then_return_length_min.hako`
- VM smoke: exit code 3 (s="abc" → s.length() → 3)
## Results
- ✅ Unit tests: 10/10 passed
- ✅ Phase 142 VM smoke: PASS
- ✅ Phase 131 regression: PASS
- ✅ Build: Success
## Design
- **Pattern Explosion Prevention**: Normalize only the loop (consumed=1)
- **Out-of-Scope Policy**: Always Ok(None) for fallback
- **Fail-Fast**: Only for "in-scope but broken" cases
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 04:41:01 +09:00
3ef929df53
docs(normalization): Update README for Phase 142 P0
...
- Document statement-level normalization unit change
- Add Phase 142 P0 section to Pattern Detection
- Mark Phase 132-135 patterns as LEGACY
- Update suffix_router description
- Clarify LoopWithPost deprecation status
Phase 142 P0: Normalization unit changed from "block suffix" to "statement"
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 04:40:35 +09:00
aaba27d311
refactor(normalization): Deprecate LoopWithPost variant
...
- Mark LoopWithPost enum variant as deprecated (Phase 142 P0)
- Add deprecation to loop_with_post() constructor function
- Document migration path to LoopOnly
- Keep for backward compatibility until full migration
Phase 142 P0: Statement-level normalization makes LoopWithPost obsolete
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 04:39:25 +09:00
21a3c6b5d4
docs(normalization): Update suffix_router comments for Phase 142 P0
...
- Reflect that post statements are no longer required
- Document LoopOnly pattern acceptance
- Update responsibility description
Phase 142 P0: Normalization unit changed to "statement (loop only)"
2025-12-19 04:31:45 +09:00
1742f0412e
feat(normalized): Phase 141 P1.5 - external env inputs + KnownIntrinsic SSOT
...
## Task B: External env input bug fix (Priority 1)
Fix: Suffix normalization couldn't access prefix-built local variables
**Problem**: `s.length()` failed because 's' (from prefix `s = "abc"`) was
not in available_inputs during suffix normalization.
**Root cause**: `AvailableInputsCollectorBox::collect()` only collected
function params and CapturedEnv, missing `builder.variable_map`.
**Solution**: Add `prefix_variables` parameter with 3-source merge:
1. Function params (highest priority)
2. Prefix variables (medium priority - NEW)
3. CapturedEnv (lowest priority)
**Changed files**:
- src/mir/control_tree/normalized_shadow/available_inputs_collector.rs
- src/mir/builder/control_flow/normalization/execute_box.rs
- src/mir/builder/control_flow/joinir/patterns/policies/normalized_shadow_suffix_router_box.rs
- src/mir/builder/control_flow/joinir/routing.rs
- src/mir/builder/stmts.rs
- src/mir/control_tree/normalized_shadow/dev_pipeline.rs
- docs/development/current/main/design/normalized-expr-lowering.md (Available Inputs SSOT section)
**Tests**: 3 new unit tests (prefix merge, priority order)
## Task A: KnownIntrinsic SSOT化 (Priority 2)
Eliminate string literal scattered matching by centralizing to registry.
**Problem**: Adding new intrinsics required editing if/match chains with
hard-coded string literals (`if method == KnownIntrinsic::Length0.method_name()`).
**Solution**: Create `KnownIntrinsicRegistryBox` as SSOT:
- `lookup(method, arity) -> Option<KnownIntrinsic>`
- `get_spec(intrinsic) -> KnownIntrinsicSpec`
- Adding new intrinsics now requires: (1) enum variant, (2) registry entry only
**Changed files**:
- src/mir/control_tree/normalized_shadow/common/known_intrinsics.rs (NEW)
- src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs
- src/mir/control_tree/normalized_shadow/common/expr_lowering_contract.rs (deprecated methods removed)
- src/mir/control_tree/normalized_shadow/common/mod.rs
- docs/development/current/main/design/normalized-expr-lowering.md (Known Intrinsic SSOT section)
**Impact**: ~30% code reduction in intrinsic matching logic
## Task C: Better diagnostics (Priority 3)
Add `OutOfScopeReason::IntrinsicNotWhitelisted` for precise diagnostics.
**Changed files**:
- src/mir/control_tree/normalized_shadow/common/expr_lowering_contract.rs (enum variant)
- src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (diagnostic logic)
## Verification
✅ Build: `cargo build --release` - PASS
✅ Phase 97 regression: next_non_ws LLVM EXE - PASS
✅ Phase 131: loop(true) break-once VM - PASS
✅ Phase 136: return literal VM - PASS
✅ Phase 137: return x+2 VM - PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 03:59:41 +09:00
1264b3593d
fix(normalization): Tighten loop(true) gate to prevent loop(i<n) mismatch
...
Problem:
- Phase 97 LLVM EXE tests (next_non_ws, json_loader_escape) were failing
- NormalizationPlan accepted loop(i < n) but couldn't lower it
- Execute stage returned hard error instead of fallback
Root Cause:
- Plan stage only checked `ASTNode::Loop`, not condition
- loop(i < n) got Plan → Execute tried to normalize → error
- Should: loop(i < n) returns Ok(None) → fallback to Pattern2
Fix:
- Tighten gate in plan_box.rs (lines 50-71)
- Only accept loop(true) - literal Bool true
- loop(i < n) now returns Ok(None) → clean fallback
Added:
- Test: test_plan_block_suffix_no_match_loop_not_true()
- Verifies loop(i < n) returns None (not Plan)
Verification:
- Phase 97 next_non_ws LLVM EXE: PASS
- Phase 97 json_loader_escape LLVM EXE: PASS
- Phase 131/135/136/137 regression: all PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 00:15:51 +09:00
91c7dfbf0b
refactor(normalization): Phase 135 P0 - Extend plan to zero post-loop assigns
...
Generalize NormalizationPlan suffix detection to accept zero post-loop assignments:
Goal: Improve entry point consistency by allowing `loop + assign* + return` (N >= 0)
Implementation:
- Modified plan_box.rs detection logic (only file changed)
- Removed `post_assign_count >= 1` requirement
- Unified Phase 131 (loop + return) and Phase 132-133 (loop + assign+ + return) paths
Changes:
- src/mir/builder/control_flow/normalization/plan_box.rs:
- Removed assignment count constraint
- Unified pattern detection: `loop + assign* + return` (N >= 0)
- apps/tests/phase135_loop_true_break_once_post_empty_return_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase135_*.sh (new smoke tests)
Pattern support:
- Phase 131/135: loop + return only (consumed: 2, post_assign_count: 0) ✅
- Phase 132: loop + 1 assign + return (consumed: 3, post_assign_count: 1) ✅
- Phase 133: loop + N assigns + return (consumed: 2+N, post_assign_count: N) ✅
Design principles maintained:
- **Minimal change**: Only plan_box.rs modified (execute_box unchanged)
- **SSOT**: Detection logic centralized in plan_box.rs
- **Box-First**: Responsibility separation preserved (Plan/Execute)
Test results:
- Unit tests (plan_box): 9/9 PASS (2 new tests added)
- Phase 135 VM/LLVM EXE: PASS (exit code 1)
- Phase 131 regression: 2/2 PASS (path now unified)
- Phase 133 regression: 2/2 PASS
- cargo test --lib: PASS
Benefits:
- Unified entry point for all loop + post patterns
- Easier maintenance (single detection logic)
- Future extensibility (easy to add new patterns)
- Clear separation of Phase 131 and Phase 132-135 paths
Default behavior unchanged: Dev-only guard maintained
Related: Phase 135 normalization pattern consistency improvement
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 22:46:32 +09:00
f4ab5ca5f4
refactor(control_flow): Phase 134 P0 - Normalization entry point SSOT
...
Consolidate dual entry points into unified NormalizationPlan system:
Problem:
- Dual entry points: try_normalized_shadow() + suffix_router_box
- ~220 lines of duplicated pattern detection logic
- Maintenance burden: changes required in two places
Solution:
- New normalization module with Box-First architecture
- NormalizationPlanBox: Single source of truth for pattern detection
- NormalizationExecuteBox: Single source of truth for execution
Implementation:
- src/mir/builder/control_flow/normalization/ (new module)
- README.md: Design contract (SSOT)
- plan.rs: NormalizationPlan data structure
- plan_box.rs: Pattern detection (7 unit tests)
- execute_box.rs: Execution logic
- mod.rs: Module integration
Refactored files:
- routing.rs::try_normalized_shadow(): 165 → 87 lines (-78 lines)
- suffix_router_box::try_lower_loop_suffix(): 258 → 116 lines (-142 lines)
Pattern support maintained:
- Phase 131: loop(true) only (consumed: 1)
- Phase 132: loop + single post (consumed: 3)
- Phase 133: loop + multiple post (consumed: 2+N)
Box-First principles:
- Plan Box: Detection responsibility only
- Execute Box: Execution responsibility only
- README.md: Contract documentation (SSOT)
- Clear separation enables independent testing
Test results:
- cargo test --lib: 1186 PASS (10 new tests added)
- Phase 133 VM/LLVM EXE: PASS (exit code 6)
- Phase 132 LLVM EXE: PASS (exit code 3)
- Phase 131 LLVM EXE: PASS (exit code 1)
Benefits:
- Code duplication eliminated (~220 lines)
- Single source of truth for normalization decisions
- Improved maintainability and testability
- Future-proof extensibility (easy to add new patterns)
Default behavior unchanged: Dev-only guard maintained
Related: Phase 134 normalization infrastructure improvement
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 22:29:29 +09:00
d5a36cf818
refactor(joinir): Phase 132-R0 - Continuation SSOT + legacy isolation
...
**Task 1: Continuation SSOT 一本化** ✅
- Add JoinInlineBoundary::default_continuations()
- Replace all BTreeSet::from([JoinFuncId::new(2)]) hardcoding (7 locations)
- Single source of truth for continuation function IDs
**Task 2: merge 契約 docs SSOT 化** ✅
- New: src/mir/builder/control_flow/joinir/merge/README.md
- Document continuation contracts, skip conditions, forbidden behaviors
- Prohibit by-name/by-id classification
**Task 3: テスト配置正規化** ✅
- New: src/mir/builder/control_flow/joinir/merge/tests/continuation_contract.rs
- Move tests from instruction_rewriter.rs to dedicated test file
- Add 4 test cases (Case A-D)
**Task 4: legacy 導線隔離** ✅
- New: src/mir/builder/control_flow/joinir/legacy/
- Move routing_legacy_binding.rs → legacy/routing_legacy_binding.rs
- Add legacy/README.md with removal conditions
- No cfg(feature="legacy") (docs-only isolation for now)
**Task 5: ノイズ除去** ✅
- Remove unused imports (ConstValue, MirInstruction)
- Clean warnings in touched files
Changes:
- src/mir/join_ir/lowering/inline_boundary.rs: +default_continuations()
- src/mir/builder/control_flow/joinir/merge/README.md: +140 lines
- src/mir/builder/control_flow/joinir/merge/tests/: +180 lines
- src/mir/builder/control_flow/joinir/legacy/: +3 files
Test results:
- cargo test --lib: 1176 PASS
- All Phase 131/132/97 smokes: PASS
Benefits:
- Continuation definition centralized (SSOT)
- Merge contracts documented and tested
- Legacy code path clearly isolated
- Code quality improved (warnings reduced)
Related: Phase 132 infrastructure improvements
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 21:52:21 +09:00
149e30cae5
fix(joinir): Phase 132 P1 - k_exit continuation classification fix
...
Problem: k_exit with TailCall(post_k) was classified as skippable continuation,
causing post_k block to become unreachable.
Root cause:
- Continuation classification was name-based ("join_func_2")
- Skippable continuation check didn't examine function body
- k_exit with tail call to post_k had its block skipped during merge
Solution:
- Check function body structure before classifying as skippable
- Non-skippable pattern: continuation with TailCall to another function
- Properly emit tail call as Jump instruction
Changes:
- src/mir/builder/control_flow/joinir/merge/mod.rs:
- Add structural check in is_skippable_continuation()
- Detect TailCall(other_func) pattern
- Skip only if function is truly empty (1 block, Return only)
- src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs:
- Improve k_exit continuation handling
- Properly rewrite TailCall → Jump for post_k
Test results:
- Phase 132 LLVM EXE: PASS (exit code 3)
- Phase 132 VM: PASS
- Phase 131 regression: PASS
- Phase 97 regression: PASS
Related: Phase 132 loop(true) + post-loop VM/LLVM parity
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 21:51:52 +09:00
b5d8ace6ab
feat(control_tree): Phase 132 P0 + P0.5 - loop(true) + post-loop support
...
**Phase 132 P0**: Extend loop(true) break-once to support post-loop statements
Goal: Support `loop(true) { x = 1; break }; x = x + 2; return x` → exit code 3
Implementation:
- loop_true_break_once.rs: Add post_k continuation generation
- Reuse Phase 130's lower_assign_stmt for post statements
- ExitMeta uses DirectValue mode (PHI-free)
**Phase 132 P0.5**: Fix StepTree post-loop statement visibility
Root cause: routing.rs created StepTree from Loop node only, losing post statements
Solution:
- New: normalized_shadow_suffix_router_box.rs
- Detects block suffix: Loop + Assign* + Return
- Creates StepTree from entire suffix (Block([Loop, Assign, Return]))
- Modified build_block() to call suffix router (dev-only)
Changes:
- apps/tests/phase132_loop_true_break_once_post_add_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase132_loop_true_break_once_post_add_*.sh
- src/mir/control_tree/normalized_shadow/loop_true_break_once.rs (+150 lines)
- src/mir/builder/control_flow/joinir/patterns/policies/normalized_shadow_suffix_router_box.rs (+380 lines)
- src/mir/builder/stmts.rs (build_block modified to support suffix skipping)
Design principles:
- StepTree unchanged: Block is SSOT for statement order
- No data duplication: Loop doesn't hold post_nodes
- Suffix router handles detection + conversion
- build_block() handles wiring only
Test results:
- Phase 132 VM: PASS (exit code 3)
- Phase 131 regression: PASS
- Phase 97 regression: PASS
Related: Phase 132 loop(true) + post-loop minimal support
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 21:51:33 +09:00
d6225a88d0
refactor(joinir): Task 6 & 7 - MergeConfig unification + contract_checks tests
...
Task 6: MergeConfig 一構造体化
- Consolidate dispersed parameters (dev_log, strict_mode, exit_reconnect_mode)
- Reduce function argument clutter in merge/mod.rs
- Single source of truth for merge configuration
- Added MergeConfig struct with factory methods (default, strict, with_debug)
Task 7: contract_checks 単体テスト追加
- Add 4 test cases for verify_all_terminator_targets_exist
- Test coverage: all_present, missing_allowed, missing_disallowed, MergeContracts creation
- Validate fail-fast behavior with freeze_with_hint
- Enable regression detection during future refactoring
Changes:
- src/mir/builder/control_flow/joinir/merge/mod.rs (+54 -6 lines)
- src/mir/builder/control_flow/joinir/merge/contract_checks.rs (+116 lines)
Test Results:
- New tests: 4 PASS
- Regression tests: 1162 PASS
- No breaking changes
Related: Phase 131 refactoring to improve code organization and maintainability
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-18 18:28:24 +09:00
02c4c313e5
feat(control_tree): Phase 131 P1.5-P2 DirectValue exit reconnection
...
Implement DirectValue mode for Normalized shadow exit handling:
**P1.5 Changes**:
- Add ExitReconnectMode::DirectValue (skip exit PHI generation)
- Carry remapped_exit_values through merge result
- Update host variable_map directly with exit values
- Fix loop(true) { x = 1; break }; return x to return 1 correctly
**P2 Changes**:
- Normalize k_exit continuation entry/exit edges
- Rewrite TailCall(k_exit) → Jump(exit_block) for proper merge
- Add verify_all_terminator_targets_exist contract check
- Extend ExitLineReconnector to handle DirectValue mode
**Infrastructure**:
- tools/build_llvm.sh: Force TMPDIR under target/ (EXDEV mitigation)
- llvm_exe_runner.sh: Add exit_code verification support
- Phase 131 smokes: Update for dev-only + exit code validation
**Contracts**:
- PHI-free: Normalized path uses continuations only
- Exit values reconnect via remapped ValueIds
- Existing patterns unaffected (既定挙動不変)
Related: Phase 131 loop(true) break-once Normalized support
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 17:48:05 +09:00
df23a52916
refactor(control_tree): modularize normalized_shadow dev pipeline
2025-12-18 08:14:49 +09:00
e0cbeb9aa0
feat(control_tree): Phase 129-B join_k as-last lowering
2025-12-18 07:53:27 +09:00
72f2c1f64d
feat(joinir/dev): Phase 126 wire available_inputs into normalized builder
...
- AvailableInputsCollectorBox::collect() called in lower_function_body (dev-only)
- try_lower_if_only() signature extended (accepts available_inputs)
- EnvLayout::from_contract() now uses real available_inputs (not empty stub)
- Unit tests updated (empty BTreeMap for backward compat)
- All 23 normalized_shadow tests PASS
2025-12-18 06:45:23 +09:00
cc1a0946b0
feat(joinir/dev): build Normalized if-only module with structure verification (no behavior change)
...
Phase 122 P2-P3: Dev-only wiring + structure verification
- Wire Phase 122 emission into existing Phase 121 dev path
- Add verify_normalized_structure() for module validation
- Check: phase, function count, entry point, env args count
- Strict mode: fail-fast on structure mismatch
- No behavior change to existing execution path
2025-12-18 04:52:09 +09:00
89b868703f
feat(joinir/dev): wire Phase 121 StepTree shadow lowering (strict fail-fast)
2025-12-18 04:34:43 +09:00