diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 15:59:58 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 18:42:48 -0700 |
commit | 282369b5430287c2397eb9e3cdd859ad12fa3937 (patch) | |
tree | df5f2b3d37c64cb8fd085f65c199b4244b650eed /src/ast_utils.h | |
parent | b518e564be25cc2705ab3993b71f0170feabac7e (diff) | |
download | binaryen-282369b5430287c2397eb9e3cdd859ad12fa3937.tar.gz binaryen-282369b5430287c2397eb9e3cdd859ad12fa3937.tar.bz2 binaryen-282369b5430287c2397eb9e3cdd859ad12fa3937.zip |
autodrop if body if no else
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r-- | src/ast_utils.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index f7a486332..5deaa6a2c 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -832,6 +832,13 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop, Visitor<Auto curr->finalize(); // we may have changed our type } + 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); + } + } + void visitFunction(Function* curr) { if (curr->result == none && isConcreteWasmType(curr->body->type)) { curr->body = Builder(*getModule()).makeDrop(curr->body); |