summaryrefslogtreecommitdiff
path: root/src/passes/Inlining.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-08-28 20:12:48 -0700
committerGitHub <noreply@github.com>2017-08-28 20:12:48 -0700
commitd621116cada789d15c569385ea79a57ba534c08f (patch)
tree6f9c922c5a0c2f5c8791636a156c8694d4be1d4d /src/passes/Inlining.cpp
parent5c2f4ab22367d04753678fbd12d67b4dc2a29010 (diff)
parent2d9e5a1c60a41e747956880ab199955b8f12d53c (diff)
downloadbinaryen-d621116cada789d15c569385ea79a57ba534c08f.tar.gz
binaryen-d621116cada789d15c569385ea79a57ba534c08f.tar.bz2
binaryen-d621116cada789d15c569385ea79a57ba534c08f.zip
Merge pull request #1154 from WebAssembly/fuzz
Fuzz fixes
Diffstat (limited to 'src/passes/Inlining.cpp')
-rw-r--r--src/passes/Inlining.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 710fc00ff..192480d26 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -155,7 +155,6 @@ static Expression* doInlining(Module* module, Function* into, InliningAction& ac
auto* call = (*action.callSite)->cast<Call>();
Builder builder(*module);
auto* block = Builder(*module).makeBlock();
- block->type = call->type;
block->name = Name(std::string("__inlined_func$") + from->name.str);
*action.callSite = block;
// set up a locals mapping
@@ -191,6 +190,16 @@ static Expression* doInlining(Module* module, Function* into, InliningAction& ac
auto* contents = ExpressionManipulator::copy(from->body, *module);
updater.walk(contents);
block->list.push_back(contents);
+ block->type = call->type;
+ // if the function returned a value, we just set the block containing the
+ // inlined code to have that type. or, if the function was void and
+ // contained void, that is fine too. a bad case is a void function in which
+ // we have unreachable code, so we would be replacing a void call with an
+ // unreachable; we need to handle
+ if (contents->type == unreachable && block->type == none) {
+ // make the block reachable by adding a break to it
+ block->list.push_back(builder.makeBreak(block->name));
+ }
return block;
}