I do have some problems with the alignment within struct
s for my target. On my target everything is aligned to 64 bits, no matter how many bits the value has in size.
For the struct:
typedef struct {
short4* p[3];
} short4Array_t;
only memory for 2 pointers instead of 3 is allocated. For the simplified but equivalent type
typedef short4* short4Array_t[3];
memory for all 3 pointers is allocated. This tells me that the array is not the problem.
Debugging showed me, that the array knows its correct size, but it is not used. Instead the function call chain ItaniumRecordLayoutBuilder::LayoutField
→ ASTContext::getTypeInfoInChars
→ getConstantArrayInfoInChars
(re-)computes the size of the array as #Elements * sizeof(Element). In general this would be correct, but I have to align each element:
unsigned Align = EltInfo.Align.getQuantity();
uint64_t Width = llvm::alignTo(EltInfo.Width.getQuantity(), Align) * Size;
Now, everything is complied as expected. But I have two questions:
- Could this change raise a problem in other situations?
- Might such a change be needed for an array of MVT::f80, 128 bits aligned on a X86?