diff options
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 9 | ||||
-rw-r--r-- | test/passes/translate-to-fuzz_all-features_metrics_noprint.txt | 60 |
2 files changed, 38 insertions, 31 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. diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index 24943eddd..e31cbc364 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,6 +1,6 @@ total - [exports] : 6 - [funcs] : 13 + [exports] : 8 + [funcs] : 16 [globals] : 5 [imports] : 5 [memories] : 1 @@ -8,36 +8,34 @@ total [table-data] : 3 [tables] : 1 [tags] : 1 - [total] : 558 + [total] : 653 [vars] : 36 - ArrayNew : 7 - ArrayNewFixed : 3 - AtomicCmpxchg : 1 - AtomicNotify : 1 - Binary : 70 - Block : 73 - Break : 2 - Call : 21 - CallRef : 1 - Const : 120 - Drop : 9 - GlobalGet : 34 - GlobalSet : 34 + ArrayNew : 8 + ArrayNewFixed : 4 + Binary : 76 + Block : 90 + Break : 3 + Call : 25 + CallRef : 3 + Const : 134 + Drop : 11 + GlobalGet : 40 + GlobalSet : 40 I31New : 1 - If : 22 - Load : 18 - LocalGet : 38 - LocalSet : 19 - Loop : 5 - Nop : 5 - RefAs : 1 - RefFunc : 8 + If : 26 + Load : 19 + LocalGet : 43 + LocalSet : 21 + Loop : 6 + Nop : 11 + RefFunc : 13 RefNull : 4 - Return : 5 + Return : 3 SIMDExtract : 1 - Select : 2 - StructNew : 6 - TupleExtract : 3 - TupleMake : 6 - Unary : 20 - Unreachable : 18 + Select : 4 + Store : 2 + StructNew : 9 + TupleExtract : 2 + TupleMake : 5 + Unary : 27 + Unreachable : 22 |