summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-07-10 12:15:22 -0700
committerGitHub <noreply@github.com>2024-07-10 12:15:22 -0700
commit37a86d558994415e722e7f62f5784b1a8b8b4832 (patch)
tree282342051d33146bbda303ef97587b652b148d6a /src
parent76f661203f98820ebc6840ecf627a5eafc038403 (diff)
downloadbinaryen-37a86d558994415e722e7f62f5784b1a8b8b4832.tar.gz
binaryen-37a86d558994415e722e7f62f5784b1a8b8b4832.tar.bz2
binaryen-37a86d558994415e722e7f62f5784b1a8b8b4832.zip
[StackIR] Allow StackIR to be disabled from the commandline (#6725)
Normally we use it when optimizing (above a certain level). This lets the user prevent it from being used even then. Also add optimization options to wasm-metadce so that this is possible there as well and not just in wasm-opt (this also opens the door to running more passes in metadce, which may be useful later).
Diffstat (limited to 'src')
-rw-r--r--src/tools/optimization-options.h17
-rw-r--r--src/tools/wasm-metadce.cpp4
2 files changed, 18 insertions, 3 deletions
diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h
index 8772edd29..af468769d 100644
--- a/src/tools/optimization-options.h
+++ b/src/tools/optimization-options.h
@@ -26,12 +26,17 @@
namespace wasm {
struct OptimizationOptions : public ToolOptions {
+ // By default we allow StackIR and enable it by default in higher optimization
+ // levels, but users can disallow it as well.
+ bool allowStackIR = true;
+
void parse(int argc, const char* argv[]) {
ToolOptions::parse(argc, argv);
// After parsing the arguments, update defaults based on the optimize/shrink
// levels.
- if (passOptions.optimizeLevel >= 2 || passOptions.shrinkLevel >= 1) {
+ if (allowStackIR &&
+ (passOptions.optimizeLevel >= 2 || passOptions.shrinkLevel >= 1)) {
passOptions.generateStackIR = true;
passOptions.optimizeStackIR = true;
}
@@ -191,6 +196,16 @@ struct OptimizationOptions : public ToolOptions {
[&](Options* o, const std::string& arguments) {
passOptions.debugInfo = true;
})
+ .add("--no-stack-ir",
+ "",
+ "do not use StackIR (even when it is the default)",
+ ToolOptionsCategory,
+ Options::Arguments::Zero,
+ [&](Options* o, const std::string& arguments) {
+ allowStackIR = false;
+ passOptions.generateStackIR = false;
+ passOptions.optimizeStackIR = false;
+ })
.add("--always-inline-max-function-size",
"-aimfs",
"Max size of functions that are always inlined (default " +
diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp
index 301470206..9cc06375e 100644
--- a/src/tools/wasm-metadce.cpp
+++ b/src/tools/wasm-metadce.cpp
@@ -29,11 +29,11 @@
#include "asmjs/shared-constants.h"
#include "ir/element-utils.h"
#include "ir/module-utils.h"
+#include "optimization-options.h"
#include "pass.h"
#include "support/colors.h"
#include "support/file.h"
#include "support/json.h"
-#include "tool-options.h"
#include "wasm-builder.h"
#include "wasm-io.h"
#include "wasm-validator.h"
@@ -371,7 +371,7 @@ int main(int argc, const char* argv[]) {
const std::string WasmMetaDCEOption = "wasm-opt options";
- ToolOptions options(
+ OptimizationOptions options(
"wasm-metadce",
"This tool performs dead code elimination (DCE) on a larger space "
"that the wasm module is just a part of. For example, if you have "