Re: [PATCH] btf: improve -dA comments for testsuite

2023-05-30 Thread David Faust via Gcc-patches
On 5/30/23 00:30, Indu Bhagat wrote: > On 5/25/23 9:37 AM, David Faust via Gcc-patches wrote: >> Many BTF type kinds refer to other types via index to the final types >> list. However, the order of the final types list is not guaranteed to >> remain the same for the same s

[PATCH 1/2] btf: be clear when record size/type is not used

2023-05-30 Thread David Faust via Gcc-patches
[Changes from v1: split this change into own commit.] All BTF type records have a 4-byte field used to encode a size or link to another type, depending on the type kind. But BTF_KIND_ARRAY and BTF_KIND_FWD do not use this field at all, and should write zero. GCC already correctly writes zero in t

[PATCH 2/2] btf: improve -dA comments for testsuite

2023-05-30 Thread David Faust via Gcc-patches
[Changes from v1: - Fix typos. - Split unrelated change into separate commit. - Improve asm comment for enum constants, update btf-enum-1 test. - Improve asm comment for DATASEC records, update btf-datasec-2 test.] Many BTF type kinds refer to other types via index to the final types list. How

[PATCH][committed] btf: fix bootstrap -Wformat errors [PR110073]

2023-06-02 Thread David Faust via Gcc-patches
Commit 7aae58b04b9 "btf: improve -dA comments for testsuite" broke bootstrap on a number of architectures because it introduced some new -Wformat errors. Fix those errors by properly using PRIu64 and a small refactor to the offending code. Based on the suggested patch from Rainer Orth. Committed

[PATCH 3/9] dwarf: create annotation DIEs for decl tags

2023-07-11 Thread David Faust via Gcc-patches
The "btf_decl_tag" attribute is handled by constructing a DW_TAG_GNU_annotation DIE for each occurrence to record the argument string in debug information. The DIEs are children of the declarations they annotate, with the following format: DW_TAG_GNU_annotation DW_AT_name "btf_decl_tag"

[PATCH 4/9] dwarf: expose get_die_parent

2023-07-11 Thread David Faust via Gcc-patches
Expose get_die_parent () so it can be used outside of dwarf2out.cc gcc/ * dwarf2out.cc (get_die_parent): Make non-static. * dwarf2out.h (get_die_parent): Add extern declaration here. --- gcc/dwarf2out.cc | 2 +- gcc/dwarf2out.h | 1 + 2 files changed, 2 insertions(+), 1 deletion

[PATCH 9/9] doc: document btf_decl_tag attribute

2023-07-11 Thread David Faust via Gcc-patches
Add documentation for the btf_decl_tag attribute. gcc/ * doc/extend.texi (Common Function Attributes): Document btf_decl_tag. (Common Variable Attributes): Likewise. --- gcc/doc/extend.texi | 47 + 1 file changed, 47 insertions(+) diff

[PATCH 6/9] dwarf2ctf: convert annotation DIEs to CTF types

2023-07-11 Thread David Faust via Gcc-patches
This patch makes the DWARF-to-CTF conversion process aware of the new DW_TAG_GNU_annotation DIEs. The DIEs are converted to CTF_K_DECL_TAG types and added to the compilation unit CTF container to be translated to BTF and output. gcc/ * dwarf2ctf.cc (handle_btf_tags): New function.

[PATCH 8/9] testsuite: add tests for BTF decl tags

2023-07-11 Thread David Faust via Gcc-patches
This patch adds tests for the btf_decl_tag attribute, in both DWARF and BTF. gcc/testsuite/ * gcc.dg/debug/btf/btf-decltag-func.c: New test. * gcc.dg/debug/btf/btf-decltag-sou.c: New test. * gcc.dg/debug/btf/btf-decltag-var.c: New test. * gcc.dg/debug/dwarf2/annota

[PATCH 1/9] c-family: add btf_decl_tag attribute

2023-07-11 Thread David Faust via Gcc-patches
Add the "btf_decl_tag" attribute to the attribute table, along with a simple handler for it. gcc/c-family/ * c-attribs.cc (c_common_attribute_table): Add btf_decl_tag. (handle_btf_decl_tag_attribute): Handle new attribute. --- gcc/c-family/c-attribs.cc | 23 ++

[PATCH 7/9] btf: create and output BTF_KIND_DECL_TAG types

2023-07-11 Thread David Faust via Gcc-patches
This patch updates btfout.cc to be aware of BTF_KIND_DECL_TAG types and output them appropriately. gcc/ * btfout.cc (funcs_map): New hash map. (btf_emit_preprocess): ... Initialize it here... (btf_collect_datasec): ... Populate it here... (btf_finalize): ... And fr

Re: [PATCH 0/9] Add btf_decl_tag C attribute

2023-07-12 Thread David Faust via Gcc-patches
mponent in the kernel (pahole).] >>> >>> Hi Richard. >>> >>>> On Tue, Jul 11, 2023 at 11:58 PM David Faust via Gcc-patches >>>> wrote: >>>>> >>>>> Hello, >>>>> >>>>> This series adds suppor

Re: [PATCH] bpf: fixed template for neg (added second operand)

2023-07-21 Thread David Faust via Gcc-patches
Hi Cupertino, On 7/21/23 09:43, Cupertino Miranda wrote: > gcc/ChangeLog: > > * config/bpf/bpf.md: fixed template for neg instruction. > --- > gcc/config/bpf/bpf.md | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md > ind

Re: [PATCH 0/9] Add btf_decl_tag C attribute

2023-07-24 Thread David Faust via Gcc-patches
Gentle ping. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624156.html On 7/11/23 14:57, David Faust via Gcc-patches wrote: > Hello, > > This series adds support for a new attribute, "btf_decl_tag" in GCC. > The same attribute is already supported in clang,

[COMMITTED] bpf: add pseudo-c asm dialect for "nop"

2023-07-24 Thread David Faust via Gcc-patches
The define_insn "nop" was missing a template for the pseudo-c dialect, so the normal syntax was unconditionally emitted. Tested on bpf-unknown-none, committed as obvious. gcc/ * config/bpf/bpf.md (nop): Add pseudo-c asm dialect template. --- gcc/config/bpf/bpf.md | 2 +- 1 file changed,

[PATCH 1/2] bpf: don't print () in bpf_print_operand_address

2023-07-25 Thread David Faust via Gcc-patches
Unfortunately, the pseudo-C dialect syntax used for some of the v3 atomic instructions clashes with unconditionally printing the surrounding parentheses in bpf_print_operand_address. Instead, place the parentheses in the output templates where needed. Tested in bpf-unknown-none. OK? gcc/

[PATCH 2/2] bpf: add v3 atomic instructions

2023-07-25 Thread David Faust via Gcc-patches
This patch adds support for the general atomic operations introduced in eBPF v3. In addition to the existing atomic add instruction, this adds: - Atomic and, or, xor - Fetching versions of these operations (including add) - Atomic exchange - Atomic compare-and-exchange To control emission of t

Re: [PATCH 2/2] bpf: add v3 atomic instructions

2023-07-25 Thread David Faust via Gcc-patches
On 7/25/23 15:18, Jose E. Marchesi wrote: > > Hi David. > >> +<<< HEAD > > There is a merge problem there. Ugh, I swear I've fixed this twice now. Yet it keeps cropping up. Sorry. v2 shortly. > >> @opindex mbswap >> @item -mbswap >> Enable byte swap instructions. Enabled for CPU v4

Re: [PATCH 1/2] bpf: don't print () in bpf_print_operand_address

2023-07-25 Thread David Faust via Gcc-patches
On 7/25/23 15:14, Jose E. Marchesi wrote: > > Hi David. > >> Unfortunately, the pseudo-C dialect syntax used for some of the v3 >> atomic instructions clashes with unconditionally printing the >> surrounding parentheses in bpf_print_operand_address. >> >> Instead, place the parentheses in the

[PATCH v2 2/2] bpf: add v3 atomic instructions

2023-07-25 Thread David Faust via Gcc-patches
[Changes from v1: fix merge issue in invoke.texi] This patch adds support for the general atomic operations introduced in eBPF v3. In addition to the existing atomic add instruction, this adds: - Atomic and, or, xor - Fetching versions of these operations (including add) - Atomic exchange - At

[COMMITTED v2 1/2] bpf: don't print () in bpf_print_operand_address

2023-07-25 Thread David Faust via Gcc-patches
[Changes from v1: save calls to fprintf] Unfortunately, the pseudo-C dialect syntax used for some of the v3 atomic instructions clashes with unconditionally printing the surrounding parentheses in bpf_print_operand_address. Instead, place the parentheses in the output templates where needed. gcc

[PATCH] bpf: correct pseudo-C template for add3 and sub3

2023-07-27 Thread David Faust via Gcc-patches
The pseudo-C output templates for these instructions were incorrectly using operand 1 rather than operand 2 on the RHS, which led to some very incorrect assembly generation with -masm=pseudoc. Tested on bpf-unknown-none. OK? gcc/ * config/bpf/bpf.md (add3): Use %w2 instead of %w1

[PATCH] bpf: minor doc cleanup for command-line options

2023-07-27 Thread David Faust via Gcc-patches
This patch makes some minor cleanups to eBPF options documented in invoke.texi: - Delete some vestigal docs for removed -mkernel option - Add -mbswap and -msdiv to the option summary - Note the negative versions of several options - Note that -mcpu=v4 also enables -msdiv. gcc/ * doc/i

[PATCH] bpf: ISA V4 sign-extending move and load insns [PR110782, PR110784]

2023-07-27 Thread David Faust via Gcc-patches
BPF ISA V4 introduces sign-extending move and load operations. This patch makes the BPF backend generate those instructions, when enabled and useful. A new option, -m[no-]smov gates generation of these instructions, and is enabled by default for -mcpu=v4 and above. Tests for the new instructions

Re: [PATCH] bpf: ISA V4 sign-extending move and load insns [PR110782,PR110784]

2023-07-27 Thread David Faust via Gcc-patches
On 7/27/23 15:27, Jose E. Marchesi wrote: > > Hi David. > Thanks for the patch. > >> BPF ISA V4 introduces sign-extending move and load operations. This >> patch makes the BPF backend generate those instructions, when enabled >> and useful. >> >> A new option, -m[no-]smov gates generation of

[committed] MAINTAINERS: Add myself as CTF and BTF reviewer

2022-07-27 Thread David Faust via Gcc-patches
ChangeLog: * MAINTAINERS: Add myself as reviewer for CTF and BTF. --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7408396471f..1a37f4419b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -267,6 +267,7 @@ arc port

Re: [PATCH V2] btf: emit linkage information in BTF_KIND_FUNC entries

2022-07-27 Thread David Faust via Gcc-patches
On 7/12/22 08:13, Jose E. Marchesi via Gcc-patches wrote: > > The kernel bpftool expects BTF_KIND_FUNC entries in BTF to include an > annotation reflecting the linkage of functions (static, global). For > whatever reason they abuse the `vlen' field of the BTF_KIND_FUNC entry > instead of addin

Re: [PATCH] btf: do not use the CHAR `encoding' bit for BTF

2022-08-01 Thread David Faust via Gcc-patches
On 7/26/22 14:58, Indu Bhagat wrote: > On 7/22/22 4:23 AM, Jose E. Marchesi via Gcc-patches wrote: >> >> Contrary to CTF and our previous expectations, as per [1], turns out >> that in BTF: >> >> 1) The `encoding' field in integer types shall not be treated as a >> bitmap, but as an enumerat

Re: [PATCH] btf: do not use the CHAR `encoding' bit for BTF

2022-08-02 Thread David Faust via Gcc-patches
On 8/2/22 08:42, Jose E. Marchesi wrote: > >> On 7/26/22 14:58, Indu Bhagat wrote: >>> On 7/22/22 4:23 AM, Jose E. Marchesi via Gcc-patches wrote: Contrary to CTF and our previous expectations, as per [1], turns out that in BTF: 1) The `encoding' field in integer types

[COMMITTED] MAINTAINERS: Add myself as a BPF port reviewer

2023-08-07 Thread David Faust via Gcc-patches
ChangeLog: * MAINTAINERS: Add the BPF port to my reviewer listing. --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6cac5ac6671..1e54844c905 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -273,7 +273,7 @@ arc port

[PING 2][PATCH 0/9] Add btf_decl_tag C attribute

2023-08-09 Thread David Faust via Gcc-patches
Ping for this series. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624156.html Thanks On 7/11/23 14:57, David Faust via Gcc-patches wrote: > Hello, > > This series adds support for a new attribute, "btf_decl_tag" in GCC. > The same attribute is already supported in

[PATCH] bpf: fix pseudoc w regs for small modes [PR111029]

2023-08-15 Thread David Faust via Gcc-patches
In the BPF pseudo-c assembly dialect, registers treated as 32-bits rather than the full 64 in various instructions ought to be printed as "wN" rather than "rN". But bpf_print_register () was only doing this for specifically SImode registers, meaning smaller modes were printed incorrectly. This ca

[PATCH] bpf: remove useless define_insn for extendsisi2

2023-08-15 Thread David Faust via Gcc-patches
This define_insn is never used, since a sign-extend to the same mode is just a move, so delete it. Tested on x86_64-linux-gnu host for bpf-unknown-none target. gcc/ * config/bpf/bpf.md (extendsisi2): Delete useless define_insn. --- gcc/config/bpf/bpf.md | 7 --- 1 file changed, 7 de

[PATCH] bpf: neg instruction does not accept an immediate

2023-08-21 Thread David Faust via Gcc-patches
The BPF virtual machine does not support neg nor neg32 instructions with an immediate. The erroneous instructions were removed from binutils: https://sourceware.org/pipermail/binutils/2023-August/129135.html Change the define_insn so that an immediate cannot be accepted. >From testing, a neg-imm

[PATCH 0/9] Add btf_decl_tag C attribute

2023-07-11 Thread David Faust via Gcc-patches
Hello, This series adds support for a new attribute, "btf_decl_tag" in GCC. The same attribute is already supported in clang, and is used by various components of the BPF ecosystem. The purpose of the attribute is to allow to associate (to "tag") declarations with arbitrary string annotations, wh

[PATCH 2/9] include: add BTF decl tag defines

2023-07-11 Thread David Faust via Gcc-patches
Add definitions for btf_decl_tag and the DW_TAG_GNU_annotation DWARF extension. include/ * btf.h (struct btf_type): Update comment. (BTF_KIND_DECL_TAG): New define. (struct btf_decl_tag): New. * dwarf2.def (DW_TAG_GNU_annotation): New DW_TAG extension. --- include

[PATCH 5/9] ctf: add support to pass through BTF tags

2023-07-11 Thread David Faust via Gcc-patches
BTF generation currently relies on the internal CTF representation to convert debug info from DWARF dies. This patch adds a new internal header, "ctf-int.h", which defines CTF kinds to be used internally to represent BTF tags which must pass through the CTF container. It also adds a new type for re

[PATCH] bpf: fix memory constraint of ldx/stx instructions [PR108790]

2023-02-14 Thread David Faust via Gcc-patches
In some cases where the target memory address for an ldx or stx instruction could be reduced to a constant, GCC could emit a malformed instruction like: ldxdw %r0,0 Rather than the expected form: ldxdw %rX, [%rY + OFFSET] This is due to the constraint allowing a const_int operand, which

[PATCH] btf: improve -dA comments for testsuite

2023-05-25 Thread David Faust via Gcc-patches
Many BTF type kinds refer to other types via index to the final types list. However, the order of the final types list is not guaranteed to remain the same for the same source program between different runs of the compiler, making it difficult to test inter-type references. This patch updates the

[PATCH 1/7] dwarf: externalize lookup_type_die

2021-08-04 Thread David Faust via Gcc-patches
Expose the function lookup_type_die in dwarf2out, so that it can be used by CTF/BTF when adding BPF CO-RE information. The function is now non-static, and an extern prototype is added in dwarf2out.h. gcc/ChangeLog: * dwarf2out.c (lookup_type_die): Function is no longer static. * d

[PATCH 3/7] ctfc: add function to lookup CTF ID of a TREE type

2021-08-04 Thread David Faust via Gcc-patches
Add a new function, ctf_lookup_tree_type, to return the CTF type ID associated with a type via its is TREE node. The function is exposed via a prototype in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_lookup_tree_type): New function. * ctfc.h: Likewise. --- gcc/ctfc.c | 16 ++

[PATCH 4/7] btf: expose get_btf_id

2021-08-04 Thread David Faust via Gcc-patches
Expose the function get_btf_id, so that it may be used by the BPF backend. This enables the BPF CO-RE machinery in the BPF backend to lookup BTF type IDs, in order to create CO-RE relocation records. A prototype is added in ctfc.h gcc/ChangeLog: * btfout.c (get_btf_id): Function is no lo

[PATCH 0/7] BPF CO-RE Support

2021-08-04 Thread David Faust via Gcc-patches
[ These patches depend on the series "Allow means for late BTF generation for BPF CO-RE" by Indu Bhagat, here: https://gcc.gnu.org/pipermail/gcc-patches/2021-July/576446.html ] Hello, This patch series adds support for the BPF Compile Once - Run Everywhere (BPF CO-RE) mechanism in GCC. A BPF

[PATCH 2/7] ctfc: externalize ctf_dtd_lookup

2021-08-04 Thread David Faust via Gcc-patches
Expose the function ctf_dtd_lookup, so that it can be used by the BPF CO-RE machinery. The function is no longer static, and an extern prototype is added in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_dtd_lookup): Function is no longer static. * ctfc.h: Analogous change. --- gcc/ctfc.c

[PATCH 7/7] doc: BPF CO-RE documentation

2021-08-04 Thread David Faust via Gcc-patches
Document the new command line options (-mcore and -mno-core), the new BPF target builtin (__builtin_preserve_access_index), and the new BPF target attribute (preserve_access_index) introduced with BPF CO-RE. gcc/ChangeLog: * doc/extend.texi (BPF Type Attributes) New node. Document

[PATCH 6/7] bpf testsuite: Add BPF CO-RE tests

2021-08-04 Thread David Faust via Gcc-patches
This commit adds several tests for the new BPF CO-RE functionality to the BPF target testsuite. gcc/testsuite/ChangeLog: * gcc.target/bpf/core-attr-1.c: New test. * gcc.target/bpf/core-attr-2.c: Likewise. * gcc.target/bpf/core-attr-3.c: Likewise. * gcc.target/bpf/c

[PATCH 5/7] bpf: BPF CO-RE support

2021-08-04 Thread David Faust via Gcc-patches
This commit introduces support for BPF Compile Once - Run Everywhere (CO-RE) in GCC. gcc/ChangeLog: * config/bpf/bpf.c: Adjust includes. (bpf_handle_preserve_access_index_attribute): New function. (bpf_attribute_table): Use it here. (bpf_builtins): Add BPF_BUILTIN_

Re: [PATCH, V2 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase

2021-08-10 Thread David Faust via Gcc-patches
On 8/10/21 5:00 AM, Richard Biener via Gcc-patches wrote: On Thu, Aug 5, 2021 at 2:53 AM Indu Bhagat via Gcc-patches wrote: DWARF generation is split between early and late phases when LTO is in effect. This poses challenges for CTF/BTF generation especially if late debug info generation is

[PATCH] bpf: use xBPF signed div, mod insns when available

2020-09-17 Thread David Faust via Gcc-patches
The 'mod' and 'div' operators in eBPF are unsigned, with no signed counterpart. xBPF adds two new ALU operations, sdiv and smod, for signed division and modulus, respectively. Update bpf.md with 'define_insn' blocks for signed div and mod to use them when targetting xBPF, and add new tests to ensur

Re: [PATCH] bpf: use xBPF signed div, mod insns when available

2020-09-18 Thread David Faust via Gcc-patches
> >>> The 'mod' and 'div' operators in eBPF are unsigned, with no signed >>> counterpart. xBPF adds two new ALU operations, sdiv and smod, for >>> signed division and modulus, respectively. Update bpf.md with >>> 'define_insn' blocks for signed div and mod to use them when targetting >>> xBPF, and

Re: [PATCH] btf: Add support to BTF_KIND_ENUM64 type

2022-09-28 Thread David Faust via Gcc-patches
Hi Guillermo, Thanks for the patch. Just a couple of small nits on the changelog entries below but otherwise very nice, LGTM. But, please wait a couple of days before pushing to give Indu time to raise any objections about the changes in ctfc/dwarf2ctf. Thanks! David On 8/29/22 14:11, Guillermo

[PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-04-01 Thread David Faust via Gcc-patches
Hello, This patch series is a first attempt at adding support for: - Two new C-language-level attributes that allow to associate (to "tag") particular declarations and types with arbitrary strings. As explained below, this is intended to be used to, for example, characterize certain pointer

[PATCH 1/8] dwarf: Add dw_get_die_parent function

2022-04-01 Thread David Faust via Gcc-patches
gcc/ * dwarf2out.cc (dw_get_die_parent): New function. * dwarf2out.h (dw_get_die_parent): Declare it here. --- gcc/dwarf2out.cc | 8 gcc/dwarf2out.h | 1 + 2 files changed, 9 insertions(+) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 5681b01749a..35322fb5f6e 1

[PATCH 2/8] include: Add BTF tag defines to dwarf2 and btf

2022-04-01 Thread David Faust via Gcc-patches
include/ * btf.h: Add BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG defines. Update comments. (struct btf_decl_tag): New. * dwarf2.def: Add new DWARF extension DW_TAG_GNU_annotation. --- include/btf.h | 17 +++-- include/dwarf2.def | 4 2 files cha

[PATCH 3/8] c-family: Add BTF tag attribute handlers

2022-04-01 Thread David Faust via Gcc-patches
This patch adds attribute handlers in GCC for two attributes already supported in LLVM: "btf_decl_tag" and "btf_type_tag". Both attributes accept a single string constant argument, and are used to add arbitrary annotations to debug information generated for the types/decls to which they apply. gcc

[PATCH 4/8] dwarf: create BTF decl and type tag DIEs

2022-04-01 Thread David Faust via Gcc-patches
The "btf_decl_tag" and "btf_type_tag" attributes are handled by constructing DW_TAG_LLVM_annotation DIEs. The DIEs are children of the declarations or types which they annotate, and convey the annotation via a string constant. Currently, all generation of these DIEs is gated behind btf_debuginfo_p

[PATCH 5/8] ctfc: Add support to pass through BTF annotations

2022-04-01 Thread David Faust via Gcc-patches
BTF generation currently relies on the internal CTF representation to convert debug info from DWARF dies. This patch adds a new internal header, "ctf-int.h", which defines CTF kinds to be used internally to represent BTF tags which must pass through the CTF container. It also adds a new type for re

[PATCH 6/8] dwarf2ctf: convert tag DIEs to CTF types

2022-04-01 Thread David Faust via Gcc-patches
This patch makes the DWARF-to-CTF conversion process aware of the new DW_TAG_GNU_annotation DIEs. The DIEs are converted to CTF_K_DECL_TAG or CTF_K_TYPE_TAG types as approprate and added to the compilation unit CTF container. gcc/ * dwarf2ctf.cc (handle_btf_tags): New function. (g

[PATCH 8/8] testsuite: Add tests for BTF tags

2022-04-01 Thread David Faust via Gcc-patches
This commit adds tests for the tags, in BTF and in DWARF. gcc/teststuite/ * gcc.dg/debug/btf/btf-decltag-func.c: New test. * gcc.dg/debug/btf/btf-decltag-sou.c: Likewise. * gcc.dg/debug/btf/btf-decltag-typedef.c: Likewise. * gcc.dg/debug/btf/btf-typetag-1.c: Likewi

[PATCH 7/8] Output BTF DECL_TAG and TYPE_TAG types

2022-04-01 Thread David Faust via Gcc-patches
This patch updates btfout.cc to be aware of the DECL_TAG and TYPE_TAG kinds and output them appropriately. gcc/ * btfout.cc (get_btf_kind): Handle TYPE_TAG and DECL_TAG kinds. (btf_calc_num_vbytes): Likewise. (btf_asm_type): Likewise. (output_asm_btf_vlen_bytes): L

Re: [PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-04-05 Thread David Faust via Gcc-patches
On 4/4/22 15:13, Yonghong Song wrote: On 4/1/22 12:42 PM, David Faust wrote: Hello, This patch series is a first attempt at adding support for: - Two new C-language-level attributes that allow to associate (to "tag") particular declarations and types with arbitrary strings. As explain

[ping][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-04-18 Thread David Faust via Gcc-patches
/22 12:42, David Faust via Gcc-patches wrote: Hello, This patch series is a first attempt at adding support for: - Two new C-language-level attributes that allow to associate (to "tag") particular declarations and types with arbitrary strings. As explained below, this is intended

[PATCH] bpf: write CO-RE relocation record size only once

2022-01-18 Thread David Faust via Gcc-patches
The CO-RE relocation record size should be written only once in the .BTF.ext section, not once for each section with relocations. Tested for bpf-unknown-none, OK to install? Thanks gcc/ChangeLog: * config/bpf/coreout.c (output_btfext_header): Account for 4-byte record size in cor

[PATCH] bpf: ensure correct string offsets in BTF.ext

2022-01-18 Thread David Faust via Gcc-patches
BPF CO-RE relocations contain offsets to strings buffered in the BTF string table. These BTF-specific strings are stored in memory in the CTF auxilliary strtab, which at output time is concatenated onto the end of the standard strtab. Previously, these string offsets were computed at the time the

[PATCH v2] bpf: write CO-RE relocation record size only once

2022-01-18 Thread David Faust via Gcc-patches
[Changed from v1: Adjust to account for file renaming so patch applies.] The CO-RE relocation record size should be written only once in the .BTF.ext section, not once for each section with relocations. Tested for bpf-unknown-none. OK to install? Thanks. gcc/ChangeLog: * config/bpf/core

[PATCH v2] bpf: ensure correct string offsets in BTF.ext

2022-01-18 Thread David Faust via Gcc-patches
[Changed from v1: Adjust to account for file renaming so patch applies.] BPF CO-RE relocations contain offsets to strings buffered in the BTF string table. These BTF-specific strings are stored in memory in the CTF auxilliary strtab, which at output time is concatenated onto the end of the standar

Re: [PATCH v2] bpf: write CO-RE relocation record size only once

2022-01-18 Thread David Faust via Gcc-patches
On 1/18/22 13:17, Jose E. Marchesi wrote: Hi David. [Changed from v1: Adjust to account for file renaming so patch applies.] The CO-RE relocation record size should be written only once in the .BTF.ext section, not once for each section with relocations. Tested for bpf-unknown-none. OK to

Re: [PATCH v2] bpf: ensure correct string offsets in BTF.ext

2022-01-18 Thread David Faust via Gcc-patches
On 1/18/22 13:18, Jose E. Marchesi wrote: Hi David. [Changed from v1: Adjust to account for file renaming so patch applies.] BPF CO-RE relocations contain offsets to strings buffered in the BTF string table. These BTF-specific strings are stored in memory in the CTF auxilliary strtab, whic

[COMMITTED] bpf: avoid potential NULL pointer dereference

2021-12-08 Thread David Faust via Gcc-patches
[Committed as obvious.] If the result from SSA_NAME_DEF_STMT is NULL, we could try to dereference it anyway and ICE. Avoid this. gcc/ChangeLog: * config/bpf/bpf.c (handle_attr_preserve): Avoid calling is_gimple_assign with a NULL pointer. --- gcc/config/bpf/bpf.c | 2 +- 1 file

[PATCH] bpf: add preserve_field_info builtin

2022-10-19 Thread David Faust via Gcc-patches
Add BPF __builtin_preserve_field_info. This builtin is used to extract information to facilitate struct and union relocations performed by the BPF loader, especially for bitfields. The builtin has the following signature: unsigned int __builtin_preserve_field_info (EXPR, unsigned int KIND); Wh

[PATCH v2] bpf: add preserve_field_info builtin

2022-10-25 Thread David Faust via Gcc-patches
Hi Jose, Thanks for your comments. I think I've addressed them all in the updated patch below. >>+ get_inner_reference (src, &bitsize, &bitpos, &var_off, &mode, &unsignedp, >>+&reversep, &volatilep); > >Since the information returned by the builtin is always constant >(positi

[PATCH v3] bpf: add preserve_field_info builtin

2022-10-26 Thread David Faust via Gcc-patches
>> I'm not sure whether this behavior is a known limitation or an >> oversight. In my opinion it makes more sense to error at compile time, >> becuase even after the loader patches the return value it still will >> not be correct for these cases. >> >> So for now I've set these cases to error out,

Re: [PATCH v3] bpf: add preserve_field_info builtin

2022-10-26 Thread David Faust via Gcc-patches
On 10/26/22 12:33, Jose E. Marchesi wrote: > > Hi David. > > Thanks for the updates. > OK for master. > Pushed, thanks.

[PATCH] bpf: handle anonymous members in CO-RE reloc [PR106745]

2022-08-29 Thread David Faust via Gcc-patches
The old method for computing a member index for a CO-RE relocation relied on a name comparison, which could SEGV if the member in question is itself part of an anonymous inner struct or union. This patch changes the index computation to not rely on a name, while maintaining the ability to account

Re: [PATCH] bpf: handle anonymous members in CO-RE reloc [PR106745]

2022-08-29 Thread David Faust via Gcc-patches
On 8/29/22 12:57, Jose E. Marchesi wrote: > > Hi David. > >> The old method for computing a member index for a CO-RE relocation >> relied on a name comparison, which could SEGV if the member in question >> is itself part of an anonymous inner struct or union. >> >> This patch changes the index

[PATCH v2] bpf: handle anonymous members in CO-RE reloc [PR106745]

2022-08-29 Thread David Faust via Gcc-patches
[changes from v1: simplify the new conditional logic as suggested.] The old method for computing a member index for a CO-RE relocation relied on a name comparison, which could SEGV if the member in question is itself part of an anonymous inner struct or union. This patch changes the index computa

[PATCH] btf: do not skip emitting void variables [PR106773]

2022-09-01 Thread David Faust via Gcc-patches
The eBPF loader expects to find BTF_KIND_VAR records for references to extern const void symbols. We were mistakenly identifing these as unsupported types, and as a result skipping emitting VAR records for them. Tested on bpf-unknown-none and x86_64, no known regressions. OK? Thanks. gcc/ChangeL

[ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-02 Thread David Faust via Gcc-patches
l The series adds support for new attribues btf_type_tag and btf_decl_tag, for recording arbitrary string tags in DWARF and BTF debug info. The feature is to support kernel use cases. Thanks, David On 4/1/22 12:42, David Faust via Gcc-patches wrote: Hello, This patch series is a first att

Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-04 Thread David Faust via Gcc-patches
On 5/3/22 15:32, Joseph Myers wrote: On Mon, 2 May 2022, David Faust via Gcc-patches wrote: Consider the following example: #define __typetag1 __attribute__((btf_type_tag("tag1"))) #define __typetag2 __attribute__((btf_type_tag("tag2"))) #define __ty

Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-06 Thread David Faust via Gcc-patches
On 5/5/22 16:00, Yonghong Song wrote: On 5/4/22 10:03 AM, David Faust wrote: On 5/3/22 15:32, Joseph Myers wrote: On Mon, 2 May 2022, David Faust via Gcc-patches wrote: Consider the following example:     #define __typetag1 __attribute__((btf_type_tag("tag1")))  

Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-11 Thread David Faust via Gcc-patches
On 5/10/22 22:05, Yonghong Song wrote: On 5/10/22 8:43 PM, Yonghong Song wrote: On 5/6/22 2:18 PM, David Faust wrote: On 5/5/22 16:00, Yonghong Song wrote: On 5/4/22 10:03 AM, David Faust wrote: On 5/3/22 15:32, Joseph Myers wrote: On Mon, 2 May 2022, David Faust via Gcc

Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-24 Thread David Faust via Gcc-patches
t; >>>>> On 5/6/22 2:18 PM, David Faust wrote: >>>>>> >>>>>> >>>>>> On 5/5/22 16:00, Yonghong Song wrote: >>>>>>> >>>>>>> >>>>>>> On 5/4/22 10:03 AM, David Faust

Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations

2022-05-24 Thread David Faust via Gcc-patches
t;>>>>>> >>>>>>>> On 5/5/22 16:00, Yonghong Song wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> On 5/4/22 10:03 AM, David Faust wrote: >>>>>>>>>> >>&g

[COMMITTED V2 0/7] BPF CO-RE Support

2021-09-07 Thread David Faust via Gcc-patches
[ Changes from V1: All patches have been OK'd, but the prerequisite series "Allow means for late BTF generation for BPF CO-RE" had not been accepted. Now that that series has been applied, this can be pushed with some very minor tweaks: - Accomodate rename of option '-mco-re' (was -mcore)

[COMMITTED V2 1/7] dwarf: externalize lookup_type_die

2021-09-07 Thread David Faust via Gcc-patches
Expose the function lookup_type_die in dwarf2out, so that it can be used by CTF/BTF when adding BPF CO-RE information. The function is now non-static, and an extern prototype is added in dwarf2out.h. gcc/ChangeLog: * dwarf2out.c (lookup_type_die): Function is no longer static. * d

[COMMITTED V2 3/7] ctfc: add function to lookup CTF ID of a TREE type

2021-09-07 Thread David Faust via Gcc-patches
Add a new function, ctf_lookup_tree_type, to return the CTF type ID associated with a type via its is TREE node. The function is exposed via a prototype in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_lookup_tree_type): New function. * ctfc.h: Likewise. --- gcc/ctfc.c | 16 ++

[COMMITTED V2 2/7] ctfc: externalize ctf_dtd_lookup

2021-09-07 Thread David Faust via Gcc-patches
Expose the function ctf_dtd_lookup, so that it can be used by the BPF CO-RE machinery. The function is no longer static, and an extern prototype is added in ctfc.h. gcc/ChangeLog: * ctfc.c (ctf_dtd_lookup): Function is no longer static. * ctfc.h: Analogous change. --- gcc/ctfc.c

[COMMITTED V2 4/7] btf: expose get_btf_id

2021-09-07 Thread David Faust via Gcc-patches
Expose the function get_btf_id, so that it may be used by the BPF backend. This enables the BPF CO-RE machinery in the BPF backend to lookup BTF type IDs, in order to create CO-RE relocation records. A prototype is added in ctfc.h gcc/ChangeLog: * btfout.c (get_btf_id): Function is no lo

[COMMITTED V2 7/7] doc: BPF CO-RE documentation

2021-09-07 Thread David Faust via Gcc-patches
Document the new command line options (-mco-re and -mno-co-re), the new BPF target builtin (__builtin_preserve_access_index), and the new BPF target attribute (preserve_access_index) introduced with BPF CO-RE. gcc/ChangeLog: * doc/extend.texi (BPF Type Attributes) New node. Docume

[COMMITTED V2 6/7] bpf testsuite: Add BPF CO-RE tests

2021-09-07 Thread David Faust via Gcc-patches
This commit adds several tests for the new BPF CO-RE functionality to the BPF target testsuite. gcc/testsuite/ChangeLog: * gcc.target/bpf/core-attr-1.c: New test. * gcc.target/bpf/core-attr-2.c: Likewise. * gcc.target/bpf/core-attr-3.c: Likewise. * gcc.target/bpf/c

[COMMITTED V2 5/7] bpf: BPF CO-RE support

2021-09-07 Thread David Faust via Gcc-patches
This commit introduces support for BPF Compile Once - Run Everywhere (CO-RE) in GCC. gcc/ChangeLog: * config/bpf/bpf.c: Adjust includes. (bpf_handle_preserve_access_index_attribute): New function. (bpf_attribute_table): Use it here. (bpf_builtins): Add BPF_BUILTIN_

[PATCH] bpf: correct zero_extend output templates

2021-09-09 Thread David Faust via Gcc-patches
The output templates for zero_extendhidi2 and zero_extendqidi2 could lead to incorrect code generation when zero-extending one register into another. This patch adds a new output template to the define_insns to handle such cases and produce correct asm. gcc/ChangeLog: * config/bpf/bpf.md (

[PATCH 0/3] bpf: add -mcpu and related feature options

2021-09-09 Thread David Faust via Gcc-patches
New instructions have been added over time to the eBPF ISA, but previously there has been no good method to select which version to target in GCC. This patch adds the following options to the BPF backend: -mcpu={v1, v2, v3} Select which version of the eBPF ISA to target. This enables or

[PATCH 3/3] doc: document BPF -mcpu and related options

2021-09-09 Thread David Faust via Gcc-patches
This commit adds documentation for the new BPF options -mcpu, -mjmpext, -mjmp32, and -malu32. gcc/ChangeLog: * doc/invoke.texi: Document BPF -mcpu, -mjmpext, -mjmp32 and -malu32 options. --- gcc/doc/invoke.texi | 39 ++- 1 file changed, 38 inser

[PATCH 2/3] bpf testsuite: add tests for new feature options

2021-09-09 Thread David Faust via Gcc-patches
This commit adds tests for the new -mjmpext, -mjmp32 and -malu32 feature options in the BPF backend. gcc/testsuite/ChangeLog: * gcc.target/bpf/alu-1.c: New test. * gcc.target/bpf/jmp-1.c: New test. --- gcc/testsuite/gcc.target/bpf/alu-1.c | 56 +++ gcc/test

[PATCH 1/3] bpf: add -mcpu and related feature options

2021-09-09 Thread David Faust via Gcc-patches
New instructions have been added over time to the eBPF ISA, but previously there has been no good method to select which version to target in GCC. This patch adds the following options to the BPF backend: -mcpu={v1, v2, v3} Select which version of the eBPF ISA to target. This enables or

[PATCH] bpf: correct extra_headers

2021-09-28 Thread David Faust via Gcc-patches
The BPF CO-RE support (commit 8bdabb37549f12ce727800a1c8aa182c0b1dd42a) mistakenly overwrote bpf-*-* extra_headers in config.gcc, causing bpf-helpers.h to not be installed. The redefinition with coreout.h is unneeded, so delete it. gcc/ChangeLog: * config.gcc (bpf-*-*): Do not overwrite e

Re: [PATCH 2/2] bpf: allow BSS symbols to be global symbols

2021-04-27 Thread David Faust via Gcc-patches
On 4/22/21 11:54 PM, Jose E. Marchesi via Gcc-patches wrote: > > Hi YiFei. > >> Prior to this, a BSS declaration such as: >> >> int foo; >> static int bar; >> >> Generates: >> >> .global foo >> .local foo >> .comm foo,4,4 >> .local bar >> .commbar,4,4 >> >> Creating s

Re: [PATCH 2/2] bpf: allow BSS symbols to be global symbols

2021-04-28 Thread David Faust via Gcc-patches
>> >> OK for backport to GCC 11 (both patches)? > > Yes please. Provided releases/gcc-11 is open for backports.. > Done, thanks.

Re: [PATCH V7 4/7] CTF/BTF debug formats

2021-04-30 Thread David Faust via Gcc-patches
On 4/30/21 9:11 AM, Jose E. Marchesi via Gcc-patches wrote: > >>> For a moment, for the sake of this question, if we establish that CTF/BTF >>> generation always feeds off DWARF DIEs (so there is no need to access >>> type/decl tree nodes), what will it take to keep LTO support while keeping >>>

  1   2   >