The -malign-double flag causes i64 and f64 types to have alignment 8
instead of 4. On x86-64, the behavior of -malign-double is enabled by default.
Rebases and cleans phosek's work here: http://reviews.llvm.org/D12860
Differential D19734
[X86] Add -malign-double support seanklein on Apr 29 2016, 11:56 AM. Authored by
Details The -malign-double flag causes i64 and f64 types to have alignment 8 Rebases and cleans phosek's work here: http://reviews.llvm.org/D12860
Diff Detail Event TimelineComment Actions I want to push back just a little bit on adding more ABI tweaking flags. If users need some data to be more aligned, they can already apply alignment attributes to the performance-sensitive declarations instead of changing all record layout everywhere. To get this in, can you provide some evidence that this is a popular flag that we need to support?
Comment Actions
This feature is used by the Native Client toolchain for our x86 build. Additionally, lack of support for this flag was an issue for folks at Nvidia (shown here). Additionally, this change would provide feature parity with GCC. The corresponding LLVM backend change has been added to the summary, and is visible here. Comment Actions Seems reasonable.
Stepping back, do you actually need to change LLVM's data layout here? Can this be a purely frontend change that affects alignment of variables in memory and record layout? If we tell LLVM that it needs to align all doubles that got spilled to the stack to 8 bytes, we're going to get a lot of stack realignment prologues that we probably don't want. We also want to avoid adding new cl::opts in LLVM if at all possible. Comment Actions Updated to avoid changing:
Also included a more extensive test.
Comment Actions Test looks great, btw, thanks. It could be structured as a Sema-only check, but I think it's fine the way it is. Comment Actions Moved AlignDouble to Language Options. Modifiying double alignment in TargetInfo::adjust rather than x86TargetInfo. |
This should probably be in LangOptions, since those are automatically compared for PCH compatibility. Similar options controlling record layout are there, like PackStruct and MaxTypeAlign.