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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230394 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2015-02-24 23:17:02 +00:00
parent 7a1721e7c3
commit 0bf03cb473
5 changed files with 210 additions and 12 deletions

View File

@@ -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);
}
}