diff options
author | Ashley Nelson <nashley@google.com> | 2023-11-12 22:38:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 06:38:30 +0000 |
commit | 84f51cd5af96ef4d9e157452d98965301251016a (patch) | |
tree | 9b6a1c555fc432516cd83668f8dcc6ff7ccca590 /test/gtest | |
parent | af93434115800f5b7d85eb81cb774db287f1b3b7 (diff) | |
download | binaryen-84f51cd5af96ef4d9e157452d98965301251016a.tar.gz binaryen-84f51cd5af96ef4d9e157452d98965301251016a.tar.bz2 binaryen-84f51cd5af96ef4d9e157452d98965301251016a.zip |
[Outlining] Adds Outlining pass (#6110)
Adds an outlining pass that performs outlining on a module end to end, and two tests.
Diffstat (limited to 'test/gtest')
-rw-r--r-- | test/gtest/stringify.cpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/test/gtest/stringify.cpp b/test/gtest/stringify.cpp index 8e854ee4b..59b7db6e1 100644 --- a/test/gtest/stringify.cpp +++ b/test/gtest/stringify.cpp @@ -250,29 +250,11 @@ TEST_F(StringifyTest, Stringify) { })); } -std::vector<SuffixTree::RepeatedSubstring> -repeatSubstrings(std::vector<uint32_t> hashString) { - SuffixTree st(hashString); - std::vector<SuffixTree::RepeatedSubstring> substrings(st.begin(), st.end()); - std::sort( - substrings.begin(), - substrings.end(), - [](SuffixTree::RepeatedSubstring a, SuffixTree::RepeatedSubstring b) { - size_t aWeight = a.Length * a.StartIndices.size(); - size_t bWeight = b.Length * b.StartIndices.size(); - if (aWeight == bWeight) { - return a.StartIndices[0] < b.StartIndices[0]; - } - return aWeight > bWeight; - }); - return substrings; -} - TEST_F(StringifyTest, Substrings) { Module wasm; parseWast(wasm, dupModuleText); auto hashString = hashStringifyModule(&wasm); - auto substrings = repeatSubstrings(hashString); + auto substrings = StringifyProcessor::repeatSubstrings(hashString); EXPECT_EQ( substrings, @@ -294,7 +276,7 @@ TEST_F(StringifyTest, DedupeSubstrings) { parseWast(wasm, dupModuleText); auto hashString = hashStringifyModule(&wasm); std::vector<SuffixTree::RepeatedSubstring> substrings = - repeatSubstrings(hashString); + StringifyProcessor::repeatSubstrings(hashString); auto result = StringifyProcessor::dedupe(substrings); EXPECT_EQ( @@ -332,10 +314,9 @@ TEST_F(StringifyTest, FilterLocalSets) { parseWast(wasm, localSetModuleText); HashStringifyWalker stringify = HashStringifyWalker(); stringify.walkModule(&wasm); - auto substrings = repeatSubstrings(stringify.hashString); - auto result = StringifyProcessor::dedupe(substrings); - - result = StringifyProcessor::filterLocalSets(substrings, stringify.exprs); + auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString); + auto result = + StringifyProcessor::filterLocalSets(substrings, stringify.exprs); EXPECT_EQ( result, @@ -375,8 +356,7 @@ TEST_F(StringifyTest, FilterBranches) { parseWast(wasm, branchesModuleText); HashStringifyWalker stringify = HashStringifyWalker(); stringify.walkModule(&wasm); - - auto substrings = repeatSubstrings(stringify.hashString); + auto substrings = StringifyProcessor::repeatSubstrings(stringify.hashString); auto result = StringifyProcessor::filterBranches(substrings, stringify.exprs); EXPECT_EQ( |