[RFC] Clearify tbaa.struct requirements within language reference

Hi all,

I am currently writing a patch to generate correct tbaa.struct metadata for bitfields (see the issue https://github.com/llvm/llvm-project/issues/59328 ). Thereby, I realized that two points of the description of the tbaa.struct metadata within the llvm language reference manual could be clarified:

  1. The order of the fields within tbaa.struct

The order of the fields could be unspecified, ordered by offset or ordered by field index. In the example within the specification it looks like the fields are ordered by offset. The implementation in clang outputs the fields in the order as specified in C/C++ (which might be different i.e. for randomized layouts). So I suggest to explicit state the order is unspecified.

  1. It is allowed that the byte range of two fields may overlap?

I think it would make sense to restrict the tbaa.struct that two fields must not overlap. At least that would simplify an algorithm for splitting memcpy into load/store that respect padding (which to the best of my knowledge does not exist)

I suggest to extend the tbaa.struct section of the llvm language reference manual by the following paragraph:

The order of the fields is unspecified. The byte range
[offset, offset + size) of two fields must not overlap. The size
of one field might be greater than the size of its TBAA tag (e.g. in
case of arrays) or might be smaller (e.g. in case of bitfields).