Skip to content

Conversation

b-naber
Copy link
Contributor

@b-naber b-naber commented Nov 26, 2021

Fixes #59324
Fixes #67684
Fixes #69398
Fixes #71113
Fixes #82079
Fixes #85103
Fixes #88856
Fixes #91231
Fixes #91234

Previously we called normalize_erasing_regions inside layout_of. normalize_erasing_regions assumes that the normalization succeeds. Since some layout_of calls happen before typecheck has finished, we introduce a new variant that allows for returning an error.

@rust-highfive
Copy link
Contributor

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive
Copy link
Contributor

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 26, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 26, 2021
@bors
Copy link
Collaborator

bors commented Nov 26, 2021

⌛ Trying commit 11f105cd6e9635ae233a61121bdf330f1b040582 with merge 7cd727ea460dd27fc8f52e430e9cd2301eec1439...

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even care about the size of this type? We care about InterpErrorInfo but that is a Box so it is independent of the size of InterpError.

So I think I would favor removing this assertion, it might just lead someone to unnecessarily introduce another unnecessary Box indirection.

@jackh726
Copy link
Member

This is great :) does this fix the test in #82039?

@camelid
Copy link
Member

camelid commented Nov 26, 2021

Does this fix #91231 as well, since it's very similar to #91234 (which this is marked as fixing)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just make these two "normalizing {}", so the error outputs are nicer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is never actually emitted? Makes me wonder if we actually need to keep track of what we couldn't normalize.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I noticed that too and was debating whether we need the type, but think that it makes sense to output the type for which normalization fails here. There are a couple other issues which triggered this ICE (but not through layout_of and which have yet to be fixed (although I think the new function would make that fairly straightforward)), and we might need this type information there.

I also added another test for issue 85103 which emits this error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this deserves a comment on why failing to fully normalize is valid here. I would potentially imagine that by the time we need to know layout, we should have all the information to normalize (though I'm not sure, this might not be true)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might make sense to have two different versions of layout_of. Currently most of the calls of that function happen after typecheck and normalization is always guaranteed to succeed, but there are some calls in typecheck and some lints that use it. Does it makes sense to have one version which requires normalization to succeed and another in which it can fail?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question! In #82039, IIRC we were basically coming to the conclusion that we shouldn't be trying to get the layout of things until after typechecking. So, I think splitting out layout_of into two version is a decent intermediate step to "audit", in some way, incorrect behavior.

I think this would be better as a followup. Can you add a FIXME or file an issue?

@camelid
Copy link
Member

camelid commented Nov 26, 2021

Does this fix #85103? (cc #85485)

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Nov 26, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2021
@camelid
Copy link
Member

camelid commented Nov 26, 2021

You'll need to update rustdoc:

error[E0004]: non-exhaustive patterns: `Err(NormalizationFailure(_, _))` not covered
681
    --> src/librustdoc/html/render/print_item.rs:1705:11
682
     |
683
1705 |     match tcx.layout_of(param_env.and(ty)) {
684
     |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Err(NormalizationFailure(_, _))` not covered
685
     |
686
    ::: /checkout/library/core/src/result.rs:512:5
687
     |
688
512  |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
689
     |     --- not covered
690
     |
691
     = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
692
     = note: the matched value is of type `Result<TyAndLayout<&TyS>, rustc_middle::ty::layout::LayoutError>`
693

@b-naber
Copy link
Contributor Author

b-naber commented Nov 26, 2021

@jackh726 The test in #82039 is not fixed by this, since I only used try_normalize_erasing_regions in layout_of. There are a couple of other calls of normalize_erasing_regions which are used before normalization is guaranteed to succeed. I can change those to use this new function.

@camelid The two issues you mentioned are fixed by this PR, added tests.

@b-naber
Copy link
Contributor Author

b-naber commented Nov 26, 2021

Can anybody request another another timer run once CI passes, please?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@bors
Copy link
Collaborator

bors commented Nov 26, 2021

⌛ Trying commit ce0e6f8c86311589ecc6df277b37bbe236e0e8ca with merge 3393f73e33f01001d1dbe2362ae0d7311dba2447...

@camelid camelid added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 26, 2021
@b-naber
Copy link
Contributor Author

b-naber commented Dec 1, 2021

@bors r=jackh276

@bors
Copy link
Collaborator

bors commented Dec 1, 2021

📌 Commit 6952470 has been approved by jackh276

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 1, 2021
@bors
Copy link
Collaborator

bors commented Dec 1, 2021

⌛ Testing commit 6952470 with merge f04a2f4...

@bors
Copy link
Collaborator

bors commented Dec 1, 2021

☀️ Test successful - checks-actions
Approved by: jackh276
Pushing f04a2f4 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 1, 2021
@bors bors merged commit f04a2f4 into rust-lang:master Dec 1, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 1, 2021
@jyn514
Copy link
Member

jyn514 commented Dec 1, 2021

Ooh, I wonder if this could be used for #82692 :)

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f04a2f4): comparison url.

Summary: This change led to small relevant regressions 😿 in compiler performance.

  • Small regression in instruction counts (up to 0.9% on incr-full builds of ctfe-stress-4)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@b-naber b-naber deleted the normalization-ice branch December 2, 2021 09:16
@rylev
Copy link
Member

rylev commented Dec 7, 2021

@b-naber @jackh726 as you can see this PR yielded some performance regressions (albeit not huge ones and mostly in stress tests. Looking at the self profiling info, nothing jumped out at me. A run of cachegrind may be in order, but I unfortunately don't have time to do that right now. Any thoughts on potential causes of the regressions?

@b-naber
Copy link
Contributor Author

b-naber commented Dec 7, 2021

@rylev performance regression might be due to the fact that we don't cache normalize_erasing_regions queries in functions that now use th try version. We might be able to improve this by implementing normalize_erasing_regions in terms of try_normalize_erasing_regions. I can implement this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet