summaryrefslogtreecommitdiff
path: root/src/passes/DeadCodeElimination.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-05-11 10:50:11 -0700
committerGitHub <noreply@github.com>2020-05-11 10:50:11 -0700
commit91ec2ee5bedefc4736fcda78ae39298846aeeb41 (patch)
treefd7c34a65f7c2273bad64d93f554a7aedca5be60 /src/passes/DeadCodeElimination.cpp
parent2c30ee408a72f5403fddeba8b4b856437c711727 (diff)
downloadbinaryen-91ec2ee5bedefc4736fcda78ae39298846aeeb41.tar.gz
binaryen-91ec2ee5bedefc4736fcda78ae39298846aeeb41.tar.bz2
binaryen-91ec2ee5bedefc4736fcda78ae39298846aeeb41.zip
Handle throw and rethrow in DCE (#2844)
This adds missing handlings for `throw` and `rethrow` in DCE. They should set `reachable` variable to `false`, like other branches.
Diffstat (limited to 'src/passes/DeadCodeElimination.cpp')
-rw-r--r--src/passes/DeadCodeElimination.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp
index ebeeca364..400252e8f 100644
--- a/src/passes/DeadCodeElimination.cpp
+++ b/src/passes/DeadCodeElimination.cpp
@@ -148,14 +148,6 @@ struct DeadCodeElimination
reachable = false;
}
- void visitBrOnExn(BrOnExn* curr) {
- if (isDead(curr->exnref)) {
- replaceCurrent(curr->exnref);
- return;
- }
- addBreak(curr->name);
- }
-
void visitReturn(Return* curr) {
if (isDead(curr->value)) {
replaceCurrent(curr->value);
@@ -259,6 +251,18 @@ struct DeadCodeElimination
typeUpdater.maybeUpdateTypeToUnreachable(curr);
}
+ void visitThrow(Throw* curr) { reachable = false; }
+
+ void visitRethrow(Rethrow* curr) { reachable = false; }
+
+ void visitBrOnExn(BrOnExn* curr) {
+ if (isDead(curr->exnref)) {
+ replaceCurrent(curr->exnref);
+ return;
+ }
+ addBreak(curr->name);
+ }
+
static void scan(DeadCodeElimination* self, Expression** currp) {
auto* curr = *currp;
if (!self->reachable) {