[all-commits] [llvm/llvm-project] 152a9f: BPF: permit .maps section variables with typedef type

yonghong-song via All-commits all-commits at lists.llvm.org
Sun Jul 12 09:47:07 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 152a9fef1b3b44f2c224cb8096b3d649279f2578
      https://github.com/llvm/llvm-project/commit/152a9fef1b3b44f2c224cb8096b3d649279f2578
  Author: Yonghong Song <yhs at fb.com>
  Date:   2020-07-12 (Sun, 12 Jul 2020)

  Changed paths:
    M llvm/lib/Target/BPF/BTFDebug.cpp
    A llvm/test/CodeGen/BPF/BTF/map-def-2.ll
    A llvm/test/CodeGen/BPF/BTF/map-def-3.ll
    M llvm/test/CodeGen/BPF/BTF/map-def.ll

  Log Message:
  -----------
  BPF: permit .maps section variables with typedef type

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.

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




More information about the All-commits mailing list