diff options
author | Alon Zakai <azakai@google.com> | 2021-02-08 19:36:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 11:36:36 -0800 |
commit | d4e31719c6609e121d5bb6758e1b9d3335113755 (patch) | |
tree | f6e18755edcc7bab09bde056e3812caa549c99e0 /src | |
parent | 3be78fdd2f8e673457d93f3c7bfb341f8074d298 (diff) | |
download | binaryen-d4e31719c6609e121d5bb6758e1b9d3335113755.tar.gz binaryen-d4e31719c6609e121d5bb6758e1b9d3335113755.tar.bz2 binaryen-d4e31719c6609e121d5bb6758e1b9d3335113755.zip |
[GC] Avoid replacing non-defaultable types in the fuzzer (#3549)
We can't arbitrarily replace a non-defaultable type, as it may lead to us
needing a temp local for it (say, in a tuple).
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 4150ac725..66f175414 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -723,6 +723,14 @@ private: builder.makeSequence(makeHangLimitCheck(), func->body, func->sig.results); } + // Recombination and mutation can replace a node with another node of the same + // type, but should not do so for certain types that are dangerous. For + // example, it would be bad to add an RTT in a tuple, as that would force us + // to use temporary locals for the tuple, but RTTs are not defaultable. + bool canBeArbitrarilyReplaced(Expression* curr) { + return curr->type.isDefaultable(); + } + void recombine(Function* func) { // Don't always do this. if (oneIn(2)) { @@ -776,7 +784,7 @@ private: : wasm(wasm), scanner(scanner), parent(parent) {} void visitExpression(Expression* curr) { - if (parent.oneIn(10)) { + if (parent.oneIn(10) && parent.canBeArbitrarilyReplaced(curr)) { // Replace it! auto& candidates = scanner.exprsByType[curr->type]; assert(!candidates.empty()); // this expression itself must be there @@ -803,7 +811,7 @@ private: : wasm(wasm), parent(parent) {} void visitExpression(Expression* curr) { - if (parent.oneIn(10)) { + if (parent.oneIn(10) && parent.canBeArbitrarilyReplaced(curr)) { // For constants, perform only a small tweaking in some cases. if (auto* c = curr->dynCast<Const>()) { if (parent.oneIn(2)) { |