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

2022-05-24 Thread David Faust via Gcc-patches
On 5/24/22 04:07, Jose E. Marchesi wrote: > >> On 5/11/22 11:44 AM, David Faust wrote: >>> >>> On 5/10/22 22:05, Yonghong Song wrote: >>>> >>>> >>>> On 5/10/22 8:43 PM, Yonghong Song wrote: >>>>> >>>>&g

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

2022-05-24 Thread David Faust via Gcc-patches
On 5/24/22 09:03, Yonghong Song wrote: > > > On 5/24/22 8:53 AM, David Faust wrote: >> >> >> On 5/24/22 04:07, Jose E. Marchesi wrote: >>> >>>> On 5/11/22 11:44 AM, David Faust wrote: >>>>> >>>>> On 5/10/22 22:0

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

2021-09-07 Thread David Faust via Gcc-patches
ore requires BTF generation. For cases where BTF information is desired but CO-RE is not important, it can be disabled with -mno-core. David Faust (7): dwarf: externalize lookup_type_die ctfc: externalize ctf_dtd_lookup ctfc: add function to lookup CTF ID of a TREE type btf: expose get_btf_i

[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
. Enabled for CPU v3 and above. Negative versions of -mjmpext, -mjmp32, and -malu32 options are also supported. David Faust (3): bpf: add -mcpu and related feature options bpf testsuite: add tests for new feature options doc: document BPF -mcpu and related options gcc/config/bpf/bpf-opts.h

[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 >>>

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 p

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 targ

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 mis

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

2022-12-13 Thread David Faust via Gcc-patches
feedback. ] 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

[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_S

[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/26/22 00:29, Yonghong Song wrote: > > > On 5/24/22 10:04 AM, David Faust wrote: >> >> >> On 5/24/22 09:03, Yonghong Song wrote: >>> >>> >>> On 5/24/22 8:53 AM, David Faust wrote: >>>> >>>> >>>> On

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

2022-06-07 Thread David Faust via Gcc-patches
On 6/2/22 19:04, Yonghong Song wrote: > > > On 5/27/22 12:56 PM, David Faust wrote: >> >> >> On 5/26/22 00:29, Yonghong Song wrote: >>> >>> >>> On 5/24/22 10:04 AM, David Faust wrote: >>>> >>>> >>>> On 5

[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
: int <1><64>: Abbrev Number: 0 In the case of BTF, the annotations are recorded in two type kinds recently added to the BTF specification: BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG. The above example declaration prodcues the following BTF information: [1] INT 'int' size=4

[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 >>

[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
uld be sufficiently correct. Yes, I would agree that the test case can be adapted as mentioned. The purpose of the test case is to check that BTF is correctly generated for whatever section the symbols end up in. Adding David Faust in CC for ACK. Thanks Indu I concur. This looks like a goo

<    1   2   3