Commit graph

5294 commits

Author SHA1 Message Date
xtqqczze
66c85df09d
actions: bump rustsec/audit-check to v2 (#1627) 2026-02-16 20:19:59 +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
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
bjorn3
4d0b725e06 Add a gdb helper for jit backtraces 2026-01-11 17:30:41 +00:00
bjorn3
c1569cc007 Lower extern "rust-cold" to default calling convention
The next Cranelift release will support for CallConv::Cold as it was
already effectively equivalent to the default calling convention.
2026-01-11 17:25:20 +00:00
Pavel Grigorenko
b86553f808 Stabilize alloc_layout_extra 2026-01-11 16:39:18 +03:00
Martin Nordholts
0cba97b3b4 Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
bjorn3
9c369a43ce Rustup to rustc 1.94.0-nightly (fcd630976 2026-01-01) 2026-01-02 18:15:51 +00:00
bjorn3
b908e2e552 Sync from rust fcd630976c 2026-01-02 11:47:26 +00:00
bjorn3
6da1048236 Fix some divergences with the cg_clif subtree
For some reason git-subtree incorrectly synced those changes.
2025-12-24 15:16:59 +00:00
bors
fcdea4d663 Auto merge of #149114 - BoxyUwU:mgca_adt_exprs, r=lcnr
MGCA: Support struct expressions without intermediary anon consts

r? oli-obk

tracking issue: rust-lang/rust#132980

Fixes rust-lang/rust#127972
Fixes rust-lang/rust#137888
Fixes rust-lang/rust#140275

due to delaying a bug instead of ICEing in HIR ty lowering.

### High level goal

Under `feature(min_generic_const_args)` this PR adds another kind of const argument. A struct/variant construction const arg kind. We represent the values of the fields as themselves being const arguments which allows for uses of generic parameters subject to the existing restrictions present in `min_generic_const_args`:
```rust
fn foo<const N: Option<u32>>() {}

trait Trait {
    #[type_const]
    const ASSOC: usize;
}

fn bar<T: Trait, const N: u32>() {
    // the initializer of `_0` is a `N` which is a legal const argument
    // so this is ok.
    foo::<{ Some::<u32> { 0: N } }>();

    // this is allowed as mgca supports uses of assoc consts in the
    // type system. ie `<T as Trait>::ASSOC` is a legal const argument
    foo::<{ Some::<u32> { 0: <T as Trait>::ASSOC } }>();

    // this on the other hand is not allowed as `N + 1` is not a legal
    // const argument
    foo::<{ Some::<u32> { 0: N + 1 } }>();
}
```

This PR does not support uses of const ctors, e.g. `None`. And also does not support tuple constructors, e.g. `Some(N)`. I believe that it would not be difficult to add support for such functionality after this PR lands so have left it out deliberately.

We currently require that all generic parameters on the type being constructed be explicitly specified. I haven't really looked into why that is but it doesn't seem desirable to me as it should be legal to write `Some { ... }` in a const argument inside of a body and have that desugar to `Some::<_> { ... }`. Regardless this can definitely be a follow-up PR and I assume this is some underlying consistency with the way that elided args are handled with type paths elsewhere.

This PRs implementation of supporting struct expressions is somewhat incomplete. We don't handle `Foo { ..expr }` at all and aren't handling privacy/stability. The printing of `ConstArgKind::Struct` HIR nodes doesn't really exist either :')

I've tried to keep the implementation here somewhat deliberately incomplete as I think a number of these issues are actually quite small and self contained after this PR lands and I'm hoping it could be a good set of issues to mentor newer contributors on 🤔 I just wanted the "bare minimum" required to actually demonstrate that the previous changes are "necessary".

### `ValTree` now recurse through `ty::Const`

In order to actually represent struct/variant construction in `ty::Const` without going through an anon const we would need to introduce some new `ConstKind` variant. Let's say some hypothetical `ConstKind::ADT(Ty<'tcx>, List<Const<'tcx>>)`.

This variant would represent things the same way that `ValTree` does with the first element representing the `VariantIdx` of the enum (if its an enum), and then followed by a list of field values in definition order.

This *could* work but there are a few reasons why it's suboptimal.

First it would mean we have a second kind of `Const` that can be normalized. Right now we only have `ConstKind::Unevaluated` which possibly needs normalization. Similarly with `TyKind` we *only* have `TyKind::Alias`. If we introduced `ConstKind::ADT` it would need to be normalized to a `ConstKind::Value` eventually. This feels to me like it has the potential to cause bugs in the long run where only `ConstKind::Unevaluated` is handled by some code paths.

Secondly it would make type equality/inference be kind of... weird... It's desirable for `Some { 0: ?x } eq Some { 0: 1_u32 }` to result in `?x=1_u32`.  I can't see a way for this to work with this `ConstKind::ADT` design under the current architecture for how we represent types/consts and generally do equality operations.

We would need to wholly special case these two variants in type equality and have a custom recursive walker separate from the existing architecture for doing type equality. It would also be somewhat unique in that it's a non-rigid `ty::Const` (it can be normalized more later on in type inference) while also having somewhat "structural" equality behaviour.

Lastly, it's worth noting that its not *actually* `ConstKind::ADT` that we want. It's desirable to extend this setup to also support tuples and arrays, or even references if we wind up supporting those in const generics. Therefore this isn't really `ConstKind::ADT` but a more general `ConstKind::ShallowValue` or something to that effect. It represents at least one "layer" of a types value :')

Instead of doing this implementation choice we instead change `ValTree::Branch`:
```rust
enum ValTree<'tcx> {
    Leaf(ScalarInt),
    // Before this PR:
    Branch(Box<[ValTree<'tcx>]>),
    // After this PR
    Branch(Box<[Const<'tcx>]>),
}
```

The representation for so called "shallow values" is now the same as the representation for the *entire* full value. The desired inference/type equality behaviour just falls right out of this. We also don't wind up with these shallow values actually being non-rigid. And `ValTree` *already* supports references/tuples/arrays so we can handle those just fine.

I think in the future it might be worth considering inlining `ValTree` into `ty::ConstKind`. E.g:
```rust
enum ConstKind {
    Scalar(Ty<'tcx>, ScalarInt),
    ShallowValue(Ty<'tcx>, List<Const<'tcx>>),
    Unevaluated(UnevaluatedConst<'tcx>),
    ...
}
```

This would imply that the usage of `ValTree`s in patterns would now be using `ty::Const` but they already kind of are anyway and I think that's probably okay in the long run. It also would mean that the set of things we *could* represent in const patterns is greater which may be desirable in the long run for supporting things such as const patterns of const generic parameters.

Regardless, this PR doesn't actually inline `ValTree` into `ty::ConstKind`, it only changes `Branch` to recurse through `Const`. This change could be split out of this PR if desired.

I'm not sure if there'll be a perf impact from this change. It's somewhat plausible as now all const pattern values that have nesting will be interning a lot more `Ty`s. We shall see :>

### Forbidding generic parameters under mgca

Under mgca we now allow all const arguments to resolve paths to generic parameters. We then *later* actually validate that the const arg should be allowed to access generic parameters if it did wind up resolving to any.

This winds up just being a lot simpler to implement than trying to make name resolution "keep track" of whether we're inside of a non-anon-const const arg and then encounter a `const { ... }` indicating we should now stop allowing resolving to generic parameters.

It's also somewhat in line with what we'll need for a `feature(generic_const_args)` where we'll want to decide whether an anon const should have any generic parameters based off syntactically whether any generic parameters were used. Though that design is entirely hypothetical at this point :)

### Followup Work

- Make HIR ty lowering check whether lowering generic parameters is supported and if not lower to an error type/const. Should make the code cleaner, fix some other bugs, and maybe(?) recover perf since we'll be accessing less queries which I think is part of the perf regression of this PR
- Make the ValTree setup less scuffed. We should find a new name for `ConstKind::Value` and the `Val` part of `ValTree` and `ty::Value` as they no longer correspond to a fully normalized structure. It may also be worth looking into inlining `ValTreeKind` into `ConstKind` or atleast into `ty::Value` or sth 🤔
- Support tuple constructors and const constructors not just struct expressions.
- Reduce code duplication between HIR ty lowering's handling of struct expressions, and HIR typeck's handling of struct expressions
- Try fix perf https://github.com/rust-lang/rust/pull/149114#issuecomment-3668038853. Maybe this will clear up once we clean up `ValTree` a bit and stop doing double interning and whatnot
2025-12-23 23:53:55 +00:00
bjorn3
4e375db44a Merge commit '6f3f6bdacb' into sync_cg_clif-2025-12-23 2025-12-23 17:47:42 +00:00
bjorn3
6f3f6bdacb Rustup to rustc 1.94.0-nightly (4f14395c3 2025-12-22) 2025-12-23 16:22:22 +00:00
bjorn3
de4168be8c Sync from rust 4f14395c37 2025-12-23 16:07:31 +00:00