summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-24 09:56:23 -0700
committerGitHub <noreply@github.com>2022-08-24 09:56:23 -0700
commit892ebbe8a11417d0ffd3a5c798fb8bdab89d6634 (patch)
tree0c4b30aee02211a9ded29358db765f45e5424c28
parent594ff7b9609656edb83187cb4600b23b3f2fde37 (diff)
downloadbinaryen-892ebbe8a11417d0ffd3a5c798fb8bdab89d6634.tar.gz
binaryen-892ebbe8a11417d0ffd3a5c798fb8bdab89d6634.tar.bz2
binaryen-892ebbe8a11417d0ffd3a5c798fb8bdab89d6634.zip
Fuzzer simplification: Remove trap-ignoring logic (#4958)
The "ignore trap" logic there is not close to enough for what we'd need to actually fuzz in a way that ignores traps, so this removes it. Atm that logic just allows a trap to happen without causing an error (that is, when comparing two results, one might trap and the other not, but they'd still be considered "equal"). But due to how we optimize traps in TrapsNeverHappens mode, the optimizer is free to assume the trap never occurs, which might remove side effects that are noticeable later. To actually handle that, we'd need to refactor the code to retain results per function (including the Loggings) and then to ignore everything from the very first trapping function. That is somewhat complicated to do, and a simpler thing is done in #4936, so we won't need it here.
-rw-r--r--src/tools/execution-results.h17
-rw-r--r--src/tools/wasm-opt.cpp2
-rw-r--r--test/lit/exec/trap.wast55
3 files changed, 3 insertions, 71 deletions
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h
index 10e243287..2491fbf1b 100644
--- a/src/tools/execution-results.h
+++ b/src/tools/execution-results.h
@@ -95,12 +95,6 @@ struct ExecutionResults {
// If set, we should ignore this and not compare it to anything.
bool ignore = false;
- // If set, we don't compare whether a trap has occurred or not.
- bool ignoreTrap = false;
-
- ExecutionResults(const PassOptions& options)
- : ignoreTrap(options.ignoreImplicitTraps || options.trapsNeverHappen) {}
- ExecutionResults(bool ignoreTrap) : ignoreTrap(ignoreTrap) {}
// get results of execution
void get(Module& wasm) {
@@ -140,7 +134,7 @@ struct ExecutionResults {
// get current results and check them against previous ones
void check(Module& wasm) {
- ExecutionResults optimizedResults(ignoreTrap);
+ ExecutionResults optimizedResults;
optimizedResults.get(wasm);
if (optimizedResults != *this) {
std::cout << "[fuzz-exec] optimization passes changed results\n";
@@ -202,14 +196,7 @@ struct ExecutionResults {
}
std::cout << "[fuzz-exec] comparing " << name << '\n';
if (results[name].index() != other.results[name].index()) {
- if (ignoreTrap) {
- if (!std::get_if<Trap>(&results[name]) &&
- !std::get_if<Trap>(&other.results[name])) {
- return false;
- }
- } else {
- return false;
- }
+ return false;
}
auto* values = std::get_if<Literals>(&results[name]);
auto* otherValues = std::get_if<Literals>(&other.results[name]);
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 3927e513c..538496ecf 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -314,7 +314,7 @@ int main(int argc, const char* argv[]) {
runner.run();
}
- ExecutionResults results(options.passOptions);
+ ExecutionResults results;
if (fuzzExecBefore) {
results.get(wasm);
}
diff --git a/test/lit/exec/trap.wast b/test/lit/exec/trap.wast
deleted file mode 100644
index a0ed6f0f2..000000000
--- a/test/lit/exec/trap.wast
+++ /dev/null
@@ -1,55 +0,0 @@
-;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
-
-;; RUN: wasm-opt %s --vacuum --fuzz-exec -q -o /dev/null 2>&1 | filecheck %s
-;; RUN: wasm-opt %s --ignore-implicit-traps --vacuum --fuzz-exec -q -o /dev/null 2>&1 | filecheck %s --check-prefix=IIT
-;; RUN: wasm-opt %s --traps-never-happen --vacuum --fuzz-exec -q -o /dev/null 2>&1 | filecheck %s --check-prefix=TNH
-
-(module
- ;; CHECK: [fuzz-exec] calling trap
- ;; CHECK-NEXT: [trap unreachable]
- ;; IIT: [fuzz-exec] calling trap
- ;; IIT-NEXT: [trap unreachable]
- ;; TNH: [fuzz-exec] calling trap
- ;; TNH-NEXT: [trap unreachable]
- (func "trap"
- (unreachable)
- )
-
- (memory 1 1)
- ;; CHECK: [fuzz-exec] calling load-trap
- ;; CHECK-NEXT: [trap highest > memory: 65536 > 65532]
- ;; IIT: [fuzz-exec] calling load-trap
- ;; IIT-NEXT: [trap highest > memory: 65536 > 65532]
- ;; TNH: [fuzz-exec] calling load-trap
- ;; TNH-NEXT: [trap highest > memory: 65536 > 65532]
- (func "load-trap"
- ;; This load traps, so this cannot be removed. But if either of
- ;; --ignore-implicit-traps or --traps-never-happen is set, this load is
- ;; assumed not to trap and we end up optimizing this out with --vacuum,
- ;; causes the trap behavior to change. This should not result in [fuzz-exec]
- ;; comparison failure.
- (drop
- (i32.load (i32.const 65536))
- )
- )
-)
-;; CHECK: [fuzz-exec] calling trap
-;; CHECK-NEXT: [trap unreachable]
-
-;; CHECK: [fuzz-exec] calling load-trap
-;; CHECK-NEXT: [trap highest > memory: 65536 > 65532]
-;; CHECK-NEXT: [fuzz-exec] comparing load-trap
-;; CHECK-NEXT: [fuzz-exec] comparing trap
-
-;; IIT: [fuzz-exec] calling trap
-;; IIT-NEXT: [trap unreachable]
-
-;; IIT: [fuzz-exec] calling load-trap
-;; IIT-NEXT: [fuzz-exec] comparing load-trap
-;; IIT-NEXT: [fuzz-exec] comparing trap
-
-;; TNH: [fuzz-exec] calling trap
-
-;; TNH: [fuzz-exec] calling load-trap
-;; TNH-NEXT: [fuzz-exec] comparing load-trap
-;; TNH-NEXT: [fuzz-exec] comparing trap