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

Fix invalid DWARF for enums when using ThinLTO #59380

Merged
merged 2 commits into from
Mar 30, 2019
Merged

Fix invalid DWARF for enums when using ThinLTO #59380

merged 2 commits into from
Mar 30, 2019

Conversation

philipc
Copy link
Contributor

@philipc philipc commented Mar 23, 2019

We were setting the same identifier for both the DW_TAG_structure_type
and the DW_TAG_variant_part. This becomes a problem when using ThinLTO
becauses it uses the identifier as a key for a map of types that is used
to delete duplicates based on the ODR, so one of them is deleted as a
duplicate, resulting in invalid DWARF.

The DW_TAG_variant_part isn't a standalone type, so it doesn't need
an identifier. Fix by omitting its identifier.

ODR uniquing is enabled here.

We were setting the same identifier for both the DW_TAG_structure_type
and the DW_TAG_variant_part. This becomes a problem when using thinlto
becauses it uses the identifier as a key for a map of types that is used
to delete duplicates based on the ODR, so one of them is deleted as a
duplicate, resulting in invalid DWARF.

The DW_TAG_variant_part isn't a standalone type, so it doesn't need
an identifier. Fix by omitting its identifier.
@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(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 Mar 23, 2019
@michaelwoerister
Copy link
Member

Thanks for the PR, @philipc! I'll try to review shortly.

@michaelwoerister
Copy link
Member

This seems to make the infrastructure around composite types more complicated. Wouldn't it be easier to keep the ODR identifier for the DW_TAG_variant_part and just make it distinct from its parent's identifier (e.g. by appending _variant_part to it)?

@philipc
Copy link
Contributor Author

philipc commented Mar 26, 2019

Omitting the identifier seemed more correct to me, but yes that'll be simpler. I'll update the PR later.

and bump llvm version in test
@philipc
Copy link
Contributor Author

philipc commented Mar 27, 2019

I've given the variant parts their own identifier.

@michaelwoerister
Copy link
Member

Thanks, @philipc! As far as I can tell these identifiers are solely used for LLVM uniquing and don't make it to actual debuginfo, so I don't think that giving an identifier to the variant part is especially wrong.

That being said, this code is very old and was initially written against LLVM 3.x. It could probably do with a more fundamental overhaul.

@bors r+

@bors
Copy link
Contributor

bors commented Mar 27, 2019

📌 Commit 3a5a8a5 has been approved by michaelwoerister

@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 Mar 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Mar 30, 2019
…oerister

Fix invalid DWARF for enums when using ThinLTO

We were setting the same identifier for both the DW_TAG_structure_type
and the DW_TAG_variant_part. This becomes a problem when using ThinLTO
becauses it uses the identifier as a key for a map of types that is used
to delete duplicates based on the ODR, so one of them is deleted as a
duplicate, resulting in invalid DWARF.

The DW_TAG_variant_part isn't a standalone type, so it doesn't need
an identifier. Fix by omitting its identifier.

ODR uniquing is [enabled here](https://github.com/rust-lang/rust/blob/f21dee2c6179276321a88a63300dce74ff707e92/src/rustllvm/PassWrapper.cpp#L1101).
bors added a commit that referenced this pull request Mar 30, 2019
Rollup of 5 pull requests

Successful merges:

 - #59343 (rustc(codegen): uncache `def_symbol_name` prefix from `symbol_name`.)
 - #59380 (Fix invalid DWARF for enums when using ThinLTO)
 - #59463 (skip dyn keyword lint under macros)
 - #59539 (Fix infinite recursion)
 - #59544 (manifest: only include miri on the nightly channel)

Failed merges:

r? @ghost
@bors bors merged commit 3a5a8a5 into rust-lang:master Mar 30, 2019
@philipc philipc deleted the thinlto-variant branch March 30, 2019 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants