From 8caba239fab0adbc76a551a1937ff52b0d6b3f8a Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 29 Nov 2022 19:49:22 -0800 Subject: [PATCH] WIP. --- src/frontend.rs | 8 +++++++- src/ir/func.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frontend.rs b/src/frontend.rs index 1187bed..a0f76d0 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -1156,11 +1156,12 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> { .collect::>(); self.locals.start_block(*el, self.reachable); self.cur_block = *el; + self.reachable = *head_reachable; self.emit_branch(*out, &else_result_values[..]); assert_eq!(self.op_stack.len(), *start_depth); } self.cur_block = *out; - self.reachable = *head_reachable || self.reachable || *merge_reachable; + self.reachable = *head_reachable || was_reachable || *merge_reachable; self.locals.seal_block_preds(*out, &mut self.body); self.locals.start_block(*out, was_reachable); self.push_block_params(results.len()); @@ -1455,6 +1456,11 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> { } fn emit_unreachable(&mut self) { + log::trace!( + "emit_unreachable: cur_block {} reachable {}", + self.cur_block, + self.reachable + ); if self.reachable { self.body.end_block(self.cur_block, Terminator::Unreachable); self.reachable = false; diff --git a/src/ir/func.rs b/src/ir/func.rs index e80ddf3..611abf1 100644 --- a/src/ir/func.rs +++ b/src/ir/func.rs @@ -170,6 +170,7 @@ impl FunctionBody { } pub fn end_block(&mut self, block: Block, terminator: Terminator) { + log::trace!("block {} terminator {:?}", block, terminator); terminator.visit_successors(|succ| { self.add_edge(block, succ); });