[PATCH] D145891: [BPF] Generate BTF info using 'btf:type_tag' annotation
Eduard Zingerman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 12 18:47:33 PDT 2023
eddyz87 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
eddyz87 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a follow-up for BPF mailing list discussion at [1].
Previous commit in a series updated DWARF generation for the following
example:
int __attribute__((btf_type_tag("tag1"))) *g;
To generate DWARF that looks as follows:
0x0000001e: DW_TAG_variable
DW_AT_name ("g")
DW_AT_type (0x00000029 "int *")
0x00000029: DW_TAG_pointer_type
DW_AT_type (0x00000032 "int")
0x00000032: DW_TAG_base_type
DW_AT_name ("int")
0x00000036: DW_TAG_LLVM_annotation
DW_AT_name ("btf:type_tag")
DW_AT_const_value ("tag1")
The fresh part is attachment of `btf:type_tag` annotations to types
other than pointers. This commit changes BTF generation to rely on
`btf:type_tag` annotations to generate TYPE_TAG entries.
This necessitates the following changes:
- The logic for `BTFTypeTypeTag` chains creation is moved to `BTFDebug::addType()`;
- Special logic is added to avoid duplicate BTF entries for tagged and un-tagged type variants, e.g. in the following case:
#define __tag1 __attribute__((btf_type_tag("tag1"))) #define __tag2 __attribute__((btf_type_tag("tag2")))
struct foo {};
struct bar { struct foo __tag1 aa; struct foo __tag2 bb; struct foo cc; };
Debug information generated for this example contains three instances of `DICompositeType(name: "foo")` with different `annotations` fields, however single BTF definition for structure "foo" should be generated. Field `BTFDebug::DIDedupMap` and method `BTFDebug::lookupType()` are responsible for this logic;
- Care is taken to avoid references to type tags in relocation entries.
[1] https://lore.kernel.org/bpf/87r0w9jjoq.fsf@oracle.com/
Depends on D143967 <https://reviews.llvm.org/D143967>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145891
Files:
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/lib/Target/BPF/BTFDebug.h
llvm/test/CodeGen/BPF/BTF/type-tag-dedup-enum.ll
llvm/test/CodeGen/BPF/BTF/type-tag-dedup-struct.ll
llvm/test/CodeGen/BPF/BTF/type-tag-dedup-typedef.ll
llvm/test/CodeGen/BPF/BTF/type-tag-dedup-union.ll
llvm/test/CodeGen/BPF/BTF/type-tag-field-relo.ll
llvm/test/CodeGen/BPF/BTF/type-tag-fixup-fwd.ll
llvm/test/CodeGen/BPF/BTF/type-tag-fixup-resolved.ll
llvm/test/CodeGen/BPF/BTF/type-tag-skip-var.ll
llvm/test/CodeGen/BPF/BTF/type-tag-var.ll
llvm/test/CodeGen/BPF/BTF/type-tag-void.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145891.504494.patch
Type: text/x-patch
Size: 85654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230313/7074951c/attachment-0001.bin>
More information about the llvm-commits
mailing list