|
|
2db8ff72d0
|
refactor(mir): Remove CoreContext legacy fields (Phase 2-2/7)
完全移行→削除の安全順序(Option C)に従い、CoreContext の
deprecated フィールドと sync helpers を完全削除。
## Changes
- Migrated all access sites to core_ctx.* (SSOT allocators)
- utils.rs: value_gen (3 sites), block_gen (1 site), temp_slot_counter (1 site)
- loop_api.rs: block_gen (1 site)
- phi_helpers.rs: value_gen (1 site)
- builder.rs: sync helpers (2 methods), test assertions (2 sites)
- Removed 5 deprecated fields from builder.rs
- value_gen: ValueIdGenerator
- block_gen: BasicBlockIdGenerator
- next_binding_id: u32
- temp_slot_counter: u32
- debug_join_counter: u32
- Removed sync helper calls (allocate_binding_id, debug_next_join_id)
- Removed field initializations from MirBuilder::new()
- Maintained Phase 136 P0 SSOT structure (next_value_id() remains as high-level API)
## Tests
- cargo build --release: PASS
- cargo test --release --lib: 1029 passed (4 pre-existing failures)
- Deprecation warnings: 435 → 456 (+21)
Note: Warnings increased due to remaining deprecated field *uses* being exposed
after removing the field *definitions*. This is expected during migration.
## Code metrics
- Net reduction: 40 lines (-56 removed, +16 modifications)
- Files changed: 4 (builder.rs, utils.rs, loop_api.rs, phi_helpers.rs)
Phase 2 Progress: 2/7 contexts complete (MetadataContext ✅, CoreContext ✅)
|
2025-12-15 23:05:36 +09:00 |
|
|
|
a898e99310
|
refactor(mir): Remove MetadataContext legacy fields (Phase 2-1/7)
完全移行→削除の安全順序(Option C)に従い、MetadataContext の
deprecated フィールドと sync helpers を完全削除。
## Changes
- Migrated all access sites to metadata_ctx.* (builder methods)
- current_span → metadata_ctx.current_span() / set_current_span()
- source_file → metadata_ctx.current_source_file() / set_source_file() / clear_source_file()
- hint_sink → metadata_ctx.hint_scope_enter/leave/join_result()
- current_region_stack → metadata_ctx.push_region/pop_region/current_region_stack()
- Removed 4 deprecated fields from MirBuilder
- current_span, source_file, hint_sink, current_region_stack
- Removed 2 sync helpers
- sync_metadata_ctx_to_legacy(), sync_legacy_to_metadata_ctx()
- Updated 10 files with direct field accesses
## Files Modified
- src/mir/builder.rs: -56 lines (fields + sync helpers + initialization)
- src/mir/builder/exprs.rs: metadata_ctx.set_current_span()
- src/mir/builder/exprs_peek.rs: metadata_ctx.current_span()
- src/mir/builder/if_form.rs: metadata_ctx.current_span()
- src/mir/builder/phi.rs: metadata_ctx.current_span()
- src/mir/builder/stmts.rs: metadata_ctx.set_current_span()
- src/mir/builder/utils.rs: metadata_ctx.current_span()
- src/mir/loop_api.rs: metadata_ctx.current_span()
- src/mir/region/observer.rs: metadata_ctx.push/pop_region()
- src/mir/utils/phi_helpers.rs: metadata_ctx.current_span()
## Tests
- cargo build --release: SUCCESS (1m 10s)
- cargo test --release --lib: 1029 PASS, 4 FAIL (pre-existing)
- Deprecation warnings: 469 → 435 (-34 warnings)
## Verification
✅ No direct access to removed fields (grep count: 0)
✅ No sync helper calls (grep count: 0)
✅ Build success
✅ MetadataContext is now complete SSOT (二重管理解消)
Phase 2 Progress: 1/7 contexts complete (MetadataContext ✅)
🎉 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-15 22:44:38 +09:00 |
|
|
|
af6f95cd4b
|
Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
|
2025-12-11 20:54:33 +09:00 |
|
|
|
440f8646b1
|
feat(joinir): Phase 183 LoopBodyLocal role separation + test fixes
Phase 183 Implementation:
- Added is_var_used_in_condition() helper for AST variable detection
- Implemented LoopBodyLocal filtering in TrimLoopLowerer
- Created 4 test files for P1/P2 patterns
- Added 5 unit tests for variable detection
Test Fixes:
- Fixed test_is_outer_scope_variable_pinned (BasicBlockId import)
- Fixed test_pattern2_accepts_loop_param_only (literal node usage)
Refactoring:
- Unified pattern detection documentation
- Consolidated CarrierInfo initialization
- Documented LoopScopeShape construction paths
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-08 23:43:26 +09:00 |
|
|
|
c6edbaaf3a
|
feat(mir): Phase 63-6-1/2 MIR Phi type_hint field & JoinIR propagation
Phase 63-6-1: MirInstruction::Phi に type_hint フィールド追加
- Added `type_hint: Option<MirType>` field to Phi instruction
- Updated 21 files with type_hint initialization (all set to None for legacy paths)
- Pattern matching updated across codebase (11 files)
- Test code updated (basic_block.rs)
Phase 63-6-2: JoinIR→MIR Bridge で型ヒント伝播実装
- Modified convert.rs: Select → MIR now creates PHI with type_hint
- Removed Copy instructions from then/else blocks
- PHI instruction at merge block receives type_hint from JoinIR Select
- Test verification: ✅ Type hint propagation successful (Some(Integer))
Modified files:
- instruction.rs: Added type_hint field definition
- join_ir_vm_bridge/convert.rs: Select lowering with PHI + type_hint
- 19 other files: type_hint field initialization
Test results:
- ✅ test_type_hint_propagation_simple: Type hint = Some(Integer) confirmed
- ✅ 7/8 if_select tests passing (1 race condition, passes individually)
Next: Phase 63-6-3 (lifecycle.rs で型ヒント使用)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-30 04:35:40 +09:00 |
|
|
|
da1a5558e5
|
Normalize passes keep spans and clean warnings
|
2025-11-24 15:02:51 +09:00 |
|
|
|
f9d100ce01
|
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <noreply@openai.com>
Co-Authored-By: Task Assistant <task@anthropic.com>
|
2025-11-21 06:25:17 +09:00 |
|
|
|
cc9fb2f654
|
fix(phi): if-block PHI reassignment のSSA違反を解消
**問題**: If-block PHI nodes がグローバルValueIdアロケーター使用 → 関数ローカルIDと衝突
- insert_phi() が value_gen.next() 使用
- 関数内で後から割り当てられるValueIdと重複 → SSA違反
**根本原因**:
```rust
// ❌ Before: グローバルアロケーター
let phi_val = self.value_gen.next();
// ✅ After: 関数ローカルアロケーター
let phi_val = if let Some(ref mut f) = self.current_function {
f.next_value_id() // 関数コンテキスト
} else {
self.value_gen.next() // モジュールコンテキスト
};
```
**修正内容**:
1. **insert_phi() 修正** (src/mir/utils/phi_helpers.rs:63-70)
- 関数コンテキストでは f.next_value_id() 使用
- pin_to_slot() / loop builder (e2d061d1) と同じパターン
2. **insert_phi_with_dst() ドキュメント強化** (lines 94-114)
- 正しいValueId割り当て方法を例示
- ❌ 間違い: 常に value_gen.next() 使用
- ✅ 正しい: 関数コンテキスト判定
**テスト結果**:
✅ Simple if-param-method: PASS (SSA違反なし)
✅ Test1/Test3: PASS (regression なし)
⚠️ Test2 (Stage-B): ValueId(22) 残存(別問題: receiver materialization)
**残存問題** (別issue):
- ValueId(22) = receiver materialization 問題
- pin_to_slot / emit_guard / BlockScheduleBox が分散
- 責務の集約が必要(次タスク)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-17 06:54:48 +09:00 |
|
|
|
1cc09786ee
|
refactor: unify PHI insertion patterns (Phase 4)
- Add PHI insertion helper utilities in mir/utils/phi_helpers.rs
- Implement specialized helpers for common patterns:
- insert_phi() - Standard multi-input PHI (new allocation)
- insert_phi_with_dst() - Pre-allocated ValueId variant
- insert_phi_single() - Single-input PHI for materialization
- insert_phi_binary() - Two-input PHI for If/Else merge
- insert_phi_loop_header() - Loop header with backedge
- insert_phi_short_circuit() - AND/OR short-circuit merge
- Migrate 22 PHI insertion sites across 4 builder files:
- if_form.rs: 2 sites (-12 lines, 86% reduction)
- ops.rs: 5 sites (-32 lines, 86% reduction)
- phi.rs: 4 sites (-13 lines, 81% reduction)
- exprs_peek.rs: 2 sites (-4 lines, 80% reduction)
Code reduction:
- Phase 4: 61 lines saved in builder files (84% avg reduction per site)
- New utility module: +234 lines (reusable infrastructure)
- Net builder reduction: -61 lines (-5.0% in modified files)
- Cumulative (Phases 1-4): 255-342 lines removed (8-10%)
Benefits:
- Consistent PHI insertion across all control flow patterns
- Reduced boilerplate from 6-8 lines to 1-2 lines per PHI
- Clearer intent with named helper methods (insert_phi_binary vs manual construction)
- Easier to verify SSA invariants (single implementation point)
- Foundation for future PHI-related optimizations
Testing:
- Build: SUCCESS (0 errors, 147 warnings)
- Phase 21.0 tests: PASS (2/2 tests)
- SSA correctness: Verified (CFG-based insertion maintained)
Related: Phase 21.0 refactoring, MIR SSA construction
Risk: Low (wraps existing insert_phi_at_head, fully tested)
|
2025-11-06 23:57:24 +09:00 |
|