[all-commits] [llvm/llvm-project] cf56b5: [BPF] Allow struct pointee member btf generation w...

yonghong-song via All-commits all-commits at lists.llvm.org
Wed May 28 14:36:31 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cf56b536bfed34f5fda18393b922eab955baca6c
      https://github.com/llvm/llvm-project/commit/cf56b536bfed34f5fda18393b922eab955baca6c
  Author: yonghong-song <yhs at fb.com>
  Date:   2025-05-28 (Wed, 28 May 2025)

  Changed paths:
    M llvm/lib/Target/BPF/BTFDebug.cpp
    A llvm/test/CodeGen/BPF/BTF/annot-dup-ptr-struct.ll
    M llvm/test/CodeGen/BPF/BTF/type-tag-fixup-resolved.ll

  Log Message:
  -----------
  [BPF] Allow struct pointee member btf generation with annotations (#141719)

Currently, to avoid generating too much BTF types, for a struct type
like
```
  struct foo {
    int val;
    struct bar *ptr;
  };
```
if the BTF generation reaches 'struct foo', it will not generate actual
type for 'struct bar' and instead a forward decl is generated. The
'struct bar' is actual generated in BTF unless it is reached through a
non-struct pointer member.

Such a limitation forces bpf developer to hack and workaround this
problem. See [1] and [2]. For example in [1], we have
```
    struct map_value {
	struct prog_test_ref_kfunc *not_kptr;
	struct prog_test_ref_kfunc __kptr *val;
	struct node_data __kptr *node;
    };
```
The BTF type for 'struct node_data' is not generated. Note that we have
a '__kptr' annotation. Similar problem for [2] with a '__uptr'
annotation. Note that the issue in [1] has been resolved later but the
hack in [2] is still needed.

This patch relaxed the struct type (with struct pointer member) BTF
generation if the struct pointer has a btf_type_tag annotation.

[1] https://lore.kernel.org/r/20230310230743.2320707-4-davemarchevsky@fb.com
[2] https://lore.kernel.org/r/20241023234759.860539-9-martin.lau@linux.dev



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list