Previously the alignment on the newly created rtti/typeinfo data was largely
not set, meaning that DataLayout::getPreferredAlignment was free to overalign
it to 16 bytes. This causes unnecessary code bloat.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Could we make CreateOrReplaceCXXRuntimeVariable take the alignment as an argument, so we can be sure we're consistently setting the alignment for these variables? This seems easy to mess up if we're scattering calls all over the place.
Sort of orthogonal, but CreateOrReplaceCXXRuntimeVariable should probably also call setUnnamedAddr, instead of making each caller call it.
I've become less sure about what the various alignments should be here. There seem to be multiple ways to calculate such things, I'm not sure which are best. For example, for want of a better option I've used getPointerAlign in ItaniumRTTIBuilder::BuildTypeInfo.
getClassPointerAlignment is not really relevant here; that's the alignment of a pointer to an object with the type of the class.
For the LLVM IR structs which don't have a corresponding clang type, you can probably just use DataLayout::getABITypeAlignment(). I think that's just the alignment of a pointer in practice, but the intent is more clear.
lib/CodeGen/MicrosoftCXXABI.cpp | ||
---|---|---|
2027 ↗ | (On Diff #163727) | This is an array of int. |
LGTM with one change.
lib/CodeGen/ItaniumCXXABI.cpp | ||
---|---|---|
2730 ↗ | (On Diff #164693) | Please use getTypeAlignInChars(getContext().CharTy), or something like that, so it's clear where the "1" is coming from. |