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

debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo. #93154

Conversation

michaelwoerister
Copy link
Member

Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name.

This commit also emits {closure_env#0} as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called {closure#0}). Previously both were assigned the same name.

NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.

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

r? @cjgillot

(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 Jan 21, 2022
@michaelwoerister
Copy link
Member Author

There might be some indeterminism in the order some of the LLVM IR is produced :(
I'll look into making the test more robust or, even better, getting rid of the indeterminism.

@rust-log-analyzer

This comment has been minimized.

@michaelwoerister michaelwoerister force-pushed the fix-generic-closure-and-generator-debuginfo branch from be342d5 to 2022bac Compare January 21, 2022 15:05
@michaelwoerister
Copy link
Member Author

Using the new symbol mangling scheme should make codegen item order independent of rustc's version (within codegen items of the same crate). Let's see if this is enough to stabilize the test.

@michaelwoerister michaelwoerister added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Jan 26, 2022
// MSVC: !DIGlobalVariable(name: "impl$<debug_vtable::bar::closure_env$0, core::ops::function::FnOnce<tuple$<enum$<core::option::Option<ref$<dyn$<core::ops::function::Fn<tuple$<>,assoc$<Output,tuple$<> > > > > >, {{.*}}, {{.*}}, Some> > > >::vtable$"

// NONMSVC: !DIGlobalVariable(name: "<debug_vtable::generic_closure::{closure_env#0}<bool> as core::ops::function::FnOnce<()>>::{vtable}"
// MSVC: !DIGlobalVariable(name: "impl$<debug_vtable::generic_closure::closure_env$0<bool>, core::ops::function::FnOnce<tuple$<> > >::vtable$
Copy link
Member

Choose a reason for hiding this comment

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

I was going to comment on the tuple$<> thing which seems like it could break natvis but I see we already filed #89704 for that.

@wesleywiser
Copy link
Member

r? @wesleywiser
@bors r+

@bors
Copy link
Contributor

bors commented Jan 31, 2022

📌 Commit 2022bac has been approved by wesleywiser

@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 Jan 31, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 31, 2022
…e-and-generator-debuginfo, r=wesleywiser

debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo.

Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name.

This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name.

NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
@matthiaskrgr
Copy link
Member

Might have failed in a rollup on windows: #93510 (comment)
@bors r- rollup=iffy

@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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 31, 2022
…nments are unique in debuginfo.

Before this change, closure/generator environments coming from different
instantiations of the same generic function were all assigned the same
name even though they were distinct types with potentially different data
layout. Now we append the generic arguments of the originating function
to the type name.

This commit also emits '{closure_env#0}' as the name of these types in
order to disambiguate them from the accompanying closure function
'{closure#0}'. Previously both were assigned the same name.
@michaelwoerister michaelwoerister force-pushed the fix-generic-closure-and-generator-debuginfo branch from 2022bac to fd7557b Compare February 1, 2022 09:40
@michaelwoerister
Copy link
Member Author

Fixed the test case.

@bors r=wesleywiser

@bors
Copy link
Contributor

bors commented Feb 1, 2022

📌 Commit fd7557b has been approved by wesleywiser

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

bors commented Feb 2, 2022

⌛ Testing commit fd7557b with merge dca1e7a...

@bors
Copy link
Contributor

bors commented Feb 2, 2022

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing dca1e7a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 2, 2022
@bors bors merged commit dca1e7a into rust-lang:master Feb 2, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 2, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dca1e7a): comparison url.

Summary: This benchmark run shows 18 relevant regressions 😿 to instruction counts.

  • Average relevant regression: 1.6%
  • Largest regression in instruction counts: 2.9% on incr-full builds of deeply-nested-closures debug

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

@rustbot rustbot added the perf-regression Performance regression. label Feb 2, 2022
@Mark-Simulacrum
Copy link
Member

@michaelwoerister it looks like this had a negative effect on a number of -debug benchmarks, which I suppose is likely expected -- do you think there are any particular spots where this impl might be inefficient (and so should specifically be investigated), or is this just roughly an expected result?

If expected, then please mark as perf-regression-triaged.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 9, 2022
…debuginfo-regression, r=wesleywiser

debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in rust-lang#89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? `@wesleywiser`

This PR should fix issue rust-lang#93164.
~~The PR is blocked on rust-lang#93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 9, 2022
…debuginfo-regression, r=wesleywiser

debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in rust-lang#89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? ``@wesleywiser``

This PR should fix issue rust-lang#93164.
~~The PR is blocked on rust-lang#93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

10 participants