From debd24681cb4764e75936dd74bc33c41899b8a23 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 10 Oct 2024 08:39:53 -0700 Subject: Fix BranchUtils::operateOnScopeNameUsesAndSentValues() on BrOn (#6995) BrOn does not always send a value. This is an odd asymmetry in the wasm spec, where br_on_null does not send the null on the branch (which makes sense, but the asymmetry does mean we need to special-case it). --- src/ir/branch-utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ir/branch-utils.h') diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h index be3f7f7a8..369365e72 100644 --- a/src/ir/branch-utils.h +++ b/src/ir/branch-utils.h @@ -108,7 +108,8 @@ void operateOnScopeNameUsesAndSentValues(Expression* expr, T func) { } else if (auto* sw = expr->dynCast()) { func(name, sw->value); } else if (auto* br = expr->dynCast()) { - func(name, br->ref); + // A value may not be sent (e.g. BrOnNull does *not* send a null). + func(name, br->getSentType() != Type::none ? br->ref : nullptr); } else if (expr->is()) { // The values are supplied by throwing instructions, so we are unable to // know what they will be here. -- cgit v1.2.3