fixing some bugs

This commit is contained in:
Jakub Doka 2024-11-22 19:50:36 +01:00
parent 05a7bd0583
commit 2253ac6198
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
3 changed files with 9 additions and 3 deletions

View file

@ -998,6 +998,7 @@ impl Nodes {
self.lock(target); self.lock(target);
for i in self[target].outputs.clone() { for i in self[target].outputs.clone() {
if self[i].kind == Kind::Phi { if self[i].kind == Kind::Phi {
self.queued_peeps.extend(self[i].outputs.clone());
self.replace(i, self[i].inputs[side]); self.replace(i, self[i].inputs[side]);
} }
} }
@ -1383,6 +1384,7 @@ impl Nodes {
self.remove(prev); self.remove(prev);
self.unlock(o); self.unlock(o);
self.queued_peeps.extend(self[o].outputs.clone());
self.replace(o, self[o].inputs[1]); self.replace(o, self[o].inputs[1]);
} }
} }
@ -1436,6 +1438,10 @@ impl Nodes {
let ctrl = &self[cursor]; let ctrl = &self[cursor];
// TODO: do more inteligent checks on the condition // TODO: do more inteligent checks on the condition
if matches!(ctrl.kind, Kind::Then | Kind::Else) { 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]; let other_cond = self[ctrl.inputs[0]].inputs[1];
if let Some(value) = self.matches_cond(cond, other_cond) { if let Some(value) = self.matches_cond(cond, other_cond) {
return CondOptRes::Known { return CondOptRes::Known {

View file

@ -299,12 +299,12 @@ impl HbvmBackend {
self.ralloc = res; self.ralloc = res;
let bundle_count = self.ralloc.bundles.len() + (reg_offset as usize); 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 { 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 _) bundle_count.saturating_sub((reg::RET_ADDR - 1) as _)
} else {
self.ralloc.bundles.len()
}, },
tail, tail,
) )