Commit Graph

850 Commits

Author SHA1 Message Date
Matthias Krüger
ca36ed27be
Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errors
Remove outdated references to librustc_middle

The relevant comment is now in 791a53f380/compiler/rustc_middle/src/tests.rs (L3-L13)
2024-02-05 06:37:14 +01:00
clubby789
fd29f74ff8 Remove unused features 2024-01-25 14:01:33 +00:00
Josh Stone
8f3af4c6e2 rustc_data_structures: use either instead of itertools 2024-01-24 15:36:57 -08:00
bors
3066253050 Auto merge of #120080 - cuviper:128-align-packed, r=nikic
Pack u128 in the compiler to mitigate new alignment

This is based on #116672, adding a new `#[repr(packed(8))]` wrapper on `u128` to avoid changing any of the compiler's size assertions. This is needed in two places:

* `SwitchTargets`, otherwise its `SmallVec<[u128; 1]>` gets padded up to 32 bytes.
* `LitKind::Int`, so that entire `enum` can stay 24 bytes.
  * This change definitely has far-reaching effects though, since it's public.
2024-01-22 13:08:19 +00:00
bors
6745c6000a Auto merge of #116185 - Zoxc:rem-one-thread, r=cjgillot
Remove `OneThread`

This removes `OneThread` by switching `incr_comp_session` over to `RwLock`.
2024-01-20 13:18:33 +00:00
Josh Stone
cb7d863e74 Add Pu128 = #[repr(packed(8))] u128 2024-01-19 20:10:38 -08:00
bors
1bd42be8cb Auto merge of #120076 - Mark-Simulacrum:unhash, r=cjgillot
Use UnhashMap for a few more maps

This avoids a few cases of hashing data that's already hashed.

cc https://github.com/rust-lang/rust/issues/56308
2024-01-19 04:43:17 +00:00
bors
25f8d01fd8 Auto merge of #114231 - ttsugriy:binary_search_slice, r=cjgillot
[rustc_data_structures] Use partition_point to find  slice range end.

This PR uses approach introduced in https://github.com/rust-lang/rust/pull/114152 to find
the end of the range. It's much easier to understand and reason about invariants of such
implementation.
Technically it's possible to make it even shorter by returning `&[start..end]` unconditionally
because even if searched item is not present in the slice, `start` and `end` would point at
the same index, so the range would be empty. The reason I decided not to use this shorter
implementation is because it would involve more comparisons in case there are no elements
in the slice with key equal to `key`.

Also, not that it matters much, but this implementation also improves perf according to the
benchmark below:
https://gist.github.com/ttsugriy/63c0ed39ae132b131931fa1f8a3dea55

The results on my M1 macbook air are:
```
Running benches/bin_search_slice_benchmark.rs (target/release/deps/bin_search_slice_benchmark-90fa6d68c3bd1298)
Benchmarking multiply add/binary_search_slice: Collecting 100 samples in estimated 5.0002 s (1
multiply add/binary_search_slice
                        time:   [44.719 ns 44.918 ns 45.158 ns]
                        No change in performance detected.
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe
Benchmarking multiply add/binary_search_slice_new: Collecting 100 samples in estimated 5.0001
multiply add/binary_search_slice_new
                        time:   [36.955 ns 37.060 ns 37.221 ns]
                        No change in performance detected.
Found 7 outliers among 100 measurements (7.00%)
  3 (3.00%) high mild
  4 (4.00%) high severe
```
2024-01-18 18:54:54 +00:00
John Kåre Alsaker
63446d00ee Remove OneThread 2024-01-18 03:30:05 +01:00
Mark Rousskov
510fcd318b Use UnhashMap for a few more maps
This avoids hashing data that's already hashed.
2024-01-17 17:09:55 -05:00
Michael Woerister
ac58f9ae03 Update measureme crate to version 11 2024-01-13 16:32:03 +01:00
Guillaume Gomez
d3574beb5d
Rollup merge of #119527 - klensy:ordering, r=compiler-errors
don't reexport atomic::ordering via rustc_data_structures, use std import

This looks simpler.
2024-01-09 13:23:17 +01:00
Matthias Krüger
909f2b63a3
Rollup merge of #119591 - Enselic:DestinationPropagation-stable, r=cjgillot
rustc_mir_transform: Make DestinationPropagation stable for queries

By using `FxIndexMap` instead of `FxHashMap`, so that the order of visiting of locals is deterministic.

We also need to bless
`copy_propagation_arg.foo.DestinationPropagation.panic*.diff`. Do not review the diff of the diff. Instead look at the diff files before and after this commit. Both before and after this commit, 3 statements are replaced with nop. It's just that due to change in ordering, different statements are replaced. But the net result is the same. In other words, compare this diff (before fix):
* 090d5eac72/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff

With this diff (after fix):
* f603babd63/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff

and you can see that both before and after the fix, we replace 3 statements with `nop`s.

I find it _slightly_ surprising that the test this PR affects did not previously fail spuriously due to the indeterminism of `FxHashMap`, but I guess in can be explained with the predictability of small `FxHashMap`s with `usize` (`Local`) keys, or something along those lines.

This should fix [this](https://github.com/rust-lang/rust/pull/119252#discussion_r1436101791) comment, but I wanted to make a separate PR for this fix for a simpler development and review process.

Part of https://github.com/rust-lang/rust/issues/84447 which is E-help-wanted.

r? `@cjgillot` who is reviewer for the highly related PR https://github.com/rust-lang/rust/pull/119252.
2024-01-06 16:07:47 +01:00
klensy
56173611d6 don't reexport atomic::ordering via rustc_data_structures, use std import 2024-01-06 15:01:10 +03:00
bors
e21f4cd98f Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser
Avoid specialization in the metadata serialization code

With the exception of a perf-only specialization for byte slices and byte vectors.

This uses the same trick of introducing a new trait and having the Encodable and Decodable derives add a bound to it as used for TyEncoder/TyDecoder. The new code is clearer about which encoder/decoder uses which impl and it reduces the dependency of rustc on specialization, making it easier to remove support for specialization entirely or turn it into a construct that is only allowed for perf optimizations if we decide to do this.
2024-01-06 09:56:00 +00:00
bors
d62f05b842 Auto merge of #119459 - cjgillot:inline-mir-utils, r=compiler-errors
Inline a few utility functions around MIR

Most of them are small enough to benefit from inlining.
2024-01-06 04:01:09 +00:00
Martin Nordholts
95eb5bcb67 rustc_mir_transform: Make DestinationPropagation stable for queries
By using FxIndexMap instead of FxHashMap, so that the order of visiting
of locals is deterministic.

We also need to bless
copy_propagation_arg.foo.DestinationPropagation.panic*.diff. Do not
review the diff of the diff. Instead look at the diff file before and
after this commit. Both before and after this commit, 3 statements are
replaced with nop. It's just that due to change in ordering, different
statements are replaced. But the net result is the same.
2024-01-05 20:55:32 +01:00
Alona Enraght-Moony
16e117cf96 Remove outdated references to librustc_middle. 2024-01-05 16:34:52 +00:00
Michael Woerister
077540cedf Address review comments and add back some #[inline] attrs from removed commits. 2024-01-04 13:51:06 +01:00
Michael Woerister
900a11bbec Provide generalized collect methods for UnordItems 2024-01-04 13:48:57 +01:00
Michael Woerister
739e5ef49e Split StableCompare trait out of StableOrd trait.
StableCompare is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableOrd` implementation can be provided to offer a lightweight way for stable sorting. (The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`.)
2024-01-04 13:32:42 +01:00
bjorn3
6ed37bdc42 Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
Camille GILLOT
f83468c89b Inline dominator check. 2023-12-31 00:37:45 +00:00
Nilstrieb
ffafcd8819 Update to bitflags 2 in the compiler
This involves lots of breaking changes. There are two big changes that
force changes. The first is that the bitflag types now don't
automatically implement normal derive traits, so we need to derive them
manually.

Additionally, bitflags now have a hidden inner type by default, which
breaks our custom derives. The bitflags docs recommend using the impl
form in these cases, which I did.
2023-12-30 18:17:28 +01:00
Camille GILLOT
821920b2a3 Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
Pietro Albini
f9f5840eb4
update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
Matthias Krüger
8479945c08 NFC don't convert types to identical types 2023-12-15 23:56:24 +01:00
bors
f651b436ce Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkov
[`RFC 3086`] Attempt to try to resolve blocking concerns

Implements what is described at https://github.com/rust-lang/rust/issues/83527#issuecomment-1744822345 to hopefully make some progress.

It is unknown if such approach is or isn't desired due to the lack of further feedback, as such, it is probably best to nominate this PR to the official entities.

`@rustbot` labels +I-compiler-nominated
2023-12-13 06:37:08 +00:00
surechen
40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
oksbsb
dabedb711f 1. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-08 09:50:28 +08:00
Caio
0278505691 Attempt to try to resolve blocking concerns 2023-12-01 21:19:22 -03:00
belovdv
45e6342346 jobserver: check file descriptors 2023-11-29 18:00:03 +03:00
Nicholas Nethercote
b12851ce5d Avoid an unnecessary by_ref. 2023-11-28 14:32:40 +11:00
Mark Rousskov
ee9223ff97 Enforce NonZeroUsize on thread count
This allows avoiding some if != 0 checks when allocating worker-local
datasets.
2023-11-23 20:10:44 -05:00
Nicholas Nethercote
7060fc8327 Replace no_ord_impl with orderable.
Similar to the previous commit, this replaces `newtype_index`'s opt-out
`no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22 18:38:17 +11:00
bors
cc4bb0de20 Auto merge of #117928 - nnethercote:rustc_ast_pretty, r=fee1-dead
`rustc_ast_pretty` cleanups

Some improvements I found while looking at this code.

r? `@fee1-dead`
2023-11-22 05:09:33 +00:00
Nicholas Nethercote
3eadc6844b Update itertools to 0.11.
Because the API for `with_position` improved in 0.11 and I want to use
it.
2023-11-22 08:13:21 +11:00
Nilstrieb
21a870515b Fix clippy::needless_borrow in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01:00
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
cui fliter
a44a4edc0e Fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-11-14 23:06:50 +08:00
bors
d8dbf7ca0e Auto merge of #117557 - Zoxc:panic-prio, r=petrochenkov
Make `FatalErrorMarker` lower priority than other panics

This makes `FatalErrorMarker` lower priority than other panics in a parallel sections. If any other panics occur, they will be unwound instead of `FatalErrorMarker`. This ensures `rustc` will exit with the correct error code on ICEs.

This fixes https://github.com/rust-lang/rust/issues/116659.
2023-11-09 00:39:02 +00:00
bors
f9b644636f Auto merge of #117435 - SparrowLii:nightly_parallel, r=oli-obk,davidtwco
enable parallel rustc front end in nightly builds

Refers to the [MCP](https://github.com/rust-lang/compiler-team/issues/681), this pr does:
1. Enable the parallel front end in nightly builds, and keep the default number of threads as 1. Then users can use the parallel rustc front end via -Z threads=n option.

2. Set it up to serial front end for beta/stable builds via bootstrap.

3. Switch over the alt builders from parallel rustc to serial, so we have artifacts without parallel to test against the artifacts with parallel.

r? `@oli-obk`

cc `@cjgillot` `@nnethercote` `@bjorn3` `@Kobzol`
2023-11-06 07:41:22 +00:00
SparrowLii
f2a40e99ff use portable AtomicU64 for powerPC and MIPS 2023-11-06 09:58:51 +08:00
Taras Tsugrii
97bc528877
Remove invariant comments 2023-11-05 17:35:37 -06:00
John Kåre Alsaker
ff1858e2aa Make FatalErrorMarker lower priority than other panics 2023-11-03 19:46:00 +01:00
Josh Stone
3984914aff Use filter_map in try_par_for_each_in
This simplifies the expression, especially for the rayon part, and also
lets us drop the `E: Copy` constraint.
2023-11-03 09:17:16 -07:00
Nicholas Nethercote
8ff624a9f2 Clean up rustc_*/Cargo.toml.
- Sort dependencies and features sections.
- Add `tidy` markers to the sorted sections so they stay sorted.
- Remove empty `[lib`] sections.
- Remove "See more keys..." comments.

Excluded files:
- rustc_codegen_{cranelift,gcc}, because they're external.
- rustc_lexer, because it has external use.
- stable_mir, because it has external use.
2023-10-30 08:46:02 +11:00
bors
a56bd2b944 Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillot
Avoid a `track_errors` by bubbling up most errors from `check_well_formed`

I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them.

This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`)

cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23 09:59:40 +00:00
Oli Scherer
fd9ef69adf Avoid a track_errors by bubbling up most errors from check_well_formed 2023-10-20 08:46:27 +00:00
Caio
6379013876 Initiate the inner usage of cfg_match 2023-10-19 20:18:51 -03:00
bors
862bba6093 Auto merge of #116830 - nnethercote:rustc_type_ir, r=compiler-errors
Remove `IdFunctor` trait.

It's defined in `rustc_data_structures` but is only used in
`rustc_type_ir`. The code is shorter and easier to read if we remove
this layer of abstraction and just do the things directly where they are
needed.

r? `@BoxyUwU`
2023-10-18 03:55:36 +00:00
Nicholas Nethercote
847c8ba70d Remove IdFunctor trait.
It's defined in `rustc_data_structures` but is only used in
`rustc_type_ir`. The code is shorter and easier to read if we remove
this layer of abstraction and just do the things directly where they are
needed.
2023-10-17 16:26:35 +11:00
Nicholas Nethercote
4175c9b595 Remove unused features from rustc_data_structures. 2023-10-17 16:26:12 +11:00
Michael Howell
2ff2624722 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Tomasz Miąsko
b61a6d59e4 Remove unused dominator iterator 2023-10-10 21:39:59 +02:00
Tomasz Miąsko
0528d378b6 Optimize dominators for small path graphs
Generalizes the small dominators approach from #107449.
2023-10-05 23:45:59 +02:00
Tomasz Miąsko
ba694e301c Remove redundant Dominators::start_node field 2023-10-05 23:45:58 +02:00
Tomasz Miąsko
a8ec7ddf0e Test immediate dominators using public API 2023-10-05 23:45:58 +02:00
John Kåre Alsaker
2c507cae36 Rename cold_path to outline 2023-09-25 22:54:07 +02:00
Florian Schmiderer
3409ca65d8 Add OwnedTargetMachine to manage llvm:TargetMachine. Uses pointers
instead of &'static mut and provides safe interface to create/dispose
it.
2023-09-24 21:11:37 +02:00
bors
f73d376fb6 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
2023-09-21 19:24:01 +00:00
Samuel Thibault
dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
Ralf Jung
57444cf9f3 use pretty_print_const_value from MIR constant 'extra' printing 2023-09-19 11:06:32 +02:00
Zalathar
01b67f4b26 coverage: Simplify sorting of coverage spans extracted from MIR
Switching to `Ordering::then_with` makes control-flow less complicated, and
there is no need to use `partial_cmp` here.
2023-09-18 23:15:25 +10:00
Matthias Krüger
f3cc59b741
Rollup merge of #115548 - Zoxc:parallel-extract, r=wesleywiser
Extract parallel operations in `rustc_data_structures::sync` into a new `parallel` submodule

This extracts parallel operations in `rustc_data_structures::sync` into a new `parallel` submodule. This cuts down on the size of the large `cfg_if!` in `sync` and makes it easier to compare between serial and parallel variants.
2023-09-11 21:16:20 +02:00
bors
9b72cc9abf Auto merge of #115388 - Zoxc:sharded-lock, r=SparrowLii
Add optimized lock methods for `Sharded` and refactor `Lock`

This adds methods to `Sharded` which pick a shard and also locks it. These branch on parallelism just once instead of twice, improving performance.

Benchmark for `cfg(parallel_compiler)` and 1 thread:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.6461s</td><td align="right">1.6345s</td><td align="right"> -0.70%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2414s</td><td align="right">0.2394s</td><td align="right"> -0.83%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9205s</td><td align="right">0.9143s</td><td align="right"> -0.67%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.4981s</td><td align="right">1.4869s</td><td align="right"> -0.75%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.7629s</td><td align="right">5.7256s</td><td align="right"> -0.65%</td></tr><tr><td>Total</td><td align="right">10.0690s</td><td align="right">10.0008s</td><td align="right"> -0.68%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9928s</td><td align="right"> -0.72%</td></tr></table>

cc `@SparrowLii`
2023-09-11 01:43:29 +00:00
John Kåre Alsaker
1d8fdc0332 Use FreezeLock for CStore 2023-09-09 16:02:11 +02:00
John Kåre Alsaker
c83eba9251 Add Freeze::clone 2023-09-08 14:14:57 +02:00
John Kåre Alsaker
9690142bef Remove the LockMode enum and dispatch 2023-09-08 10:15:12 +02:00
John Kåre Alsaker
61cc00d238 Refactor Lock implementation 2023-09-08 08:48:44 +02:00
John Kåre Alsaker
8fc160b742 Add optimized lock methods for Sharded 2023-09-08 08:48:44 +02:00
John Kåre Alsaker
f49382c050 Use Freeze for SourceFile.lines 2023-09-07 13:05:05 +02:00
John Kåre Alsaker
c5996b80be Use Freeze for SourceFile.external_src 2023-09-07 13:04:23 +02:00
John Kåre Alsaker
35e8b67fc2 Use a reference to the lock in the guards 2023-09-06 11:44:06 +02:00
John Kåre Alsaker
fe614712dd Extract parallel operations in rustc_data_structures::sync into a new parallel submodule 2023-09-06 09:47:34 +02:00
John Kåre Alsaker
a3ad045ea4 Rename Freeze to FreezeLock 2023-09-02 08:14:06 +02:00
John Kåre Alsaker
50f0d666d3 Add some comments 2023-09-02 08:13:07 +02:00
John Kåre Alsaker
25884ec9be Use RwLock for Freeze 2023-09-02 08:13:07 +02:00
John Kåre Alsaker
0c96a9260b Add Freeze type and use it to store Definitions 2023-09-02 08:13:03 +02:00
John Kåre Alsaker
90f5f94699 Use OnceLock for SingleCache 2023-09-01 03:11:51 +02:00
John Kåre Alsaker
c303c8abdd Use a parallel_guard function to handle the parallel guard 2023-08-30 18:17:38 +02:00
John Kåre Alsaker
d36393b839 Use Mutex to avoid issue with conditional locks 2023-08-30 18:17:38 +02:00
John Kåre Alsaker
b56acac41d Add ParallelGuard type to handle unwinding in parallel sections 2023-08-30 18:13:06 +02:00
John Kåre Alsaker
51eb8427bf Make parallel! an expression 2023-08-30 18:12:18 +02:00
John Kåre Alsaker
5739349e96 Use conditional synchronization for Lock 2023-08-30 06:10:02 +02:00
bors
6d32b298ed Auto merge of #114894 - Zoxc:sharded-cfg-cleanup2, r=cjgillot
Remove conditional use of `Sharded` from query state

`Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job.

r? `@cjgillot`
2023-08-29 12:04:37 +00:00
klensy
3b26b3d1d2 don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead 2023-08-28 18:59:55 +03:00
Weihang Lo
832fb9c072
Rollup merge of #114987 - RalfJung:unsound-mmap, r=cjgillot
elaborate a bit on the (lack of) safety in 'Mmap::map'

Sadly none of the callers of this function even consider it worth mentioning in their unsafe block that what they are doing is completely unsound.
2023-08-24 22:53:57 +01:00
John Kåre Alsaker
f458b112f8 Optimize lock_shards 2023-08-24 23:29:48 +02:00
bors
b60e31b673 Auto merge of #115082 - Zoxc:syntax-context-decode-race, r=cjgillot
Fix races conditions with `SyntaxContext` decoding

This changes `SyntaxContext` decoding to work with concurrent decoding. The `remapped_ctxts` field now only stores `SyntaxContext` which have completed decoding, while the new `decoding` and `local_in_progress` keeps track of `SyntaxContext`s which are in process of being decoding and on which threads.

This fixes 2 issues with the current implementation. It can return an `SyntaxContext` which contains dummy data if another thread starts decoding before the first one has completely finished. Multiple threads could also allocate multiple `SyntaxContext`s for the same `raw_id`.
2023-08-24 17:43:02 +00:00
bors
8a6b67f988 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur
Update bootstrap compiler to 1.73.0 beta
2023-08-24 11:10:52 +00:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
John Kåre Alsaker
e41240e45b Fix races conditions with SyntaxContext decoding 2023-08-22 02:36:41 +02:00
Ralf Jung
132a2c6cf2 elaborate a bit on the (lack of) safety in 'Mmap::map' 2023-08-19 12:50:26 +02:00
John Kåre Alsaker
0823f0c32b Remove count 2023-08-16 10:44:32 +02:00
John Kåre Alsaker
81220c0ace Keep SHARDS fixed instead of a function of cfg!(parallel_compiler) 2023-08-16 10:00:25 +02:00
John Kåre Alsaker
c737c62e70 Make Sharded an enum and specialize it for the single thread case 2023-08-15 17:22:48 +02:00
bors
617821ab32 Auto merge of #114339 - ttsugriy:unsafe-utf8, r=davidtwco
[rustc_data_structures][base_n][perf] Remove unnecessary utf8 check.

Since all output characters taken from `BASE_64` are valid UTF8 chars there is no need to waste cycles on validation.

Even though it's obviously a perf win, I've also used a [benchmark](https://gist.github.com/ttsugriy/e1e63c07927d8f31e71695a9c617bbf3) on M1 MacBook Air with following results:
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.670 µs 14.852 µs 15.074 µs]
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe
push_str/new            time:   [12.573 µs 12.674 µs 12.801 µs]
Found 11 outliers among 100 measurements (11.00%)
  7 (7.00%) high mild
  4 (4.00%) high severe
```
2023-08-08 10:25:37 +00:00
Matthias Krüger
4669905ee6
Rollup merge of #114418 - klensy:parking_lot, r=oli-obk
bump parking_lot to 0.12

Bumps parking_lot to 0.12, replaces few explicit uses of parking_lot with rustc_data_structures::sync ones.

<strike>cc `@oli-obk` this touches recent https://github.com/rust-lang/rust/pull/114283</strike>
cc `@SparrowLii` i've checked that this builds with parallel-compiler

measureme's bump https://github.com/rust-lang/measureme/pull/209
fcf3006e01/compiler/rustc_data_structures/src/sync.rs (L18-L34)
2023-08-04 21:31:56 +02:00
klensy
383b715163 bump parking_lot 0.11 to 0.12 2023-08-03 16:05:26 +03:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
Taras Tsugrii
64dfd1090d [rustc_data_structures][base_n][perf] Remove unnecessary utf8 check.
Since all output characters taken from `BASE_64` are valid UTF8 chars
there is no need to waste cycles on validation.

Even though it's obviously a perf win, I've also used a [benchmark](https://gist.github.com/ttsugriy/e1e63c07927d8f31e71695a9c617bbf3)
on M1 MacBook Air with following results:
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.670 µs 14.852 µs 15.074 µs]
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe
push_str/new            time:   [12.573 µs 12.674 µs 12.801 µs]
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  7 (7.00%) high mild
  4 (4.00%) high severe
```
2023-08-01 11:10:17 -07:00
Matthias Krüger
00ad3ccae6
Rollup merge of #114306 - ttsugriy:push_str, r=wesleywiser
[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-01 17:39:12 +02:00
Matthias Krüger
b38718090e
Rollup merge of #114283 - oli-obk:parkin_lot_rwlock, r=SparrowLii
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-01 17:39:10 +02:00
Oli Scherer
3eb5733ed4 Always use parking_lot's RwLock, even without parallel compiler 2023-08-01 06:55:12 +00:00
Matthias Krüger
a902550233
Rollup merge of #114313 - ttsugriy:sm-insert, r=petrochenkov
[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-01 06:55:55 +02:00
Taras Tsugrii
9eae73a5de [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-07-31 16:58:04 -07:00
Matthias Krüger
58f963fb65
Rollup merge of #113717 - cuishuang:master, r=Nilstrieb
remove repetitive words
2023-07-31 22:49:47 +02: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
cui fliter
88c7b16e03 remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31 16:13:02 +08:00
Taras Tsugrii
9ced089569 [rustc_data_structures] Use partition_point to find binary_search_slice end. 2023-07-29 19:42:22 -07:00
Taras Tsugrii
31fadf621b [rustc][data_structures] Simplify binary_search_slice. 2023-07-29 07:22:56 -07:00
Matthias Krüger
af2b370100 more clippy::style fixes:
get_first
single_char_add_str
unnecessary_mut_passed
manual_map
manual_is_ascii_check
2023-07-23 23:39:04 +02:00
Michael Woerister
457b787a52 Introduce ExtentUnord trait for collections that can safely consume UnordItems. 2023-07-14 10:10:15 +02:00
Michael Woerister
cfb310939b Enable potential_query_instability lint in rustc_hir_typeck.
Fix linting errors by using FxIndex(Map|Set) and Unord(Map|Set) as appropriate.
2023-07-14 10:10:14 +02:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Josh Stone
d9b1fa93c4 Upgrade to indexmap 2.0.0
The new version was already added to the tree as an indirect dependency
in #113046, but now our direct dependents are using it too.
2023-07-03 13:51:54 -07:00
Nicholas Nethercote
f2d863fa75 Remove SmallStr.
It no longer has any uses. If it's needed in the future, it can be
easily reinstated. Or a crate such as `smallstr` can be used, much like
we use `smallvec`.
2023-06-29 11:45:52 +10:00
Guillaume Gomez
a5561eb4d5
Rollup merge of #112538 - ndrewxie:issue-84447-partial-1, r=compiler-errors
Removed unnecessary &String -> &str, now that &String implements StableOrd as well

Applied a few nits suggested by lcnr to PR #110040 (nits can be found [here](https://github.com/rust-lang/rust/pull/110040#pullrequestreview-1469452191).)

Making a new PR because the old one was already merged, and given that this just applies changes that were already suggested, reviewing it should be fairly open-and-shut.
2023-06-21 20:00:49 +02:00
Camille GILLOT
7d5b2e4926 Make closure_saved_names_of_captured_variables a query. 2023-06-19 16:50:52 +00:00
Andrew Xie
0cac8455e6 Applied nits 2023-06-11 22:45:04 -04:00
Michael Goulet
80e9ca9398 Don't print Interned or PrivateZst 2023-06-09 00:20:37 +00:00
Andrew Xie
54d7b327e5 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
Andrew Xie
f5f638c124 Fixed to_sorted => to_sorted_stable_ord 2023-06-05 00:16:20 -04:00
Andrew Xie
6f2d3dee17 Fixed unord mistake 2023-06-04 21:55:32 -04:00
Andrew Xie
96b577860d Fixed failing test + minor cleanup 2023-06-04 21:55:32 -04:00
Arlo Siemsen
4d9b476bb1 Update dependencies with reported vulnerabilities
bumpalo 3.12.1 (yanked)
  * updated to 3.13.0
tokio 1.8.4 - https://rustsec.org/advisories/RUSTSEC-2023-0001
  * updated to 1.28.2
remove_dir_all 0.5.3 - https://rustsec.org/advisories/RUSTSEC-2023-0018
  * removed by using the standard library function in `rust-installer` instead and updating to `tempfile@3.5.0` (which also removes the dependency).
2023-06-02 12:34:01 -05:00
bors
ad8304a0d5 Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot
diagnostics: exclude indirect private deps from trait impl suggest

Fixes #88696
2023-05-31 13:47:36 +00:00
John Kåre Alsaker
8abafd085a Add some comments 2023-05-28 15:54:52 +02:00
John Kåre Alsaker
5843858c01 Don't access self.mask with a single shard 2023-05-28 15:47:44 +02:00
John Kåre Alsaker
6620882089 Use only one shard with a single thread 2023-05-28 14:08:59 +02:00
Michael Howell
52bd82f522 rustc_data_structures: sync and atomic consistency
Co-authored-by: @lukas-code
2023-05-25 15:18:05 -07:00
Michael Howell
6a358960da rustc_metadata: specialize private_dep flag with fetch_and 2023-05-25 08:15:05 -07:00
Michael Howell
a12f50ddc4 rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
2023-05-25 08:15:04 -07:00
Matthias Krüger
a9743e108a
Rollup merge of #111875 - WaffleLapkin:defer_on_drop, r=Nilstrieb
Don't leak the function that is called on drop

It probably wasn't causing problems anyway, but still, a `// this leaks, please don't pass anything that owns memory` is not sustainable.

I could implement a version which does not require `Option`, but it would require `unsafe`, at which point it's probably not worth it.
2023-05-25 08:01:08 +02:00
Manish Goregaokar
d0b3ebee66
Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, r=petrochenkov
Use `Option::is_some_and` and `Result::is_ok_and` in the compiler

`.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable.

This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24 15:05:05 -07:00
bors
97d328012b Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiasko
Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of https://github.com/rust-lang/rust/pull/107157
cc `@tmiasko`
2023-05-24 16:18:21 +00:00
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
Maybe Waffle
e2b953063d Don't leak the function that is called on drop 2023-05-23 14:53:36 +00:00
bors
25f084d5e0 Auto merge of #111596 - cjgillot:dominator-bucket, r=Mark-Simulacrum
Process current bucket instead of parent's bucket when starting loop for dominators.

The linked paper by Georgiadis suggests in §2.2.3 to process `bucket[w]` when beginning the loop, instead of `bucket[parent[w]]` when finishing it.

In the test case, we correctly computed `idom[2] = 0` and `sdom[3] = 1`, but the algorithm returned `idom[3] = 1`, instead of the correct value 0, because of the path 0-7-2-3.

This provoked LLVM ICE in https://github.com/rust-lang/rust/pull/111061#issuecomment-1546912112. LLVM checks that SSA assignments dominate uses using its own implementation of Lengauer-Tarjan, and saw case where rustc was breaking the dominance property.

r? `@Mark-Simulacrum`
2023-05-20 07:41:15 +00:00
Camille GILLOT
7c8f29f02c Revert spurious changes. 2023-05-18 14:36:13 +00:00
Dylan DPC
ad214ac02b
Rollup merge of #111707 - nnethercote:rm-WorkerLocal-Vec, r=compiler-errors
Remove unused `impl<T> WorkerLocal<Vec<T>>`.

cc ``@SparrowLii`` ``@Zoxc``
2023-05-18 17:37:10 +05:30
Nicholas Nethercote
9bfb90b1be Remove unused impl<T> WorkerLocal<Vec<T>>. 2023-05-18 13:14:45 +10:00
Camille GILLOT
fa8598cb50 Merge DominatorTree and Dominators. 2023-05-17 10:37:29 +00:00
Camille GILLOT
4bbdb64016 Typo. 2023-05-17 10:29:12 +00:00
Camille GILLOT
ae318e3444 Remove outdated comment. 2023-05-17 10:26:04 +00:00
Tomasz Miąsko
aa1267f630 Preprocess dominator tree to answer queries in O(1) 2023-05-17 09:36:12 +00:00
Dylan DPC
2a5c4baf68
Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb
Share slice of bytes

r? `@Nilstrieb`
cc `@noamtashma`
2023-05-17 11:13:55 +05:30
Maybe Waffle
a6197a5dca Fixup comments 2023-05-16 12:09:24 +00:00
Maybe Waffle
e39d61cbf3 Remove MetadataRef type alias 2023-05-16 11:55:47 +00:00