Page MenuHomePhabricator

[DWARF] Support new TAG DW_TAG_LLVM_annotation
ClosedPublic

Authored by yonghong-song on Jul 22 2021, 5:35 PM.

Details

Summary

A new LLVM specific TAG DW_TAG_LLVM_annotation is added.
The name is suggested by Paul Robinson ([1]).
Currently, this tag is used to output attribute((btf_tag("string")))
annotations in dwarf. The following is an example for a global
variable with two btf_tag attributes:

0x0000002a:   DW_TAG_variable
                DW_AT_name      ("g1")
                DW_AT_type      (0x00000052 "int")
                DW_AT_external  (true)
                DW_AT_decl_file ("/tmp/home/yhs/work/tests/llvm/btf_tag/t.c")
                DW_AT_decl_line (8) 
                DW_AT_location  (DW_OP_addr 0x0)

0x0000003f:     DW_TAG_LLVM_annotation
                  DW_AT_name    ("btf_tag")
                  DW_AT_const_value     ("tag1")

0x00000048:     DW_TAG_LLVM_annotation
                  DW_AT_name    ("btf_tag")
                  DW_AT_const_value     ("tag2")

0x00000051:     NULL

In the future, DW_TAG_LLVM_annotation may encode other type
of non-string const value.

[1] https://lists.llvm.org/pipermail/llvm-dev/2021-June/151250.html

Diff Detail

Event Timeline

yonghong-song created this revision.Jul 22 2021, 5:35 PM
yonghong-song requested review of this revision.Jul 22 2021, 5:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 5:35 PM
anakryiko added inline comments.Jul 27 2021, 3:04 PM
llvm/test/DebugInfo/attr-btf_tag.ll
15

looking at CHECK tests below, seems like tag1 and tag2 are associated with the arg parameter, right? A bit surprised with syntax, I was expecting something like struct t1 *arg __tag1 __tag2, would such variant also work?

yonghong-song added inline comments.Jul 27 2021, 5:00 PM
llvm/test/DebugInfo/attr-btf_tag.ll
15

struct t1 *arg __tag1 __tag2 will have the same effect as struct t1 __tag1 __tag2 *arg. But I will change example to have the syntax as you suggested.

yonghong-song edited the summary of this revision. (Show Details)
  • rebase based on latest llvm-project and update commit message

@dblaikie @probinson Could you help take a look at the patch? Currently I chose the new tag definition as HANDLE_DW_TAG(0x6000, LLVM_annotation, 0, LLVM, DW_KIND_NONE) which might not be the best choice. Please let me know if you have other suggestions.

dblaikie accepted this revision.Mon, Aug 30, 10:20 PM

Looks generally OK to me. (not 100% sure that DW_TAG extension space is unused, but I think we've generally got most of the extensions in llvm-dwarfdump, so it probably is unused - and worst-case we can change it if needed)

This revision is now accepted and ready to land.Mon, Aug 30, 10:20 PM

Looks generally OK to me. (not 100% sure that DW_TAG extension space is unused, but I think we've generally got most of the extensions in llvm-dwarfdump, so it probably is unused - and worst-case we can change it if needed)

@aprantl updated Dwarf.def with everything that David Anderson (libdwarf) was aware of, early this year. If we're adding a new vendor TAG that will actually reach object files (as opposed to internal-only things like DW_OP_LLVM_convert) then we should communicate that back to David.

This revision was automatically updated to reflect the committed changes.
acme added a subscriber: acme.Wed, Sep 8, 7:08 AM