From e382c577bc7df6f26933a7b7627757ad32bca842 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 19 Oct 2020 09:13:45 -0700 Subject: 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. --- src/passes/Inlining.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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(global->init).list) { + infos[ref->func].usedGlobally = true; + } + } + } } bool iteration(PassRunner* runner, Module* module) { -- cgit v1.2.3