summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-08-28 14:53:00 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-08-28 14:53:00 -0700
commit2d9e5a1c60a41e747956880ab199955b8f12d53c (patch)
treed6b23811890682bfd79d498372fdab147d03bd96 /src
parentd199aafed128cdf52de229aba4cf4c6769929e71 (diff)
downloadbinaryen-2d9e5a1c60a41e747956880ab199955b8f12d53c.tar.gz
binaryen-2d9e5a1c60a41e747956880ab199955b8f12d53c.tar.bz2
binaryen-2d9e5a1c60a41e747956880ab199955b8f12d53c.zip
improve fuzzing of functions with unreachable body
Diffstat (limited to 'src')
-rw-r--r--src/tools/translate-to-fuzz.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/translate-to-fuzz.h b/src/tools/translate-to-fuzz.h
index 307604af6..74a457013 100644
--- a/src/tools/translate-to-fuzz.h
+++ b/src/tools/translate-to-fuzz.h
@@ -259,16 +259,16 @@ private:
labelIndex = 0;
assert(breakableStack.empty());
assert(hangStack.empty());
+ // with small chance, make the body unreachable
+ auto bodyType = func->result;
+ if (oneIn(10)) {
+ bodyType = unreachable;
+ }
// with reasonable chance make the body a block
if (oneIn(2)) {
- func->body = makeBlock(func->result);
+ func->body = makeBlock(bodyType);
} else {
- // with very small chance, make the body unreachable
- if (oneIn(20)) {
- func->body = make(unreachable);
- } else {
- func->body = make(func->result);
- }
+ func->body = make(bodyType);
}
if (HANG_LIMIT > 0) {
func->body = builder.makeSequence(