diff options
author | Heejin Ahn <aheejin@gmail.com> | 2022-01-04 12:39:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 12:39:38 -0800 |
commit | 16ac2eb73a57eb530f78b632cffacac97c6b8fdd (patch) | |
tree | 81e0945bbb828b880f8292647c21318c600b783c /src/tools/fuzzing/fuzzing.cpp | |
parent | 28665b1d8f0632216ceb2de475560c64dc260b9d (diff) | |
download | binaryen-16ac2eb73a57eb530f78b632cffacac97c6b8fdd.tar.gz binaryen-16ac2eb73a57eb530f78b632cffacac97c6b8fdd.tar.bz2 binaryen-16ac2eb73a57eb530f78b632cffacac97c6b8fdd.zip |
[EH] Enable fuzzer with initial contents (#4409)
This enables fuzzing EH with initial contents. fuzzing.cpp/h does not
yet support generation of EH instructions, but with this we can still
fuzz EH based on initial contents.
The fuzzer ran successfully for more than 1,900,000 iterations, with my
local modification that always enables EH and lets the fuzzer select
only EH tests for its initial contents.
Diffstat (limited to 'src/tools/fuzzing/fuzzing.cpp')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 8194c52d3..a41e6704e 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -581,14 +581,18 @@ void TranslateToFuzzReader::recombine(Function* func) { // First, scan and group all expressions by type. struct Scanner : public PostWalker<Scanner, UnifiedExpressionVisitor<Scanner>> { + TranslateToFuzzReader& parent; // A map of all expressions, categorized by type. InsertOrderedMap<Type, std::vector<Expression*>> exprsByType; + Scanner(TranslateToFuzzReader& parent) : parent(parent) {} void visitExpression(Expression* curr) { - exprsByType[curr->type].push_back(curr); + if (parent.canBeArbitrarilyReplaced(curr)) { + exprsByType[curr->type].push_back(curr); + } } }; - Scanner scanner; + Scanner scanner(*this); scanner.walk(func->body); // Potentially trim the list of possible picks, so replacements are more // likely to collide. |