[PATCH] D82976: [BPF] Fix a BTF gen bug related to a pointer struct member

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 09:10:32 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, BTF generation stops at pointer struct members
if the pointee type is a struct. This is to avoid bloating
generated BTF size. The following is the process to
correctly record types for these pointee struct types.

- During type traversal stage, when a struct member, which is a pointer to another struct, is encountered, the pointee struct type, keyed with its name, is remembered in a Fixup map.
- Later, when all type traversal is done, the Fixup map is scanned, based on struct name matching, to either resolve as pointing to a real already generated type or as a forward declaration.

Andrii discovered a bug if the struct member pointee struct
is anonymous. In this case, a struct with empty name is
recorded in Fixup map, and later it happens another anonymous
struct with empty name is defined in BTF. So wrong type
resolution happens.

To fix the problem, if the struct member pointee struct
is anonymous, pointee struct type will be generated in
stead of being put in Fixup map.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82976

Files:
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/test/CodeGen/BPF/BTF/struct-anon-2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82976.274839.patch
Type: text/x-patch
Size: 6848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200701/e660d44d/attachment.bin>


More information about the llvm-commits mailing list