diff options
Diffstat (limited to 'src/tools/wasm-metadce.cpp')
-rw-r--r-- | src/tools/wasm-metadce.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index 46b66c986..71ea2f693 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -213,20 +213,18 @@ struct MetaDCEGraph { // we can't remove segments, so root what they need InitScanner rooter(this, Name()); rooter.setModule(&wasm); - for (auto& table : wasm.tables) { - for (auto& segment : table->segments) { - // TODO: currently, all functions in the table are roots, but we - // should add an option to refine that - for (auto& name : segment.data) { - if (!wasm.getFunction(name)->imported()) { - roots.insert(functionToDCENode[name]); - } else { - roots.insert(importIdToDCENode[getFunctionImportId(name)]); - } + ModuleUtils::iterActiveElementSegments(wasm, [&](ElementSegment* segment) { + // TODO: currently, all functions in the table are roots, but we + // should add an option to refine that + for (auto& name : segment->data) { + if (!wasm.getFunction(name)->imported()) { + roots.insert(functionToDCENode[name]); + } else { + roots.insert(importIdToDCENode[getFunctionImportId(name)]); } - rooter.walk(segment.offset); } - } + rooter.walk(segment->offset); + }); for (auto& segment : wasm.memory.segments) { if (!segment.isPassive) { rooter.walk(segment.offset); |