summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-11-01 13:51:50 -0700
committerGitHub <noreply@github.com>2019-11-01 13:51:50 -0700
commite53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2 (patch)
tree243df8cdedf7e48fe8ef2d65b893f9e2265b40dc /src
parentfb78a120277c023531020b146dd6506608aa9bcc (diff)
downloadbinaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.tar.gz
binaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.tar.bz2
binaryen-e53d4bdae0fffb6763ec4ae4fbf6f727d0da04d2.zip
Don't remove events used in instructions (#2412)
Previously RemoveUnusedModuleElements pass only preserved exported events and did not preserve events used in `throw` and `br_on_exn` instructions. This fixes it.
Diffstat (limited to 'src')
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index d4c6d5a5d..806545adf 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -116,6 +116,18 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> {
usesMemory = true;
}
}
+ void visitThrow(Throw* curr) {
+ if (reachable.count(ModuleElement(ModuleElementKind::Event, curr->event)) ==
+ 0) {
+ queue.emplace_back(ModuleElementKind::Event, curr->event);
+ }
+ }
+ void visitBrOnExn(BrOnExn* curr) {
+ if (reachable.count(ModuleElement(ModuleElementKind::Event, curr->event)) ==
+ 0) {
+ queue.emplace_back(ModuleElementKind::Event, curr->event);
+ }
+ }
};
// Finds function type usage