This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Support typedef with btf_decl_tag attributes
ClosedPublic

Authored by yonghong-song on Sep 20 2021, 11:31 PM.

Details

Summary

Clang patch ([1]) added support for btf_decl_tag attributes with typedef
types. This patch added llvm support including dwarf generation.
For example, for typedef

typedef unsigned * __u __attribute__((btf_decl_tag("tag1")));
__u u;

the following shows llvm-dwarfdump result:

 0x00000033:   DW_TAG_typedef
                 DW_AT_type      (0x00000048 "unsigned int *") 
                 DW_AT_name      ("__u")
                 DW_AT_decl_file ("/home/yhs/work/tests/llvm/btf_tag/t.c")
                 DW_AT_decl_line (1) 

 0x0000003e:     DW_TAG_LLVM_annotation
                   DW_AT_name    ("btf_decl_tag")
                   DW_AT_const_value     ("tag1")

 0x00000047:     NULL

[1] https://reviews.llvm.org/D110127

Diff Detail

Event Timeline

yonghong-song created this revision.Sep 20 2021, 11:31 PM
yonghong-song requested review of this revision.Sep 20 2021, 11:31 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 20 2021, 11:31 PM
probinson added inline comments.
clang/test/CodeGen/attr-btf_tag-typedef.c
2

Outside of clang/test/Driver, tests should use %clang_cc1 to run the frontend directly instead of via the driver. This will require some minor adjustment to the command-line options, for example -target becomes -triple and -g generally becomes -debug-info-kind=limited.

Also, the x86_64 triple will do the wrong thing on a Windows host. You probably want %itanium_abi_triple there.

llvm/test/Bitcode/attr-btf_tag-typedef.ll
1

Does this really require a specific target? I don't see anything target-dependent in the test.

llvm/test/DebugInfo/attr-btf_tag-typedef.ll
1

Move this test to llvm/test/DebugInfo/X86 and remove the REQUIRES line.

2

Use %itanium_abi_triple so the test will work correctly on Windows.

yonghong-song updated this revision to Diff 374073.EditedSep 21 2021, 5:18 PM
  • updated tests based on @probinson suggestions.
  • The only thing left is for llvm/test/DebugInfo/X86/attr-btf_tag-typedef.ll for which I didn't use %itanium_abi_triple as it seems only available for %clang ... and not available for llc.
[$ ~/work/llvm-project/llvm/test] egrep -r itanium_abi_triple
[$ ~/work/llvm-project/llvm/test]
probinson accepted this revision.Sep 22 2021, 7:45 AM
  • The only thing left is for llvm/test/DebugInfo/X86/attr-btf_tag-typedef.ll for which I didn't use %itanium_abi_triple as it seems only available for %clang ... and not available for llc.

Oh right, that's just a clang thing. An explicit triple is fine.
LGTM

This revision is now accepted and ready to land.Sep 22 2021, 7:45 AM
yonghong-song retitled this revision from [DebugInfo] Support typedef with btf_tag attributes to [DebugInfo] Support typedef with btf_decl_tag attributes.
yonghong-song edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Oct 21 2021, 8:50 AM
This revision was automatically updated to reflect the committed changes.