From ce091693756e6f039a9b1f11f7528baf043a772d Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Sat, 25 Feb 2023 22:52:59 -0800 Subject: [PATCH] bugfixes --- src/backend/localify.rs | 9 ++++++++- src/backend/mod.rs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backend/localify.rs b/src/backend/localify.rs index aa23ac3..9050355 100644 --- a/src/backend/localify.rs +++ b/src/backend/localify.rs @@ -56,6 +56,10 @@ struct BlockVisitor<'a, V: Visitor> { } impl<'a, V: Visitor> BlockVisitor<'a, V> { fn new(body: &'a FunctionBody, trees: &'a Trees, visitor: V) -> Self { + log::trace!( + "localify: running on:\n{}", + body.display_verbose("| ", None) + ); Self { body, trees, @@ -70,6 +74,9 @@ impl<'a, V: Visitor> BlockVisitor<'a, V> { self.visitor.pre_term(); for &inst in self.body.blocks[block].insts.iter().rev() { + if self.trees.owner.contains_key(&inst) { + continue; + } self.visitor.post_inst(inst); self.visit_inst(inst, /* root = */ true); self.visitor.pre_inst(inst); @@ -223,7 +230,7 @@ impl<'a> Context<'a> { } } - self.points = point; + self.points = point + 1; } fn allocate(&mut self) { diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 97cbec0..b5f5b40 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -204,6 +204,7 @@ impl<'a> WasmFuncBackend<'a> { match &self.body.values[value] { &ValueDef::Operator(ref op, ref args, ref tys) => { for &arg in &args[..] { + let arg = self.body.resolve_alias(arg); if self.trees.owner.contains_key(&arg) { log::trace!(" -> arg {} is owned", arg); self.lower_inst(arg, /* root = */ false, func);