summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-09-22 14:28:11 -0700
committerGitHub <noreply@github.com>2017-09-22 14:28:11 -0700
commitf84fa96a0abb482a392040cf0aeab627345d812d (patch)
tree8666768ec00345c64839ca2113b9cdb7ed23a74c /src
parentdb66e646df6512d4eb2be344778001c62402e4c5 (diff)
downloadbinaryen-f84fa96a0abb482a392040cf0aeab627345d812d.tar.gz
binaryen-f84fa96a0abb482a392040cf0aeab627345d812d.tar.bz2
binaryen-f84fa96a0abb482a392040cf0aeab627345d812d.zip
when we re-finalize a function body, we may have changed it from unreachable to none. that is bad if the function has a return value, as unreachable was ok but none is not. in that case, we must add an unreachable (#1193)
Diffstat (limited to 'src')
-rw-r--r--src/ast_utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index 95f725636..dfa233f26 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -176,6 +176,15 @@ struct ReFinalize : public WalkerPass<PostWalker<ReFinalize>> {
void visitNop(Nop *curr) { curr->finalize(); }
void visitUnreachable(Unreachable *curr) { curr->finalize(); }
+ void visitFunction(Function* curr) {
+ // we may have changed the body from unreachable to none, which might be bad
+ // if the function has a return value
+ if (curr->result != none && curr->body->type == none) {
+ Builder builder(*getModule());
+ curr->body = builder.blockify(curr->body, builder.makeUnreachable());
+ }
+ }
+
WasmType getValueType(Expression* value) {
return value ? value->type : none;
}