|
Revision tags: llvmorg-20.1.0, llvmorg-20.1.0-rc3, llvmorg-20.1.0-rc2, llvmorg-20.1.0-rc1, llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6 |
|
| #
437f9600 |
| 18-Jun-2022 |
Kazu Hirata <[email protected]> |
[llvm] Call *set::insert without checking membership first (NFC)
|
| #
adf4142f |
| 11-Jun-2022 |
Fangrui Song <[email protected]> |
[MC] De-capitalize SwitchSection. NFC
Add SwitchSection to return switchSection. The API will be removed soon.
|
|
Revision tags: llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2 |
|
| #
dc1c43d7 |
| 20-Apr-2022 |
Yonghong Song <[email protected]> |
[BPF] Add BTF 64bit enum value support
Current BTF only supports 32-bit value. For example, enum T { VAL = 0xffffFFFF00000008 }; the generated BTF looks like .long 16
[BPF] Add BTF 64bit enum value support
Current BTF only supports 32-bit value. For example, enum T { VAL = 0xffffFFFF00000008 }; the generated BTF looks like .long 16 # BTF_KIND_ENUM(id = 4) .long 100663297 # 0x6000001 .long 8 .long 18 .long 8 The encoded value is 8 which equals to (uint32_t)0xffffFFFF00000008 and this is incorrect.
This patch introduced BTF_KIND_ENUM64 which permits to encode 64-bit value. The format for each enumerator looks like: .long name_offset .long (uint32_t)value # lower-32 bit value .long value >> 32 # high-32 bit value
We use two 32-bit values to represent a 64-bit value as current BTF type subsection has 4-byte alignment and gaps are not permitted in the subsection.
This patch also added support for kflag (the bit 31 of CommonType.Info) such that kflag = 1 implies the value is signed and kflag = 0 implies the value is unsigned. The kernel UAPI enumerator definition is struct btf_enum { __u32 name_off; __s32 val; }; so kflag = 0 with unsigned value provides backward compatability.
With this patch, for enum T { VAL = 0xffffFFFF00000008 }; the generated BTF looks like .long 16 # BTF_KIND_ENUM64(id = 4) .long 3187671053 # 0x13000001 .long 8 .long 18 .long 8 # 0x8 .long 4294967295 # 0xffffffff and the enumerator value and signedness are encoded correctly.
Differential Revision: https://reviews.llvm.org/D124641
show more ...
|
|
Revision tags: llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3 |
|
| #
ed98c1b3 |
| 09-Mar-2022 |
serge-sans-paille <[email protected]> |
Cleanup includes: DebugInfo & CodeGen
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121332
|
|
Revision tags: llvmorg-14.0.0-rc2 |
|
| #
3671bdbc |
| 16-Feb-2022 |
Yonghong Song <[email protected]> |
[BPF] Fix a BTF type pruning bug
In BPF backend, BTF type generation may skip some debuginfo types if they are the pointee type of a struct member. For example, struct task_struct { ... st
[BPF] Fix a BTF type pruning bug
In BPF backend, BTF type generation may skip some debuginfo types if they are the pointee type of a struct member. For example, struct task_struct { ... struct mm_struct *mm; ... }; BPF backend may generate a forward decl for 'struct mm_struct' instead of full type if there are no other usage of 'struct mm_struct'. The reason is to avoid bringing too much unneeded types in BTF.
Alexei found a pruning bug where we may miss some full type generation. The following is an illustrating example: struct t1 { ... } struct t2 { struct t1 *p; }; struct t2 g; void foo(struct t1 *arg) { ... } In the above case, we will have partial debuginfo chain like below: struct t2 -> member p \ -> ptr -> struct t1 / foo -> argument arg During traversing struct t2 -> member p -> ptr -> struct t1 The corresponding BTF types are generated except 'struct t1' which will be in FixUp stage. Later, when traversing foo -> argument arg -> ptr -> struct t1 The 'ptr' BTF type has been generated and currently implementation ignores 'pointer' type hence 'struct t1' is not generated.
This patch fixed the issue not just for the above case, but for general case with multiple derived types, e.g., struct t2 -> member p \ -> const -> ptr -> volatile -> struct t1 / foo -> argument arg
Differential Revision: https://reviews.llvm.org/D119986
show more ...
|
| #
f419029f |
| 13-Feb-2022 |
Yonghong Song <[email protected]> |
[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 a
[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/[email protected]/
Differential Revision: https://reviews.llvm.org/D119799
show more ...
|
|
Revision tags: llvmorg-14.0.0-rc1, llvmorg-15-init |
|
| #
fc72f3a1 |
| 27-Jan-2022 |
Nikita Popov <[email protected]> |
[BTFDebug] Avoid pointer element type access
Use the global value type instead.
|
| #
aa97bc11 |
| 21-Jan-2022 |
Nikita Popov <[email protected]> |
[NFC] Remove uses of PointerType::getElementType()
Instead use either Type::getPointerElementType() or Type::getNonOpaquePointerElementType().
This is part of D117885, in preparation for deprecatin
[NFC] Remove uses of PointerType::getElementType()
Instead use either Type::getPointerElementType() or Type::getNonOpaquePointerElementType().
This is part of D117885, in preparation for deprecating the API.
show more ...
|
|
Revision tags: llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1 |
|
| #
8d499bd5 |
| 08-Nov-2021 |
Yonghong Song <[email protected]> |
BPF: change btf_type_tag BTF output format
For the declaration like below: int __tag1 * __tag1 __tag2 *g Commit 41860e602aaa ("BPF: Support btf_type_tag attribute") implemented the following encod
BPF: change btf_type_tag BTF output format
For the declaration like below: int __tag1 * __tag1 __tag2 *g Commit 41860e602aaa ("BPF: Support btf_type_tag attribute") implemented the following encoding: VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int
Some further experiments with linux btf_type_tag support, esp. with generating attributes in vmlinux.h, and also some internal discussion showed the following format is more desirable: VAR(g) -> pointer -> __tag2 -> __tag1 -> pointer -> __tag1 -> int
The format makes it similar to other modifier like 'const', e.g., const int *g which has encoding VAR(g) -> PTR -> CONST -> int
Differential Revision: https://reviews.llvm.org/D113496
show more ...
|
| #
41860e60 |
| 18-Oct-2021 |
Yonghong Song <[email protected]> |
BPF: Support btf_type_tag attribute
A new kind BTF_KIND_TYPE_TAG is defined. The tags associated with a pointer type are emitted in their IR order as modifiers. For example, for the following declar
BPF: Support btf_type_tag attribute
A new kind BTF_KIND_TYPE_TAG is defined. The tags associated with a pointer type are emitted in their IR order as modifiers. For example, for the following declaration: int __tag1 * __tag1 __tag2 *g; The BTF type chain will look like VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int In the above "->" means BTF CommonType.Type which indicates the point-to type.
Differential Revision: https://reviews.llvm.org/D113222
show more ...
|
|
Revision tags: llvmorg-13.0.0, llvmorg-13.0.0-rc4 |
|
| #
0472e83f |
| 21-Sep-2021 |
Yonghong Song <[email protected]> |
BPF: emit BTF_KIND_DECL_TAG for typedef types
If a typedef type has __attribute__((btf_decl_tag("str"))) with bpf target, emit BTF_KIND_DECL_TAG for that type in the BTF.
Differential Revision: htt
BPF: emit BTF_KIND_DECL_TAG for typedef types
If a typedef type has __attribute__((btf_decl_tag("str"))) with bpf target, emit BTF_KIND_DECL_TAG for that type in the BTF.
Differential Revision: https://reviews.llvm.org/D112259
show more ...
|
| #
cd40b5a7 |
| 19-Oct-2021 |
Yonghong Song <[email protected]> |
BPF: set .BTF and .BTF.ext section alignment to 4
Currently, .BTF and .BTF.ext has default alignment of 1. For example, $ cat t.c int foo() { return 0; } $ clang -target bpf -O2 -c -g t.c
BPF: set .BTF and .BTF.ext section alignment to 4
Currently, .BTF and .BTF.ext has default alignment of 1. For example, $ cat t.c int foo() { return 0; } $ clang -target bpf -O2 -c -g t.c $ llvm-readelf -S t.o ... Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al ... [ 7] .BTF PROGBITS 0000000000000000 000167 00008b 00 0 0 1 [ 8] .BTF.ext PROGBITS 0000000000000000 0001f2 000050 00 0 0 1
But to have no misaligned data access, .BTF and .BTF.ext actually requires alignment of 4. Misalignment is not an issue for architecture like x64/arm64 as it can handle it well. But some architectures like mips may incur a trap if .BTF/.BTF.ext is not properly aligned.
This patch explicitly forced .BTF and .BTF.ext alignment to be 4. For the above example, we will have [ 7] .BTF PROGBITS 0000000000000000 000168 00008b 00 0 0 4 [ 8] .BTF.ext PROGBITS 0000000000000000 0001f4 000050 00 0 0 4
Differential Revision: https://reviews.llvm.org/D112106
show more ...
|
| #
f4a8526c |
| 18-Oct-2021 |
Yonghong Song <[email protected]> |
[NFC][BPF] fix comments and rename functions related to BTF_KIND_DECL_TAG
There are no functionality change. Fix some comments and rename processAnnotations() to processDeclAnnotations() to avoid co
[NFC][BPF] fix comments and rename functions related to BTF_KIND_DECL_TAG
There are no functionality change. Fix some comments and rename processAnnotations() to processDeclAnnotations() to avoid confusion when later BTF_KIND_TYPE_TAG is introduced (https://reviews.llvm.org/D111199).
show more ...
|
| #
1321e472 |
| 12-Oct-2021 |
Yonghong Song <[email protected]> |
BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG
Per discussion in https://reviews.llvm.org/D111199, the existing btf_tag attribute will be renamed to btf_decl_tag. This patch updated BTF backend to us
BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG
Per discussion in https://reviews.llvm.org/D111199, the existing btf_tag attribute will be renamed to btf_decl_tag. This patch updated BTF backend to use btf_decl_tag attribute name and also renamed BTF_KIND_TAG to BTF_KIND_DECL_TAG.
Differential Revision: https://reviews.llvm.org/D111592
show more ...
|
|
Revision tags: llvmorg-13.0.0-rc3 |
|
| #
e52617c3 |
| 10-Sep-2021 |
Yonghong Song <[email protected]> |
BPF: change BTF_KIND_TAG format
Previously we have the following binary representation: struct bpf_type { name, info, type } struct btf_tag { __u32 component_idx; } If the tag points to a st
BPF: change BTF_KIND_TAG format
Previously we have the following binary representation: struct bpf_type { name, info, type } struct btf_tag { __u32 component_idx; } If the tag points to a struct/union/var/func type, we will have kflag = 1, component_idx = 0 if the tag points to struct/union member or func argument, we will have kflag = 0, component_idx = 0, ..., vlen - 1
The above rather makes interface complex to have both kflag and component needed to determine its legality and index.
This patch simplifies the interface by removing kflag involvement. component_idx = (u32)-1 : tag pointing to a type component_idx = 0 ... vlen - 1 : tag pointing to a member or argument and kflag is always 0 and there is no need to check.
Differential Revision: https://reviews.llvm.org/D109560
show more ...
|
|
Revision tags: llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init |
|
| #
49489270 |
| 20-Jul-2021 |
Yonghong Song <[email protected]> |
[BPF] support btf_tag attribute in .BTF section
A new kind BTF_KIND_TAG is added to .BTF to encode btf_tag attributes. The format looks like CommonType.name : attribute string CommonType.type
[BPF] support btf_tag attribute in .BTF section
A new kind BTF_KIND_TAG is added to .BTF to encode btf_tag attributes. The format looks like CommonType.name : attribute string CommonType.type : attached to a struct/union/func/var. CommonType.info : encoding BTF_KIND_TAG kflag == 1 to indicate the attribute is for CommonType.type, or kflag == 0 for struct/union member or func argument. one uint32_t : to encode which member/argument starting from 0.
If one particular type or member/argument has more than one attribute, multiple BTF_KIND_TAG will be generated.
Differential Revision: https://reviews.llvm.org/D106622
show more ...
|
|
Revision tags: llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1 |
|
| #
bba7338b |
| 14-Apr-2021 |
Yonghong Song <[email protected]> |
BPF: generate BTF info for LD_imm64 loaded function pointer
For an example like below, extern int do_work(int); long bpf_helper(void *callback_fn); long prog() { return bpf_helpe
BPF: generate BTF info for LD_imm64 loaded function pointer
For an example like below, extern int do_work(int); long bpf_helper(void *callback_fn); long prog() { return bpf_helper(&do_work); }
The final generated codes look like: r1 = do_work ll call bpf_helper exit where we have debuginfo for do_work() extern function: !17 = !DISubprogram(name: "do_work", ...)
This patch implemented to add additional checking in processing LD_imm64 operands for possible function pointers so BTF for bpf function do_work() can be properly generated. The original llvm function name processReloc() is renamed to processGlobalValue() to better reflect what the function is doing.
Differential Revision: https://reviews.llvm.org/D100568
show more ...
|
| #
a285bdb5 |
| 13-Apr-2021 |
Yonghong Song <[email protected]> |
BPF: remove default .extern data section
Currently, for any extern variable, if it doesn't have section attribution, it will be put into a default ".extern" btf DataSec. The initial design is to put
BPF: remove default .extern data section
Currently, for any extern variable, if it doesn't have section attribution, it will be put into a default ".extern" btf DataSec. The initial design is to put every extern variable in a DataSec so libbpf can use it.
But later on, libbpf actually requires extern variables to put into special sections, e.g., ".kconfig", ".ksyms", etc. so they can be used properly based on section name.
Andrii mentioned since ".extern" variables are not actually used, it makes sense to remove it from the compiler so libbpf does not need to deal with it, esp. for static linking. The BTF for these extern variables is still generated.
With this patch, I tested kernel selftests/bpf and all tests passed. Indeed, removing ".extern" DataSec seems having no impact.
Differential Revision: https://reviews.llvm.org/D100392
show more ...
|
| #
968292cb |
| 13-Apr-2021 |
Yonghong Song <[email protected]> |
BPF: generate proper BTF for globals with WeakODRLinkage
For a global weak symbol defined as below: char g __attribute__((weak)) = 2; LLVM generates an allocated global with WeakAnyLinkage, for wh
BPF: generate proper BTF for globals with WeakODRLinkage
For a global weak symbol defined as below: char g __attribute__((weak)) = 2; LLVM generates an allocated global with WeakAnyLinkage, for which BPF backend generates proper BTF info.
For the above example, if a modifier "const" is added like const char g __attribute__((weak)) = 2; LLVM generates an allocated global with WeakODRLinkage, for which BPF backend didn't generate any BTF as it didn't handle WeakODRLinkage.
This patch addes support for WeakODRLinkage and proper BTF info can be generated for weak symbol defined with "const" modifier.
Differential Revision: https://reviews.llvm.org/D100362
show more ...
|
|
Revision tags: llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4 |
|
| #
886f9ff5 |
| 25-Mar-2021 |
Yonghong Song <[email protected]> |
BPF: add extern func to data sections if specified
This permits extern function (BTF_KIND_FUNC) be added to BTF_KIND_DATASEC if a section name is specified. For example,
-bash-4.4$ cat t.c void foo
BPF: add extern func to data sections if specified
This permits extern function (BTF_KIND_FUNC) be added to BTF_KIND_DATASEC if a section name is specified. For example,
-bash-4.4$ cat t.c void foo(int) __attribute__((section(".kernel.funcs"))); int test(void) { foo(5); return 0; }
The extern function foo (BTF_KIND_FUNC) will be put into BTF_KIND_DATASEC with name ".kernel.funcs".
This will help to differentiate two kinds of external functions, functions in kernel and functions defined in other bpf programs.
Differential Revision: https://reviews.llvm.org/D93563
show more ...
|
|
Revision tags: llvmorg-12.0.0-rc3 |
|
| #
a7137b23 |
| 05-Mar-2021 |
Ilya Leoshkevich <[email protected]> |
[BPF] Add support for floats and doubles
Some BPF programs compiled on s390 fail to load, because s390 arch-specific linux headers contain float and double types. At the moment there is no BTF_KIND
[BPF] Add support for floats and doubles
Some BPF programs compiled on s390 fail to load, because s390 arch-specific linux headers contain float and double types. At the moment there is no BTF_KIND for floats and doubles, so the release version of LLVM ends up emitting type id 0 for them, which the in-kernel verifier does not accept.
Introduce support for such types to libbpf by representing them using the new BTF_KIND_FLOAT.
Reviewed By: yonghong-song
Differential Revision: https://reviews.llvm.org/D83289
show more ...
|
|
Revision tags: llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2, llvmorg-11.0.1-rc1 |
|
| #
4369223e |
| 14-Nov-2020 |
Yonghong Song <[email protected]> |
BPF: make __builtin_btf_type_id() return 64bit int
Linux kernel recently added support for kernel modules https://lore.kernel.org/bpf/[email protected]/
In such cases, a
BPF: make __builtin_btf_type_id() return 64bit int
Linux kernel recently added support for kernel modules https://lore.kernel.org/bpf/[email protected]/
In such cases, a type id in the kernel needs to be presented as (btf id for modules, btf type id for this module). Change __builtin_btf_type_id() to return 64bit value so libbpf can do the above encoding.
Differential Revision: https://reviews.llvm.org/D91489
show more ...
|
| #
a0ad066c |
| 03-Nov-2020 |
Jameson Nash <[email protected]> |
make the AsmPrinterHandler array public
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of han
make the AsmPrinterHandler array public
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of handlers already existed, this just cleans up the code so that it can be exposed publically.
Replaces https://reviews.llvm.org/D74158
Differential Revision: https://reviews.llvm.org/D89613
show more ...
|
| #
4242df14 |
| 16-Oct-2020 |
Jameson Nash <[email protected]> |
Revert "make the AsmPrinterHandler array public"
I messed up one of the tests.
|
| #
ac2def2d |
| 15-Oct-2020 |
Jameson Nash <[email protected]> |
make the AsmPrinterHandler array public
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of han
make the AsmPrinterHandler array public
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of handlers already existed, this just cleans up the code so that it can be exposed publically.
Differential Revision: https://reviews.llvm.org/D74158
show more ...
|