summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast_utils.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index f883d5f66..4664f22ae 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -881,9 +881,21 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop, Visitor<Auto
}
void visitIf(If* curr) {
- // if without else does not return a value, so the body must be dropped if it is concrete
- if (!curr->ifFalse && isConcreteWasmType(curr->ifTrue->type)) {
- curr->ifTrue = Builder(*getModule()).makeDrop(curr->ifTrue);
+ if (curr->ifFalse) {
+ if (!isConcreteWasmType(curr->type)) {
+ // if either side of an if-else not returning a value is concrete, drop it
+ if (isConcreteWasmType(curr->ifTrue->type)) {
+ curr->ifTrue = Builder(*getModule()).makeDrop(curr->ifTrue);
+ }
+ if (isConcreteWasmType(curr->ifFalse->type)) {
+ curr->ifFalse = Builder(*getModule()).makeDrop(curr->ifFalse);
+ }
+ }
+ } else {
+ // if without else does not return a value, so the body must be dropped if it is concrete
+ if (isConcreteWasmType(curr->ifTrue->type)) {
+ curr->ifTrue = Builder(*getModule()).makeDrop(curr->ifTrue);
+ }
}
}