diff options
author | Thomas Lively <tlively@google.com> | 2023-10-09 10:12:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-09 10:12:53 -0700 |
commit | 1cd81268627c71f36f45d6ef875dee84a79630f4 (patch) | |
tree | d2f5c9e6e5013d2582035f5a638244d896d88d19 /src | |
parent | b3775b5e4e150439276ad3d34f1bb564b28e8ef5 (diff) | |
download | binaryen-1cd81268627c71f36f45d6ef875dee84a79630f4.tar.gz binaryen-1cd81268627c71f36f45d6ef875dee84a79630f4.tar.bz2 binaryen-1cd81268627c71f36f45d6ef875dee84a79630f4.zip |
Fix a bug printing and emitting empty, passive element segments (#6002)
Empty, passive element segments were always emitted as having `func` type
because all their elements trivially were RefFunc (because they have no
elements) and because we were incorrectly checking table types if they existed
instead of the element segment's type directly to see if it was non-func.
Fix the bug by checking each element segment's type directly and add a test.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/table-utils.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/ir/table-utils.cpp b/src/ir/table-utils.cpp index fb9285319..124eb2aa3 100644 --- a/src/ir/table-utils.cpp +++ b/src/ir/table-utils.cpp @@ -72,14 +72,11 @@ bool usesExpressions(ElementSegment* curr, Module* module) { return entry->is<RefFunc>(); }); - // If the table has a specialized (non-MVP) type, then the segment must - // declare a type that is a subtype of that, so it must use the post-MVP form - // of using expressions. - bool hasTableOfSpecializedType = - curr->table.is() && - module->getTable(curr->table)->type != Type(HeapType::func, Nullable); + // If the segment has a specialized (non-MVP) type, then it must use the + // post-MVP form of using expressions. + bool hasSpecializedType = curr->type != Type(HeapType::func, Nullable); - return !allElementsRefFunc || hasTableOfSpecializedType; + return !allElementsRefFunc || hasSpecializedType; } } // namespace wasm::TableUtils |