Ping: [PATCH v2 1/5][STAGE1] c-family: add btf_type_tag and btf_decl_tag attributes

2025-03-07 Thread David Faust
Ping. this patch: https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675242.html series: https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675241.html On 2/6/25 11:54, David Faust wrote: > Add two new c-family attributes, "btf_type_tag" and "btf_decl_tag"

Ping: [PATCH v2 2/5][STAGE1] dwarf: create annotation DIEs for btf tags

2025-03-07 Thread David Faust
could take a look once again? Thanks! archive links this patch: https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675243.html series: https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675241.html On 2/6/25 11:54, David Faust wrote: > The btf_decl_tag and btf_type_tag attribu

Ping2: [PATCH v2 0/5][STAGE1] Add btf_decl_tag and btf_type_tag C attributes

2025-02-28 Thread David Faust
Ping. On 2/20/25 14:24, David Faust wrote: > > Gentle ping for this series. > https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675241.html > > On 2/6/25 11:54, David Faust wrote: >> [v1: https://gcc.gnu.org/pipermail/gcc-patches/2024-October/666911.html >> C

Re: [PATCH v2 3/5][STAGE1] ctf: translate annotation DIEs to internal ctf

2025-02-24 Thread David Faust
On 2/24/25 11:04, Indu Bhagat wrote: > On 2/6/25 11:54 AM, David Faust wrote: >> Translate DW_TAG_GNU_annotation DIEs created for C attributes >> btf_decl_tag and btf_type_tag into an in-memory representation in the >> CTF/BTF container. They will be output in BTF as

Re: [PATCH v2 4/5][STAGE1] btf: generate and output DECL_TAG and TYPE_TAG records

2025-02-24 Thread David Faust
On 2/24/25 11:03, Indu Bhagat wrote: > On 2/6/25 11:54 AM, David Faust wrote: >> Support the btf_decl_tag and btf_type_tag attributes in BTF by creating >> and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, >> respectively, for them. >> >> Some care i

Ping: [PATCH v2 0/5][STAGE1] Add btf_decl_tag and btf_type_tag C attributes

2025-02-20 Thread David Faust
Gentle ping for this series. https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675241.html On 2/6/25 11:54, David Faust wrote: > [v1: https://gcc.gnu.org/pipermail/gcc-patches/2024-October/666911.html > Changes from v1: > - Fix a bug in v1 related to generating DWARF for

[PATCH v2 4/5][STAGE1] btf: generate and output DECL_TAG and TYPE_TAG records

2025-02-06 Thread David Faust
Support the btf_decl_tag and btf_type_tag attributes in BTF by creating and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, respectively, for them. Some care is required when -gprune-btf is in effect to avoid emitting decl or type tags for declarations or types which have been pruned and

[PATCH v2 3/5][STAGE1] ctf: translate annotation DIEs to internal ctf

2025-02-06 Thread David Faust
Translate DW_TAG_GNU_annotation DIEs created for C attributes btf_decl_tag and btf_type_tag into an in-memory representation in the CTF/BTF container. They will be output in BTF as BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records. The new CTF kinds used to represent these annotations, CTF_K_DECL_T

[PATCH v2 0/5][STAGE1] Add btf_decl_tag and btf_type_tag C attributes

2025-02-06 Thread David Faust
f type tags which do not allow it to be shared. The DIE for "rcu", however, is shared between uses. And BTF information: [1] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'rcu_s' type_id=2 'ptr' type_id=6 [2] TYPE_TAG 'rcu' type_id=3

[PATCH v2 2/5][STAGE1] dwarf: create annotation DIEs for btf tags

2025-02-06 Thread David Faust
The btf_decl_tag and btf_type_tag attributes provide a means to annotate declarations and types respectively with arbitrary user provided strings. These strings are recorded in debug information for post-compilation uses, and despite the name they are meant to be recorded in DWARF as well as BTF.

[PATCH v2 5/5][STAGE1] doc: document btf_type_tag and btf_decl_tag attributes

2025-02-06 Thread David Faust
gcc/ * doc/extend.texi (Common Variable Attributes): Document btf_decl_tag attribute. (Common Type Attributes): Document btf_type_tag attribute. --- gcc/doc/extend.texi | 68 + 1 file changed, 68 insertions(+) diff --git a/gcc/do

[PATCH v2 1/5][STAGE1] c-family: add btf_type_tag and btf_decl_tag attributes

2025-02-06 Thread David Faust
Add two new c-family attributes, "btf_type_tag" and "btf_decl_tag" along with a simple shared handler for them. gcc/c-family/ * c-attribs.cc (c_common_attribute_table): Add btf_decl_tag and btf_type_tag attributes. (handle_btf_tag_attribute): New handler for both new attrib

[PATCH] bpf: avoid possible null deref in btf_ext_output [PR target/117447]

2024-11-07 Thread David Faust
The BPF-specific .BTF.ext section is always generated for BPF programs if -gbtf is specified, and generating it requires BTF information and assumes that the BTF info has already been generated. Compiling non-C languages to BPF is not supported, nor is generating CTF/BTF for non-C. But, compiling

[committed] btf: check hash maps are non-null before emptying

2024-11-07 Thread David Faust
These maps will always be non-null in btf_finalize under normal circumstances, but be safe and verify that before trying to empty them. Tested on x86_64-linux-gnu and x86_64-linux-gnu host for bpf-unknown-none target. Pushed as obvious. gcc/ * btfout.cc (btf_finalize): Check that hash map

[PATCH 2/5] dwarf: create annotation DIEs for btf tags

2024-10-30 Thread David Faust
The btf_decl_tag and btf_type_tag attributes provide a means to annotate declarations and types respectively with arbitrary user provided strings. These strings are recorded in debug information for post-compilation uses, and despite the name they are meant to be recorded in DWARF as well as BTF.

[PATCH 0/5] Add btf_decl_tag and btf_type_tag C attributes

2024-10-30 Thread David Faust
[4] STRUCT 'S' size=4 vlen=1 ... [6] TYPE_TAG 'foo' type_id=7 [7] PTR '(anon)' type_id=0 [8] TYPE_TAG 'foo' type_id=9 [9] TYPE_TAG 'rcu' type_id=10 [10] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [11] VAR &#x

[PATCH 4/5] btf: generate and output DECL_TAG and TYPE_TAG records

2024-10-30 Thread David Faust
Support the btf_decl_tag and btf_type_tag attributes in BTF by creating and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, respectively, for them. Some care is required when -gprune-btf is in effect to avoid emitting decl or type tags for declarations or types which have been pruned and

[PATCH 3/5] ctf: translate annotation DIEs to internal ctf

2024-10-30 Thread David Faust
Translate DW_TAG_GNU_annotation DIEs created for C attributes btf_decl_tag and btf_type_tag into an in-memory representation in the CTF/BTF container. They will be output in BTF as BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records. The new CTF kinds used to represent these annotations, CTF_K_DECL_T

[PATCH 5/5] doc: document btf_type_tag and btf_decl_tag attributes

2024-10-30 Thread David Faust
gcc/ * doc/extend.texi (Common Variable Attributes): Document new btf_decl_tag attribute. (Common Type Attributes): Document new btf_type_tag attribute. --- gcc/doc/extend.texi | 68 + 1 file changed, 68 insertions(+) diff --git

[PATCH 1/5] c-family: add btf_type_tag and btf_decl_tag attributes

2024-10-30 Thread David Faust
Add two new c-family attributes, "btf_decl_tag" and "btf_type_tag" along with a simple shared handler for them. gcc/c-family/ * c-attribs.cc (c_common_attribute_table): Add btf_decl_tag and btf_type_tag attributes. (handle_btf_tag_attribute): New handler for both new attri

Re: [PATCH v2] bpf: make sure CO-RE relocs are typed with struct BTF_KIND_STRUCT

2024-10-15 Thread David Faust
On 10/14/24 11:04, Cupertino Miranda wrote: > Hi everyone, > > Here is the v2 for the patch in this thread: > https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665378.html > Please noticed that commit message was adapted to new content. > > Regards, > Cupertino Hi Cupertino, Thanks for

Re: [PATCH 3/3] bpf: set index entry for a VAR_DECL in CO-RE relocs

2024-09-30 Thread David Faust
On 9/27/24 09:49, Cupertino Miranda wrote: > CO-RE accesses with non pointer struct variables will also generate a > "0" string access within the CO-RE relocation. > The first index within the access string, has sort of a different > meaning then the remaining of the indexes. > For i0:i1:...:in

Re: [PATCH 2/3] bpf: calls do not promote attr access_index on lhs

2024-09-30 Thread David Faust
On 9/27/24 09:49, Cupertino Miranda wrote: > When traversing gimple to introduce CO-RE relocation entries to > expressions that are accesses to attributed perserve_access_index types, > the access is likely to be split in multiple gimple statments. > In order to keep doing the proper CO-RE conve

Re: [PATCH 1/3] bpf: make sure CO-RE relocs are never typed with a BTF_KIND_CONST

2024-09-30 Thread David Faust
On 9/27/24 09:49, Cupertino Miranda wrote: > Based on observation within bpf-next selftests and comparisson of GCC > and clang compiled code, the BPF loader expects all CO-RE relocations to > point to BTF non const type nodes. > --- > gcc/btfout.cc | 2 +- > gcc

Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind

2024-08-09 Thread David Faust
On 8/7/24 10:19, Will Hawkins wrote: > On Mon, Jul 29, 2024 at 2:14 PM David Faust wrote: >> >> >> On 7/29/24 07:42, Will Hawkins wrote: >>> If the user provides a kind value that is more than 5 bits, the >>> BTF_KIND_INFO macro would emit incorrect value

Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind

2024-07-29 Thread David Faust
On 7/29/24 07:42, Will Hawkins wrote: > If the user provides a kind value that is more than 5 bits, the > BTF_KIND_INFO macro would emit incorrect values for info (by clobbering > values of the kind flag). > > Tested on x86_64-redhat-linux. OK, thanks. > > include/ChangeLog: > > * btf.

Re: [PATCH] bpf: create modifier for mem operand for xchg and cmpxchg

2024-07-18 Thread David Faust
On 7/15/24 08:33, Cupertino Miranda wrote: > Both xchg and cmpxchg instructions, in the pseudo-C dialect, do not > expect their memory address operand to be surrounded by parentheses. > For example, it should be output as "w0 =cmpxchg32_32(r8+8,w0,w2)" > instead of "w0 =cmpxchg32_32((r8+8),w0,w2)".

[PATCH] opts: allow -gctf, -gbtf, -gdwarf simultaneously

2024-07-10 Thread David Faust
[This is a resend of a patch previously sent as: PATCH v4 6/6 opts: allow any combination of DWARF,CTF,BTF https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654253.html] Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made i

[COMMITTED] Regenerate common.opt.urls

2024-07-02 Thread David Faust
I was not aware of the requirement to regenerate the opt urls files when adding a new option until the autobuilder complained. Regenerate common.opt.urls for the -gprune-btf option added in: b8977d928a7a btf: add -gprune-btf option Pushed as obvious. gcc/ * common.opt.urls: Regenerate.

Re: [PATCH v4 6/6] opts: allow any combination of DWARF, CTF, BTF

2024-06-24 Thread David Faust
Ping. archive: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654253.html On 6/11/24 12:01, David Faust wrote: > Previously it was not supported to generate both CTF and BTF debug info > in the same compiler run, as both formats made incompatible changes to > the same inte

Re: [PATCH v4 4/6] btf: add -gprune-btf option

2024-06-24 Thread David Faust
it. Thanks! archive: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654252.html On 6/11/24 12:01, David Faust wrote: > This patch adds a new option, -gprune-btf, to control BTF debug info > generation. > > As the name implies, this option enables a kind of "pruning" of

Re: [PATCH v4 5/6] bpf,btf: enable BTF pruning by default for BPF

2024-06-12 Thread David Faust
On 6/12/24 09:55, Jose E. Marchesi wrote: > > Hi Faust. > Thanks for the patch. > Please see a question below. > >> This patch enables -gprune-btf by default in the BPF backend when >> generating BTF information, and fixes BPF CO-RE generation when using >> -gprune-btf. >> >> When generating B

[PATCH v4 6/6] opts: allow any combination of DWARF, CTF, BTF

2024-06-11 Thread David Faust
Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made incompatible changes to the same internal data structures. With the structural change in the prior patches, in particular the guarantee that CTF will always be fully emitted befor

[PATCH v4 2/6] ctf: use pointers instead of IDs internally

2024-06-11 Thread David Faust
This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. This change is only to the in-memory repr

[PATCH v4 4/6] btf: add -gprune-btf option

2024-06-11 Thread David Faust
This patch adds a new option, -gprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from DWARF, only information for types dire

[PATCH v4 3/6] btf: refactor and simplify implementation

2024-06-11 Thread David Faust
This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process of converting CTF type IDs to BTF type I

[PATCH v4 5/6] bpf,btf: enable BTF pruning by default for BPF

2024-06-11 Thread David Faust
This patch enables -gprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -gprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have sufficient BTF information emited so that the

[PATCH v4 1/6] ctf, btf: restructure CTF/BTF emission

2024-06-11 Thread David Faust
This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreversibly, the shared in-memory represen

[PATCH v4 0/6] btf: refactor and add pruning option

2024-06-11 Thread David Faust
generating both CTF and BTF in the same compiler run, allowing for any combinaion of -gdwarf, -gctf and -gbtf. Tested on x86_64-linux-gnu, and on x86_64-linux-gnu host for bpf-unknown-none target. Also tested by compiling and runninng Linux kernel BPF selftests. No known regressions. David Faust

Re: [PATCH v3 4/6] btf: add -fprune-btf option

2024-05-31 Thread David Faust
On 5/31/24 00:07, Richard Biener wrote: > On Thu, May 30, 2024 at 11:34 PM David Faust wrote: >> >> This patch adds a new option, -fprune-btf, to control BTF debug info >> generation. > > Can you name it -gprune-btf instead? Yes, sure. I think I followed -felimin

[PATCH v3 3/6] btf: refactor and simplify implementation

2024-05-30 Thread David Faust
This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process of converting CTF type IDs to BTF type I

[PATCH v3 5/6] bpf,btf: enable BTF pruning by default for BPF

2024-05-30 Thread David Faust
This patch enables -fprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -fprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have sufficient BTF information emited so that the

[PATCH v3 6/6] opts: allow any combination of DWARF, CTF, BTF

2024-05-30 Thread David Faust
Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made incompatible changes to the same internal data structures. With the structural change in the prior patches, in particular the guarantee that CTF will always be fully emitted befor

[PATCH v3 4/6] btf: add -fprune-btf option

2024-05-30 Thread David Faust
This patch adds a new option, -fprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from DWARF, only information for types dire

[PATCH v3 2/6] ctf: use pointers instead of IDs internally

2024-05-30 Thread David Faust
This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. This change is only to the in-memory repr

[PATCH v3 1/6] ctf, btf: restructure CTF/BTF emission

2024-05-30 Thread David Faust
This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreversibly, the shared in-memory represen

[PATCH v3 0/6] btf: refactor and add pruning option

2024-05-30 Thread David Faust
and on x86_64-linux-gnu host for bpf-unknown-none target. Also tested by compiling and runninng Linux kernel BPF selftests. No known regressions. David Faust (6): ctf, btf: restructure CTF/BTF emission ctf: use pointers instead of IDs internally btf: refactor and simplify implementation

Re: [PATCH v2 1/6] ctf, btf: restructure CTF/BTF emission

2024-05-06 Thread David Faust
On 5/3/24 2:02 PM, Indu Bhagat wrote: > On 5/2/24 10:11, David Faust wrote: >> This commit makes some structural changes to the CTF/BTF debug info >> emission. In particular: >> >> a) CTF is new always fully generated and emitted before any >> BTF-relate

[PATCH v2 6/6] bpf,btf: enable BTF pruning by default for BPF

2024-05-02 Thread David Faust
This patch enables -fprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -fprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have sufficient BTF information emited so that the

[PATCH v2 4/6] btf: refactor and simplify implementation

2024-05-02 Thread David Faust
This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process of converting CTF type IDs to BTF type I

[PATCH v2 5/6] btf: add -fprune-btf option

2024-05-02 Thread David Faust
This patch adds a new option, -fprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from DWARF, only information for types dire

[PATCH v2 2/6] opts: allow any combination of DWARF, CTF, BTF

2024-05-02 Thread David Faust
Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made incompatible changes to the same internal data structures. With the structural change in the prior patch, in particular the guarantee that CTF will always be fully emitted before

[PATCH v2 3/6] ctf: use pointers instead of IDs internally

2024-05-02 Thread David Faust
This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. This change is only to the in-memory repr

[PATCH v2 0/6] btf: refactor and add pruning option

2024-05-02 Thread David Faust
makes BTF pruning work with BPF CO-RE, and enables the pruning by default in the BPF backend. Tested on x86_64-linux-gnu, and on x86_64-linux-gnu host for bpf-unknown-none target. Also heavily tested with Linux kernel BPF selftests. No known regressions. David Faust (6): ctf, btf: restructu

[PATCH v2 1/6] ctf, btf: restructure CTF/BTF emission

2024-05-02 Thread David Faust
This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreversibly, the shared in-memory represen

Re: [PATCH 3/6] ctf: use pointers instead of IDs internally

2024-05-02 Thread David Faust
On 5/1/24 12:15, David Faust wrote: > This patch replaces all inter-type references in the ctfc internal data > structures with pointers, rather than the references-by-ID which were > used previously. > > A couple of small updates in the BPF backend are included to make it > c

[PATCH 4/6] btf: refactor and simplify implementation

2024-05-01 Thread David Faust
This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process of converting CTF type IDs to BTF type I

[PATCH 3/6] ctf: use pointers instead of IDs internally

2024-05-01 Thread David Faust
This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. This change is only to the in-memory repr

[PATCH 5/6] btf: add -fprune-btf option

2024-05-01 Thread David Faust
This patch adds a new option, -fprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from DWARF, only information for types dire

[PATCH 6/6] bpf,btf: enable BTF pruning by default for BPF

2024-05-01 Thread David Faust
This patch enables -fprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -fprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have sufficient BTF information emited so that the

[PATCH 1/6] ctf, btf: restructure CTF/BTF emission

2024-05-01 Thread David Faust
This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreversibly, the shared in-memory represen

[PATCH 0/6] btf: refactor and add pruning option

2024-05-01 Thread David Faust
rmation by a factor of 10. Patch 6 makes BTF pruning work with BPF CO-RE, and enables the pruning by default in the BPF backend. Tested on x86_64-linux-gnu, and on x86_64-linux-gnu host for bpf-unknown-none target. Also heavily tested with Linux kernel BPF selftests. No known regressions. Davi

[PATCH 2/6] opts: allow any combination of DWARF, CTF, BTF

2024-05-01 Thread David Faust
Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made incompatible changes to the same internal data structures. With the structural change in the prior patch, in particular the guarantee that CTF will always be fully emitted before

[PATCH] bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG

2024-04-25 Thread David Faust
BTF is the standard debug info used with BPF programs, so it makes sense to default to BTF rather than DWARF. Tested on x86_64-linux-gnu host for bpf-unknown-none target. gcc/ * config/bpf/bpf.h (PREFERRED_DEBUGGING_TYPE): Set to BTF_DEBUG. gcc/testsuite/ * gcc.target/bpf/bpf-deb

[PATCH] bpf: avoid issues with CO-RE and -gtoggle

2024-04-25 Thread David Faust
Compiling a BPF program with CO-RE relocations (and BTF) while also passing -gtoggle led to an inconsistent state where CO-RE support was enabled but BTF would not be generated, and this was not caught by the existing option parsing. This led to an ICE when generating the CO-RE relocation info, si

Re: [PATCH v3] bpf: remove huge memory waste with string allocation.

2024-04-18 Thread David Faust
Hi Cupertino, On 4/18/24 13:58, Cupertino Miranda wrote: > Hi David, everyone, > > Following Davids last review I decided to properly detect error cases, > as suggested. > The error however should be reported earlier in compilation in > pack_enum_valud function, where all the errors are reported.

Re: [PATCH v2] bpf: remove huge memory waste with string allocation.

2024-04-17 Thread David Faust
On 4/17/24 11:44, Cupertino Miranda wrote: > The BPF backend was allocating an unnecessarily large string when > constructing CO-RE relocations for enum types. > > gcc/ChangeLog: > * config/bpf/core-builtins.cc (process_enum_value): Correct > string allocation. > --- > gcc/config/b

[PATCH] btf: fix a possibly misleading asm debug comment

2024-04-11 Thread David Faust
This patch fixes a small error that could occur in the debug comment when emitting a type reference with btf_asm_type_ref. While working on a previous patch, I noticed the following in the asm output for the test btf-bitfields-4.c: ... .long 0x39# MEMBER 'c' idx=3 .l

[PATCH v2] btf: emit non-representable bitfield as void

2024-04-11 Thread David Faust
[Changes from v1: use btf_dmd_representable_bitfield_p in btf_asm_sou_member, instead of a slightly incorrect equivalent check.] This patch fixes an issue with mangled BTF that could occur when a struct type contains a bitfield member which cannot be represented in BTF. It is undefined what shou

Re: [PATCH] btf: emit non-representable bitfield as void

2024-04-11 Thread David Faust
On 4/11/24 13:40, Indu Bhagat wrote: > On 4/11/24 11:53, David Faust wrote: >> This patch fixes an issue with mangled BTF that could occur when >> a struct type contains a bitfield member which cannot be represented >> in BTF. It is undefined what should happen in such ca

[PATCH] btf: emit non-representable bitfield as void

2024-04-11 Thread David Faust
This patch fixes an issue with mangled BTF that could occur when a struct type contains a bitfield member which cannot be represented in BTF. It is undefined what should happen in such cases, but we can at least do something reasonable. Commit 936dd627cd9 "btf: do not skip members of data type

Re: [PATCH 2/3] bpf: remove huge memory waste with string allocation.

2024-04-11 Thread David Faust
Hi Cupertino, On 4/11/24 04:11, Cupertino Miranda wrote: > Code was allocating way too much space for the string. A little bit more description would not hurt. Perhaps you could say something like: "The BPF backend was allocating an unnecessarily large string when constructing CO-RE relocations

Re: [PATCH 2/2] btf: do not skip members of data type with type id BTF_VOID_TYPEID

2024-04-10 Thread David Faust
Hi Indu, On 4/10/24 11:25, Indu Bhagat wrote: > Testing the previous fix in gen_ctf_sou_type () reveals an issue in BTF > generation, however: BTF emission was currently decrementing the vlen > (indicating the number of members) to skip members of type CTF_K_UNKNOWN > altogether, but still emittin

Re: [PATCH 1/2] ctf: fix PR debug/112878

2024-04-10 Thread David Faust
On 4/10/24 11:25, Indu Bhagat wrote: > PR debug/112878: ICE: in ctf_add_slice, at ctfc.cc:499 with _BitInt > 255 in > a struct and -gctf1 > > The CTF generation in GCC does not have a mechanism to roll-back an > already added type. In this testcase presented in the PR, we hit a > representation

[PATCH] btf: improve btf-datasec-3.c test [PR 114642]

2024-04-08 Thread David Faust
This test failed on powerpc --target_board=unix'{-m32}' because two variables were not placed in sections where the test silently (and incorrectly) assumed they would be. The important thing for the test is only that BTF_KIND_DATASEC entries are NOT generated for the extern variable declarations w

[PATCH] btf: emit symbol refs in DATASEC entries only for BPF [PR114608]

2024-04-08 Thread David Faust
The behavior introduced in fa60ac54964 btf: Emit labels in DATASEC bts_offset entries. is only fully correct when compiling for the BPF target with BPF CO-RE enabled. In other cases, depending on optimizations, it can result in an incorrect symbol reference in the entry bts_offset field for a s

Re: [PATCH] btf: Fix up btf-datasec-1.c test on x86

2024-03-27 Thread David Faust
Hi Jakub, On 3/27/24 04:16, Jakub Jelinek wrote: > On Wed, Mar 27, 2024 at 11:18:49AM +0100, Jakub Jelinek wrote: >>> -/* The offset entry for each variable in a DATSEC should be 0 at compile >>> time. */ >>> -/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 7 } } */ >>> +/* Th

Re: [PATCH] btf: Emit labels in DATASEC bts_offset entries.

2024-03-26 Thread David Faust
On 3/26/24 07:28, Cupertino Miranda wrote: > Hi everyone, > > This patch is an expected fix for the issue reported by systemd in: > https://github.com/systemd/systemd/issues/31888 > Also, Jose Marchesi opened the following bugzilla to report it: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114

Re: [PATCH 3/3] bpf: Corrected index computation when present with unnamed struct fields

2024-03-19 Thread David Faust
On 3/13/24 07:24, Cupertino Miranda wrote: > Any unnamed structure field if not a member of the BTF_KIND_STRUCT. typo: if -> is I'd suggest to clarify that "any unnamed structure field" is really any unnamed non-struct-or-union field, since anonymous inner structs and unions certainly are prese

Re: [PATCH 2/3] bpf: Fix access string default for CO-RE type based relocations

2024-03-19 Thread David Faust
On 3/13/24 07:24, Cupertino Miranda wrote: > Although part of all CO-RE relocation data, type based relocations do > not require an access string. > Initial implementation defined it as an empty string. > On the other hand, libbpf when parsing the CO-RE relocations verifies > that those strings

Re: [PATCH] bpf: define INT8_TYPE as signed char

2024-03-14 Thread David Faust
On 3/14/24 10:16, Jose E. Marchesi wrote: > > Hi David. > >> Change the BPF backend to define INT8_TYPE with an explicit sign, rather >> than a plain char. This is in line with other targets and removes the >> risk of int8_t being affected by the signedness of the plain char type >> of the ho

[PATCH] bpf: define INT8_TYPE as signed char

2024-03-14 Thread David Faust
Change the BPF backend to define INT8_TYPE with an explicit sign, rather than a plain char. This is in line with other targets and removes the risk of int8_t being affected by the signedness of the plain char type of the host system. Tested on x86_64-linux-gnu host for bpf-unknown-none. Sanity ch

[PATCH v2] bpf: add size threshold for inlining mem builtins

2024-03-08 Thread David Faust
[Changes from v1: - Error if threshold is exceeded instead of silently emitting libcall - Update test accordingly - Expand documentation to explain this behavior ] BPF cannot fall back on library calls to implement memmove, memcpy and memset, so we attempt to expand these inline always if poss

[PATCH] bpf: testsuite: fix unresolved test in memset-1.c

2024-03-07 Thread David Faust
The test was trying to do too much by both checking for an error, and checking the resulting assembly. Of course, due to the error no asm was produced, so the scan-asm went unresolved. Split it into two separate tests to fix the issue. Tested on x86_64-linux-gnu host for bpf-unknown-none target.

[PATCH] bpf: add size threshold for inlining mem builtins

2024-03-07 Thread David Faust
BPF cannot fall back on library calls to implement memmove, memcpy and memset, so we attempt to expand these inline always if possible. However, this inline expansion was being attempted even for excessively large operations, which could result in gcc consuming huge amounts of memory and hanging.

Re: [PATCH, V3] ctf: fix incorrect CTF for multi-dimensional array types

2024-03-05 Thread David Faust
On 3/5/24 00:47, Indu Bhagat wrote: > From: Cupertino Miranda > > [Changes from V2] > - Fixed aarch64 new FAILs reported by Linaro CI. > - Fixed typos and other nits pointed out in V2. > [End of changes from V2] OK, thanks. > > PR debug/114186 > > DWARF DIEs of type DW_TAG_subrange_typ

Re: [PATCH,V2] ctf: fix incorrect CTF for multi-dimensional array types

2024-03-04 Thread David Faust
Hi Indu, Cupertino, On 3/4/24 10:00, Indu Bhagat wrote: > From: Cupertino Miranda > > [Changes from V1] > - Refactor the code a bit. > [End of changes from V1] > > PR debug/114186 > > DWARF DIEs of type DW_TAG_subrange_type are linked together to represent > the information about the subsequ

[PATCH] bpf: add inline memset expansion

2024-03-04 Thread David Faust
Similar to memmove and memcpy, the BPF backend cannot fall back on a library call to implement __builtin_memset, and should always expand calls to it inline if possible. This patch implements simple inline expansion of memset in the BPF backend in a verifier-friendly way. Similar to memcpy and mem

[PATCH] testsuite: ctf: make array in ctf-file-scope-1 fixed length

2024-03-01 Thread David Faust
The array member of struct SFOO in the ctf-file-scope-1 caused the test to fail for the BPF target, since BPF does not support dynamic stack allocation. The array does not need to variable length for the sake of the test, so make it fixed length instead to allow the test to run successfully for the

Re: [PATCH v2 4/5] bpf: implementation of func_info in .BTF.ext.

2024-02-27 Thread David Faust
Hi Cupertino, On 2/27/24 11:04, Cupertino Miranda wrote: > Kernel verifier complains in some particular cases for missing func_info > implementation in .BTF.ext. This patch implements it. > > Strings are cached locally in coreout.cc to avoid adding duplicated > strings in the string list. This st

Re: [PATCH v2 5/5] bpf: renamed coreout.* files to btfext-out.*.

2024-02-27 Thread David Faust
On 2/27/24 11:04, Cupertino Miranda wrote: > gcc/ChangeLog: > > * config.gcc (target_gtfiles): Changes coreout to btfext-out. > (extra_objs): Changes coreout to btfext-out. > * config/bpf/coreout.cc: Renamed to btfext-out.cc. > * config/bpf/btfext-out.cc: Added. > * c

Re: [PATCH v2 3/5] bpf: Always emit .BTF.ext section if generating BTF

2024-02-27 Thread David Faust
On 2/27/24 11:04, Cupertino Miranda wrote: > BPF applications, when generating BTF information should always create a > .BTF.ext section. > Current implementation was only creating it when -mco-re option was used. > This patch makes .BTF.ext always be generated for BPF target objects. > The patc

Re: [PATCH v2 2/5] btf: added KIND_FUNC traversal function.

2024-02-27 Thread David Faust
Hi Cupertino, Similar to patch 1, please use present tense to match the style of existing commits, in commit message and in ChangeLog. On 2/27/24 11:04, Cupertino Miranda wrote: > Added a traversal function to traverse all BTF_KIND_FUNC nodes with a > callback function. Used for .BTF.ext section

Re: [PATCH v2 1/5] btf: fixed type id in BTF_KIND_FUNC struct data.

2024-02-27 Thread David Faust
Hi Cupertino, Just some nits below. Apologies for incoming pedantry. On 2/27/24 11:04, Cupertino Miranda wrote: > This patch correct the aditition of +1 on the type id, which originally > was done in the wrong location and leaded to func_sts->dtd_type for > BTF_KIND_FUNCS struct data to contain t

Re: [PATCH 5/5] bpf: renamed coreout.* files to btfext-out.*.

2024-02-21 Thread David Faust
On 2/20/24 02:24, Cupertino Miranda wrote: > gcc/ChangeLog: > * config.gcc (target_gtfiles): changed coreout to btfext-out. > (extra_objs): changed coreout to btfext-out. I think these entries should start with a capital letter ("Changed..."). > * config/bpf/coreout.cc: Renam

Re: [PATCH 2/5] btf: added KIND_FUNC traversal function.

2024-02-21 Thread David Faust
On 2/20/24 02:24, Cupertino Miranda wrote: > Added a traversal function to traverse all BTF_KIND_FUNC nodes with a > callback function. Used for .BTF.ext section content creation. > > gcc/ChangeLog > > * btfout.cc (output_btf_func_types): use FOR_EACH_VEC_ELT. > (traverse_btf_func_t

[PATCH v3] bpf: add inline memmove and memcpy expansion

2024-02-20 Thread David Faust
[Changes from v2: - Fix incorrectly passing a location instead of OPT_W* for warning (). - Reword warning/error message and test accordingly. ] [Changes from v1: Jose's review comments, all of which I agree with. - Fix 'implments' typo in commit message. - Change check that alignment is CON

Re: [PATCH v2] bpf: add inline memmove and memcpy expansion

2024-02-20 Thread David Faust
On 2/20/24 12:37, Jose E. Marchesi wrote: > > Hi Faust. > >> +bool >> +bpf_expand_cpymem (rtx *operands, bool is_move) >> +{ >> + /* Size must be constant for this expansion to work. */ >> + if (!CONST_INT_P (operands[2])) >> +{ >> + const char *name = is_move ? "memmove" : "memcpy

Re: [PATCH 3/5] btf: moved btf deallocation to final.

2024-02-20 Thread David Faust
Hi Cupertino, On 2/20/24 02:24, Cupertino Miranda wrote: > Dissociated .BTF.ext from the CO-RE relocations creation. Improvement of > allocation/deallocation of BTF structures. Moving deallocation to final > when needed. > > gcc/ChangeLog: > > * config/bpf/bpf.cc (bpf_option_override): Mak

Re: [PATCH 1/5] btf: fixed type id in BTF_KIND_FUNC struct data.

2024-02-20 Thread David Faust
On 2/20/24 02:24, Cupertino Miranda wrote: > This patch correct the aditition of +1 on the type id, which originally > was done in the wrong location and leaded to func_sts->dtd_type for > BTF_KIND_FUNCS struct data to contain the type id of the previous entry. > > gcc/ChangeLog: > * btfo

  1   2   3   >