diff options
author | Alon Zakai <azakai@google.com> | 2023-01-24 14:22:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 14:22:31 -0800 |
commit | dd3091c87cc11ffe297632259cad18a64162e68b (patch) | |
tree | 46caa704cb0b41e9769ae11e7e91da2ffd2acfed /src/ir/drop.cpp | |
parent | ed3bf4f0613a66496342720d82f4100eccf39403 (diff) | |
download | binaryen-dd3091c87cc11ffe297632259cad18a64162e68b.tar.gz binaryen-dd3091c87cc11ffe297632259cad18a64162e68b.tar.bz2 binaryen-dd3091c87cc11ffe297632259cad18a64162e68b.zip |
Fix OptimizeInstructions on null trap of struct.set (#5449)
StructSet cannot be dropped.
Diffstat (limited to 'src/ir/drop.cpp')
-rw-r--r-- | src/ir/drop.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ir/drop.cpp b/src/ir/drop.cpp index 49bff55f7..5a860fa29 100644 --- a/src/ir/drop.cpp +++ b/src/ir/drop.cpp @@ -59,7 +59,12 @@ Expression* getDroppedChildrenAndAppend(Expression* curr, if (effects.hasUnremovableSideEffects() || curr->is<If>() || curr->is<Try>() || curr->is<Pop>() || BranchUtils::getDefinedName(curr).is()) { - return builder.makeSequence(builder.makeDrop(curr), last); + // If curr is concrete we must drop it. Or, if it is unreachable or none, + // then we can leave it as it is. + if (curr->type.isConcrete()) { + curr = builder.makeDrop(curr); + } + return builder.makeSequence(curr, last); } std::vector<Expression*> contents; @@ -67,11 +72,10 @@ Expression* getDroppedChildrenAndAppend(Expression* curr, if (!EffectAnalyzer(options, wasm, child).hasUnremovableSideEffects()) { continue; } + // See above. if (child->type.isConcrete()) { contents.push_back(builder.makeDrop(child)); } else { - // The child is unreachable, or none (none is possible as a child of a - // block or loop, etc.); in both cases we do not need a drop. contents.push_back(child); } } |