diff options
author | Alon Zakai <azakai@google.com> | 2024-02-07 17:20:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-07 17:20:22 -0800 |
commit | 4e0796d022fcd48c8af5a8a709577ce495bca991 (patch) | |
tree | 8ca814907b2719379f65b7592d78487feb81aaa7 /src | |
parent | d4c3fddd3de605983398756d3b46e2f14e55aba2 (diff) | |
download | binaryen-4e0796d022fcd48c8af5a8a709577ce495bca991.tar.gz binaryen-4e0796d022fcd48c8af5a8a709577ce495bca991.tar.bz2 binaryen-4e0796d022fcd48c8af5a8a709577ce495bca991.zip |
SimplifyGlobals: Propagate constant globals into nested gets in other globals (#6285)
Before we propagated to the top level, but not to anything interior.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/SimplifyGlobals.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/passes/SimplifyGlobals.cpp b/src/passes/SimplifyGlobals.cpp index 3baec4409..323ebd6a7 100644 --- a/src/passes/SimplifyGlobals.cpp +++ b/src/passes/SimplifyGlobals.cpp @@ -41,6 +41,7 @@ #include <atomic> #include "ir/effects.h" +#include "ir/find_all.h" #include "ir/linear-execution.h" #include "ir/properties.h" #include "ir/utils.h" @@ -659,10 +660,11 @@ struct SimplifyGlobals : public Pass { // This is the init of a passive segment, which is null. return; } - if (auto* get = init->dynCast<GlobalGet>()) { + for (auto** getp : FindAllPointers<GlobalGet>(init).list) { + auto* get = (*getp)->cast<GlobalGet>(); auto iter = constantGlobals.find(get->name); if (iter != constantGlobals.end()) { - init = builder.makeConstantExpression(iter->second); + *getp = builder.makeConstantExpression(iter->second); } } }; |