Re: [PATCH 3/3] btf: correct generation for extern funcs [PR106773]

2022-12-12 Thread David Faust via Gcc-patches
On 12/8/22 23:36, Indu Bhagat wrote: > On 12/7/22 12:57, David Faust wrote: >> The eBPF loader expects to find entries for functions declared as extern >> in the corresponding BTF_KIND_DATASEC record, but we were not generating >> these entries. >> >> This patch adds support for the 'extern' lin

Re: [PATCH 1/3] btf: add 'extern' linkage for variables [PR106773]

2022-12-12 Thread David Faust via Gcc-patches
On 12/8/22 22:55, Indu Bhagat wrote: > Hi David, > > On 12/7/22 12:57, David Faust wrote: >> Add support for the 'extern' linkage value for BTF_KIND_VAR records, >> which is used for variables declared as extern in the source file. >> >> PR target/106773 >> >> gcc/ >> >> * btfout.cc (

Re: [PATCH 2/3] btf: fix 'extern const void' variables [PR106773]

2022-12-12 Thread David Faust via Gcc-patches
On 12/8/22 23:34, Indu Bhagat wrote: > Looks OK to me overall. Minor comments below. > > Thanks > > On 12/7/22 12:57, David Faust wrote: >> The eBPF loader expects to find BTF_KIND_VAR records for references to >> extern const void symbols. We were mistakenly identifing these as >> unsupported

[PATCH v2 0/3] btf: fix BTF for extern items [PR106773]

2022-12-13 Thread David Faust via Gcc-patches
[Changes from v1: - Remove #defines for LINKAGE_* values, instead mirror enums from linux/btf.h to include/btf.h and use those. - Fix BTF generation for extern variable with both non-defining and defining decls in the same CU. Add a test for this. - Update several comments per review feedb

[PATCH v2 1/3] btf: add 'extern' linkage for variables [PR106773]

2022-12-13 Thread David Faust via Gcc-patches
[Changes from v1: - Add enum btf_var_linkage in include/btf.h and use that instead of local #defines. - Fix BTF generation for extern variable with both non-defining and defining decls in the same CU. Add a test for this. ] Add support for the 'extern' linkage value for BTF_KIND_VAR record

[PATCH v2 2/3] btf: fix 'extern const void' variables [PR106773]

2022-12-13 Thread David Faust via Gcc-patches
[Changes from v1: Minor updates to comments per review. ] 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. In addition, the internal D

[PATCH v2 3/3] btf: correct generation for extern funcs [PR106773]

2022-12-13 Thread David Faust via Gcc-patches
[Changes from v1: - Add enum btf_func_linkage to include/btf.h and use it. - Minor updates to comments based on review. ] The eBPF loader expects to find entries for functions declared as extern in the corresponding BTF_KIND_DATASEC record, but we were not generating these entries. This patch a

[PATCH] bpf: correct bpf_print_operand for floats [PR108293]

2023-01-09 Thread David Faust via Gcc-patches
The existing logic in bpf_print_operand was only correct for integral CONST_DOUBLEs, and emitted garbage for floating point modes. Fix it so floating point mode operands are correctly handled. Tested on bpf-unknown-none, no known regressions. OK to check-in? Thanks. PR target/108293 gc

[PATCH v2] bpf: correct bpf_print_operand for floats [PR108293]

2023-01-10 Thread David Faust via Gcc-patches
Hi Jose, As we discussed on IRC, since we don't currently define TARGET_SUPPORTS_WIDE_INT it is safer to keep the handling for VOIDmode CONST_DOUBLEs. My current understanding is that it may be needed if the host is a 32-bit platform. I also added a gcc_unreachable () as you pointed out. V2 below

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

2023-09-11 Thread David Faust via Gcc-patches
, 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, and is used by various > components of the BPF ecosystem. > > The purpose of the attribute is

[PATCH] bpf: generate indirect calls for xBPF

2020-09-03 Thread David Faust via Gcc-patches
This patch updates the BPF back end to generate indirect calls via the 'call %reg' instruction when targetting xBPF. Additionally, the BPF ASM_SPEC is updated to pass along -mxbpf to gas, where it is now supported. 2020-09-03 David Faust gcc/ * config/bpf/bpf.h (ASM_SPEC): Pass -mxbp

[committed] bpf: cleanup missed refactor

2022-11-07 Thread David Faust via Gcc-patches
Commit 068baae1864 "bpf: add preserve_field_info builtin" factored out some repeated code to a new function maybe_make_core_relo (), but missed using it in one place. Clean that up. Regtested on bpf-unknown-none, pushed as obvious. gcc/ * config/bpf/bpf.cc (handle_attr_preserve): Use may

[PATCH] bpf: Use enum for resolved overloaded builtins

2022-11-07 Thread David Faust via Gcc-patches
Change several places in the eBPF backend dealing with overloaded built-in functions to consistently use the enum bpf_builtins type, rather than variously using integer constants or booleans. The result is eaiser to read and extend. Tested on bpf-unknown-none, no known regressions. OK to push? Th

[committed] bpf: avoid possible use of uninitialized variable

2022-11-15 Thread David Faust via Gcc-patches
Fix a maybe-uninitialized warning introduced in commit: 068baae1864 bpf: add preserve_field_info builtin Thanks to Jan-Benedict Glaw for pointing this out. Tested on bpf-unknown-none, committed as obvious. gcc/ * config/bpf/bpf.cc (bpf_expand_builtin): Avoid use of uninitialized

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

2022-05-27 Thread David Faust via Gcc-patches
;>>>>>> >>>>>>>> On 5/10/22 8:43 PM, Yonghong Song wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> On 5/6/22 2:18 PM, David Faust wrote: >>>>>>>>>> >>>>>>>>>> >>

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

2022-06-07 Thread David Faust via Gcc-patches
0/22 8:43 PM, Yonghong Song wrote: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 5/6/22 2:18 PM, David Faust wrote: >>>>>>>>>>>> >>>>>>>>>>>

[PATCH 1/9] dwarf: add dw_get_die_parent function

2022-06-07 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 29f32ec6939..9c61026bb34 1

[PATCH 0/9] Add debug_annotate attributes

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

[PATCH 2/9] include: Add new definitions

2022-06-07 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/9] c-family: Add debug_annotate attribute handlers

2022-06-07 Thread David Faust via Gcc-patches
This patch adds attribute handlers for two new attributes: "debug_annotate_decl" and "debug_annotate_type". Both attributes accept a single string argument, and are used to add arbitrary annotations to debug information generated for the decls or types to which they apply. gcc/c-family/ *

[PATCH 5/9] ctfc: pass through debug annotations to BTF

2022-06-07 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 7/9] btf: output decl_tag and type_tag records

2022-06-07 Thread David Faust via Gcc-patches
This patch updates btfout.cc to be aware of debug annotations, convert them to BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, and output them appropriately. gcc/ * btfout.cc (get_btf_kind): Handle TYPE_TAG and DECL_TAG kinds. (btf_calc_num_vbytes): Likewise. (btf_asm_typ

[PATCH 4/9] dwarf: generate annotation DIEs

2022-06-07 Thread David Faust via Gcc-patches
The "debug_annotate_decl" and "debug_annotate_type" attributes are handled by constructing DW_TAG_GNU_annotation DIEs. These DIEs are children of the declarations or types which they annotate, and convey the information via a string constant. gcc/ * dwarf2out.cc (gen_decl_annotation_dies)

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

2022-06-07 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 an internal-only CTF representation as appropriate and added to the compilation unit CTF container. gcc/ * dwarf2ctf.cc (handle_debug_annotations): New function.

[PATCH 9/9] testsuite: add debug annotation tests

2022-06-07 Thread David Faust via Gcc-patches
This patch adds tests for debug annotations, in BTF and in DWARF. gcc/testsuite/ * 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:

[PATCH 8/9] doc: document new attributes

2022-06-07 Thread David Faust via Gcc-patches
gcc/ * doc/extend.texi (Common Function Attributes): Document debug_annotate_decl attribute. (Common Variable Attributes): Likewise. (Common Type Attributes): Likewise. Also document debug_annotate_type attribute. --- gcc/doc/extend.texi | 106 +

Re: [PATCH 0/9] Add debug_annotate attributes

2022-06-15 Thread David Faust via Gcc-patches
On 6/14/22 22:53, Yonghong Song wrote: > > > On 6/7/22 2:43 PM, David Faust wrote: >> Hello, >> >> This patch series adds support for: >> >> - Two new C-language-level attributes that allow to associate (to "annotate" >> or >>to "tag") particular declarations and types with arbitrary stri

[committed] MAINTAINERS: Add myself for write after approval

2021-04-23 Thread David Faust via Gcc-patches
ChangeLog: 2021-04-23 David Faust * MAINTAINERS (Write After Approval): Add myself. --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index db25583b37b..c589c0b30ac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -387,6 +387,7 @@ Doug Evans

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

2021-04-23 Thread David Faust via Gcc-patches
Hi YiFei, I've just checked in both patches to master and GCC 10 on your behalf. Thanks! 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 >> .lo

[PATCH] BTF: Support for BTF_KIND_FLOAT

2021-07-01 Thread David Faust via Gcc-patches
Add BTF_KIND_FLOAT, a new BTF type kind which has recently stabilized in the linux kernel [1]. This kind is used for encoding floating point types, and is of particular use when generating BTF for some s390 arch-specific kernel headers. Also update some BTF tests which previously used floating poi

[PATCH 0/3] btf: fix BTF for extern items [PR106773]

2022-12-07 Thread David Faust via Gcc-patches
Hi, This series fixes the issues reported in target/PR106773. I decided to split it into three commits, as there are ultimately three distinct issues and fixes. See each patch for details. Tested on bpf-unknown-none and x86_64-linux-gnu, no known regressions. OK to push? Thanks. David Faust (3)

[PATCH 2/3] btf: fix 'extern const void' variables [PR106773]

2022-12-07 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. In addition, the internal DWARF representation from which BTF is produced does not gen

[PATCH 3/3] btf: correct generation for extern funcs [PR106773]

2022-12-07 Thread David Faust via Gcc-patches
The eBPF loader expects to find entries for functions declared as extern in the corresponding BTF_KIND_DATASEC record, but we were not generating these entries. This patch adds support for the 'extern' linkage of function types in BTF, and creates entries for for them BTF_KIND_DATASEC records as n

[PATCH 1/3] btf: add 'extern' linkage for variables [PR106773]

2022-12-07 Thread David Faust via Gcc-patches
Add support for the 'extern' linkage value for BTF_KIND_VAR records, which is used for variables declared as extern in the source file. PR target/106773 gcc/ * btfout.cc (BTF_LINKAGE_STATIC): New define. (BTF_LINKAGE_GLOBAL): Likewise. (BTF_LINKAGE_EXTERN): Likewi

[PATCH] bpf: add define_insn for bswap

2022-12-08 Thread David Faust via Gcc-patches
The eBPF architecture provides 'end[be,le]' instructions for endianness swapping. Add a define_insn for bswap2 to use them instaed of falling back on a libcall. Tested on bpf-unknown-none, no known regressions. OK to commit? Thanks gcc/ * config/bpf/bpf.md (bswap2): New define_insn. gc

Re: [PATCH] Testsuite: Add btf-dataset option for RISC-V.

2022-01-03 Thread David Faust via Gcc-patches
On 1/3/22 08:43, Indu Bhagat wrote: On 12/30/21 8:59 AM, Palmer Dabbelt wrote: On Thu, 30 Dec 2021 08:28:34 PST (-0800), gcc-patches@gcc.gnu.org wrote: On 12/29/2021 8:02 PM, jiawei wrote: Add -msmall-data-limit option to put global and static data into right section and generate 'btt_inf

<    1   2