Commit graph

1287 commits

Author SHA1 Message Date
bors
a371038013 Auto merge of #149426 - antoyo:libgccjit-targets, r=Kobzol
Move the libgccjit.so file in a target directory

Since GCC is not multi-target, we need multiple libgccjit.so. Our solution to have a directory per target so that we can have multiple libgccjit.so.

r? `@Kobzol`
2025-12-09 01:58:46 +00:00
Antoni Boucher
ea0995a91a Ignore failing GCC test 2025-12-05 09:51:27 -05:00
Boxy Uwu
76bd21ad66 account for safe target features in fndef<->closure and fndef<->fndef coerce-lubs 2025-12-03 14:55:41 +00:00
bors
4ad239f415 Auto merge of #142821 - cjgillot:jump-threading-single, r=saethlin
Compute jump threading opportunities in a single pass

The current implementation of jump threading walks MIR CFG backwards from each `SwitchInt` terminator. This PR replaces this by a single postorder traversal of MIR. In theory, we could do a full fixpoint dataflow analysis, but this has low returns as we forbid threading through a loop header.

The second commit in this PR modifies the carried state to a lighter data structure. The current implementation uses some kind of `IndexVec<ValueIndex, &[Condition]>`. This is needlessly heavy, as the state rarely ever carries more than a few `Condition`s. The first commit replaces this state with a simpler `&[Condition]`, and puts the corresponding `ValueIndex` inside `Condition`.

The three later commits are perf tweaks.

The sixth commit is the main change. Instead of carrying the goto target inside the condition, we maintain a set of conditions associated with each block, and their consequences in following blocks. Think: if this condition is fulfilled in this block, then that condition is fulfilled in that block. This makes the threading algorithm much easier to implement, without the extra bookkeeping of `ThreadingOpportunity` we had.

Later commits modify that algorithm to shrink the set of duplicated blocks. By propagating fulfilled conditions down the CFG, and trimming costly threads.
2025-12-01 23:44:49 +00:00
Stuart Cook
549c577c2a
Rollup merge of #149087 - nxsaken:unchecked_neg_shifts_stabilize, r=Amanieu
Stabilize `unchecked_neg` and `unchecked_shifts`

Features: `unchecked_neg`, `unchecked_shifts`
Tracking issue: rust-lang/rust#85122

r? `@Amanieu`
2025-11-28 15:30:43 +11:00
bors
e9acbd99d3 Auto merge of #147827 - saethlin:maybeuninit-codegen2, r=scottmcm
Fix MaybeUninit codegen using GVN

This is an alternative to https://github.com/rust-lang/rust/pull/142837, based on https://github.com/rust-lang/rust/pull/146355#discussion_r2421651968.

The general approach I took here is to aggressively propagate anything that is entirely uninitialized. GVN generally takes the approach of only synthesizing small types, but we need to generate large consts to fix the codegen issue.

I also added a special case to MIR dumps for this where now an entirely uninit const is printed as `const <uninit>`, because otherwise we end up with extremely verbose dumps of the new consts.

After GVN though, we still end up with a lot of MIR that looks like this:
```
StorageLive(_1);
_1 = const <uninit>;
_2 = &raw mut _1;
```
Which will break tests/codegen-llvm/maybeuninit-rvo.rs with the naive lowering. I think the ideal fix here is to somehow omit these `_1 = const <uninit>` assignments that come directly after a StorageLive, but I'm not sure how to do that. For now at least, ignoring such assignments (even if they don't come right after a StorageLive) in codegen seems to work.

Note that since GVN is based on synthesizing a `ConstValue`  which has a defined layout, this scenario still gets deoptimized by LLVM.
```rust
#![feature(rustc_attrs)]
#![crate_type = "lib"]
use std::mem::MaybeUninit;

#[unsafe(no_mangle)]
pub fn oof() -> [[MaybeUninit<u8>; 8]; 8] {
    #[rustc_no_mir_inline]
    pub fn inner<T: Copy>() -> [[MaybeUninit<T>; 8]; 8] {
        [[MaybeUninit::uninit(); 8]; 8]
    }

    inner()
}
```
This case can be handled correctly if enough inlining has happened, or it could be handled by post-mono GVN. Synthesizing `UnevaluatedConst` or some other special kind of const seems dubious.
2025-11-23 17:09:07 +00:00
Ben Kimock
1a4852c5fe Fix MaybeUninit codegen using GVN 2025-11-23 08:23:49 -05:00
Tomasz Miąsko
6bd1a031ab Turn moves into copies after copy propagation
Previously copy propagation presumed that there is further unspecified
distinction between move operands and copy operands in assignments and
propagated moves from assignments into terminators. This is inconsistent
with current operational semantics.

Turn moves into copies after copy propagation to preserve existing behavior.

Fixes https://github.com/rust-lang/rust/issues/137936.
Fixes https://github.com/rust-lang/rust/issues/146423.
2025-11-20 19:23:10 +01:00
nxsaken
47153b5276 Stabilize unchecked_neg and unchecked_shifts 2025-11-19 13:19:22 +04:00
Camille Gillot
72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
Camille Gillot
223620f3c6 Filter costly chains after simplification. 2025-11-16 01:38:16 +00:00
Camille Gillot
2a63fde0bc Simplify condition graph. 2025-11-16 01:38:16 +00:00
Camille GILLOT
f59dfc1a4a Maintain a graph of fulfilled conditions. 2025-11-16 01:38:16 +00:00
Camille GILLOT
d67e3e6c5a Use a simpler condition set in jump threading. 2025-11-16 01:38:11 +00:00
Camille Gillot
bd8db4548e Add tests. 2025-11-16 01:37:48 +00:00
Camille GILLOT
ee16aed94c Fortify test. 2025-11-16 01:37:48 +00:00
Stuart Cook
f61bfb0037
Rollup merge of #148725 - scottmcm:experiment-new-try-block-v3, r=petrochenkov
Implement the alternative `try` block desugaring

As discussed in https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727, update the `try` in nightly to match the RFC as a way to experiment.

This addresses the following unresolved issue from https://github.com/rust-lang/rust/issues/31436

>  Address issues with type inference (`try { expr? }?` currently requires an explicit type annotation somewhere).
2025-11-14 19:57:06 +11:00
Scott McMurray
e5803fceed Move into_try_type to a free function 2025-11-13 19:53:02 -08:00
Stuart Cook
1c32a0b6bb
Rollup merge of #148928 - WaffleLapkin:always-test, r=jieyouxu
Move & adjust some `!`-adjacent tests

I'm trying to clean up tests relating to the never type...
2025-11-14 13:14:10 +11:00
Waffle Lapkin
b13f49e419
add explanation comments to !-related tests
... outside `tests/ui/never_type/`
2025-11-14 00:04:58 +01:00
Waffle Lapkin
5d33ab1316
fix some typos in !-related test comments 2025-11-14 00:04:54 +01:00
Mara Bos
8b20d0d0a1 Allow larger string pieces in fmt::Arguments repr. 2025-11-12 12:48:44 +01:00
Mara Bos
04c5e7b54a Document fmt::Arguments internal representation. 2025-11-12 12:48:39 +01:00
Mara Bos
7b42543f81 Bless tests. 2025-11-12 12:48:27 +01:00
klensy
e611ef32f8 fix filecheck typos in tests 2025-11-10 17:55:01 +03:00
Scott McMurray
86c3ba754a Implement the alternative try desugaring 2025-11-09 04:09:10 -08:00
Stuart Cook
aa458ff6bc
Rollup merge of #147925 - fneddy:fix_big_endian_GVN_tests, r=saethlin
Fix tests for big-endian

The tests fail on s390x and presumably other big-endian systems, due to check of raw alloc values in the MIR output.

To fix the tests remove the raw bytes from the MIR output (via: compile-flags: -Zdump-mir-exclude-alloc-bytes) and update the matching diffs.
2025-11-05 10:59:18 +11:00
Guillaume Gomez
c97bde7df7
Rollup merge of #135099 - Shunpoco:116971-mir-opt-copy-prop, r=davidtwco
Add FileCheck annotations to mir-opt/copy-prop

This resolves a part of https://github.com/rust-lang/rust/issues/116971 .

This PR adds FileCheck annotations to test files under mir-opt/copy-prop.
2025-11-03 17:20:31 +01:00
bors
df984edf44 Auto merge of #147083 - dianne:non-extended-indices, r=matthewjasper
Do not lifetime-extend array/slice indices

When lowering non-overloaded indexing operations to MIR, this uses the temporary lifetime of the index expression for the index temporary, rather than applying the temporary lifetime of the indexing operation as a whole to the index.

For example, in
```rust
let x = &xs[i];
```
previously, the temporary containing the result of evaluating `i` would live until the end of the block due to the indexing operation being [lifetime-extended](https://doc.rust-lang.org/nightly/reference/destructors.html#temporary-lifetime-extension). Under this PR, the index temporary only lives to the end of the `let` statement because it uses the more precise temporary lifetime of the index expression.

I don't think this will affect semantics in an observable way, but the more precise `StorageDead` placement may slightly improve analysis/codegen performance.

r? mir
2025-10-28 03:02:00 +00:00
Shunpoco
620b9b15cd Add FileCheck to reborrow.rs 2025-10-26 11:58:30 +01:00
Shunpoco
8ae4d57afb Add FileCheck to partial_init.rs 2025-10-26 11:58:26 +01:00
Shunpoco
aa83f1799b Add FileCheck to non_dominate.rs 2025-10-26 11:58:22 +01:00
Shunpoco
6eaf4fedcf Add FileCheck to mutate_through_pointer.rs 2025-10-26 11:58:17 +01:00
Shunpoco
3d12668f21 Add FileCheck to move_projection.rs 2025-10-26 11:58:14 +01:00
Shunpoco
13e971e532 Add FileCheck to move_arg.rs 2025-10-26 11:58:10 +01:00
Shunpoco
dd2d390876 Add FileCheck to issue_107511.rs 2025-10-26 11:58:06 +01:00
Shunpoco
76dc555dc9 remove dead_stores_better.rs
As we discussed, it is identical with dead_stores_79191
2025-10-26 11:58:01 +01:00
Shunpoco
109870df2c Add FileCheck to dead_stores_79191.rs 2025-10-26 11:57:57 +01:00
Shunpoco
ff260c850c Add FileCheck to cycle.rs 2025-10-26 11:57:54 +01:00
Shunpoco
17b0d90365 Add FileCheck to custom_move_arg.rs 2025-10-26 11:57:50 +01:00
Shunpoco
c204231d96 Add FileCheck to copy_propagation_arg.rs 2025-10-26 11:57:46 +01:00
Shunpoco
3b1e20ce5d Add FileCheck to calls.rs 2025-10-26 11:57:41 +01:00
Shunpoco
e36689aea7 Add FileCheck to branch.rs 2025-10-26 11:57:35 +01:00
Camille Gillot
a15ef42488 Only load pin field once. 2025-10-24 02:41:50 +00:00
Camille Gillot
5dfbf67f94 Replace NullOp::SizeOf and NullOp::AlignOf by lang items. 2025-10-23 00:38:28 +00:00
Camille Gillot
51275e82c9 Elaborate ShallowInitBox too. 2025-10-22 00:52:52 +00:00
Eduard Stefes
cbae95602f Fix tests for big-endian
The tests fail on s390x and presumably other big-endian systems, due
to check of raw alloc values in the MIR output.

To fix the tests remove the raw bytes from the MIR output
(via: compile-flags: -Zdump-mir-exclude-alloc-bytes) and update the
matching diffs.
2025-10-21 08:30:41 +02:00
dianqk
afff0502a6
GVN: Preserve derefs at terminators that cannot write to memory 2025-10-16 23:03:05 +08:00
dianqk
a673575b24
mir-opt: Simplify trivial constants in SimplifyConstCondition 2025-10-16 21:30:06 +08:00
bors
e100792918 Auto merge of #147662 - Zalathar:rollup-j8ci0f2, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#146277 (Enable `u64` limbs in `core::num::bignum`)
 - rust-lang/rust#146976 (constify basic Clone impls)
 - rust-lang/rust#147249 (Do two passes of `handle_opaque_type_uses_next`)
 - rust-lang/rust#147266 (fix 2 search graph bugs)
 - rust-lang/rust#147497 (`proc_macro` cleanups (3/N))
 - rust-lang/rust#147546 (Suppress unused_parens for labeled break)
 - rust-lang/rust#147548 (Fix ICE for never pattern as closure parameters)
 - rust-lang/rust#147594 (std: implement `pal::os::exit` for VEXos)
 - rust-lang/rust#147596 (Adjust the Arm targets in CI to reflect latest changes)
 - rust-lang/rust#147607 (GVN: Invalidate derefs at loop headers)
 - rust-lang/rust#147620 (Avoid redundant UB check in RangeFrom slice indexing)
 - rust-lang/rust#147647 (Hide vendoring and copyright in GHA group)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-14 12:32:31 +00:00