summaryrefslogtreecommitdiff
path: root/src/passes/RemoveUnusedModuleElements.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-05-11 12:29:46 -0700
committerGitHub <noreply@github.com>2021-05-11 12:29:46 -0700
commited92a8d5e493c839687c2f2d56cdc5123e6e3a47 (patch)
treeb947cb02acae0097fe635be6f4069ba86d48ad58 /src/passes/RemoveUnusedModuleElements.cpp
parent09052c055c07ec5a1385cd5c142ff4d8534f1d1c (diff)
downloadbinaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.tar.gz
binaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.tar.bz2
binaryen-ed92a8d5e493c839687c2f2d56cdc5123e6e3a47.zip
ExtractFunction: Do not always remove the memory and table (#3877)
Instead, run RemoveUnusedModuleElements, which does that sort of thing. That is, this pass just "extracts" the function by turning all others into imports, and then they should almost all be removable via RemoveUnusedModuleElements, depending on whether they are used in the table or not, whether the extracted function calls them, etc. Without this, we would error if a function was in the table, and so this fixes #3876
Diffstat (limited to 'src/passes/RemoveUnusedModuleElements.cpp')
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index b5cf2635a..59d9a2a9b 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -229,6 +229,10 @@ struct RemoveUnusedModuleElements : public Pass {
analyzer.reachable.count(
ModuleElement(ModuleElementKind::Table, curr->name)) == 0;
});
+ // TODO: After removing elements, we may be able to remove more things, and
+ // should continue to work. (For example, after removing a reference
+ // to a function from an element segment, we may be able to remove
+ // that function, etc.)
// Handle the memory
if (!exportsMemory && !analyzer.usesMemory) {