diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-24 23:17:02 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-24 23:17:02 +0000 |
commit | 1baeaa395a95d618fdd7d5a1fcea9ccc3a6ed996 (patch) | |
tree | 0e0071bfb6eaaf846020b95ee9652c7502f6e16e /llvm/unittests/Transforms/IPO/LowerBitSets.cpp | |
parent | 03f38362aa2bb98c6d3a4e66068e8cbac358a792 (diff) | |
download | bcm5719-llvm-1baeaa395a95d618fdd7d5a1fcea9ccc3a6ed996.tar.gz bcm5719-llvm-1baeaa395a95d618fdd7d5a1fcea9ccc3a6ed996.zip |
LowerBitSets: Introduce global layout builder.
The builder is based on a layout algorithm that tries to keep members of
small bit sets together. The new layout compresses Chromium's bit sets to
around 15% of their original size.
Differential Revision: http://reviews.llvm.org/D7796
llvm-svn: 230394
Diffstat (limited to 'llvm/unittests/Transforms/IPO/LowerBitSets.cpp')
-rw-r--r-- | llvm/unittests/Transforms/IPO/LowerBitSets.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/IPO/LowerBitSets.cpp b/llvm/unittests/Transforms/IPO/LowerBitSets.cpp index 796d90f29e9..2f27c0762ff 100644 --- a/llvm/unittests/Transforms/IPO/LowerBitSets.cpp +++ b/llvm/unittests/Transforms/IPO/LowerBitSets.cpp @@ -62,3 +62,30 @@ TEST(LowerBitSets, BitSetBuilder) { } } } + +TEST(LowerBitSets, GlobalLayoutBuilder) { + struct { + uint64_t NumObjects; + std::vector<std::set<uint64_t>> Fragments; + std::vector<uint64_t> WantLayout; + } GLBTests[] = { + {0, {}, {}}, + {4, {{0, 1}, {2, 3}}, {0, 1, 2, 3}}, + {3, {{0, 1}, {1, 2}}, {0, 1, 2}}, + {4, {{0, 1}, {1, 2}, {2, 3}}, {0, 1, 2, 3}}, + {4, {{0, 1}, {2, 3}, {1, 2}}, {0, 1, 2, 3}}, + {6, {{2, 5}, {0, 1, 2, 3, 4, 5}}, {0, 1, 2, 5, 3, 4}}, + }; + + for (auto &&T : GLBTests) { + GlobalLayoutBuilder GLB(T.NumObjects); + for (auto &&F : T.Fragments) + GLB.addFragment(F); + + std::vector<uint64_t> ComputedLayout; + for (auto &&F : GLB.Fragments) + ComputedLayout.insert(ComputedLayout.end(), F.begin(), F.end()); + + EXPECT_EQ(T.WantLayout, ComputedLayout); + } +} |