diff options
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r-- | src/passes/pass.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 570cd8610..f55f5018e 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -23,6 +23,7 @@ #include "ir/hashed.h" #include "ir/module-utils.h" +#include "ir/type-updating.h" #include "pass.h" #include "passes/passes.h" #include "support/colors.h" @@ -936,16 +937,29 @@ void PassRunner::runPassOnFunction(Pass* pass, Function* func) { } void PassRunner::handleAfterEffects(Pass* pass, Function* func) { - if (pass->modifiesBinaryenIR()) { - // If Binaryen IR is modified, Stack IR must be cleared - it would - // be out of sync in a potentially dangerous way. - if (func) { - func->stackIR.reset(nullptr); - } else { - for (auto& func : wasm->functions) { - func->stackIR.reset(nullptr); - } + if (!pass->modifiesBinaryenIR()) { + return; + } + + // Binaryen IR is modified, so we may have work here. + + if (!func) { + // If no function is provided, then this is not a function-parallel pass, + // and it may have operated on any of the functions in theory, so run on + // them all. + assert(!pass->isFunctionParallel()); + for (auto& func : wasm->functions) { + handleAfterEffects(pass, func.get()); } + return; + } + + // If Binaryen IR is modified, Stack IR must be cleared - it would + // be out of sync in a potentially dangerous way. + func->stackIR.reset(nullptr); + + if (pass->requiresNonNullableLocalFixups()) { + TypeUpdating::handleNonDefaultableLocals(func, *wasm); } } |