-
- Downloads
[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
Showing
- clang/lib/CodeGen/CGDebugInfo.cpp 150 additions, 35 deletionsclang/lib/CodeGen/CGDebugInfo.cpp
- clang/lib/CodeGen/CGDebugInfo.h 14 additions, 7 deletionsclang/lib/CodeGen/CGDebugInfo.h
- clang/test/CodeGen/attr-btf_type_tag-func.c 20 additions, 0 deletionsclang/test/CodeGen/attr-btf_type_tag-func.c
- clang/test/CodeGen/attr-btf_type_tag-typedef-field.c 35 additions, 0 deletionsclang/test/CodeGen/attr-btf_type_tag-typedef-field.c
- clang/test/CodeGen/attr-btf_type_tag-var.c 31 additions, 0 deletionsclang/test/CodeGen/attr-btf_type_tag-var.c
- llvm/include/llvm/IR/DIBuilder.h 6 additions, 5 deletionsllvm/include/llvm/IR/DIBuilder.h
- llvm/lib/IR/DIBuilder.cpp 7 additions, 8 deletionsllvm/lib/IR/DIBuilder.cpp
- llvm/test/Bitcode/attr-btf_type_tag.ll 36 additions, 0 deletionsllvm/test/Bitcode/attr-btf_type_tag.ll
- llvm/test/DebugInfo/attr-btf_type_tag.ll 62 additions, 0 deletionsllvm/test/DebugInfo/attr-btf_type_tag.ll
Loading