From 2253ac61981039ac9035204e91856c5262198596 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Fri, 22 Nov 2024 19:50:36 +0100 Subject: [PATCH] fixing some bugs --- lang/src/son.rs | 6 ++++++ lang/src/son/hbvm/regalloc.rs | 6 +++--- lang/tests/son_tests_something_somehow.txt | 0 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 lang/tests/son_tests_something_somehow.txt diff --git a/lang/src/son.rs b/lang/src/son.rs index fe10250..c2def59 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -998,6 +998,7 @@ impl Nodes { self.lock(target); for i in self[target].outputs.clone() { if self[i].kind == Kind::Phi { + self.queued_peeps.extend(self[i].outputs.clone()); self.replace(i, self[i].inputs[side]); } } @@ -1383,6 +1384,7 @@ impl Nodes { self.remove(prev); self.unlock(o); + self.queued_peeps.extend(self[o].outputs.clone()); self.replace(o, self[o].inputs[1]); } } @@ -1436,6 +1438,10 @@ impl Nodes { let ctrl = &self[cursor]; // TODO: do more inteligent checks on the condition if matches!(ctrl.kind, Kind::Then | Kind::Else) { + if self[ctrl.inputs[0]].kind == Kind::End { + return CondOptRes::Unknown; + } + debug_assert_eq!(self[ctrl.inputs[0]].kind, Kind::If); let other_cond = self[ctrl.inputs[0]].inputs[1]; if let Some(value) = self.matches_cond(cond, other_cond) { return CondOptRes::Known { diff --git a/lang/src/son/hbvm/regalloc.rs b/lang/src/son/hbvm/regalloc.rs index 6cb4535..452f332 100644 --- a/lang/src/son/hbvm/regalloc.rs +++ b/lang/src/son/hbvm/regalloc.rs @@ -299,12 +299,12 @@ impl HbvmBackend { self.ralloc = res; let bundle_count = self.ralloc.bundles.len() + (reg_offset as usize); + debug_assert!(bundle_count < reg::STACK_PTR as usize, "TODO: spill memory"); ( if tail { - assert!(bundle_count < reg::STACK_PTR as usize, "TODO: spill memory"); - self.ralloc.bundles.len() - } else { bundle_count.saturating_sub((reg::RET_ADDR - 1) as _) + } else { + self.ralloc.bundles.len() }, tail, ) diff --git a/lang/tests/son_tests_something_somehow.txt b/lang/tests/son_tests_something_somehow.txt new file mode 100644 index 0000000..e69de29