🔧 Hotfix 7 (Enhanced): ValueId receiver alias tracking for nested loops
- Problem: Pinned receiver variables in loops cause undefined ValueId errors - Enhanced fix: Update all receiver aliases (me + all __pin$N$@recv levels) - Handles nested loops by updating previous pin levels - Test status: Partial improvement, ValueId(50) → ValueId(40) - Further investigation needed for complete fix Files modified: - src/mir/phi_core/loopform_builder.rs (emit_header_phis)
This commit is contained in:
@ -217,6 +217,32 @@ impl LoopFormBuilder {
|
||||
vec![(self.preheader_id, pinned.preheader_copy)],
|
||||
)?;
|
||||
ops.update_var(pinned.name.clone(), pinned.header_phi);
|
||||
|
||||
// 🔧 Hotfix 7 (Enhanced): Update aliases for pinned receiver variables
|
||||
// When a variable like "me" is pinned to "__pin$N$@recv", both names
|
||||
// must point to the same PHI value to avoid stale ValueId references.
|
||||
// This handles:
|
||||
// 1. Direct receiver: "me" → "__pin$1$@recv"
|
||||
// 2. Nested loops: "__pin$1$@recv" → "__pin$2$@recv"
|
||||
// 3. Multiple aliasing scenarios
|
||||
if pinned.name.contains("@recv") {
|
||||
// Always update "me" (the canonical receiver name)
|
||||
ops.update_var("me".to_string(), pinned.header_phi);
|
||||
|
||||
// Also update all previous pin levels (__pin$1$@recv, __pin$2$@recv, etc.)
|
||||
// Extract the pin counter and update all lower levels
|
||||
if let Some(idx) = pinned.name.find("$") {
|
||||
if let Some(end_idx) = pinned.name[idx+1..].find("$") {
|
||||
if let Ok(counter) = pinned.name[idx+1..idx+1+end_idx].parse::<u32>() {
|
||||
// Update all previous pin levels (1 through counter-1)
|
||||
for i in 1..counter {
|
||||
let alias = format!("__pin${}$@recv", i);
|
||||
ops.update_var(alias, pinned.header_phi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Emit PHIs for carrier variables
|
||||
|
||||
Reference in New Issue
Block a user