summaryrefslogtreecommitdiff
path: root/src/passes/SafeHeap.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-04-10 10:16:57 -0700
committerGitHub <noreply@github.com>2019-04-10 10:16:57 -0700
commit7cc509f54a759034fbff57fae64e142ad15cc097 (patch)
tree9311e086d02a645707dbb5692119a5450e52b6c6 /src/passes/SafeHeap.cpp
parentb13db5a0bc1170494ba845ab66129a506b251fde (diff)
downloadbinaryen-7cc509f54a759034fbff57fae64e142ad15cc097.tar.gz
binaryen-7cc509f54a759034fbff57fae64e142ad15cc097.tar.bz2
binaryen-7cc509f54a759034fbff57fae64e142ad15cc097.zip
Fuzz fixes (#1991)
Get fuzzer to attempt to create almost all features. Pass v8 all the flags to allow that. Fix fuzz bugs where we read signed_ even when it was irrelevant for that type of load. Improve wasm-reduce on fuzz testcases, try to replace a node with drops of its children, not just the children themselves.
Diffstat (limited to 'src/passes/SafeHeap.cpp')
-rw-r--r--src/passes/SafeHeap.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp
index 3cc1021ed..852af0c16 100644
--- a/src/passes/SafeHeap.cpp
+++ b/src/passes/SafeHeap.cpp
@@ -28,6 +28,7 @@
#include "ir/bits.h"
#include "ir/function-type-utils.h"
#include "ir/import-utils.h"
+#include "ir/load-utils.h"
namespace wasm {
@@ -39,7 +40,7 @@ static Name getLoadName(Load* curr) {
std::string ret = "SAFE_HEAP_LOAD_";
ret += printType(curr->type);
ret += "_" + std::to_string(curr->bytes) + "_";
- if (!isFloatType(curr->type) && !curr->signed_) {
+ if (LoadUtils::isSignRelevant(curr) && !curr->signed_) {
ret += "U_";
}
if (curr->isAtomic) {
@@ -219,8 +220,10 @@ struct SafeHeap : public Pass {
// creates a function for a particular style of load
void addLoadFunc(Load style, Module* module) {
+ auto name = getLoadName(&style);
+ if (module->getFunctionOrNull(name)) return;
auto* func = new Function;
- func->name = getLoadName(&style);
+ func->name = name;
func->params.push_back(i32); // pointer
func->params.push_back(i32); // offset
func->vars.push_back(i32); // pointer + offset
@@ -265,8 +268,10 @@ struct SafeHeap : public Pass {
// creates a function for a particular type of store
void addStoreFunc(Store style, Module* module) {
+ auto name = getStoreName(&style);
+ if (module->getFunctionOrNull(name)) return;
auto* func = new Function;
- func->name = getStoreName(&style);
+ func->name = name;
func->params.push_back(i32); // pointer
func->params.push_back(i32); // offset
func->params.push_back(style.valueType); // value