Commit Graph

49931 Commits

Author SHA1 Message Date
lcnr
b51a3a565a review 2025-09-08 14:17:56 +02:00
lcnr
f514586408 optimize CanonicalVarValues::instantiate 2025-09-08 14:17:56 +02:00
lcnr
28a0e77d13 pass sub_relations into canonical queries 2025-09-08 14:17:56 +02:00
lcnr
2cb04b960f inline CanonicalTyVarKind 2025-09-08 14:17:56 +02:00
lcnr
67965f817d eagerly compute sub_relations again 2025-09-08 14:17:56 +02:00
bors
a09fbe2c83 Auto merge of #145910 - saethlin:ignore-intrinsic-calls, r=cjgillot
Ignore intrinsic calls in cross-crate-inlining cost model

I noticed in a side project that a function which just compares to `[u64; 2]` for equality is not cross-crate-inlinable. That was surprising to me because I didn't think that code contained a function call, but of course our array comparisons are lowered to an intrinsic. Intrinsic calls don't make a function no longer a leaf, so it makes sense to add this as an exception to the "only leaves" cross-crate-inline heuristic.

This is the useful compare link: https://perf.rust-lang.org/compare.html?start=7cb1a81145a739c4fd858abe3c624ce8e6e5f9cd&end=c3f0a64dbf9fba4722dacf8e39d2fe00069c995e&stat=instructions%3Au because it disables CGU merging in both commits, so effects that cause changes in the sysroot to perturb partitioning downstream are excluded. Perturbations to what is and isn't cross-crate-inlinable in the sysroot has chaotic effects on what items are in which CGUs after merging. It looks like before this PR by sheer luck some of the CGUs dirtied by the patch in eza incr-unchanged happened to be merged together, and with this PR they are not.

The perf runs on this PR point to a nice runtime performance improvement.
2025-09-08 03:03:21 +00:00
bors
2f3f27bf79 Auto merge of #145541 - cjgillot:dest-prop-live-range, r=Amanieu
Reimplement DestinationPropagation according to live ranges.

This PR reimplements DestinationPropagation as a problem of merging live-ranges of locals. We merge locals that have disjoint live-ranges. This allows merging several locals in the same round by updating live range information.

Live ranges are mainly computed using the `MaybeLiveLocals` analysis. The subtlety is that we split each statement and terminator in 2 positions. The first position is the regular statement. The second position is a shadow, which is always more live. It encodes partial writes and dead writes as a local being live for half a statement. This half statement ensures that writes conflict with another local's writes and regular liveness.

r? `@Amanieu`
2025-09-07 23:36:21 +00:00
Matthias Krüger
36557d1046 Rollup merge of #146297 - cjgillot:may-observe-address, r=saethlin
Introduce PlaceContext::may_observe_address.

A small utility method to avoid open-coding the logic in several MIR opts.
2025-09-07 20:02:29 +02:00
Matthias Krüger
92bad93f06 Rollup merge of #146209 - bjorn3:lto_refactors5, r=dianqk
Misc LTO cleanups

Follow up to https://github.com/rust-lang/rust/pull/145955.

* Remove want_summary argument from `prepare_thin`.
   Since https://github.com/rust-lang/rust/pull/133250 ThinLTO summary writing is instead done by `llvm_optimize`.
* Two minor cleanups
2025-09-07 20:02:27 +02:00
Camille Gillot
5d0e66d451 Use rustc_data_structures::union_find. 2025-09-07 16:46:34 +00:00
Camille Gillot
28ff5cf502 Simplify candidate collection. 2025-09-07 16:45:34 +00:00
Camille Gillot
99f6bcf380 Unify a source with all possible destinations. 2025-09-07 16:45:00 +00:00
Camille Gillot
4e9dd1b67b Do not use prepend to avoid quadratic behaviour. 2025-09-07 16:36:30 +00:00
Camille Gillot
de7c633ee5 Simplify VisitPlacesWith. 2025-09-07 16:36:22 +00:00
Camille Gillot
b9262bce67 Use regular MaybeLiveLocals. 2025-09-07 16:35:30 +00:00
Camille GILLOT
9b8a719ae4 Reimplement DestinationPropagation according to live ranges. 2025-09-07 16:24:46 +00:00
Camille GILLOT
2ff92e83af Introduce fast insertion at extremities to IntervalSet. 2025-09-07 16:06:40 +00:00
bors
55b9b4d1e1 Auto merge of #146289 - cjgillot:gvn-aggregate, r=dianqk
GVN: Allow reusing aggregates if LHS is not a simple local.

This resolves a FIXME in the code. I don't see a reason not to allow this.
2025-09-07 14:02:09 +00:00
Camille GILLOT
4e7a068c9a Introduce PlaceContext::may_observe_address. 2025-09-07 13:51:53 +00:00
bors
fbd8f95118 Auto merge of #146292 - matthiaskrgr:rollup-bkjs887, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#146254 (Use `Itertools::all_equal_value()` where applicable)
 - rust-lang/rust#146290 (Revert "Add LSX accelerated implementation for source file analysis")

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-07 07:28:43 +00:00
Matthias Krüger
1b492b0c54 Rollup merge of #146290 - heiher:r-src-analysis-lsx, r=lqd
Revert "Add LSX accelerated implementation for source file analysis"

This reverts commit 5b43244ac5 to fix native build failures on LoongArch.

Link: https://github.com/rust-lang/rust/pull/145963#issuecomment-3263195096
Link: https://github.com/rust-lang/rust/pull/145963#issuecomment-3263420700
2025-09-07 08:18:59 +02:00
Matthias Krüger
cb8b5fa4e2 Rollup merge of #146254 - yotamofek:pr/itertools-all-equal-value, r=cjgillot
Use `Itertools::all_equal_value()` where applicable

Just a small cleanup.
We already have `itertools` as a dep in these crates, so might as well use another of its features.
Makes the code simpler IMHO :)
2025-09-07 08:18:59 +02:00
bors
ebdf2abea4 Auto merge of #146271 - niacdoial:improperctypes-refactor1, r=tgross35
lint ImproperCTypes: refactor linting architecture (part 1)

This is the first PR in an effort to split  rust-lang/rust#134697 into individually-mergeable parts.

This one focuses on properly packaging the lint and its tests, as well as properly separate the "linting" and "type-checking" code.

There is exactly one user-visible change: the safety of `Option<Box<FFISafePointee>>` is now the same in `extern` blocks and function definitions: it is safe.

r? `@tgross35` because you are already looking at the original
2025-09-07 04:17:27 +00:00
WANG Rui
58e2cd4263 Revert "Add LSX accelerated implementation for source file analysis"
This reverts commit 5b43244ac5 to fix
native build failures on LoongArch.
2025-09-07 11:27:20 +08:00
Camille GILLOT
52f74a5162 Allow simplifying aggregates if LHS is not a simple local. 2025-09-07 03:23:23 +00:00
bors
f4b2f68e04 Auto merge of #146285 - matthiaskrgr:rollup-oaokoo3, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#146200 (Simplify rustdoc-gui tester by calling directly browser-ui-test)
 - rust-lang/rust#146236 (gpu offload: change suspicious map into filter)
 - rust-lang/rust#146240 (DynamicConfig: use canonical clone impl)
 - rust-lang/rust#146251 (rustc_middle: clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-07 01:04:57 +00:00
Matthias Krüger
019486082d Rollup merge of #146251 - hkBst:clippy-fix-8, r=cjgillot
rustc_middle: clippy fixes

Fixes for:
```text
warning: bound is defined in more than one place
warning: empty line after doc comment
```
2025-09-06 23:49:54 +02:00
Matthias Krüger
bb27a2b93d Rollup merge of #146240 - hkBst:query-1, r=cjgillot
DynamicConfig: use canonical clone impl

Fixes clippy warning:
```text
warning: non-canonical implementation of `clone` on a `Copy` type
  --> compiler/rustc_query_impl/src/lib.rs:60:29
   |
60 |       fn clone(&self) -> Self {
   |  _____________________________^
61 | |         DynamicConfig { dynamic: self.dynamic }
62 | |     }
   | |_____^ help: change this to: `{ *self }`
```
2025-09-06 23:49:54 +02:00
Matthias Krüger
1123d49090 Rollup merge of #146236 - hkBst:gpu-1, r=ZuseZ4
gpu offload: change suspicious map into filter

Fixes clippy warning:
```text
warning: this call to `map()` won't have an effect on the call to `count()`
   --> compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs:194:25
    |
194 |       let num_ptr_types = types
    |  _________________________^
195 | |         .iter()
196 | |         .map(|&x| matches!(cx.type_kind(x), rustc_codegen_ssa::common::TypeKind::Pointer))
197 | |         .count();
    | |________________^
    |
    = help: make sure you did not confuse `map` with `filter`, `for_each` or `inspect`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
    = note: `-W clippy::suspicious-map` implied by `-W clippy::suspicious`
    = help: to override `-W clippy::suspicious` add `#[allow(clippy::suspicious_map)]`
```
2025-09-06 23:49:53 +02:00
bors
76863e3404 Auto merge of #146282 - tgross35:rollup-0n5tjnm, r=tgross35
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#139524 (Add socket extensions for cygwin)
 - rust-lang/rust#145940 (single buffer for exponent fmt of integers)
 - rust-lang/rust#146206 (identity uses are ok, even if there are no defining uses)
 - rust-lang/rust#146272 (Update comment for `-Werror` on LLVM builds)
 - rust-lang/rust#146280 (Make `LetChainsPolicy` public for rustfmt usage)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-06 21:47:58 +00:00
niacdoial
20f050b444 ImproperCTypes: redo state tracking
No changes should be visible by rustc users
This is just some architecture changes to the type checking to
facilitate FFI-safety decisions that depend on how the type is used
(the change here is not complete, there are still bits of "legacy" state
passing for this, but since this is a retconned commit, I can tell you
those bits will disappear before the end of the commit chain)
(there is at least one bit where the decision making code is weird, but
that this is because we do not want to change the lint's behaviour this
early in the chain)
2025-09-06 22:00:28 +02:00
niacdoial
050c119784 ImproperCTypes: re-separate linting and checking
no visible changes to rust users, just making the inner architecture of
the ImproperCTypes lints more sensible, with a clean separation between
the struct (now singular) that interacts with the linting system
and the struct (now singular) that visits the types to check FFI-safety
2025-09-06 21:46:33 +02:00
niacdoial
33943d1832 ImproperCTypes: more pre-emptive cleanup
Mainly, we realise that the non-null assumption on a Box<_> argument
does not depend on what side of the FFI boundary the function is on.
And anyway, this is not the way to deal with this assumption being maybe violated.
2025-09-06 21:46:33 +02:00
niacdoial
0c0e764ff7 ImproperCTypes: move code and tests into proper directories 2025-09-06 21:46:33 +02:00
Trevor Gross
f338542c42 Rollup merge of #146280 - mohe2015:public-for-rustfmt-forks, r=lqd
Make `LetChainsPolicy` public for rustfmt usage

Related to https://github.com/rust-lang/rust/pull/138511. To call `Parser::parse_expr_cond` from [rustfmt forks for custom macro formatting](30c83df9e1/src/parse/macros/html.rs (L57)) you need to pass this enum so it would be nice if it could be public.

Thank you.
2025-09-06 14:39:06 -04:00
Trevor Gross
865c99a092 Rollup merge of #146272 - rperier:rustc_llvm_werror_remove_commment_llvm22, r=tgross35
Update comment for `-Werror` on LLVM builds

cc rust-lang/rust#109712

see https://github.com/rust-lang/rust/issues/109712#issuecomment-3257474643
2025-09-06 14:39:05 -04:00
Trevor Gross
d3d5c7f9bd Rollup merge of #146206 - lcnr:fix-non-defining-uses, r=BoxyUwU
identity uses are ok, even if there are no defining uses

fix rust-lang/rust#146191

I've tried moving the "is this an identity use" check to `fn clone_and_resolve_opaque_types` and this would allow the following code to compile as it now ignores `Opaque<'!a> = Opaque<'!a>` while they previously resulted in errors 71289c378d/tests/ui/type-alias-impl-trait/hkl_forbidden.rs (L42-L46)

The closure signature gets inferred to `for<'a> fn(&'a ()) -> Inner<'a>`. The closure then has a defining use `Inner<'a_latbound> = &'a_latebound ()` while the parent function has a non-defining `Inner<'!a> = Inner<'!a>`. By eagerly discarding identity uses we don't error on the non-defining use in the parent.

r? `@BoxyUwU`
2025-09-06 14:39:05 -04:00
bors
1ed3cd7030 Auto merge of #146233 - jieyouxu:run-make-fission, r=Kobzol
Split `run-make` into two {`run-make`,`run-make-cargo`} test suites

## Summary

Split `tests/run-make` into two test suites, to make it faster and more convenient for contributors to run run-make tests that do not need in-tree `cargo`.

| New test suites        | Explanation                                                                                                                                                                                                                              |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tests/run-make`       | The "fast path" test suite intended for run-make tests that do not need in-tree `cargo`. These tests may not use `cargo`.                                                                                                                |
| `tests/run-make-cargo` | The "slow path" test suite that requires checking out `cargo` submodule and building in-tree `cargo`, and thus will have access to in-tree `cargo`. In practice, these constitute a very small portion of the original `run-make` tests. |

This PR carries out [MCP 847: Split run-make test suite into slower-building test suite with suitably-staged cargo and faster-building test suite without cargo](https://github.com/rust-lang/compiler-team/issues/847).
Fixes rust-lang/rust#135573 (for the tests that do not need in-tree `cargo`).
Fixes rust-lang/rust#134109.

## Remarks

- I considered if we want to split by in-tree tools previously. However, as discussed rust-lang/rust#134109, in practice `rustdoc` is not very slow to build, but `cargo` takes a good few minutes. So, the partition boundary was determined to be along in-tree `cargo` availability.
- The `run-make` tests previously that wanted to use `cargo` cannot just use the bootstrap `cargo`, otherwise they would run into situations where bootstrap `cargo` can significantly diverge from in-tree `cargo` (see https://github.com/rust-lang/rust/pull/130642).

---

try-job: aarch64-msvc-1
try-job: test-various
try-job: x86_64-gnu-debug
try-job: aarch64-gnu-debug
try-job: aarch64-apple
try-job: dist-various-1
2025-09-06 18:37:35 +00:00
bjorn3
3a1ae064a7 Move timers into execute_*_work_item 2025-09-06 18:37:23 +00:00
bjorn3
f2933b34a8 Remove want_summary argument from prepare_thin
It is always false nowadays. ThinLTO summary writing is instead done by
llvm_optimize.
2025-09-06 18:37:23 +00:00
bjorn3
e3d0b7d648 Remove thin_link_data method from ThinBufferMethods
It is only used within cg_llvm.
2025-09-06 18:37:23 +00:00
Moritz Hedtke
7fada167f9 Make LetChainsPolicy public for rustfmt usage 2025-09-06 18:01:31 +02:00
bors
bea625f327 Auto merge of #146232 - bjorn3:lto_allocator_shim, r=lqd
Make the allocator shim participate in LTO again

This is likely the cause of the perf regression in https://github.com/rust-lang/rust/pull/145955. It also caused some functional regressions.

Fixes https://github.com/rust-lang/rust/issues/146235
Fixes https://github.com/rust-lang/rust/issues/146239
2025-09-06 15:21:16 +00:00
Romain Perier
6c4e958fad Update comment for werror on rust-lang/rust CI explaining why we keep MSVC definitively excluded 2025-09-06 16:39:49 +02:00
lcnr
381b3267ae identity uses are ok, even if there are no defining uses 2025-09-06 16:05:31 +02:00
bjorn3
2cf94b92ca Ensure fat LTO doesn't merge everything into the allocator module 2025-09-06 13:31:41 +00:00
Matthias Krüger
a0c5e6b041 Rollup merge of #146211 - Urgau:cfg-disallow-shebang, r=fmease
Disallow shebang in `--cfg` and `--check-cfg` arguments

This PR is similar to https://github.com/rust-lang/rust/issues/146130, where we disallowed frontmatter in `--cfg` and `--check-cfg` arguments. While fixing the other one we also discovered that shebang `#!/usr/bin/shebang` are currently also allowed in `--cfg` and `--check-cfg` arguments.

Allowing shebang in them (which are just ignored) was never intended, this PR fixes that by not stripping shebang for `--cfg` and `--check-cfg` arguments.

This is technically a breaking-change, although I don't expect anyone to actually rely on this unintended behavior.

Fixes https://github.com/rust-lang/rust/issues/146130#issuecomment-3246299499
r? fmease
2025-09-06 13:03:16 +02:00
Matthias Krüger
bc0dfaa048 Rollup merge of #144801 - estebank:issue-144734, r=spastorino
Suggest bounds in more cases, accounting for type parameters referenced in predicate

Use a `ty::Visitor` to see if the failed predicate references a type parameter. If it does, then we only suggest adding a bound to an (associated) item only if the referenced parameter is present in its generics.

Provide adding bound suggestion in trait and impl associated functions in cases we previously weren't:

```
error[E0277]: `?` couldn't convert the error to `ApplicationError`
  --> $DIR/suggest-complex-bound-on-method.rs:18:16
   |
LL |         t.run()?;
   |           -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError`
   |           |
   |           this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>`
   |
note: `ApplicationError` needs to implement `From<<T as Trait>::Error>`
  --> $DIR/suggest-complex-bound-on-method.rs:12:1
   |
LL | enum ApplicationError {
   | ^^^^^^^^^^^^^^^^^^^^^
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
   |
LL |     fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> {
   |                                                                     +++++++++++++++++++++++++++++++++++++++++++++++++
```

Fix rust-lang/rust#144734.
2025-09-06 13:03:15 +02:00
Matthias Krüger
020edbe4cf Rollup merge of #127316 - klensy:tracing-bump, r=Kobzol
move pinned version from tracing_core to tracing

This PR removes pin from `tracing-core` and moves it to `tracing`, which regressed perf in > 0.1.37 versions.
2025-09-06 13:03:15 +02:00
bjorn3
0271359768 Make the allocator shim participate in LTO again 2025-09-06 08:35:55 +00:00