This is an archive of the discontinued LLVM Phabricator instance.

[RDA] Use TinyPtrVector to store reaching defs (NFCI)
ClosedPublic

Authored by nikic on Apr 5 2020, 1:33 PM.

Details

Summary

RDA currently uses SmallVector<int, 1> to store reaching definitions. A SmallVector<int, 1> is 24 bytes large, and X86 currently has 164 register units, which means we need 3936 bytes per block. If you have a large function with 1000 blocks, that's already 4MB.

A large fraction of these reg units will not have any reaching defs (say, those corresponding to zmm registers), and many will have just one. A TinyPtrVector serves this use-case much better, as it only needs 8 bytes per register if it has 0 or 1 reaching defs.

As the name implies, TinyPtrVector is designed to work with pointers, so we need to add some boilerplate to treat our reaching defs integers as pointers, using an appropriate encoding. We need to keep the low bit free for tagging, and make sure at least one bit is set to distinguish the null pointer.

Diff Detail

Event Timeline

nikic created this revision.Apr 5 2020, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2020, 1:33 PM
nikic added a comment.Apr 5 2020, 2:33 PM

Together with the dependent patches, this saves on average 1% max-rss, with 4.5% for sqlite (the tramp3d-v4 regression is not real, ThinLTO has unstable memory usage for that benchmark). We also get on average 0.6% less instructions retired. The memory savings are mainly due to this patch, the compile-time improvements mainly due to the dependent patches.

samparker accepted this revision.Apr 8 2020, 3:44 AM

Every day is a school day for me, many thanks.

This revision is now accepted and ready to land.Apr 8 2020, 3:44 AM
This revision was automatically updated to reflect the committed changes.