diff options
author | Alon Zakai <azakai@google.com> | 2021-12-07 17:12:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 01:12:42 +0000 |
commit | 3b16999a77640b945d6f85201d843a76659ff635 (patch) | |
tree | 5e89e8f7cbcd15981b7a1cc58d6eb45eb9931790 /src/ir/effects.h | |
parent | 756f90b4bb91e842ca8c49f30062c4b7af97010d (diff) | |
download | binaryen-3b16999a77640b945d6f85201d843a76659ff635.tar.gz binaryen-3b16999a77640b945d6f85201d843a76659ff635.tar.bz2 binaryen-3b16999a77640b945d6f85201d843a76659ff635.zip |
Do not track effects of immutable things (#4376)
We don't use those effects now in any way, and if we need them some day
we can add them back. For now they just add overhead and complexity.
Diffstat (limited to 'src/ir/effects.h')
-rw-r--r-- | src/ir/effects.h | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index 808693e95..2bce174ef 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -72,7 +72,6 @@ public: std::set<Index> localsRead; std::set<Index> localsWritten; std::set<Name> mutableGlobalsRead; - std::set<Name> immutableGlobalsRead; std::set<Name> globalsWritten; bool readsMemory = false; bool writesMemory = false; @@ -81,7 +80,6 @@ public: // TODO: More specific type-based alias analysis, and not just at the // struct/array level. bool readsMutableStruct = false; - bool readsImmutableStruct = false; bool writesStruct = false; bool readsArray = false; bool writesArray = false; @@ -132,17 +130,11 @@ public: bool accessesMutableGlobal() const { return globalsWritten.size() + mutableGlobalsRead.size() > 0; } - bool accessesGlobal() const { - return accessesMutableGlobal() + immutableGlobalsRead.size() > 0; - } bool accessesMemory() const { return calls || readsMemory || writesMemory; } bool accessesTable() const { return calls || readsTable || writesTable; } bool accessesMutableStruct() const { return calls || readsMutableStruct || writesStruct; } - bool accessesStruct() const { - return accessesMutableStruct() || readsImmutableStruct; - } bool accessesArray() const { return calls || readsArray || writesArray; } bool throws() const { return throws_ || !delegateTargets.empty(); } // Check whether this may transfer control flow to somewhere outside of this @@ -199,7 +191,7 @@ public: bool hasAnything() const { return hasSideEffects() || accessesLocal() || readsMemory || readsTable || - accessesGlobal(); + accessesMutableGlobal(); } // check if we break to anything external from ourselves @@ -280,7 +272,6 @@ public: readsTable = readsTable || other.readsTable; writesTable = writesTable || other.writesTable; readsMutableStruct = readsMutableStruct || other.readsMutableStruct; - readsImmutableStruct = readsImmutableStruct || other.readsImmutableStruct; writesStruct = writesStruct || other.writesStruct; readsArray = readsArray || other.readsArray; writesArray = writesArray || other.writesArray; @@ -299,9 +290,6 @@ public: for (auto i : other.mutableGlobalsRead) { mutableGlobalsRead.insert(i); } - for (auto i : other.immutableGlobalsRead) { - immutableGlobalsRead.insert(i); - } for (auto i : other.globalsWritten) { globalsWritten.insert(i); } @@ -470,8 +458,6 @@ private: void visitGlobalGet(GlobalGet* curr) { if (parent.module.getGlobal(curr->name)->mutable_ == Mutable) { parent.mutableGlobalsRead.insert(curr->name); - } else { - parent.immutableGlobalsRead.insert(curr->name); } } void visitGlobalSet(GlobalSet* curr) { @@ -705,8 +691,6 @@ private: .fields[curr->index] .mutable_ == Mutable) { parent.readsMutableStruct = true; - } else { - parent.readsImmutableStruct = true; } // traps when the arg is null if (curr->ref->type.isNullable()) { @@ -805,7 +789,7 @@ public: if (localsWritten.size() > 0) { effects |= SideEffects::WritesLocal; } - if (mutableGlobalsRead.size() + immutableGlobalsRead.size() > 0) { + if (mutableGlobalsRead.size()) { effects |= SideEffects::ReadsGlobal; } if (globalsWritten.size() > 0) { |