]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
18 months agotweak get_source_text_between comment devel/c++-contracts
Jason Merrill [Fri, 4 Nov 2022 17:05:06 +0000 (13:05 -0400)] 
tweak get_source_text_between comment

18 months agotest predicate output
Jason Merrill [Fri, 4 Nov 2022 13:47:56 +0000 (09:47 -0400)] 
test predicate output

18 months agoupdate get_source_text_between
Jason Merrill [Fri, 4 Nov 2022 01:42:54 +0000 (21:42 -0400)] 
update get_source_text_between

18 months agoremove remove_contracts_from_specialization
Jason Merrill [Fri, 4 Nov 2022 01:16:50 +0000 (21:16 -0400)] 
remove remove_contracts_from_specialization

18 months agodoc: add contracts flags
Jason Merrill [Thu, 3 Nov 2022 22:26:29 +0000 (18:26 -0400)] 
doc: add contracts flags

18 months agocomment tweaks
Jason Merrill [Thu, 3 Nov 2022 19:59:38 +0000 (15:59 -0400)] 
comment tweaks

18 months agoinput: rename get_source to get_source_text_between
Jason Merrill [Thu, 3 Nov 2022 19:44:25 +0000 (15:44 -0400)] 
input: rename get_source to get_source_text_between

Let's use a more informative name.

gcc/ChangeLog:

* input.h:
* input.cc (get_source):
Rename to get_source_text_between.

gcc/cp/ChangeLog:

* contracts.cc (build_comment): Adjust.

18 months agoc++: friend contracts are in complete-class context
Jason Merrill [Wed, 2 Nov 2022 19:21:29 +0000 (15:21 -0400)] 
c++: friend contracts are in complete-class context

Comparing friend contracts to a previous declaration was awkward
because at the point of duplicate_decls we haven't parsed the new ones yet,
and we're about to throw away one of the decls.  But conveniently, there's
already defer_guarded_contract_match to handle this.

This reverts commit 9c0d8bfebc32d5e2c35ed61753440fb175a87dcf.

gcc/cp/ChangeLog:

* contracts.cc (check_for_mismatched_contracts):
Only check new_contract for deferred.
(match_deferred_contracts): Set processing_template_decl.
(duplicate_contracts): Call defer_guarded_contract_match
for friend decl.  Handle templates.
* decl.cc (duplicate_decls): Use it for templates.
* parser.h (struct cp_parser): Remove declaring_friend_p.
* parser.cc (cp_parser_new): Don't clear it.
(cp_parser_direct_declarator): Don't set it.
(cp_parser_contract_attribute_spec): Don't check it.
* contracts.h (match_contract_conditions): Remove.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts-friend1.C: Revert.
* g++.dg/contracts/contracts-nested-class1.C: Revert.
* g++.dg/contracts/contracts-redecl7.C: Revert.
* g++.dg/contracts/contracts-redecl8.C: Revert.

18 months agoc++: fix assume test
Jason Merrill [Wed, 2 Nov 2022 18:50:04 +0000 (14:50 -0400)] 
c++: fix assume test

18 months agoc++: more tidying
Jason Merrill [Tue, 1 Nov 2022 13:45:00 +0000 (09:45 -0400)] 
c++: more tidying

Move more macros to contracts.h, remove unnecessary extern decls, tweak
comments, remove DECL_ORIGINAL_FN.

18 months agoc++: small refactor
Jason Merrill [Tue, 1 Nov 2022 15:27:18 +0000 (11:27 -0400)] 
c++: small refactor

Reducing the number of places that check DECL_{CONS,DES}TRUCTOR_P to decide
whether to outline the contracts.

18 months agolibstdc++: reorder contract_violation
Jason Merrill [Tue, 1 Nov 2022 14:38:02 +0000 (10:38 -0400)] 
libstdc++: reorder contract_violation

Moving the int after the pointers makes the object one word smaller.

18 months agoMerge remote-tracking branch 'origin/master' into devel/c++-contracts
Jason Merrill [Tue, 1 Nov 2022 02:18:58 +0000 (22:18 -0400)] 
Merge remote-tracking branch 'origin/master' into devel/c++-contracts

18 months agoc++: more tidying
Jason Merrill [Mon, 31 Oct 2022 15:36:05 +0000 (11:36 -0400)] 
c++: more tidying

gcc/cp/ChangeLog:

* contracts.h: Move lots of decls from...
* cp-tree.h: ...here.
* contracts.cc (cp_contract_assertion_p): Move from parser.cc.
(inherit_base_contracts): Move from search.cc.
* decl.cc (grokdeclarator): Don't use function_declarator_p.
* decl2.cc (cp_tree_defined_p_r)
(cp_tree_defined_p): Remove.
* module.cc (trees_out::fn_parms_init): Tweak comment.
* parser.cc (cp_contract_assertion_p): Moved.
(find_innermost_function_declarator)
(function_declarator_p): Revert.
(cp_parser_function_definition_after_declarator): Remove dead assignment.
(cp_parser_save_default_args): Tweak formatting.
* search.cc (inherit_base_contracts): Moved.

gcc/ChangeLog:

* input.cc (get_source): Tweak comments.

18 months agoc++: pass std attributes to make_call_declarator
Jason Merrill [Mon, 31 Oct 2022 17:40:10 +0000 (13:40 -0400)] 
c++: pass std attributes to make_call_declarator

It seems preferable to pass these to the function rather than set them
separately after the call.

gcc/cp/ChangeLog:

* parser.cc (make_call_declarator): Add std_attrs parm.
(cp_parser_lambda_declarator_opt): Pass it.
(cp_parser_direct_declarator): Pass it.

18 months agoc++: set TREE_NOTHROW after genericize
Jason Merrill [Mon, 31 Oct 2022 17:38:41 +0000 (13:38 -0400)] 
c++: set TREE_NOTHROW after genericize

genericize might introduce function calls (and does on the contracts
branch), so it's safer to set this flag later.

gcc/cp/ChangeLog:

* decl.cc (finish_function): Set TREE_NOTHROW later in the function.

18 months agoc++: formatting tweaks
Jason Merrill [Mon, 31 Oct 2022 17:37:13 +0000 (13:37 -0400)] 
c++: formatting tweaks

gcc/cp/ChangeLog:

* decl.cc (duplicate_decls): Reformat loop.
* parser.cc (cp_parser_member_declaration): Add newline.
* semantics.cc: Remove newline.

18 months agoAdd attribute hot judgement for INLINE_HINT_known_hot hint.
Cui,Lili [Tue, 1 Nov 2022 01:16:49 +0000 (09:16 +0800)] 
Add attribute hot judgement for INLINE_HINT_known_hot hint.

We set up INLINE_HINT_known_hot hint only when we have profile feedback,
now add function attribute judgement for it, when both caller and callee
have __attribute__((hot)), we will also set up INLINE_HINT_known_hot hint
for it.

With this patch applied,
ADL Multi-copy:    538.imagic_r  16.7%
ICX Multi-copy:    538.imagic_r  15.2%
CLX Multi-copy:    538.imagic_r  12.7%
Znver3 Multi-copy: 538.imagic_r  10.6%
Arm Multi-copy:    538.imagic_r  13.4%

gcc/ChangeLog

* ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute
judgement for INLINE_HINT_known_hot hint.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/inlinehint-6.c: New test.

18 months agoDaily bump.
GCC Administrator [Tue, 1 Nov 2022 00:19:02 +0000 (00:19 +0000)] 
Daily bump.

18 months agoRISC-V: Libitm add RISC-V support.
Xiongchuan Tan [Mon, 31 Oct 2022 22:16:26 +0000 (16:16 -0600)] 
RISC-V: Libitm add RISC-V support.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
libitm/ChangeLog:

* configure.tgt: Add riscv support.
* config/riscv/asm.h: New file.
* config/riscv/sjlj.S: New file.
* config/riscv/target.h: New file.

18 months agolibstdc++-v3: <complex> support for extended floating point types
Jakub Jelinek [Mon, 31 Oct 2022 19:13:02 +0000 (20:13 +0100)] 
libstdc++-v3: <complex> support for extended floating point types

The following patch adds <complex> support for extended floating point
types.
C++23 removes the float/double/long double specializations from the spec
and instead adds explicit(bool) specifier on the converting constructor.
The patch uses that for converting constructor of the base template as well
as the float/double/long double specializations's converting constructors
(e.g. so that it handles convertion construction also from complex of extended
floating point types).  Copy ctor was already defaulted as the spec now
requires.
The patch also adds partial specialization for the _Float{16,32,64,128}
and __gnu_cxx::__bfloat16_t types because the base template doesn't use
__complex__ but a pair of floating point values.
The g++.dg/cpp23/ testcase verifies explicit(bool) works correctly.

2022-10-31  Jakub Jelinek  <jakub@redhat.com>

gcc/testsuite/
* g++.dg/cpp23/ext-floating12.C: New test.
libstdc++-v3/
* include/std/complex (complex::complex converting ctor): For C++23
use explicit specifier with constant expression.  Explicitly cast
both parts to _Tp.
(__complex_abs, __complex_arg, __complex_cos, __complex_cosh,
__complex_exp, __complex_log, __complex_sin, __complex_sinh,
__complex_sqrt, __complex_tan, __complex_tanh, __complex_pow): Add
__complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16)
overloads.
(complex<float>::complex converting ctor,
complex<double>::complex converting ctor,
complex<long double>::complex converting ctor): For C++23 implement
as template with explicit specifier with constant expression
and explicit casts.
(__complex_type): New template.
(complex): New partial specialization for types with extended floating
point types.
(__complex_acos, __complex_asin, __complex_atan, __complex_acosh,
__complex_asinh, __complex_atanh): Add __complex__ _Float{16,32,64,128}
and __complex__ decltype(0.0bf16) overloads.
(__complex_proj): Likewise.  Add template for complex of extended
floating point types.
* include/bits/cpp_type_traits.h (__is_floating): Specialize for
_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t.
* testsuite/26_numerics/complex/ext_c++23.cc: New test.

18 months agobtf: Add support to BTF_KIND_ENUM64 type
Guillermo E. Martinez [Mon, 31 Oct 2022 16:32:50 +0000 (09:32 -0700)] 
btf: Add support to BTF_KIND_ENUM64 type

BTF supports 64-bits enumerators with following encoding:

  struct btf_type:
    name_off: 0 or offset to a valid C identifier
    info.kind_flag: 0 for unsigned, 1 for signed
    info.kind: BTF_KIND_ENUM64
    info.vlen: number of enum values
    size: 1/2/4/8

The btf_type is followed by info.vlen number of:

    struct btf_enum64
    {
      uint32_t name_off;   /* Offset in string section of enumerator name.  */
      uint32_t val_lo32;   /* lower 32-bit value for a 64-bit value Enumerator */
      uint32_t val_hi32;   /* high 32-bit value for a 64-bit value Enumerator */
    };

So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64
and a new field dtd_enum_unsigned in ctf_dtdef structure to distinguish
when CTF enum is a signed or unsigned type, later that information is
used to encode the BTF enum type.

gcc/ChangeLog:

* btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of
enumerator type btf_enum{,64}.
(btf_asm_type): Update btf_kflag according to enumeration type sign
using dtd_enum_unsigned field for both:  BTF_KIND_ENUM{,64}.
(btf_asm_enum_const): New argument to represent the size of
the BTF enum type, writing the enumerator constant value for
32 bits, if it's 64 bits then explicitly writes lower 32-bits
value and higher 32-bits value.
(output_asm_btf_enum_list): Add enumeration size argument.
* ctfc.cc (ctf_add_enum): New argument to represent CTF enum
basic information.
(ctf_add_generic): Use of ei_{name. size, unsigned} to build the
dtd structure containing enumeration information.
(ctf_add_enumerator): Update comment mention support for BTF
enumeration in 64-bits.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness
for enumeration type and use it in ctf_add_enum.
* ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow
use 32/64 bits enumerators.
information.
(ctf_dtdef): New field to describe enum signedness.

include/
* btf.h (btf_enum64): Add new definition and new symbolic
constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct
info.kflags encoding.
* gcc.dg/debug/btf/btf-enum64-1.c: New testcase.

18 months agoc++: don't add contracted fns to unparsed_funs.
Jason Merrill [Fri, 28 Oct 2022 16:08:06 +0000 (12:08 -0400)] 
c++: don't add contracted fns to unparsed_funs.

They get their own late parse.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_member_declaration): Don't add
fn with contracts to unparsed_funs_with_definitions.

18 months agolibstdc++: Small extended float support tweaks
Jakub Jelinek [Mon, 31 Oct 2022 15:47:23 +0000 (16:47 +0100)] 
libstdc++: Small extended float support tweaks

The following patch
1) enables the std::float128_t overloads for x86 with glibc 2.26+
2) makes std::nextafter(std::float16_t, std::float16_t) and
   std::nextafter(std::bfloat16_t, std::bfloat16_t) constexpr
3) adds (small) testsuite coverage for that

2022-10-21  Jakub Jelinek  <jakub@redhat.com>

* config/os/gnu-linux/os_defines.h (_GLIBCXX_HAVE_FLOAT128_MATH):
Uncomment.
* include/c_global/cmath (nextafter(_Float16, _Float16)): Make it constexpr.
If std::__is_constant_evaluated() call __builtin_nextafterf16.
(nextafter(__gnu_cxx::__bfloat16_t, __gnu_cxx::__bfloat16_t)): Similarly
but call __builtin_nextafterf16b.
* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc (test): Add
static assertions to test constexpr nextafter.

18 months agoRISC-V: Change constexpr back to CONSTEXPR
Ju-Zhe Zhong [Thu, 27 Oct 2022 14:41:52 +0000 (22:41 +0800)] 
RISC-V: Change constexpr back to CONSTEXPR

According to https://github.com/gcc-mirror/gcc/commit/f95d3d5de72a1c43e8d529bad3ef59afc3214705.
Since GCC 4.8.6 doesn't support constexpr, we should change it back to CONSTEXPR.
gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-bases.cc: Change constexpr back to CONSTEXPR.
* config/riscv/riscv-vector-builtins-shapes.cc (SHAPE): Ditto.
* config/riscv/riscv-vector-builtins.cc (struct registered_function_hasher): Ditto.
* config/riscv/riscv-vector-builtins.h (struct rvv_arg_type_info): Ditto.

18 months agoamdgcn: add fmin/fmax patterns
Andrew Stubbs [Fri, 28 Oct 2022 12:09:20 +0000 (13:09 +0100)] 
amdgcn: add fmin/fmax patterns

Add fmin/fmax for scalar, vector, and reductions.  The smin/smax patterns are
already using the IEEE compliant hardware instructions anyway, so we can just
expand to use those insns.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (fminmaxop): New iterator.
(<fexpander><mode>3): New define_expand.
(<fexpander><mode>3<exec>): Likewise.
(reduc_<fexpander>_scal_<mode>): Likewise.
* config/gcn/gcn.md (fexpander): New attribute.

18 months agoamdgcn: multi-size vector reductions
Andrew Stubbs [Fri, 28 Oct 2022 11:38:43 +0000 (12:38 +0100)] 
amdgcn: multi-size vector reductions

Add support for vector reductions for any vector width by switching iterators
and generalising the code slightly.  There's no one-instruction way to move an
item from lane 31 to lane 0 (63, 15, 7, 3, and 1 are all fine though), and
vec_extract is probably fewer cycles anyway, so now we always reduce to an
SGPR.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (V64_SI): Delete iterator.
(V64_DI): Likewise.
(V64_1REG): Likewise.
(V64_INT_1REG): Likewise.
(V64_2REG): Likewise.
(V64_ALL): Likewise.
(V64_FP): Likewise.
(reduc_<reduc_op>_scal_<mode>): Use V_ALL. Use gen_vec_extract.
(fold_left_plus_<mode>): Use V_FP.
(*<reduc_op>_dpp_shr_<mode>): Use V_1REG.
(*<reduc_op>_dpp_shr_<mode>): Use V_DI.
(*plus_carry_dpp_shr_<mode>): Use V_INT_1REG.
(*plus_carry_in_dpp_shr_<mode>): Use V_SI.
(*plus_carry_dpp_shr_<mode>): Use V_DI.
(mov_from_lane63_<mode>): Delete.
(mov_from_lane63_<mode>): Delete.
* config/gcn/gcn.cc (gcn_expand_reduc_scalar): Support partial vectors.
* config/gcn/gcn.md (unspec): Remove UNSPEC_MOV_FROM_LANE63.

18 months agoamdgcn: Silence unused parameter warning
Andrew Stubbs [Mon, 24 Oct 2022 13:05:03 +0000 (14:05 +0100)] 
amdgcn: Silence unused parameter warning

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_simd_clone_compute_vecsize_and_simdlen):
Set base_type as ARG_UNUSED.

18 months agoUpdate email address
Ramana Radhakrishnan [Mon, 31 Oct 2022 11:07:27 +0000 (11:07 +0000)] 
Update email address

/
* MAINTAINERS: Update email address.

18 months agoLibvtv: Add loongarch support.
Lulu Cheng [Tue, 27 Sep 2022 07:28:43 +0000 (15:28 +0800)] 
Libvtv: Add loongarch support.

The loongarch64 specification permits page sizes of 4KiB, 16KiB and 64KiB,
but only 16KiB pages are supported for now.

Co-Authored-By: qijingwen <qijingwen@loongson.cn>
include/ChangeLog:

* vtv-change-permission.h (defined): Determines whether the macro
__loongarch_lp64 is defined
(VTV_PAGE_SIZE): Set VTV_PAGE_SIZE to 16KiB for loongarch64.

libvtv/ChangeLog:

* configure.tgt: Add loongarch support.

18 months agobuiltins: Add various complex builtins for _Float{16,32,64,128,32x,64x,128x}
Jakub Jelinek [Mon, 31 Oct 2022 08:09:48 +0000 (09:09 +0100)] 
builtins: Add various complex builtins for _Float{16,32,64,128,32x,64x,128x}

The following patch adds some complex builtins which have libm
implementation in glibc 2.26 and later on various arches.
It is needed for libstdc++ _Float128 support when long double is not
IEEE quad.

2022-10-31  Jakub Jelinek  <jakub@redhat.com>

* builtin-types.def (BT_COMPLEX_FLOAT16, BT_COMPLEX_FLOAT32,
BT_COMPLEX_FLOAT64, BT_COMPLEX_FLOAT128, BT_COMPLEX_FLOAT32X,
BT_COMPLEX_FLOAT64X, BT_COMPLEX_FLOAT128X,
BT_FN_COMPLEX_FLOAT16_COMPLEX_FLOAT16,
BT_FN_COMPLEX_FLOAT32_COMPLEX_FLOAT32,
BT_FN_COMPLEX_FLOAT64_COMPLEX_FLOAT64,
BT_FN_COMPLEX_FLOAT128_COMPLEX_FLOAT128,
BT_FN_COMPLEX_FLOAT32X_COMPLEX_FLOAT32X,
BT_FN_COMPLEX_FLOAT64X_COMPLEX_FLOAT64X,
BT_FN_COMPLEX_FLOAT128X_COMPLEX_FLOAT128X,
BT_FN_FLOAT16_COMPLEX_FLOAT16, BT_FN_FLOAT32_COMPLEX_FLOAT32,
BT_FN_FLOAT64_COMPLEX_FLOAT64, BT_FN_FLOAT128_COMPLEX_FLOAT128,
BT_FN_FLOAT32X_COMPLEX_FLOAT32X, BT_FN_FLOAT64X_COMPLEX_FLOAT64X,
BT_FN_FLOAT128X_COMPLEX_FLOAT128X,
BT_FN_COMPLEX_FLOAT16_COMPLEX_FLOAT16_COMPLEX_FLOAT16,
BT_FN_COMPLEX_FLOAT32_COMPLEX_FLOAT32_COMPLEX_FLOAT32,
BT_FN_COMPLEX_FLOAT64_COMPLEX_FLOAT64_COMPLEX_FLOAT64,
BT_FN_COMPLEX_FLOAT128_COMPLEX_FLOAT128_COMPLEX_FLOAT128,
BT_FN_COMPLEX_FLOAT32X_COMPLEX_FLOAT32X_COMPLEX_FLOAT32X,
BT_FN_COMPLEX_FLOAT64X_COMPLEX_FLOAT64X_COMPLEX_FLOAT64X,
BT_FN_COMPLEX_FLOAT128X_COMPLEX_FLOAT128X_COMPLEX_FLOAT128X): New.
* builtins.def (CABS_TYPE, CACOSH_TYPE, CARG_TYPE, CASINH_TYPE,
CPOW_TYPE, CPROJ_TYPE): Define and undefine later.
(BUILT_IN_CABS, BUILT_IN_CACOSH, BUILT_IN_CACOS, BUILT_IN_CARG,
BUILT_IN_CASINH, BUILT_IN_CASIN, BUILT_IN_CATANH, BUILT_IN_CATAN,
BUILT_IN_CCOSH, BUILT_IN_CCOS, BUILT_IN_CEXP, BUILT_IN_CLOG,
BUILT_IN_CPOW, BUILT_IN_CPROJ, BUILT_IN_CSINH, BUILT_IN_CSIN,
BUILT_IN_CSQRT, BUILT_IN_CTANH, BUILT_IN_CTAN): Add
DEF_EXT_LIB_FLOATN_NX_BUILTINS.
* fold-const-call.cc (fold_const_call_sc, fold_const_call_cc,
fold_const_call_ccc): Add various CASE_CFN_*_FN: cases when
CASE_CFN_* is present.
* gimple-ssa-backprop.cc (backprop::process_builtin_call_use):
Likewise.
* builtins.cc (expand_builtin, fold_builtin_1): Likewise.
* fold-const.cc (negate_mathfn_p, tree_expr_finite_p,
tree_expr_maybe_signaling_nan_p, tree_expr_maybe_nan_p,
tree_expr_maybe_real_minus_zero_p, tree_call_nonnegative_warnv_p):
Likewise.

18 months agobuiltins: Add __builtin_nextafterf16b builtin
Jakub Jelinek [Mon, 31 Oct 2022 08:07:04 +0000 (09:07 +0100)] 
builtins: Add __builtin_nextafterf16b builtin

The following patch adds another needed builtin.
The earlier patch adds among other things __builtin_nextafterf16
builtin which we need in order to constexpr evaluate
std::nextafter(_Float16) overload (patch for that has been posted already).
While there is inline implementation of the overload, it isn't constant
evaluation friendly, and the builtin doesn't need libm implementation
because it will be used only during constant expression evaluation.
We need the same thing also for std::nextafter(__gnu_cxx::__bfloat16_t)
though and this patch does that.

2022-10-31  Jakub Jelinek  <jakub@redhat.com>

* builtin-types.def (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16): New.
* builtins.def (BUILT_IN_NEXTAFTERF16B): New builtin.
* fold-const-call.cc (fold_const_call_sss): Handle
CFN_BUILT_IN_NEXTAFTERF16B.

18 months agobuiltins: Add various __builtin_*f{16,32,64,128,32x,64x,128x} builtins
Jakub Jelinek [Mon, 31 Oct 2022 08:05:02 +0000 (09:05 +0100)] 
builtins: Add various __builtin_*f{16,32,64,128,32x,64x,128x} builtins

When working on libstdc++ extended float support in <cmath>, I found that
we need various builtins for the _Float{16,32,64,128,32x,64x,128x} types.
Glibc 2.26 and later provides the underlying libm routines (except for
_Float16 and _Float128x for the time being) and in libstdc++ I think we
need at least the _Float128 builtins on x86_64, i?86, powerpc64le and ia64
(when long double is IEEE quad, we can handle it by using __builtin_*l
instead), because without the builtins the overloads couldn't be constexpr
(say when it would declare the *f128 extern "C" routines itself and call
them).

The testcase covers just types of those builtins and their constant
folding, so doesn't need actual libm support.

2022-10-31  Jakub Jelinek  <jakub@redhat.com>

* builtin-types.def (BT_FLOAT16_PTR, BT_FLOAT32_PTR, BT_FLOAT64_PTR,
BT_FLOAT128_PTR, BT_FLOAT32X_PTR, BT_FLOAT64X_PTR, BT_FLOAT128X_PTR):
New DEF_PRIMITIVE_TYPE.
(BT_FN_INT_FLOAT16, BT_FN_INT_FLOAT32, BT_FN_INT_FLOAT64,
BT_FN_INT_FLOAT128, BT_FN_INT_FLOAT32X, BT_FN_INT_FLOAT64X,
BT_FN_INT_FLOAT128X, BT_FN_LONG_FLOAT16, BT_FN_LONG_FLOAT32,
BT_FN_LONG_FLOAT64, BT_FN_LONG_FLOAT128, BT_FN_LONG_FLOAT32X,
BT_FN_LONG_FLOAT64X, BT_FN_LONG_FLOAT128X, BT_FN_LONGLONG_FLOAT16,
BT_FN_LONGLONG_FLOAT32, BT_FN_LONGLONG_FLOAT64,
BT_FN_LONGLONG_FLOAT128, BT_FN_LONGLONG_FLOAT32X,
BT_FN_LONGLONG_FLOAT64X, BT_FN_LONGLONG_FLOAT128X): New
DEF_FUNCTION_TYPE_1.
(BT_FN_FLOAT16_FLOAT16_FLOAT16PTR, BT_FN_FLOAT32_FLOAT32_FLOAT32PTR,
BT_FN_FLOAT64_FLOAT64_FLOAT64PTR, BT_FN_FLOAT128_FLOAT128_FLOAT128PTR,
BT_FN_FLOAT32X_FLOAT32X_FLOAT32XPTR,
BT_FN_FLOAT64X_FLOAT64X_FLOAT64XPTR,
BT_FN_FLOAT128X_FLOAT128X_FLOAT128XPTR, BT_FN_FLOAT16_FLOAT16_INT,
BT_FN_FLOAT32_FLOAT32_INT, BT_FN_FLOAT64_FLOAT64_INT,
BT_FN_FLOAT128_FLOAT128_INT, BT_FN_FLOAT32X_FLOAT32X_INT,
BT_FN_FLOAT64X_FLOAT64X_INT, BT_FN_FLOAT128X_FLOAT128X_INT,
BT_FN_FLOAT16_FLOAT16_INTPTR, BT_FN_FLOAT32_FLOAT32_INTPTR,
BT_FN_FLOAT64_FLOAT64_INTPTR, BT_FN_FLOAT128_FLOAT128_INTPTR,
BT_FN_FLOAT32X_FLOAT32X_INTPTR, BT_FN_FLOAT64X_FLOAT64X_INTPTR,
BT_FN_FLOAT128X_FLOAT128X_INTPTR, BT_FN_FLOAT16_FLOAT16_LONG,
BT_FN_FLOAT32_FLOAT32_LONG, BT_FN_FLOAT64_FLOAT64_LONG,
BT_FN_FLOAT128_FLOAT128_LONG, BT_FN_FLOAT32X_FLOAT32X_LONG,
BT_FN_FLOAT64X_FLOAT64X_LONG, BT_FN_FLOAT128X_FLOAT128X_LONG): New
DEF_FUNCTION_TYPE_2.
(BT_FN_FLOAT16_FLOAT16_FLOAT16_INTPTR,
BT_FN_FLOAT32_FLOAT32_FLOAT32_INTPTR,
BT_FN_FLOAT64_FLOAT64_FLOAT64_INTPTR,
BT_FN_FLOAT128_FLOAT128_FLOAT128_INTPTR,
BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_INTPTR,
BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_INTPTR,
BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_INTPTR): New DEF_FUNCTION_TYPE_3.
* builtins.def (ACOSH_TYPE, ATAN2_TYPE, ATANH_TYPE, COSH_TYPE,
FDIM_TYPE, HUGE_VAL_TYPE, HYPOT_TYPE, ILOGB_TYPE, LDEXP_TYPE,
LGAMMA_TYPE, LLRINT_TYPE, LOG10_TYPE, LRINT_TYPE, MODF_TYPE,
NEXTAFTER_TYPE, REMQUO_TYPE, SCALBLN_TYPE, SCALBN_TYPE, SINH_TYPE):
Define and undefine later.
(FMIN_TYPE, SQRT_TYPE): Undefine at a later line.
(INF_TYPE): Define at a later line.
(BUILT_IN_ACOSH, BUILT_IN_ACOS, BUILT_IN_ASINH, BUILT_IN_ASIN,
BUILT_IN_ATAN2, BUILT_IN_ATANH, BUILT_IN_ATAN, BUILT_IN_CBRT,
BUILT_IN_COSH, BUILT_IN_COS, BUILT_IN_ERFC, BUILT_IN_ERF,
BUILT_IN_EXP2, BUILT_IN_EXP, BUILT_IN_EXPM1, BUILT_IN_FDIM,
BUILT_IN_FMOD, BUILT_IN_FREXP, BUILT_IN_HYPOT, BUILT_IN_ILOGB,
BUILT_IN_LDEXP, BUILT_IN_LGAMMA, BUILT_IN_LLRINT, BUILT_IN_LLROUND,
BUILT_IN_LOG10, BUILT_IN_LOG1P, BUILT_IN_LOG2, BUILT_IN_LOGB,
BUILT_IN_LOG, BUILT_IN_LRINT, BUILT_IN_LROUND, BUILT_IN_MODF,
BUILT_IN_NEXTAFTER, BUILT_IN_POW, BUILT_IN_REMAINDER, BUILT_IN_REMQUO,
BUILT_IN_SCALBLN, BUILT_IN_SCALBN, BUILT_IN_SINH, BUILT_IN_SIN,
BUILT_IN_TANH, BUILT_IN_TAN, BUILT_IN_TGAMMA): Add
DEF_EXT_LIB_FLOATN_NX_BUILTINS.
(BUILT_IN_HUGE_VAL): Use HUGE_VAL_TYPE instead of INF_TYPE in
DEF_GCC_FLOATN_NX_BUILTINS.
* fold-const-call.cc (fold_const_call_ss): Add various CASE_CFN_*_FN:
cases when CASE_CFN_* is present.
(fold_const_call_sss): Likewise.
* builtins.cc (mathfn_built_in_2): Use CASE_MATHFN_FLOATN instead of
CASE_MATHFN for various builtins in SEQ_OF_CASE_MATHFN macro.
(builtin_with_linkage_p): Add CASE_FLT_FN_FLOATN_NX for various
builtins next to CASE_FLT_FN.
* fold-const.cc (tree_call_nonnegative_warnv_p): Add CASE_CFN_*_FN:
next to CASE_CFN_*: for various builtins.
* tree-call-cdce.cc (can_test_argument_range): Add
CASE_FLT_FN_FLOATN_NX next to CASE_FLT_FN for various builtins.
(edom_only_function): Likewise.

* gcc.dg/torture/floatn-builtin.h: Add tests for newly added builtins.

18 months agoSupport Intel AVX-NE-CONVERT
konglin1 [Mon, 31 Oct 2022 06:39:18 +0000 (14:39 +0800)] 
Support Intel AVX-NE-CONVERT

gcc/ChangeLog:

* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AVXNECONVERT_SET,
OPTION_MASK_ISA2_AVXNECONVERT_UNSET): New.
(ix86_handle_option): Handle -mavxneconvert, unset
avxneconvert when avx2 is disabled.
* common/config/i386/i386-cpuinfo.h (processor_types): Add
FEATURE_AVXNECONVERT.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
avxneconvert.
* common/config/i386/cpuinfo.h (get_available_features):
Detect avxneconvert.
* config.gcc: Add avxneconvertintrin.h
* config/i386/avxneconvertintrin.h: New.
* config/i386/avx512bf16vlintrin.h (_mm256_cvtneps_pbh):
Unified builtin with avxneconvert.
(_mm_cvtneps_pbh): Ditto.
* config/i386/cpuid.h (bit_AVXNECONVERT): New.
* config/i386/i386-builtin-types.def: Add
DEF_POINTER_TYPE (PCV8HF, V8HF, CONST),
DEF_POINTER_TYPE (PCV8BF, V8BF, CONST),
DEF_POINTER_TYPE (PCV16HF, V16HF, CONST),
DEF_POINTER_TYPE (PCV16BF, V16BF, CONST),
DEF_FUNCTION_TYPE (V4SF, PCBFLOAT16),
DEF_FUNCTION_TYPE (V4SF, PCFLOAT16),
DEF_FUNCTION_TYPE (V8SF, PCBFLOAT16),
DEF_FUNCTION_TYPE (V8SF, PCFLOAT16),
DEF_FUNCTION_TYPE (V4SF, PCV8BF),
DEF_FUNCTION_TYPE (V4SF, PCV8HF),
DEF_FUNCTION_TYPE (V8SF, PCV16HF),
DEF_FUNCTION_TYPE (V8SF, PCV16BF),
* config/i386/i386-builtin.def: Add new builtins.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__AVXNECONVERT__.
* config/i386/i386-expand.cc (ix86_expand_special_args_builtin):
Handle V4SF_FTYPE_PCBFLOAT16,V8SF_FTYPE_PCBFLOAT16, V4SF_FTYPE_PCFLOAT16,
V8SF_FTYPE_PCFLOAT16,V4SF_FTYPE_PCV8BF,
V4SF_FTYPE_PCV8HF,V8SF_FTYPE_PCV16BF,V8SF_FTYPE_PCV16HF.
* config/i386/i386-isa.def : Add DEF_PTA(AVXNECONVERT) New.
* config/i386/i386-options.cc (isa2_opts): Add -mavxneconvert.
(ix86_valid_target_attribute_inner_p): Handle avxneconvert.
* config/i386/i386.md: Add attr avx512bf16vl and avxneconvert.
* config/i386/i386.opt: Add option -mavxneconvert.
* config/i386/immintrin.h: Inculde avxneconvertintrin.h.
* config/i386/sse.md (vbcstnebf162ps_<mode>): New define_insn.
(vbcstnesh2ps_<mode>): Ditto.
(vcvtnee<bf16_ph>2ps_<mode>):Ditto.
(vcvtneo<bf16_ph>2ps_<mode>):Ditto.
(vcvtneps2bf16_v4sf): Ditto.
(*vcvtneps2bf16_v4sf): Ditto.
(vcvtneps2bf16_v8sf): Ditto.
* doc/invoke.texi: Document -mavxneconvert.
* doc/extend.texi: Document avxneconvert.
* doc/sourcebuild.texi: Document target avxneconvert.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx-check.h: Add avxneconvert check.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-12.c: Add -mavxneconvert.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* g++.dg/other/i386-2.C: Ditto.
* g++.dg/other/i386-3.C: Ditto.
* lib/target-supports.exp:add check_effective_target_avxneconvert.
* gcc.target/i386/avx-ne-convert-1.c: New test.
* gcc.target/i386/avx-ne-convert-vbcstnebf162ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vbcstnesh2ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vcvtneebf162ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vcvtneeph2ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vcvtneobf162ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vcvtneoph2ps-2.c: Ditto.
* gcc.target/i386/avx-ne-convert-vcvtneps2bf16-2.c: Ditto.
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1.c: Rename..
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1a.c: To this.
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1b.c: New test.

18 months agoi386:: using __bf16 for AVX512BF16 intrinsics
konglin1 [Mon, 31 Oct 2022 06:04:08 +0000 (14:04 +0800)] 
i386:: using __bf16 for AVX512BF16 intrinsics

gcc/ChangeLog:

* config/i386/avx512bf16intrin.h (__attribute__): Change short to bf16.
(_mm_cvtsbh_ss): Ditto.
(_mm512_cvtne2ps_pbh): Ditto.
(_mm512_mask_cvtne2ps_pbh): Ditto.
(_mm512_maskz_cvtne2ps_pbh): Ditto.
* config/i386/avx512bf16vlintrin.h (__attribute__): Ditto.
(_mm256_cvtne2ps_pbh): Ditto.
(_mm256_mask_cvtne2ps_pbh): Ditto.
(_mm256_maskz_cvtne2ps_pbh): Ditto.
(_mm_cvtne2ps_pbh): Ditto.
(_mm_mask_cvtne2ps_pbh): Ditto.
(_mm_maskz_cvtne2ps_pbh): Ditto.
(_mm_cvtness_sbh): Ditto.
* config/i386/i386-builtin-types.def (V8BF): Add new
DEF_VECTOR_TYPE for BFmode.
(V16BF): Ditto.
(V32BF): Ditto.
* config/i386/i386-builtin.def (BDESC): Fixed builtins.
* config/i386/i386-expand.cc (ix86_expand_args_builtin): Changed
avx512bf16 ix86_builtin_func_type included HI to BF.
* config/i386/immintrin.h: Add SSE2 depend for avx512bf16.
* config/i386/sse.md (TARGET_AVX512VL): Changed HI vector to BF
vector.
(avx512f_cvtneps2bf16_v4sf): New define_expand.
(*avx512f_cvtneps2bf16_v4sf): New define_insn.
(avx512f_cvtneps2bf16_v4sf_maskz):Ditto.
(avx512f_cvtneps2bf16_v4sf_mask): Ditto.
(avx512f_cvtneps2bf16_v4sf_mask_1): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512bf16-cvtsbh2ss-1.c: Add fpmath option.
* gcc.target/i386/avx512bf16-vdpbf16ps-2.c: Fixed
scan-assembler.
* gcc.target/i386/avx512bf16vl-cvtness2sbh-1.c: Add x/y suffix
for vcvtneps2bf16.
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1.c: Ditto.

18 months agoEnable V4BFmode and V2BFmode.
liuhongt [Tue, 25 Oct 2022 05:31:54 +0000 (13:31 +0800)] 
Enable V4BFmode and V2BFmode.

Enable V4BFmode and V2BFmode with the same ABI as V4HFmode and
V2HFmode. No real operation is supported for them except for movement.
This should solve PR target/107261.

Also I notice there's redundancy in VALID_AVX512FP16_REG_MODE, and
remove V2BFmode remove it.

gcc/ChangeLog:

PR target/107261
* config/i386/i386-modes.def (VECTOR_MODE): Support V2BFmode.
* config/i386/i386.cc (classify_argument): Handle V4BFmode and
V2BFmode.
(ix86_convert_const_vector_to_integer): Ditto.
* config/i386/i386.h (VALID_AVX512FP16_REG_MODE): Remove
V2BFmode.
(VALID_SSE2_REG_MODE): Add V4BFmode and V2BFmode.
(VALID_MMX_REG_MODE): Add V4BFmode.
* config/i386/i386.md (mode): Add V4BF and V2BF.
(MODE_SIZE): Ditto.
* config/i386/mmx.md (MMXMODE) Add V4BF.
(V_32): Add V2BF.
(V_16_32_64): Add V4BF and V2BF.
(mmxinsnmode): Add V4BF and V2BF.
(*mov<mode>_internal): Hanlde V4BFmode and V2BFmode.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr107261.c: New test.

18 months agoDaily bump.
GCC Administrator [Mon, 31 Oct 2022 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

18 months agoDaily bump.
GCC Administrator [Sun, 30 Oct 2022 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

18 months agoRepair --disable-sjlj-exceptions
Eric Botcazou [Sat, 29 Oct 2022 12:12:04 +0000 (14:12 +0200)] 
Repair --disable-sjlj-exceptions

It was broken by:

2022-08-31  Martin Liska  <mliska@suse.cz>

config.build: Remove deprecated ports.
config.gcc: Likewise.
config.host: Likewise.
configure.ac: Likewise.
configure: Regenerate.
config/pa/pa-hpux10.h: Removed.
config/pa/pa-hpux10.opt: Removed.
config/pa/t-dce-thr: Removed.

gcc/
* configure.ac (sjlj-exceptions): Restore dropped line.
* configure: Regenerate.

18 months agoRestore RTL alias analysis for hard frame pointer
Eric Botcazou [Sat, 29 Oct 2022 08:16:18 +0000 (10:16 +0200)] 
Restore RTL alias analysis for hard frame pointer

The change:

2021-07-28  Bin Cheng  <bin.cheng@linux.alibaba.com>

alias.c (init_alias_analysis): Don't skip prologue/epilogue.

broke the alias analysis for the hard frame pointer (when it is used as a
frame pointer, i.e. when the frame pointer is not eliminated) described in
the large comment at the top of the file, because static_reg_base_value is
set for it and, consequently, new_reg_base_value too.

When the instruction saving the stack pointer into the hard frame pointer in
the prologue is processed, it is viewed as a second set of the hard frame
pointer and to a different value by record_set, which then proceeds to reset
new_reg_base_value to 0 and the game is over.

gcc/
* alias.cc (init_alias_analysis): Do not record sets to the hard
frame pointer if the frame pointer has not been eliminated.

18 months agod: Merge upstream dmd, druntime e4f8919591, phobos 3ad507b51.
Iain Buclaw [Sat, 29 Oct 2022 07:05:54 +0000 (09:05 +0200)] 
d: Merge upstream dmd, druntime e4f8919591, phobos 3ad507b51.

D front-end changes:

    - Import dmd v2.101.0-beta.1.
    - Add predefined version `D_Optimized' when compiling with `-O'.
    - Shortened method syntax (DIP1043) is now enabled by default.
    - Array literals assigned to `scope' array variables are now
      allocated on the stack.
    - Implement `@system' variables (DIP1035), available behind the
      preview feature flag `-fpreview=systemvariables'.

D runtime changes:

    - Import druntime v2.101.0-beta.1.

Phobos changes:

    - Import phobos v2.101.0-beta.1.
    - Added `std.typecons.SafeRefCounted', that can be used in `@safe'
      code with `-fpreview=dip1000'.

gcc/d/ChangeLog:

* d-attribs.cc (apply_user_attributes): Update for new front-end
interface.
* d-builtins.cc (d_init_versions): Predefine `D_Optimized' with
compiling with optimizations enabled.
* d-lang.cc (d_handle_option): Update for new front-end interface.
Handle new option `-fpreview=systemvariables'.
* dmd/MERGE: Merge upstream dmd e4f8919591.
* dmd/VERSION: Bump version to v2.101.0-beta.1.
* expr.cc (ExprVisitor::visit (AssignExp *)): Treat construction of
static arrays from a call expression as a simple assignment.
(ExprVisitor::visit (ArrayLiteralExp *)): Handle array literals with
`scope' storage.
* gdc.texi: Update documentation of `-fpreview=' options.
* lang.opt (fpreview=shortenedmethods): Remove.
(fpreview=systemvariables):  New option.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e4f8919591.
* src/MERGE: Merge upstream phobos 3ad507b51.

gcc/testsuite/ChangeLog:

* gdc.dg/simd19630.d: Move tests with errors to ...
* gdc.dg/simd19630b.d: ... here.  New test.
* gdc.dg/simd19630c.d: New test.
* gdc.dg/simd_ctfe.d: Removed.
* gdc.dg/simd18867.d: New test.
* gdc.dg/simd19788.d: New test.
* gdc.dg/simd21469.d: New test.
* gdc.dg/simd21672.d: New test.
* gdc.dg/simd23077.d: New test.
* gdc.dg/simd23084.d: New test.
* gdc.dg/simd23085.d: New test.
* gdc.dg/torture/simd19632.d: New test.
* gdc.dg/torture/simd20041.d: New test.
* gdc.dg/torture/simd21673.d: New test.
* gdc.dg/torture/simd21676.d: New test.
* gdc.dg/torture/simd22438.d: New test.
* gdc.dg/torture/simd23009.d: New test.
* gdc.dg/torture/simd23077.d: New test.
* gdc.dg/torture/simd8.d: New test.
* gdc.dg/torture/simd9.d: New test.
* gdc.dg/torture/simd_prefetch.d: New test.

18 months agoBetter separate 'LTO' vs. 'LTODump' in 'gcc/lto/lang.opt'
Thomas Schwinge [Fri, 1 Apr 2022 17:52:54 +0000 (19:52 +0200)] 
Better separate 'LTO' vs. 'LTODump' in 'gcc/lto/lang.opt'

Minor clean-up after Subversion r270897 (Git
commit 66d62d9f2e6b059be6a018397fba555147133a9a) "Add lto-dump tool".

No change in generated files.

gcc/lto/
* lang.opt: Better separate 'LTO' vs. 'LTODump'.

18 months agod: Make TARGET_D_MINFO_SECTION hooks in elfos.h the language default.
Iain Buclaw [Sun, 23 Oct 2022 12:09:17 +0000 (14:09 +0200)] 
d: Make TARGET_D_MINFO_SECTION hooks in elfos.h the language default.

Removes the last of all TARGET_D_* macro definitions in common target
headers.  Now everything is either defined in the D language front-end,
or D-specific target headers.

gcc/ChangeLog:

* config/darwin-d.cc (TARGET_D_MINFO_START_NAME): Rename to ...
(TARGET_D_MINFO_SECTION_START): ...this.
(TARGET_D_MINFO_END_NAME): Rename to ...
(TARGET_D_MINFO_SECTION_END): ... this.
* config/elfos.h (TARGET_D_MINFO_SECTION): Remove.
(TARGET_D_MINFO_START_NAME): Remove.
(TARGET_D_MINFO_END_NAME): Remove.
* config/i386/cygwin-d.cc (TARGET_D_MINFO_SECTION): Remove.
(TARGET_D_MINFO_START_NAME): Remove.
(TARGET_D_MINFO_END_NAME): Remove.
* config/i386/winnt-d.cc (TARGET_D_MINFO_SECTION): Remove.
(TARGET_D_MINFO_START_NAME): Remove.
(TARGET_D_MINFO_END_NAME): Remove.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (TARGET_D_MINFO_START_NAME): Rename to ...
(TARGET_D_MINFO_SECTION_START): ...this.
(TARGET_D_MINFO_END_NAME): Rename to ...
(TARGET_D_MINFO_SECTION_END): ...this.

gcc/d/ChangeLog:

* d-target.def (d_minfo_section): Expand documentation of hook.
Default initialize to "minfo".
(d_minfo_start_name): Rename to ...
(d_minfo_section_start): ... this.  Default initialize to
"__start_minfo".
(d_minfo_end_name): Rename to ...
(d_minfo_section_end): ... this. Default initialize to "__stop_minfo".
* modules.cc (register_moduleinfo): Use new targetdm hook names.

18 months agod: Remove D-specific version definitions from target headers
Iain Buclaw [Mon, 17 Oct 2022 17:32:52 +0000 (19:32 +0200)] 
d: Remove D-specific version definitions from target headers

This splits up the targetdm sources so that each file only handles one
target platform.

Having all logic kept in the headers means that they could become out of
sync when a new target is added (loongarch*-*-linux*) or accidentally
broken if some headers in tm_file are changed about.

gcc/ChangeLog:

* config.gcc: Split out glibc-d.o into linux-d.o, kfreebsd-d.o,
kopensolaris-d.o, and gnu-d.o.  Split out cygwin-d.o from winnt-d.o.
* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/i386/cygwin.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/mingw32.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/t-cygming: Add cygwin-d.o.
* config/i386/winnt-d.cc (winnt_d_os_builtins): Only add
MinGW-specific version condition.
* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Remove.
* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/t-glibc: Remove glibc-d.o, add gnu-d.o, kfreebsd-d.o,
kopensolaris-d.o.
* config/t-linux: Add linux-d.o.
* config/glibc-d.cc: Remove file.
* config/gnu-d.cc: New file.
* config/i386/cygwin-d.cc: New file.
* config/kfreebsd-d.cc: New file.
* config/kopensolaris-d.cc: New file.
* config/linux-d.cc: New file.

18 months agoFix signed vs unsigned issue in H8 port
Jeff Law [Sat, 29 Oct 2022 03:33:06 +0000 (23:33 -0400)] 
Fix signed vs unsigned issue in H8 port

gcc/
* config/h8300/h8300.cc (pre_incdec_with_reg): Make reg argument
an unsigned int
* config/h8300/h8300-protos.h (pre_incdec_with_reg): Adjust prototype.

18 months agoDaily bump.
GCC Administrator [Sat, 29 Oct 2022 00:17:49 +0000 (00:17 +0000)] 
Daily bump.

18 months agolibstdc++: Fix dangling reference in filesystem::path::filename()
Jonathan Wakely [Fri, 28 Oct 2022 14:28:09 +0000 (15:28 +0100)] 
libstdc++: Fix dangling reference in filesystem::path::filename()

The new -Wdangling-reference warning noticed this.

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path::filename()): Fix dangling
reference.

18 months agolibstdc++: Make placeholders inline when inline variables are available
Arsen Arsenović [Thu, 20 Oct 2022 14:58:53 +0000 (16:58 +0200)] 
libstdc++: Make placeholders inline when inline variables are available

This slightly lowers the dependency of generated code on libstdc++.so.

libstdc++-v3/ChangeLog:

* include/std/functional: Make placeholders inline, if possible.

18 months agolibstdc++: Don't use gstdint.h anymore
Arsen Arsenović [Thu, 20 Oct 2022 14:20:19 +0000 (16:20 +0200)] 
libstdc++: Don't use gstdint.h anymore

libstdc++-v3/ChangeLog:

* configure.ac: Stop generating gstdint.h.
* src/c++11/compatibility-atomic-c++0x.cc: Stop using gstdint.h.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

18 months agoc++: move duplicate_contracts to contracts.cc
Jason Merrill [Fri, 28 Oct 2022 15:37:23 +0000 (11:37 -0400)] 
c++: move duplicate_contracts to contracts.cc

gcc/cp/ChangeLog:

* cp-tree.h (duplicate_contracts): Add prototype.
* contracts.cc (duplicate_contracts): Move from...
* decl.cc (duplicate_contracts): ...here.
* parser.cc (cp_parser_contract_attribute_spec): Fix typo.

18 months agoc++: remove friend_attributes
Jason Merrill [Fri, 28 Oct 2022 15:26:05 +0000 (11:26 -0400)] 
c++: remove friend_attributes

Instead of the friend_attributes hack, we can apply friend attributes before
calling do_friend.

gcc/cp/ChangeLog:

* decl.cc (friend_attributes): Remove.
(duplicate_contracts): Adjust.
(duplicate_decls): Adjust.
(grokdeclarator): Call cplus_decl_attributes before do_friend.

18 months agoc++: build contract_violation object directly
Jason Merrill [Thu, 27 Oct 2022 14:31:28 +0000 (10:31 -0400)] 
c++: build contract_violation object directly

The __on_contract_violation function was an awkward library dependency;
instead, let's build up a temporary contract_violation and call
handle_contract_violation directly.

gcc/cp/ChangeLog:

* cp-tree.h (enum cp_tree_index): Remove
CPTI_ON_CONTRACT_VIOLATION*, add CPTI_PSEUDO_CONTRACT_VIOLATION.
(pseudo_contract_violation_type): New.
(on_contract_violation_fn)
(on_contract_violation_never_fn): Remove.
* contracts.cc (get_pseudo_contract_violation_type): New.
(build_contract_violation): New.
(declare_handle_contract_violation): New.
  (build_contract_handler_call): Use them.
(build_contract_check): Call terminate here.
(init_contract_processing): Remove.
* decl.cc (cxx_init_decl_processing): Don't call it.

libstdc++-v3/ChangeLog:

* src/experimental/contract.cc (__on_contract_violation): Remove.
* include/experimental/contract: Remove its comment.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts14.C
* g++.dg/contracts/contracts15.C: Remove __on_contract_violation.

18 months agoc++: pass dg-options to module link
Jason Merrill [Thu, 27 Oct 2022 01:37:09 +0000 (21:37 -0400)] 
c++: pass dg-options to module link

The link command needs to see -fcontracts for it to automatically add
-lstdc++exp.

gcc/testsuite/ChangeLog:

* g++.dg/modules/modules.exp: Pass dg-options to link command.

18 months agoc++: move contract_violation to std::experimental
Jason Merrill [Tue, 25 Oct 2022 20:52:34 +0000 (16:52 -0400)] 
c++: move contract_violation to std::experimental

libstdc++-v3/ChangeLog:

* include/experimental/contract: Move into std::experimental
* src/experimental/contract.cc: Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts14.C
* g++.dg/contracts/contracts15.C
* g++.dg/contracts/contracts16.C
* g++.dg/contracts/contracts17.C: contract_violation is now in
std::experimental.

18 months agoc++: comment tweaks
Jason Merrill [Tue, 25 Oct 2022 19:55:20 +0000 (15:55 -0400)] 
c++: comment tweaks

18 months agoc++: -Wdangling-reference and system headers
Marek Polacek [Thu, 27 Oct 2022 01:15:53 +0000 (21:15 -0400)] 
c++: -Wdangling-reference and system headers

I got this testcase:

  auto f() -> std::optional<std::string>;
  for (char c : f().value()) { }

which has a dangling reference: std::optional<T>::value returns
a reference to the contained value, but here it's the f() temporary.
We warn, which is great, but only with -Wsystem-headers, because
the function comes from a system header and warning_enabled_at used
in do_warn_dangling_reference checks diagnostic_report_warnings_p,
which in this case returned false so we didn't warn.

Fixed as below.  I could also override dc_warn_system_headers so that
the warning is enabled in system headers always.  With that, I found one
issue in libstdc++:

libstdc++-v3/include/bits/fs_path.h:1265:15: warning: possibly dangling reference to a temporary [-Wdangling-reference]
 1265 |         auto& __last = *--end();
      |               ^~~~~~

which looks like a true positive as well.

gcc/cp/ChangeLog:

* call.cc (maybe_warn_dangling_reference): Enable the warning in
system headers if the decl isn't in a system header.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference4.C: New test.

18 months agoc++: apply friend attributes sooner
Jason Merrill [Fri, 28 Oct 2022 14:45:06 +0000 (10:45 -0400)] 
c++: apply friend attributes sooner

Comparing attributes between declarations of a friend function has been
complicated by pushdecl happening before decl_attributes.  I assumed there
was some complicated reason we weren't calling decl_attributes here, but it
doesn't break anything.

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Call decl_attributes before do_friend.

18 months agoc: tree: target: C2x (...) function prototypes and va_start relaxation
Joseph Myers [Fri, 28 Oct 2022 14:40:25 +0000 (14:40 +0000)] 
c: tree: target: C2x (...) function prototypes and va_start relaxation

C2x allows function prototypes to be given as (...), a prototype
meaning a variable-argument function with no named arguments.  To
allow such functions to access their arguments, requirements for
va_start calls are relaxed so it ignores all but its first argument
(i.e. subsequent arguments, if any, can be arbitrary pp-token
sequences).

Implement this feature accordingly.  The va_start relaxation in
<stdarg.h> is itself easy: __builtin_va_start already supports a
second argument of 0 instead of a parameter name, and calls get
converted internally to the form using 0 for that argument, so
<stdarg.h> just needs changing to use a variadic macro that passes 0
as the second argument of __builtin_va_start.  (This is done only in
C2x mode, on the expectation that users of older standard would expect
unsupported uses of va_start to be diagnosed.)

For the (...) functions, it's necessary to distinguish these from
unprototyped functions, whereas previously C++ (...) functions and
unprototyped functions both used NULL TYPE_ARG_TYPES.  A flag is added
to tree_type_common to mark the (...) functions; as discussed on gcc@,
doing things this way is likely to be safer for unchanged code in GCC
than adding a different form of representation in TYPE_ARG_TYPES, or
adding a flag that instead signals that the function is unprototyped.

There was previously an option
-fallow-parameterless-variadic-functions to enable support for (...)
prototypes.  The support was incomplete - it treated the functions as
unprototyped, and only parsed some declarations, not e.g.
"int g (int (...));".  This option is changed into a no-op ignored
option; (...) is always accepted syntactically, with a pedwarn_c11
call to given required diagnostics when appropriate.  The peculiarity
of a parameter list with __attribute__ followed by '...' being
accepted with that option is removed.

Interfaces in tree.cc that create function types are adjusted to set
this flag as appropriate.  It is of course possible that some existing
users of the functions to create variable-argument functions actually
wanted unprototyped functions in the no-named-argument case, rather
than functions with a (...) prototype; some such cases in c-common.cc
(for built-in functions and implicit function declarations) turn out
to need updating for that reason.

I didn't do anything to change how the C++ front end creates (...)
function types.  It's very likely there are unchanged places in the
compiler that in fact turn out to need changes to work properly with
(...) function prototypes.

Target setup_incoming_varargs hooks, where they used the information
passed about the last named argument, needed updating to avoid using
that information in the (...) case.  Note that apart from the x86
changes, I haven't done any testing of those target changes beyond
building cc1 to check for syntax errors.  It's possible further
target-specific fixes will be needed; target maintainers should watch
out for failures of c2x-stdarg-4.c or c2x-stdarg-split-1a.c, the
execution tests, which would indicate that this feature is not working
correctly.  Those tests also verify the case where there are named
arguments but the last named argument has a declaration that results
in undefined behavior in previous C standard versions, such as a type
changed by the default argument promotions.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
* config/aarch64/aarch64.cc (aarch64_setup_incoming_varargs):
Check TYPE_NO_NAMED_ARGS_STDARG_P.
* config/alpha/alpha.cc (alpha_setup_incoming_varargs): Likewise.
* config/arc/arc.cc (arc_setup_incoming_varargs): Likewise.
* config/arm/arm.cc (arm_setup_incoming_varargs): Likewise.
* config/csky/csky.cc (csky_setup_incoming_varargs): Likewise.
* config/epiphany/epiphany.cc (epiphany_setup_incoming_varargs):
Likewise.
* config/fr30/fr30.cc (fr30_setup_incoming_varargs): Likewise.
* config/frv/frv.cc (frv_setup_incoming_varargs): Likewise.
* config/ft32/ft32.cc (ft32_setup_incoming_varargs): Likewise.
* config/i386/i386.cc (ix86_setup_incoming_varargs): Likewise.
* config/ia64/ia64.cc (ia64_setup_incoming_varargs): Likewise.
* config/loongarch/loongarch.cc
(loongarch_setup_incoming_varargs): Likewise.
* config/m32r/m32r.cc (m32r_setup_incoming_varargs): Likewise.
* config/mcore/mcore.cc (mcore_setup_incoming_varargs): Likewise.
* config/mips/mips.cc (mips_setup_incoming_varargs): Likewise.
* config/mmix/mmix.cc (mmix_setup_incoming_varargs): Likewise.
* config/nds32/nds32.cc (nds32_setup_incoming_varargs): Likewise.
* config/nios2/nios2.cc (nios2_setup_incoming_varargs): Likewise.
* config/riscv/riscv.cc (riscv_setup_incoming_varargs): Likewise.
* config/rs6000/rs6000-call.cc (setup_incoming_varargs): Likewise.
* config/sh/sh.cc (sh_setup_incoming_varargs): Likewise.
* config/visium/visium.cc (visium_setup_incoming_varargs):
Likewise.
* config/vms/vms-c.cc (vms_c_common_override_options): Do not set
flag_allow_parameterless_variadic_functions.
* doc/invoke.texi (-fallow-parameterless-variadic-functions): Do
not document option.
* function.cc (assign_parms): Call assign_parms_setup_varargs for
TYPE_NO_NAMED_ARGS_STDARG_P case.
* ginclude/stdarg.h [__STDC_VERSION__ > 201710L] (va_start): Make
variadic macro.  Pass second argument of 0 to __builtin_va_start.
* target.def (setup_incoming_varargs): Update documentation.
* doc/tm.texi: Regenerate.
* tree-core.h (struct tree_type_common): Add
no_named_args_stdarg_p.
* tree-streamer-in.cc (unpack_ts_type_common_value_fields): Unpack
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree-streamer-out.cc (pack_ts_type_common_value_fields): Pack
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree.cc (type_cache_hasher::equal): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
(build_function_type): Add argument no_named_args_stdarg_p.
(build_function_type_list_1, build_function_type_array_1)
(reconstruct_complex_type): Update calls to build_function_type.
(stdarg_p, prototype_p): Return true for (...) functions.
(gimple_canonical_types_compatible_p): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.
* tree.h (TYPE_NO_NAMED_ARGS_STDARG_P): New.
(build_function_type): Update prototype.

gcc/c-family/
* c-common.cc (def_fn_type): Call build_function_type for
zero-argument variable-argument function.
(c_common_nodes_and_builtins): Build default_function_type with
build_function_type.
* c.opt (fallow-parameterless-variadic-functions): Mark as ignored
option.

gcc/c/
* c-decl.cc (grokdeclarator): Pass
arg_info->no_named_args_stdarg_p to build_function_type.
(grokparms): Check arg_info->no_named_args_stdarg_p before
converting () to (void).
(build_arg_info): Initialize no_named_args_stdarg_p.
(get_parm_info): Set no_named_args_stdarg_p.
(start_function): Pass TYPE_NO_NAMED_ARGS_STDARG_P to
build_function_type.
(store_parm_decls): Count (...) functions as prototyped.
* c-parser.cc (c_parser_direct_declarator): Allow '...' after open
parenthesis to start parameter list.
(c_parser_parms_list_declarator): Always allow '...' with no
arguments, call pedwarn_c11 and set no_named_args_stdarg_p.
* c-tree.h (struct c_arg_info): Add field no_named_args_stdarg_p.
* c-typeck.cc (composite_type): Handle
TYPE_NO_NAMED_ARGS_STDARG_P.
(function_types_compatible_p): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.

gcc/fortran/
* trans-types.cc (gfc_get_function_type): Do not use
build_varargs_function_type_vec for unprototyped function.

gcc/lto/
* lto-common.cc (compare_tree_sccs_1): Compare
TYPE_NO_NAMED_ARGS_STDARG_P.

gcc/objc/
* objc-next-runtime-abi-01.cc (build_next_objc_exception_stuff):
Use build_function_type to build type of objc_setjmp_decl.

gcc/testsuite/
* gcc.dg/c11-stdarg-1.c, gcc.dg/c11-stdarg-2.c,
gcc.dg/c11-stdarg-3.c, gcc.dg/c2x-stdarg-1.c,
gcc.dg/c2x-stdarg-2.c, gcc.dg/c2x-stdarg-3.c,
gcc.dg/c2x-stdarg-4.c, gcc.dg/gnu2x-stdarg-1.c,
gcc.dg/torture/c2x-stdarg-split-1a.c,
gcc.dg/torture/c2x-stdarg-split-1b.c: New tests.
* gcc.dg/Wold-style-definition-2.c, gcc.dg/format/sentinel-1.c:
Update expected diagnostics.
* gcc.dg/c2x-nullptr-1.c (test5): Cast unused parameter to (void).
* gcc.dg/diagnostic-token-ranges.c: Use -pedantic.  Expect warning
in place of error.

18 months agolibstdc++: Fix allocator propagation in regex algorithms [PR107376]
Jonathan Wakely [Tue, 25 Oct 2022 12:03:12 +0000 (13:03 +0100)] 
libstdc++: Fix allocator propagation in regex algorithms [PR107376]

The PR points out that we assume the match_results allocator is default
constuctible, which might not be true. We also have a related issue with
unwanted propagation from an object that might have an unequal
allocator.

Ideally we use the same allocator type for _State_info::_M_match_queue
but that would be an ABI change now. We should investigate if that can
be done without breaking anything, which might be possible because the
_Executor object is short-lived and never leaks out of the regex_match,
regex_search, and regex_replace algorithms. If we change the mangled
name for _Executor then there would be no ODR violations when mixing old
and new definitions. This commit does not attempt that.

libstdc++-v3/ChangeLog:

PR libstdc++/107376
* include/bits/regex_executor.h (_Executor::_Executor): Use same
allocator for _M_cur_results and _M_results.
* include/bits/regex_executor.tcc (_Executor::_M_main_dispatch):
Prevent possibly incorrect allocator propagating to
_M_cur_results.
* testsuite/28_regex/algorithms/regex_match/107376.cc: New test.

18 months agovect: Reject non-byte offsets for gather/scatters [PR107346]
Andre Vieira [Fri, 28 Oct 2022 14:05:11 +0000 (15:05 +0100)] 
vect: Reject non-byte offsets for gather/scatters [PR107346]

The ada failure reported in the PR was being caused by vect_check_gather_scatter
failing to deal with bit offsets that weren't multiples of BITS_PER_UNIT. This
patch makes vect_check_gather_scatter reject memory accesses with such offsets.

gcc/ChangeLog:

PR tree-optimization/107346
* tree-vect-data-refs.cc (vect_check_gather_scatter): Reject offsets
that aren't multiples of BITS_PER_UNIT.

18 months agotree-optimization/107407 - wrong code with DSE
Richard Biener [Fri, 28 Oct 2022 13:03:49 +0000 (15:03 +0200)] 
tree-optimization/107407 - wrong code with DSE

So what happens is that we elide processing of this check with

          /* In addition to kills we can remove defs whose only use
             is another def in defs.  That can only ever be PHIs of which
             we track two for simplicity reasons, the first and last in
             {first,last}_phi_def (we fail for multiple PHIs anyways).
             We can also ignore defs that feed only into
             already visited PHIs.  */
          else if (single_imm_use (vdef, &use_p, &use_stmt)
                   && (use_stmt == first_phi_def
                       || use_stmt == last_phi_def
                       || (gimple_code (use_stmt) == GIMPLE_PHI
                           && bitmap_bit_p (visited,
                                            SSA_NAME_VERSION
                                              (PHI_RESULT (use_stmt))))))

where we have the last PHI being the outer loop virtual PHI and the first
PHI being the loop exit PHI of the outer loop and we've already processed
the single immediate use of the outer loop PHI, the inner loop PHI.  But
we still have to perform the above check!

It's easiest to perform the check when we visit the PHI node instead of
delaying it to the actual processing loop.

PR tree-optimization/107407
* tree-ssa-dse.cc (dse_classify_store): Perform backedge
varying index check when collecting PHI uses rather than
after optimizing processing of the candidate defs.

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

18 months agotree-optimization/107447 - avoid hoisting returns-twice calls in LIM
Richard Biener [Fri, 28 Oct 2022 12:20:36 +0000 (14:20 +0200)] 
tree-optimization/107447 - avoid hoisting returns-twice calls in LIM

The following makes sure to not hoist returns-twice calls in LIM
since we have no way to move the abnormal edge associated with it
and we are prone having stray abnormal edges in the IL which will
then cause IL verification failures even when the actual call
does not return twice.

PR tree-optimization/107447
* tree-ssa-loop-im.cc (determine_max_movement): Do not
hoist returns-twice calls.

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

18 months agotree-optimization/107435 - ICE with recurrence vectorization
Richard Biener [Fri, 28 Oct 2022 11:50:57 +0000 (13:50 +0200)] 
tree-optimization/107435 - ICE with recurrence vectorization

This implements the missed conversion from pointer to integer.

PR tree-optimization/107435
* tree-vect-loop.cc (vectorizable_recurr): Convert initial
value to vector component type.

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

18 months agoopenmp: Allow optional comma after directive-specifier in C/C++
Jakub Jelinek [Fri, 28 Oct 2022 09:03:56 +0000 (11:03 +0200)] 
openmp: Allow optional comma after directive-specifier in C/C++

Previously we've been allowing that comma only in C++ when in attribute
form (which was the reason why it has been allowed), but 5.1 allows that
even in pragma form in C/C++ (with clarifications in 5.2) and 5.2
also in Fortran (which this patch doesn't implement).

Note, for directives which take an argument (== unnamed clause),
comma is not allowed in between the directive name and the argument,
like the directive-1.c testcase shows.

2022-10-28  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
* c-parser.cc (c_parser_omp_all_clauses): Allow optional
comma before the first clause.
(c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj,
c_parser_omp_flush, c_parser_omp_scan_loop_body,
c_parser_omp_ordered, c_finish_omp_declare_variant,
c_parser_omp_declare_target, c_parser_omp_declare_reduction,
c_parser_omp_requires, c_parser_omp_error,
c_parser_omp_assumption_clauses): Likewise.
gcc/cp/
* parser.cc (cp_parser_omp_all_clauses): Allow optional comma
before the first clause even in pragma syntax.
(cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj,
cp_parser_omp_flush, cp_parser_omp_scan_loop_body,
cp_parser_omp_ordered, cp_parser_omp_assumption_clauses,
cp_finish_omp_declare_variant, cp_parser_omp_declare_target,
cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires,
cp_parser_omp_error): Likewise.
gcc/testsuite/
* c-c++-common/gomp/directive-1.c: New test.
* c-c++-common/gomp/clauses-6.c: New test.
* c-c++-common/gomp/declare-variant-2.c (f75a): Declare.
(f75): Use f75a as variant instead of f1 and don't expect error.
* g++.dg/gomp/clause-4.C (foo): Don't expect error on comma
before first clause.
* gcc.dg/gomp/clause-2.c (foo): Likewise.

18 months agoAdjust gcc.dg/vect/pr100756.c for V8SI and V16SI
Richard Biener [Fri, 28 Oct 2022 08:31:02 +0000 (10:31 +0200)] 
Adjust gcc.dg/vect/pr100756.c for V8SI and V16SI

The following adjusts the testcase to require no epilogue also
for larger vectors than V4SI.

* gcc.dg/vect/pr100756.c: Adjust for larger vectors.

18 months agoOpenACC: Don't gang-privatize artificial variables [PR90115]
Julian Brown [Wed, 12 Oct 2022 20:44:57 +0000 (20:44 +0000)] 
OpenACC: Don't gang-privatize artificial variables [PR90115]

This patch prevents compiler-generated artificial variables from being
treated as privatization candidates for OpenACC.

The rationale is that e.g. "gang-private" variables actually must be
shared by each worker and vector spawned within a particular gang, but
that sharing is not necessary for any compiler-generated variable (at
least at present, but no such need is anticipated either).  Variables on
the stack (and machine registers) are already private per-"thread"
(gang, worker and/or vector), and that's fine for artificial variables.

We're restricting this to blocks, as we still need to understand what it
means for a 'DECL_ARTIFICIAL' to appear in a 'private' clause.

Several tests need their scan output patterns adjusted to compensate.

2022-10-14  Julian Brown  <julian@codesourcery.com>

PR middle-end/90115
gcc/
* omp-low.cc (oacc_privatization_candidate_p): Artificial vars are not
privatization candidates.

libgomp/
* testsuite/libgomp.oacc-fortran/declare-1.f90: Adjust scan output.
* testsuite/libgomp.oacc-fortran/host_data-5.F90: Likewise.
* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/print-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
18 months agoFix target selector syntax in 'gcc.dg/vect/bb-slp-cond-1.c'
Thomas Schwinge [Tue, 25 Oct 2022 11:10:52 +0000 (13:10 +0200)] 
Fix target selector syntax in 'gcc.dg/vect/bb-slp-cond-1.c'

... to restore testing lost in recent
commit r13-3225-gbd9a05594d227cde79a67dc715bd9d82e9c464e9
"amdgcn: vector testsuite tweaks" (for example, x86_64-pc-linux-gnu):

    PASS: gcc.dg/vect/bb-slp-cond-1.c (test for excess errors)
    PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects  scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
    [-PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects  scan-tree-dump-times vect "loop vectorized" 1-]
    PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects (test for excess errors)
    PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects execution test
    PASS: gcc.dg/vect/bb-slp-cond-1.c execution test
    PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
    [-PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump-times vect "loop vectorized" 1-]

gcc/testsuite/
* gcc.dg/vect/bb-slp-cond-1.c: Fix target selector syntax.

18 months agodocs: document sanitizers can trigger warnings
Martin Liska [Wed, 26 Oct 2022 11:07:57 +0000 (13:07 +0200)] 
docs: document sanitizers can trigger warnings

PR sanitizer/107298

gcc/ChangeLog:

* doc/invoke.texi: Document sanitizers can trigger warnings.

18 months agolto-dump: modernize a bit
Martin Liska [Thu, 27 Oct 2022 08:40:58 +0000 (10:40 +0200)] 
lto-dump: modernize a bit

gcc/lto/ChangeLog:

* lto-dump.cc (dump_list): Remove trailing return.
(dump_symbol): Likewise.
(dump_body): Filter name based on mangled name.
(dump_tool_help): Use GIMPLE wording.
(lto_main): Update wording.

18 months agoDocument 'distclean-stage[N]'
Thomas Schwinge [Wed, 26 Oct 2022 11:07:27 +0000 (13:07 +0200)] 
Document 'distclean-stage[N]'

Refer to 'Makefile.tpl':

    # Rules to wipe a stage and all the following ones, also used for cleanstrap
    [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
    .PHONY: distclean-stage[+id+]
    distclean-stage[+id+]::
     @: $(MAKE); $(stage)
     @test "`cat stage_last`" != stage[+id+] || rm -f stage_last
     rm -rf stage[+id+]-* [+
       IF compare-target +][+compare-target+] [+ ENDIF compare-target +]

gcc/
* doc/makefile.texi (Makefile Targets): Document
'distclean-stage[N]'.

18 months agoChange remaining flag_finite_math_only use in value-range.cc.
Aldy Hernandez [Fri, 28 Oct 2022 06:13:38 +0000 (08:13 +0200)] 
Change remaining flag_finite_math_only use in value-range.cc.

gcc/ChangeLog:

* value-range.cc (range_tests_floats): Use HONOR_INFINITIES.

18 months agotestsuite: Adjust vect-bitfield-read-* with vect_shift and vect_long_long [PR107240]
Kewen Lin [Fri, 28 Oct 2022 03:30:16 +0000 (22:30 -0500)] 
testsuite: Adjust vect-bitfield-read-* with vect_shift and vect_long_long [PR107240]

The test cases vect-bitfield-read-* requires vector shift
target support, they need one explicit vect_shift effective
target requirement checking.  Besides, the vectype for struct
in test cases vect-bitfield-read-{2,4} is vector of long long,
we need to check effective target vect_long_long for them.
This patch can help to fix all remaining vect-bitfield-{read,
write}-* test failures on powerpc.

PR testsuite/107240

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-bitfield-read-1.c: Add effective target checking
vect_shift.
* gcc.dg/vect/vect-bitfield-read-3.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-5.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-6.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-7.c: Likewise.
* gcc.dg/vect/vect-bitfield-read-2.c: Add effective target checking
vect_shift and replace vect_int with vect_long_long.
* gcc.dg/vect/vect-bitfield-read-4.c: Likewise.

18 months agoc: C2x enums with fixed underlying type [PR61469]
Joseph Myers [Fri, 28 Oct 2022 00:37:28 +0000 (00:37 +0000)] 
c: C2x enums with fixed underlying type [PR61469]

C2x adds support for enums with a fixed underlying type specified
("enum e : long long;" and similar).  Implement this in the C front
end.  The same representation is used for these types as in C++, with
two macros moved from cp-tree.h to c-common.h.

Such enums can have bool as the underlying type, and various C
front-end code checking for boolean types is adjusted to use a new
C_BOOLEAN_TYPE_P to handle such enums the same way as bool.  (Note
that for C++ we have bug 96496 that enums with underlying type bool
don't work correctly there.)

There are various issues with the wording for such enums in the
current C2x working draft (including but not limited to wording in the
accepted paper that failed to make it into the working draft), which I
intend to raise in NB comments.  I think what I've implemented and
added tests for matches the intent.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/61469

gcc/c-family/
* c-common.h (ENUM_UNDERLYING_TYPE, ENUM_FIXED_UNDERLYING_TYPE_P):
New.  Moved from cp/cp-tree.h.
* c-warn.cc (warnings_for_convert_and_check): Do not consider
conversions to enum with underlying type bool to overflow.

gcc/c/
* c-convert.cc (c_convert): Handle enums with underlying boolean
type like bool.
* c-decl.cc (shadow_tag_warned): Allow shadowing declarations for
enums with enum type specifier, but give errors for storage class
specifiers, qualifiers or alignment specifiers in non-definition
declarations of such enums.
(grokdeclarator): Give error for non-definition use of type
specifier with an enum type specifier.
(parser_xref_tag): Add argument has_enum_type_specifier.  Pass it
to lookup_tag and use it to set ENUM_FIXED_UNDERLYING_TYPE_P.
(xref_tag): Update call to parser_xref_tag.
(start_enum): Add argument fixed_underlying_type.  Complete enum
type with a fixed underlying type given in the definition.  Give
error for defining without a fixed underlying type in the
definition if one was given in a prior declaration.  Do not mark
enums with fixed underlying type as packed for -fshort-enums.
Store the enum type in the_enum.
(finish_enum): Do not adjust types of values or check their range
for an enum with a fixed underlying type.  Set underlying type of
enum and variants.
(build_enumerator): Check enumeration constants for enum with
fixed underlying type against that type and convert to that type.
Increment in the underlying integer type, with handling for bool.
(c_simulate_enum_decl): Update call to start_enum.
(declspecs_add_type): Set specs->enum_type_specifier_ref_p.
* c-objc-common.cc (c_get_alias_set): Use ENUM_UNDERLYING_TYPE
rather than recomputing an underlying type based on size.
* c-parser.cc (c_parser_declspecs)
(c_parser_struct_or_union_specifier, c_parser_typeof_specifier):
Set has_enum_type_specifier for type specifiers.
(c_parser_enum_specifier): Handle enum type specifiers.
(c_parser_struct_or_union_specifier): Update call to
parser_xref_tag.
(c_parser_omp_atomic): Check for boolean increment or decrement
using C_BOOLEAN_TYPE_P.
* c-tree.h (C_BOOLEAN_TYPE_P): New.
(struct c_typespec): Add has_enum_type_specifier.
(struct c_declspecs): Add enum_type_specifier_ref_p.
(struct c_enum_contents): Add enum_type.
(start_enum, parser_xref_tag): Update prototypes.
* c-typeck.cc (composite_type): Allow for enumerated types
compatible with bool.
(common_type, comptypes_internal, perform_integral_promotions):
Use ENUM_UNDERLYING_TYPE.
(parser_build_binary_op, build_unary_op, convert_for_assignment)
(c_finish_return, c_start_switch, build_binary_op): Check for
boolean types using C_BOOLEAN_TYPE_P.

gcc/cp/
* cp-tree.h (ENUM_FIXED_UNDERLYING_TYPE_P, ENUM_UNDERLYING_TYPE):
Remove.  Moved to c-common.h.

gcc/testsuite/
* gcc.dg/c11-enum-4.c, gcc.dg/c11-enum-5.c, gcc.dg/c11-enum-6.c,
gcc.dg/c2x-enum-6.c, gcc.dg/c2x-enum-7.c, gcc.dg/c2x-enum-8.c,
gcc.dg/gnu2x-enum-1.c: New tests.

18 months agoDaily bump.
GCC Administrator [Fri, 28 Oct 2022 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

18 months agoruntime: use _libgo_off_t_type when calling C mmap
Ian Lance Taylor [Thu, 27 Oct 2022 00:23:42 +0000 (17:23 -0700)] 
runtime: use _libgo_off_t_type when calling C mmap

The last argument to the C mmap function is type off_t, not uintptr.
On some 32-bit systems, off_t is larger than uintptr.

Based on patch by Sören Tempel.

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

18 months agoAarch64: Do not define DONT_USE_BUILTIN_SETJMP
Eric Botcazou [Thu, 27 Oct 2022 22:22:43 +0000 (00:22 +0200)] 
Aarch64: Do not define DONT_USE_BUILTIN_SETJMP

The setting looks obsolete at this point.

gcc/
* config/aarch64/aarch64.h (DONT_USE_BUILTIN_SETJMP): Delete.

18 months agox86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns
H.J. Lu [Thu, 20 Oct 2022 18:55:19 +0000 (11:55 -0700)] 
x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns

In i386.md, neg patterns which set MODE_CC register like

(set (reg:CCC FLAGS_REG)
     (ne:CCC (match_operand:SWI48 1 "general_reg_operand") (const_int 0)))

can lead to errors when operand 1 is a constant value.  If FLAGS_REG in

(set (reg:CCC FLAGS_REG)
     (ne:CCC (const_int 2) (const_int 0)))

is set to 1, RTX simplifiers may simplify

(set (reg:SI 93)
     (neg:SI (ltu:SI (reg:CCC 17 flags) (const_int 0 [0]))))

as

(set (reg:SI 93)
     (neg:SI (ltu:SI (const_int 1) (const_int 0 [0]))))

which leads to incorrect results since LTU on MODE_CC register isn't the
same as "unsigned less than" in x86 backend.  To prevent RTL optimizers
from setting MODE_CC register to a constant, use UNSPEC_CC_NE to replace
ne:CCC/ne:CCO when setting FLAGS_REG in neg patterns.

gcc/

PR target/107172
* config/i386/i386.md (UNSPEC_CC_NE): New.
Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns.

gcc/testsuite/

PR target/107172
* gcc.target/i386/pr107172.c: New test.

18 months agoUse simple_dce_from_worklist with match_simplify_replacement.
Andrew Pinski [Thu, 27 Oct 2022 04:37:01 +0000 (04:37 +0000)] 
Use simple_dce_from_worklist with match_simplify_replacement.

This is a simple patch to do some DCE after a successful
match and simplify replacement in PHI-OPT. match and simplify
likes to generate some extra statements which should be cleaned
up.

OK? Bootstrapped and tested on x86_64-linux with no regressions.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* tree-ssa-phiopt.cc: Include tree-ssa-dce.h
(replace_phi_edge_with_variable):
New argument, dce_ssa_names. Call simple_dce_from_worklist.
(match_simplify_replacement): If we inserted a sequence,
mark the lhs of the new sequence to be possible dce.
Always move the statement and mark the lhs (if it is a name)
as possible to remove.

18 months agoc++: Fix ICE on g++.dg/modules/adl-3_c.C [PR107379]
Jakub Jelinek [Thu, 27 Oct 2022 18:10:18 +0000 (20:10 +0200)] 
c++: Fix ICE on g++.dg/modules/adl-3_c.C [PR107379]

As mentioned in the PR, apparently my r13-2887 P1467R9 changes
regressed these tests on powerpc64le-linux with IEEE quad by default.

I believe my changes just uncovered a latent bug.
The problem is that push_namespace calls find_namespace_slot,
which does:
  tree *slot = DECL_NAMESPACE_BINDINGS (ns)
    ->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
                           create_p ? INSERT : NO_INSERT);
In the <identifier_node 0x7fffe9f55ac0 details> ns case, slot is non-NULL
above with a binding_vector in it.
Then pushdecl is called and this does:
                  slot = find_namespace_slot (ns, name, ns == current_namespace);
where ns == current_namespace (ns is :: and name is details) is true.
So this again calls
          tree *slot = DECL_NAMESPACE_BINDINGS (ns)
            ->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
                                   create_p ? INSERT : NO_INSERT);
but this time with create_p and so INSERT.
At this point we reach
          if (insert == INSERT && m_size * 3 <= m_n_elements * 4)
            expand ();
and when we are unlucky and the occupancy of the hash table just reached 3/4,
expand () is called and the hash table is reallocated.  But when that happens,
it means the slot pointer in the pushdecl caller (push_namespace) points to
freed memory and so any accesses to it in make_namespace_finish will be UB.

The following patch fixes it by calling find_namespace_slot again even if it
was non-NULL, just doesn't assert it is *slot == ns in that case (because
it often is not).

2022-10-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/107379
* name-lookup.cc (push_namespace): Call find_namespace_slot again
after pushdecl as the hash table might be expanded during pushdecl.

18 months agoc++: Templated lambda mangling
Nathan Sidwell [Mon, 24 Oct 2022 21:39:55 +0000 (17:39 -0400)] 
c++: Templated lambda mangling

(Explicitly) Templated lambdas have a different signature to
implicitly templated lambdas -- '[]<template T> (T) {}' is not the
same as '[](auto) {}'.  This should be reflected in the mangling.  The
ABI captures this as
https://github.com/itanium-cxx-abi/cxx-abi/issues/31, and clang has
implemented such additions.

It's relatively straight forwards to write out the non-synthetic
template parms, and note if we need to issue an ABI warning.

gcc/cp/
* mangle.cc (write_closure_template_head): New.
(write_closure_type_name): Call it.
gcc/testsuite/
* g++.dg/abi/lambda-ctx1-18.C: Adjust.
* g++.dg/abi/lambda-ctx1-18vs17.C: Adjust.
* g++.dg/abi/lambda-tpl1-17.C: New.
* g++.dg/abi/lambda-tpl1-18.C: New.
* g++.dg/abi/lambda-tpl1-18vs17.C: New.
* g++.dg/abi/lambda-tpl1.h: New.

18 months agoaarch64: Reinstate some uses of CONSTEXPR
Richard Sandiford [Thu, 27 Oct 2022 13:20:23 +0000 (14:20 +0100)] 
aarch64: Reinstate some uses of CONSTEXPR

In 9482a5e4eac8d696129ec2854b331e1bb5dbab42 I'd replaced uses
of CONSTEXPR with direct uses of constexpr.  However, it turns
out that we still have CONSTEXPR for a reason: GCC 4.8 doesn't
implement constexpr properly, and for example rejects things like:

  extern const int x;
  constexpr int x = 1;

This patch partially reverts the previous one.  To make things
more complicated, there are still some things that need to be
constexpr rather than CONSTEXPR, since they are used to initialise
scalar constants.  The patch therefore doesn't change anything
in aarch64-feature-deps.h.

gcc/
* config/aarch64/aarch64-protos.h: Replace constexpr with
CONSTEXPR.
* config/aarch64/aarch64-sve-builtins-base.cc: Likewise.
* config/aarch64/aarch64-sve-builtins-functions.h: Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.cc: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise.
* config/aarch64/aarch64-sve-builtins.cc: Likewise.
* config/aarch64/aarch64.cc: Likewise.
* config/aarch64/driver-aarch64.cc: Likewise

18 months ago[PR tree-optimization/107394] Canonicalize global franges as they are read back.
Aldy Hernandez [Tue, 25 Oct 2022 20:44:51 +0000 (22:44 +0200)] 
[PR tree-optimization/107394] Canonicalize global franges as they are read back.

The problem here is that we're inlining a global range with NANs into
a function that has been tagged with __attribute__((optimize
("-ffinite-math-only"))).  As the global range is copied from
SSA_NAME_RANGE_INFO, its NAN bits are copied, which then cause
frange::verify_range() to fail a sanity check making sure no NANs
creep in when !HONOR_NANS.

I think what we should do is nuke the NAN bits as we're restoring the
global range.  For that matter, if we use the frange constructor,
everything except that NAN sign will be done automatically, including
dropping INFs to the min/max representable range when appropriate.

PR tree-optimization/107394

gcc/ChangeLog:

* value-range-storage.cc (frange_storage_slot::get_frange): Use
frange constructor.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr107394.c: New test.

18 months agooptions: Clarify 'Init' option property usage for streaming optimization
Thomas Schwinge [Thu, 31 Mar 2022 10:06:29 +0000 (12:06 +0200)] 
options: Clarify 'Init' option property usage for streaming optimization

This clarifies commit 95db7e9afe57ca1c269d46baa2accced004e5c74
"options, lto: Optimize streaming of optimization nodes".

No functional change; no change in generated files.

gcc/
* optc-save-gen.awk: Clarify 'Init' option property usage for
streaming optimization.

18 months agolto: do not load LTO stream for aliases [PR107418]
Martin Liska [Thu, 27 Oct 2022 08:29:17 +0000 (10:29 +0200)] 
lto: do not load LTO stream for aliases [PR107418]

PR lto/107418

gcc/lto/ChangeLog:

* lto-dump.cc (lto_main): Do not load LTO stream for aliases.

18 months agoc++: Fix excess precision related ICE on invalid binop [PR107382, PR107383]
Jakub Jelinek [Thu, 27 Oct 2022 08:24:45 +0000 (10:24 +0200)] 
c++: Fix excess precision related ICE on invalid binop [PR107382, PR107383]

The following tests ICE in the gcc_assert (common); in cp_build_binary_op.
I've missed that while for * common is set always, while for +, - and /
it is in some cases not.
If it is not, then
  if (!result_type
      && arithmetic_types_p
      && (shorten || common || short_compare))
condition is false, then the following
  if (may_need_excess_precision
      && (orig_type0 != type0 || orig_type1 != type1)
      && build_type == NULL_TREE)
would fail the assertion there and if there wouldn't be excess precision,
  if (code == SPACESHIP_EXPR)
would be false (for SPACESHIP_EXPR we always have build_type set like for
other comparisons) and then trigger
  if (!result_type)
    {
      if (complain & tf_error)
        {
          binary_op_rich_location richloc (location,
                                           orig_op0, orig_op1, true);
          error_at (&richloc,
                    "invalid operands of types %qT and %qT to binary %qO",
                    TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code);
        }
      return error_mark_node;
    }
So, if result_type is NULL, we don't really need to compute
semantic_result_type because nothing will use it anyway and can get
fall through into the error/return error_mark_node; case.

2022-10-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/107382
PR c++/107383
* typeck.cc (cp_build_binary_op): Don't compute semantic_result_type
if result_type is NULL.

* g++.dg/diagnostic/bad-binary-ops2.C: New test.

18 months agoIRA: Make sure array is big enough
Torbjörn SVENSSON [Tue, 25 Oct 2022 09:45:40 +0000 (11:45 +0200)] 
IRA: Make sure array is big enough

In commit 081c96621da, the call to resize_reg_info() was moved before
the call to remove_scratches() and the latter one can increase the
number of regs and that would cause an out of bounds usage on the
reg_renumber global array.

Without this patch, the following testcase randomly fails with:
during RTL pass: ira
In file included from /src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:13:
/src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c: In function 'checkgSf13':
/src/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h:28:1: internal compiler error: Segmentation fault
/src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:22:1: note: in expansion of macro 'TEST'

gcc/ChangeLog:

* ira.cc: Resize array after reg number increased.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
18 months agoRISC-V: Add zhinx/zhinxmin testcases.
Jiawei [Thu, 20 Oct 2022 09:32:35 +0000 (17:32 +0800)] 
RISC-V: Add zhinx/zhinxmin testcases.

Test zhinx/zhinxmin support, same like with zfh/zfhmin testcases
but use gprs and don't use fmv instruction.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/_Float16-zhinx-1.c: New test.
* gcc.target/riscv/_Float16-zhinx-2.c: New test.
* gcc.target/riscv/_Float16-zhinx-3.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-1.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-2.c: New test.
* gcc.target/riscv/_Float16-zhinxmin-3.c: New test.

18 months agoRISC-V: Limit regs use for z*inx extension.
Jiawei [Thu, 20 Oct 2022 09:32:34 +0000 (17:32 +0800)] 
RISC-V: Limit regs use for z*inx extension.

Limit z*inx abi support with 'ilp32','ilp32e','lp64' only.
Use GPR instead FPR when 'zfinx' enable, Only use even registers
in RV32 when 'zdinx' enable.
Enable FLOAT16 when Zhinx/Zhinxmin enabled.

Co-Authored-By: Sinan Lin <sinan@isrc.iscas.ac.cn>
gcc/ChangeLog:

* config/riscv/constraints.md (TARGET_ZFINX ? GR_REGS): Set GPRS
use while Zfinx is enable.
* config/riscv/riscv.cc (riscv_hard_regno_mode_ok): Limit odd
registers use when Zdinx enable in RV32 cases.
(riscv_option_override): New target enable MASK_FDIV.
(riscv_libgcc_floating_mode_supported_p): New error info when
use incompatible arch&abi.
(riscv_excess_precision): New target enable FLOAT16.

18 months agoRISC-V: Target support for z*inx extension.
Jiawei [Thu, 20 Oct 2022 09:32:33 +0000 (17:32 +0800)] 
RISC-V: Target support for z*inx extension.

Support 'TARGET_ZFINX' with float instruction pattern and builtin function.
Reuse 'TARGET_HADR_FLOAT',  'TARGET_DOUBLE_FLOAT' and 'TARGET_ZHINX' patterns.

gcc/ChangeLog:

* config/riscv/iterators.md (TARGET_ZFINX):New target.
(TARGET_ZDINX): Ditto.
(TARGET_ZHINX): Ditto.
* config/riscv/riscv-builtins.cc (AVAIL): Ditto.
(riscv_atomic_assign_expand_fenv): Ditto.
* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Ditto.
* config/riscv/riscv.md: Ditto.

18 months agoRISC-V: Minimal support of z*inx extension.
Jiawei [Thu, 20 Oct 2022 09:32:32 +0000 (17:32 +0800)] 
RISC-V: Minimal support of z*inx extension.

Minimal support of z*inx extension, include 'zfinx', 'zdinx' and 'zhinx/zhinxmin'
corresponding to 'f', 'd' and 'zfh/zfhmin', the 'zdinx' will imply 'zfinx'
same as 'd' imply 'f', 'zhinx' will aslo imply 'zfinx', all zfinx extension imply 'zicsr'.

Co-Authored-By: Sinan Lin <sinan@isrc.iscas.ac.cn>
gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: New extensions.
* config/riscv/arch-canonicalize: New imply relations.
* config/riscv/riscv-opts.h (MASK_ZFINX): New mask.
(MASK_ZDINX): Ditto.
(MASK_ZHINX): Ditto.
(MASK_ZHINXMIN): Ditto.
(TARGET_ZFINX): New target.
(TARGET_ZDINX): Ditto.
(TARGET_ZHINX): Ditto.
(TARGET_ZHINXMIN): Ditto.
* config/riscv/riscv.opt: New target variable.

18 months agoDaily bump.
GCC Administrator [Thu, 27 Oct 2022 00:18:35 +0000 (00:18 +0000)] 
Daily bump.

18 months agoc++: share code between [[assert]] and contracts
Jason Merrill [Fri, 21 Oct 2022 14:48:15 +0000 (10:48 -0400)] 
c++: share code between [[assert]] and contracts

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_assert): Factor out from...
(cxx_eval_internal_function): ...here.
(cxx_eval_constant_expression): Also use it for contracts.
* contracts.cc (build_contract_check): Use build_assume_call.

18 months agoanalyzer: fixes to file-descriptor handling
David Malcolm [Wed, 26 Oct 2022 20:45:17 +0000 (16:45 -0400)] 
analyzer: fixes to file-descriptor handling

gcc/analyzer/ChangeLog:
* sm-fd.cc (fd_state_machine::on_open): Transition to "unchecked"
when the mode is symbolic, rather than just on integer constants.
(fd_state_machine::check_for_open_fd): Don't complain about
unchecked values in the start state.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-3.c (test_5): Expect "opened here" message
even when flags are symbolic.
(test_read_from_symbolic_fd): New.
(test_write_to_symbolic_fd): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
18 months agoanalyzer: add sm-fd.dot
David Malcolm [Wed, 26 Oct 2022 20:44:23 +0000 (16:44 -0400)] 
analyzer: add sm-fd.dot

Add a .dot file to document the file descriptor state machine.

gcc/analyzer/ChangeLog:
* sm-fd.dot: New file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
18 months agoFortran: BOZ literal constants are not compatible to any type [PR103413]
Harald Anlauf [Wed, 26 Oct 2022 19:00:44 +0000 (21:00 +0200)] 
Fortran: BOZ literal constants are not compatible to any type [PR103413]

gcc/fortran/ChangeLog:

PR fortran/103413
* symbol.cc (gfc_type_compatible): A boz-literal-constant has no type
and thus is not considered compatible to any type.

gcc/testsuite/ChangeLog:

PR fortran/103413
* gfortran.dg/illegal_boz_arg_4.f90: New test.

18 months agobpf: add preserve_field_info builtin
David Faust [Mon, 24 Oct 2022 20:59:39 +0000 (13:59 -0700)] 
bpf: add preserve_field_info builtin

Add BPF __builtin_preserve_field_info. This builtin is used to extract
information to facilitate struct and union relocations performed by the
BPF loader, especially for bitfields.

The builtin has the following signature:

  unsigned int __builtin_preserve_field_info (EXPR, unsigned int KIND);

Where EXPR is an expression accessing a field of a struct or union.
Depending on KIND, different information is returned to the program. The
supported values for KIND are as follows:

  enum {
    FIELD_BYTE_OFFSET = 0,
    FIELD_BYTE_SIZE,
    FIELD_EXISTENCE,
    FIELD_SIGNEDNESS,
    FIELD_LSHIFT_U64,
    FIELD_RSHIFT_U64
  };

If -mco-re is in effect (explicitly or implicitly specified), a CO-RE
relocation is added for the access in EXPR recording the relevant
information according to KIND.

gcc/

* config/bpf/bpf.cc: Support __builtin_preserve_field_info.
(enum bpf_builtins): Add new builtin.
(bpf_init_builtins): Likewise.
(bpf_core_field_info): New function.
(bpf_expand_builtin): Accomodate new builtin. Refactor adding new
relocation to...
(maybe_make_core_relo): ... here. New function.
(bpf_resolve_overloaded_builtin): Accomodate new builtin.
(bpf_core_newdecl): Likewise.
(bpf_core_walk): Likewise.
(bpf_core_is_maybe_aggregate_access): Improve logic.
(struct core_walk_data): New.
* config/bpf/coreout.cc (bpf_core_reloc_add): Allow adding different
relocation kinds.
* config/bpf/coreout.h: Analogous change.
* doc/extend.texi: Document BPF __builtin_preserve_field_info.

gcc/testsuite/

* gcc.target/bpf/core-builtin-fieldinfo-errors-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-errors-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-existence-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-be.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-le.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-lshift-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-rshift-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-sign-1.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-sign-2.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-size-1.c: New test.

18 months agoc++: Implement -Wdangling-reference [PR106393]
Marek Polacek [Fri, 14 Oct 2022 14:05:57 +0000 (10:05 -0400)] 
c++: Implement -Wdangling-reference [PR106393]

This patch implements a new experimental warning (enabled by -Wall) to
detect references bound to temporaries whose lifetime has ended.  The
primary motivation is the Note in
<https://en.cppreference.com/w/cpp/algorithm/max>:

  Capturing the result of std::max by reference produces a dangling reference
  if one of the parameters is a temporary and that parameter is returned:

  int n = 1;
  const int& r = std::max(n-1, n+1); // r is dangling

That's because both temporaries for n-1 and n+1 are destroyed at the end
of the full expression.  With this warning enabled, you'll get:

g.C:3:12: warning: possibly dangling reference to a temporary [-Wdangling-reference]
    3 | const int& r = std::max(n-1, n+1);
      |            ^
g.C:3:24: note: the temporary was destroyed at the end of the full expression 'std::max<int>((n - 1), (n + 1))'
    3 | const int& r = std::max(n-1, n+1);
      |                ~~~~~~~~^~~~~~~~~~

The warning works by checking if a reference is initialized with a function
that returns a reference, and at least one parameter of the function is
a reference that is bound to a temporary.  It assumes that such a function
actually returns one of its arguments!  (I added code to check_return_expr
to suppress the warning when we've seen the definition of the function
and we can say that it can return a variable with static storage
duration.)

It warns when the function in question is a member function, but only if
the function is invoked on a temporary object, otherwise the warning
would emit loads of warnings for valid code like obj.emplace<T>({0}, 0).
It does detect the dangling reference in:

  struct S {
    const S& self () { return *this; }
  };
  const S& s = S().self();

It warns in member initializer lists as well:

  const int& f(const int& i) { return i; }
  struct S {
    const int &r;
    S() : r(f(10)) { }
  };

I've run the testsuite/bootstrap with the warning enabled by default.
There were just a few FAILs, all of which look like genuine bugs.
A bootstrap with the warning enabled by default passed as well.

When testing a previous version of the patch, there were many FAILs in
libstdc++'s 22_locale/; all of them because the warning triggered on

  const test_type& obj = std::use_facet<test_type>(std::locale());

but this code looks valid -- std::use_facet doesn't return a reference
to its parameter.  Therefore I added a #pragma and code to suppress the
warning.

PR c++/106393

gcc/c-family/ChangeLog:

* c.opt (Wdangling-reference): New.

gcc/cp/ChangeLog:

* call.cc (expr_represents_temporary_p): New, factored out of...
(conv_binds_ref_to_temporary): ...here.  Don't return false just
because a ck_base is missing.  Use expr_represents_temporary_p.
(do_warn_dangling_reference): New.
(maybe_warn_dangling_reference): New.
(extend_ref_init_temps): Call maybe_warn_dangling_reference.
* cp-tree.h: Adjust comment.
* typeck.cc (check_return_expr): Suppress -Wdangling-reference
warnings.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wdangling-reference.

libstdc++-v3/ChangeLog:

* include/bits/locale_classes.tcc: Add #pragma to disable
-Wdangling-reference with std::use_facet.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/elision4.C: Use -Wdangling-reference, add dg-warning.
* g++.dg/cpp23/elision7.C: Likewise.
* g++.dg/warn/Wdangling-pointer-2.C: Use -Wno-dangling-reference.
* g++.dg/warn/Wdangling-reference1.C: New test.
* g++.dg/warn/Wdangling-reference2.C: New test.
* g++.dg/warn/Wdangling-reference3.C: New test.

18 months agoxtensa: Fix out-of-bounds array access in the movdi pattern
Takayuki 'January June' Suwa [Wed, 26 Oct 2022 06:27:51 +0000 (15:27 +0900)] 
xtensa: Fix out-of-bounds array access in the movdi pattern

The following new warnings were introduced in the commit
4f3f0296acbb ("xtensa: Prepare the transition from Reload to LRA"):

gcc/config/xtensa/xtensa.md:945:26: error: array subscript 3 is above
array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
  945 |           emit_move_insn (operands[2], operands[3]);
gcc/config/xtensa/xtensa.md:945:26: error: array subscript 2 is above
array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
  945 |           emit_move_insn (operands[2], operands[3]);

From gcc/insn-emit.cc (generated by building):

> /* ../../gcc/config/xtensa/xtensa.md:932 */
> rtx
> gen_movdi (rtx operand0,
>  rtx operand1)
> {
>   rtx_insn *_val = 0;
>   start_sequence ();
>   {
>     rtx operands[2]; // only 2 elements
>     operands[0] = operand0;
>     operands[1] = operand1;
> #define FAIL return (end_sequence (), _val)
> #define DONE return (_val = get_insns (), end_sequence (), _val)
> #line 936 "../../gcc/config/xtensa/xtensa.md"
> {
>   if (CONSTANT_P (operands[1]))
>     {
>       /* Split in halves if 64-bit Const-to-Reg moves
>   because of offering further optimization opportunities.  */
>       if (register_operand (operands[0], DImode))
>  {
>    xtensa_split_DI_reg_imm (operands); // out-of-bounds!
>    emit_move_insn (operands[0], operands[1]);
>    emit_move_insn (operands[2], operands[3]); // out-of-bounds!
>    DONE;
>  }

gcc/ChangeLog:

* config/xtensa/xtensa.md (movdi):
Copy operands[0...1] to ops[0...3] and then use the latter before
calling xtensa_split_DI_reg_imm() and emitting insns.

18 months agoipa-visibility: remove assert in TLS optimization [PR107353]
Alexander Monakov [Wed, 26 Oct 2022 13:37:34 +0000 (16:37 +0300)] 
ipa-visibility: remove assert in TLS optimization [PR107353]

When upgrading TLS access model based on optimized symbol visibility
status, we attempted to assert that recomputing the model would not
weaken it. It turns out that C, C++, and Fortran front-ends all can
(unintentionally) assign a stronger model than what can be derived
from the declaration.

Let's act conservatively instead of asserting, at least as long as
such pre-existing issues remain.

gcc/ChangeLog:

PR other/107353
* ipa-visibility.cc (function_and_variable_visibility):
Conditionally upgrade TLS model instead of asserting.

18 months agoCheck if varying may also be non-negative.
Andrew MacLeod [Tue, 25 Oct 2022 19:16:47 +0000 (15:16 -0400)] 
Check if varying may also be non-negative.

When using strict enums, we can sometimes turn varying into a better
range.

* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if
stmt is non-negative and adjust the range.