summaryrefslogtreecommitdiff
path: root/src/ir/branch-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-10-10 08:39:53 -0700
committerGitHub <noreply@github.com>2024-10-10 08:39:53 -0700
commitdebd24681cb4764e75936dd74bc33c41899b8a23 (patch)
treeb2b96a96aaaa539202700e5dab62ed569c85bc7c /src/ir/branch-utils.h
parent930034ff1637f611a05582ac28fb734d6503b12e (diff)
downloadbinaryen-debd24681cb4764e75936dd74bc33c41899b8a23.tar.gz
binaryen-debd24681cb4764e75936dd74bc33c41899b8a23.tar.bz2
binaryen-debd24681cb4764e75936dd74bc33c41899b8a23.zip
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).
Diffstat (limited to 'src/ir/branch-utils.h')
-rw-r--r--src/ir/branch-utils.h3
1 files changed, 2 insertions, 1 deletions
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<Switch>()) {
func(name, sw->value);
} else if (auto* br = expr->dynCast<BrOn>()) {
- 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<TryTable>()) {
// The values are supplied by throwing instructions, so we are unable to
// know what they will be here.