Commit graph

5305 commits

Author SHA1 Message Date
bjorn3
173d38e22a Sync from rust 8387095803 2026-02-18 14:47:37 +00:00
bjorn3
6d0aca46a8 Simplify bootstrap patches 2026-02-17 11:22:03 +00:00
bjorn3
224eef62e8 Fix rustc test suite 2026-02-17 11:22:03 +00:00
bjorn3
7964c1b78d Rustup to rustc 1.95.0-nightly (3c9faa0d0 2026-02-16) 2026-02-17 11:00:57 +00:00
bjorn3
cef9cfee90 Sync from rust 3c9faa0d03 2026-02-17 10:47:17 +00:00
Stuart Cook
46c90c5113 Rollup merge of #152512 - okaneco:exact_integer, r=tgross35
core: Implement feature `float_exact_integer_constants`

Accepted ACP - https://github.com/rust-lang/libs-team/issues/713#issuecomment-3880122239
Tracking issue - https://github.com/rust-lang/rust/issues/152466

Implement accepted ACP for `MAX_EXACT_INTEGER` and `MIN_EXACT_INTEGER` on `f16`, `f32`, `f64`, and `f128`
Add tests to `coretests/tests/floats/mod.rs`
2026-02-17 13:02:22 +11:00
okaneco
d54a023c69 [cg_clif]: Fix codegen of f128 to i128 casts
Correct name for intrinsic that converts f128 to u128
Use `to_signed` instead of `from_signed` to ensure proper intrinsic
selected for u128/i128
2026-02-16 16:29:36 -05:00
xtqqczze
66c85df09d
actions: bump rustsec/audit-check to v2 (#1627) 2026-02-16 20:19:59 +01:00
bors
cb30787d4c Auto merge of #148190 - RalfJung:box_new, r=RalfJung
replace box_new with lower-level intrinsics

The `box_new` intrinsic is super special: during THIR construction it turns into an `ExprKind::Box` (formerly known as the `box` keyword), which then during MIR building turns into a special instruction sequence that invokes the exchange_malloc lang item (which has a name from a different time) and a special MIR statement to represent a shallowly-initialized `Box` (which raises [interesting opsem questions](https://github.com/rust-lang/rust/issues/97270)).

This PR is the n-th attempt to get rid of `box_new`. That's non-trivial because it usually causes a perf regression: replacing `box_new` by naive unsafe code will incur extra copies in debug builds, making the resulting binaries a lot slower, and will generate a lot more MIR, making compilation measurably slower. Furthermore, `vec!` is a macro, so the exact code it expands to is highly relevant for borrow checking, type inference, and temporary scopes.

To avoid those problems, this PR does its best to make the MIR almost exactly the same as what it was before. `box_new` is used in two places, `Box::new` and `vec!`:
- For `Box::new` that is fairly easy: the `move_by_value` intrinsic is basically all we need. However, to avoid the extra copy that would usually be generated for the argument of a function call, we need to special-case this intrinsic during MIR building. That's what the first commit does.
- `vec!` is a lot more tricky. As a macro, its details leak to stable code, so almost every variant I tried broke either type inference or the lifetimes of temporaries in some ui test or ended up accepting unsound code due to the borrow checker not enforcing all the constraints I hoped it would enforce. I ended up with a variant that involves a new intrinsic, `fn write_box_via_move<T>(b: Box<MaybeUninit<T>>, x: T) -> Box<MaybeUninit<T>>`, that writes a value into a `Box<MaybeUninit<T>>` and returns that box again. In exchange we can get rid of somewhat similar code in the lowering for `ExprKind::Box`, and the `exchange_malloc` lang item. (We can also get rid of `Rvalue::ShallowInitBox`; I didn't include that in this PR -- I think @cjgillot has a commit for this somewhere [around here](https://github.com/rust-lang/rust/pull/147862/commits).)

See [here](https://github.com/rust-lang/rust/pull/148190#issuecomment-3457454814) for the latest perf numbers. Most of the regressions are in deep-vector which consists entirely of an invocation of `vec!`, so any change to that macro affects this benchmark disproportionally.

This is my first time even looking at MIR building code, so I am very low confidence in that part of the patch, in particular when it comes to scopes and drops and things like that.

I also had do nerf some clippy tests because clippy gets confused by the new expansion of `vec!` so it makes fewer suggestions when `vec!` is involved.

### `vec!` FAQ

- Why does `write_box_via_move` return the `Box` again? Because we need to expand `vec!` to a bunch of method invocations without any blocks or let-statements, or else the temporary scopes (and type inference) don't work out.
- Why is `box_assume_init_into_vec_unsafe` (unsoundly!) a safe function? Because we can't use an unsafe block in `vec!` as that would necessarily also include the `$x` (due to it all being one big method invocation) and therefore interpret the user's code as being inside `unsafe`, which would be bad (and 10 years later, we still don't have safe blocks for macros like this).
- Why does `write_box_via_move` use `Box` as input/output type, and not, say, raw pointers? Because that is the only way to get the correct behavior when `$x` panics or has control effects: we need the `Box` to be dropped in that case. (As a nice side-effect this also makes the intrinsic safe, which is imported as explained in the previous bullet.)
- Can't we make it safe by having `write_box_via_move` return `Box<T>`? Yes we could, but there's no easy way for the intrinsic to convert its `Box<MaybeUninit<T>>` to a `Box<T>`. Transmuting would be unsound as the borrow checker would no longer properly enforce that lifetimes involved in a `vec!` invocation behave correctly.
- Is this macro truly cursed? Yes, yes it is.
2026-02-16 18:46:10 +00:00
Ralf Jung
db5ed68a88 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00
bjorn3
e028e7848c Re-enable fixed rustc test 2026-02-16 09:53:02 +00:00
bjorn3
417cc114f5 Rustup to rustc 1.95.0-nightly (873b4beb0 2026-02-15) 2026-02-16 09:42:54 +00:00
bjorn3
66d6f559bf Sync from rust 873b4beb0c 2026-02-16 09:37:49 +00:00
Trevor Gross
b28ebc87a8 clif: Only set has_reliable_f128_math with glibc
New float tests in core are failing on clif with issues like the
following:

    Undefined symbols for architecture arm64:
        "_coshf128", referenced from:
            __RNvMNtCshY0fR2o0hOA_3std4f128C4f1284coshCs5TKtJxXQNGL_9coretests in coretests-e38519c0cc90db54.coretests.44b6247a565e10d1-cgu.10.rcgu.o
                "_exp2f128", referenced from:
            __RNvMNtCshY0fR2o0hOA_3std4f128C4f1284exp2Cs5TKtJxXQNGL_9coretests in coretests-e38519c0cc90db54.coretests.44b6247a565e10d1-cgu.10.rcgu.o
        ...

Disable f128 math unless the symbols are known to be available, which
for now is only glibc targets. This matches the LLVM backend.
2026-02-15 18:00:54 +00:00
xonx
5868ac677e unify and deduplicate floats 2026-02-15 18:00:41 +00:00
Jacob Pratt
0eca6c0058 Rollup merge of #152573 - usamoi:escape-2, r=bjorn3
move `escape_symbol_name` to `cg_ssa`

followup of rust-lang/rust#151955

r? @bjorn3
2026-02-13 22:26:33 -05:00
Jonathan Brouwer
b9ce2e420a Rollup merge of #152469 - mu001999-contrib:cleanup/unused-features, r=nadrieril,jdonszelmann
Remove unused features

Detected by https://github.com/rust-lang/rust/pull/152164.

~~Only allow `unused_features` if there are complex platform-specific features enabled.~~
2026-02-13 13:34:58 +01:00
usamoi
15831ddb75 move escape_symbol_name to cg_ssa 2026-02-13 20:31:18 +08:00
bjorn3
0b47779223 Fix rustc test suite 2026-02-13 11:30:56 +00:00
bjorn3
47f2bf6d65 Rustup to rustc 1.95.0-nightly (47611e160 2026-02-12) 2026-02-13 10:38:52 +00:00
bjorn3
33e6037170 Sync from rust 47611e1604 2026-02-13 10:29:17 +00:00
mu001999
81cb2a9d6d Remove unused features in compiler 2026-02-13 09:25:39 +08:00
bjorn3
99147c1808 Use cg_ssa's produce_final_output_artifacts in cg_clif 2026-02-11 12:36:19 +00:00
bjorn3
47b2f234bc Update to Cranelift 0.128 2026-02-05 10:02:13 +00:00
bjorn3
3318d22754 Convert to inline diagnostics in all codegen backends 2026-02-04 13:12:49 +00:00
bjorn3
b871f6c767 Fix running rustc tests in CI 2026-02-03 14:48:45 +00:00
bjorn3
0ad8260c75 Update a couple of dependencies 2026-01-27 11:31:02 +00:00
bjorn3
cf9e94ca49 Move some rustc test disables around 2026-01-27 10:44:55 +00:00
bjorn3
20e7d31d4d Re-enable a couple of rustc tests 2026-01-27 10:28:58 +00:00
bjorn3
c73f662595 Rustup to rustc 1.95.0-nightly (474276961 2026-01-26) 2026-01-27 10:14:50 +00:00
bjorn3
2859fde18a Fix rustc test suite 2026-01-26 16:57:51 +00:00
bjorn3
82fc4ec595 Rustup to rustc 1.95.0-nightly (873d4682c 2026-01-25) 2026-01-26 16:24:35 +00:00
bjorn3
3a3e5f5fa5 Sync from rust 873d4682c7 2026-01-26 16:17:22 +00:00
bors
156bce9ca3 Auto merge of #151065 - nagisa:add-preserve-none-abi, r=petrochenkov
abi: add a rust-preserve-none calling convention

This is the conceptual opposite of the rust-cold calling convention and is particularly useful in combination with the new `explicit_tail_calls` feature.

For relatively tight loops implemented with tail calling (`become`) each of the function with the regular calling convention is still responsible for restoring the initial value of the preserved registers. So it is not unusual to end up with a situation where each step in the tail call loop is spilling and reloading registers, along the lines of:

    foo:
        push r12
        ; do things
        pop r12
        jmp next_step

This adds up quickly, especially when most of the clobberable registers are already used to pass arguments or other uses.

I was thinking of making the name of this ABI a little less LLVM-derived and more like a conceptual inverse of `rust-cold`, but could not come with a great name (`rust-cold` is itself not a great name: cold in what context? from which perspective? is it supposed to mean that the function is rarely called?)
2026-01-25 02:49:32 +00:00
Matthias Krüger
04db0fb5da Rollup merge of #151346 - folkertdev:simd-splat, r=workingjubilee
add `simd_splat` intrinsic

Add `simd_splat` which lowers to the LLVM canonical splat sequence.

```llvm
insertelement <N x elem> poison, elem %x, i32 0
shufflevector <N x elem> v0, <N x elem> poison, <N x i32> zeroinitializer
```

Right now we try to fake it using one of

```rust
fn splat(x: u32) -> u32x8 {
    u32x8::from_array([x; 8])
}
```

or (in `stdarch`)

```rust
fn splat(value: $elem_type) -> $name {
    #[derive(Copy, Clone)]
    #[repr(simd)]
    struct JustOne([$elem_type; 1]);
    let one = JustOne([value]);
    // SAFETY: 0 is always in-bounds because we're shuffling
    // a simd type with exactly one element.
    unsafe { simd_shuffle!(one, one, [0; $len]) }
}
```

Both of these can confuse the LLVM optimizer, producing sub-par code. Some examples:

- https://github.com/rust-lang/rust/issues/60637
- https://github.com/rust-lang/rust/issues/137407
- https://github.com/rust-lang/rust/issues/122623
- https://github.com/rust-lang/rust/issues/97804

---

As far as I can tell there is no way to provide a fallback implementation for this intrinsic, because there is no `const` way of evaluating the number of elements (there might be issues beyond that, too). So, I added implementations for all 4 backends.

Both GCC and const-eval appear to have some issues with simd vectors containing pointers. I have a workaround for GCC, but haven't yet been able to make const-eval work. See the comments below.

Currently this just adds the intrinsic, it does not actually use it anywhere yet.
2026-01-24 21:04:15 +01:00
Simonas Kazlauskas
11d0889dc0 abi: add a rust-preserve-none calling convention
This is the conceptual opposite of the rust-cold calling convention and
is particularly useful in combination with the new `explicit_tail_calls`
feature.

For relatively tight loops implemented with tail calling (`become`) each
of the function with the regular calling convention is still responsible
for restoring the initial value of the preserved registers. So it is not
unusual to end up with a situation where each step in the tail call loop
is spilling and reloading registers, along the lines of:

    foo:
        push r12
        ; do things
        pop r12
        jmp next_step

This adds up quickly, especially when most of the clobberable registers
are already used to pass arguments or other uses.

I was thinking of making the name of this ABI a little less LLVM-derived
and more like a conceptual inverse of `rust-cold`, but could not come
with a great name (`rust-cold` is itself not a great name: cold in what
context? from which perspective? is it supposed to mean that the
function is rarely called?)
2026-01-24 19:23:17 +02:00
Pratham Jaiswal
41b7226b85
Fix CI disk space issue for abi-cafe tests (#1625)
* Fix CI disk space issue for abi-cafe tests

Port disk space cleanup script from rust-lang/rust to free space on
GitHub Actions runners before running abi-cafe tests.

* ci: update free-disk-space.sh to match rust-lang/rust@d29e478

* ci: set RUNNER_ENVIRONMENT=github-hosted for free-disk-space script

* Revert indentation change

---------

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2026-01-24 16:31:40 +01:00
León Orell Valerian Liehr
fe61cd6fa3 Support debuginfo for assoc const bindings 2026-01-21 18:52:08 +01:00
bjorn3
7b8c532d9a Rustup to rustc 1.95.0-nightly (5c49c4f7c 2026-01-20) 2026-01-21 12:32:38 +00:00
bjorn3
d43ca00f96 Sync from rust 5c49c4f7c8 2026-01-21 12:21:18 +00:00
Jacob Pratt
63c439fe18 Rollup merge of #150436 - va-list-copy, r=workingjubilee,RalfJung
`c_variadic`: impl `va_copy` and `va_end` as Rust intrinsics

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

Implement `va_copy` as (the rust equivalent of) `memcpy`, which is the behavior of all current LLVM targets. By providing our own implementation, we can guarantee its behavior. These guarantees are important for implementing c-variadics in e.g. const-eval.

Discussed in [#t-compiler/const-eval > c-variadics in const-eval](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/c-variadics.20in.20const-eval/with/565509704).

I've also updated the comment for `Drop` a bit. The background here is that the C standard requires that `va_end` is used in the same function (and really, in the same scope) as the corresponding `va_start` or `va_copy`. That is because historically `va_start` would start a scope, which `va_end` would then close. e.g.

https://softwarepreservation.computerhistory.org/c_plus_plus/cfront/release_3.0.3/source/incl-master/proto-headers/stdarg.sol

```c
#define         va_start(ap, parmN)     {\
        va_buf  _va;\
        _vastart(ap = (va_list)_va, (char *)&parmN + sizeof parmN)
#define         va_end(ap)      }
#define         va_arg(ap, mode)        *((mode *)_vaarg(ap, sizeof (mode)))
```

The C standard still has to consider such implementations, but for Rust they are irrelevant. Hence we can use `Clone` for `va_copy` and `Drop` for `va_end`.
2026-01-20 19:46:29 -05:00
Folkert de Vries
0b71ff60f8 c_variadic: use Clone instead of LLVM va_copy 2026-01-20 18:38:50 +01:00
Jonathan Brouwer
9949a536d3 Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
Folkert de Vries
ef9002c3d7 add simd_splat intrinsic 2026-01-19 16:48:28 +01:00
bjorn3
fd97bb64ce Rustup to rustc 1.94.0-nightly (f6a07efc8 2026-01-16) 2026-01-17 16:13:30 +00:00
bjorn3
4d4fb2784f Pass -Zbinary-dep-depinfo when testing rustc tests 2026-01-17 16:03:18 +00:00
bjorn3
e4e41b7426 Use -Zno-embed-metadata for the codegen backend and sysroot
This saves about 10MB on the dist size and about 240MB on the build dir
size.
2026-01-14 11:18:07 +00:00
bjorn3
0b05e69bce Rustup to rustc 1.94.0-nightly (2850ca829 2026-01-13) 2026-01-14 10:59:12 +00:00
bjorn3
94d5977b6c Sync from rust 2850ca8295 2026-01-14 10:53:34 +00:00
bjorn3
a03e769410 Improve standard library source remapping 2026-01-11 17:58:51 +00:00