[all-commits] [llvm/llvm-project] 737e42: [Attr] support btf_type_tag attribute

yonghong-song via All-commits all-commits at lists.llvm.org
Thu Nov 4 14:29:21 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 737e4216c537c33aab8ec51880f06b8a54325b94
      https://github.com/llvm/llvm-project/commit/737e4216c537c33aab8ec51880f06b8a54325b94
  Author: Yonghong Song <yhs at fb.com>
  Date:   2021-11-04 (Thu, 04 Nov 2021)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/lib/CodeGen/CGDebugInfo.h
    A clang/test/CodeGen/attr-btf_type_tag-func.c
    A clang/test/CodeGen/attr-btf_type_tag-typedef-field.c
    A clang/test/CodeGen/attr-btf_type_tag-var.c
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/lib/IR/DIBuilder.cpp
    A llvm/test/Bitcode/attr-btf_type_tag.ll
    A llvm/test/DebugInfo/attr-btf_type_tag.ll

  Log Message:
  -----------
  [Attr] support btf_type_tag attribute

This patch added clang codegen and llvm support
for btf_type_tag support. Currently, btf_type_tag
attribute info is preserved in DebugInfo IR only for
pointer types associated with typedef, global variable
and function declaration. Eventually, such information
is emitted to dwarf.

The following is an example:
  $ cat test.c
  #define __tag __attribute__((btf_type_tag("tag")))
  int __tag *g;
  $ clang -O2 -g -c test.c
  $ llvm-dwarfdump --debug-info test.o
  ...
  0x0000001e:   DW_TAG_variable
                  DW_AT_name      ("g")
                  DW_AT_type      (0x00000033 "int *")
                  DW_AT_external  (true)
                  DW_AT_decl_file ("/home/yhs/test.c")
                  DW_AT_decl_line (2)
                  DW_AT_location  (DW_OP_addr 0x0)

  0x00000033:   DW_TAG_pointer_type
                  DW_AT_type      (0x00000042 "int")

  0x00000038:     DW_TAG_LLVM_annotation
                    DW_AT_name    ("btf_type_tag")
                    DW_AT_const_value     ("tag")

  0x00000041:     NULL

  0x00000042:   DW_TAG_base_type
                  DW_AT_name      ("int")
                  DW_AT_encoding  (DW_ATE_signed)
                  DW_AT_byte_size (0x04)

  0x00000049:   NULL

Basically, a DW_TAG_LLVM_annotation tag will be inserted
under DW_TAG_pointer_type tag if that pointer has a btf_type_tag
associated with it.

Differential Revision: https://reviews.llvm.org/D111199




More information about the All-commits mailing list