refactor(phi): Phase 57 PHI code reduction
## Changes ### 57-2-alt: Remove redundant ConservativeMerge call - phi.rs called ConservativeMerge::analyze twice (once directly, once via merge_all_vars) - Now merge_all_vars returns changed_vars, eliminating redundancy ### 57-3: Delete PhiMergeOps trait (dead code, 17 lines) - PhiMergeOps trait was defined but never called - Only impl in loop_builder.rs was unused - PhiBuilderOps has replaced it ### 57-4: Add responsibility comments to infer_type_from_phi - Document that it's the "last resort" for type inference - Specify deletion conditions (JoinIR type annotations) ## Cumulative PHI reduction - Phase 38: 90 lines - Phase 40-4.1: 35 lines - Phase 41-1: 99 lines - Phase 47: 33 lines - Phase 57: 17 lines (PhiMergeOps) + optimization - Total: 365+ lines removed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -155,14 +155,19 @@ impl<'a> PhiMergeHelper<'a> {
|
||||
/// * `skip_var` - Optional variable name to skip (already merged elsewhere)
|
||||
///
|
||||
/// # Returns
|
||||
/// Ok(()) on success, Err(String) on failure
|
||||
/// Ok(changed_vars) - Set of variables that were changed, for pin handling
|
||||
///
|
||||
/// # Phase 57 改善
|
||||
///
|
||||
/// 戻り値を `()` から `HashSet<String>` に変更。
|
||||
/// これにより `phi.rs` での冗長な `ConservativeMerge::analyze` 呼び出しを削除可能に。
|
||||
pub fn merge_all_vars(
|
||||
&mut self,
|
||||
pre_if_snapshot: &BTreeMap<String, ValueId>, // Phase 25.1: BTreeMap化
|
||||
then_map_end: &BTreeMap<String, ValueId>, // Phase 25.1: BTreeMap化
|
||||
else_map_end_opt: &Option<BTreeMap<String, ValueId>>, // Phase 25.1: BTreeMap化
|
||||
skip_var: Option<&str>,
|
||||
) -> Result<(), String> {
|
||||
) -> Result<std::collections::HashSet<String>, String> {
|
||||
// Use Conservative strategy from conservative module
|
||||
let conservative = crate::mir::phi_core::conservative::ConservativeMerge::analyze(
|
||||
pre_if_snapshot,
|
||||
@ -232,6 +237,7 @@ impl<'a> PhiMergeHelper<'a> {
|
||||
self.merge_variable(name.clone(), then_v, else_v)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
// Phase 57: 変更された変数セットを返す(phi.rsでの冗長呼び出し削除用)
|
||||
Ok(conservative.changed_vars)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user