Page MenuHomePhabricator

[DebugInfo] Support typedef with btf_decl_tag attributes
AcceptedPublic

Authored by yonghong-song on Mon, Sep 20, 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

Unit TestsFailed

TimeTest
40 msx64 debian > Clang.CodeGen::attr-btf_tag-typedef.c
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/clang -cc1 -internal-isystem /var/lib/buildkite-agent/builds/llvm-project/build/lib/clang/14.0.0/include -nostdsysteminc -triple x86_64-unknown-linux-gnu -debug-info-kind=limited -S -emit-llvm -o - /var/lib/buildkite-agent/builds/llvm-project/clang/test/CodeGen/attr-btf_tag-typedef.c | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/clang/test/CodeGen/attr-btf_tag-typedef.c

Event Timeline

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

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
2

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 ↗(On Diff #373785)

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

2 ↗(On Diff #373785)

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

yonghong-song updated this revision to Diff 374073.EditedTue, Sep 21, 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.Wed, Sep 22, 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.Wed, Sep 22, 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)