llvm-project/llvm
Yonghong Song 6b01b46538 [BPF] preserve debuginfo types for builtin __builtin__btf_type_id()
The builtin function
  u32 btf_type_id = __builtin_btf_type_id(param, 0)
can help preserve type info for the following use case:
  extern void foo(..., void *data, int size);
  int test(...) {
    struct t { int a; int b; int c; } d;
    d.a = ...; d.b = ...; d.c = ...;
    foo(..., &d, sizeof(d));
  }

The function "foo" in the above only see raw data and does not
know what type of the data is. In certain cases, e.g., logging,
the additional type information will help pretty print.

This patch handles the builtin in BPF backend. It includes
an IR pass to translate the IR intrinsic to a load of
a global variable which carries the metadata, and an MI
pass to remove the intermediate load of the global variable.
Finally, in AsmPrinter pass, proper instruction are generated.

In the above example, the second argument for __builtin_btf_type_id()
is 0, which means a relocation for local adjustment,
i.e., w.r.t. bpf program BTF change,  will be generated.
The value 1 for the second argument means
a relocation for remote adjustment, e.g., against vmlinux.

Differential Revision: https://reviews.llvm.org/D74572
2020-05-15 08:00:44 -07:00
..
benchmarks
bindings Update go bindings for 2dea3f1298 2020-04-22 19:02:59 +02:00
cmake [cmake] fix typo. 2020-05-13 17:42:46 -07:00
docs [IR][BFloat] Add BFloat IR type 2020-05-15 14:43:43 +01:00
examples [examples] Skip building the Bye pass plugin on windows 2020-05-13 13:40:56 +03:00
include [IR][BFloat] Add BFloat IR type 2020-05-15 14:43:43 +01:00
lib [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
projects
resources
runtimes
test [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
tools Fix Linux build broken by f06e6564 2020-05-15 15:36:26 +01:00
unittests [DebugInfo] support for DW_AT_data_location in llvm 2020-05-15 11:33:17 +05:30
utils Add MSVC natvis visualisation of llvm::Type 2020-05-15 09:38:37 -04:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [AIX] Make sure we use export lists for plugins 2020-05-08 14:00:25 -04:00
CODE_OWNERS.TXT
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.