[PATCH] D83638: BPF: permit .maps section variables with typedef type

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 11 23:02:50 PDT 2020


yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Currently, llvm when see a global variable in .maps section,
it ensures its type must be a struct type. Then pointee
will be further evaluated for the structure members.
In normal cases, the pointee type will be skipped.

Although this is what current all bpf programs are doing,
but it is a little bit restrictive. For example, it is legitimate
for users to have:
typedef struct { int key_size; int value_size; } __map_t;
__map_t map __attribute__((section(".maps")));

This patch lifts this restriction and typedef of
a struct type is also allowed for .maps section variables.
To avoid create unnecessary fixup entries when traversal
started with typedef/struct type, the new implementation
first traverse all map struct members and then traverse
the typedef/struct type. This way, in internal BTFDebug
implementation, no fixup entries are generated.

Two new unit tests are added for typedef and const
struct in .maps section. Also tested with kernel bpf selftests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83638

Files:
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/test/CodeGen/BPF/BTF/map-def-2.ll
  llvm/test/CodeGen/BPF/BTF/map-def-3.ll
  llvm/test/CodeGen/BPF/BTF/map-def.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83638.277274.patch
Type: text/x-patch
Size: 15935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200712/ab309468/attachment.bin>


More information about the llvm-commits mailing list