Commit Graph

746 Commits

Author SHA1 Message Date
Hans Wennborg
2e331b1637 Update codegen-llvm/inline-debuginfo.rs for distinct DILocation 2026-09-08 08:59:13 +02:00
Jacob Pratt
4e27adb224 Rollup merge of #161697 - folkertdev:complex-sparc64-powerpc64, r=JohnTitor
make `Complex` ABI-compatible on sparc64 and powerpc64

tracking issue: https://github.com/rust-lang/rust/issues/154023

Make the ABI for `Complex` match C for two slightly more involved targets.

For Sparc64 the implementation matches GCC and Clang 24 and up. In https://github.com/llvm/llvm-project/pull/215015 a bug with how small complex numbers are passed was fixed.

For powerpc64 we match Clang exactly (and Clang is compatible with GCC for this target).

cc @beetrees @Gelbpunkt
2026-09-07 04:06:30 -04:00
bors
f207aa3913 Auto merge of #162333 - Zalathar:rollup-DdpfsFl, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#162324 (miri subtree update)
 - rust-lang/rust#162170 (bootstrap: use target's LLVM libdir when cross-compiling)
 - rust-lang/rust#158312 (Adds support for AArch64 SVE to inline assembly)
 - rust-lang/rust#159792 (A more readable debug map for IndexMaps)
 - rust-lang/rust#160745 (make closures act like MaybeDangling)
 - rust-lang/rust#161263 (break rustc_expand-rustc_middle dependency)
 - rust-lang/rust#161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment)
 - rust-lang/rust#161940 (Promote `wasm32-wasip3` to a tier 2 target)
 - rust-lang/rust#161397 (coverage: Tidy tests and add some new ones)
 - rust-lang/rust#161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval)
 - rust-lang/rust#162248 (Add regression test for unsized const parameter default ICE)
 - rust-lang/rust#162250 (Fix hashing of span end columns in incremental compilation)
 - rust-lang/rust#162265 (cargotest: add lockfiles)
 - rust-lang/rust#162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
2026-09-05 17:04:57 +00:00
Folkert de Vries
9e53b26932 make PowerPC64 Complex ABI GCC-compatible 2026-09-04 16:50:41 +02:00
Folkert de Vries
821527b611 make SPARC64 Complex ABI GCC-compatible 2026-09-04 16:50:41 +02:00
Folkert de Vries
cccde2f30b add placeholder for amdgpu 2026-09-04 16:50:40 +02:00
Ralf Jung
e7c3734a6a make closure-like types act like MaybeDangling 2026-09-04 16:35:10 +02:00
Folkert de Vries
a305a9c3b6 fix is_homogeneous_aggregate: use unit size, not total size 2026-09-04 16:15:13 +02:00
Jonathan Brouwer
f0fd2caeeb Rollup merge of #157808 - 1c3t3a:sanitizer-ignorelist, r=rcvalle
sanitizers: Implement support for the sanitize ignorelist

The sanitize ignorelist gives central controls over which functions, files, etc. should be ignored and not sanitized. It is a common file format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change adds support for this list in Rust as well.

r? @rcvalle
2026-09-04 09:44:44 +02:00
Jonathan Brouwer
86be46f85d Rollup merge of #162230 - zmodem:unchecked_math, r=nikic
Pass -Z merge-functions=disabled in tests/codegen-llvm/intrinsics/unchecked_math.rs

Otherwise e.g. `@unchecked_add_unsigned` and `@unchecked_add_signed` get merged after https://github.com/llvm/llvm-project/pull/220015, breaking the test's expectations.
2026-09-03 20:03:00 +02:00
Bastian Kersting
c0e55d66cc sanitizers: Implement support for the sanitize ignorelist
The sanitize ignorelist gives central controls over which functions,
files, etc. should be ignored and not sanitized. It is a common file
format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change
adds support for this list in Rust as well.
2026-09-03 15:53:04 +00:00
Hans Wennborg
c5c326ba70 Pass -Z merge-functions=disabled in tests/codegen-llvm/intrinsics/unchecked_math.rs
Otherwise e.g. `@unchecked_add_unsigned` and `@unchecked_add_signed` get
merged after https://github.com/llvm/llvm-project/pull/220015, breaking
the test's expectations.
2026-09-03 13:08:13 +02:00
Jonathan Brouwer
656ff175cf Rollup merge of #162151 - folkertdev:ppc-itanium, r=tgross35
Test itanium mangling of `f16` and `f128`

And fix the string that is used for `f128` on powerpc targets, where the standard `"g"` is already taken by `__ibm128`.

In clang

bd5b1f58ae/clang/lib/Basic/Targets/PPC.h (L362-L363)

```c
  const char *getFloat128Mangling() const override { return "u9__ieee128"; }
  const char *getIbm128Mangling() const override { return "g"; }
```

and GCC

fc54ab94ad/gcc/config/rs6000/rs6000.cc (L20795-L20801)

```c

  if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IBM_P (TYPE_MODE (type)))
    return "g";
  if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IEEE_P (TYPE_MODE (type)))
    return "u9__ieee128";
```

From what i can tell this is not really testable for powerpc at the moment because CFI is not supported on powerpc.

r? tgross35
2026-09-03 12:43:00 +02:00
Jonathan Brouwer
e48a722293 Rollup merge of #160564 - RalfJung:volatile-with-trap, r=nikic
volatile: allow accesses to non-AM memory to trap

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/610 by saying that yes, volatile accesses may trap. This also fixes what I believe to be the last case of "time-traveling UB" we have in Rust: with this change, UB always fully sequenced wrt observable events (I/O and volatile accesses). UB can still travel around unobservable events such as non-volatile memory accesses.

For writes, LLVM has already implemented the new semantics for a long time. For reads, LLVM only recently implemented the "may trap" semantics with LLVM 23. We still allow compiling rustc with older versions of LLVM. To (hopefully) prevent old LLVM from screwing this up with optimizations, this PR makes the backend emit an inline asm block *without* `willreturn`, which should prevent optimizations that break programs where a volatile load traps.

Cc @rust-lang/opsem @rust-lang/wg-llvm
2026-09-03 12:42:57 +02:00
Ralf Jung
ece2980246 volatile: allow accesses to trap 2026-09-02 14:46:04 +02:00
Folkert de Vries
bb0bcf25cc add itanium mangling test for f16 and f128 2026-09-01 21:50:00 +02:00
Folkert de Vries
45b97ea0cc itanium mangling: use minicore 2026-09-01 21:50:00 +02:00
Jonathan Brouwer
4679857002 Rollup merge of #161209 - scottmcm:redo-npot, r=clarfonthey
Rework `next_power_of_two` to always be `1 << …`

r? @clarfonthey
Who accidentally nerd-sniped me by mentioning rust-lang/rust#161069

This obviates that PR by reworking the `(checked_)next_power_of_two` logic to calculate the necessary exponent e, then return 2ᵉ, so it's structurally obvious from the IR -- the `shl nuw 1, …` instruction -- that it's always a power of two.

As always, the reason this is tricky is because shifts don't work for `<< Self::BITS`.  The previous code handled that by checking `self <= 1` first, and thus doing a `-1 >> n` where `n < BITS`.  This code instead flips the check: it looks up-front for a value that will wrap (an input above `1 << (BITS - 1)`) and thus by excluding those cases the calculated `1 << n` always has `n < BITS`.  And the codegen tests show that, without needing any `llvm.assume`s, LLVM can take advantage of it to do things like rewriting `%` to masking.  Plus the overflow check optimizes out for constrained inputs like slice lengths.
2026-09-01 21:26:16 +02:00
Folkert de Vries
9ed2e0c0ca reformat itanium mangling test to be more readable 2026-09-01 20:44:08 +02:00
Jonathan Brouwer
08a94d8b20 Rollup merge of #162040 - weihanglo:bump-stage0, r=cuviper
bootstrap: stage0 to cbae9b4cae2b108f6a3d18cfe6075714bb739463

This also contains a formatting change due to rustfmt bump.
Need this in order to test <https://github.com/rust-lang/rust/pull/161049>.
See also [#t-cargo > ✔ 1.99 beta backport](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/.E2.9C.94.201.2E99.20beta.20backport/with/619824670)

r? cuviper
2026-09-01 13:27:40 +02:00
Scott McMurray
f771946e61 Rework next_power_of_two to always be 1 << … 2026-08-31 12:42:39 -07:00
Weihang Lo
2060175f5a bootstrap: stage0 to cbae9b4cae2b108f6a3d18cfe6075714bb739463
Also contains a formatting change due to rustfmt bump
2026-08-30 22:57:52 -04:00
Scott McMurray
7519f42401 Add intrinsics for integer minimum and maximum 2026-08-30 00:48:34 -07:00
bors
6bb812b714 Auto merge of #161965 - JonathanBrouwer:rollup-wuyND0F, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#161692 (Allow Unpin impls for local extern type)
 - rust-lang/rust#161886 (compiler: Make +fix-cortex-a53-835769 a default feature for aarch64 fuchsia)
2026-08-29 08:31:18 +00:00
Jonathan Brouwer
711bd1a052 Rollup merge of #161886 - PiJoules:fix-cortex-a53-835769, r=jieyouxu
compiler: Make +fix-cortex-a53-835769 a default feature for aarch64 fuchsia

This matches the default target features for aarch64 fuchsia emitted by clang.
2026-08-29 10:07:38 +02:00
Jacob Pratt
36a684fdec Rollup merge of #161888 - PiJoules:sanitize-safestack-togglable, r=adwinwhite
compiler: Allow safestack to be togglable via #[sanitize(safestack = "...")]

Since safestack is a sanitizer, it should be possible to allow enabling/disabling it on functions like we do with the other sanitizers. It's likely that when adding the `#[sanitize(...)]` support for the other ones that safestack was just missed, so this makes safestack follow suite. It was also suggested in https://github.com/rust-lang/rust/pull/159873 that we just disable safestack this way for a specific test where we should check stack protector instrumentation.
2026-08-29 01:18:59 -04:00
Jonathan Brouwer
b1268fd125 Rollup merge of #161860 - tshepang:patch-3, r=chenyukang
atomicptr.rs test: remove unused import
2026-08-28 10:15:51 +02:00
Jonathan Brouwer
729e58af0f Rollup merge of #161528 - KevinA-cpu:regression-test-81342, r=khyperia
Add regression test to ensure optimal compilation

closes rust-lang/rust#81342
2026-08-28 10:15:46 +02:00
Jonathan Brouwer
43650ca540 Rollup merge of #161862 - bjorn3:wasm_link_section_segment_custom_section, r=alexcrichton
Put data segment in specified section with link_section on wasm

This is the normal behavior on other targets, but previously on wasm the data segment would be in the default section and instead a custom section with the given name would be added to the wasm module.

Fixes https://github.com/rust-lang/rust/issues/146538

r? alexcrichton
2026-08-28 10:15:42 +02:00
Leonard Chan
65184e6d1d compiler: Allow safestack to be togglable via #[sanitize(safestack = "...")] 2026-08-27 20:58:13 +00:00
Leonard Chan
42f6596205 compiler: Make +fix-cortex-a53-835769 a default feature for aarch64 fuchsia
This matches the default target features for aarch64 fuchsia emitted by
clang.
2026-08-27 20:39:08 +00:00
KevinA-cpu
4a96536ffa fix: apply suggestion from comment 2026-08-27 22:10:18 +07:00
bjorn3
281be7d22d Put data segment in specified section with link_section on wasm
This is the normal behavior on other targets, but previously on wasm the
data segment would be in the default section and instead a custom
section with the given name would be added to the wasm module.
2026-08-27 12:57:37 +02:00
bjorn3
3f09e9e49c Use extern "llvm-intrinsic" for some SVE LLVM intrinsics 2026-08-27 12:26:14 +02:00
bjorn3
6c4af72a31 Rename extern "unadjusted" to extern "llvm-intrinsic"
This makes it clear that it is only meant for LLVM intrinsics and not
for defining or calling arbitrary user functions.
2026-08-27 12:26:05 +02:00
bjorn3
63bf231e54 Remove a couple of unnecessary references to unadjusted ABI 2026-08-27 12:24:37 +02:00
Tshepang Mbambo
b20fe9bf6c atomicptr.rs test: remove unused import 2026-08-27 12:02:17 +02:00
Jonathan Brouwer
107540364e Rollup merge of #161774 - zakrad:regr-test-115026, r=JonathanBrouwer
Add codegen test for disjunction fed to unreachable_unchecked

Closes rust-lang/rust#115026
2026-08-25 23:01:11 +02:00
Jonathan Brouwer
44ec893f6f Rollup merge of #161724 - zakrad:regr-test-44041, r=chenyukang
Add codegen test for static table search loop unrolling

Adds a test for reported case in rust-lang/rust#44041. The follow up case in that issue is still open so this does not close it
2026-08-25 18:00:10 +02:00
zakrad
c42b90f54a Add codegen test for disjunction fed to unreachable_unchecked 2026-08-25 11:20:28 +03:30
Guillaume Gomez
0ce1db749b Rollup merge of #161670 - jakos-sec:large-data-threshold, r=nagisa
Pass LargeDataThreshold to LLVM module IR

Before, LargeDataThreshold was only set via `LLVMRustCreateTargetMachine`. When LTO is enabled, this information is required to be passed into the generated LLVM module IR files since the LTO linker spins up its own TargetMachine and otherwise has no knowledge of the LargeDataThreshold.

Currently, `-Z large-data-threshold` has no affect at all when compiling with LTO.
This commit makes sure that if `-Z large-data-threshold` is passed and not 0, it is preserved and stored into the generated LLVM IR.
2026-08-25 00:33:35 +02:00
Waffle Lapkin
046ebb717e remove #![feature(never_type)] from tests 2026-08-24 19:04:00 +02:00
KevinA-cpu
d23062897e fix: enfore 64bit for the test 2026-08-24 19:37:36 +07:00
Jakob Koschel
7eaf48cc1f Pass LargeDataThreshold to LLVM module IR
Before, LargeDataThreshold was only set via `LLVMRustCreateTargetMachine`.
When LTO is enabled, this information is required to be passed into the
generated LLVM module IR files since the LTO linker spins up its own
TargetMachine and otherwise has no knowledge of the LargeDataThreshold.

Currently, `-Z large-data-threshold` has no affect at all when compiling
with LTO.
This commit makes sure that if `-Z large-data-threshold` is passed and
not 0, it is preserved and stored into the generated LLVM IR.
2026-08-24 12:31:48 +00:00
zakrad
536f0a32b7 Add codegen test for static table search loop unrolling 2026-08-24 12:04:00 +03:30
zakrad
0c10bfa358 Add codegen test for Vec::clear lowering to an unconditional store 2026-08-24 11:53:07 +03:30
Stuart Cook
9a34abc30f Rollup merge of #161580 - zakrad:regr-test-78745, r=mu001999
Add codegen test for redundant bit mask after a range check

Closes rust-lang/rust#78745
2026-08-24 14:21:55 +10:00
Stuart Cook
d036963d43 Rollup merge of #161187 - folkertdev:complex-layout-simple-targets, r=fmease
add `Complex<T>` layout tests for straightforward targets

tracking issue: https://github.com/rust-lang/rust/issues/154023

Best reviewed commit-by-commit.

This PR does two things

- it updates and enables the CHECK lines for targets where rust already matches the ABI of complex numbers. The original check lines are what `clang` emits. Rust often specifies the same signature slightly differently, but those differences are just cosmetic, e.g. `{ half, half }` versus `[2 x half]`.
- adds some custom logic for complex numbers on `s390x`, so that they match `clang` and `gcc` for that target.

I've validated this extensively with `abi-cafe`. But also, this is just locking in the status-quo for an unstable feature. So, I'm not really looking for someone to pore over every line of the diff, just a coarse scan to see if anything odd jumps out. We have automated ways of checking that our logic is actually correct.
2026-08-24 14:21:44 +10:00
zakrad
412a5a5064 Add codegen test for redundant bit mask after a range check 2026-08-23 21:56:58 +03:30
KevinA-cpu
002e141091 Add regression test to ensure optimal compilation 2026-08-22 20:56:22 +07:00