summaryrefslogtreecommitdiff
path: root/src/tools/translate-to-fuzz.h
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-08-19 08:13:56 -0700
committerAlon Zakai <alonzakai@gmail.com>2017-08-25 16:04:23 -0700
commitf3d59ea84e899f2b1cca9c1c7d23c80260b0df04 (patch)
tree80ff933fef02217d133a506c40fbb8d3539e80db /src/tools/translate-to-fuzz.h
parente0c5e9cd83f2bc27c8f1ca3cc9c6a5029c6641b2 (diff)
downloadbinaryen-f3d59ea84e899f2b1cca9c1c7d23c80260b0df04.tar.gz
binaryen-f3d59ea84e899f2b1cca9c1c7d23c80260b0df04.tar.bz2
binaryen-f3d59ea84e899f2b1cca9c1c7d23c80260b0df04.zip
add a chance to make a get_local in makeTrivial, so that hang-check returns etc. don't always return a constant, but may return the result of computation
Diffstat (limited to 'src/tools/translate-to-fuzz.h')
-rw-r--r--src/tools/translate-to-fuzz.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tools/translate-to-fuzz.h b/src/tools/translate-to-fuzz.h
index 36639ce84..307604af6 100644
--- a/src/tools/translate-to-fuzz.h
+++ b/src/tools/translate-to-fuzz.h
@@ -452,14 +452,20 @@ private:
// make something with no chance of infinite recursion
Expression* makeTrivial(WasmType type) {
if (isConcreteWasmType(type)) {
- return makeConst(type);
+ if (oneIn(2)) {
+ return makeGetLocal(type);
+ } else {
+ return makeConst(type);
+ }
} else if (type == none) {
return makeNop(type);
}
assert(type == unreachable);
- return builder.makeReturn(
- isConcreteWasmType(func->result) ? makeConst(func->result) : nullptr
- );
+ Expression* ret = nullptr;
+ if (isConcreteWasmType(func->result)) {
+ ret = makeTrivial(func->result);
+ }
+ return builder.makeReturn(ret);
}
// specific expression creators
@@ -650,7 +656,7 @@ private:
Expression* makeGetLocal(WasmType type) {
auto& locals = typeLocals[type];
- if (locals.empty()) return makeTrivial(type);
+ if (locals.empty()) return makeConst(type);
return builder.makeGetLocal(vectorPick(locals), type);
}