From 282369b5430287c2397eb9e3cdd859ad12fa3937 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 7 Sep 2016 15:59:58 -0700 Subject: autodrop if body if no else --- src/ast_utils.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ast_utils.h') 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 WalkerPassfinalize(); // 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); -- cgit v1.2.3