This is an archive of the discontinued LLVM Phabricator instance.

[Dwarf] DW_TAG_unspecified_type is a type tag.
ClosedPublic

Authored by JDevlieghere on Aug 7 2019, 5:46 PM.

Details

Summary

This fixes an incorrect verifier error for a DW_AT_type pointing to DW_TAG_unspecified_type.

error: DIE has DW_AT_type with incompatible tag DW_TAG_unspecified_type

rdar://54059283

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Aug 7 2019, 5:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2019, 5:46 PM
JDevlieghere edited the summary of this revision. (Show Details)Aug 7 2019, 5:58 PM

This doesn't seem complete. And it's hard to tell, because the list is mostly but not entirely in numeric order.
Mostly it's missing the new v5 type tags (coarray, dynamic, atomic, immutable) which is probably my fault, but some older ones also appear to be missing (restrict, shared).

FYI. You can derive the complete list by scanning for DW_AT_type in DWARF 5 Appendix A, Table A.1.

FYI. You can derive the complete list by scanning for DW_AT_type in DWARF 5 Appendix A, Table A.1.

? not really. Any tag that is a type qualifier will have DW_AT_type, but also anything else that simply has a type (DW_TAG_constant, etc).

I do think that the regex DW_TAG_*_type will find all of them.

FYI. You can derive the complete list by scanning for DW_AT_type in DWARF 5 Appendix A, Table A.1.

? not really. Any tag that is a type qualifier will have DW_AT_type, but also anything else that simply has a type (DW_TAG_constant, etc).

I do think that the regex DW_TAG_*_type will find all of them.

I'm probably misunderstanding something here, but DW_TAG_constant *is* listed in Appendix A as allowing a DW_AT_type attribute, so are all the DW_TAG_*_type tags.

FYI. You can derive the complete list by scanning for DW_AT_type in DWARF 5 Appendix A, Table A.1.

? not really. Any tag that is a type qualifier will have DW_AT_type, but also anything else that simply has a type (DW_TAG_constant, etc).

I do think that the regex DW_TAG_*_type will find all of them.

I'm probably misunderstanding something here, but DW_TAG_constant *is* listed in Appendix A as allowing a DW_AT_type attribute, so are all the DW_TAG_*_type tags.

is-a versus has-a? We want the isType(Tag T) predicate to return true for the tags that DW_AT_type is allowed to *point to* (i.e. whether the tag is-a type), not those tags that permit DW_AT_type as an attribute (i.e., those that have-a type).

Got it! I misunderstood the purpose of this function.

Add missing type tags and sort the list alphabetically.

aprantl added inline comments.Aug 12 2019, 4:13 PM
llvm/include/llvm/BinaryFormat/Dwarf.h
118 ↗(On Diff #214731)

Looking at the LHS, I think that the list was *meant* to be sorted by encoding value (cf. Table 7.3) which could make it easier to check whether some new group of TAGs have been added. I'm fine either way... Alphabetical also has its advantages.

aprantl accepted this revision.Aug 12 2019, 4:14 PM
This revision is now accepted and ready to land.Aug 12 2019, 4:14 PM
aprantl added inline comments.Aug 12 2019, 4:15 PM
llvm/include/llvm/BinaryFormat/Dwarf.h
118 ↗(On Diff #214731)

The *nicest* way to implement this might be to add a new IS_TYPE field to the TAG macro in Dwarf.def and then generate this switch statement.

Make type part of the def file.

This revision was automatically updated to reflect the committed changes.

Neat. Thanks!