Commit Graph

3642 Commits

Author SHA1 Message Date
bors
4f16abdff6 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
Mahdi Dibaiee
d45c8c3e7c refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
bjorn3
fae8935e3d Avoid installing rustc-dev in the rustfmt CI job 2023-07-13 11:39:04 +00:00
bjorn3
aa6916bd01 Use correct lang item for AssertKind::MisalignedPointerDereference
cc #1381
2023-07-12 19:03:27 +00:00
bjorn3
c3a0431731 Avoid recursive cargo calls when doing cargo clif instead of cargo-clif
Fixes #1383
2023-07-12 17:24:46 +00:00
bjorn3
c137418bde Explicitly disable git gpg signing
Otherwise building fails if the user has globally enabled gpg signing.

Fixes #1384
2023-07-12 17:21:14 +00:00
bjorn3
34d63e4c1d Use GHA log grouping 2023-07-12 16:45:42 +00:00
bjorn3
8b9187dfec Fix rustc test suite 2023-07-12 14:47:23 +00:00
bjorn3
c28878d8f2 Rustup to rustc 1.73.0-nightly (993deaa0b 2023-07-11) 2023-07-12 14:31:00 +00:00
bjorn3
2922d41fa5 Sync from rust 993deaa0bf 2023-07-12 13:42:45 +00:00
Erik Desjardins
388a6b5835 cg_clif: just ignore all the unused LayoutS fields 2023-07-10 19:19:41 -04:00
Erik Desjardins
6f16da3ee7 repr(align) <= 4 should still be byval 2023-07-10 19:19:40 -04:00
Erik Desjardins
d2d76ef358 cg_clif: add has_repr_align 2023-07-10 19:19:40 -04:00
Nilstrieb
1cae70145c Rename adjustment::PointerCast and variants using it to PointerCoercion
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related
casts, when in reality their just used to share a some enum variants. Make it clear there these
are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07 18:17:16 +02:00
Boxy
40de0c2765 Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
Boxy
b5b1c0eddc Deal with fallout 2023-07-05 09:46:30 +01:00
bors
b51f778846 Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk
A mish-mash of micro-optimizations

These were aimed at speeding up LLVM codegen, but ended up affecting other places as well.

r? `@bjorn3`
2023-06-30 00:35:19 +00:00
Nicholas Nethercote
9db001dfbb Avoid unnecessary line lookup.
`lookup_debug_loc` calls `SourceMap::lookup_line`, which does a binary
search over the files, and then a binary search over the lines within
the found file. It then calls `SourceFile::line_begin_pos`, which redoes
the binary search over the lines within the found file.

This commit removes the second binary search over the lines, instead
getting the line starting pos directly using the result of the first
binary search over the lines.

(And likewise for `get_span_loc`, in the cranelift backend.)
2023-06-29 11:26:39 +10:00
bjorn3
d3e9e424a1 Update setup_rust_fork.sh for cg_clif build layout changes 2023-06-28 16:52:02 +00:00
bjorn3
ab12203187 Rustup to rustc 1.72.0-nightly (5ea666864 2023-06-27) 2023-06-28 16:45:15 +00:00
许杰友 Jieyou Xu (Joe)
2cdf8a4c3f Provide more context for rustc +nightly -Zunstable-options on stable 2023-06-27 23:23:33 +08:00
bjorn3
85b5253806
Merge pull request #1382 from cuviper/indexmap-2
Upgrade to indexmap v2
2023-06-25 14:13:43 +02:00
Josh Stone
814f46c39d Minor cleanup around IndexSet 2023-06-24 17:43:35 -07:00
Josh Stone
ff10c0f037 Upgrade to indexmap v2 2023-06-24 17:42:48 -07:00
bjorn3
e44f47adf7
Merge pull request #1380 from bjorn3/more_vendor_intrinsics
Implement a whole bunch more x86 vendor intrinsics
2023-06-23 14:17:35 +02:00
bjorn3
aee30c5ddc Implement _mm_abs_epi* 2023-06-23 10:37:57 +00:00
bjorn3
92a4093850 Implement _mm_storeu_pd 2023-06-23 10:31:52 +00:00
bjorn3
d957015234 Implement _mm_slli_epi64 2023-06-23 10:28:27 +00:00
bjorn3
cb0a9b9550 Implement _addcarryx_{u32,u64} 2023-06-23 10:23:20 +00:00
bjorn3
8cad29a529 Implement _xgetbv 2023-06-23 10:05:18 +00:00
bjorn3
aef31cb2f3 Implement _mm_srli_epi64 2023-06-23 09:35:39 +00:00
bjorn3
bbf45081b7 Implement _mm_srai_epi* and _mm256_srai_epi* 2023-06-23 09:32:52 +00:00
bjorn3
71cb045c7d Fix _mm_cmp*_ps 2023-06-23 09:27:15 +00:00
bjorn3
7cbc8bcb4b Implement nontemporal_store using a regular store 2023-06-23 09:19:11 +00:00
bjorn3
41af17a9d1 Implement more _mm_cmp*_{ps,pd} intrinsics 2023-06-23 09:18:56 +00:00
bjorn3
0311202fd4 Implement _addcarry_u32 and _subborrow_u32 2023-06-23 09:17:02 +00:00
bjorn3
6b141f39d2 Rustup to rustc 1.72.0-nightly (065a1f5df 2023-06-21) 2023-06-22 18:45:21 +00:00
bjorn3
ee1793432d Sync from rust 065a1f5df9 2023-06-22 18:40:02 +00:00
bjorn3
c8620a3cbf Nicer error when implementation limits are exceeded
Fixes #1370
2023-06-20 15:48:00 +00:00
bjorn3
e5268804a2 Update Cranelift to 0.97 2023-06-20 15:32:44 +00:00
bjorn3
aebbeceb88 Handle rust-call abi without self argument
Fixes #1236
2023-06-20 10:05:23 +00:00
Michael Goulet
7ba31b9938 Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
bjorn3
daf79b5685 Avoid the stack in a couple more cases in write_cvalue_maybe_transmute 2023-06-19 20:56:21 +00:00
bjorn3
ab836ca5e3 Fix transmuting fat pointers to integers
Fixes #1325
2023-06-19 20:55:55 +00:00
bjorn3
ece98a4b41 Simplify CPlaceInner::Addr branch of write_cvalue_maybe_transmute 2023-06-19 20:26:07 +00:00
bjorn3
d169ee3457 Recurse into function signatures in assert_assignable
Fixes #1311
2023-06-19 19:30:44 +00:00
bjorn3
43064b005d Update portable-simd 2023-06-19 17:39:38 +00:00
bjorn3
932645473c Fix warning about the cargo resolver to use 2023-06-19 17:36:32 +00:00
bjorn3
0b3060138b Use -Zinline-mir instead of -Zmir-opt-level=3
Except for mir inlining all mir opts that are beneficial for cg_clif now
run on -Zmir-opt-level=2. -Zmir-opt-level=3 enables some more expensive
optimizations.
2023-06-19 17:21:30 +00:00
bjorn3
8b23094ade Fix some outdated references to y.rs 2023-06-19 16:21:11 +00:00