about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-08-01[rustc_span][perf] Remove unnecessary string joins and allocs.Taras Tsugrii-2/+2
Comparing vectors of string parts yields the same result but avoids unnecessary `join` and potential allocation for resulting `String`. This code is cold so it's unlikely to have any measurable impact, but considering but since it's also simpler, why not? :)
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-557/+222
cleanup: remove pointee types This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.) I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup. As a followup, this will enable #96242 to be resolved. r? `@ghost` `@rustbot` label S-blocked
2023-08-01Rollup merge of #114320 - ouz-a:smir_statements, r=oli-obkMatthias Krüger-15/+279
Cover statements for stable_mir Added missing statements to stable_mir, used opaque types for few types that are only used for diagnostic. cc https://github.com/rust-lang/project-stable-mir/issues/16 r? `@oli-obk`
2023-08-01Rollup merge of #114306 - ttsugriy:push_str, r=wesleywiserMatthias Krüger-4/+3
[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-08-01Rollup merge of #114296 - RalfJung:interpret-repeat-align, r=oli-obkMatthias Krüger-4/+4
interpret: fix alignment handling for Repeat expressions
2023-08-01Rollup merge of #114288 - Urgau:fix-issue-109352, r=b-naberMatthias Krüger-31/+136
Improve diagnostic for wrong borrow on binary operations This PR improves the diagnostic for wrong borrow on binary operations by suggesting to reborrow on appropriate expressions. ```diff + = note: an implementation for `&Foo * &Foo` exist + help: consider reborrowing both sides + | + LL | let _ = &*ref_mut_foo * &*ref_mut_foo; + | ++ ++ ``` Fixes https://github.com/rust-lang/rust/issues/109352
2023-08-01Rollup merge of #114283 - oli-obk:parkin_lot_rwlock, r=SparrowLiiMatthias Krüger-21/+7
Use parking lot's rwlock even without parallel-rustc Considering that this doesn't affect perf, I think we should use the simplest solution.
2023-08-01Rollup merge of #113428 - Zalathar:operand, r=davidtwcoMatthias Krüger-241/+154
coverage: Replace `ExpressionOperandId` with enum `Operand` *This is one step in my larger coverage refactoring ambitions described at <https://github.com/rust-lang/compiler-team/issues/645>.* LLVM coverage has a concept of “mapping expressions” that allow a span's execution count to be computed as a simple arithmetic expression over other counters/expressions, instead of requiring a dedicated physical counter for every control-flow branch. These expressions have an operator (`+` or `-`) and two operands. Operands are currently represented as `ExpressionOperandId`, which wraps a `u32` with the following semantics: - 0 represents a special counter that always has a value of zero - Values ascending from 1 represent counter IDs - Values descending from `u32::MAX` represent the IDs of other expressions --- This change replaces that whole `ExpressionOperandId` scheme with a simple enum that explicitly distinguishes between the three cases. This lets us remove a lot of fiddly code for dealing with the different operand kinds: - Previously it was only possible to distinguish between counter-ID operands and expression-ID operands by comparing the operand ID with the total number of counters in a function. This is unnecessary now that the enum distinguishes them explicitly. - There's no need for expression IDs to descend from `u32::MAX` and then get translated into zero-based indices in certain places. Now that they ascend from zero, they can be used as indices directly. - There's no need to reserve ID number 0 for the special zero operand, since it can just have its own variant in the enum, so counter IDs can count up from 0. (Making counter IDs ascend from 0 also lets us fix an off-by-one error in the query for counting the total number of counters, which would cause LLVM to emit an extra unused counter for every instrumented function.) --- This PR may be easiest to review as individual patches, since that breaks it up into clearly distinct parts: - Replace a `u32` wrapper with an explicit enum, without changing the semantics of the underlying IDs being stored. - Change the numbering scheme used by `Operand::Expression` to make expression IDs ascend from 0 (instead of descending from `u32::MAX`). - Change the numbering scheme used by `Operand::Counter` to make counter IDs ascend from 0 (instead of ascending from 1).
2023-08-01clean up, use opaque typesouz-a-42/+53
2023-08-01Cover statements for stable_mirouz-a-14/+267
2023-08-01Auto merge of #114318 - matthiaskrgr:rollup-c7gcw18, r=matthiaskrgrbors-3/+2
Rollup of 7 pull requests Successful merges: - #111081 (impl SliceIndex<str> for (Bound<usize>, Bound<usize>)) - #113394 (style-guide: Document style editions, start 2024 style edition) - #113588 (bootstrap: use git merge-base for LLVM CI download logic) - #113743 (Directly link more target docs) - #114262 (Improve the rust style guide doc) - #114309 (Update books) - #114313 ([rustc_data_structures] Simplify SortedMap::insert.) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-01Improve diagnostic for wrong borrow on binary operationsUrgau-31/+136
2023-08-01Always use parking_lot's RwLock, even without parallel compilerOli Scherer-21/+7
2023-08-01Rollup merge of #114313 - ttsugriy:sm-insert, r=petrochenkovMatthias Krüger-3/+2
[rustc_data_structures] Simplify SortedMap::insert. It looks like current usage of `swap` is aimed at achieving what `std::mem::replace` does but more concisely and idiomatically.
2023-08-01Auto merge of #111753 - cjgillot:simp-place-conflict, r=compiler-errorsbors-90/+87
Only consider places with the same local in each_borrow_involving_path. This avoids having a busy loop that repeatedly checks for equality of locals.
2023-08-01Make coverage counter IDs count up from 0, not 1Zalathar-54/+36
Operand types are now tracked explicitly, so there is no need to reserve ID 0 for the special always-zero counter. As part of the renumbering, this change fixes an off-by-one error in the way counters were counted by the `coverageinfo` query. As a result, functions should now have exactly the number of counters they actually need, instead of always having an extra counter that is never used.
2023-08-01Make coverage expression IDs count up from 0, not down from `u32::MAX`Zalathar-67/+45
Operand types are now tracked explicitly, so there is no need for expression IDs to avoid counter IDs by descending from `u32::MAX`. Instead they can just count up from 0, and can be used directly as indices when necessary.
2023-08-01Replace `ExpressionOperandId` with enum `Operand`Zalathar-143/+92
Because the three kinds of operand are now distinguished explicitly, we no longer need fiddly code to disambiguate counter IDs and expression IDs based on the total number of counters/expressions in a function. This does increase the size of operands from 4 bytes to 8 bytes, but that shouldn't be a big deal since they are mostly stored inside boxed structures, and the current coverage code is not particularly size-optimized anyway.
2023-08-01Add some line comments to enum `CoverageKind`Zalathar-0/+4
The actual motivation here is to prevent `rustfmt` from suddenly reformatting these enum variants onto a single line, when they become slightly shorter in the future. But there's no harm in adding some helpful documentation at the same time.
2023-07-31[rustc_data_structures] Simplify SortedMap::insert.Taras Tsugrii-3/+2
It looks like current usage of `swap` is aimed at achieving what `std::mem::replace` does but more concisely and idiomatically.
2023-07-31Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgrbors-20/+114
Rollup of 7 pull requests Successful merges: - #109318 (Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`) - #113701 (Re-export core::ffi::FromBytesUntilNulError in std::ffi) - #113804 (Resolve correct archive version name in `opt-dist`) - #114165 (Add missing rvalues to smir) - #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) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-31Rollup merge of #114200 - compiler-errors:detect-tail-unsize-then-upcast, r=lcnrMatthias Krüger-5/+20
Detect trait upcasting through struct tail unsizing in new solver select Oops, we were able to hide trait upcasting behind a parent unsize goal that evaluated to `Certainty::Yes`. Let's do rematching for `Certainty::Yes` unsize goals with `BuiltinImplSource::Misc` sources (corresponding to all of the other unsize rules) to make sure we end up selecting any nested goals which may be satisfied via `BuiltinImplSource::TraitUpcasting` or `::TupleUnsizing`. r? ``@lcnr``
2023-07-31Rollup merge of #114193 - crlf0710:lexer_unicode15, r=ManishearthMatthias Krüger-8/+9
Update lexer emoji diagnostics to Unicode 15.0 This replaces the `unic-emoji-char` dep tree (which hasn't been updated for a while) with `unicode-properties` crate which contains Unicode 15.0 data. Improves diagnostics for added emoji characters in recent years. (See tests). cc #101840 cc ``@Manishearth``
2023-07-31Rollup merge of #114165 - ouz-a:smir1, r=spastorinoMatthias Krüger-7/+85
Add missing rvalues to smir Added few missing rvalues to smir, not entirely confident about changes to `Aggregate` cc https://github.com/rust-lang/project-stable-mir/issues/13 r? `@oli-obk`
2023-07-31Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkovMatthias Krüger-23/+30
fix(resolve): report unresolved imports firstly Fixes #81413 An easy fix, r? ```@petrochenkov```
2023-07-31Rollup merge of #113717 - cuishuang:master, r=NilstriebMatthias Krüger-2/+2
remove repetitive words
2023-07-31Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-SimulacrumMatthias Krüger-0/+20
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-31add missing rvalues to smirouz-a-7/+85
2023-07-31[rustc_data_structures][perf] Simplify base_n::push_str.Taras Tsugrii-4/+3
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-31fix alignment handling for Repeat expressionsRalf Jung-4/+4
2023-07-31Rollup merge of #114286 - nbdd0121:upcast, r=compiler-errorsMatthias Krüger-0/+1
Add missing feature gate in multiple_supertrait_upcastable doc Fix #112424
2023-07-31Rollup merge of #114267 - compiler-errors:rpitit-opaque-bounds, r=spastorinoMatthias Krüger-47/+53
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-31Rollup merge of #114228 - fmease:wf-lazy-ty-aliases, r=oli-obkMatthias Krüger-9/+17
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-31Rollup merge of #114169 - lcnr:unsize, r=compiler-errorsMatthias Krüger-219/+272
refactor builtin unsize handling, extend comments r? `@compiler-errors`
2023-07-31Add missing feature gate in multiple_supertrait_upcastable docGary Guo-0/+1
2023-07-31Auto merge of #113879 - nnethercote:codegen_ssa-cleanups, r=bjorn3bors-199/+192
`codegen_ssa` cleanups Some clarifications I made when reading this code closely. r? `@tmiasko`
2023-07-31remove repetitive wordscui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31Remove unnecessary semicolon.Nicholas Nethercote-1/+1
2023-07-31Clean up `generate_lto_work`.Nicholas Nethercote-22/+23
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-31Fix LLVM thread names on Windows.Nicholas Nethercote-3/+3
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-31Introduce `running_with_any_token` closure.Nicholas Nethercote-7/+10
It makes things a little clearer.
2023-07-31Use standard Rust capitalization rules for names containing "LTO".Nicholas Nethercote-22/+22
2023-07-31Tweak structure of the message loop.Nicholas Nethercote-17/+20
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-31Tweak a loop condition.Nicholas Nethercote-7/+11
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-31Move `maybe_start_llvm_timer`'s body into `spawn_work`.Nicholas Nethercote-26/+18
The two functions are alway called together. This commit factors out the repeated code.
2023-07-31Remove `CodegenContext::worker`.Nicholas Nethercote-24/+12
`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-31Fix a comment.Nicholas Nethercote-0/+1
Make it match the corresponding comment at the start of the unstable options.
2023-07-31Remove `ExtraBackendMethods::spawn_thread`.Nicholas Nethercote-21/+0
It's no longer used, and `spawn_named_thread` is preferable, because naming threads is helpful when profiling.
2023-07-31Give the coordinator thread a name.Nicholas Nethercote-3/+4
This is useful when profiling with a profiler like Samply.
2023-07-31Remove some unused values in `codegen_crate`.Nicholas Nethercote-3/+0