This is an archive of the discontinued LLVM Phabricator instance.

LowerBitSets: Introduce global layout builder.
ClosedPublic

Authored by pcc on Feb 20 2015, 12:35 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 20428.Feb 20 2015, 12:35 PM
pcc retitled this revision from to LowerBitSets: Introduce global layout builder..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added reviewers: kcc, jfb.
pcc added a subscriber: Unknown Object (MLST).
jfb edited edge metadata.Feb 20 2015, 12:52 PM

Nice results :-)

I honestly have a bit of a hard time visualizing how the algorithm works. Do you think you could illustrate it a bit more clearly?

lib/Transforms/IPO/LowerBitSets.cpp
125 ↗(On Diff #20428)

Format.

552 ↗(On Diff #20428)

This won't be deterministic without a tie-breaker?

test/Transforms/LowerBitSets/layout.ll
5 ↗(On Diff #20428)

Could you add an explanation of what the test does?

pcc updated this revision to Diff 20437.Feb 20 2015, 2:36 PM
pcc edited edge metadata.
  • Address review comments
pcc added a comment.Feb 20 2015, 2:37 PM

I've added a long comment to the top of the GlobalLayoutBuilder class which should hopefully explain things a little better.

lib/Transforms/IPO/LowerBitSets.cpp
125 ↗(On Diff #20428)

Done

552 ↗(On Diff #20428)

Because I'm using stable_sort, it should be as deterministic as EquivalenceClasses is. I'm not certain, but it looks like the only non-determinism there relates to the order in which elements are visited (i.e. begin()..end()), not the order in which members of equivalence classes are visited (member_begin()..member_end()). That's a separate problem which we should fix somehow.

test/Transforms/LowerBitSets/layout.ll
5 ↗(On Diff #20428)

Done

jfb added inline comments.Feb 20 2015, 2:41 PM
lib/Transforms/IPO/LowerBitSets.cpp
552 ↗(On Diff #20428)

My main concern is that order of iteration of std::set isn't stable, am I understanding correctly?

pcc added inline comments.Feb 20 2015, 2:43 PM
lib/Transforms/IPO/LowerBitSets.cpp
552 ↗(On Diff #20428)

I don't understand. We aren't iterating over std::set here. BitSetMembers is a std::vector.

jfb added inline comments.Feb 20 2015, 2:48 PM
lib/Transforms/IPO/LowerBitSets.cpp
552 ↗(On Diff #20428)

Sorry, explaining myself badly: if the std::set are equal then we can't iterate through them to compare members? I guess your point was that using std::stable_sort keeps the same order as BitSetMembers already had, and that was already deterministic?

pcc added inline comments.Feb 20 2015, 3:04 PM
lib/Transforms/IPO/LowerBitSets.cpp
552 ↗(On Diff #20428)

I still don't get it. We aren't iterating over any std::sets here, we are only taking their sizes. Anyway, std::sets are ordered, see http://en.cppreference.com/w/cpp/container/set

pcc added inline comments.Feb 20 2015, 4:34 PM
lib/Transforms/IPO/LowerBitSets.cpp
552 ↗(On Diff #20428)

Oh, and BitSetMembers is deterministic within the equivalence class (I think).

kcc edited edge metadata.Feb 20 2015, 5:27 PM

BTW, please reflect this in the design doc (not necessary in this change)

jfb added inline comments.Feb 22 2015, 11:02 AM
include/llvm/Transforms/IPO/LowerBitSets.h
120 ↗(On Diff #20437)

I'm not sure I understand how "Clients should use a nested pair of for loops to access the object indices." is helpful. Are you trying to illustrate the order of indices?

lib/Transforms/IPO/LowerBitSets.cpp
534 ↗(On Diff #20437)

Could you clarify below what operands 0 and 1 are? It's not obvious from the surrounding code.

552 ↗(On Diff #20428)

Oh I get it now, I was indeed confused :-)

pcc updated this revision to Diff 20533.Feb 23 2015, 12:43 PM
pcc edited edge metadata.
  • Address review comments
include/llvm/Transforms/IPO/LowerBitSets.h
120 ↗(On Diff #20437)

Yes. I rewrote this to hopefully be more useful.

lib/Transforms/IPO/LowerBitSets.cpp
534 ↗(On Diff #20437)

Done

pcc updated this revision to Diff 20536.Feb 23 2015, 12:57 PM
  • Add a reference to GlobalLayoutBuilder in docs
jfb accepted this revision.Feb 24 2015, 9:23 AM
jfb edited edge metadata.

lgtm

This revision is now accepted and ready to land.Feb 24 2015, 9:23 AM
This revision was automatically updated to reflect the committed changes.