diff options
author | Abbas Mashayekh <martianboy2005@gmail.com> | 2021-03-24 21:43:45 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 10:13:45 -0700 |
commit | ffac06650507ac413d60d72aadc1e33fb1f91ccf (patch) | |
tree | f581d02da66df8db2a775fc731d39baf15d96c82 /src/passes/RemoveImports.cpp | |
parent | 683c31381f5798016f683a6b42e2a8fad0f871cb (diff) | |
download | binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.gz binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.bz2 binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.zip |
[RT] Support expressions in element segments (#3666)
This PR adds support for `ref.null t` as a valid element segment
item. The abbreviated format of `(elem ... func $f $g...)` is kept in
both printing and binary emitting if all items are `ref.func`s. Public
APIs aren't updated in this PR.
Diffstat (limited to 'src/passes/RemoveImports.cpp')
-rw-r--r-- | src/passes/RemoveImports.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/passes/RemoveImports.cpp b/src/passes/RemoveImports.cpp index be41717f4..2a1c119fd 100644 --- a/src/passes/RemoveImports.cpp +++ b/src/passes/RemoveImports.cpp @@ -22,6 +22,7 @@ // look at all the rest of the code). // +#include "ir/element-utils.h" #include "ir/module-utils.h" #include "pass.h" #include "wasm.h" @@ -49,11 +50,8 @@ struct RemoveImports : public WalkerPass<PostWalker<RemoveImports>> { *curr, [&](Function* func) { names.push_back(func->name); }); // Do not remove names referenced in a table std::set<Name> indirectNames; - for (auto& segment : curr->elementSegments) { - for (auto& name : segment->data) { - indirectNames.insert(name); - } - } + ElementUtils::iterAllElementFunctionNames( + curr, [&](Name& name) { indirectNames.insert(name); }); for (auto& name : names) { if (indirectNames.find(name) == indirectNames.end()) { curr->removeFunction(name); |