summaryrefslogtreecommitdiff
path: root/src/passes/RemoveUnusedModuleElements.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/RemoveUnusedModuleElements.cpp')
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index 0cafd9d9d..93cc33563 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -32,6 +32,7 @@
namespace wasm {
+// TODO: Add data segment, multiple memories (#5224)
enum class ModuleElementKind { Function, Global, Tag, Table, ElementSegment };
typedef std::pair<ModuleElementKind, Name> ModuleElement;
@@ -195,7 +196,10 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> {
void visitAtomicNotify(AtomicNotify* curr) { usesMemory = true; }
void visitAtomicFence(AtomicFence* curr) { usesMemory = true; }
void visitMemoryInit(MemoryInit* curr) { usesMemory = true; }
- void visitDataDrop(DataDrop* curr) { usesMemory = true; }
+ void visitDataDrop(DataDrop* curr) {
+ // TODO: Replace this with a use of a data segment (#5224).
+ usesMemory = true;
+ }
void visitMemoryCopy(MemoryCopy* curr) { usesMemory = true; }
void visitMemoryFill(MemoryFill* curr) { usesMemory = true; }
void visitMemorySize(MemorySize* curr) { usesMemory = true; }
@@ -227,6 +231,19 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> {
maybeAdd(ModuleElement(ModuleElementKind::Tag, tag));
}
}
+ void visitArrayNewSeg(ArrayNewSeg* curr) {
+ switch (curr->op) {
+ case NewData:
+ // TODO: Replace this with a use of the specific data segment (#5224).
+ usesMemory = true;
+ return;
+ case NewElem:
+ auto segment = module->elementSegments[curr->segment]->name;
+ maybeAdd(ModuleElement(ModuleElementKind::ElementSegment, segment));
+ return;
+ }
+ WASM_UNREACHABLE("unexpected op");
+ }
};
struct RemoveUnusedModuleElements : public Pass {