This is an archive of the discontinued LLVM Phabricator instance.

[StructLayout] Use TrailingObjects to allocate space for MemberOffsets.
ClosedPublic

Authored by craig.topper on Mar 30 2021, 10:10 AM.

Details

Summary

MemberOffsets are stored at the end of StructLayout. The class
contains a single entry array to mark the start of the member
offsets. getStructLayout calculates the additional space needed
for additional elements before allocating memory.

This patch converts this to use TrailingObjects. This simplifies
the size computation in getStructLayout and gets rid of the
single entry array.

This is prep work, but to use TypeSize instead of uint64_t for
D98169. The single entry array doesn't work with TypeSize because
TypeSize doesn't have a default constructor. We thought this
change was an improvement by itself so we've separated it out.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 30 2021, 10:10 AM
craig.topper requested review of this revision.Mar 30 2021, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2021, 10:10 AM
mehdi_amini accepted this revision.Mar 30 2021, 3:05 PM
This revision is now accepted and ready to land.Mar 30 2021, 3:05 PM
This revision was landed with ongoing or failed builds.Mar 30 2021, 5:37 PM
This revision was automatically updated to reflect the committed changes.