summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r--src/tools/fuzzing.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index 1d68219e2..6a947d80c 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -1200,12 +1200,15 @@ private:
Expression* makeCall(Type type) {
// seems ok, go on
int tries = TRIES;
+ bool isReturn;
while (tries-- > 0) {
Function* target = func;
if (!wasm.functions.empty() && !oneIn(wasm.functions.size())) {
target = vectorPick(wasm.functions).get();
}
- if (target->result != type) {
+ isReturn = type == unreachable && wasm.features.hasTailCall() &&
+ func->result == target->result;
+ if (target->result != type && !isReturn) {
continue;
}
// we found one!
@@ -1213,7 +1216,7 @@ private:
for (auto argType : target->params) {
args.push_back(make(argType));
}
- return builder.makeCall(target->name, args, type);
+ return builder.makeCall(target->name, args, type, isReturn);
}
// we failed to find something
return make(type);
@@ -1227,11 +1230,14 @@ private:
// look for a call target with the right type
Index start = upTo(data.size());
Index i = start;
- Function* func;
+ Function* targetFn;
+ bool isReturn;
while (1) {
// TODO: handle unreachable
- func = wasm.getFunction(data[i]);
- if (func->result == type) {
+ targetFn = wasm.getFunction(data[i]);
+ isReturn = type == unreachable && wasm.features.hasTailCall() &&
+ func->result == targetFn->result;
+ if (targetFn->result == type || isReturn) {
break;
}
i++;
@@ -1251,11 +1257,12 @@ private:
target = make(i32);
}
std::vector<Expression*> args;
- for (auto type : func->params) {
+ for (auto type : targetFn->params) {
args.push_back(make(type));
}
- func->type = ensureFunctionType(getSig(func), &wasm)->name;
- return builder.makeCallIndirect(func->type, target, args, func->result);
+ targetFn->type = ensureFunctionType(getSig(targetFn), &wasm)->name;
+ return builder.makeCallIndirect(
+ targetFn->type, target, args, targetFn->result, isReturn);
}
Expression* makeLocalGet(Type type) {