diff options
author | Alon Zakai <azakai@google.com> | 2023-03-10 13:02:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 13:02:10 -0800 |
commit | 271312d06760eb3b1d8de1206cc6d00e2cf30d42 (patch) | |
tree | 72c5048df574ab9367a25c6e2802fd20e8297fb5 /src/tools/fuzzing/fuzzing.cpp | |
parent | f568b250e09d5c69cc855f1b9affc8346d736a73 (diff) | |
download | binaryen-271312d06760eb3b1d8de1206cc6d00e2cf30d42.tar.gz binaryen-271312d06760eb3b1d8de1206cc6d00e2cf30d42.tar.bz2 binaryen-271312d06760eb3b1d8de1206cc6d00e2cf30d42.zip |
Fuzzer: Emit fewer uninhabitable types in getSubType (#5563)
Only rarely return an uninhabitable subtype of an inhabitable one. This
avoids a major source of uninhabitability and immediate traps.
Diffstat (limited to 'src/tools/fuzzing/fuzzing.cpp')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 7d663641e..37f596b54 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -3333,6 +3333,15 @@ Type TranslateToFuzzReader::getSubType(Type type) { } else if (type.isRef()) { auto heapType = getSubType(type.getHeapType()); auto nullability = getSubType(type.getNullability()); + // We don't want to emit lots of uninhabitable types like (ref none), so + // avoid them with high probability. Specifically, if the original type was + // inhabitable then return that; avoid adding more uninhabitability. + auto uninhabitable = nullability == NonNullable && heapType.isBottom(); + auto originalUninhabitable = + type.isNonNullable() && type.getHeapType().isBottom(); + if (uninhabitable && !originalUninhabitable && !oneIn(20)) { + return type; + } return Type(heapType, nullability); } else { // This is an MVP type without subtypes. |