summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-10-19 12:52:59 -0700
committerGitHub <noreply@github.com>2021-10-19 12:52:59 -0700
commitd09be7af5b00f5e739ed56077ac5fb6b8e4e2adf (patch)
treec8c66b78b2334928cdc1e0767ae35831440d2e89 /src/passes/OptimizeInstructions.cpp
parentc19ff59c71824b34fa312aac9ad979e2198d7d36 (diff)
downloadbinaryen-d09be7af5b00f5e739ed56077ac5fb6b8e4e2adf.tar.gz
binaryen-d09be7af5b00f5e739ed56077ac5fb6b8e4e2adf.tar.bz2
binaryen-d09be7af5b00f5e739ed56077ac5fb6b8e4e2adf.zip
OptimizeInstructions: Ignore unreachable subsequent sets (#4259)
Fuzzing followup to #4244.
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index ba18bfd74..f23c119ec 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1415,6 +1415,11 @@ struct OptimizeInstructions
bool optimizeSubsequentStructSet(StructNew* new_,
StructSet* set,
Index refLocalIndex) {
+ // Leave unreachable code for DCE, to avoid updating types here.
+ if (new_->type == Type::unreachable || set->type == Type::unreachable) {
+ return false;
+ }
+
if (new_->isWithDefault()) {
// Ignore a new_default for now. If the fields are defaultable then we
// could add them, in principle, but that might increase code size.