From 71653a4af5810c893fae6fbcf88196b7ebca1bb6 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Tue, 18 Nov 2025 20:35:47 +0900 Subject: [PATCH] =?UTF-8?q?refactor(mir):=20Phase=207-G=E5=AE=8C=E4=BA=86?= =?UTF-8?q?=20-=20=E3=83=AC=E3=82=AC=E3=82=B7=E3=83=BC=E3=83=98=E3=83=AB?= =?UTF-8?q?=E3=83=91=E3=83=BC=20Phase=202A=E5=89=8A=E9=99=A4=EF=BC=8840?= =?UTF-8?q?=E8=A1=8C=E5=89=8A=E6=B8=9B=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **削除内容**(孤立関数4個): - ✅ seal_block() (14行) - build_loop_legacy削除で孤立 - ✅ create_exit_phis() (17行) - LoopForm v2で置き換わり - ✅ mark_block_unsealed() (5行) - no-op(デフォルトunsealed) - ✅ build_expression_with_phis() (4行) - no-op wrapper **削減効果**: - **削減行数**: 40行(Task先生予測と完全一致) - **削減率**: 3.5%(1136行 → 1096行) - **テスト**: 全グリーン維持 ✅ **技術的成果**: - 呼び出しゼロの孤立関数削除(リスク最小) - LoopForm v2への完全移行を反映 - 保守性向上: 不要なコード削除 **残存警告(Phase 2B対象)**: - 4つの dead_code 警告 - prepare_loop_variables (51行) - find_copy_source (28行) - emit_safepoint (4行) - 保留推奨 - mark_block_sealed (12行) - 保留推奨 **テスト結果(全グリーン維持)**: - ✅ mir_loopform_exit_phi (4 tests) - ✅ mir_stage1_using_resolver (3 tests) - ✅ mir_stageb_loop_break_continue (2 tests) **次の目標**: Phase 2Bで79行削除し、**1000行切り達成**! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/mir/loop_builder.rs | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/mir/loop_builder.rs b/src/mir/loop_builder.rs index 50993817..c3a62f35 100644 --- a/src/mir/loop_builder.rs +++ b/src/mir/loop_builder.rs @@ -468,39 +468,8 @@ impl<'a> LoopBuilder<'a> { } /// ブロックをシールし、不完全なPhi nodeを完成させる - fn seal_block(&mut self, block_id: BasicBlockId, latch_id: BasicBlockId) -> Result<(), String> { - if let Some(incomplete_phis) = self.incomplete_phis.remove(&block_id) { - let cont_snaps = self.continue_snapshots.clone(); - crate::mir::phi_core::loop_phi::seal_incomplete_phis_with( - self, - block_id, - latch_id, - incomplete_phis, - &cont_snaps, - )?; - } - self.mark_block_sealed(block_id)?; - Ok(()) - } /// Exitブロックで変数のPHIを生成(breakポイントでの値を統一) - fn create_exit_phis(&mut self, header_id: BasicBlockId, exit_id: BasicBlockId) -> Result<(), String> { - // Use the saved header block snapshot instead of current variable map - // The current block at this point is the exit block, not the header, - // so we must retrieve the header's snapshot from block_var_maps. - let header_vars = self.block_var_maps - .get(&header_id) - .cloned() - .unwrap_or_else(|| self.get_current_variable_map()); - let exit_snaps = self.exit_snapshots.clone(); - crate::mir::phi_core::loop_phi::build_exit_phis_with( - self, - header_id, - exit_id, - &header_vars, - &exit_snaps, - ) - } // --- ヘルパーメソッド(親ビルダーへの委譲) --- @@ -655,11 +624,6 @@ impl<'a> LoopBuilder<'a> { } } - fn mark_block_unsealed(&mut self, _block_id: BasicBlockId) -> Result<(), String> { - // ブロックはデフォルトでunsealedなので、特に何もしない - // (既にBasicBlock::newでsealed: falseに初期化されている) - Ok(()) - } fn mark_block_sealed(&mut self, block_id: BasicBlockId) -> Result<(), String> { if let Some(ref mut function) = self.parent_builder.current_function { @@ -702,10 +666,6 @@ impl<'a> LoopBuilder<'a> { self.parent_builder.variable_map.get(name).copied() } - fn build_expression_with_phis(&mut self, expr: ASTNode) -> Result { - // Phi nodeの結果を考慮しながら式を構築 - self.parent_builder.build_expression(expr) - } fn build_statement(&mut self, stmt: ASTNode) -> Result { match stmt {