Commit graph

206953 commits

Author SHA1 Message Date
Chung-Ju Wu
6e249a9ad9 arm: Add support for Arm Cortex-M52 CPU.
This patch adds the -mcpu support for the Arm Cortex-M52 CPU which is
an Armv8.1-M Mainline CPU supporting MVE and PACBTI by default.

-mcpu=cortex-m52 switch by default matches to -march=armv8.1-m.main+pacbti+mve.fp+fp.dp.

The cde feature is supported by specifying +cdecpN (e.g. -mcpu=cortex-m52+cdecp<N>),
where N is the coprocessor number 0 to 7.

Also following options are provided to disable default features.
+nomve.fp (disables MVE Floating point)
+nomve (disables MVE Integer and MVE Floating point)
+nodsp (disables dsp, MVE Integer and MVE Floating point)
+nopacbti (disables pacbti)
+nofp (disables floating point and MVE floating point)

Signed-off-by: Chung-Ju Wu <jasonwucj@gmail.com>

gcc/ChangeLog:

	* config/arm/arm-cpus.in (cortex-m52): New cpu.
	* config/arm/arm-tables.opt: Regenerate.
	* config/arm/arm-tune.md: Regenerate.
2024-01-09 14:26:18 +08:00
Haochen Jiang
ab6224dfe1 i386: Fix recent testcase fail
After commit 01f4251b87, early break
vectorization is supported. The two testcases need to be fixed.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-xorsign-1.c: Fix testcase.
	* gcc.target/i386/part-vect-absneghf.c: Ditto.
2024-01-09 13:47:51 +08:00
Jiahao Xu
34d339bbd0 LoongArch: Implement vec_init<M><N> where N is a LSX vector mode
This patch implements more vec_init optabs that can handle two LSX vectors producing a LASX
vector by concatenating them. When an lsx vector is concatenated with an LSX const_vector of
zeroes, the vec_concatz pattern can be used effectively. For example as below

typedef short v8hi __attribute__ ((vector_size (16)));
typedef short v16hi __attribute__ ((vector_size (32)));
v8hi a, b;

v16hi vec_initv16hiv8hi ()
{
 return __builtin_shufflevector (a, b, 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15);
}

Before this patch:

vec_initv16hiv8hi:
    addi.d  $r3,$r3,-64
    .cfi_def_cfa_offset 64
    xvrepli.h   $xr0,0
    la.local    $r12,.LANCHOR0
    xvst    $xr0,$r3,0
    xvst    $xr0,$r3,32
    vld $vr0,$r12,0
    vst $vr0,$r3,0
    vld $vr0,$r12,16
    vst $vr0,$r3,32
    xvld    $xr1,$r3,32
    xvld    $xr2,$r3,32
    xvld    $xr0,$r3,0
    xvilvh.h    $xr0,$xr1,$xr0
    xvld    $xr1,$r3,0
    xvilvl.h    $xr1,$xr2,$xr1
    addi.d  $r3,$r3,64
    .cfi_def_cfa_offset 0
    xvpermi.q   $xr0,$xr1,32
    jr  $r1

After this patch:

vec_initv16hiv8hi:
    la.local        $r12,.LANCHOR0
    vld     $vr0,$r12,32
    vld     $vr2,$r12,48
    xvilvh.h        $xr1,$xr2,$xr0
    xvilvl.h        $xr0,$xr2,$xr0
    xvpermi.q       $xr1,$xr0,32
    xvst    $xr1,$r4,0
    jr      $r1

gcc/ChangeLog:

	* config/loongarch/lasx.md (vec_initv32qiv16qi): Rename to ..
	(vec_init<mode><lasxhalf>): .. this, and extend to mode.
	(@vec_concatz<mode>): New insn pattern.
	* config/loongarch/loongarch.cc (loongarch_expand_vector_group_init):
	Handle VALS containing two vectors.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lasx/lasx-vec-init-2.c: New test.
2024-01-09 12:00:32 +08:00
Juzhe-Zhong
2e4607666c RISC-V: Fix comments of segment load/store intrinsic [NFC]
We have supported segment load/store intrinsics.

Committed as it is obvious.

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins-functions.def (vleff): Move comments.
	(vundefined): Ditto.
2024-01-09 10:15:26 +08:00
Feng Wang
411b210797 RISC-V: Add crypto vector api-testing cases.
Patch v8: Resubmit after fix the rtl-checking issue. Passed all the riscv regression test.
Patch v7: Add newline at the end of file.
Patch v6: Move intrinsic tests into rvv/base.
Patch v5: Rebase
Patch v4: Add some RV32 vx constraint testcase.
Patch v3: Refine crypto vector api-testing cases.
Patch v2: Update march info according to the change of riscv-common.c

This patch add crypto vector api-testing cases based on
https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/eopc/vector-crypto/auto-generated/vector-crypto
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/zvbb-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvbb_vandn_vx_constraint.c: New test.
	* gcc.target/riscv/rvv/base/zvbc-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvbc_vx_constraint-1.c: New test.
	* gcc.target/riscv/rvv/base/zvbc_vx_constraint-2.c: New test.
	* gcc.target/riscv/rvv/base/zvkg-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvkned-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvknha-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvknhb-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvksed-intrinsic.c: New test.
	* gcc.target/riscv/rvv/base/zvksh-intrinsic.c: New test.
	* gcc.target/riscv/zvkb.c: New test.
2024-01-09 01:37:38 +00:00
Feng Wang
e50a1ed3d3 RISC-V: Add crypto vector builtin function.
This patch add the intrinsic funtions of crypto vector based on the
intrinsic doc(https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob
/eopc/vector-crypto/auto-generated/vector-crypto/intrinsic_funcs.md).

Co-Authored by: Songhe Zhu <zhusonghe@eswincomputing.com>
Co-Authored by: Ciyan Pan <panciyan@eswincomputing.com>
gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins-bases.cc (class vandn):
				Add new function_base for crypto vector.
	(class bitmanip): Ditto.
	(class b_reverse):Ditto.
	(class vwsll):   Ditto.
	(class clmul):   Ditto.
	(class vg_nhab):  Ditto.
	(class crypto_vv):Ditto.
	(class crypto_vi):Ditto.
	(class vaeskf2_vsm3c):Ditto.
	(class vsm3me): Ditto.
	(BASE): Add BASE declaration for crypto vector.
	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
	* config/riscv/riscv-vector-builtins-functions.def (REQUIRED_EXTENSIONS):
				Add crypto vector intrinsic definition.
	(vbrev): Ditto.
	(vclz): Ditto.
	(vctz): Ditto.
	(vwsll): Ditto.
	(vandn): Ditto.
	(vbrev8): Ditto.
	(vrev8): Ditto.
	(vrol): Ditto.
	(vror): Ditto.
	(vclmul): Ditto.
	(vclmulh): Ditto.
	(vghsh): Ditto.
	(vgmul): Ditto.
	(vaesef): Ditto.
	(vaesem): Ditto.
	(vaesdf): Ditto.
	(vaesdm): Ditto.
	(vaesz): Ditto.
	(vaeskf1): Ditto.
	(vaeskf2): Ditto.
	(vsha2ms): Ditto.
	(vsha2ch): Ditto.
	(vsha2cl): Ditto.
	(vsm4k): Ditto.
	(vsm4r): Ditto.
	(vsm3me): Ditto.
	(vsm3c): Ditto.
	* config/riscv/riscv-vector-builtins-shapes.cc (struct crypto_vv_def):
				Add new function_shape for crypto vector.
	(struct crypto_vi_def): Ditto.
	(struct crypto_vv_no_op_type_def): Ditto.
	(SHAPE): Add SHAPE declaration of crypto vector.
	* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
	* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_CRYPTO_SEW32_OPS):
				Add new data type for crypto vector.
	(DEF_RVV_CRYPTO_SEW64_OPS): Ditto.
	(vuint32mf2_t): Ditto.
	(vuint32m1_t): Ditto.
	(vuint32m2_t): Ditto.
	(vuint32m4_t): Ditto.
	(vuint32m8_t): Ditto.
	(vuint64m1_t): Ditto.
	(vuint64m2_t): Ditto.
	(vuint64m4_t): Ditto.
	(vuint64m8_t): Ditto.
	* config/riscv/riscv-vector-builtins.cc (DEF_RVV_CRYPTO_SEW32_OPS):
				Add new data struct for crypto vector.
	(DEF_RVV_CRYPTO_SEW64_OPS): Ditto.
	(registered_function::overloaded_hash): Processing size_t uimm for C overloaded func.
	* config/riscv/riscv-vector-builtins.def (vi): Add vi OP_TYPE.
2024-01-09 01:03:03 +00:00
GCC Administrator
6b1d6a2d3a Daily bump. 2024-01-09 00:17:50 +00:00
John David Anglin
ff9e79eba2 xfail dg-final "Sunk statements: 5" on hppa*64*-*-*
2024-01-08  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/ssa-sink-18.c: xfail dg-final "Sunk statements: 5"
	on hppa*64*-*-*.
2024-01-08 22:32:03 +00:00
John David Anglin
d1260e9e24 Skip gfortran.dg/dec_math.f90 on hppa
hppa*-*-hpux* doesn't have any long double trig functions.

2024-01-08  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

	* gfortran.dg/dec_math.f90: Skip on hppa*-*-hpux*.
2024-01-08 22:18:28 +00:00
John David Anglin
932b8d077c hppa: Fix bind_c_coms.f90 and bind_c_vars.f90 tests on hppa
Commit 6271dd98 changed the default from -fcommon to -fno-common.
This silently changed the alignment of uninitialized BSS data on
hppa where the alignment of common data must be greater or equal
to the alignment of the largest type that will fit in the block.
For example, the alignment of `double d[2];' changed from 16 to 8
on hppa64.

The hppa architecture requires strict alignment and the linker
warns about inconsistent alignment of variables.  This change broke
the gfortran.dg/bind_c_coms.f90 and gfortran.dg/bind_c_vars.f90
tests.  These tests check whether bind_c works between fortran
and C.

Adding the -fcommon option fixes the tests.  Probably, gcc and HP
C are now by default inconsistent but that's water under the bridge.

2024-01-08  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

	PR testsuite/94253
	* gfortran.dg/bind_c_coms.f90: Add -fcommon option on hppa*-*-*.
	* gfortran.dg/bind_c_vars.f90: Likewise.
2024-01-08 20:27:20 +00:00
Thomas Schwinge
f9290cdf46 GCN: Add pre-initial support for gfx1100: 'EF_AMDGPU_MACH_AMDGCN_GFX1100'
../../../source-gcc/libgomp/plugin/plugin-gcn.c: In function ‘isa_hsa_name’:
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c:1666:10: error: ‘EF_AMDGPU_MACH_AMDGCN_GFX1100’ undeclared (first use in this function); did you mean ‘EF_AMDGPU_MACH_AMDGCN_GFX1030’?
     1666 |     case EF_AMDGPU_MACH_AMDGCN_GFX1100:
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          EF_AMDGPU_MACH_AMDGCN_GFX1030
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c:1666:10: note: each undeclared identifier is reported only once for each function it appears in
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c: In function ‘isa_code’:
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c:1711:12: error: ‘EF_AMDGPU_MACH_AMDGCN_GFX1100’ undeclared (first use in this function); did you mean ‘EF_AMDGPU_MACH_AMDGCN_GFX1030’?
     1711 |     return EF_AMDGPU_MACH_AMDGCN_GFX1100;
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |            EF_AMDGPU_MACH_AMDGCN_GFX1030
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c: In function ‘max_isa_vgprs’:
    ../../../source-gcc/libgomp/plugin/plugin-gcn.c:1728:10: error: ‘EF_AMDGPU_MACH_AMDGCN_GFX1100’ undeclared (first use in this function); did you mean ‘EF_AMDGPU_MACH_AMDGCN_GFX1030’?
     1728 |     case EF_AMDGPU_MACH_AMDGCN_GFX1100:
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          EF_AMDGPU_MACH_AMDGCN_GFX1030
    make[4]: *** [Makefile:813: libgomp_plugin_gcn_la-plugin-gcn.lo] Error 1

Fix-up for commit 52a2c659ae
"GCN: Add pre-initial support for gfx1100".

	libgomp/
	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): Add
	'EF_AMDGPU_MACH_AMDGCN_GFX1100'.
2024-01-08 20:46:37 +01:00
Joseph Myers
0d0908c365 MAINTAINERS: Update my email address
* MAINTAINERS: Update my email address.
2024-01-08 18:52:09 +00:00
Ilya Leoshkevich
ba4cfef0a4 asan: Do not call asan_function_start () without the current function [PR113251]
Using ASAN on i686-linux with -fPIC causes an ICE, because when
pc_thunks are generated, there is no current function anymore, but
asan_function_start () expects one.

Fix by not calling asan_function_start () without one.

A narrower fix would be to temporarily disable ASAN around pc_thunk
generation.  However, the issue looks generic enough, and may affect
less often tested configurations, so go for a broader fix.

Fixes: e66dc37b29 ("asan: Align .LASANPC on function boundary")
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

gcc/ChangeLog:

	PR sanitizer/113251
	* varasm.cc (assemble_function_label_raw): Do not call
	asan_function_start () without the current function.
2024-01-08 19:36:27 +01:00
Cupertino Miranda
dfc88fb51c bpf: Correct BTF for kernel_helper attributed decls
This patch fix a problem with kernel_helper attribute BTF information,
which incorrectly generates BTF_KIND_FUNC entry.
This BTF entry although accurate with traditional extern function
declarations, once the function is attributed with kernel_helper, it is
semantically incompatible of the kernel helpers in BPF infrastructure.

gcc/ChangeLog:
	PR target/113225
	* btfout.cc (btf_collect_datasec): Skip creating BTF info for
	extern and kernel_helper attributed function decls.
gcc/testsuite/ChangeLog:
	* gcc.target/bpf/attr-kernel-helper.c: New test.
2024-01-08 18:35:25 +00:00
Cupertino Miranda
4a5bb8bc1c btf: print string offset in comment
When using -dA, this function was only printing as comment btf_string or
btf_aux_string.
This patch changes the comment to also include the position of the
string within the section in hexadecimal format.

gcc/ChangeLog:
	* btfout.cc (output_btf_strs): Changed.
2024-01-08 18:35:25 +00:00
Julian Brown
a17299c17a OpenMP: Support accelerated 2D/3D memory copies for AMD GCN
This patch adds support for 2D/3D memory copies for omp_target_memcpy_rect
using AMD extensions to the HSA API.  This is just the AMD GCN-specific
part of the following patch:

  https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631001.html

2024-01-04  Julian Brown  <julian@codesourcery.com>

libgomp/
	* plugin/plugin-gcn.c (hsa_runtime_fn_info): Add
	hsa_amd_memory_lock_fn, hsa_amd_memory_unlock_fn,
	hsa_amd_memory_async_copy_rect_fn function pointers.
	(init_hsa_runtime_functions): Add above functions, with
	DLSYM_OPT_FN.
	(GOMP_OFFLOAD_memcpy2d, GOMP_OFFLOAD_memcpy3d): New functions.
2024-01-08 17:56:17 +00:00
Harald Anlauf
0056458550 Fortran: SIZE optional DIM argument having OPTIONAL+VALUE attributes [PR113245]
gcc/fortran/ChangeLog:

	PR fortran/113245
	* trans-intrinsic.cc (gfc_conv_intrinsic_size): Use
	gfc_conv_expr_present() for proper check of optional DIM argument.

gcc/testsuite/ChangeLog:

	PR fortran/113245
	* gfortran.dg/size_optional_dim_2.f90: New test.
2024-01-08 18:42:39 +01:00
Jonathan Wakely
eb846114ed libstdc++: Remove std::__unicode::__null_sentinel
The name __null_sentinel is defined as a macro by newlib, so we can't
use it as an identifier. That variable is not actually used by
libstdc++, it was added because P2728R6 proposes std::uc::null_sentinel.
Since we don't need it and it breaks bootstrap for newlib targets, just
remove it. A null sentinel can still be used by constructing a
_Null_sentinel_t object as needed, rather than having a named object of
that type predefined.

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h (__null_sentinel): Remove.
	* testsuite/17_intro/names.cc: Add __null_sentinel.
2024-01-08 16:04:59 +00:00
Tobias Burnus
97a52f69d2 amdgcn: Add gfx1100 to new XNACK defaults in mkoffload
Commit r14-6997-g78dff4c25c1b95 added an arch-dependent
SET_XNACK_OFF vs. SET_XNACK_ANY check; that was added
between writing and committing the add-gfx1100
commit r14-7005-g52a2c659ae6c21 - and I missed to add
it there.

gcc/ChangeLog:

	* config/gcn/mkoffload.cc (main): Handle gfx1100
	when setting the default XNACK.
2024-01-08 15:18:10 +01:00
Tobias Burnus
52a2c659ae GCN: Add pre-initial support for gfx1100
ROCm since 5.7.1 supports gfx1100 (RDNA3) cards. This commit adds support
for it, mostly by assuming gfx1100 behaves identical to gfx1030.  Like gfx1030,
gfx1100 support is neither documented nor the build of the multilib enabled by
default.

But contrary to gfx1030, gfx1100 has a known issue causing some libraries not
to build, including newlib: The sdwa variant of v_mov_b32_sdwa is not supported
by the hardware but GCC current does generates this instruction.
This will be addressed in a later commit.

gcc/ChangeLog:

	* config.gcc (amdgcn-*-amdhsa): Accept --with-arch=gfx1100.
	* config/gcn/gcn-hsa.h (NO_XNACK): Add gfx1100:
	(ASM_SPEC): Handle gfx1100.
	* config/gcn/gcn-opts.h (enum processor_type): Add PROCESSOR_GFX1100.
	(enum gcn_isa): Add ISA_RDNA3.
	(TARGET_GFX1100, TARGET_RDNA2_PLUS, TARGET_RDNA3): Define.
	* config/gcn/gcn-valu.md: Change TARGET_RDNA2 to TARGET_RDNA2_PLUS.
	* config/gcn/gcn.cc (gcn_option_override,
	gcn_omp_device_kind_arch_isa, output_file_start): Handle gfx1100.
	(gcn_global_address_p, gcn_addr_space_legitimate_address_p): Change
	TARGET_RDNA2 to TARGET_RDNA2_PLUS.
	(gcn_hsa_declare_function_name): Don't use '.amdhsa_reserve_flat_scratch'
	with gfx1100.
	* config/gcn/gcn.h (ASSEMBLER_DIALECT): Likewise.
	(TARGET_CPU_CPP_BUILTINS): Define __RDNA3__, __gfx1030__ and
	__gfx1100__.
	* config/gcn/gcn.md: Change TARGET_RDNA2 to TARGET_RDNA2_PLUS.
	* config/gcn/gcn.opt (Enum gpu_type): Add gfx1100.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1100): Define.
	(isa_has_combined_avgprs, main): Handle gfx1100.
	* config/gcn/t-omp-device (isa): Add gfx1100.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (gcn_gfx1100_s): New const string.
	(gcn_isa_name_len): Fix length.
	(isa_hsa_name, isa_code, max_isa_vgprs): Handle gfx1100.
2024-01-08 15:12:44 +01:00
Richard Biener
4b358f9b73 Clarify -mmovbe documentation
It was noticed that -mmovbe doesn't use movbe for __builtin_bswap{32,64}
when not optimizing.  The follownig adjusts the documentation to
say it will be used for optimizing and applies to all byte swaps,
not just those carried out via builtin function calls.

	* doc/invoke.texi (-mmovbe): Clarify.
2024-01-08 14:50:12 +01:00
Richard Biener
b3cc5a1efe tree-optimization/113026 - avoid vector epilog in more cases
The following avoids creating a niter peeling epilog more consistently,
matching what peeling later uses for the skip_vector condition, in
particular when versioning is required which then also ensures the
vector loop is entered unless the epilog is vectorized.  This should
ideally match LOOP_VINFO_VERSIONING_THRESHOLD which is only computed
later, some refactoring could make that better matching.

The patch also makes sure to adjust the upper bound of the epilogues
when we do not have a skip edge around the vector loop.

	PR tree-optimization/113026
	* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
	Avoid an epilog in more cases.
	* tree-vect-loop-manip.cc (vect_do_peeling): Adjust the
	epilogues niter upper bounds and estimates.

	* gcc.dg/torture/pr113026-1.c: New testcase.
	* gcc.dg/torture/pr113026-2.c: Likewise.
2024-01-08 14:45:56 +01:00
Jakub Jelinek
8c0dd8a6ff gimplify: Fix ICE in recalculate_side_effects [PR113228]
The following testcase ICEs during regimplificatgion since the addition of
(convert (eqne zero_one_valued_p@0 INTEGER_CST@1))
simplification.  That simplification is novel in the sense that in
gimplify_expr it can turn an expression (comparison in particular) into
a SSA_NAME.  Normally when gimplify_expr sees originally a SSA_NAME, it does
        case SSA_NAME:
          /* Allow callbacks into the gimplifier during optimization.  */
          ret = GS_ALL_DONE;
          break;
and doesn't try to recalculate side effects because of that, but in this
case gimplify_expr normally enters the:
        default:
          switch (TREE_CODE_CLASS (TREE_CODE (*expr_p)))
            {
            case tcc_comparison:
then does
                      *expr_p = gimple_boolify (*expr_p);
and then
                          *expr_p = fold_convert_loc (input_location,
                                                      org_type, *expr_p);
with this new match.pd simplification turns that tcc_comparison class
into SSA_NAME.  Unlike the outer SSA_NAME handling though, this falls
through into
          recalculate_side_effects (*expr_p);

        dont_recalculate:
          break;
but unfortunately recalculate_side_effects doesn't handle SSA_NAME and ICEs
on it.
SSA_NAMEs don't ever have TREE_SIDE_EFFECTS set on those, so the following
patch fixes it by handling it similarly to the tcc_constant case.

2024-01-08  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/113228
	* gimplify.cc (recalculate_side_effects): Do nothing for SSA_NAMEs.

	* gcc.c-torture/compile/pr113228.c: New test.
2024-01-08 13:59:15 +01:00
Jakub Jelinek
efef8d7ff4 lower-bitint: Fix up lowering of huge _BitInt 0 PHI args [PR113120]
The PHI argument expansion of INTEGER_CSTs where bitint_min_cst_precision
returns significantly smaller precision than the PHI result precision is
optimized by loading the much smaller constant (if any) from memory and
then either setting the remaining limbs to {} or calling memset with -1.
The case where no constant is loaded (i.e. c == NULL) is when the
INTEGER_CST is 0 or all_ones - in that case we can just set all the limbs
to {} or call memset with -1 on everything.
While for the all ones extension case that is what the code was already
doing, I missed one spot in the zero extension case, where constricting
the offset of the MEM_REF lhs of the = {} store it was using unconditionally
the byte size of c, which obviously doesn't work if c is NULL.  In that case
we want to use zero offset.

2024-01-08  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/113120
	* gimple-lower-bitint.cc (gimple_lower_bitint): Fix handling of very
	large _BitInt zero INTEGER_CST PHI argument.

	* gcc.dg/bitint-62.c: New test.
2024-01-08 13:58:28 +01:00
Jakub Jelinek
7590d975ec lower-bitint: Punt .*_OVERFLOW optimization if cast from IMAGPART_EXPR appears before REALPART_EXPR [PR113119]
_BitInt lowering for .{ADD,SUB,MUL}_OVERFLOW calls which have both
REALPART_EXPR and IMAGPART_EXPR used and have a cast from the IMAGPART_EXPR
to a boolean or normal integral type lowers them at the point of
the REALPART_EXPR statement (which is especially needed if the lhs of
the call is complex with large/huge _BitInt element type); we emit the
stmt to set the lhs of the cast at the same spot as well.
Normally, the lowering of __builtin_{add,sub,mul}_overflow arranges
the REALPART_EXPR to come before IMAGPART_EXPR, followed by cast from that,
but as the testcase shows, a redundant __builtin_*_overflow call and VN
can reorder those and we then ICE because the def-stmt of the former cast
from IMAGPART_EXPR may appear after its uses.
We already check that all of REALPART_EXPR, IMAGPART_EXPR and the cast
from the latter appear in the same bb as the .{ADD,SUB,MUL}_OVERFLOW call
in the optimization, the following patch just extends it to make sure
cast appears after REALPART_EXPR; if not, we punt on the optimization and
expand it as a store of a complex _BitInt on the location of the ifn call.
Only the testcase in the testsuite is changed by the patch, all other
__builtin_*_overflow* calls in the bitint* tests (and there are quite a few)
have REALPART_EXPR first.

2024-01-08  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/113119
	* gimple-lower-bitint.cc (optimizable_arith_overflow): Punt if
	both REALPART_EXPR and cast from IMAGPART_EXPR appear, but cast
	is before REALPART_EXPR.

	* gcc.dg/bitint-61.c: New test.
2024-01-08 13:57:26 +01:00
Georg-Johann Lay
c131b1d5da AVR: PR target/112952: Fix attribute "address", "io" and "io_low"
so they work with all combinations of -f[no-]data-sections -f[no-]common.
The patch also improves some diagnostics and adds additional checks, for
example these attributes must only be applied to variables in static storage.

gcc/
	PR target/112952
	* config/avr/avr.cc (avr_handle_addr_attribute): Also print valid
	range when diagnosing attribute "io" and "io_low" are out of range.
	(avr_eval_addr_attrib): Don't ICE on empty address at that place.
	(avr_insert_attributes): Reject if attribute "address", "io" or "io_low"
	in contexts other than static storage.
	(avr_asm_output_aligned_decl_common): Move output of decls with
	attribute "address", "io", and "io_low" to...
	(avr_output_addr_attrib): ...this new function.
	(avr_asm_asm_output_aligned_bss): Remove output for decls with
	attribute "address", "io", and "io_low".
	(avr_encode_section_info): Rectify handling of decls with attribute
	"address", "io", and "io_low".

gcc/testsuite/
	PR target/112952
	* gcc.target/avr/attribute-io.h: New file.
	* gcc.target/avr/pr112952-0.c: New test.
	* gcc.target/avr/pr112952-1.c: New test.
	* gcc.target/avr/pr112952-2.c: New test.
	* gcc.target/avr/pr112952-3.c: New test.
2024-01-08 12:30:22 +01:00
Thomas Schwinge
cde6f1085b libgrust: 'AM_ENABLE_MULTILIB' only for target builds [PR113056]
..., but not for host builds, which don't need it, and it may cause the build
to fail.

Use what appears to be the standard pattern for that (see
'libbacktrace/configure.ac', 'zlib/configure.ac').

	PR rust/113056
	libgrust/
	* configure.ac: 'AM_ENABLE_MULTILIB' only for target builds.
	* configure: Regenerate.
2024-01-08 12:01:05 +01:00
Andrew Stubbs
78dff4c25c amdgcn: Match new XNACK defaults in mkoffload
The patch that disabled XNACK by default for ISA other than gfx90a was missing
the matching mkoffload changes.  This patch should fix offload.

gcc/ChangeLog:

	* config/gcn/mkoffload.cc (TEST_XNACK_UNSET): New.
	(elf_flags): Remove XNACK from the default value.
	(main): Set a default XNACK according to the arch.
2024-01-08 09:57:44 +00:00
Andrew Stubbs
c5c3aab381 amdgcn: Don't double-count AVGPRs
CDNA2 devices have VGPRs and AVGPRs combined into a single hardware register
file (they're seperate in CDNA1).  I originally thought they were counted
separately in the vgpr_count and agpr_count metadata fields, and therefore
mkoffload had to account for this when passing the values to libgomp.  However,
that wasn't the case, and this code should have been removed when I corrected
the calculations in gcn.cc.  Fixing the error now.

gcc/ChangeLog:

	* config/gcn/mkoffload.cc (isa_has_combined_avgprs): Delete.
	(process_asm): Don't count avgprs.
2024-01-08 09:57:09 +00:00
Kito Cheng
4d31d66062 RISC-V: Fix testsuite
Don't use assert, it not work well with multilib testing.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/partial/single_rgroup-3.h: Use
	check + abort rather than assert.
2024-01-08 14:10:23 +08:00
Hongyu Wang
79b5fd013a i386: [APX] Add missing document for APX
The supported sub-features for APX was missing in option document and
target attribute section. Add those missing ones.

gcc/ChangeLog:

	* config/i386/i386.opt: Add supported sub-features.
	* doc/extend.texi: Add description for target attribute.
2024-01-08 11:02:43 +08:00
Jonathan Wakely
cddaff46ad libstdc++: Implement P2918R0 "Runtime format strings II" for C++26
This adds std::runtime_format for C++26. These new overloaded functions
enhance the std::format API so that it isn't necessary to use the less
ergonomic std::vformat and std::make_format_args (which are meant to be
implementation details). This was approved in Kona 2023 for C++26.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::_Runtime_format_string): Define
	new class template.
	(basic_format_string): Add non-consteval constructor for runtime
	format strings.
	(runtime_format): Define new function for C++26.
	* testsuite/std/format/runtime_format.cc: New test.
2024-01-08 01:14:51 +00:00
Jonathan Wakely
2a8ee2592e libstdc++: Implement P2905R2 "Runtime format strings" for C++20
This change makes std::make_format_args refuse to create dangling
references to temporaries. This makes the std::vformat API safer. This
was approved in Kona 2023 as a DR for C++20 so the change is implemented
unconditionally.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono): Always use
	lvalue arguments to make_format_args.
	* include/std/format (make_format_args): Change parameter pack
	from forwarding references to lvalue references. Remove use of
	remove_reference_t which is now unnecessary.
	(format_to, formatted_size): Remove incorrect forwarding of
	arguments.
	* include/std/ostream (print): Remove forwarding of arguments.
	* include/std/print (print): Likewise.
	* testsuite/20_util/duration/io.cc: Use lvalues as arguments to
	make_format_args.
	* testsuite/std/format/arguments/args.cc: Likewise.
	* testsuite/std/format/arguments/lwg3810.cc: Likewise.
	* testsuite/std/format/functions/format.cc: Likewise.
	* testsuite/std/format/functions/vformat_to.cc: Likewise.
	* testsuite/std/format/string.cc: Likewise.
	* testsuite/std/time/day/io.cc: Likewise.
	* testsuite/std/time/month/io.cc: Likewise.
	* testsuite/std/time/weekday/io.cc: Likewise.
	* testsuite/std/time/year/io.cc: Likewise.
	* testsuite/std/time/year_month_day/io.cc: Likewise.
	* testsuite/std/format/arguments/args_neg.cc: New test.
2024-01-08 01:14:50 +00:00
Jonathan Wakely
37a4c5c23a libstdc++: Add Unicode-aware width estimation for std::format
This implements the requirements in the following proposals, which
dictate how std::format deals with non-ASCII strings:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1868r1.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2572r1.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2675r1.pdf

There are two parts to this. The width estimation for strings must only
count the width of the first character in an extended grapheme cluster.
That requires implementing the algorithm for detecting cluster breaks,
which requires a number of lookup tables of the grapheme cluster break
properties (and Indic_Conjunct_Break and Extended_Pictographic
properties) of every code point. Additionally, some characters have a
field width of 2, which requires another lookup table of field widths
for every code point.  The tables added in this commit do not contain
entries for every code point from 0 to 0x10FFFF as that would be very
inefficient and use too much memory. Instead the tables only contain the
code points that form an "edge" for a property, omitting all the code
points that have the same property as the preceding one. We can use a
binary search to find the closest code point in the table that is not
greater than the one we're looking for.

The tables are generated by a new Python script added to the
contrib/unicode directory, and a new data file downloaded from the
Unicode Consortium website.

The rules for extended grapheme cluster breaking are implemented for the
latest Unicode standard, version 15.1.0.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/unicode.h: New file.
	* include/bits/unicode-data.h: New file.
	* include/std/format: Include <bits/unicode.h>.
	(__literal_encoding_is_utf8): Move to <bits/unicode.h>.
	(_Spec::_M_fill): Change type to char32_t.
	(_Spec::_M_parse_fill_and_align): Read a Unicode scalar value
	instead of a single character.
	(__write_padded): Change __fill_char parameter to char32_t and
	encode it into the output.
	(__formatter_str::format): Use new __unicode::__field_width and
	__unicode::__truncate functions.
	* include/std/ostream: Adjust namespace qualification for
	__literal_encoding_is_utf8.
	* include/std/print: Likewise.
	* src/c++23/print.cc: Add [[unlikely]] attribute to error path.
	* testsuite/ext/unicode/view.cc: New test.
	* testsuite/std/format/functions/format.cc: Add missing examples
	from the standard demonstrating alignment with non-ASCII
	characters. Add examples checking correct handling of extended
	grapheme clusters.

contrib/ChangeLog:

	* unicode/README: Add notes about generating libstdc++ tables.
	* unicode/GraphemeBreakProperty.txt: New file.
	* unicode/emoji-data.txt: New file.
	* unicode/gen_libstdcxx_unicode_data.py: New file.
2024-01-08 01:14:50 +00:00
Jonathan Wakely
74a0dab182 libstdc++: Implement P2909R4 ("Dude, where's my char?") for C++20
This change ensures that char and wchar_t arguments are formatted
consistently when using integer presentation types. This avoids
non-portable std::format output that depends on whether char and wchar_t
happen to be signed or unsigned on the target. Formatting '\xff' as an
integer will now always format 255 and not sometimes -1. This was
approved in Kona 2023 as a DR for C++20 so the change is implemented
unconditionally.

Also make character formatters check for _Pres_c explicitly and call
_M_format_character directly. This avoid the overhead of calling format
and _S_to_character and then calling _M_format_character anyway.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (format_uchar): Define.
	* include/bits/version.h: Regenerate.
	* include/std/format (formatter<C, C>::format): Check for
	_Pres_c and call _M_format_character directly. Cast C to its
	unsigned equivalent for formatting as an integer.
	(formatter<char, wchar_t>::format): Likewise.
	(basic_format_arg(T&)): Store char arguments as unsigned char
	for formatting to a wide string.
	* testsuite/std/format/functions/format.cc: Adjust test. Check
	formatting of
2024-01-08 01:14:50 +00:00
Feng Wang
c97436f84c RISC-V: Fix avl-type operand index error for ZVBC
This patch fix the rtl-checking error for crypto vector. The root
cause is the avl-type index of zvbc ins is error,it should be operand[8]
not operand[5].
gcc/ChangeLog:

	* config/riscv/vector.md: Modify avl_type operand index of zvbc ins.
2024-01-08 00:55:57 +00:00
GCC Administrator
59e0c2180d Daily bump. 2024-01-08 00:16:43 +00:00
Georg-Johann Lay
a6b8d8f919 AVR: Fix some test options. Skip tests with address-space on Reduced Tiny.
gcc/testsuite/
	* gcc.target/avr/lra-cpymem_qi.c: Remove duplicate -mmcu=.
	* gcc.target/avr/lra-elim.c: Same.
	* gcc.target/avr/pr112830.c: Skip for Reduced Tiny.
	* gcc.target/avr/pr46779-1.c: Same.
	* gcc.target/avr/pr46779-2.c: Same.
	* gcc.target/avr/pr86869.c: Skip for Reduced Tiny and add -std=gnu99
	for GNU-C due to address spaces.
	* gcc.target/avr/pr89270.c: Same.
	* gcc.target/avr/torture/builtins-2-flash.c: Only test address
	space __flash1 if we have it.
	* gcc.target/avr/torture/addr-space-1-1.c: Same.
	* gcc.target/avr/torture/addr-space-2-1.c: Same.
2024-01-07 21:13:03 +01:00
Jerry DeLisle
add995ec11 libgfortran: Emit a space at beginning of internal unit NML.
PR libgfortran/113223

libgfortran/ChangeLog:

	* io/write.c (namelist_write): If internal_unit precede with space.

gcc/testsuite/ChangeLog:

	* gfortran.dg/dtio_25.f90: Update.
	* gfortran.dg/namelist_57.f90: Update.
	* gfortran.dg/namelist_65.f90: Update.
2024-01-07 10:32:04 -08:00
Roger Sayle
0a8aba760f i386: PR target/113231: Improved costs in Scalar-To-Vector (STV) pass.
This patch improves the cost/gain calculation used during the i386 backend's
SImode/DImode scalar-to-vector (STV) conversion pass.  The current code
handles loads and stores, but doesn't consider that converting other
scalar operations with a memory destination, requires an explicit load
before and an explicit store after the vector equivalent.

To ease the review, the significant change looks like:

         /* For operations on memory operands, include the overhead
            of explicit load and store instructions.  */
         if (MEM_P (dst))
           igain += !optimize_insn_for_size_p ()
                    ? -COSTS_N_BYTES (8);
                    : (m * (ix86_cost->int_load[2]
                            + ix86_cost->int_store[2])
                       - (ix86_cost->sse_load[sse_cost_idx] +
                          ix86_cost->sse_store[sse_cost_idx]));

however the patch itself is complicated by a change in indentation
which leads to a number of lines with only whitespace changes.
For architectures where integer load/store costs are the same as
vector load/store costs, there should be no change without -Os/-Oz.

2024-01-07  Roger Sayle  <roger@nextmovesoftware.com>
	    Uros Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
	PR target/113231
	* config/i386/i386-features.cc (compute_convert_gain): Include
	the overhead of explicit load and store (movd) instructions when
	converting non-store scalar operations with memory destinations.
	Various indentation whitespace fixes.

gcc/testsuite/ChangeLog
	PR target/113231
	* gcc.target/i386/pr113231.c: New test case.
2024-01-07 17:42:00 +00:00
Tamar Christina
d9dd04f9f1 arm: Add Advanced SIMD cbranch implementation
This adds an implementation for conditional branch optab for AArch32.

For e.g.

void f1 ()
{
  for (int i = 0; i < N; i++)
    {
      b[i] += a[i];
      if (a[i] > 0)
	break;
    }
}

For 128-bit vectors we generate:

        vcgt.s32        q8, q9, #0
        vpmax.u32       d7, d16, d17
        vpmax.u32       d7, d7, d7
        vmov    r3, s14 @ int
        cmp     r3, #0

and of 64-bit vector we can omit one vpmax as we still need to compress to
32-bits.

gcc/ChangeLog:

	* config/arm/neon.md (cbranch<mode>4): New.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-early-break_2.c: Skip Arm.
	* gcc.dg/vect/vect-early-break_7.c: Likewise.
	* gcc.dg/vect/vect-early-break_75.c: Likewise.
	* gcc.dg/vect/vect-early-break_77.c: Likewise.
	* gcc.dg/vect/vect-early-break_82.c: Likewise.
	* gcc.dg/vect/vect-early-break_88.c: Likewise.
	* lib/target-supports.exp (add_options_for_vect_early_break,
	check_effective_target_vect_early_break_hw,
	check_effective_target_vect_early_break): Support AArch32.
	* gcc.target/arm/vect-early-break-cbranch.c: New test.
2024-01-07 17:32:13 +00:00
Jeff Law
66d82874d2 Fix typo in last change
gcc/testsuite
	* gcc.dg/tree-ssa/phi-opt-25b.c: Remove extraneous "short".
2024-01-07 09:52:44 -07:00
Georg-Johann Lay
1c76501655 testsuite/52641: Fix fallout from sloppy tests.
gcc/testsuite/
	PR testsuite/52641
	* gcc.dg/torture/pr110838.c: Use proper shift offset to get MSB or int.
	* gcc.dg/torture/pr112282.c: Use at least 32 bits for :20 bit-fields.
	* gcc.dg/tree-ssa/bitcmp-5.c: Use integral type with 32 bits or more.
	* gcc.dg/tree-ssa/bitcmp-6.c: Same.
	* gcc.dg/tree-ssa/cltz-complement-max.c: Same.
	* gcc.dg/tree-ssa/cltz-max.c: Same.
	* gcc.dg/tree-ssa/if-to-switch-8.c: Use literals that fit int.
	* gcc.dg/tree-ssa/if-to-switch-9.c [avr]: Set case-values-threshold=3.
	* gcc.dg/tree-ssa/negneg-3.c: Discriminate [not] large_double.
	* gcc.dg/tree-ssa/phi-opt-25b.c: Use types of correct widths for
	__builtin_bswapN.
	* gcc.dg/tree-ssa/pr55177-1.c: Same.
	* gcc.dg/tree-ssa/popcount-max.c: Use int32_t where required.
	* gcc.dg/tree-ssa/pr111583-1.c: Use intptr_t as needed.
	* gcc.dg/tree-ssa/pr111583-2.c: Same.
2024-01-07 16:53:21 +01:00
Georg-Johann Lay
7d60b1b785 testsuite/52641: Fix fallout from sloppy tests.
gcc/testsuite/
	PR testsuite/52641
	* gcc.dg/memchr-3.c [avr]: Anticipate -Wbuiltin-declaration-mismatch.
	* gcc.dg/pr103207.c: Use __INT32_TYPE__ instead of int.
	* gcc.dg/pr103451.c [void* != long]: Anticipate -Wpointer-to-int-cast.
	* gcc.dg/pr110496.c [void* != long]: Anticipate -Wint-to-pointer-cast.
	* gcc.dg/pr109977.c: Use __SIZEOF_DOUBLE__ instead of 8.
	* gcc.dg/pr110506-2.c: Use __UINT32_TYPE__ for uint32_t.
	* gcc.dg/pr110582.c: Require int32plus.
	* gcc.dg/pr111039.c: [sizeof(int) < 4]: Use __INT32_TYPE__.
	* gcc.dg/pr111599.c: Same.
	* gcc.dg/builtin-dynamic-object-size-0.c: Require size20plus.
	* gcc.dg/builtin-object-size-1.c [avr]: Skip tests with strndup.
	* gcc.dg/builtin-object-size-2.c: Same.
	* gcc.dg/builtin-object-size-3.c: Same.
	* gcc.dg/builtin-object-size-4.c: Same.
	* gcc.dg/pr111070.c: Use __UINTPTR_TYPE__ instead of unsigned long.
	* gcc.dg/debug/btf/btf-pr106773.c: Same.
	* gcc.dg/debug/btf/btf-bitfields-2.c: [sizeof(int) < 4]: Use
	__UINT32_TYPE__.
2024-01-07 13:43:34 +01:00
Georg-Johann Lay
c2e66755b6 testsuite/52641: Fix sloppy tests that did not care for sizeof(int)=2 etc.
gcc/testsuite/
	PR testsuite/52641
	* gcc.c-torture/compile/attr-complex-method-2.c [target=avr]: Check
	for "divsc3" as double = float per default.
	* gcc.c-torture/compile/pr106537-1.c: Use __INTPTR_TYPE__ instead of
	hard-coded "long".
	* gcc.c-torture/compile/pr106537-2.c: Same.
	* gcc.c-torture/compile/pr106537-3.c: Same.
	* gcc.c-torture/execute/20230630-3.c: Use __INT32_TYPE__ for bit-field
	wider than 16 bits.
	* gcc.c-torture/execute/20230630-4.c: Same.
	* gcc.c-torture/execute/pr109938.c: Require int32plus.
	* gcc.c-torture/execute/pr109986.c: Same.
	* gcc.dg/fold-ior-4.c: Same.
	* gcc.dg/fold-ior-5.c: Same
	* gcc.dg/fold-parity-5.c: Same.
	* gcc.dg/fold-popcount-5.c: Same.
	* gcc.dg/builtin-bswap-13.c [sizeof(int) < 4]: Use __INT32_TYPE__
	instead of int.
	* gcc.dg/builtin-bswap-14.c: Use __INT32_TYPE__ instead of int where
	required by code.
	* gcc.dg/c23-constexpr-9.c: Require large_double.
	* gcc.dg/c23-nullptr-1.c [target=avr]: xfail.
	* gcc.dg/loop-unswitch-10.c: Require size32plus.
	* gcc.dg/loop-unswitch-14.c: Same.
	* gcc.dg/loop-unswitch-11.c: Require int32.
	* gcc.dg/pr101836.c: Use __SIZEOF_INT instead of hard-coded 4.
	* gcc.dg/pr101836_1.c: Same.
	* gcc.dg/pr101836_2.c: Same.
	* gcc.dg/pr101836_3.c: Same.
2024-01-07 13:43:33 +01:00
Nathaniel Shead
a71c3977d2 c++: Fix ICE when writing nontrivial variable initializers
The attached testcase Patrick found in PR c++/112899 ICEs because it is
attempting to write a variable initializer that is no longer in the
static_aggregates map.

The issue is that, for non-header modules, the loop in
c_parse_final_cleanups prunes the static_aggregates list, which means
that by the time we get to emitting module information those
initialisers have been lost.

However, we don't actually need to write non-trivial initialisers for
non-header modules, because they've already been emitted as part of the
module TU itself.  Instead let's just only write the initializers from
header modules (which skipped writing them in c_parse_final_cleanups).

gcc/cp/ChangeLog:

	* module.cc (trees_out::write_var_def): Only write initializers
	in header modules.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/init-5_a.C: New test.
	* g++.dg/modules/init-5_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-07 21:07:29 +11:00
Nathaniel Shead
63b531e6f8 c++: Export usings referring to global module fragment [PR109679]
This patch stops 'add_binding_entity' from ignoring all names in the
global module fragment, since they should still be exported if named
in an exported using-declaration.

	PR c++/109679

gcc/cp/ChangeLog:

	* module.cc (depset:#️⃣:add_binding_entity): Don't skip names
	in the GMF if they've been exported with a using declaration.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/using-11.h: New test.
	* g++.dg/modules/using-11_a.C: New test.
	* g++.dg/modules/using-11_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-07 21:05:14 +11:00
Nathaniel Shead
7f24446a3c c++: Follow module grammar more closely [PR110808]
This patch cleans up the parsing of module-declarations and
import-declarations to more closely follow the grammar defined by the
standard.

For instance, currently we allow declarations like 'import A:B', even
from an unrelated source file (not part of module A), which causes
errors in merging declarations. However, the syntax in [module.import]
doesn't even allow this form of import, so this patch prevents this from
parsing at all and avoids the error that way.

Additionally, we sometimes allow statements like 'import :X' or
'module :X' even when not in a named module, and this causes segfaults,
so we disallow this too.

	PR c++/110808

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_module_name): Rewrite to handle
	module-names and module-partitions independently.
	(cp_parser_module_partition): New function.
	(cp_parser_module_declaration): Parse module partitions
	explicitly. Don't change state if parsing module decl failed.
	(cp_parser_import_declaration): Handle different kinds of
	import-declarations locally.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/part-hdr-1_c.C: Fix syntax.
	* g++.dg/modules/part-mac-1_c.C: Likewise.
	* g++.dg/modules/mod-invalid-1.C: New test.
	* g++.dg/modules/part-8_a.C: New test.
	* g++.dg/modules/part-8_b.C: New test.
	* g++.dg/modules/part-8_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-01-07 21:04:17 +11:00
Juzhe-Zhong
e74c37aab5 RISC-V: Use MAX instead of std::max [VSETVL PASS]
Obvious fix, Committed.

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: replace std::max by MAX.
2024-01-07 09:26:36 +08:00
Jonathan Wakely
8c5d00f829 libstdc++: Avoid conflicting declaration in eh_call.cc [PR112997]
r14-1527-g2415024e0f81f8 changed the parameter of the
__cxa_call_terminate definition, but there's also a declaration in
unwind-cxx.h which should have been changed too.

libstdc++-v3/ChangeLog:

	PR libstdc++/112997
	* libsupc++/unwind-cxx.h (__cxa_call_terminate): Change first
	parameter to void*.
2024-01-07 00:58:46 +00:00