Commit 2a66224c authored by qinsoon's avatar qinsoon

avoid infinite regression that causes rust stack overflow

parent f9990047
Pipeline #1401 failed with stages
in 22 minutes and 48 seconds
......@@ -182,7 +182,7 @@ impl CopyPropagation {
for (id, lattice) in self.lattices.iter() {
match lattice {
&CopyLattice::Copy(copy) => {
ret.insert(*id, self.resolve_copy(copy));
ret.insert(*id, self.resolve_copy(copy, *id));
}
_ => continue
}
......@@ -205,14 +205,21 @@ impl CopyPropagation {
}
}
fn resolve_copy(&self, id: MuID) -> MuID {
/// resovles the first-ever copy for a variable (use orig to prevent infinite loop)
fn resolve_copy(&self, id: MuID, orig: MuID) -> MuID {
assert!(
self.lattices.contains_key(&id),
"cant find {} in lattice",
id
);
match self.lattices.get(&id).unwrap() {
&CopyLattice::Copy(copy) => self.resolve_copy(copy),
&CopyLattice::Copy(copy) => {
if copy != orig {
self.resolve_copy(copy, orig)
} else {
orig
}
}
_ => id
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment