This is an archive of the discontinued LLVM Phabricator instance.

[ValueLattice] Add CompactValueLatticeElement.
AbandonedPublic

Authored by fhahn on Nov 7 2017, 10:07 AM.

Details

Reviewers
davide
reames
anna
Summary

This patch adds a CompactValueLatticeElement class which uses
PointerIntPair to store info about the element in a compact
fashion. Something along those lines has been mentioned in
PR26921.

Most of the actual ValueLatticeElement logic is moved to
ValueLatticeElementBase. Templates are used to dispatch calls to
subtypes of ValueLatticeElementBase (which contain the actual data)
statically.

In LazyValueInfo, the compact representation is used to store the
cached values, but ValueLatticeElement is used for the temporary
objects, to avoid internalizing constant ranges unnecessarily.

I also tried to push down the conversions between the 2 representations
as far as possible. In general, we should only need to do at most
1 conversion to and from to compact representation each.

Also the plan is to use reference counting to remove ConstantRanges
from the pool as they become unused. That's not implemented yet.

Diff Detail

Event Timeline

fhahn created this revision.Nov 7 2017, 10:07 AM

This version still contains style violations and there are a few parts that could potentially be committed as NFCs.

reames added a reviewer: anna.Nov 7 2017, 4:16 PM
reames edited edge metadata.

Structural suggestion: pick either of the two subtasks and implement them in isolation. That is *either* replace the ConstantRange with an owned ConstantRange allocation and implement the tagged pointer OR implement the ConstantRange folding set. Doing both in one change is needlessly complicated. Once one is done, the other follows more naturally. I'd suggest the first then the second, but either order is defensible.

Can I ask why you chose to tackle this one? What motivated you to care about the memory consumption of LVI? Just curious about the background and motivating test cases.

fhahn updated this revision to Diff 123353.Nov 17 2017, 8:56 AM
fhahn retitled this revision from [ValueLattice] Use PointerIntPair (WIP). to [ValueLattice] Add CompactValueLatticeElement..
fhahn edited the summary of this revision. (Show Details)

Thanks @reames ! This patch should introduces a more compact lattice element representation using PointerIntPair, not the ConstantRange folding set.

Updated the patch to avoid the need to internalize constant ranges for temporary objects, as used by LazyValueInfo.

fhahn added a comment.Nov 17 2017, 8:59 AM

> Can I ask why you chose to tackle this one? What motivated you to care about the memory consumption of LVI? Just curious about the background and motivating test cases.

There is no particular test case I am looking at. But I want to use ValueLatticeElement for values in IPSCCP (not just parameters, as it is at the moment), and thought it would be a good idea to try to get a more compact representation before that. Also, the more compact representation should make it easier to add additional lattices in the future.

fhahn added a comment.Nov 20 2017, 1:55 PM

This needs some more work. I'll update the patch and post some data once I am done.

reames requested changes to this revision.Jan 17 2018, 6:55 PM

Marking to get off my queue.

This revision now requires changes to proceed.Jan 17 2018, 6:55 PM
fhahn abandoned this revision.Nov 7 2018, 3:19 AM

Abandoning for now