diff options
-rw-r--r-- | src/ir/LocalGraph.cpp | 18 | ||||
-rw-r--r-- | src/ir/local-graph.h | 8 | ||||
-rw-r--r-- | src/passes/MergeLocals.cpp | 2 | ||||
-rw-r--r-- | src/passes/OptimizeAddedConstants.cpp | 2 | ||||
-rw-r--r-- | src/passes/SSAify.cpp | 2 | ||||
-rw-r--r-- | src/passes/StackIR.cpp | 2 |
6 files changed, 23 insertions, 11 deletions
diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index 2fdf1e4a4..9deea9153 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -281,7 +281,18 @@ bool LocalGraph::equivalent(LocalGet* a, LocalGet* b) { } } -void LocalGraph::computeInfluences() { +void LocalGraph::computeSetInfluences() { + for (auto& pair : locations) { + auto* curr = pair.first; + if (auto* get = curr->dynCast<LocalGet>()) { + for (auto* set : getSetses[get]) { + setInfluences[set].insert(get); + } + } + } +} + +void LocalGraph::computeGetInfluences() { for (auto& pair : locations) { auto* curr = pair.first; if (auto* set = curr->dynCast<LocalSet>()) { @@ -289,11 +300,6 @@ void LocalGraph::computeInfluences() { for (auto* get : findAll.list) { getInfluences[get].insert(set); } - } else { - auto* get = curr->cast<LocalGet>(); - for (auto* set : getSetses[get]) { - setInfluences[set].insert(get); - } } } } diff --git a/src/ir/local-graph.h b/src/ir/local-graph.h index 9e63bb3a8..2e4fdf0fe 100644 --- a/src/ir/local-graph.h +++ b/src/ir/local-graph.h @@ -55,7 +55,13 @@ struct LocalGraph { // Optional: compute the influence graphs between sets and gets // (useful for algorithms that propagate changes). - void computeInfluences(); + void computeSetInfluences(); + void computeGetInfluences(); + + void computeInfluences() { + computeSetInfluences(); + computeGetInfluences(); + } // for each get, the sets whose values are influenced by that get std::unordered_map<LocalGet*, std::unordered_set<LocalSet*>> getInfluences; diff --git a/src/passes/MergeLocals.cpp b/src/passes/MergeLocals.cpp index 2b4b3efea..a55d81cf6 100644 --- a/src/passes/MergeLocals.cpp +++ b/src/passes/MergeLocals.cpp @@ -192,7 +192,7 @@ struct MergeLocals // the live range unless we are definitely removing a conflict, same // logic as before). LocalGraph postGraph(func); - postGraph.computeInfluences(); + postGraph.computeSetInfluences(); for (auto& pair : optimizedToCopy) { auto* copy = pair.first; auto* trivial = pair.second; diff --git a/src/passes/OptimizeAddedConstants.cpp b/src/passes/OptimizeAddedConstants.cpp index e5cbf108a..107b06ffb 100644 --- a/src/passes/OptimizeAddedConstants.cpp +++ b/src/passes/OptimizeAddedConstants.cpp @@ -277,7 +277,7 @@ struct OptimizeAddedConstants propagatable.clear(); if (propagate) { localGraph = make_unique<LocalGraph>(func); - localGraph->computeInfluences(); + localGraph->computeSetInfluences(); localGraph->computeSSAIndexes(); findPropagatable(); } diff --git a/src/passes/SSAify.cpp b/src/passes/SSAify.cpp index 9f330f7b3..07867b32d 100644 --- a/src/passes/SSAify.cpp +++ b/src/passes/SSAify.cpp @@ -90,7 +90,7 @@ struct SSAify : public Pass { module = module_; func = func_; LocalGraph graph(func); - graph.computeInfluences(); + graph.computeSetInfluences(); graph.computeSSAIndexes(); // create new local indexes, one for each set createNewIndexes(graph); diff --git a/src/passes/StackIR.cpp b/src/passes/StackIR.cpp index 6d163d897..fbb990fe0 100644 --- a/src/passes/StackIR.cpp +++ b/src/passes/StackIR.cpp @@ -112,7 +112,7 @@ private: // TODO: we can do this a lot faster, as we just care about linear // control flow. LocalGraph localGraph(func); - localGraph.computeInfluences(); + localGraph.computeSetInfluences(); // We maintain a stack of relevant values. This contains: // * a null for each actual value that the value stack would have // * an index of each LocalSet that *could* be on the value |