about summary refs log tree commit diff
path: root/tests/codegen/align-byval.rs
AgeCommit message (Collapse)AuthorLines
2023-07-14i686-windows: make requested alignment > 4 special case apply transitivelyErik Desjardins-2/+4
2023-07-10repr(align) <= 4 should still be byvalErik Desjardins-7/+4
2023-07-10align-byval test: add cases for lower requested alignment, wrapped, and ↵Erik Desjardins-3/+100
repr(transparent)
2023-07-10ensure byval allocas are sufficiently alignedErik Desjardins-15/+101
2023-07-10align-byval test: add cases for <= align 4Erik Desjardins-2/+50
2023-07-10align-byval test: add cases distinguishing natural vs forced/requested alignmentErik Desjardins-10/+62
2023-07-10align-byval test: add x86Erik Desjardins-3/+12
x86 Windows also should not use byval since the struct is overaligned, see https://reviews.llvm.org/D72114
2023-07-10align-byval test: use revisions to test different targetsErik Desjardins-40/+35
2023-07-10rustc_target: Add alignment to indirectly-passed by-value types, correcting thePatrick Walton-0/+56
alignment of `byval` on x86 in the process. Commit 88e4d2c2918428d55e34cd57c11279ea839c8822 from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by @eddyb. Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: https://github.com/rust-lang/rust/pull/80822#issuecomment-829985417