summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-12 14:29:12 -0700
committerGitHub <noreply@github.com>2022-08-12 14:29:12 -0700
commit6c6aae1358d657fe16fcfdc3a0eccfcea66cc841 (patch)
tree2fc4a82526e88b056d5854c02dce19200b0bfe1b /src/wasm/wasm-validator.cpp
parent48d5a5d529cf3e51605a5e50a746603b74a72e97 (diff)
downloadbinaryen-6c6aae1358d657fe16fcfdc3a0eccfcea66cc841.tar.gz
binaryen-6c6aae1358d657fe16fcfdc3a0eccfcea66cc841.tar.bz2
binaryen-6c6aae1358d657fe16fcfdc3a0eccfcea66cc841.zip
Function-level pass-debug mode 2 validation (#4897)
In BINARYEN_PASS_DEBUG=2 we save the module before each pass, and if validation fails afterwards, we print the module before. This PR does the same for function-parallel passes - in that case, we can actually show the specific function that broke validation, as opposed to the whole module.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 10310f8c0..572a3b4ba 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -223,6 +223,9 @@ struct FunctionValidator : public WalkerPass<PostWalker<FunctionValidator>> {
// Validate a specific expression.
void validate(Expression* curr) { walk(curr); }
+ // Validate a function.
+ void validate(Function* func) { walkFunction(func); }
+
std::unordered_map<Name, std::unordered_set<Type>> breakTypes;
std::unordered_set<Name> delegateTargetNames;
std::unordered_set<Name> rethrowTargetNames;
@@ -3215,4 +3218,18 @@ bool WasmValidator::validate(Module& module, Flags flags) {
return info.valid.load();
}
+bool WasmValidator::validate(Function* func, Module& module, Flags flags) {
+ ValidationInfo info(module);
+ info.validateWeb = (flags & Web) != 0;
+ info.validateGlobally = (flags & Globally) != 0;
+ info.quiet = (flags & Quiet) != 0;
+ FunctionValidator(module, &info).validate(func);
+ // print all the data
+ if (!info.valid.load() && !info.quiet) {
+ std::cerr << info.getStream(func).str();
+ std::cerr << info.getStream(nullptr).str();
+ }
+ return info.valid.load();
+}
+
} // namespace wasm