summaryrefslogtreecommitdiff
path: root/src/ir/local-graph.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-09-18 16:58:13 -0700
committerGitHub <noreply@github.com>2024-09-18 16:58:13 -0700
commitb285448a3f8f06123b5b6048efa4ff3d2a13e0a7 (patch)
tree489e532b28e680ccbd57e099cce24e85a577f754 /src/ir/local-graph.h
parente2ce099f7e85b506cb45d306ec7c89a237d2e7c6 (diff)
downloadbinaryen-b285448a3f8f06123b5b6048efa4ff3d2a13e0a7.tar.gz
binaryen-b285448a3f8f06123b5b6048efa4ff3d2a13e0a7.tar.bz2
binaryen-b285448a3f8f06123b5b6048efa4ff3d2a13e0a7.zip
[NFC] Add isSSA to LazyLocalGraph, and use it in OptimizeAddedConstants (#6952)
This makes the pass 15% faster.
Diffstat (limited to 'src/ir/local-graph.h')
-rw-r--r--src/ir/local-graph.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ir/local-graph.h b/src/ir/local-graph.h
index 6f1e621cf..7b8001be6 100644
--- a/src/ir/local-graph.h
+++ b/src/ir/local-graph.h
@@ -209,6 +209,16 @@ struct LazyLocalGraph : public LocalGraphBase {
}
return (*getInfluences)[get];
}
+ bool isSSA(Index index) const {
+ auto iter = SSAIndexes.find(index);
+ if (iter == SSAIndexes.end()) {
+ auto ret = computeSSA(index);
+ // The result must have been memoized.
+ assert(SSAIndexes.count(index));
+ return ret;
+ }
+ return iter->second;
+ }
const Locations& getLocations() const {
if (!locations) {
@@ -229,6 +239,9 @@ private:
// include sets of other indexes, so there is no simple way to lazify that
// computation.
mutable std::optional<GetInfluencesMap> getInfluences;
+ // A map if indexes to a bool indicating if the index is SSA. If there is no
+ // entry, it has not yet been computed.
+ mutable std::unordered_map<Index, bool> SSAIndexes;
mutable std::optional<Locations> locations;
// Compute the sets for a get and store them on getSetsMap.
@@ -237,6 +250,8 @@ private:
void computeSetInfluences(LocalSet* set) const;
// Compute influences for all gets and store them on getInfluences.
void computeGetInfluences() const;
+ // Compute whether an index is SSA and store that on SSAIndexes.
+ bool computeSSA(Index index) const;
// Compute locations and store them on getInfluences.
void computeLocations() const;