Commit Graph

26671 Commits

Author SHA1 Message Date
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
Nicholas Nethercote
c17c8dc78e Remove unnecessary semicolon. 2023-07-31 16:34:13 +10: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
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
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
Jubilee
126d809287
Rollup merge of #113741 - compiler-errors:rpitit-projects-to-missing-opaque, r=spastorino
Don't install default projection bound for return-position `impl Trait` in trait methods with no body

This ensures that we never try to project to an opaque type in a trait method that has no body to infer its hidden type, which means we never later call `type_of` on that opaque. This is because opaque types try to reveal their hidden type when proving auto traits.

I thought about this a lot, and I think this is a fix that's less likely to introduce other strange downstream ICEs than #113461.

Fixes #113434

r? `@spastorino`
2023-07-30 17:50:48 -07:00
Michael Goulet
0f0ab89feb Don't install default projection bound for RPITITs 2023-07-30 21:46:29 +00:00
Caleb Zulawski
77ed437de8 Fix simd_bswap for i8/u8 2023-07-30 15:40:32 -04:00
Matthias Krüger
4916ab5330
Rollup merge of #114258 - WaffleLapkin:reuse_in_derive_expansion, r=petrochenkov
Simplify `Span::can_be_used_for_suggestions` a little tiny bit

Just something I saw randomly.
2023-07-30 20:36:35 +02:00
Matthias Krüger
97bacad9c2
Rollup merge of #114256 - Urgau:fix-issue-114180, r=WaffleLapkin
Fix invalid suggestion for mismatched types in closure arguments

This PR fixes the invalid suggestion for mismatched types in closure arguments.

The invalid suggestion came from a wrongly created span in the parser for closure arguments that don't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern.

There is one unfortunate downside of this fix, it worsens even more the diagnostic for mismatched types in closure args without an explicit type. This happens because there is no correct span for implied inferred type. I tried also fixing this but it's a rabbit hole.

Fixes https://github.com/rust-lang/rust/issues/114180
2023-07-30 20:36:35 +02:00
Matthias Krüger
d113b5b848
Rollup merge of #114246 - Bryanskiy:type-privacy-lints-fixes, r=petrochenkov
Weaken unnameable_types lint

`unnameable_types` lint is no longer emitted for
- associated types
- internal types

r? ``@petrochenkov``
2023-07-30 20:36:34 +02:00
Matthias Krüger
b192576036
Rollup merge of #114074 - matthiaskrgr:fmt_args_rustc_2, r=WaffleLapkin
inline format!() args from rustc_middle up to and including rustc_codegen_llvm (3)

r? `@WaffleLapkin`
2023-07-30 20:36:34 +02:00
Maybe Waffle
a3838780f2 Simplify Span::can_be_used_for_suggestions a little tiny bit 2023-07-30 15:37:39 +00:00
Urgau
8ea7e45e44 Fix invalid suggestion for mismatched types in closure arguments
The invalid suggestion came from a wrongly created span in `rustc_parse'
for closure arguments that didn't have a type specified. Specifically,
the span in this case was the last token span, but in the case of
tuples, the span represented the last parenthesis instead of the whole
tuple, which is fixed by taking the more accurate span of the pattern.
2023-07-30 17:15:55 +02:00
Matthias Krüger
a964f948d5
Rollup merge of #114068 - matthiaskrgr:fmt_args_rustc_1, r=WaffleLapkin
inline format!() args up to and including rustc_middle (2)

r? `@WaffleLapkin`
2023-07-30 14:25:09 +02:00
Matthias Krüger
427f3d3266
Rollup merge of #114018 - Enselic:multi-annotation, r=b-naber
Make `--error-format human-annotate-rs` handle multiple files

Closes #64205 which is E-help-wanted
2023-07-30 14:25:09 +02:00
Matthias Krüger
e3bf088fb5
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Matthias Krüger
3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
Matthias Krüger
23815467a2 inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
Bryanskiy
8203d1ddf6 Weaken unnameable_types lint 2023-07-30 14:02:21 +03:00
Maybe Waffle
90f9640528 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
fee1-dead
7b4bfd640d
Rollup merge of #114203 - fee1-dead-contrib:effects/pp-no-host, r=oli-obk
Effects: don't print `host` param in diagnostics

r? ``@oli-obk``
2023-07-30 07:13:03 +00:00
bors
fb53384c94 Auto merge of #114226 - matthiaskrgr:rollup-wxdudsm, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #114129 (Rustdoc small cleanups)
 - #114152 ([rustc][data_structures] Simplify binary_search_slice.)
 - #114222 (Mark `lazy_type_alias` as incomplete)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 00:41:35 +00:00
Matthias Krüger
d4926b13aa
Rollup merge of #114222 - compiler-errors:lazy-type-alias-is-incomplete, r=oli-obk
Mark `lazy_type_alias` as incomplete

This feature is very not complete: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-lazy_type_alias

r? types
2023-07-30 01:22:43 +02:00
Matthias Krüger
b8895980bc
Rollup merge of #114152 - ttsugriy:master, r=WaffleLapkin
[rustc][data_structures] Simplify binary_search_slice.

Instead of using `binary_search_by_key`, it's possible to use `partition_point` to find the lower bound. This avoids the need to locate the leftmost matching entry separately.

It's also possible to use `partition_point` to find the upper bound, so I plan to send a separate PR for your consideration.
2023-07-30 01:22:42 +02:00
Michael Goulet
744e770939 some nits, bless test 2023-07-29 21:29:03 +00:00
Michael Goulet
50d21091ee Implement assumed_wf_types for RPITITs' implementations 2023-07-29 21:19:33 +00:00
Michael Goulet
349a2372ed Take RPITITs inherit the assumed_wf_types of their parent fn 2023-07-29 21:19:33 +00:00
Michael Goulet
4b58ae0bb8 Mark lazy_type_alias as incomplete 2023-07-29 19:47:15 +00:00
bors
03a57254b5 Auto merge of #114156 - calebzulawski:simd-bswap, r=compiler-errors
Add simd_bswap, simd_bitreverse, simd_ctlz, and simd_cttz intrinsics

cc `@workingjubilee`
2023-07-29 18:51:45 +00:00
bors
a04e649c09 Auto merge of #114028 - Centri3:ternary-operator, r=compiler-errors
Gracefully handle ternary operator

Fixes #112578

~~May not be the best way to do this as it doesn't check for a single `:`, so it could perhaps appear even when the actual issue is just a missing semicolon. May not be the biggest deal, though?~~

Nevermind, got it working properly now ^^
2023-07-29 16:45:29 +00:00
bors
4c96822796 Auto merge of #114148 - cuviper:drop-llvm-14, r=nikic
Update the minimum external LLVM to 15

With this change, we'll have stable support for LLVM 15 through 17 (pending release).
For reference, the previous increase to LLVM 14 was #107573.
2023-07-29 14:57:47 +00:00
Deadbeef
df3f9fdf5a Effects: don't print host param in diagnostics 2023-07-29 14:55:35 +00:00
Taras Tsugrii
31fadf621b [rustc][data_structures] Simplify binary_search_slice. 2023-07-29 07:22:56 -07:00