feat(joinir): Phase 224-cont - Promoted variable tracking for lowerer

- Add promoted_loopbodylocals field to CarrierInfo
- Record promoted variables in Pattern2 promotion handler
- Filter promoted variables in lowerer LoopBodyLocal check
- digit_pos → is_digit_pos promotion now continues to lowering

Closes Phase 224 lowerer integration gap.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-10 16:30:53 +09:00
parent 00d1ec7cc5
commit 4cddca1cae
5 changed files with 49 additions and 1 deletions

View File

@ -308,6 +308,9 @@ impl MirBuilder {
promoted_var, carrier_name
);
// Phase 224: Record promoted variable before merging
carrier_info.promoted_loopbodylocals.push(promoted_var.clone());
// Merge promoted carrier into existing CarrierInfo
carrier_info.merge_from(&promoted_carrier);
@ -316,6 +319,10 @@ impl MirBuilder {
carrier_name,
carrier_info.carrier_count()
);
eprintln!(
"[pattern2/cond_promoter] Phase 224: Recorded promoted variable '{}' in carrier_info.promoted_loopbodylocals",
promoted_var
);
// Check if this is a safe Trim pattern
if let Some(helper) = carrier_info.trim_helper() {

View File

@ -72,6 +72,7 @@ impl Pattern4CarrierAnalyzer {
loop_var_id: all_carriers.loop_var_id,
carriers: updated_carriers,
trim_helper: all_carriers.trim_helper.clone(),
promoted_loopbodylocals: all_carriers.promoted_loopbodylocals.clone(), // Phase 224
})
}
@ -287,6 +288,7 @@ mod tests {
},
],
trim_helper: None,
promoted_loopbodylocals: Vec::new(), // Phase 224
};
// Analyze carriers

View File

@ -404,6 +404,7 @@ mod tests {
},
],
trim_helper: None,
promoted_loopbodylocals: Vec::new(), // Phase 224
},
loop_scope: LoopScopeShapeBuilder::empty_body_locals(
BasicBlockId(0),
@ -442,6 +443,7 @@ mod tests {
carrier_name: "is_whitespace".to_string(),
whitespace_chars: vec![" ".to_string(), "\t".to_string()],
}),
promoted_loopbodylocals: Vec::new(), // Phase 224
},
loop_scope: LoopScopeShapeBuilder::empty_body_locals(
BasicBlockId(0),