summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-09-30 12:35:09 -0700
committerGitHub <noreply@github.com>2024-09-30 12:35:09 -0700
commitb5e995f774ebd72c8b6c100ee94b1e03c36d22cc (patch)
treea3d9a7ae7aeb24917dfb0ebeffa29d570b78e6ab /src
parent2da69a84b69a316409d5af65f66443a27422a353 (diff)
downloadbinaryen-b5e995f774ebd72c8b6c100ee94b1e03c36d22cc.tar.gz
binaryen-b5e995f774ebd72c8b6c100ee94b1e03c36d22cc.tar.bz2
binaryen-b5e995f774ebd72c8b6c100ee94b1e03c36d22cc.zip
Fix the type of reused RefFunc in Precompute (#6976)
When we precompute something, we try to avoid allocating a new copy. That's important to avoid many allocations each time we run Precompute - otherwise, each time we see a br we'd allocate a fresh one, and for its values. But we had a bug where we reused a RefFunc as the value of a br without updating the type. It's actually tricky to reach a situation where we find a RefFunc to reuse and it is different from the actual one we want, but the fuzzer found one. Fixes the fuzz bug reported on #6845 (but unrelated to that PR).
Diffstat (limited to 'src')
-rw-r--r--src/passes/Precompute.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 709fd7d3d..0fc0753ae 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -298,7 +298,8 @@ struct Precompute
singleValue.type.getHeapType().isSignature()) {
if (auto* r = curr->value->template dynCast<RefFunc>()) {
r->func = singleValue.getFunc();
- r->finalize();
+ auto heapType = getModule()->getFunction(r->func)->type;
+ r->finalize(Type(heapType, NonNullable));
curr->finalize();
return;
}