refactor(mir): Phase 7-G完了 - レガシーヘルパー Phase 2A削除(40行削減)

**削除内容**(孤立関数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 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-18 20:35:47 +09:00
parent fa2ca75ecc
commit 71653a4af5

View File

@ -468,39 +468,8 @@ impl<'a> LoopBuilder<'a> {
} }
/// ブロックをシールし、不完全なPhi nodeを完成させる /// ブロックをシールし、不完全な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ポイントでの値を統一 /// 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> { fn mark_block_sealed(&mut self, block_id: BasicBlockId) -> Result<(), String> {
if let Some(ref mut function) = self.parent_builder.current_function { 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() self.parent_builder.variable_map.get(name).copied()
} }
fn build_expression_with_phis(&mut self, expr: ASTNode) -> Result<ValueId, String> {
// Phi nodeの結果を考慮しながら式を構築
self.parent_builder.build_expression(expr)
}
fn build_statement(&mut self, stmt: ASTNode) -> Result<ValueId, String> { fn build_statement(&mut self, stmt: ASTNode) -> Result<ValueId, String> {
match stmt { match stmt {