diff options
author | Ashley Nelson <nashley@google.com> | 2023-10-18 13:09:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 20:09:22 +0000 |
commit | ecb3eb3fdb9536472706c173d00b3379e3332469 (patch) | |
tree | 15b5250d06e998b1653d4131bd1515223f0a10ac /src/passes/hash-stringify-walker.cpp | |
parent | f50e933f639c24f3a5814980fb20e6f7e1435184 (diff) | |
download | binaryen-ecb3eb3fdb9536472706c173d00b3379e3332469.tar.gz binaryen-ecb3eb3fdb9536472706c173d00b3379e3332469.tar.bz2 binaryen-ecb3eb3fdb9536472706c173d00b3379e3332469.zip |
[Outlining] Filter branches & returns (#6024)
Adds a function to filter branch and return instructions from being included in potential outlining candidates.
Diffstat (limited to 'src/passes/hash-stringify-walker.cpp')
-rw-r--r-- | src/passes/hash-stringify-walker.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/passes/hash-stringify-walker.cpp b/src/passes/hash-stringify-walker.cpp index beae3bf44..abcd07162 100644 --- a/src/passes/hash-stringify-walker.cpp +++ b/src/passes/hash-stringify-walker.cpp @@ -82,7 +82,7 @@ void HashStringifyWalker::visitExpression(Expression* curr) { // repeats come first and 2) these are more worthwhile to keep than subsequent // substrings of substrings, even if they appear more times. std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::dedupe( - const std::vector<SuffixTree::RepeatedSubstring>&& substrings) { + const std::vector<SuffixTree::RepeatedSubstring>& substrings) { std::unordered_set<uint32_t> seen; std::vector<SuffixTree::RepeatedSubstring> result; for (auto substring : substrings) { @@ -111,7 +111,7 @@ std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::dedupe( } std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::filter( - const std::vector<SuffixTree::RepeatedSubstring>&& substrings, + const std::vector<SuffixTree::RepeatedSubstring>& substrings, const std::vector<Expression*> exprs, std::function<bool(const Expression*)> condition) { @@ -166,4 +166,21 @@ std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::filter( return result; } +std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::filterLocalSets( + const std::vector<SuffixTree::RepeatedSubstring>& substrings, + const std::vector<Expression*> exprs) { + return StringifyProcessor::filter( + substrings, exprs, [](const Expression* curr) { + return curr->is<LocalSet>(); + }); +} + +std::vector<SuffixTree::RepeatedSubstring> StringifyProcessor::filterBranches( + const std::vector<SuffixTree::RepeatedSubstring>& substrings, + const std::vector<Expression*> exprs) { + return StringifyProcessor::filter( + substrings, exprs, [](const Expression* curr) { + return Properties::isBranch(curr) || curr->is<Return>(); + }); +} } // namespace wasm |