Commit Graph

231115 Commits

Author SHA1 Message Date
Matthias Krüger
d0ae0b31a8
Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum
Update Android system definitions and add riscv-linux-android as tier 3 target

This PR includes the following:
* Corrected Android system definitions for some types
* Support for the riscv64-linux-android target

The authoritative types for the system definitions can be found here: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h

Fixes rust-lang/compiler-team#640
2023-07-31 22:49:46 +02:00
ouz-a
2a3da87c0e add missing rvalues to smir 2023-07-31 22:48:55 +03:00
Taras Tsugrii
b84942a0fe [rustc_data_structures][perf] Simplify base_n::push_str.
This minor change removes the need to reverse resulting digits.
Since reverse is O(|digit_num|) but bounded by 128, it's unlikely
to be a noticeable in practice. At the same time, this code is
also a 1 line shorter, so combined with tiny perf win, why not?

I ran https://gist.github.com/ttsugriy/ed14860ef597ab315d4129d5f8adb191
on M1 macbook air and got a small improvement
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.180 µs 14.313 µs 14.462 µs]
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe
push_str/new            time:   [13.741 µs 13.839 µs 13.973 µs]
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) high mild
  5 (5.00%) high severe
```
2023-07-31 12:40:11 -07:00
Matt Fellenz
f189d00d40
Work around missing <*str>::len 2023-07-31 11:42:14 -07:00
Matt Fellenz
e12e7fcc50
impl SliceIndex<str> for (Bound<usize>, Bound<usize>) 2023-07-31 11:32:40 -07:00
Michael Goulet
9295817bad Don't check unnecessarily that impl trait is RPIT 2023-07-31 18:13:48 +00:00
Ralf Jung
b169ee7c1a fix alignment handling for Repeat expressions 2023-07-31 19:22:14 +02:00
Ralf Jung
314fe5dd01
apply nit
Co-authored-by: Albert Larsan <albertlarsan@unbon.cafe>
2023-07-31 18:39:41 +02:00
bors
b3df56a65f Auto merge of #114294 - matthiaskrgr:rollup-yk78pvd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #114111 (Improve test case for experimental API remove_matches)
 - #114169 (refactor builtin unsize handling, extend comments)
 - #114182 (clean up after 113312)
 - #114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - #114200 (Detect trait upcasting through struct tail unsizing in new solver select)
 - #114228 (Check lazy type aliases for well-formedness)
 - #114267 (Map RPITIT's opaque type bounds back from projections to opaques)
 - #114269 (Migrate GUI colors test to original CSS color format)
 - #114286 (Add missing feature gate in multiple_supertrait_upcastable doc)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-31 16:29:54 +00:00
Matthias Krüger
f59a5604f9
Rollup merge of #114286 - nbdd0121:upcast, r=compiler-errors
Add missing feature gate in multiple_supertrait_upcastable doc

Fix #112424
2023-07-31 16:57:56 +02:00
Matthias Krüger
81bb311b09
Rollup merge of #114269 - GuillaumeGomez:migrate-gui-test-color-24, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-07-31 16:57:55 +02:00
Matthias Krüger
692d764e53
Rollup merge of #114267 - compiler-errors:rpitit-opaque-bounds, r=spastorino
Map RPITIT's opaque type bounds back from projections to opaques

An RPITIT in a program's AST is eventually translated into both a projection GAT and an opaque. The opaque is used for default trait methods, like:

```
trait Foo {
  fn bar() -> impl Sized { 0i32 }
}
```

The item bounds for both the projection and opaque are identical, and both have a *projection* self ty. This is mostly okay, since we can normalize this projection within the default trait method body to the opaque, but it does two things:
1. it leads to bugs in places where we don't normalize item bounds, like `deduce_future_output_from_obligations`
2. it leads to extra match arms that are both suspicious looking and also easy to miss

This PR maps the opaque type bounds of the RPITIT's *opaque* back to the opaque's self type to avoid this quirk. Then we can fix the UI test for #108304 (1.) and also remove a bunch of match arms (2.).

Fixes #108304

r? `@spastorino`
2023-07-31 16:57:55 +02:00
Matthias Krüger
95b7116d70
Rollup merge of #114228 - fmease:wf-lazy-ty-aliases, r=oli-obk
Check lazy type aliases for well-formedness

Previously we didn't check if `T: Mul` holds given lazy `type Alias<T> = <T as Mul>::Output;`.
Now we do. It only makes sense.

`@rustbot` label F-lazy_type_alias

r? `@oli-obk`
2023-07-31 16:57:54 +02:00
Matthias Krüger
b8f78fb47c
Rollup merge of #114169 - lcnr:unsize, r=compiler-errors
refactor builtin unsize handling, extend comments

r? `@compiler-errors`
2023-07-31 16:57:53 +02:00
bors
3114eb1fa5 Auto merge of #113592 - Kobzol:pgo-script-bolt, r=Mark-Simulacrum
Move BOLT from `bootstrap` to `opt-dist`

Currently, we use BOLT to optimize LLVM for x64 Linux. The BOLT instrumentation and optimization step is implemented in `bootstrap`, but it was always quite hacky, because BOLT works quite differently than PGO. Rather than building an instrumented artifact, it takes an already built artifact and instruments it in-place. This is not a good fit for the bootstrap caching mechanism, and it meant that we had to run BOLT "on-the-fly" when packaging LLVM artifacts into the created sysroot.

The BOLT code was also really only used by the PGO script (now called `opt-dist`) and nothing else, so it was quite hardcoded for this one single usage. And even if someone wanted to use the `--llvm-bolt-profile-[use/generate]` bootstrap flags outside of the PGO script, they would also need to implement profile gathering, as this is not performed by bootstrap anyway.

I think that it could be more practical to move the BOLT logic to the `opt-dist` tool instead. This simplifies bootstrap, removes unneeded implementation of BOLT caching (we will now do it exactly once - no need to check if it has been performed already when bootstrap copies `libLLVM.so` around multiple times) and removes two BOLT-specific bootstrap flags, and also one special case for building LLVM (instead I pass the linker flags with `--set llvm.ldflags` from `opt-dist` now).

There are also a few disadvantages to this new approach:
- We have to guess/find the path to the built `libLLVM.so` file (but currently this is quite easy, it's just in `stage2/lib`).
- We have to provide the BOLT profile externally to bootstrap, so that it is packaged into the reproducible artifacts archive. Doesn't seem like a big deal to me.
- We are depending on some inner behavior of boostrap in `opt-dist` (namely, that `libLLVM.so` is hardlinked). But we do that for many other things in the `opt-dist` tool anyway, it's tied quite closely to bootstrap.

I would like to go back to my attempts to also use BOLT for `librustc_driver.so`, and I think that it might be a bit simpler if I also do it from the `opt-dist` tool, so this is the first step towards that.

Anyway, let me know what you think about this. It's just a refactoring in a way, no big deal.

r? bootstrap
2023-07-31 14:36:09 +00:00
Gary Guo
e617faabe7 Add missing feature gate in multiple_supertrait_upcastable doc 2023-07-31 12:28:53 +01:00
lcnr
fc98c5a098 update comment 2023-07-31 12:47:24 +02:00
bors
b321edd1b2 Auto merge of #114277 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in 7ac9416d82cd4fc5e707c9ec3574d22dff6466e5..c91a693e7977e33a1064b63a5daf5fb689f01651
2023-07-24 14:29:38 +0000 to 2023-07-31 00:26:46 +0000
- fix: align `cargo --help` text (rust-lang/cargo#12418)
- fix: normalize relative git submodule urls with `ssh://` (rust-lang/cargo#12411)
- test: relax help text assertion (rust-lang/cargo#12416)
- test: relax assertions of panic handler message format (rust-lang/cargo#12413)
- fix(package): Recognize and normalize `cargo.toml` (rust-lang/cargo#12399)
- Clarify `lto` setting passing `-Clinker-plugin-lto` (rust-lang/cargo#12407)
- doc: add missing reference to `CARGO_PROFILE_&lt;name&gt;_STRIP` in environment variables docs (rust-lang/cargo#12408)
- Update curl-sys to pull in curl 8.2.1 (rust-lang/cargo#12406)
- docs: raise awareness of resolver used inside workspace (rust-lang/cargo#12388)
- chore: update `home` to 0.5.7 (rust-lang/cargo#12401)
- Update curl-sys to pull in curl 8.2.0 (rust-lang/cargo#12400)
- test(cli): Track --help output (rust-lang/cargo#11912)
- refactor(test): Move cargo-config into a dir (rust-lang/cargo#12398)
- refactor(tests): Name init ui tests more consistently (rust-lang/cargo#12397)

r? `@ghost`
2023-07-31 10:13:09 +00:00
Konrad Borowski
0f06b07552 Implement UnwindSafe and RefUnwindSafe for Backtrace
Backtrace doesn't have visible mutable state.
2023-07-31 10:38:24 +02:00
bors
5082281609 Auto merge of #113879 - nnethercote:codegen_ssa-cleanups, r=bjorn3
`codegen_ssa` cleanups

Some clarifications I made when reading this code closely.

r? `@tmiasko`
2023-07-31 08:18:19 +00:00
cui fliter
88c7b16e03 remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31 16:13:02 +08:00
Weihang Lo
00a774774b
Update cargo 2023-07-31 09:09:20 +01:00
Jakub Beránek
142995f15f
Pass BOLT profile to bootstrap to be included in the reproducible artifacts archive 2023-07-31 08:54:47 +02:00
Jakub Beránek
78403f4e13
Remove BOLT from bootstrap 2023-07-31 08:54:47 +02:00
Jakub Beránek
a16925d5f3
Implement BOLT optimization in the opt-dist tool 2023-07-31 08:52:41 +02:00
Nicholas Nethercote
c17c8dc78e Remove unnecessary semicolon. 2023-07-31 16:34:13 +10:00
bors
03b8b50fcb Auto merge of #114225 - workingjubilee:only-golden-arches, r=compiler-errors
Only golden arches

A number of tests in the test suite have applied the somewhat comedic practice of ignoring *every* single target architecture that rustc has ever supported. This is silly, when they are clearly tests built around certain assumptions, primarily of the x86-64 architecture, or in one case when they are only relevant for a handful of 32-bit targets. This has even resulted, in one case, in the same architecture being ignored twice!

Document these better, and use a "revision + only-arch" idiom in the test headers to denote the "golden arches" that actually pass these tests.
2023-07-31 06:28:01 +00:00
Nicholas Nethercote
5673f47042 Clean up generate_lto_work.
This function has some shared code for the thin LTO and fat LTO cases,
but those cases have so little in common that it's actually clearer to
treat them fully separately.
2023-07-31 16:21:03 +10:00
Nicholas Nethercote
d404699fb1 Fix LLVM thread names on Windows.
PR #112946 tweaked the naming of LLVM threads, but messed things up
slightly, resulting in threads on Windows having names like `optimize
module {} regex.f10ba03eb5ec7975-cgu.0`.

This commit removes the extraneous `{} `.
2023-07-31 16:21:03 +10:00
Nicholas Nethercote
90ce358afa Introduce running_with_any_token closure.
It makes things a little clearer.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
3b44f5b0eb Use standard Rust capitalization rules for names containing "LTO". 2023-07-31 16:21:02 +10:00
Nicholas Nethercote
a08220bcab Tweak structure of the message loop.
The main loop has a *very* complex condition, which includes two
mentions of `codegen_state`. The body of the loop then immediately
switches on the `codegen_state`.

I find it easier to understand if it's a `loop` and we check for exit
conditions after switching on `codegen_state`. We end up with a tiny bit
of code duplication, but it's clear that (a) we never exit in the
`Ongoing` case, (b) we exit in the `Completed` state only if several
things are true (and there's interaction with LTO there), and (c) we
exit in the `Aborted` state if a couple of things are true. Also, the
exit conditions are all simple conjunctions.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
179bf19813 Tweak a loop condition.
This loop condition involves `codegen_state`, `work_items`, and
`running_with_own_token`. But the body of the loop cannot modify
`codegen_state`, so repeatedly checking it is unnecessary.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
d21d31cce7 Move maybe_start_llvm_timer's body into spawn_work.
The two functions are alway called together. This commit factors out the
repeated code.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
3517fe899e Remove CodegenContext::worker.
`CodegenContext` is immutable except for the `worker` field - we clone
`CodegenContext` in multiple places, changing the `worker` field each
time. It's simpler to move the `worker` field out of `CodegenContext`.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
0ea9950ede Document -Zno-parallel-llvm.
Because it's usefulness wasn't clear to me, and I initially wondered if
it could be removed. The text is based on the text in #50972, the PR
that added the flag.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
67e4bec200 Fix a comment.
Make it match the corresponding comment at the start of the unstable
options.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
4a120f33f7 Remove ExtraBackendMethods::spawn_thread.
It's no longer used, and `spawn_named_thread` is preferable, because
naming threads is helpful when profiling.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
e78fb95dfa Give the coordinator thread a name.
This is useful when profiling with a profiler like Samply.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
176610c2cd Remove some unused values in codegen_crate. 2023-07-31 16:21:02 +10:00
Nicholas Nethercote
8b9e3f0dd6 Remove an unnecessary pub. 2023-07-31 16:21:00 +10:00
Nicholas Nethercote
f81fe9d702 Rename MainThreadWorkerState.
The `Worker` is unnecessary, and just makes it longer than necessary.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
5bef04ed38 Rename things related to the main thread's operations.
It took me some time to understand how the main thread can lend a
jobserver token to an LLVM thread. This commit renames a couple of
things to make it clearer.

- Rename the `LLVMing` variant as `Lending`, because that is a clearer
  description of what is happening.
- Rename `running` as `running_with_own_token`, which makes it clearer
  that there might be one additional LLVM thread running (with a loaned
  token). Also add a comment to its definition.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
fd017d3c17 Add some assertions.
- Thin and fat LTO can't happen together.
- `NeedsLink` and (non-allocator) `Compiled` work item results can't
  happen together.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
4f598b852c Add comments to WorkItemResult.
And rename the `Compiled` variant as `Finished`, because that name makes
it clearer there is nothing left to do, contrasting nicely with the
`Needs*` variants.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
a8c71f0a15 Inline and remove submit_pre_codegened_module_to_llvm.
It has a single callsite, and provides little value.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
2e6ce68fba Remove desugar_doc_comments arg from Parser::new().
It's only true at one call site; do the desugaring there instead.
2023-07-31 14:47:08 +10:00
Nicholas Nethercote
d72fc5ce44 Remove TokenTreeCursor::replace_prev_and_rewind.
It's no longer used.
2023-07-31 14:47:06 +10:00
Nicholas Nethercote
ff7d5ba65e Move doc comment desugaring out of TokenCursor.
`TokenCursor` currently does doc comment desugaring on the fly, if the
`desugar_doc_comment` field is set. This requires also modifying the
token stream on the fly with `replace_prev_and_rewind`.

This commit moves the doc comment desugaring out of `TokenCursor`, by
introducing a new `TokenStream::desugar_doc_comment` method. This
separation of desugaring and iterating makes the code nicer.
2023-07-31 14:47:03 +10:00
bors
3be07c1161 Auto merge of #114266 - calebzulawski:simd-bswap, r=compiler-errors
Fix simd_bswap for i8/u8

#114156 missed this test case ☹️
cc `@workingjubilee`
2023-07-31 04:43:48 +00:00