diff options
author | Alon Zakai <azakai@google.com> | 2023-03-01 10:06:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 10:06:09 -0800 |
commit | 702b48f80dcc5f83548c8f461cf75bfe0a318997 (patch) | |
tree | 06944b84cb09ba2eb3a9b7bb8b0acf8e3f26e080 /src | |
parent | 059622228659fbf59dd82363fd16323725288de1 (diff) | |
download | binaryen-702b48f80dcc5f83548c8f461cf75bfe0a318997.tar.gz binaryen-702b48f80dcc5f83548c8f461cf75bfe0a318997.tar.bz2 binaryen-702b48f80dcc5f83548c8f461cf75bfe0a318997.zip |
Fuzzer: Only use RefAs in a function context (#5533)
It is not a constant instruction and cannot be used in globals.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 03ee7d376..d3539a51b 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -1974,7 +1974,8 @@ Expression* TranslateToFuzzReader::makeRefFuncConst(Type type) { // but only rarely if the type is non-nullable (because in that case we'd need // to add a ref.as_non_null to validate, and the code will trap when we get // here). - if ((type.isNullable() && oneIn(2)) || (type.isNonNullable() && oneIn(16))) { + if ((type.isNullable() && oneIn(2)) || + (type.isNonNullable() && oneIn(16) && funcContext)) { Expression* ret = builder.makeRefNull(HeapType::nofunc); if (!type.isNullable()) { ret = builder.makeRefAs(RefAsNonNull, ret); @@ -2155,6 +2156,7 @@ Expression* TranslateToFuzzReader::makeConstCompoundRef(Type type) { })) { // There is a nondefaultable field, which we must create. for (auto& field : fields) { + // TODO: when in a function context, we don't need to be trivial. values.push_back(makeTrivial(field.type)); } } @@ -2163,6 +2165,7 @@ Expression* TranslateToFuzzReader::makeConstCompoundRef(Type type) { auto element = heapType.getArray().element; Expression* init = nullptr; if (!element.type.isDefaultable()) { + // TODO: when in a function context, we don't need to be trivial. init = makeTrivial(element.type); } return builder.makeArrayNew(type.getHeapType(), makeConst(Type::i32), init); |