-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process. #112157
Commits on Jul 10, 2023
-
rustc_target: Add alignment to indirectly-passed by-value types, corr…
…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 fix rust-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)
Configuration menu - View commit details
-
Copy full SHA for 0becc89 - Browse repository at this point
Copy the full SHA 0becc89View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1022926 - Browse repository at this point
Copy the full SHA 1022926View commit details -
Configuration menu - View commit details
-
Copy full SHA for be1d4e3 - Browse repository at this point
Copy the full SHA be1d4e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for a07eb0a - Browse repository at this point
Copy the full SHA a07eb0aView commit details -
add ignore-cross-compile to run-make/extern-fn-explicit-align
From the test logs, other extern-fn-* tests have this: [run-make] tests/run-make/extern-fn-with-packed-struct ... ignored, ignored when cross-compiling [run-make] tests/run-make/extern-fn-with-union ... ignored, ignored when cross-compiling [run-make] tests/run-make/extern-multiple-copies ... ignored, ignored when cross-compiling [run-make] tests/run-make/extern-multiple-copies2 ... ignored, ignored when cross-compiling [run-make] tests/run-make/extern-overrides-distribution ... ignored, ignored when cross-compiling [run-make] tests/run-make/extra-filename-with-temp-outputs ... ignored, ignored when cross-compiling [run-make] tests/run-make/extern-fn-explicit-align ... FAILED
Configuration menu - View commit details
-
Copy full SHA for 0f7d333 - Browse repository at this point
Copy the full SHA 0f7d333View commit details -
Configuration menu - View commit details
-
Copy full SHA for fdaaf86 - Browse repository at this point
Copy the full SHA fdaaf86View commit details -
Configuration menu - View commit details
-
Copy full SHA for 84ff2e3 - Browse repository at this point
Copy the full SHA 84ff2e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5f4472e - Browse repository at this point
Copy the full SHA 5f4472eView commit details -
Configuration menu - View commit details
-
Copy full SHA for bc9d26a - Browse repository at this point
Copy the full SHA bc9d26aView commit details -
x86 Windows also should not use byval since the struct is overaligned, see https://reviews.llvm.org/D72114
Configuration menu - View commit details
-
Copy full SHA for 08d1892 - Browse repository at this point
Copy the full SHA 08d1892View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8ec90f6 - Browse repository at this point
Copy the full SHA 8ec90f6View commit details -
extern-fn-struct-passing-abi test: ensure we don't start passing stru…
…ct with natural alignment > 8 by reference
Configuration menu - View commit details
-
Copy full SHA for 7089321 - Browse repository at this point
Copy the full SHA 7089321View commit details -
Configuration menu - View commit details
-
Copy full SHA for ed317e4 - Browse repository at this point
Copy the full SHA ed317e4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 209ed07 - Browse repository at this point
Copy the full SHA 209ed07View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e76446 - Browse repository at this point
Copy the full SHA 0e76446View commit details -
align-byval test: add cases for lower requested alignment, wrapped, a…
…nd repr(transparent)
Configuration menu - View commit details
-
Copy full SHA for f704396 - Browse repository at this point
Copy the full SHA f704396View commit details -
extern-fn-explicit-align test: add wrapped and lower requested alignm…
…ent, improve assertions
Configuration menu - View commit details
-
Copy full SHA for 65d11b5 - Browse repository at this point
Copy the full SHA 65d11b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 00b3eca - Browse repository at this point
Copy the full SHA 00b3ecaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4c1dbc3 - Browse repository at this point
Copy the full SHA 4c1dbc3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2591c30 - Browse repository at this point
Copy the full SHA 2591c30View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7e933b4 - Browse repository at this point
Copy the full SHA 7e933b4View commit details -
Configuration menu - View commit details
-
Copy full SHA for d1e764c - Browse repository at this point
Copy the full SHA d1e764cView commit details -
Configuration menu - View commit details
-
Copy full SHA for c858d34 - Browse repository at this point
Copy the full SHA c858d34View commit details
Commits on Jul 13, 2023
-
extern fn-explicit-align test: don't use uint128_t
...which seems not to be available on some platforms. Or maybe it is under a different name but I don't want to deal with that Instead, use two u64s. This isn't exactly the same, but we already have some coverage of the packed u128 case in another test, so it's not essential to have it here.
Configuration menu - View commit details
-
Copy full SHA for ecf2390 - Browse repository at this point
Copy the full SHA ecf2390View commit details
Commits on Jul 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for f297f32 - Browse repository at this point
Copy the full SHA f297f32View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2daacf5 - Browse repository at this point
Copy the full SHA 2daacf5View commit details