Uh oh!
There was an error while loading. Please reload this page.
Set attrs.pointee_align when constructing function ABI - #80822
Conversation
Fixesrust-lang#80127 This will require additional testing to see if the old FIXME still applies
rust-highfive
commented
Jan 8, 2021
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
Aaron1011
commented
Jan 8, 2021
cc @eddyb |
nagisa
commented
Jan 8, 2021
nagisa
commented
Jan 10, 2021
I bootstrapped the compiler with these changes with
Both failures look a lot like wrong offsets, e.g. the former test asserts receiving (NB: test names or the numbers may have errors because I typed them over by hand) |
bors
commented
Jan 24, 2021
☔ The latest upstream changes (presumably #80594) made this pull request unmergeable. Please resolve the merge conflicts. |
camelid
commented
Feb 12, 2021
Ping from triage: @Aaron1011 could you fix the merge conflicts? |
Dylan-DPC-zz
commented
Mar 2, 2021
@Aaron1011 any updates? |
crlf0710
commented
Apr 23, 2021
@Aaron1011 any updates here? |
oli-obk
commented
Apr 23, 2021
r? @nagisa |
eddyb
commented
Apr 30, 2021
@Aaron1011@nagisa oh god I completely missed something when I first wrote this code. So what I thought we'd get is better optimizations, because of the assumption of alignment. But LLVM must be using this Can you try making
Actually, scratch that last part, it doesn't make sense because of the semantics of Which means that fixing my FIXME is not enough for #80127, now that I look closer. So what probably needs to happen is what I saying above about making |
…ecting the alignment of `byval` on x86 in the process. 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 fixrust-lang#80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: rust-lang#80822 (comment)
rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of `byval` on x86 in the process. 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 fixrust-lang#80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: rust-lang#80822 (comment)
…ecting the alignment of `byval` on x86 in the process. 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 fixrust-lang#80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: rust-lang#80822 (comment)
Fixes#80127
This will require additional testing to see if the old FIXME still
applies