Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #121332

Closed
wants to merge 25 commits into from
Closed

Conversation

Noratrieb
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

RalfJung and others added 25 commits February 17, 2024 09:14
Its one use isn't necessary, because it's not possible for errors to
have been emitted at that point.
Currently `has_errors` excludes lint errors. This commit changes it to
include lint errors.

The motivation for this is that for most places it doesn't matter
whether lint errors are included or not. But there are multiple places
where they must be includes, and only one place where they must not be
included. So it makes sense for `has_errors` to do the thing that fits
the most situations, and the new `has_errors_excluding_lint_errors`
method in the one exceptional place.

The same change is made for `err_count`. Annoyingly, this requires the
introduction of `err_count_excluding_lint_errs` for one place, to
preserve existing error printing behaviour. But I still think the change
is worthwhile overall.
This profile originally made sense when download-ci-llvm = if-unchanged
didn't exist and we had the bad tradeoff of "never modify or always
compile".

Thankfully, these grim times are over and we have discovered clean
water, so the only differentiator between the two profiles is the
codegen profile having LLVM assertions. Adding them doesn't cause that
much of a slowdown, <10% on UI tests from an unscientific benchmark.

It also had LLVM warnings when compiling, which makes sense for every
compiler contributor brave enough to compile LLVM.

The way I removed is by just issueing a nice error message. Given that
everyone with this profile should be a contributor and not someone like
a distro who is more upset when things break, this should be fine.
If it isn't, we can always fall back to just letting codegen mean
compiler.
…sertions)

The current complexities in `assert_unsafe_precondition` are delicately
balancing several concerns, among them compile times for the cases where
there are no debug assertions. This comes at a large runtime cost when
the assertions are enabled, making the debug assertion compiler a lot
slower, which is very annoying.

To avoid this, we always inline the check when building with debug
assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)`
  `debug_assertions`: 67s
- this: 54s

So this seems like a good solution. I think we can still get
the same run-time perf improvements for other users too by
massaging this code further (see my other PR about adding
`#[rustc_no_mir_inline]`) but this is a simpler step that
solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with
dbeug assertions makes it faster (than without, when using debug
assertions downstream)!
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
Because it's now simple enough that it doesn't provide much benefit.
It currently is infallible and uses `abort_if_errors` and
`FatalError.raise()` to signal errors. It's easy to instead return a
`Result<_, ErrorGuaranteed>`, which is the more usual way of doing
things.
Replace `abort_if_errors` calls that are certain to abort -- because
we emit an error immediately beforehand -- with `FatalErro.raise()`.
It's clumsy and doesn't improve readability.
It is a clearer name because it communicates what the lint does
instead of the underlying mechanism it uses (const propagation).
resolve: Scale back unloading of speculatively loaded crates

Fixes rust-lang#120830 and fixes rust-lang#120909 while still unblocking rust-lang#117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
…aethlin

Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions)

The current complexities in `assert_unsafe_precondition` are delicately balancing several concerns, among them compile times for the cases where there are no debug assertions. This comes at a large runtime cost when the assertions are enabled, making the debug assertion compiler a lot slower, which is very annoying.

To avoid this, we always inline the check when building with debug assertions.

Numbers (compiling stage1 library after touching core):
- master: 80s
- just adding `#[inline(always)]` to the `cfg(bootstrap)` `debug_assertions` (equivalent to a bootstrap bump (uhh, i just realized that i was on a slightly outdated master so this bump might have happened already), (rust-lang#121112)): 67s
- this: 54s

So this seems like a good solution. I think we can still get the same run-time perf improvements for other users too by massaging this code further (see my other PR about adding `#[rustc_no_mir_inline]` rust-lang#121114) but this is a simpler step that solves the imminent problem of "holy shit my rustc is sooo slow".

Funny consequence: This now means compiling the standard library with dbeug assertions makes it faster (than without, when using debug assertions downstream)!

r? `@saethlin` (or anyone else if someone wants to review this)

fixes rust-lang#121110, supposedly
…ng, r=oli-obk

Top level error handling

The interactions between the following things are surprisingly complicated:
- `emit_stashed_diagnostics`,
- `flush_delayed`,
- normal return vs `abort_if_errors`/`FatalError.raise()` unwinding in the call to the closure in `interface::run_compiler`.

This PR disentangles it all.

r? `@oli-obk`
intrinsics::simd: add missing functions

Turns out stdarch declares a bunch more SIMD intrinsics that are still missing from libcore.
I hope I got the docs and in particular the safety requirements right for these "unordered" and "nanless" intrinsics.

Many of these are unused even in stdarch, but they are implemented in the codegen backend, so we may as well list them here.

r? `@Amanieu`
Cc `@calebzulawski` `@workingjubilee`
…s, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? ``@dtolnay``
…tmcm,Nilstrieb

Generate `getelementptr` instead of `inttoptr` for `ptr::invalid`

Currently, `ptr::invalid` [generates an `inttoptr`](https://godbolt.org/z/3cj15dEG1), which means LLVM doesn't know that the pointer shouldn't have provenance. This PR changes the implementation so that a `getelementptr` relative to the null pointer is generated, which LLVM knows not to have provenance.
…y789

Remove the "codegen" profile from bootstrap

This profile originally made sense when download-ci-llvm = if-unchanged didn't exist and we had the bad tradeoff of "never modify or always compile".

Thankfully, these grim times are over and we have discovered clean water, so the only differentiator between the two profiles is the codegen profile having LLVM assertions. Adding them doesn't cause that much of a slowdown, <10% on UI tests from an unscientific benchmark.

It also had LLVM warnings when compiling, which makes sense for every compiler contributor brave enough to compile LLVM.

The way I removed is by just issueing a nice error message. Given that everyone with this profile should be a contributor and not someone like a distro who is more upset when things break, this should be fine. If it isn't, we can always fall back to just letting codegen mean compiler.
…-obk

Rename `ConstPropLint` to `KnownPanicsLint`

`OverflowLint` is a clearer name because it communicates what the lint does instead of the underlying mechanism it uses (const propagation) which should be of secondary concern.

`OverflowLint` isn't the most accurate name because the lint looks for other errors as well such as division by zero not just overflows, but I couldn't think of another equally succinct name.

As a part of this change. I've also added/updated some of the comments.

cc `@RalfJung` `@oli-obk` for visibility in case you go looking for the lint using the old name.

Edit:

Changed the name from `OverflowLint` to `KnownPanicsLint`
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 20, 2024
@rustbot rustbot added T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 20, 2024
@Noratrieb
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Feb 20, 2024

📌 Commit 76a78ef has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2024
@bors
Copy link
Contributor

bors commented Feb 20, 2024

⌛ Testing commit 76a78ef with merge 43b954a...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121206 (Top level error handling)
 - rust-lang#121223 (intrinsics::simd: add missing functions)
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121242 (Generate `getelementptr` instead of `inttoptr` for `ptr::invalid`)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [mir-opt] tests/mir-opt/inline/polymorphic_recursion.rs ... ok

failures:

---- [mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs stdout ----
14           scope 3 {
15               debug ptr => _3;
16           }
-           scope 4 (inlined Unique::<[bool; 0]>::dangling) {
-               let mut _5: std::ptr::NonNull<[bool; 0]>;
-               scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
-                   let mut _7: usize;
-                   scope 6 {
-                       let _6: *mut [bool; 0];
-                       scope 7 {
-                           debug ptr => _6;
-                           scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
-                               debug ptr => _6;
-                               let mut _8: bool;
-                               let _9: ();
-                               let mut _10: *mut ();
-                               let mut _11: *const [bool; 0];
-                               scope 12 {
-                           }
-                       }
-                       }
-                       scope 8 (inlined align_of::<[bool; 0]>) {
-                       }
-                       scope 9 (inlined invalid_mut::<[bool; 0]>) {
-                           debug addr => _7;
-                           scope 10 {
-                       }
-                   }
-               }
-           }
-           }
45       }
46   
47       bb0: {

48           StorageLive(_1);
49           StorageLive(_2);
50           StorageLive(_3);
-           StorageLive(_9);
52           StorageLive(_4);
-           StorageLive(_5);
-           StorageLive(_6);
-           StorageLive(_7);
- -         _7 = AlignOf([bool; 0]);
- -         _6 = _7 as *mut [bool; 0] (Transmute);
- +         _7 = const 1_usize;
- +         _6 = const {0x1 as *mut [bool; 0]};
-           StorageDead(_7);
-           StorageLive(_10);
-           StorageLive(_11);
-           StorageLive(_8);
-           _8 = cfg!(debug_assertions);
-           switchInt(move _8) -> [0: bb3, otherwise: bb2];
+           _4 = Unique::<[bool; 0]>::dangling() -> [return: bb2, unwind unreachable];
67   
68       bb1: {

71       }
71       }
72   
73       bb2: {
- -         _10 = _6 as *mut () (PtrToPtr);
- -         _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable];
- +         _10 = const {0x1 as *mut ()};
- +         _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable];
-   
-       bb3: {
-           StorageDead(_8);
-           StorageDead(_8);
- -         _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer));
- -         _5 = NonNull::<[bool; 0]> { pointer: _11 };
- +         _11 = const {0x1 as *const [bool; 0]};
- +         _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
-           StorageDead(_11);
-           StorageDead(_10);
-           StorageDead(_6);
- -         _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
- +         _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
-           StorageDead(_5);
- -         _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
- +         _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+           _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
94           StorageDead(_4);
- -         _2 = Box::<[bool]>(_3, const std::alloc::Global);
- +         _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
-           StorageDead(_9);
+           _2 = Box::<[bool]>(_3, const std::alloc::Global);
98           StorageDead(_3);
- -         _1 = A { foo: move _2 };
- +         _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
+           _1 = A { foo: move _2 };
101           StorageDead(_2);
102           _0 = const ();
103           drop(_1) -> [return: bb1, unwind unreachable];
104       }
- + }
- + 
- + 
- + ALLOC2 (size: 8, align: 4) {
- +     01 00 00 00 00 00 00 00                         │ ........
- + }
- + 
- + ALLOC1 (size: 8, align: 4) {
- +     01 00 00 00 00 00 00 00                         │ ........
- + }
- + 
- + ALLOC0 (size: 8, align: 4) {
- +     01 00 00 00 00 00 00 00                         │ ........
118   
119 

thread '[mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs' panicked at src/tools/compiletest/src/runtest.rs:4131:21:
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs' panicked at src/tools/compiletest/src/runtest.rs:4131:21:
Actual MIR output differs from expected MIR output /checkout/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff


failures:
    [mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs

@bors
Copy link
Contributor

bors commented Feb 20, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 20, 2024
@RalfJung RalfJung closed this Feb 20, 2024
@Noratrieb Noratrieb deleted the rollup-qwmc1i4 branch February 20, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants