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

Remove visibility information from HIR #93970

Merged
merged 12 commits into from
Apr 24, 2022
Merged

Remove visibility information from HIR #93970

merged 12 commits into from
Apr 24, 2022

Conversation

cjgillot
Copy link
Contributor

The resolver exports all the necessary visibility information through the tcx.visibility query.
This PR stops having a dedicated visibility field in HIR, in order to use this query.
We keep a vis_span field for diagnostic purposes.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 13, 2022
@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rust-highfive
Copy link
Collaborator

r? @lcnr

(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 Feb 13, 2022
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov self-assigned this Feb 14, 2022
@lcnr lcnr removed their assignment Feb 14, 2022
@lcnr
Copy link
Contributor

lcnr commented Feb 14, 2022

r? @petrochenkov

compiler/rustc_lint/src/builtin.rs Show resolved Hide resolved
compiler/rustc_lint/src/builtin.rs Show resolved Hide resolved
compiler/rustc_passes/src/dead.rs Outdated Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

failures:
    [ui] ui/error-codes/E0431.rs
    [ui] ui/save-analysis/issue-73020.rs
    [ui] ui/use/use-mod.rs

Apparently some imports still miss their visibility entries in the table.

@petrochenkov petrochenkov 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 Feb 14, 2022
@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 14, 2022
@@ -595,30 +591,16 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {

fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
match it.kind {
hir::ItemKind::Trait(.., trait_item_refs) => {
hir::ItemKind::Trait(..) => {
// Issue #11592: traits are always considered exported, even when private.
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this whole arm can be removed now (including this comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't removing this arm will change behaviour?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, but it still looks like a reasonable change.
It can be done in a separate PR.

compiler/rustc_passes/src/dead.rs Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

r=me after addressing the remaining comments and squashing commits.

@petrochenkov petrochenkov 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 Feb 15, 2022
@cjgillot
Copy link
Contributor Author

This PR introduces untracked information in metadata. As visibility is not in the HIR any more, it's not in the crate_hash, and will create incr comp ICEs in downstream crates. I'll add an extra commit to adress this.

@cjgillot
Copy link
Contributor Author

@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 Feb 18, 2022
@bors
Copy link
Contributor

bors commented Feb 18, 2022

⌛ Trying commit 1d2707f49db710409cb70bf7cedda3bfc7e28fa7 with merge 5a9e9f6c9170cf730f258de9ecbaac918bf4a913...

@bors
Copy link
Contributor

bors commented Feb 18, 2022

☀️ Try build successful - checks-actions
Build commit: 5a9e9f6c9170cf730f258de9ecbaac918bf4a913 (5a9e9f6c9170cf730f258de9ecbaac918bf4a913)

@cjgillot cjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Apr 23, 2022
@cjgillot
Copy link
Contributor Author

This version hashes visibility information into the crate hash, so should be sound in terms of metadata, unblocking.
The slowdown is mostly in "unused-warnings", which is a stress benchmark, in crate_hash query, which is expected.
Commit b272468 fixes the failure of image-0.24.1 benchmark.

@@ -131,6 +131,8 @@ pub struct ResolverOutputs {
pub definitions: rustc_hir::definitions::Definitions,
pub cstore: Box<CrateStoreDyn>,
pub visibilities: FxHashMap<LocalDefId, Visibility>,
/// This field is used to decide whether we should make `PRIVATE_IN_PUBLIC` a hard error.
pub has_pub_restricted: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be included into the crate hash too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is only used to emit a diagnostic, which won't appear in metadata. Therefore, it does not need to appear in crate_hash. I can include it as a safety precaution.

@petrochenkov
Copy link
Contributor

r=me after addressing #93970 (comment) and squashing commits.

@petrochenkov petrochenkov 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 Apr 23, 2022
@cjgillot
Copy link
Contributor Author

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Apr 23, 2022

📌 Commit 0a6e135 has been approved by petrochenkov

@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 Apr 23, 2022
@bors
Copy link
Contributor

bors commented Apr 23, 2022

⌛ Testing commit 0a6e135 with merge 143eaa8...

@bors
Copy link
Contributor

bors commented Apr 24, 2022

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 143eaa8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 24, 2022
@bors bors merged commit 143eaa8 into rust-lang:master Apr 24, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 24, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (143eaa8): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 😿 relevant regressions found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 16 2 2 2
mean2 N/A 1.3% -0.2% -0.3% -0.2%
max N/A 2.2% -0.2% -0.3% -0.2%

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

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@cjgillot
Copy link
Contributor Author

This PR removes redundant information from the HIR to directly use the resolver outputs. The regression only appears on usused-warnings, which is a stress test. The regression is concentrated on the crate_hash query, which now hashes visibility. This increased work in crate_hash is arguably a bugfix, since visibilities were not being hashed.
@rustbot label: +perf-regression-triaged

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-triaged The performance regression has been triaged. 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
Development

Successfully merging this pull request may close these issues.

8 participants