diff --git a/lang/README.md b/lang/README.md index ab3bb6c3..362689f2 100644 --- a/lang/README.md +++ b/lang/README.md @@ -1092,6 +1092,23 @@ main := fn(): uint { } ``` +#### memory_swap +```hb +U := struct {u: uint, v: uint, g: uint} +main := fn(): uint { + a := decide(0) + b := decide(1) + + c := a + a = b + b = c + + return b.u + a.u +} + +decide := fn(u: uint): U return .(u, 0, 0) +``` + #### wide_ret ```hb OemIdent := struct { diff --git a/lang/src/son.rs b/lang/src/son.rs index 36eddcf1..7afc62a5 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -1107,18 +1107,11 @@ impl Nodes { } } K::Stre => { - if target == 79 { - std::dbg!(std::backtrace::Backtrace::capture()); - } - let &[_, value, region, store, ..] = self[target].inputs.as_slice() else { unreachable!() }; if self[value].kind == Kind::Load && self[value].inputs[1] == region { - if target == 79 { - std::dbg!(1); - } return Some(store); } @@ -1137,9 +1130,6 @@ impl Nodes { 'eliminate: { if self[target].outputs.is_empty() { - if target == 79 { - std::dbg!(2); - } break 'eliminate; } @@ -1149,9 +1139,6 @@ impl Nodes { for &ele in self[value].outputs.clone().iter().filter(|&&n| n != target) { self[ele].peep_triggers.push(target); } - if target == 79 { - std::dbg!(3); - } break 'eliminate; } @@ -1160,9 +1147,6 @@ impl Nodes { }; if self[stack].ty != self[value].ty || self[stack].kind != Kind::Stck { - if target == 79 { - std::dbg!(3); - } break 'eliminate; } @@ -1187,9 +1171,6 @@ impl Nodes { } let Some(index) = unidentifed.iter().position(|&n| n == contact_point) else { - if target == 79 { - std::dbg!(5); - } break 'eliminate; }; if self[self[cursor].inputs[1]].kind == Kind::Load @@ -1198,9 +1179,6 @@ impl Nodes { == self.aclass_index(self[n].inputs[2]).0 }) { - if target == 79 { - std::dbg!(6); - } break 'eliminate; } unidentifed.remove(index); @@ -1214,9 +1192,6 @@ impl Nodes { } if !unidentifed.is_empty() { - if target == 79 { - std::dbg!(7); - } break 'eliminate; } @@ -4828,6 +4803,7 @@ mod tests { fb_driver; // Purely Testing Examples; + memory_swap; very_nested_loops; generic_type_mishap; storing_into_nullable_struct; diff --git a/lang/tests/son_tests_memory_swap.txt b/lang/tests/son_tests_memory_swap.txt new file mode 100644 index 00000000..e69de29b