[all-commits] [llvm/llvm-project] eb0fa8: [Clang][Attr] Support btf_type_tag attribute

yonghong-song via All-commits all-commits at lists.llvm.org
Thu Nov 4 14:03:21 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb0fa8bfa356d49198f98b878b004bce59232bb0
      https://github.com/llvm/llvm-project/commit/eb0fa8bfa356d49198f98b878b004bce59232bb0
  Author: Yonghong Song <yhs at fb.com>
  Date:   2021-11-04 (Thu, 04 Nov 2021)

  Changed paths:
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Sema/SemaType.cpp
    A clang/test/Sema/attr-btf_type_tag.c

  Log Message:
  -----------
  [Clang][Attr] Support btf_type_tag attribute

This patch introduced btf_type_tag attribute. The attribute
is a type attribute and intends to address the below
linux use cases.
    typedef int __user *__intp;
    int foo(int __user *arg, ...)
    static int do_execve(struct filename *filename,
        const char __user *const __user *__argv,
        const char __user *const __user *__envp)

Here __user in the kernel defined as
    __attribute__((noderef, address_space(__user)))
for sparse ([1]) type checking mode.

For normal clang compilation, we intend to replace it with
    __attribute__((btf_type_tag("user")))
and record such informaiton in dwarf and BTF so such
information later can be used in kernel for bpf verification
or for other tracing functionalities.

  [1] https://www.kernel.org/doc/html/v4.11/dev-tools/sparse.html

Differential Revision: https://reviews.llvm.org/D111199




More information about the All-commits mailing list