summaryrefslogtreecommitdiff
path: root/src/passes/MergeLocals.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-08-28 09:13:33 -0700
committerGitHub <noreply@github.com>2024-08-28 09:13:33 -0700
commit95ddd057424b996a0a2a54f282c6c567246d8cc9 (patch)
tree5fb5cf34c779f1cf9cb49208e470d557db91b177 /src/passes/MergeLocals.cpp
parente2ceaa58c10e9ee3e9eece42466243f5a8aff125 (diff)
downloadbinaryen-95ddd057424b996a0a2a54f282c6c567246d8cc9.tar.gz
binaryen-95ddd057424b996a0a2a54f282c6c567246d8cc9.tar.bz2
binaryen-95ddd057424b996a0a2a54f282c6c567246d8cc9.zip
[NFC] Refactor LocalGraph's core getSets API (#6877)
Before we just had a map that people would access with localGraph.getSetses[get], while now it is a call localGraph.getSets(get), which more nicely hides the internal implementation details. Also rename getSetses => getSetsMap. This will allow a later PR to optimize the internals of this API. This is performance-neutral as far as I can measure. (We do replace a direct read from a data structure with a call, but the call is in a header and should always get inlined.)
Diffstat (limited to 'src/passes/MergeLocals.cpp')
-rw-r--r--src/passes/MergeLocals.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/passes/MergeLocals.cpp b/src/passes/MergeLocals.cpp
index c43ec8534..b04215d73 100644
--- a/src/passes/MergeLocals.cpp
+++ b/src/passes/MergeLocals.cpp
@@ -123,9 +123,10 @@ struct MergeLocals
// however, it may depend on other writes too, if there is a
// merge/phi, and in that case we can't do anything
assert(influencedGet->index == trivial->index);
- if (preGraph.getSetses[influencedGet].size() == 1) {
+ auto& sets = preGraph.getSets(influencedGet);
+ if (sets.size() == 1) {
// this is ok
- assert(*preGraph.getSetses[influencedGet].begin() == trivial);
+ assert(*sets.begin() == trivial);
// If local types are different (when one is a subtype of the
// other), don't optimize
if (func->getLocalType(copy->index) != influencedGet->type) {
@@ -161,9 +162,10 @@ struct MergeLocals
for (auto* influencedGet : copyInfluences) {
// as above, avoid merges/phis
assert(influencedGet->index == copy->index);
- if (preGraph.getSetses[influencedGet].size() == 1) {
+ auto& sets = preGraph.getSets(influencedGet);
+ if (sets.size() == 1) {
// this is ok
- assert(*preGraph.getSetses[influencedGet].begin() == copy);
+ assert(*sets.begin() == copy);
// If local types are different (when one is a subtype of the
// other), don't optimize
if (func->getLocalType(trivial->index) != influencedGet->type) {
@@ -199,7 +201,7 @@ struct MergeLocals
auto& trivialInfluences = preGraph.setInfluences[trivial];
for (auto* influencedGet : trivialInfluences) {
// verify the set
- auto& sets = postGraph.getSetses[influencedGet];
+ auto& sets = postGraph.getSets(influencedGet);
if (sets.size() != 1 || *sets.begin() != copy) {
// not good, undo all the changes for this copy
for (auto* undo : trivialInfluences) {
@@ -213,7 +215,7 @@ struct MergeLocals
auto& copyInfluences = preGraph.setInfluences[copy];
for (auto* influencedGet : copyInfluences) {
// verify the set
- auto& sets = postGraph.getSetses[influencedGet];
+ auto& sets = postGraph.getSets(influencedGet);
if (sets.size() != 1 || *sets.begin() != trivial) {
// not good, undo all the changes for this copy
for (auto* undo : copyInfluences) {