official-gcc.git
5 days agomiddle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR
Richard Biener [Tue, 16 Apr 2024 12:05:35 +0000 (16 14:05 +0200)]
middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR

Currently we expand POINTER_DIFF_EXPR using subv_optab when -ftrapv
(but -fsanitize=undefined does nothing).  That's not consistent
with the behavior of POINTER_PLUS_EXPR which never uses addv_optab
with -ftrapv.  Both are because of the way we select whether to use
the trapping or the non-trapping optab - we look at the result type
of the expression and check

  trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);

the bugreport correctly complains that -ftrapv affects pointer
subtraction (there's no -ftrapv-pointer).  Now that we have
POINTER_DIFF_EXPR we can honor that appropriately.

The patch moves both POINTER_DIFF_EXPR and POINTER_PLUS_EXPR
handling so they will never consider trapping (or saturating)
optabs.

PR middle-end/13421
* optabs-tree.cc (optab_for_tree_code): Do not consider
{add,sub}v or {us,ss}{add,sub} optabs for POINTER_DIFF_EXPR
or POINTER_PLUS_EXPR.

5 days agogimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument [PR114876]
Jakub Jelinek [Tue, 30 Apr 2024 09:22:32 +0000 (30 11:22 +0200)]
gimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument [PR114876]

Seems when Martin S. implemented this, he coded there strict reading
of the standard, which said that %lc with (wint_t) 0 argument is handled
as wchar_t[2] temp = { arg, 0 }; %ls with temp arg and so shouldn't print
any values.  But, most of the libc implementations actually handled that
case like %c with '\0' argument, adding a single NUL character, the only
known exception is musl.
Recently, C23 changed this in response to GB-141 and POSIX in
https://austingroupbugs.net/view.php?id=1647
so that it should have the same behavior as %c with '\0'.

Because there is implementation divergence, the following patch uses
a range rather than hardcoding it to all 1s (i.e. the %c behavior),
though the likely case is still 1 (forward looking plus most of
implementations).
The res.knownrange = true; assignment removed is redundant due to
the same assignment done unconditionally before the if statement,
rest is formatting fixes.

I don't think the min >= 0 && min < 128 case is right either, I'd think
it should be min >= 0 && max < 128, otherwise it is just some possible
inputs are (maybe) ASCII and there can be others, but this code is a total
mess anyway, with the min, max, likely (somewhere in [min, max]?) and then
unlikely possibly larger than max, dunno, perhaps for at least some chars
in the ASCII range the likely case could be for the ascii case; so perhaps
just the one_2_one_ascii shouldn't set max to 1 and mayfail should be true
for max >= 128.  Anyway, didn't feel I should touch that right now.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/114876
* gimple-ssa-sprintf.cc (format_character): For min == 0 && max == 0,
set max, likely and unlikely members to 1 rather than 0.  Remove
useless res.knownrange = true;.  Formatting fixes.

* gcc.dg/pr114876.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust expected
diagnostics.

5 days agoFix pretty printers regexp for GDB output
Christophe Lyon [Thu, 25 Jan 2024 15:43:56 +0000 (25 15:43 +0000)]
Fix pretty printers regexp for GDB output

GDB emits end of lines as \r\n, we currently match any >0 number of
either \n or \r, possibly leading to mismatches under racy conditions.

I noticed this while running the GCC testsuite using the equivalent of
GDB's READ1 feature [1] which helps detecting bufferization issues.

We try to match
\n$1 = empty std::tuple\r

against {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} which fails because
of the leading \n (which was left in the buffer after the previous
"skipping" pattern matched the preceding \r).

This patch accepts any number of leading \n and/or \r in the "got" clause.

Also take this opportunity to quote \r and \r in the logs, to make
debugging such issues easier.

Tested on aarch64-linux-gnu.

[1] https//github.com/bminor/binutils-gdb/blob/master/gdb/testsuite/README#L269

2024-01-24  Christophe Lyon  <christophe.lyon@linaro.org>

libstdc++-v3/
* testsuite/lib/gdb-test.exp (gdb-test): Fix regexp.  Quote
newlines in logs.

5 days agovect: Adjust vect_transform_reduction assertion [PR114883]
Jakub Jelinek [Tue, 30 Apr 2024 08:11:47 +0000 (30 10:11 +0200)]
vect: Adjust vect_transform_reduction assertion [PR114883]

The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are
commutative conditional binary operations like ADD/MUL/AND/IOR/XOR,
and can be handled just fine.
In particular, we emit
        vminpd  %zmm3, %zmm5, %zmm0{%k2}
        vminpd  %zmm0, %zmm3, %zmm5{%k1}
and
        vmaxpd  %zmm3, %zmm5, %zmm0{%k2}
        vmaxpd  %zmm0, %zmm3, %zmm5{%k1}
in the vectorized loops of the first and second subroutine.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>
    Hongtao Liu  <hongtao.liu@intel.com>

PR tree-optimization/114883
* tree-vect-loop.cc (vect_transform_reduction): Allow IFN_COND_MIN and
IFN_COND_MAX in the assert.

* gfortran.dg/pr114883.f90: New test.

5 days agolibgcc: Do use weakrefs for glibc 2.34 on GNU Hurd
Jakub Jelinek [Tue, 30 Apr 2024 07:00:07 +0000 (30 09:00 +0200)]
libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd

On Mon, Apr 29, 2024 at 01:44:24PM +0000, Joseph Myers wrote:
> > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> > dummy shared library with just some symbol versions for compatibility, but
> > all the pthread_* APIs are in libc.so.6).
>
> I suspect this has caused link failures in the glibc testsuite for Hurd,
> which still has separate libpthread.
>
> https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

So like this then?

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

* gthr.h (GTHREAD_USE_WEAK): Don't redefine to 0 for glibc 2.34+
on GNU Hurd.

5 days agolibcpp: Adjust __STDC_VERSION__ for C23
Jakub Jelinek [Tue, 30 Apr 2024 06:58:39 +0000 (30 08:58 +0200)]
libcpp: Adjust __STDC_VERSION__ for C23

While the C23 standard isn't officially release yet,
in 2011 we've changed __STDC_VERSION__ value for C11 already
in the month in which the new __STDC_VERSION__ value has been
finalized, so we want to change this now or wait
until we implement all the C23 features?

Note, seems Clang up to 17 also used 202000L for -std=c2x but
Clang 18+ uses 202311L as specified in the latest C23 drafts.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

* init.cc (cpp_init_builtins): Change __STDC_VERSION__
for C23 from 202000L to 202311L.

* doc/cpp.texi (__STDC_VERSION__): Document 202311L value
for -std=c23/-std=gnu23.

5 days agoc++: Implement C++26 P0609R3 - Attributes for Structured Bindings [PR114456]
Jakub Jelinek [Tue, 30 Apr 2024 06:57:15 +0000 (30 08:57 +0200)]
c++: Implement C++26 P0609R3 - Attributes for Structured Bindings [PR114456]

The following patch implements the P0609R3 paper; we build the
VAR_DECLs for the structured binding identifiers early, so all we need
IMHO is just to parse the attributed identifier list and pass the attributes
to the VAR_DECL creation.

The paper mentions maybe_unused and gnu::nonstring attributes as examples
where they can be useful.  Not sure about either of them.
For maybe_unused, the thing is that both GCC and clang already don't
diagnose maybe unused for the structured binding identifiers, because it
would be a false positive too often; and there is no easy way to find out
if a structured binding has been written with the P0609R3 paper in mind or
not (maybe we could turn it on if in the structured binding is any
attribute, even if just [[]] and record that as a flag on the whole
underlying decl, so that we'd diagnose
  auto [a, b, c[[]]] = d;
  // use a, c but not b
but not
  auto [e, f, g] = d;
  // use a, c but not b
).  For gnu::nonstring, the issue is that we currently don't allow the
attribute on references to char * or references to char[], just on
char */char[].  I've filed a PR for that.

The first testcase in the patch tests it on [[]] and [[maybe_unused]],
just whether it is parsed properly, second on gnu::deprecated, which
works.  Haven't used deprecated attribute because the paper said that
attribute is for further investigation.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/114456
gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): Predefine
__cpp_structured_bindings for C++26 to 202403L rather than
201606L.
gcc/cp/
* parser.cc (cp_parser_decomposition_declaration): Implement C++26
P0609R3 - Attributes for Structured Bindings.  Parse attributed
identifier lists for structured binding declarations, pass the
attributes to start_decl.
gcc/testsuite/
* g++.dg/cpp26/decomp1.C: New test.
* g++.dg/cpp26/decomp2.C: New test.
* g++.dg/cpp26/feat-cxx26.C (__cpp_structured_bindings): Expect
202403 rather than 201606.

5 days agomiddle-end/114734 - wrong code with expand_call_mem_ref
Richard Biener [Fri, 26 Apr 2024 13:47:13 +0000 (26 15:47 +0200)]
middle-end/114734 - wrong code with expand_call_mem_ref

When expand_call_mem_ref looks at the definition of the address
argument to eventually expand a &TARGET_MEM_REF argument together
with a masked load it fails to honor constraints imposed by SSA
coalescing decisions.  The following fixes this.

PR middle-end/114734
* internal-fn.cc (expand_call_mem_ref): Use
get_gimple_for_ssa_name to get at the def stmt of the address
argument to honor SSA coalescing constraints.

5 days agoc++: Fix instantiation of imported temploid friends [PR114275]
Nathaniel Shead [Mon, 29 Apr 2024 07:00:13 +0000 (29 17:00 +1000)]
c++: Fix instantiation of imported temploid friends [PR114275]

This patch fixes a number of issues with the handling of temploid friend
declarations.

The primary issue is that instantiations of friend declarations should
attach the declaration to the same module as the befriending class, by
[module.unit] p7.1 and [temp.friend] p2; this could be a different
module from the current TU, and so needs special handling.

The other main issue here is that we can't assume that just because name
lookup didn't find a definition for a hidden class template, that it
doesn't exist at all: it could be a non-exported entity that we've
nevertheless streamed in from an imported module.  We need to ensure
that when instantiating template friend classes that we return the same
TEMPLATE_DECL that we got from our imports, otherwise we will get later
issues with 'duplicate_decls' (rightfully) complaining that they're
different when trying to merge.

This doesn't appear necessary for function templates due to the existing
name lookup handling already finding these hidden declarations.

PR c++/105320
PR c++/114275

gcc/cp/ChangeLog:

* cp-tree.h (propagate_defining_module): Declare.
(lookup_imported_hidden_friend): Declare.
* decl.cc (duplicate_decls): Also check if hidden decls can be
redeclared in this module.
* module.cc (imported_temploid_friends): New.
(init_modules): Initialize it.
(trees_out::decl_value): Write it; don't consider imported
temploid friends as attached to a module.
(trees_in::decl_value): Read it.
(get_originating_module_decl): Follow the owning decl for an
imported temploid friend.
(propagate_defining_module): New.
* name-lookup.cc (get_mergeable_namespace_binding): New.
(lookup_imported_hidden_friend): New.
* pt.cc (tsubst_friend_function): Propagate defining module for
new friend functions.
(tsubst_friend_class): Lookup imported hidden friends.  Check
for valid module attachment of existing names.  Propagate
defining module for new classes.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tpl-friend-10_a.C: New test.
* g++.dg/modules/tpl-friend-10_b.C: New test.
* g++.dg/modules/tpl-friend-10_c.C: New test.
* g++.dg/modules/tpl-friend-10_d.C: New test.
* g++.dg/modules/tpl-friend-11_a.C: New test.
* g++.dg/modules/tpl-friend-11_b.C: New test.
* g++.dg/modules/tpl-friend-12_a.C: New test.
* g++.dg/modules/tpl-friend-12_b.C: New test.
* g++.dg/modules/tpl-friend-12_c.C: New test.
* g++.dg/modules/tpl-friend-12_d.C: New test.
* g++.dg/modules/tpl-friend-12_e.C: New test.
* g++.dg/modules/tpl-friend-12_f.C: New test.
* g++.dg/modules/tpl-friend-13_a.C: New test.
* g++.dg/modules/tpl-friend-13_b.C: New test.
* g++.dg/modules/tpl-friend-13_c.C: New test.
* g++.dg/modules/tpl-friend-13_d.C: New test.
* g++.dg/modules/tpl-friend-13_e.C: New test.
* g++.dg/modules/tpl-friend-13_f.C: New test.
* g++.dg/modules/tpl-friend-13_g.C: New test.
* g++.dg/modules/tpl-friend-14_a.C: New test.
* g++.dg/modules/tpl-friend-14_b.C: New test.
* g++.dg/modules/tpl-friend-14_c.C: New test.
* g++.dg/modules/tpl-friend-14_d.C: New test.
* g++.dg/modules/tpl-friend-9.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
5 days agoc++: Standardise errors for module_may_redeclare
Nathaniel Shead [Sun, 14 Apr 2024 13:03:11 +0000 (14 23:03 +1000)]
c++: Standardise errors for module_may_redeclare

Currently different places calling 'module_may_redeclare' all emit very
similar but slightly different error messages, and handle different
kinds of declarations differently.  This patch makes the function
perform its own error messages so that they're all in one place, and
prepares it for use with temploid friends.

gcc/cp/ChangeLog:

* cp-tree.h (module_may_redeclare): Add default parameter.
* decl.cc (duplicate_decls): Don't emit errors for failed
module_may_redeclare.
(xref_tag): Likewise.
(start_enum): Likewise.
* semantics.cc (begin_class_definition): Likewise.
* module.cc (module_may_redeclare): Clean up logic. Emit error
messages on failure.

gcc/testsuite/ChangeLog:

* g++.dg/modules/enum-12.C: Update error message.
* g++.dg/modules/friend-5_b.C: Likewise.
* g++.dg/modules/shadow-1_b.C: Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
5 days agoc++/modules: imported spec befriending class tmpl [PR114889]
Patrick Palka [Tue, 30 Apr 2024 01:27:59 +0000 (29 21:27 -0400)]
c++/modules: imported spec befriending class tmpl [PR114889]

When adding to CLASSTYPE_BEFRIENDING_CLASSES as part of installing an
imported class definition, we need to look through TEMPLATE_DECL like
make_friend_class does.

Otherwise in the below testcase we won't add _Hashtable<int, int> to
CLASSTYPE_BEFRIENDING_CLASSES of _Map_base, which leads to a bogus
access check failure for _M_hash_code.

PR c++/114889

gcc/cp/ChangeLog:

* module.cc (trees_in::read_class_def): Look through
TEMPLATE_DECL when adding to CLASSTYPE_BEFRIENDING_CLASSES.

gcc/testsuite/ChangeLog:

* g++.dg/modules/friend-8_a.H: New test.
* g++.dg/modules/friend-8_b.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 days agoc++: ICE with templated sizeof(E1) / sizeof(E2) [PR114888]
Patrick Palka [Tue, 30 Apr 2024 01:14:18 +0000 (29 21:14 -0400)]
c++: ICE with templated sizeof(E1) / sizeof(E2) [PR114888]

In the sizeof / sizeof operator expression handling we're missing
a dependence check for the second operand.

PR c++/114888

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op) <case *_DIV_*>: Add missing
dependence check for the second sizeof operand.

gcc/testsuite/ChangeLog:

* g++.dg/template/sizeof19.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 days agoDaily bump.
GCC Administrator [Tue, 30 Apr 2024 00:17:28 +0000 (30 00:17 +0000)]
Daily bump.

5 days agoRevert "decay vect tests from run to link for pr95401"
Alexandre Oliva [Mon, 29 Apr 2024 23:33:37 +0000 (29 20:33 -0300)]
Revert "decay vect tests from run to link for pr95401"

This reverts commit 05d83334d5bbeae01d71080f1da524810d6740d9.

5 days agoruntime: dump registers on Solaris
Ian Lance Taylor [Sun, 28 Apr 2024 20:30:39 +0000 (28 13:30 -0700)]
runtime: dump registers on Solaris

Patch by Rainer Orth <ro@gcc.gnu.org>.

Fixes PR go/106813

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/581724

5 days agoruntime: use <stdbool.h>
Ian Lance Taylor [Sun, 28 Apr 2024 16:57:35 +0000 (28 09:57 -0700)]
runtime: use <stdbool.h>

<stdbool.h> has been available since C99. Use it rather than defining
our own boolean type and values.

Fixes https://gcc.gnu.org/PR114875

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/582275

6 days agoFortran: add SELECTED_LOGICAL_KIND
Francois-Xavier Coudert [Tue, 19 Mar 2024 14:09:22 +0000 (19 15:09 +0100)]
Fortran: add SELECTED_LOGICAL_KIND

gcc/fortran/ChangeLog:
* expr.cc (check_transformational): Add SELECTED_LOGICAL_KIND
to allowed functions for Fortran 2023.
* gfortran.h (GFC_ISYM_SL_KIND): New.
* gfortran.texi: Mention SELECTED_LOGICAL_KIND.
* intrinsic.cc (add_functions): Add SELECTED_LOGICAL_KIND.
(gfc_intrinsic_func_interface): Allow it in initialization
expressions.
* intrinsic.h (gfc_simplify_selected_logical_kind): New proto.
* intrinsic.texi: Add SELECTED_LOGICAL_KIND.
* simplify.cc (gfc_simplify_selected_logical_kind): New
function.
* trans-decl.cc (gfc_build_intrinsic_function_decls): Initialize
gfor_fndecl_sl_kind.
* trans-intrinsic.cc (gfc_conv_intrinsic_sl_kind): New function.
(gfc_conv_intrinsic_function): Call it for GFC_ISYM_SL_KIND.
* trans.h (gfor_fndecl_sl_kind): New symbol.

gcc/testsuite/ChangeLog:

* gfortran.dg/selected_logical_kind_1.f90: New test.
* gfortran.dg/selected_logical_kind_2.f90: New test.
* gfortran.dg/selected_logical_kind_3.f90: New test.
* gfortran.dg/selected_logical_kind_4.f90: New test.

libgfortran/ChangeLog:

* gfortran.map: Add _gfortran_selected_logical_kind.
* intrinsics/selected_int_kind.f90: Add SELECTED_LOGICAL_KIND.

6 days agoFortran: add F2023 ISO_FORTRAN_ENV named constants
Francois-Xavier Coudert [Tue, 19 Mar 2024 13:16:38 +0000 (19 14:16 +0100)]
Fortran: add F2023 ISO_FORTRAN_ENV named constants

gcc/fortran/ChangeLog:

* iso-fortran-env.def: Add logical{8,16,32,64} and
real16 named constants.

gcc/testsuite/ChangeLog:

* gfortran.dg/iso_fortran_env_8.f90: New test.
* gfortran.dg/iso_fortran_env_9.f90: New test.

6 days agolibstdc++: Update Solaris baselines for GCC 14.0
Rainer Orth [Mon, 29 Apr 2024 12:33:46 +0000 (29 14:33 +0200)]
libstdc++: Update Solaris baselines for GCC 14.0

This patch updates the Solaris baselines for the GLIBCXX_3.4.33 version
added in GCC 14.0.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (32 and 64-bit
each), together with the GLIBCXX_3.4.32 update, on both gcc-14 branch
and trunk.

2024-04-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

(cherry picked from commit 330c04dc530e6faa91c3442cdd91fb1df917fd97)

6 days agolibstdc++: Update Solaris baselines for GCC 13.2
Rainer Orth [Mon, 29 Apr 2024 12:30:35 +0000 (29 14:30 +0200)]
libstdc++: Update Solaris baselines for GCC 13.2

This patch updates the Solaris baselines for the GLIBCXX_3.4.32 version
added in GCC 13.2.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (32 and 64-bit
each) on the gcc-13 branch and (together with the GLIBCXX_3.4.33 update)
on both gcc-14 branch and trunk.

2024-04-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

(cherry picked from commit 3e1ca512848994950cc0641986b6ec337df5765f)

6 days agoRISC-V: Refine the condition for add additional vars in RVV cost model
demin.han [Tue, 26 Mar 2024 08:52:12 +0000 (26 16:52 +0800)]
RISC-V: Refine the condition for add additional vars in RVV cost model

The adjacent_dr_p is sufficient and unnecessary condition for contiguous access.
So unnecessary live-ranges are added and result in smaller LMUL.

This patch uses MEMORY_ACCESS_TYPE as condition and constrains segment
load/store.

Tested on RV64 and no regression.

PR target/114506

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (non_contiguous_memory_access_p): Rename
(need_additional_vector_vars_p): Rename and refine condition

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/pr114506.c: New test.

Signed-off-by: demin.han <demin.han@starfivetech.com>
6 days agoFortran: Fix regression caused by r14-9752 [PR114959]
Paul Thomas [Mon, 29 Apr 2024 10:52:11 +0000 (29 11:52 +0100)]
Fortran: Fix regression caused by r14-9752 [PR114959]

2024-04-29  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/114959
* trans-expr.cc (gfc_trans_class_init_assign): Return NULL_TREE
if the default initializer has all NULL fields. Guard this
by a requirement that the code not be EXEC_INIT_ASSIGN and that
the object be an INTENT_OUT dummy.
* trans-stmt.cc (gfc_trans_allocate): Change the initializer
code for allocate with mold to EXEC_ALLOCATE to allow an
initializer with all NULL fields.

gcc/testsuite/
PR fortran/114959
* gfortran.dg/pr114959.f90: New test.

6 days agoRISC-V: Fix ICE for legitimize move on subreg const_poly_int [PR114885]
Pan Li [Sat, 27 Apr 2024 12:24:04 +0000 (27 20:24 +0800)]
RISC-V: Fix ICE for legitimize move on subreg const_poly_int [PR114885]

When we build with isl, there will be a ICE for graphite in both
the c/c++ and fortran.  The legitimize move cannot take care of
below rtl.

(set (subreg:DI (reg:TI 237) 8) (subreg:DI (const_poly_int:TI [4, 2]) 8))

Then we will have ice similar to below:

internal compiler error: in extract_insn, at recog.cc:2812.

This patch would like to take care of the above rtl.  Given the value of
const_poly_int can hardly excceed the max of int64,  we can simply
consider the highest 8 bytes of TImode is zero and then set the dest
to (const_int 0).

The below test cases are fixed by this PATCH.

C:
FAIL: gcc.dg/graphite/pr111878.c (internal compiler error: in
extract_insn, at recog.cc:2812)
FAIL: gcc.dg/graphite/pr111878.c (test for excess errors)

Fortran:
FAIL: gfortran.dg/graphite/vect-pr40979.f90   -O  (internal compiler
error: in extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr29832.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (internal
compiler error: in extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr29581.f90   -O3 -g  (test for excess
errors)
FAIL: gfortran.dg/graphite/pr14741.f90   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/pr29581.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: gfortran.dg/graphite/vect-pr40979.f90   -O  (test for excess
errors)
FAIL: gfortran.dg/graphite/id-27.f90   -O  (internal compiler error: in
extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr29832.f90   -O3 -g  (internal compiler
error: in extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr29832.f90   -O3 -g  (test for excess
errors)
FAIL: gfortran.dg/graphite/id-27.f90   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/pr29832.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: gfortran.dg/graphite/pr29581.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (internal
compiler error: in extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr14741.f90   -O  (internal compiler error:
in extract_insn, at recog.cc:2812)
FAIL: gfortran.dg/graphite/pr29581.f90   -O3 -g  (internal compiler
error: in extract_insn, at recog.cc:2812)

The below test suites are passed for this patch:
* The rv64gcv fully regression test.
* The rv64gc fully regression test.

Try to write some RTL code for test but not works well according to
existing test cases.  Thus, take above as test cases.  Please note
graphite require the gcc build with isl.

PR target/114885

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_legitimize_subreg_const_poly_move): New
func impl to take care of (const_int_poly:TI 8).
(riscv_legitimize_move): Handle subreg is const_int_poly,

Signed-off-by: Pan Li <pan2.li@intel.com>
6 days agoRISC-V: Fix parsing of Zic* extensions
Christoph Müllner [Sun, 28 Apr 2024 22:46:06 +0000 (29 00:46 +0200)]
RISC-V: Fix parsing of Zic* extensions

The extension parsing table entries for a range of Zic* extensions
does not match the mask definition in riscv.opt.
This results in broken TARGET_ZIC* macros, because the values of
riscv_zi_subext and riscv_zicmo_subext are set wrong.

This patch fixes this by moving Zic64b into riscv_zicmo_subext
and all other affected Zic* extensions to riscv_zi_subext.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Move ziccamoa, ziccif,
zicclsm, and ziccrse into riscv_zi_subext.
* config/riscv/riscv.opt: Define MASK_ZIC64B for
riscv_ziccmo_subext.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
6 days agoMIPS: Add MIN/MAX.fmt instructions support for MIPS R6
Jie Mei [Sun, 28 Apr 2024 08:57:31 +0000 (28 16:57 +0800)]
MIPS: Add MIN/MAX.fmt instructions support for MIPS R6

This patch adds the smin/smax RTL mode for the
min/max.fmt instructions.

Also, since the min/max.fmt instrucions applies to the
IEEE 754-2008 "minNum" and "maxNum" operations, this
patch also provides the new "fmin<mode>3" and
"fmax<mode>3" modes.

gcc/ChangeLog:

* config/mips/i6400.md (i6400_fpu_minmax): New
define_insn_reservation.
* config/mips/mips.h (ISA_HAS_FMIN_FMAX): Define new macro.
* config/mips/mips.md (UNSPEC_FMIN): New unspec.
(UNSPEC_FMAX): Same as above.
(type): Add fminmax.
(smin<mode>3): Generates MIN.fmt instructions.
(smax<mode>3): Generates MAX.fmt instructions.
(fmin<mode>3): Generates MIN.fmt instructions.
(fmax<mode>3): Generates MAX.fmt instructions.
* config/mips/p6600.md (p6600_fpu_fabs): Include fminmax
type.

gcc/testsuite/ChangeLog:

* gcc.target/mips/mips-minmax1.c: New test for MIPS R6.
* gcc.target/mips/mips-minmax2.c: Same as above.

6 days agoDaily bump.
GCC Administrator [Mon, 29 Apr 2024 00:17:54 +0000 (29 00:17 +0000)]
Daily bump.

6 days agoCallers of irange_bitmask must normalize value/mask pairs.
Aldy Hernandez [Tue, 23 Apr 2024 08:12:56 +0000 (23 10:12 +0200)]
Callers of irange_bitmask must normalize value/mask pairs.

As per the documentation, irange_bitmask must have the unknown bits in
the mask set to 0 in the value field.  Even though we say we must have
normalized value/mask bits, we don't enforce it, opting to normalize
on the fly in union and intersect.  Avoiding this lazy enforcing as
well as the extra saving/restoring involved in returning the changed
status, gives us a performance increase of 1.25% for VRP and 1.51% for
ipa-CP.

gcc/ChangeLog:

* tree-ssa-ccp.cc (ccp_finalize): Normalize before calling
set_bitmask.
* value-range.cc (irange::intersect_bitmask): Calculate changed
irange_bitmask bits on our own.
(irange::union_bitmask): Same.
(irange_bitmask::verify_mask): Verify that bits are normalized.
* value-range.h (irange_bitmask::union_): Do not normalize.
Remove return value.
(irange_bitmask::intersect): Same.

6 days agoRemove range_zero and range_nonzero.
Aldy Hernandez [Wed, 20 Mar 2024 04:51:55 +0000 (20 05:51 +0100)]
Remove range_zero and range_nonzero.

Remove legacy range_zero and range_nonzero as they return by value,
which make it not work in a separate irange and prange world.  Also,
we already have set_zero and set_nonzero methods in vrange.

gcc/ChangeLog:

* range-op-ptr.cc (pointer_plus_operator::wi_fold): Use method
range setters instead of out of line functions.
(pointer_min_max_operator::wi_fold): Same.
(pointer_and_operator::wi_fold): Same.
(pointer_or_operator::wi_fold): Same.
* range-op.cc (operator_negate::fold_range): Same.
(operator_addr_expr::fold_range): Same.
(range_op_cast_tests): Same.
* range.cc (range_zero): Remove.
(range_nonzero): Remove.
* range.h (range_zero): Remove.
(range_nonzero): Remove.
* value-range.cc (range_tests_misc): Use method instead of out of
line function.

6 days agoMove print_irange_* out of vrange_printer class.
Aldy Hernandez [Tue, 19 Mar 2024 19:26:27 +0000 (19 20:26 +0100)]
Move print_irange_* out of vrange_printer class.

Move some code out of the irange pretty printers so it can be shared
with pointers.

gcc/ChangeLog:

* value-range-pretty-print.cc (print_int_bound): New.
(print_irange_bitmasks): New.
(vrange_printer::print_irange_bound): Remove.
(vrange_printer::print_irange_bitmasks): Remove.
* value-range-pretty-print.h: Remove print_irange_bitmasks and
print_irange_bound

6 days agoAccept any vrange in range_includes_zero_p.
Aldy Hernandez [Tue, 19 Mar 2024 17:29:21 +0000 (19 18:29 +0100)]
Accept any vrange in range_includes_zero_p.

Accept a vrange, as this will be used for either integers or pointers.

gcc/ChangeLog:

* value-range.h (range_includes_zero_p): Accept vrange.

6 days agoMake some integer specific ranges generic Value_Range's.
Aldy Hernandez [Tue, 19 Mar 2024 17:22:08 +0000 (19 18:22 +0100)]
Make some integer specific ranges generic Value_Range's.

There are some irange uses that should be Value_Range, because they
can be either integers or pointers.  This will become a problem when
prange comes live.

gcc/ChangeLog:

* tree-ssa-loop-split.cc (split_at_bb_p): Make int_range a Value_Range.
* tree-ssa-strlen.cc (get_range): Same.
* value-query.cc (range_query::get_tree_range):  Handle both
integers and pointers.
* vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Make
r0 and r1 Value_Range's.

6 days agoMove get_bitmask_from_range out of irange class.
Aldy Hernandez [Tue, 19 Mar 2024 17:04:55 +0000 (19 18:04 +0100)]
Move get_bitmask_from_range out of irange class.

prange will also have bitmasks, so it will need to use get_bitmask_from_range.

gcc/ChangeLog:

* value-range.cc (get_bitmask_from_range): Move out of irange class.
(irange::get_bitmask): Call function instead of internal method.
* value-range.h (class irange): Remove get_bitmask_from_range.

6 days agoAccept a vrange in get_legacy_range.
Aldy Hernandez [Tue, 19 Mar 2024 16:17:53 +0000 (19 17:17 +0100)]
Accept a vrange in get_legacy_range.

In preparation for prange, make get_legacy_range take a generic
vrange, not just an irange.

gcc/ChangeLog:

* value-range.cc (get_legacy_range): Make static and add another
version of get_legacy_range that takes a vrange.
* value-range.h (class irange): Remove unnecessary friendship with
get_legacy_range.
(get_legacy_range): Accept a vrange.

6 days agoVerify that reading back from vrange_storage doesn't drop bits.
Aldy Hernandez [Tue, 19 Mar 2024 15:35:41 +0000 (19 16:35 +0100)]
Verify that reading back from vrange_storage doesn't drop bits.

We have a sanity check in the irange storage code to make sure that
reading back a cache entry we have just written to yields exactly the
same range.  There's no need to do this only for integers.  This patch
moves the code to a more generic place.

However, doing so tickles a latent bug in the frange code where a
range is being pessimized from [0.0, 1.0] to [-0.0, 1.0].  Exclude
checking frange's until this bug is fixed.

gcc/ChangeLog:

* value-range-storage.cc (irange_storage::set_irange): Move
verification code from here...
(vrange_storage::set_vrange): ...to here.

6 days agoChange range_includes_zero_p argument to a reference.
Aldy Hernandez [Tue, 19 Mar 2024 15:33:47 +0000 (19 16:33 +0100)]
Change range_includes_zero_p argument to a reference.

Make range_includes_zero_p take an argument instead of a pointer for
consistency in the range-op code.

gcc/ChangeLog:

* gimple-range-op.cc (cfn_clz::fold_range): Change
range_includes_zero_p argument to a reference.
(cfn_ctz::fold_range): Same.
* range-op.cc (operator_plus::lhs_op1_relation): Same.
* value-range.h (range_includes_zero_p): Same.

6 days agoMake fold_cond_with_ops use a boolean type for range_true/range_false.
Aldy Hernandez [Wed, 7 Feb 2024 10:27:29 +0000 (7 11:27 +0100)]
Make fold_cond_with_ops use a boolean type for range_true/range_false.

Conditional operators are always boolean, regardless of their
operands.  Getting the type wrong is not currently a problem, but will
be when prange's can no longer store an integer.

gcc/ChangeLog:

* vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Remove
type from range_true and range_false.

6 days agoRemove GTY support for vrange and derived classes.
Aldy Hernandez [Wed, 21 Feb 2024 08:34:29 +0000 (21 09:34 +0100)]
Remove GTY support for vrange and derived classes.

Now that we have a vrange storage class to save ranges in long-term
memory, there is no need for GTY markers for any of the vrange
classes, since they should never live in GC.

gcc/ChangeLog:

* value-range-storage.h: Remove friends.
* value-range.cc (gt_ggc_mx): Remove.
(gt_pch_nx): Remove.
* value-range.h (class vrange): Remove GTY markers.
(class irange): Same.
(class int_range): Same.
(class frange): Same.
(gt_ggc_mx): Remove.
(gt_pch_nx): Remove.

6 days agoMove bitmask routines to vrange base class.
Aldy Hernandez [Thu, 22 Feb 2024 08:18:46 +0000 (22 09:18 +0100)]
Move bitmask routines to vrange base class.

Any range can theoretically have a bitmask of set bits.  This patch
moves the bitmask accessors to the base class.  This cleans up some
users in IPA*, and will provide a cleaner interface when prange is in
place.

gcc/ChangeLog:

* ipa-cp.cc (propagate_bits_across_jump_function): Access bitmask
through base class.
(ipcp_store_vr_results): Same.
* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same.
(ipcp_get_parm_bits): Same.
(ipcp_update_vr): Same.
* range-op-mixed.h (update_known_bitmask): Change argument to vrange.
* range-op.cc (update_known_bitmask): Same.
* value-range.cc (vrange::update_bitmask):  New.
(irange::set_nonzero_bits): Move to vrange class.
(irange::get_nonzero_bits): Same.
* value-range.h (class vrange): Add update_bitmask, get_bitmask,
get_nonzero_bits, and set_nonzero_bits.
(class irange): Make bitmask methods virtual overrides.
(class Value_Range): Add get_bitmask and update_bitmask.

6 days agoAdd tree versions of lower and upper bounds to vrange.
Aldy Hernandez [Mon, 22 Apr 2024 11:34:48 +0000 (22 13:34 +0200)]
Add tree versions of lower and upper bounds to vrange.

This patch adds vrange::lbound() and vrange::ubound() that return
trees.  These can be used in generic code that is type agnostic, and
avoids special casing for pointers and integers in places where we
handle both.  It also cleans up a wart in the Value_Range class.

gcc/ChangeLog:

* tree-ssa-loop-niter.cc (refine_value_range_using_guard): Convert
bound to wide_int.
* value-range.cc (Value_Range::lower_bound): Remove.
(Value_Range::upper_bound): Remove.
(unsupported_range::lbound): New.
(unsupported_range::ubound): New.
(frange::lbound): New.
(frange::ubound): New.
(irange::lbound): New.
(irange::ubound): New.
* value-range.h (class vrange): Add lbound() and ubound().
(class irange): Same.
(class frange): Same.
(class unsupported_range): Same.
(class Value_Range): Rename lower_bound and upper_bound to lbound
and ubound respectively.

6 days agoMake some Value_Range's explicitly integer.
Aldy Hernandez [Mon, 22 Apr 2024 11:29:39 +0000 (22 13:29 +0200)]
Make some Value_Range's explicitly integer.

Fix some Value_Range's that we know ahead of time will be only
integers.  This avoids using the polymorphic Value_Range unnecessarily

gcc/ChangeLog:

* gimple-ssa-warn-access.cc (check_nul_terminated_array): Make Value_Range an int_range.
(memmodel_to_uhwi): Same
* tree-ssa-loop-niter.cc (refine_value_range_using_guard): Same.
(determine_value_range): Same.
(infer_loop_bounds_from_signedness): Same.
(scev_var_range_cant_overflow): Same.

6 days agoAdd a virtual vrange destructor.
Aldy Hernandez [Wed, 21 Feb 2024 08:33:19 +0000 (21 09:33 +0100)]
Add a virtual vrange destructor.

Richi mentioned in PR113476 that it would be cleaner to move the
destructor from int_range to the base class.  Although this isn't
strictly necessary, as there are no users, it is good to future proof
things, and the overall impact is miniscule.

gcc/ChangeLog:

* value-range.h (vrange::~vrange): New.
(int_range::~int_range): Make final override.

6 days agoMake vrange an abstract class.
Aldy Hernandez [Wed, 21 Feb 2024 19:37:14 +0000 (21 20:37 +0100)]
Make vrange an abstract class.

Explicitly make vrange an abstract class.  This involves fleshing out
the unsupported_range overrides which we were inheriting by default
from vrange.

gcc/ChangeLog:

* value-range.cc (unsupported_range::accept): Move down.
(vrange::contains_p):  Rename to...
(unsupported_range::contains_p): ...this.
(vrange::singleton_p): Rename to...
(unsupported_range::singleton_p): ...this.
(vrange::set): Rename to...
(unsupported_range::set): ...this.
(vrange::type): Rename to...
(unsupported_range::type): ...this.
(vrange::supports_type_p): Rename to...
(unsupported_range::supports_type_p): ...this.
(vrange::set_undefined): Rename to...
(unsupported_range::set_undefined): ...this.
(vrange::set_varying): Rename to...
(unsupported_range::set_varying): ...this.
(vrange::union_): Rename to...
(unsupported_range::union_): ...this.
(vrange::intersect): Rename to...
(unsupported_range::intersect): ...this.
(vrange::zero_p): Rename to...
(unsupported_range::zero_p): ...this.
(vrange::nonzero_p): Rename to...
(unsupported_range::nonzero_p): ...this.
(vrange::set_nonzero): Rename to...
(unsupported_range::set_nonzero): ...this.
(vrange::set_zero): Rename to...
(unsupported_range::set_zero): ...this.
(vrange::set_nonnegative): Rename to...
(unsupported_range::set_nonnegative): ...this.
(vrange::fits_p): Rename to...
(unsupported_range::fits_p): ...this.
(unsupported_range::operator=): New.
(frange::fits_p): New.
* value-range.h (class vrange): Make an abstract class.
(class unsupported_range): Declare override methods.

6 days agolibbacktrace: load Windows modules
Ian Lance Taylor [Sun, 28 Apr 2024 18:14:17 +0000 (28 11:14 -0700)]
libbacktrace: load Windows modules

Patch from Björn Schäpers <bjoern@hazardy.de>.

* configure.ac: Checked for tlhelp32.h
* pecoff.c: Include <tlhelp32.h> if available.
(backtrace_initialize): Use tlhelp32 api for a snapshot to
detect loaded modules.
(coff_add): New argument for the module handle of the file,
to get the base address.
* configure, config.h.in: Regenerate.

7 days agodoc: Remove references to FreeBSD 7 and older
Gerald Pfeifer [Sun, 28 Apr 2024 12:59:14 +0000 (28 14:59 +0200)]
doc: Remove references to FreeBSD 7 and older

FreeBSD 7 has been end of life for years and current GCC most likely
would not build there anymore anyways.

gcc:
PR target/69374
PR target/112959
* doc/install.texi (Specific) <*-*-freebsd*>: Remove references to
FreeBSD 7 and older.

7 days agodoc: Update David Binderman's entry in contrib.texi
Gerald Pfeifer [Sun, 28 Apr 2024 11:40:53 +0000 (28 13:40 +0200)]
doc: Update David Binderman's entry in contrib.texi

gcc/ChangeLog:

* doc/contrib.texi: Update David Binderman's entry.

7 days agoAdjust alternative *k to ?k for avx512 mask in zero_extend patterns
liuhongt [Tue, 16 Apr 2024 00:37:22 +0000 (16 08:37 +0800)]
Adjust alternative *k to ?k for avx512 mask in zero_extend patterns

So when both source operand and dest operand require avx512 MASK_REGS, RA
can allocate MASK_REGS register instead of GPR to avoid reload it from
GPR to MASK_REGS.

gcc/ChangeLog:

* config/i386/i386.md: (zero_extendsidi2): Adjust
alternative *k to ?k.
(zero_extend<mode>di2): Ditto.
(*zero_extend<mode>si2): Ditto.
(*zero_extendqihi2): Ditto.

7 days ago[testsuite] require sqrt_insn effective target where needed
Alexandre Oliva [Sun, 28 Apr 2024 07:30:30 +0000 (28 04:30 -0300)]
[testsuite] require sqrt_insn effective target where needed

Some tests fail on ppc and ppc64 when testing a compiler [with options
for] for a CPU [emulator] that doesn't support the sqrt insn.

The gcc.dg/cdce3.c is one in which the expected shrink-wrap
optimization only takes place when the target CPU supports a sqrt
insn.

The gcc.target/powerpc/pr46728-1[0-4].c tests use -mpowerpc-gpopt and
call sqrt(), which involves the sqrt insn that the target CPU under
test may not support.

Require a sqrt_insn effective target for all the affected tests.

for  gcc/testsuite/ChangeLog

* gcc.dg/cdce3.c: Require sqrt_insn effective target.
* gcc.target/powerpc/pr46728-10.c: Likewise.  Drop darwin
explicit skipping.
* gcc.target/powerpc/pr46728-11.c: Likewise.  Likewise.
* gcc.target/powerpc/pr46728-13.c: Likewise.  Likewise.
* gcc.target/powerpc/pr46728-14.c: Likewise.  Likewise.

7 days agoxfail fetestexcept test - ppc always uses fcmpu
Alexandre Oliva [Sun, 28 Apr 2024 07:30:24 +0000 (28 04:30 -0300)]
xfail fetestexcept test - ppc always uses fcmpu

gcc.dg/torture/pr91323.c tests that a compare with NaNf doesn't set an
exception using builtin compare intrinsics, and that it does when
using regular compare operators.

That doesn't seem to be expected to work on powerpc targets.  It fails
on GNU/Linux, it's marked to be skipped on AIX, and a similar test,
gcc.dg/torture/pr93133.c, has the execution test xfailed for all of
powerpc*-*-*.

In this test, the functions that use intrinsics for the compare end up
with the same code as the one that uses compare operators, using
fcmpu, a floating compare that, unlike fcmpo, does not set the invalid
operand exception for quiet NaN.  I couldn't find any evidence that
the rs6000 backend ever outputs fcmpo.  Therefore, I'm adding the same
execution xfail marker to this test.

for  gcc/testsuite/ChangeLog

PR target/58684
* gcc.dg/torture/pr91323.c: Expect execution fail on
powerpc*-*-*.

7 days agoppc: testsuite: vec-mul requires vsx runtime
Alexandre Oliva [Sun, 28 Apr 2024 07:30:19 +0000 (28 04:30 -0300)]
ppc: testsuite: vec-mul requires vsx runtime

vec-mul is an execution test, but it only requires a powerpc_vsx_ok
effective target, which is enough only for compile tests.  In order to
check for runtime and execution environment support, we need to
require vsx_hw.  Make that a condition for execution, but still
perform a compile test if the condition is not satisfied.

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/vec-mul.c: Run on target vsx_hw, just
compile otherwise.

7 days agodisable ldist for test, to restore vectorizing-candidate loop
Alexandre Oliva [Sun, 28 Apr 2024 07:30:15 +0000 (28 04:30 -0300)]
disable ldist for test, to restore vectorizing-candidate loop

The loop we're supposed to try to vectorize in
gcc.dg/vect/costmodel/ppc/costmodel-vect-31a.c is turned into a memset
before the vectorizer runs.

Various other tests in this set have already run into this, and the
solution has been to disable this loop distribution transformation,
enabled at -O2, so that the vectorizer gets a chance to transform the
loop and, in this testcase, fail to do so.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/costmodel/ppc/costmodel-vect-31a.c: Disable
ldist.

7 days agoRequest check for hw support in ppc run tests with -maltivec/-mvsx
Olivier Hainque [Sun, 28 Apr 2024 07:30:06 +0000 (28 04:30 -0300)]
Request check for hw support in ppc run tests with -maltivec/-mvsx

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/swaps-p8-20.c: Change powerpc_altivec_ok
require-effective-target test into vmx_hw.
* gcc.target/powerpc/vsx-vector-5.c: Change powerpc_vsx_ok
require-effective-target test into vsx_hw.

7 days ago[testsuite] [ppc64] expect error on vxworks too
Alexandre Oliva [Sun, 28 Apr 2024 07:30:00 +0000 (28 04:30 -0300)]
[testsuite] [ppc64] expect error on vxworks too

These ppc lp64 tests check for errors or warnings on -mno-powerpc64.
On powerpc64-*-vxworks* we get the same errors as on most other
covered platforms, but the tests did not mark them as expected for
this target.  On powerpc-*-vxworks*, the tests are skipped because
lp64 is not satisfied, so I'm naming powerpc*-*-vxworks* rather than
something more specific.

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/pr106680-1.c: Error on vxworks too.
* gcc.target/powerpc/pr106680-2.c: Likewise.
* gcc.target/powerpc/pr106680-3.c: Likewise.

7 days agodecay vect tests from run to link for pr95401
Alexandre Oliva [Sun, 28 Apr 2024 07:29:54 +0000 (28 04:29 -0300)]
decay vect tests from run to link for pr95401

When vect.exp finds our configuration disables altivec by default, it
disables the execution of vectorization tests, assuming the test
hardware doesn't support it.

Tests become just compile tests, but compile tests won't work
correctly when additional sources are named, e.g. pr95401.cc, because
GCC refuses to compile multiple files into the same asm output.

With this patch, the default for when execution is not possible
becomes link.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp (check_vect_support_and_set_flags):
Decay to link rather than compile.

7 days agos390: avoid peeking eof after __vector
Jiufu Guo [Wed, 27 Mar 2024 06:15:40 +0000 (27 14:15 +0800)]
s390: avoid peeking eof after __vector

Same like PR101168, it is need for s390 to
avoid peeking eof after vector keyword.
And similar test case is also ok for s390.

PR target/95782

gcc/ChangeLog:

* config/s390/s390-c.cc (s390_macro_to_expand): Avoid empty identifier.

gcc/testsuite/ChangeLog:

* g++.target/s390/pr95782.C: New test.

7 days agoDaily bump.
GCC Administrator [Sun, 28 Apr 2024 00:16:32 +0000 (28 00:16 +0000)]
Daily bump.

7 days agoaarch64: Use vec_perm_indices::new_shrunk_vector in aarch64_evpc_reencode
Andrew Pinski [Mon, 12 Feb 2024 23:48:48 +0000 (12 15:48 -0800)]
aarch64: Use vec_perm_indices::new_shrunk_vector in aarch64_evpc_reencode

While working on PERM related stuff, I can across that aarch64_evpc_reencode
was manually figuring out if we shrink the perm indices instead of
using vec_perm_indices::new_shrunk_vector; shrunk was added after reencode
was added.

Built and tested for aarch64-linux-gnu with no regressions.

gcc/ChangeLog:

PR target/113822
* config/aarch64/aarch64.cc (aarch64_evpc_reencode): Use
vec_perm_indices::new_shrunk_vector instead of manually
going through the indices.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 days agoLoongArch: Add constraints for bit string operation define_insn_and_split's [PR114861]
Xi Ruoyao [Fri, 26 Apr 2024 07:59:11 +0000 (26 15:59 +0800)]
LoongArch: Add constraints for bit string operation define_insn_and_split's [PR114861]

Without the constrants, the compiler attempts to use a stack slot as the
target, causing an ICE building the kernel with -Os:

    drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c:3144:1:
    error: could not split insn
    (insn:TI 1764 67 1745
      (set (mem/c:DI (reg/f:DI 3 $r3) [707 %sfp+-80 S8 A64])
           (and:DI (reg/v:DI 28 $r28 [orig:422 raster_config ] [422])
                   (const_int -50331649 [0xfffffffffcffffff])))
      "drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c":1386:21 111
      {*bstrins_di_for_mask}
      (nil))

Add these constrants to fix the issue.

gcc/ChangeLog:

PR target/114861
* config/loongarch/loongarch.md (bstrins_<mode>_for_mask): Add
constraints for operands.
(bstrins_<mode>_for_ior_mask): Likewise.

gcc/testsuite/ChangeLog:

PR target/114861
* gcc.target/loongarch/pr114861.c: New test.

8 days agoRISC-V: Add -X to link spec
Fangrui Song [Sat, 27 Apr 2024 01:14:33 +0000 (26 18:14 -0700)]
RISC-V: Add -X to link spec

--discard-locals (-X) instructs the linker to remove local .L* symbols,
which occur a lot due to label differences for linker relaxation. The
arm port has a similar need and passes -X to ld.

In contrast, the RISC-V port does not pass -X to ld and rely on the
default --discard-locals in GNU ld's riscv port. The arm way is more
conventional (compiler driver instead of the linker customizes the
default linker behavior) and works with lld.

gcc/ChangeLog:

* config/riscv/elf.h (LINK_SPEC): Add -X.
* config/riscv/freebsd.h (LINK_SPEC): Add -X.
* config/riscv/linux.h (LINK_SPEC): Add -X.

8 days agoDaily bump.
GCC Administrator [Sat, 27 Apr 2024 00:18:05 +0000 (27 00:18 +0000)]
Daily bump.

8 days agoAArch64: Cleanup memset expansion
Wilco Dijkstra [Wed, 21 Feb 2024 23:34:37 +0000 (21 23:34 +0000)]
AArch64: Cleanup memset expansion

Cleanup memset implementation.  Similar to memcpy/memmove, use an offset and
bytes throughout.  Simplify the complex calculations when optimizing for size
by using a fixed limit.

gcc/ChangeLog:
* config/aarch64/aarch64.cc (MAX_SET_SIZE): New define.
(aarch64_progress_pointer): Remove function.
(aarch64_set_one_block_and_progress_pointer): Simplify and clean up.
(aarch64_expand_setmem): Clean up implementation, use byte offsets,
simplify size calculation.

8 days agoAArch64: Remove AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS
Wilco Dijkstra [Fri, 26 Apr 2024 14:09:31 +0000 (26 15:09 +0100)]
AArch64: Remove AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS

Remove the tune AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS since it is only
used by an old core and doesn't properly support -Os.  SPECINT_2017
shows that removing it has no performance difference, while codesize
is reduced by 0.07%.

gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_mode_valid_for_sched_fusion_p):
Remove check for AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS.
(aarch64_advsimd_ldp_stp_p): Likewise.
(aarch64_stp_sequence_cost): Likewise.
(aarch64_expand_cpymem): Likewise.
(aarch64_expand_setmem): Likewise.
* config/aarch64/aarch64-ldp-fusion.cc (ldp_operand_mode_ok_p):
Likewise.
* config/aarch64/aarch64-ldpstp.md: Likewise.
* config/aarch64/aarch64-tuning-flags.def: Remove NO_LDP_STP_QREGS.
* config/aarch64/tuning_models/emag.h: Likewise.
* config/aarch64/tuning_models/xgene1.h: Likewise.

gcc/testsuite:
* gcc.target/aarch64/ldp_stp_q_disable.c: Remove test.

8 days agolibatomic: Cleanup macros in atomic_16.S
Wilco Dijkstra [Tue, 26 Mar 2024 15:42:16 +0000 (26 15:42 +0000)]
libatomic: Cleanup macros in atomic_16.S

Cleanup the macros to add the libat_ prefixes in atomic_16.S.  Emit the
alias to __atomic_<op> when ifuncs are not enabled in the ENTRY macro.

libatomic:
* config/linux/aarch64/atomic_16.S: Add __libat_ prefix in the
LSE2/LSE128/CORE macros, remove elsewhere.  Add ATOMIC macro.

9 days agolibstdc++: Do not apply localized formatting to NaN and inf [PR114863]
Jonathan Wakely [Fri, 26 Apr 2024 10:42:26 +0000 (26 11:42 +0100)]
libstdc++: Do not apply localized formatting to NaN and inf [PR114863]

We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.

libstdc++-v3/ChangeLog:

PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.

9 days agoc++: fix source printing for "required from here" message
Patrick Palka [Fri, 26 Apr 2024 11:44:25 +0000 (26 07:44 -0400)]
c++: fix source printing for "required from here" message

It seems the diagnostic machinery's source line printing respects
the pretty printer prefix, but this is undesirable for the call to
diagnostic_show_locus in print_instantiation_partial_context_line
(added in r14-4388-g1c45319b66edc9) since the prefix may have been
set when issuing an earlier, unrelated diagnostic and we just want
to print an unprefixed source line.

This patch naively fixes this by clearing the prefix before calling
diagnostic_show_locus.

Before this patch, for error60a.C below we'd print

gcc/testsuite/g++.dg/template/error60a.C: In function â€˜void usage()’:
gcc/testsuite/g++.dg/template/error60a.C:24:3: error: â€˜unrelated_error’ was not declared in this scope
   24 |   unrelated_error; // { dg-error "not declared" }
      |   ^~~~~~~~~~~~~~~
gcc/testsuite/g++.dg/template/error60a.C: In instantiation of â€˜void test(Foo) [with Foo = int]’:
gcc/testsuite/g++.dg/template/error60a.C:25:13:   required from here
gcc/testsuite/g++.dg/template/error60a.C:24:3: error:    25 |   test<int> (42); // { dg-message " required from here" }
gcc/testsuite/g++.dg/template/error60a.C:24:3: error:       |   ~~~~~~~~~~^~~~
gcc/testsuite/g++.dg/template/error60a.C:19:24: error: invalid conversion from â€˜int’ to â€˜int*’ [-fpermissive]
   19 |   my_pointer<Foo> ptr (val); // { dg-error "invalid conversion from 'int' to 'int\\*'" }
      |                        ^~~
      |                        |
      |                        int
gcc/testsuite/g++.dg/template/error60a.C:9:20: note:   initializing argument 1 of â€˜my_pointer<Foo>::my_pointer(Foo*) [with Foo = int]’
    9 |   my_pointer (Foo *ptr) // { dg-message " initializing argument 1" }
      |               ~~~~~^~~

and afterward we print

gcc/testsuite/g++.dg/template/error60a.C: In function â€˜void usage()’:
gcc/testsuite/g++.dg/template/error60a.C:24:3: error: â€˜unrelated_error’ was not declared in this scope
   24 |   unrelated_error; // { dg-error "not declared" }
      |   ^~~~~~~~~~~~~~~
gcc/testsuite/g++.dg/template/error60a.C: In instantiation of â€˜void test(Foo) [with Foo = int]’:
gcc/testsuite/g++.dg/template/error60a.C:25:13:   required from here
   25 |   test<int> (42); // { dg-message " required from here" }
      |   ~~~~~~~~~~^~~~
gcc/testsuite/g++.dg/template/error60a.C:19:24: error: invalid conversion from â€˜int’ to â€˜int*’ [-fpermissive]
   19 |   my_pointer<Foo> ptr (val); // { dg-error "invalid conversion from 'int' to 'int\\*'" }
      |                        ^~~
      |                        |
      |                        int
gcc/testsuite/g++.dg/template/error60a.C:9:20: note:   initializing argument 1 of â€˜my_pointer<Foo>::my_pointer(Foo*) [with Foo = int]’
    9 |   my_pointer (Foo *ptr) // { dg-message " initializing argument 1" }
      |               ~~~~~^~~

gcc/cp/ChangeLog:

* error.cc (print_instantiation_partial_context_line): Clear the
pretty printer prefix around the call to diagnostic_show_locus.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic2.C: Expect source line printed
for the "required from here" message.
* g++.dg/template/error60a.C: New test.

9 days agolibstdc++: Adjust whitespace in status tables in manual
Jonathan Wakely [Fri, 26 Apr 2024 10:48:48 +0000 (26 11:48 +0100)]
libstdc++: Adjust whitespace in status tables in manual

This simplifies the changes needed after branching for a new release, so
that new line breaks don't need to be introduced every time we branch.

libstdc++-v3/ChangeLog:

* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Adjust whitespace.
* doc/xml/manual/status_cxx2011.xml: Likewise.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/xml/manual/status_cxx2023.xml: Likewise.
* doc/xml/manual/status_cxxtr1.xml: Likewise.
* doc/xml/manual/status_cxxtr24733.xml: Likewise.

9 days agoada: bump Library_Version to 15.
Jakub Jelinek [Fri, 26 Apr 2024 10:20:45 +0000 (26 12:20 +0200)]
ada: bump Library_Version to 15.

gcc/ada/ChangeLog:

* gnatvsn.ads: Bump Library_Version to 15.

9 days agoUpdate crontab and git_update_version.py
Jakub Jelinek [Fri, 26 Apr 2024 10:18:29 +0000 (26 12:18 +0200)]
Update crontab and git_update_version.py

2024-04-26  Jakub Jelinek  <jakub@redhat.com>

maintainer-scripts/
* crontab: Snapshots from trunk are now GCC 15 related.
Add GCC 14 snapshots from the respective branch.
contrib/
* gcc-changelog/git_update_version.py (active_refs): Add
releases/gcc-14.

9 days agoBump BASE-VER.basepoints/gcc-15
Jakub Jelinek [Fri, 26 Apr 2024 09:50:36 +0000 (26 11:50 +0200)]
Bump BASE-VER.

2024-04-26  Jakub Jelinek  <jakub@redhat.com>

* BASE-VER: Set to 15.0.0.

9 days agoamdgcn: Add gfx90c target
Frederik Harwath [Wed, 24 Apr 2024 18:29:14 +0000 (24 20:29 +0200)]
amdgcn: Add gfx90c target

Add support for gfx90c GCN5 APU integrated graphics devices.
The LLVM AMDGPU documentation does not list those devices as supported
by rocm-amdhsa, but it passes most libgomp offloading tests.
Although they are constrainted compared to dGPUs, they might be
interesting for learning, experimentation, and testing.

gcc/ChangeLog:

* config.gcc: Add gfx90c.
* config/gcn/gcn-hsa.h (NO_SRAM_ECC): Likewise.
* config/gcn/gcn-opts.h (enum processor_type): Likewise.
(TARGET_GFX90c): New macro.
* config/gcn/gcn.cc (gcn_option_override): Handle gfx90c.
(gcn_omp_device_kind_arch_isa): Likewise.
(output_file_start): Likewise.
* config/gcn/gcn.h: Add gfx90c.
* config/gcn/gcn.opt: Likewise.
* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX90c): New macro.
(get_arch): Handle gfx90c.
(main): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c
* config/gcn/t-omp-device: Add gfx90c.
* doc/install.texi: Likewise.
* doc/invoke.texi: Likewise.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (isa_hsa_name): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c.
(isa_code): Handle gfx90c.
(max_isa_vgprs): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c.

Signed-off-by: Frederik Harwath <frederik@harwath.name>
9 days agoi386: Fix array index overflow in pr105354-2.c
Haochen Jiang [Fri, 26 Apr 2024 08:48:29 +0000 (26 16:48 +0800)]
i386: Fix array index overflow in pr105354-2.c

The array index should not be over 8 for v8hi, or it will fail
under -O0 or using -fstack-protector.

gcc/testsuite/ChangeLog:

PR target/110621
* gcc.target/i386/pr105354-2.c: As mentioned.

9 days agoDaily bump.
GCC Administrator [Fri, 26 Apr 2024 00:16:42 +0000 (26 00:16 +0000)]
Daily bump.

9 days agobpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG
David Faust [Wed, 24 Apr 2024 22:01:02 +0000 (24 15:01 -0700)]
bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG

BTF is the standard debug info used with BPF programs, so it makes sense
to default to BTF rather than DWARF.

gcc/
* config/bpf/bpf.h (PREFERRED_DEBUGGING_TYPE): Set to BTF_DEBUG.

gcc/testsuite/
* gcc.target/bpf/bpf-debug-options-1.c: New test.
* gcc.target/bpf/bpf-debug-options-2.c: Likewise.
* gcc.target/bpf/bpf-debug-options-3.c: Likewise.
* gcc.target/bpf/core-options-4.c: Likewise.

9 days agoc++: Fix constexpr evaluation of parameters passed by invisible reference [PR111284]
Jakub Jelinek [Thu, 25 Apr 2024 18:45:04 +0000 (25 20:45 +0200)]
c++: Fix constexpr evaluation of parameters passed by invisible reference [PR111284]

My r9-6136 changes to make a copy of constexpr function bodies before
genericization modifies it broke the constant evaluation of non-POD
arguments passed by value.
In the callers such arguments are passed as reference to usually a
TARGET_EXPR, but on the callee side until genericization they are just
direct uses of a PARM_DECL with some class type.
In cxx_bind_parameters_in_call I've used convert_from_reference to
pretend it is passed by value and then cxx_eval_constant_expression
is called there and evaluates that as an rvalue, followed by
adjust_temp_type if the types don't match exactly (e.g. const Foo
argument and passing to it reference to Foo TARGET_EXPR).

The reason this doesn't work is that when the TARGET_EXPR in the caller
is constant initialized, this for it is the address of the TARGET_EXPR_SLOT,
but if the code later on pretends the PARM_DECL is just initialized to the
rvalue of the constant evaluation of the TARGET_EXPR, it is as if there
is a bitwise copy of the TARGET_EXPR to the callee, so this in the callee
is then address of the PARM_DECL in the callee.

The following patch attempts to fix that by constexpr evaluation of such
arguments in the caller as an lvalue instead of rvalue, and on the callee
side when seeing such a PARM_DECL, if we want an lvalue, lookup the value
(lvalue) saved in ctx->globals (if any), and if wanting an rvalue,
recursing with vc_prvalue on the looked up value (because it is there
as an lvalue, nor rvalue).

adjust_temp_type doesn't work for lvalues of non-scalarish types, for
such types it relies on changing the type of a CONSTRUCTOR, but on the
other side we know what we pass to the argument is addressable, so
the patch on type mismatch takes address of the argument value, casts
to reference to the desired type and dereferences it.

2024-04-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/111284
* constexpr.cc (cxx_bind_parameters_in_call): For PARM_DECLs with
TREE_ADDRESSABLE types use vc_glvalue rather than vc_prvalue for
cxx_eval_constant_expression and if it doesn't have the same
type as it should, cast the reference type to reference to type
before convert_from_reference and instead of adjust_temp_type
take address of the arg, cast to reference to type and then
convert_from_reference.
(cxx_eval_constant_expression) <case PARM_DECL>: For lval case
on parameters with TREE_ADDRESSABLE types lookup result in
ctx->globals if possible.  Otherwise if lookup in ctx->globals
was successful for parameter with TREE_ADDRESSABLE type,
recurse with vc_prvalue on the returned value.

* g++.dg/cpp1z/constexpr-111284.C: New test.
* g++.dg/cpp1y/constexpr-lifetime7.C: Expect one error on a different
line.

9 days agolibgcc: Don't use weakrefs for glibc 2.34
Jakub Jelinek [Thu, 25 Apr 2024 18:43:13 +0000 (25 20:43 +0200)]
libgcc: Don't use weakrefs for glibc 2.34

glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
dummy shared library with just some symbol versions for compatibility, but
all the pthread_* APIs are in libc.so.6).
So, we don't need to do the .weakref dances to check whether a program
has been linked with -lpthread or not, in dynamically linked apps those
will be always true anyway.
In -static linking, this fixes various issues people had when only linking
some parts of libpthread.a and getting weird crashes.  A hack for that was
what e.g. some Fedora glibcs used, where libpthread.a was a library
containing just one giant *.o file which had all the normal libpthread.a
*.o files linked with -r together.

libstdc++-v3 actually does something like this already since r10-10928,
the following patch is meant to fix it even for libgfortran, libobjc and
whatever else uses gthr.h.

2024-04-25  Jakub Jelinek  <jakub@redhat.com>

* gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later.

9 days agoc++: Retry the aliasing of base/complete cdtor optimization at import_export_decl...
Jakub Jelinek [Thu, 25 Apr 2024 18:37:10 +0000 (25 20:37 +0200)]
c++: Retry the aliasing of base/complete cdtor optimization at import_export_decl time [PR113208]

When expand_or_defer_fn is called at_eof time, it calls import_export_decl
and then maybe_clone_body, which uses DECL_ONE_ONLY and comdat name in a
couple of places to try to optimize cdtors which are known to have the
same body by making the complete cdtor an alias to base cdtor (and in
that case also uses *[CD]5* as comdat group name instead of the normal
comdat group names specific to each mangled name).
Now, this optimization depends on DECL_ONE_ONLY and DECL_INTERFACE_KNOWN,
maybe_clone_body and can_alias_cdtor use:
      if (DECL_ONE_ONLY (fn))
        cgraph_node::get_create (clone)->set_comdat_group (cxx_comdat_group (clone));
...
  bool can_alias = can_alias_cdtor (fn);
...
      /* Tell cgraph if both ctors or both dtors are known to have
         the same body.  */
      if (can_alias
          && fns[0]
          && idx == 1
          && cgraph_node::get_create (fns[0])->create_same_body_alias
               (clone, fns[0]))
        {
          alias = true;
          if (DECL_ONE_ONLY (fns[0]))
            {
              /* For comdat base and complete cdtors put them
                 into the same, *[CD]5* comdat group instead of
                 *[CD][12]*.  */
              comdat_group = cdtor_comdat_group (fns[1], fns[0]);
              cgraph_node::get_create (fns[0])->set_comdat_group (comdat_group);
              if (symtab_node::get (clone)->same_comdat_group)
                symtab_node::get (clone)->remove_from_same_comdat_group ();
              symtab_node::get (clone)->add_to_same_comdat_group
                (symtab_node::get (fns[0]));
            }
        }
and
  /* Don't use aliases for weak/linkonce definitions unless we can put both
     symbols in the same COMDAT group.  */
  return (DECL_INTERFACE_KNOWN (fn)
          && (SUPPORTS_ONE_ONLY || !DECL_WEAK (fn))
          && (!DECL_ONE_ONLY (fn)
              || (HAVE_COMDAT_GROUP && DECL_WEAK (fn))));
The following testcase regressed with Marek's r14-5979 change,
when pr113208_0.C is compiled where the ctor is marked constexpr,
we no longer perform this optimization, where
_ZN6vectorI12QualityValueEC2ERKS1_ was emitted in the
_ZN6vectorI12QualityValueEC5ERKS1_ comdat group and
_ZN6vectorI12QualityValueEC1ERKS1_ was made an alias to it,
instead we emit _ZN6vectorI12QualityValueEC2ERKS1_ in
_ZN6vectorI12QualityValueEC2ERKS1_ comdat group and the same
content _ZN6vectorI12QualityValueEC1ERKS1_ as separate symbol in
_ZN6vectorI12QualityValueEC1ERKS1_ comdat group.
Now, the linker seems to somehow cope with that, eventhough it
probably keeps both copies of the ctor, but seems LTO can't cope
with that and Honza doesn't know what it should do in that case
(linker decides that the prevailing symbol is
_ZN6vectorI12QualityValueEC2ERKS1_ (from the
_ZN6vectorI12QualityValueEC2ERKS1_ comdat group) and
_ZN6vectorI12QualityValueEC1ERKS1_ alias (from the other TU,
from _ZN6vectorI12QualityValueEC5ERKS1_ comdat group)).

Note, the case where some constructor is marked constexpr in one
TU and not in another one happens pretty often in libstdc++ when
one mixes -std= flags used to compile different compilation units.

The reason the optimization doesn't trigger when the constructor is
constexpr is that expand_or_defer_fn is called in that case much earlier
than when it is not constexpr; in the former case it is called when we
try to constant evaluate that constructor.  But DECL_INTERFACE_KNOWN
is false in that case and comdat_linkage hasn't been called either
(I think it is desirable, because comdat group is stored in the cgraph
node and am not sure it is a good idea to create cgraph nodes for
something that might not be needed later on at all), so maybe_clone_body
clones the bodies, but doesn't make them as aliases.

The following patch is an attempt to redo this optimization when
import_export_decl is called at_eof time on the base/complete cdtor
(or deleting dtor).  It will not do anything if maybe_clone_body
hasn't been called uyet (the TREE_ASM_WRITTEN check on the
DECL_MAYBE_IN_CHARGE_CDTOR_P), or when one or both of the base/complete
cdtors have been lowered already, or when maybe_clone_body called
maybe_thunk_body and it was successful.  Otherwise retries the
can_alias_cdtor check and makes the complete cdtor alias to the
base cdtor with adjustments to the comdat group.

2024-04-25  Jakub Jelinek  <jakub@redhat.com>

PR lto/113208
* cp-tree.h (maybe_optimize_cdtor): Declare.
* decl2.cc (import_export_decl): Call it for cloned cdtors.
* optimize.cc (maybe_optimize_cdtor): New function.

* g++.dg/abi/comdat2.C: New test.
* g++.dg/abi/comdat5.C: New test.
* g++.dg/lto/pr113208_0.C: New test.
* g++.dg/lto/pr113208_1.C: New file.
* g++.dg/lto/pr113208.h: New file.

9 days agobpf: avoid issues with CO-RE and -gtoggle
David Faust [Thu, 25 Apr 2024 16:31:14 +0000 (25 09:31 -0700)]
bpf: avoid issues with CO-RE and -gtoggle

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, since BTF is required for CO-RE.

Update bpf_option_override to avoid this case, and add a few tests for
the interactions of these options.

gcc/
* config/bpf/bpf.cc (bpf_option_override): Improve handling of CO-RE
options to avoid issues with -gtoggle.

gcc/testsuite/
* gcc.target/bpf/core-options-1.c: New test.
* gcc.target/bpf/core-options-2.c: Likewise.
* gcc.target/bpf/core-options-3.c: Likewise.

9 days agoopenmp: Copy DECL_LANG_SPECIFIC and DECL_LANG_FLAG_? to tree-nested decl copy [PR114825]
Jakub Jelinek [Thu, 25 Apr 2024 18:09:35 +0000 (25 20:09 +0200)]
openmp: Copy DECL_LANG_SPECIFIC and DECL_LANG_FLAG_? to tree-nested decl copy [PR114825]

tree-nested.cc creates in 2 spots artificial VAR_DECLs, one of them is used
both for debug info and OpenMP/OpenACC lowering purposes, the other solely for
OpenMP/OpenACC lowering purposes.
When the decls are used in OpenMP/OpenACC lowering, the OMP langhooks (mostly
Fortran, C just a little and C++ doesn't have nested functions) then inspect
the flags on the vars and based on that decide how to lower the corresponding
clauses.

Unfortunately we weren't copying DECL_LANG_SPECIFIC and DECL_LANG_FLAG_?, so
the langhooks made decisions on the default flags on those instead.
As the original decl isn't necessarily a VAR_DECL, could be e.g. PARM_DECL,
using copy_node wouldn't work properly, so this patch just copies those
flags in addition to other flags it was copying already.  And I've removed
code duplication by introducing a helper function which does copying common
to both uses.

2024-04-25  Jakub Jelinek  <jakub@redhat.com>

PR fortran/114825
* tree-nested.cc (get_debug_decl): New function.
(get_nonlocal_debug_decl): Use it.
(get_local_debug_decl): Likewise.

* gfortran.dg/gomp/pr114825.f90: New test.

9 days agolibstdc++: Rename man pages to use '::' instead of '_'
Jonathan Wakely [Thu, 25 Apr 2024 13:02:36 +0000 (25 14:02 +0100)]
libstdc++: Rename man pages to use '::' instead of '_'

The Doxygen-generated man pages for some new types need to be renamed to
use '::' instead of '_' in the filenames.

libstdc++-v3/ChangeLog:

* scripts/run_doxygen: Rename man pages for nested types.

9 days agolibstdc++: Fix typo in Doxygen comment
Jonathan Wakely [Thu, 25 Apr 2024 12:52:00 +0000 (25 13:52 +0100)]
libstdc++: Fix typo in Doxygen comment

libstdc++-v3/ChangeLog:

* include/std/chrono (tzdb_list): Fix typo in Doxygen comment.

9 days agolibstdc++: Fix run_doxygen for Doxygen 1.10 man page format
Jonathan Wakely [Thu, 25 Apr 2024 12:24:56 +0000 (25 13:24 +0100)]
libstdc++: Fix run_doxygen for Doxygen 1.10 man page format

Doxygen switched from \fC to \fR in its man page output:
https://github.com/doxygen/doxygen/pull/10497

This breaks our script that expects \fC so change the regaulr expression
to work with either style.

libstdc++-v3/ChangeLog:

* scripts/run_doxygen: Adjust sed pattern to match '\fR' for
new man output that Doxygen 1.10 generates.

9 days agolibstdc++: Update Doxygen config for new headers
Jonathan Wakely [Thu, 25 Apr 2024 12:09:27 +0000 (25 13:09 +0100)]
libstdc++: Update Doxygen config for new headers

libstdc++-v3/ChangeLog:

* doc/doxygen/stdheader.cc (init_map): Add missing headers.
* doc/doxygen/user.cfg.in (EXCLUDE): Exclude generated files for
std::format and std::text_encoding.

9 days agolibstdc++: Add comment to #include in <variant>
Jonathan Wakely [Thu, 25 Apr 2024 12:04:43 +0000 (25 13:04 +0100)]
libstdc++: Add comment to #include in <variant>

It's not obvious why <variant> needs <bits/parse_numbers.h> so add a
comment to it.

libstdc++-v3/ChangeLog:

* include/std/variant: Add comment to #include.

9 days agoPR modula2/114836 Avoid concatenation of error strings to aid error locale translation
Gaius Mulley [Thu, 25 Apr 2024 17:31:55 +0000 (25 18:31 +0100)]
PR modula2/114836 Avoid concatenation of error strings to aid error locale translation

This patch avoids a concatenation of error strings making locale
translation of the error message easier.

gcc/m2/ChangeLog:

PR modula2/114836
* gm2-compiler/M2Range.mod (FoldTypeAssign): Avoid error
string concatenation.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 days agobpf: default to using pseudo-C assembly syntax by default
Jose E. Marchesi [Thu, 25 Apr 2024 14:53:49 +0000 (25 16:53 +0200)]
bpf: default to using pseudo-C assembly syntax by default

At this point the kernel headers that almost all BPF programs use
contain pseudo-C inline assembly and having the GNU toolchain using
the conventional assembly syntax by default would force users to
specify the command-line option explicitly almost all of the time,
which is very inconvenient.

This patch changes GCC in order to recognize and generate the pseudo-C
assembly syntax of BPF by default.  The ASM_SPEC is adapted
accordingly, and in a way that the current release of the BPF
assembler (which still expects conventional assembler syntax by
default) does the right thing.

Tested in bpf-unknown-none-bpf target and x86_64-linux-gnu host.
No regressions.

gcc/ChangeLog

* config/bpf/bpf.opt: Use ASM_PSEUDOC for the default value of
-masm.
* config/bpf/bpf.h (ASM_SPEC): Adapt accordingly.
* doc/invoke.texi (eBPF Options): Update.

gcc/testsuite/ChangeLog

* gcc.target/bpf/alu-1.c: Specify conventional asm dialect.
* gcc.target/bpf/xbpf-indirect-call-1.c: Likewise.
* gcc.target/bpf/sync-fetch-and-add.c: Likewise.
* gcc.target/bpf/smov-2.c: Likewise.
* gcc.target/bpf/smov-1.c: Likewise.
* gcc.target/bpf/smod-1.c: Likewise.
* gcc.target/bpf/sload-1.c: Likewise.
* gcc.target/bpf/sdiv-1.c: Likewise.
* gcc.target/bpf/nop-1.c: Likewise.
* gcc.target/bpf/neg-1.c: Likewise.
* gcc.target/bpf/ldxdw.c: Likewise.
* gcc.target/bpf/jmp-1.c: Likewise.
* gcc.target/bpf/inline-memops-threshold-1.c: Likewise.
* gcc.target/bpf/float-1.c: Likewise.
* gcc.target/bpf/double-2.c: Likewise.
* gcc.target/bpf/double-1.c: Likewise.
* gcc.target/bpf/core-builtin-type-id.c: Likewise.
* gcc.target/bpf/core-builtin-type-based.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-size-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-sign-2.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-sign-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-2.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-2.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-le.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-be.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-existence-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-errors-2.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-errors-1.c: Likewise.
* gcc.target/bpf/core-builtin-fieldinfo-const-elimination.c:
Likewise.
* gcc.target/bpf/core-builtin-exprlist-4.c: Likewise.
* gcc.target/bpf/core-builtin-exprlist-3.c: Likewise.
* gcc.target/bpf/core-builtin-exprlist-2.c: Likewise.
* gcc.target/bpf/core-builtin-exprlist-1.c: Likewise.
* gcc.target/bpf/core-builtin-enumvalue-opt.c: Likewise.
* gcc.target/bpf/core-builtin-enumvalue-errors.c: Likewise.
* gcc.target/bpf/core-builtin-enumvalue.c: Likewise.
* gcc.target/bpf/core-builtin-3.c: Likewise.
* gcc.target/bpf/core-builtin-2.c: Likewise.
* gcc.target/bpf/core-builtin-1.c: Likewise.
* gcc.target/bpf/core-attr-struct-as-array.c: Likewise.
* gcc.target/bpf/core-attr-6.c: Likewise.
* gcc.target/bpf/core-attr-5.c: Likewise.
* gcc.target/bpf/core-attr-4.c: Likewise.
* gcc.target/bpf/core-attr-3.c: Likewise.
* gcc.target/bpf/core-attr-2.c: Likewise.
* gcc.target/bpf/core-attr-1.c: Likewise.
* gcc.target/bpf/builtin-load.c: Likewise.
* gcc.target/bpf/btfext-funcinfo-nocore.c: Likewise.
* gcc.target/bpf/btfext-funcinfo.c: Likewise.
* gcc.target/bpf/bswap-1.c: Likewise.
* gcc.target/bpf/bswap-2.c: Likewise.
* gcc.target/bpf/attr-kernel-helper.c: Likewise.
* gcc.target/bpf/atomic-xchg-2.c: Likewise.
* gcc.target/bpf/atomic-xchg-1.c: Likewise.
* gcc.target/bpf/atomic-op-3.c: Likewise.
* gcc.target/bpf/atomic-op-2.c: Likewise.
* gcc.target/bpf/atomic-op-1.c: Likewise.
* gcc.target/bpf/atomic-fetch-op-3.c: Likewise.
* gcc.target/bpf/atomic-fetch-op-2.c: Likewise.
* gcc.target/bpf/atomic-fetch-op-1.c: Likewise.
* gcc.target/bpf/atomic-cmpxchg-2.c: Likewise.
* gcc.target/bpf/atomic-cmpxchg-1.c: Likewise.
* gcc.target/bpf/alu-2.c: Likewise.

10 days agoarm: Zero/Sign extends for CMSE security
Richard Ball [Thu, 25 Apr 2024 14:30:42 +0000 (25 15:30 +0100)]
arm: Zero/Sign extends for CMSE security

Co-Authored by: Andre Simoes Dias Vieira <Andre.SimoesDiasVieira@arm.com>

This patch makes the following changes:

1) When calling a secure function from non-secure code then any arguments
   smaller than 32-bits that are passed in registers are zero- or sign-extended.
2) After a non-secure function returns into secure code then any return value
   smaller than 32-bits that is passed in a register is  zero- or sign-extended.

This patch addresses the following CVE-2024-0151.

gcc/ChangeLog:
PR target/114837
* config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
Add zero/sign extend.
(arm_expand_prologue): Add zero/sign extend.

gcc/testsuite/ChangeLog:

* gcc.target/arm/cmse/extend-param.c: New test.
* gcc.target/arm/cmse/extend-return.c: New test.

10 days agomodula2: issue the parameter incompatibility error message based on dialect
Gaius Mulley [Thu, 25 Apr 2024 14:19:30 +0000 (25 15:19 +0100)]
modula2: issue the parameter incompatibility error message based on dialect

This tiny patch improves the parameter incompatibility error message by
having a different message for the dialect chosen mentioning the specific
violation.  PIM uses assignment rules for pass by value and expression
rules for pass by reference.  ISO uses expression type checking for
pass by value and pass by reference.

gcc/m2/ChangeLog:

* gm2-compiler/M2FileName.def (CalculateFileName): Remove
quoted string in comment.
* gm2-compiler/M2Range.mod (FoldTypeParam): Generate dialect
specific parameter incompatibility error message.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 days agotree-optimization/114792 - order loops to unloops in CH
Richard Biener [Thu, 25 Apr 2024 06:08:24 +0000 (25 08:08 +0200)]
tree-optimization/114792 - order loops to unloops in CH

When we use unloop_loops we have to make sure to have loops ordered
inner to outer as otherwise we can wreck inner loop structure where
unlooping relies on that being intact.  The following re-sorts the
vector of to unloop loops after copy-header as that adds to the
vector in two places and the wrong order.

PR tree-optimization/114792
* tree-ssa-loop-ch.cc (ch_order_loops): New function.
(ch_base::copy_headers): Sort loops to unloop inner-to-outer.

* gcc.dg/torture/pr114792.c: New testcase.

10 days agoFix calling convention incompatibility with vendor compiler
Eric Botcazou [Thu, 25 Apr 2024 10:44:14 +0000 (25 12:44 +0200)]
Fix calling convention incompatibility with vendor compiler

For the 20th anniversary of https://gcc.gnu.org/gcc-3.4/sparc-abi.html,
a new calling convention incompatibility with the vendor compiler (and
the ABI) has been discovered in 64-bit mode, affecting small structures
containing arrays of floating-point components.  The decision has been
made to fix it on Solaris only at this point.

gcc/
PR target/114416
* config/sparc/sparc.h (SUN_V9_ABI_COMPATIBILITY): New macro.
* config/sparc/sol2.h (SUN_V9_ABI_COMPATIBILITY): Redefine it.
* config/sparc/sparc.cc (fp_type_for_abi): New predicate.
(traverse_record_type): Use it to spot floating-point types.
(compute_fp_layout): Also deal with array types.

gcc/testsuite/
* gcc.target/sparc/small-struct-1.c: New test.
* gcc.target/sparc/pr105573.c: Rename to...
* gcc.target/sparc/20230425-1.c: ...this.
* gcc.target/sparc/pr109541.c: Rename to...
* gcc.target/sparc/20230607-1.c: ...this

10 days agoRISC-V: Add test cases for insn does not satisfy its constraints [PR114714]
Pan Li [Thu, 25 Apr 2024 07:04:02 +0000 (25 15:04 +0800)]
RISC-V: Add test cases for insn does not satisfy its constraints [PR114714]

We have one ICE when RVV register overlap is enabled.  We reverted this
feature as it is in stage 4 and there is no much time to figure a better
solution for this.  Thus, for now add the related test cases which will
trigger ICE when register overlap enabled.

This will gate the RVV register overlap support in GCC-15.

PR target/114714

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/pr114714-1.C: New test.
* g++.target/riscv/rvv/base/pr114714-2.C: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-Authored-by: Kito Cheng <kito.cheng@sifive.com>
10 days agoRISC-V: Add early clobber to the dest of vwsll
Pan Li [Thu, 25 Apr 2024 00:55:08 +0000 (25 08:55 +0800)]
RISC-V: Add early clobber to the dest of vwsll

We missed the existing early clobber for the dest operand of vwsll
pattern when resolve the conflict of revert register overlap.  Thus
add it back to the pattern.  Unfortunately, we have no test to cover
this part and will improve this after GCC-15 open.

The below tests are passed for this patch:
* The rv64gcv fully regression test with isl build.

gcc/ChangeLog:

* config/riscv/vector-crypto.md: Add early clobber to the
dest operand of vwsll.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 days agoFortran: Fix ICE in gfc_trans_create_temp_array from bad type [PR93678]
Paul Thomas [Thu, 25 Apr 2024 05:56:10 +0000 (25 06:56 +0100)]
Fortran: Fix ICE in gfc_trans_create_temp_array from bad type [PR93678]

2024-04-25  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93678
* trans-expr.cc (gfc_conv_procedure_call): Use the interface,
where possible, to obtain the type of character procedure
pointers of class entities.

gcc/testsuite/
PR fortran/93678
* gfortran.dg/pr93678.f90: New test.

10 days agoFortran: Generate new charlens for shared symbol typespecs [PR89462]
Paul Thomas [Thu, 25 Apr 2024 05:52:31 +0000 (25 06:52 +0100)]
Fortran: Generate new charlens for shared symbol typespecs [PR89462]

2024-04-25  Paul Thomas  <pault@gcc.gnu.org>
    Jakub Jelinek  <jakub@gcc.gnu.org>

gcc/fortran
PR fortran/89462
* decl.cc (build_sym): Add an extra argument 'elem'. If 'elem'
is greater than 1, gfc_new_charlen is called to generate a new
charlen, registered in the symbol namespace.
(variable_decl, enumerator_decl): Set the new argument in the
calls to build_sym.

gcc/testsuite/
PR fortran/89462
* gfortran.dg/pr89462.f90: New test.

10 days agors6000: Use bcdsub. instead of bcdadd. for bcd invalid number checking
Haochen Gui [Thu, 25 Apr 2024 01:55:53 +0000 (25 09:55 +0800)]
rs6000: Use bcdsub. instead of bcdadd. for bcd invalid number checking

bcdadd. might causes overflow which also set the overflow/invalid bit.
bcdsub. doesn't have the issue when do subtracting on two same bcd number.

gcc/
* config/rs6000/altivec.md (*bcdinvalid_<mode>): Replace bcdadd
with bcdsub.
(bcdinvalid_<mode>): Likewise.

gcc/testsuite/
* gcc.target/powerpc/bcd-4.c: Adjust the number of bcdadd and
bcdsub.

10 days agoRISC-V: Add xfail test case for highpart register overlap of vwcvt
Pan Li [Wed, 24 Apr 2024 15:09:24 +0000 (24 23:09 +0800)]
RISC-V: Add xfail test case for highpart register overlap of vwcvt

We reverted below patch for register group overlap, add the related
insn test and mark it as xfail.  And we will remove the xfail
after we support the register overlap in GCC-15.

bdad036da32 RISC-V: Support highpart register overlap for vwcvt

The below test suites are passed for this patch
* The rv64gcv fully regression test with isl build.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr112431-1.c: New test.
* gcc.target/riscv/rvv/base/pr112431-2.c: New test.
* gcc.target/riscv/rvv/base/pr112431-3.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 days agoDaily bump.
GCC Administrator [Thu, 25 Apr 2024 00:16:34 +0000 (25 00:16 +0000)]
Daily bump.

10 days agoc++/modules testsuite: restrict expensive pr99023 test
Patrick Palka [Wed, 24 Apr 2024 21:51:54 +0000 (24 17:51 -0400)]
c++/modules testsuite: restrict expensive pr99023 test

The pr99023 testcase uses --param=ggc-min-expand=0 which forces a GC
during every collection point and consequently is very slow to run,
and ends up being the main bottleneck of the modules.exp testsuite.

So this patch restricts this test to run once, in C++20 mode, instead of
multiple times (C++17, C++20 and C++23 mode by default).  After this
patch the modules.exp testsuite finishes in 3m instead of 3m40s with -j8
on my machine.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr99023_a.X: Run only in C++20 mode.
* g++.dg/modules/pr99023_b.X: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 days agoc++: constexpr union member access folding [PR114709]
Patrick Palka [Wed, 24 Apr 2024 21:49:56 +0000 (24 17:49 -0400)]
c++: constexpr union member access folding [PR114709]

The object/offset canonicalization performed in cxx_fold_indirect_ref
is undesirable for union member accesses because it loses information
about the member being accessed which we may later need to diagnose an
inactive-member access.  So this patch restricts the canonicalization
accordingly.

PR c++/114709

gcc/cp/ChangeLog:

* constexpr.cc (cxx_fold_indirect_ref): Restrict object/offset
canonicalization to RECORD_TYPE member accesses.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-union8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 days agov2: DOCUMENTATION_ROOT_URL vs. release branches [PR114738]
Jakub Jelinek [Wed, 24 Apr 2024 16:29:12 +0000 (24 18:29 +0200)]
v2: DOCUMENTATION_ROOT_URL vs. release branches [PR114738]

This patch moves the documentation root URL infix for release branches
from get_option_url/make_doc_url to configure, such that only the default
changes and when users specify a custom documentation root URL, they don't
have to add gcc-MAJOR.MINOR.0 subdirectories for release branches.

Tested by checking
../configure --disable-bootstrap --enable-languages=c --disable-multilib
built trunk on
void
foo (int x)
{
  __builtin_printf ("%ld\n", x);
}
testcase and looking for the URL in there, then repeating that after
changing gcc/BASE-VER to 14.1.0 and again after changing it to 14.1.1,
plus normal bootstrap/regtest.

2024-04-24  Jakub Jelinek  <jakub@redhat.com>

PR other/114738
* opts.cc (get_option_url): Revert 2024-04-17 changes.
* gcc-urlifier.cc: Don't include diagnostic-core.h.
(gcc_urlifier::make_doc_url): Revert 2024-04-17 changes.
* configure.ac (documentation-root-url): On release branches
append gcc-MAJOR.MINOR.0/ to the default DOCUMENTATION_ROOT_URL.
* doc/install.texi (--with-documentation-root-url=): Document
the change of the default.
* configure: Regenerate.

11 days agoRevert "RISC-V: Support highpart register overlap for vwcvt"
Pan Li [Wed, 24 Apr 2024 11:20:39 +0000 (24 19:20 +0800)]
Revert "RISC-V: Support highpart register overlap for vwcvt"

This reverts commit bdad036da32f72b84a96070518e7d75c21706dc2.

11 days agobpf: define BPF feature pre-processor macros
Jose E. Marchesi [Wed, 24 Apr 2024 11:48:51 +0000 (24 13:48 +0200)]
bpf: define BPF feature pre-processor macros

This commit makes the BPF backend to define the following macros for
c-family languages:

  __BPF_CPU_VERSION__

    This is a numeric value identifying the version of the BPF "cpu"
    for which GCC is generating code.

  __BPF_FEATURE_ALU32
  __BPF_FEATURE_JMP32
  __BPF_FEATURE_JMP_EXT
  __BPF_FEATURE_BSWAP
  __BPF_FEATURE_SDIV_SMOD
  __BPF_FEATURE_MOVSX
  __BPF_FEATURE_LDSX
  __BPF_FEATURE_GOTOL
  __BPF_FEATURE_ST

    These are defines if the corresponding "feature" is enabled.  The
    features are implicitly enabled by the BPF CPU version enabled,
    and most of them can also be enabled/disabled using
    target-specific -m[no-]FEATURE command line switches.

Note that this patch moves the definition of bpf_target_macros, that
implements TARGET_CPU_CPP_BUILTINS in the BPF backend, to a bpf-c.cc
file.  This is because we are now using facilities from c-family/* and
these features are not available in compilers like lto1.

A couple of tests are also added.
Tested in target bpf-unknown-none-gcc and host x86_64-linux-gnu.
No regressions.

gcc/ChangeLog

* config.gcc: Add bpf-c.o as a target object for C and C++.
* config/bpf/bpf.cc (bpf_target_macros): Move to bpf-c.cc.
* config/bpf/bpf-c.cc: New file.
(bpf_target_macros): Move from bpf.cc and define BPF CPU
feature macros.
* config/bpf/t-bpf: Add rules to build bpf-c.o.

gcc/testsuite/ChangeLog

* gcc.target/bpf/feature-macro-1.c: New test.
* gcc.target/bpf/feature-macro-2.c: Likewise.