summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-08-23 13:56:54 -0500
committerGitHub <noreply@github.com>2023-08-23 11:56:54 -0700
commitf6867f9a485c125dcd2914f58e2636f01879db7b (patch)
tree07f976ce0d417dc2f7280e53e7a1623d6607bebb /src
parent1cd3cff4820222901eaa015fd2d7b0b4b5b7fc3e (diff)
downloadbinaryen-f6867f9a485c125dcd2914f58e2636f01879db7b.tar.gz
binaryen-f6867f9a485c125dcd2914f58e2636f01879db7b.tar.bz2
binaryen-f6867f9a485c125dcd2914f58e2636f01879db7b.zip
Fix assertion failure in RemoveUnusedBrs (#5895)
The improvements to RemoveUnusedBrs in #5887 also introduced a regression where the pass did not correctly handle unreachable fallthrough values and crashed with an assertion failure. Fix the problem by returning early when a fallthrough value is unreachable and add a regression test. Fixes #5892.
Diffstat (limited to 'src')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 4fda7afb2..a5950f2fa 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -719,6 +719,10 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
Type refType =
Properties::getFallthroughType(curr->ref, passOptions, *getModule());
+ if (refType == Type::unreachable) {
+ // Leave this to DCE.
+ return;
+ }
assert(refType.isRef());
// When we optimize based on all the fallthrough type information