llvm-project/llvm
Yonghong Song 89648eb16d [BPF] fix a bug for BTF pointee type pruning
In BTF, pointee type pruning is used to reduce cluttering
too many unused types into prog BTF. For example,
   struct task_struct {
      ...
      struct mm_struct *mm;
      ...
   }
If bpf program does not access members of "struct mm_struct",
there is no need to bring types for "struct mm_struct" to BTF.

This patch fixed a bug where an incorrect pruning happened.
The test case like below:
    struct t;
    typedef struct t _t;
    struct s1 { _t *c; };
    int test1(struct s1 *arg) { ... }

    struct t { int a; int b; };
    struct s2 { _t c; }
    int test2(struct s2 *arg) { ... }

After processing test1(), among others, BPF backend generates BTF types for
    "struct s1", "_t" and a placeholder for "struct t".
Note that "struct t" is not really generated. If later a direct access
to "struct t" member happened, "struct t" BTF type will be generated
properly.

During processing test2(), when processing member type "_t c",
BPF backend sees type "_t" already generated, so returned.
This caused the problem that "struct t" BTF type is never generated and
eventually causing incorrect type definition for "struct s2".

To fix the issue, during DebugInfo type traversal, even if a
typedef/const/volatile/restrict derived type has been recorded in BTF,
if it is not a type pruning candidate, type traversal of its base type continues.

Differential Revision: https://reviews.llvm.org/D82041
2020-06-17 15:13:46 -07:00
..
benchmarks
bindings
cmake Revert "[llvm] Added support for stand-alone cmake object libraries." 2020-06-15 12:15:39 -07:00
docs [llvm-readobj] set --elf-cg-profile as alias of --cg-profile 2020-06-17 11:24:45 -07:00
examples
include [SVE] Fix invalid usages of getNumElements in ShuffleVectorInstruction 2020-06-17 13:45:34 -07:00
lib [BPF] fix a bug for BTF pointee type pruning 2020-06-17 15:13:46 -07:00
projects
resources
runtimes [CMake][runtimes] Skip adding 2nd set of the same variables for a generic target 2020-06-15 09:59:27 +02:00
test [BPF] fix a bug for BTF pointee type pruning 2020-06-17 15:13:46 -07:00
tools [llvm-readobj] set --elf-cg-profile as alias of --cg-profile 2020-06-17 11:24:45 -07:00
unittests [llvm] [CommandLine] Do not suggest really hidden opts in nearest lookup 2020-06-17 19:00:26 +02:00
utils [lit] Avoid re-iterating result codes in different places 2020-06-17 11:40:19 -07:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt Automatically configure MLIR when flang is enabled 2020-05-27 07:31:49 +00:00
CODE_OWNERS.TXT Make myself code owner of InferAddressSpaces 2020-06-08 21:26:01 -04:00
CREDITS.TXT
LICENSE.TXT
LLVMBuild.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.