llvm-project/llvm
Yonghong Song f419029fcd [BPF] Fix a bug in BTF_KIND_TYPE_TAG generation
Kumar Kartikeya Dwivedi reported a bug ([1]) where BTF_KIND_TYPE_TAG types
are not generated.

Currently, BPF backend only generates BTF types which are used by
the program, e.g., global variables, functions and some builtin functions.
For example, suppose we have
  struct task_struct {
    ...
    struct task_group               *sched_task_group;
    struct mm_struct                *mm;
    ...
    pid_t                           pid;
    pid_t                           tgid;
    ...
  }
If BPF program intends to access task_struct->pid and task_struct->tgid,
there really no need to generate BTF types for struct task_group
and mm_struct.

In BPF backend, during BTF generation, when generating BTF for struct
task_struct, if types for task_group and mm_struct have not been generated
yet, a Fixup structure will be created, which will be reexamined later
to instantiate into either a full type or a forward type.

In current implementation, if we have something like
  struct foo {
     struct bar  __tag1    *f;
  };
and when generating types for struct foo, struct bar type
has not been generated, the __tag1 will be lost during later
Fixup instantiation. This patch fixed this issue by properly
handling btf_type_tag's during Fixup instantiation stage.

  [1] https://lore.kernel.org/bpf/20220210232411.pmhzj7v5uptqby7r@apollo.legion/

Differential Revision: https://reviews.llvm.org/D119799
2022-02-14 19:43:57 -08:00
..
benchmarks
bindings Extend the `uwtable` attribute with unwind table kind 2022-02-14 14:35:02 +00:00
cmake [llvm] [cmake] Fix finding modern ounit2 2022-02-12 13:45:17 +01:00
docs [IR] Define "ptrauth" operand bundle. 2022-02-14 11:27:35 -08:00
examples Cleanup header dependencies in LLVMCore 2022-02-02 06:54:20 +01:00
include Reland "[memprof] Introduce a wrapper around MemInfoBlock." 2022-02-14 19:04:36 -08:00
lib [BPF] Fix a bug in BTF_KIND_TYPE_TAG generation 2022-02-14 19:43:57 -08:00
projects
resources
runtimes [llvm] add missing word in a comment 2022-02-10 20:57:13 -05:00
test [BPF] Fix a bug in BTF_KIND_TYPE_TAG generation 2022-02-14 19:43:57 -08:00
tools [dsymutil] Add the ability to run the DWARF verifier on the input 2022-02-14 16:14:07 -08:00
unittests Reland "[memprof] Introduce a wrapper around MemInfoBlock." 2022-02-14 19:04:36 -08:00
utils [gn build] Port 5d1c1a243c 2022-02-14 21:39:38 +00:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt Bump the trunk major version to 15 2022-02-01 23:54:52 -08:00
CODE_OWNERS.TXT [LoongArch 1/6] Add triples loongarch{32,64} for the upcoming LoongArch target 2022-02-10 10:23:34 +00:00
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.