summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-10-19 09:13:45 -0700
committerGitHub <noreply@github.com>2020-10-19 09:13:45 -0700
commite382c577bc7df6f26933a7b7627757ad32bca842 (patch)
tree769a36ca891edbd41bc394d929c89684ebb24754 /src
parent8d8e1c53aa1b03ad4285437a6c41bc86f86731ca (diff)
downloadbinaryen-e382c577bc7df6f26933a7b7627757ad32bca842.tar.gz
binaryen-e382c577bc7df6f26933a7b7627757ad32bca842.tar.bz2
binaryen-e382c577bc7df6f26933a7b7627757ad32bca842.zip
Inlining fuzz fix: Notice ref.func function references in global inits (#3252)
Such a reference may mean we cannot remove a function after inlining it.
Diffstat (limited to 'src')
-rw-r--r--src/passes/Inlining.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index d7f132879..43addff8b 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -326,7 +326,6 @@ struct Inlining : public Pass {
PassRunner runner(module);
FunctionInfoScanner(&infos).run(&runner, module);
// fill in global uses
- // anything exported or used in a table should not be inlined
for (auto& ex : module->exports) {
if (ex->kind == ExternalKind::Function) {
infos[ex->value].usedGlobally = true;
@@ -337,6 +336,13 @@ struct Inlining : public Pass {
infos[name].usedGlobally = true;
}
}
+ for (auto& global : module->globals) {
+ if (!global->imported()) {
+ for (auto* ref : FindAll<RefFunc>(global->init).list) {
+ infos[ref->func].usedGlobally = true;
+ }
+ }
+ }
}
bool iteration(PassRunner* runner, Module* module) {