diff options
author | Alon Zakai <azakai@google.com> | 2023-03-15 13:57:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 13:57:01 -0700 |
commit | ffe4152320b4d72fbfc9c350abda922067ebec01 (patch) | |
tree | eaee024309d14faf9e12aa6815c7ce85b60350b5 /src/tools/fuzzing/fuzzing.cpp | |
parent | f093fce14259d5f73c61d8efe79086f2da57ed78 (diff) | |
download | binaryen-ffe4152320b4d72fbfc9c350abda922067ebec01.tar.gz binaryen-ffe4152320b4d72fbfc9c350abda922067ebec01.tar.bz2 binaryen-ffe4152320b4d72fbfc9c350abda922067ebec01.zip |
Fuzzer: Generate both immutable and mutable globals (#5575)
Diffstat (limited to 'src/tools/fuzzing/fuzzing.cpp')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 75eb3bd21..9beedc7fd 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -358,9 +358,13 @@ void TranslateToFuzzReader::setupGlobals() { type = getMVPType(); init = makeConst(type); } + auto mutability = oneIn(2) ? Builder::Mutable : Builder::Immutable; auto global = builder.makeGlobal( - Names::getValidGlobalName(wasm, "global$"), type, init, Builder::Mutable); + Names::getValidGlobalName(wasm, "global$"), type, init, mutability); globalsByType[type].push_back(global->name); + if (mutability == Builder::Mutable) { + mutableGlobalsByType[type].push_back(global->name); + } wasm.addGlobal(std::move(global)); } } @@ -1489,8 +1493,8 @@ Expression* TranslateToFuzzReader::makeGlobalGet(Type type) { Expression* TranslateToFuzzReader::makeGlobalSet(Type type) { assert(type == Type::none); type = getConcreteType(); - auto it = globalsByType.find(type); - if (it == globalsByType.end() || it->second.empty()) { + auto it = mutableGlobalsByType.find(type); + if (it == mutableGlobalsByType.end() || it->second.empty()) { return makeTrivial(Type::none); } auto name = pick(it->second); |