summaryrefslogtreecommitdiff
path: root/src/tools/wasm-opt.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2022-12-16 15:12:14 -0600
committerGitHub <noreply@github.com>2022-12-16 13:12:14 -0800
commit6adc3aeee21391849ad2f2a6f2508cb9ab9e58c3 (patch)
treecf05292646339b1becd006ae7d9f5f832b5de8a3 /src/tools/wasm-opt.cpp
parent960f3844f339394feba032f1875adb9e46739453 (diff)
downloadbinaryen-6adc3aeee21391849ad2f2a6f2508cb9ab9e58c3.tar.gz
binaryen-6adc3aeee21391849ad2f2a6f2508cb9ab9e58c3.tar.bz2
binaryen-6adc3aeee21391849ad2f2a6f2508cb9ab9e58c3.zip
Do not optimize public types (#5347)
Do not optimize or modify public heap types in any way. Public heap types include the types of imported or exported functions, tables, globals, etc. This is important to maintain the public interface of a module and ensure it can still link interact as intended with the outside world. Also add validation error if we find any nontrivial public types that are not the types of imported or exported functions. This error is meant to help the user ensure that type optimizations are not silently inhibited. In the future, we may want to add options to silence this error or downgrade it to a warning. This commit only updates the type updating machinery to avoid updating public types. It does not update any optimization passes accordingly. Since we avoid modifying public signature types already, this is not expected to break anything, but in the future once we have function subtyping or if we make the error optional, we may have to update some of our optimization passes.
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r--src/tools/wasm-opt.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 8f958f164..0d279dc08 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -295,7 +295,7 @@ int main(int argc, const char* argv[]) {
}
if (options.passOptions.validate) {
- if (!WasmValidator().validate(wasm)) {
+ if (!WasmValidator().validate(wasm, options.passOptions)) {
exitOnInvalidWasm("error validating input");
}
}
@@ -309,7 +309,7 @@ int main(int argc, const char* argv[]) {
reader.setAllowOOB(fuzzOOB);
reader.build();
if (options.passOptions.validate) {
- if (!WasmValidator().validate(wasm)) {
+ if (!WasmValidator().validate(wasm, options.passOptions)) {
std::cout << wasm << '\n';
Fatal() << "error after translate-to-fuzz";
}
@@ -368,7 +368,7 @@ int main(int argc, const char* argv[]) {
auto runPasses = [&]() {
options.runPasses(wasm);
if (options.passOptions.validate) {
- bool valid = WasmValidator().validate(wasm);
+ bool valid = WasmValidator().validate(wasm, options.passOptions);
if (!valid) {
exitOnInvalidWasm("error after opts");
}