diff options
Diffstat (limited to 'src/passes')
-rw-r--r-- | src/passes/Print.cpp | 4 | ||||
-rw-r--r-- | src/passes/RemoveUnusedModuleElements.cpp | 19 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6a41961a2..4d6207b01 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1842,6 +1842,10 @@ struct PrintExpressionContents printName(curr->func, o); } void visitRefEq(RefEq* curr) { printMedium(o, "ref.eq"); } + void visitTableGet(TableGet* curr) { + printMedium(o, "table.get "); + printName(curr->table, o); + } void visitTry(Try* curr) { printMedium(o, "try"); if (curr->name.is()) { diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp index 2b460a0fd..7436676ef 100644 --- a/src/passes/RemoveUnusedModuleElements.cpp +++ b/src/passes/RemoveUnusedModuleElements.cpp @@ -92,18 +92,18 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> { } } + // Add a reference to a table and all its segments and elements. + void maybeAddTable(Name name) { + maybeAdd(ModuleElement(ModuleElementKind::Table, name)); + ModuleUtils::iterTableSegments(*module, name, [&](ElementSegment* segment) { + maybeAdd(ModuleElement(ModuleElementKind::ElementSegment, segment->name)); + }); + } + void visitCall(Call* curr) { maybeAdd(ModuleElement(ModuleElementKind::Function, curr->target)); } - void visitCallIndirect(CallIndirect* curr) { - assert(!module->tables.empty() && "call-indirect to undefined table."); - maybeAdd(ModuleElement(ModuleElementKind::Table, curr->table)); - ModuleUtils::iterTableSegments( - *module, curr->table, [&](ElementSegment* segment) { - maybeAdd( - ModuleElement(ModuleElementKind::ElementSegment, segment->name)); - }); - } + void visitCallIndirect(CallIndirect* curr) { maybeAddTable(curr->table); } void visitGlobalGet(GlobalGet* curr) { maybeAdd(ModuleElement(ModuleElementKind::Global, curr->name)); @@ -128,6 +128,7 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> { void visitRefFunc(RefFunc* curr) { maybeAdd(ModuleElement(ModuleElementKind::Function, curr->func)); } + void visitTableGet(TableGet* curr) { maybeAddTable(curr->table); } void visitThrow(Throw* curr) { maybeAdd(ModuleElement(ModuleElementKind::Tag, curr->tag)); } |