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-20 10:25:29 +00:00
2023-07-08 15:38:40 +02:00
2023-01-17 16:23:22 +01:00
2023-02-09 12:29:43 +09:00
2023-07-08 15:38:40 +02:00
2023-06-11 00:04:53 -04:00
2023-04-30 00:06:26 +08:00
2023-01-11 09:32:08 +00:00
2023-04-07 15:46:45 -04:00
2023-07-08 15:38:40 +02:00
2023-07-08 15:38:40 +02:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:35 +02:00
2023-07-10 19:19:40 -04:00
2023-01-11 20:42:13 -05:00
2023-04-30 00:06:26 +08:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-07-10 19:19:36 -04:00
2023-03-16 15:07:04 +01:00
2023-07-10 19:19:36 -04:00
2023-07-14 17:48:13 -04:00
2023-01-11 09:32:08 +00:00
2023-04-16 06:31:08 +00:00
2023-05-05 04:22:51 -07:00
2023-01-11 09:32:08 +00:00
2023-05-11 14:35:09 +00:00
2023-01-11 09:32:08 +00:00
2023-07-08 15:38:40 +02:00
2023-03-01 14:42:06 -08:00
2023-07-10 19:19:35 -04:00
2023-05-03 22:09:33 -07: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-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-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-05-30 20:45:40 -07:00
2023-05-12 21:59:26 -07:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:33 +02:00
2023-05-23 16:54:34 +02: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-01-17 16:23:22 +01:00
2023-04-30 00:06:26 +08:00
2023-05-23 16:54:30 +02:00
2023-04-30 00:06:26 +08: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-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-01-11 09:32:08 +00:00
2023-02-16 23:59:13 -08:00
2023-01-17 08:14:35 +01:00
2023-05-31 14:07:16 +00:00
2023-07-08 15:38:40 +02: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-05-23 16:54:30 +02:00
2023-01-11 09:32:08 +00:00
2023-03-31 07:28:39 -04:00
2023-03-31 07:28:39 -04:00
2023-03-31 07:28:39 -04:00
2023-01-11 09:32:08 +00:00
2023-05-11 14:35:10 +00:00
2023-04-22 23:41:48 +02: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-05-22 20:20:45 -04:00
2023-05-23 16:54:35 +02:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-03 22:41:29 +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-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-06-10 08:31:06 +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-07-08 15:38:40 +02:00
2023-06-10 16:58:51 +00:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:33 +02:00
2023-01-17 08:14:35 +01:00
2023-01-11 09:32:08 +00:00
2023-07-08 15:38:40 +02: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-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-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-07-10 19:19:30 -04:00
2023-07-10 19:19:30 -04: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-30 00:06:26 +08:00
2023-04-30 00:06:26 +08:00
2023-04-30 00:06:26 +08:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-03-15 14:22:26 -04:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-04-11 11:07:48 +10:00
2023-04-07 15:46:43 -04: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-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-07-14 12:37:29 +00:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:33 +02:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-04-07 15:46:43 -04: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-07-08 15:38:40 +02:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:13 +00:00
2023-07-08 15:38:40 +02:00
2023-07-08 15:38:40 +02:00
2023-02-10 16:06:25 -08:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:30 +02:00
2023-02-14 19:21:58 -05:00
2023-01-17 16:23:22 +01:00
2023-06-14 12:52:02 +02:00
2023-05-23 16:54:33 +02: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-05-20 19:41:28 -04: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-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-05-08 03:55:41 -07:00
2023-04-17 09:16:07 +02:00
2023-04-16 11:50:20 -07:00
2023-05-18 10:28:36 -07: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-05-23 16:54:35 +02:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-01-17 16:23:22 +01:00
2023-05-23 16:54:33 +02:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-07-08 15:38:40 +02:00
2023-07-02 02:22:22 +02:00
2023-04-30 00:06:26 +08:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-04-30 00:06:26 +08:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-06-22 15:36:46 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-23 16:44:03 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-02-14 20:54:25 -05:00
2023-01-11 09:32:08 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-03 22:41:29 +00:00
2023-05-23 16:44:03 +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-01-17 16:23:22 +01:00
2023-05-26 15:18:54 -04:00
2023-01-17 08:14:35 +01:00
2023-01-11 09:32:08 +00:00
2023-07-08 15:38:40 +02:00
2023-07-11 20:21:32 -07:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-03-05 15:15:22 -08:00
2023-07-10 16:01:18 +00:00
2023-06-12 23:47:08 +02:00
2023-07-08 15:38:40 +02:00
2023-05-12 17:34:55 -07:00
2023-01-11 09:32:08 +00:00
2023-07-10 16:01:18 +00:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-01-17 16:23:22 +01:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-03 22:41:29 +00:00
2023-02-10 16:06:25 -08:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-06-23 09:48:00 -04:00
2023-01-17 16:23:22 +01: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-06-04 00:51:49 -07:00
2023-06-04 00:51:49 -07:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:13 +00:00
2023-04-17 10:53:18 -04:00
2023-05-22 14:46:40 +01:00
2023-01-11 09:32:08 +00:00
2023-04-19 23:17:35 -07:00
2023-07-08 15:38:40 +02: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-05-23 16:54:33 +02:00
2023-06-16 16:03:19 -07:00
2023-01-11 09:32:08 +00:00
2023-07-08 15:38:40 +02:00
2023-07-08 15:38:40 +02:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-05-23 16:54:35 +02:00
2023-05-23 16:54:35 +02:00
2023-01-11 09:32:08 +00:00
2023-07-08 15:38:40 +02:00
2023-02-19 14:30:21 -05:00
2023-01-11 09:32:08 +00:00
2023-01-19 08:04:26 +00:00
2023-04-03 15:29:46 +02:00
2023-01-11 09:32:08 +00:00
2023-05-11 14:35:09 +00:00
2023-06-14 22:22:41 +02:00
2023-01-11 09:32:08 +00:00
2023-01-11 09:32:08 +00:00
2023-04-05 15:59:29 +00:00
2023-01-11 09:32:08 +00:00
2023-07-01 20:24:15 +02: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-17 16:23:22 +01:00