summaryrefslogtreecommitdiff
path: root/src/ir/possible-contents.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-22 09:32:14 -0700
committerGitHub <noreply@github.com>2022-08-22 09:32:14 -0700
commit3a87ebe9f23763cf8146e7447343d44d071f6da0 (patch)
treee9fac50b36160485e778f1679dfce52e581f00b6 /src/ir/possible-contents.cpp
parentf128ac4d9d71ec5c9a7d87762f93f2fe729bec9d (diff)
downloadbinaryen-3a87ebe9f23763cf8146e7447343d44d071f6da0.tar.gz
binaryen-3a87ebe9f23763cf8146e7447343d44d071f6da0.tar.bz2
binaryen-3a87ebe9f23763cf8146e7447343d44d071f6da0.zip
GUFA: Mutable exported globals are roots (#4935)
Such globals can be written to from the outside, so we cannot infer anything about their contents. Fixes #4932
Diffstat (limited to 'src/ir/possible-contents.cpp')
-rw-r--r--src/ir/possible-contents.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp
index d9c608bda..f1302b3dd 100644
--- a/src/ir/possible-contents.cpp
+++ b/src/ir/possible-contents.cpp
@@ -1234,6 +1234,13 @@ Flower::Flower(Module& wasm) : wasm(wasm) {
}
}
}
+ } else if (ex->kind == ExternalKind::Global) {
+ // Exported mutable globals are roots, since the outside may write any
+ // value to them.
+ auto name = ex->value;
+ if (wasm.getGlobal(name)->mutable_) {
+ roots[GlobalLocation{name}] = PossibleContents::many();
+ }
}
}