[StructLayout] Use TrailingObjects to allocate space for MemberOffsets.
authorCraig Topper <craig.topper@sifive.com>
Tue, 30 Mar 2021 23:43:12 +0000 (16:43 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 31 Mar 2021 00:36:50 +0000 (17:36 -0700)
commitf59ba0849f7a148265dcc89d36a11717d365f368
treee4a012091a8358945e1efbef592305a559ac55cd
parentfb0b19c3de3b49bd6c343d6c02293cbcc77520fb
[StructLayout] Use TrailingObjects to allocate space for MemberOffsets.

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.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D99608
llvm/include/llvm/IR/DataLayout.h
llvm/lib/IR/DataLayout.cpp