From 1cd81268627c71f36f45d6ef875dee84a79630f4 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 9 Oct 2023 10:12:53 -0700 Subject: 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. --- src/ir/table-utils.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/ir/table-utils.cpp') 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(); }); - // 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 -- cgit v1.2.3