bors
7a17f577b3
Auto merge of #112157 - erikdesjardins:align, r=nikic
...
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process.
Same as #111551 , which I [accidentally closed](https://github.com/rust-lang/rust/pull/111551#issuecomment-1571222612 ) :/
---
This resurrects PR #103830 , which has sat idle for a while.
Beyond #103830 , this also:
- fixes byval alignment for types containing vectors on Darwin (see `tests/codegen/align-byval-vector.rs`)
- fixes byval alignment for overaligned types on x86 Windows (see `tests/codegen/align-byval.rs`)
- fixes ABI for types with 128bit requested alignment on ARM64 Linux (see `tests/codegen/aarch64-struct-align-128.rs`)
r? `@nikic`
---
`@pcwalton's` original PR description is reproduced below:
Commit 88e4d2c 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]: #80822 (comment)
2023-07-15 15:39:53 +00:00
..
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-19 17:31:54 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-05-05 18:32:20 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-04-02 17:54:24 -04:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-23 18:36:25 +01:00
2023-04-21 16:14:44 +00:00
2023-03-30 07:34:55 -05:00
2023-04-24 01:56:37 +02:00
2023-06-28 11:09:19 +10:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-05-17 23:54:21 -05:00
2023-05-02 12:07:55 +00:00
2023-05-17 11:39:11 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-06-06 17:54:34 -04:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-07-14 16:22:29 -04:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-10 19:19:38 -04:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-04-03 01:34:05 +00:00
2023-05-07 12:38:47 +01:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-04-28 16:11:45 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-05-19 11:02:16 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-04-25 00:08:35 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-04-25 00:08:35 +02:00
2023-03-30 07:58:50 -05:00
2023-05-23 07:37:16 +00:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-04-17 18:53:52 +02:00
2023-05-03 15:52:31 -07:00
2023-04-15 07:40:19 -07:00
2023-03-30 08:46:31 -05:00
2023-05-02 12:07:55 +00:00
2023-06-16 20:56:01 -04:00
2023-04-03 01:34:05 +00:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-05-11 14:47:56 +00:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-02 13:41:36 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-06-07 21:03:51 +01:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-04-21 18:38:17 -07:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-05-17 12:07:12 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-06-30 21:13:24 +00:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-16 20:56:01 -04:00
2023-03-30 07:34:55 -05:00
2023-01-11 09:32:08 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-04-12 05:34:21 -05:00
2023-03-30 07:34:55 -05:00
2023-06-27 23:22:44 +02:00
2023-04-13 21:58:35 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-07-11 17:52:43 +08:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-04-03 10:23:08 +02:00
2023-05-02 12:07:55 +00:00
2023-03-30 07:34:55 -05:00
2023-04-27 18:22:06 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-06-16 20:56:01 -04:00
2023-03-30 07:34:55 -05:00
2023-06-23 17:22:07 +00:00
2023-03-30 07:34:55 -05:00
2023-05-02 12:07:55 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-04-19 00:39:20 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-04-03 10:23:15 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-05-05 01:22:17 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-07-01 20:24:15 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-04-25 00:08:35 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-06-05 17:33:26 +02:00
2023-01-11 09:32:08 +00:00
2023-03-30 07:58:50 -05:00