summaryrefslogtreecommitdiff
path: root/src/passes/pass.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-02-08 10:38:51 -0800
committerGitHub <noreply@github.com>2024-02-08 10:38:51 -0800
commit6e1e53f093a92177405d59a6733bfe3e57a5b877 (patch)
tree14bff269d7af7b5cf3a86b8179152d09df025976 /src/passes/pass.cpp
parentf172920b90f9745494c2efeb1696468fa26be506 (diff)
downloadbinaryen-6e1e53f093a92177405d59a6733bfe3e57a5b877.tar.gz
binaryen-6e1e53f093a92177405d59a6733bfe3e57a5b877.tar.bz2
binaryen-6e1e53f093a92177405d59a6733bfe3e57a5b877.zip
Add a pass to propagate global constants to other globals (#6287)
SimplifyGlobals already does this, so this is a subset of that pass, and does not add anything new. It is useful for testing, however. In particular it allows testing that we propagate subsequent globals in a single pass, that is if one global reads from another and becomes constant, then it can be propagated as well. SimplifyGlobals runs multiple passes so this always worked, but with this pass we can test that we do it efficiently in one pass. This will also be useful for comparing stringref to imported strings, as it allows gathered strings to be propagated to other globals (possible with stringref, but not imported strings) but not anywhere else (which might have downsides as it could lead to more allocations). Also add an additional test for simplify-globals that we do not get confused by an unoptimizable global.get in the middle (see last part).
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r--src/passes/pass.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index c00a5e706..1fe81cbfc 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -369,6 +369,9 @@ void PassRegistry::registerPasses() {
registerPass("print-stack-ir",
"print out Stack IR (useful for internal debugging)",
createPrintStackIRPass);
+ registerPass("propagate-globals-globally",
+ "propagate global values to other globals (useful for tests)",
+ createPropagateGlobalsGloballyPass);
registerPass("remove-non-js-ops",
"removes operations incompatible with js",
createRemoveNonJSOpsPass);