[all-commits] [llvm/llvm-project] 072cde: [Clang][BPF] implement __builtin_btf_type_id() bui...
    yonghong-song via All-commits 
    all-commits at lists.llvm.org
       
    Fri May 15 09:46:48 PDT 2020
    
    
  
  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 072cde03aaa13a2c57acf62d79876bf79aa1919f
      https://github.com/llvm/llvm-project/commit/072cde03aaa13a2c57acf62d79876bf79aa1919f
  Author: Yonghong Song <yhs at fb.com>
  Date:   2020-05-15 (Fri, 15 May 2020)
  Changed paths:
    M clang/include/clang/Basic/BuiltinsBPF.def
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/CodeGen/builtin-bpf-btf-type-id.c
    A clang/test/Sema/builtin-bpf-btf-type-id.c
    M llvm/include/llvm/IR/IntrinsicsBPF.td
  Log Message:
  -----------
  [Clang][BPF] implement __builtin_btf_type_id() builtin function
Such a builtin function is mostly useful to preserve btf type id
for non-global data. For example,
   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 implemented a BPF specific builtin
  u32 btf_type_id = __builtin_btf_type_id(param, flag)
which will return a btf type id for the "param".
flag == 0 will indicate a BTF local relocation,
which means btf type_id only adjusted when bpf program BTF changes.
flag == 1 will indicate a BTF remote relocation,
which means btf type_id is adjusted against linux kernel or
future other entities.
Differential Revision: https://reviews.llvm.org/D74668
    
    
More information about the All-commits
mailing list