From f3d59ea84e899f2b1cca9c1c7d23c80260b0df04 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 19 Aug 2017 08:13:56 -0700 Subject: 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 --- src/tools/translate-to-fuzz.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3