]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
8 months agotestsuite, jit, Darwin: Handle Mach-O in assembler tests.
Iain Sandoe [Sat, 13 Jan 2024 13:40:51 +0000 (13:40 +0000)] 
testsuite, jit, Darwin: Handle Mach-O in assembler tests.

Several of the jit tests check for assembler-specific output
which differs on Mach-O from ELF.

This patch uses the facility to make the scans target-dependent
and adds handling for darwin.

gcc/testsuite/ChangeLog:

* jit.dg/test-always_inline-attribute.c: Handle Darwin in
jit-verify-assembler-output.
* jit.dg/test-noinline-attribute.c: Likewise.
* jit.dg/test-setting-alignment.c: Likewise.
* jit.dg/test-used-attribute.c: Likewise.
* jit.dg/test-variable-attribute.c: Likewise.
* jit.dg/test-weak-attribute.c: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 months agotestsuite, jit: Allow for target-specific assembler scans.
Iain Sandoe [Sat, 13 Jan 2024 13:30:08 +0000 (13:30 +0000)] 
testsuite, jit: Allow for target-specific assembler scans.

If we want to support multiple object formats and to allow for
scan-assembler tests, we need to make it possible to adjust the
tests on a per-target basis.

This adds similar mechamisms to jit-verify-assembler-output{,-not}
to those used for the general scan-assembler dg directives.

As an aside; it would, perhaps, be possible to integrate this more
with scanasm.exp (which would also give access to function body
scanning) but I did not attempt that for this patch.

After this, we can accept things like:
... { jit-verify-assembler-output-not "......" { target { ! *-*-darwin* } } } }
or
... { jit-verify-assembler-output "......" { target *-*-darwin* } } }

gcc/testsuite/ChangeLog:

* jit.dg/jit.exp: Accept target clauses in jit-verify-assembler
handling.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 months agotestsuite, jit: Handle whitespace in test-link-section-assembler.c.
Iain Sandoe [Sat, 13 Jan 2024 12:49:28 +0000 (12:49 +0000)] 
testsuite, jit: Handle whitespace in test-link-section-assembler.c.

Darwin has a different .section directive that has more fields and
uses different whitespace.  Amend the whitespace in the scan-asm to
be more flexible.

gcc/testsuite/ChangeLog:

* jit.dg/test-link-section-assembler.c: Accept any whitespace
between the .section directive and its arguments.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 months agotestsuite, jit: test-alias-attribute.c requires alias support.
Iain Sandoe [Sat, 13 Jan 2024 12:36:23 +0000 (12:36 +0000)] 
testsuite, jit: test-alias-attribute.c requires alias support.

Add a dg-require-alias to cover this.

gcc/testsuite/ChangeLog:

* jit.dg/test-alias-attribute.c: Require target alias
support.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 months agoDarwin: Fix constant CFString code-gen [PR105522].
Iain Sandoe [Sat, 6 Jan 2024 10:52:38 +0000 (10:52 +0000)] 
Darwin: Fix constant CFString code-gen [PR105522].

Although this only fires for one of the Darwin sub-ports, it is latent
elsewhere, it is also a regression c.f. the Darwin system compiler.

In the code we imported from an earlier branch, CFString objects (which
are constant aggregates) are constructed as CONST_DECLs.  Although our
current documentation suggests that these are reserved for enumeration
values, in fact they are used elsewhere in the compiler for constants.
This includes Objective-C where they are used to form NSString constants.

In the particular case, we take the address of the constant and that
triggers varasm.cc:decode_addr_constant, which does not currently support
CONST_DECL.

If there is a general intent to allow/encourage wider use of CONST_DECL,
then we should fix decode_addr_constant to look through these and evaluate
the initializer (a two-line patch, but I'm not suggesting it for stage-4).

We also need to update the GCC internals documentation to allow for the
additional uses.

This patch is Darwin-local and fixes the problem by making the CFString
constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
to back-port this to the open branches once it has baked a while on trunk.

Since, for Darwin, the Objective-C default is to construct constant
NSString objects as CFStrings; this will also cover the majority of cases
there (this patch does not make any changes to Objective-C NSStrings).

PR target/105522

gcc/ChangeLog:

* config/darwin.cc (machopic_select_section): Handle C and C++
CFStrings.
(darwin_rename_builtins): Move this out of the CFString code.
(darwin_libc_has_function): Likewise.
(darwin_build_constant_cfstring): Create an anonymous var to
hold each CFString.
* config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
CFstrings.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 months agoFix compare-debug bootstrap failure [PR113445]
Maxim Kuvyrkov [Thu, 18 Jan 2024 13:45:27 +0000 (14:45 +0100)] 
Fix compare-debug bootstrap failure [PR113445]

... caused by scheduler fix for PR96388 and PR111554.

This patch adjusts decision sched-deps.cc:find_inc() to use
length of dependency lists sans any DEBUG_INSN instructions.

gcc/ChangeLog

2024-01-18  Maxim Kuvyrkov  <maxim.kuvyrkov@linaro.org>

PR bootstrap/113445
* haifa-sched.cc (dep_list_size): Make global.
* sched-deps.cc (find_inc): Use instead of sd_lists_size().
* sched-int.h (dep_list_size): Declare.

gcc/testsuite/ChangeLog

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

PR bootstrap/113445
* gcc.dg/pr113445.c: New test.

8 months agosra: Disqualify bases of operands of asm gotos
Martin Jambor [Thu, 18 Jan 2024 13:24:15 +0000 (14:24 +0100)] 
sra: Disqualify bases of operands of asm gotos

PR 110422 shows that SRA can ICE assuming there is a single edge
outgoing from a block terminated with an asm goto.  We need that for
BB-terminating statements so that any adjustments they make to the
aggregates can be copied over to their replacements.  Because we can't
have that after ASM gotos, we need to punt.

gcc/ChangeLog:

2024-01-17  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/110422
* tree-sra.cc (scan_function): Disqualify bases of operands of asm
gotos.

gcc/testsuite/ChangeLog:

2024-01-17  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/110422
* gcc.dg/torture/pr110422.c: New test.

8 months agotree-optimization/113475 - fix memory leak in phi_analyzer
Richard Biener [Thu, 18 Jan 2024 12:23:27 +0000 (13:23 +0100)] 
tree-optimization/113475 - fix memory leak in phi_analyzer

phi_analyzer leaks all phi_group objects it allocates.  The following
fixes this by maintaining a vector of allocated objects and release
them when destroying the phi_analyzer object.

PR tree-optimization/113475
* gimple-range-phi.h (phi_analyzer::m_phi_groups): New.
* gimple-range-phi.cc (phi_analyzer::phi_analyzer): Initialize.
(phi_analyzer::~phi_analyzer): Deallocate and free collected
phi_grous.
(phi_analyzer::process_phi): Record allocated phi_groups.

8 months agoFix memory leak in vectorizable_store
Richard Biener [Thu, 18 Jan 2024 12:04:17 +0000 (13:04 +0100)] 
Fix memory leak in vectorizable_store

The following fixes a memory leak in vectorizable_store which happens
because the functions populating gvec_oprnds[i] will call .create ()
on the incoming vector, leaking what we've previously allocated.

* tree-vect-stmts.cc (vectorizable_store): Do not allocate
storage for gvec_oprnds elements.

8 months agoPR modula2/111956 Many powerpc platforms do _not_ have support for IEEE754
Gaius Mulley [Thu, 18 Jan 2024 13:06:30 +0000 (13:06 +0000)] 
PR modula2/111956 Many powerpc platforms do _not_ have support for IEEE754

This patch corrects commit
r14-4149-g81d5ca0b9b8431f1bd7a5ec8a2c94f04bb0cf032 which assummed
all powerpc platforms would have IEEE754 long double.  The patch
ensures that cc1gm2 obtains the default IEEE754 long double availability
from the configure generated tm_defines.  The user command
line switches -mabi=ibmlongdouble and -mabi=ieeelongdouble are implemented
to override the configuration defaults.

Bootstrapped on power8 and power9 machines.

gcc/m2/ChangeLog:

PR modula2/111956
* Make-lang.in (host_mc_longreal): Remove.
* configure: Regenerate.
* configure.ac (M2C_LONGREAL_FLOAT128): Remove.
(M2C_LONGREAL_PPC64LE): Remove.
* gm2-compiler/M2Options.def (SetIBMLongDouble): New procedure.
(GetIBMLongDouble): New procedure function.
(SetIEEELongDouble): New procedure.
(GetIEEELongDouble): New procedure function.
* gm2-compiler/M2Options.mod (SetIBMLongDouble): New procedure.
(GetIBMLongDouble): New procedure function.
(SetIEEELongDouble): New procedure.
(GetIEEELongDouble): New procedure function.
(InitializeLongDoubleFlags): New procedure called during
module block initialization.
* gm2-gcc/m2configure.cc: Remove duplicate includes.
(m2configure_M2CLongRealFloat128): Remove.
(m2configure_M2CLongRealIBM128): Remove.
(m2configure_M2CLongRealLongDouble): Remove.
(m2configure_M2CLongRealLongDoublePPC64LE): Remove.
(m2configure_TargetIEEEQuadDefault): New function.
* gm2-gcc/m2configure.def (M2CLongRealFloat128): Remove.
(M2CLongRealIBM128): Remove.
(M2CLongRealLongDouble): Remove.
(M2CLongRealLongDoublePPC64LE): Remove.
(TargetIEEEQuadDefault): New function.
* gm2-gcc/m2configure.h (m2configure_M2CLongRealFloat128): Remove.
(m2configure_M2CLongRealIBM128): Remove.
(m2configure_M2CLongRealLongDouble): Remove.
(m2configure_M2CLongRealLongDoublePPC64LE): Remove.
(m2configure_TargetIEEEQuadDefault): New function.
* gm2-gcc/m2options.h (M2Options_SetIBMLongDouble): New prototype.
(M2Options_GetIBMLongDouble): New prototype.
(M2Options_SetIEEELongDouble): New prototype.
(M2Options_GetIEEELongDouble): New prototype.
* gm2-gcc/m2type.cc (build_m2_long_real_node): Re-implement using
results of M2Options_GetIBMLongDouble and M2Options_GetIEEELongDouble.
* gm2-lang.cc (gm2_langhook_handle_option): Add case
OPT_mabi_ibmlongdouble and call M2Options_SetIBMLongDouble.
Add case OPT_mabi_ieeelongdouble and call M2Options_SetIEEELongDouble.
* gm2config.aci.in: Regenerate.
* gm2spec.cc (lang_specific_driver): Remove block defined by
M2C_LONGREAL_PPC64LE.
Remove case OPT_mabi_ibmlongdouble.
Remove case OPT_mabi_ieeelongdouble.

libgm2/ChangeLog:

PR modula2/111956
* Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* Makefile.in: Regenerate.
* libm2cor/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2pim/Makefile.in: Regenerate.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
8 months agohwasan: Check if Intel LAM_U57 is enabled
H.J. Lu [Tue, 9 Jan 2024 16:46:59 +0000 (08:46 -0800)] 
hwasan: Check if Intel LAM_U57 is enabled

When -fsanitize=hwaddress is used, libhwasan will try to enable LAM_U57
in the startup code.  Update the target check to enable hwaddress tests
if LAM_U57 is enabled.  Also compile hwaddress tests with -mlam=u57 on
x86-64 since hwasan requires LAM_U57 on x86-64.

* lib/hwasan-dg.exp (check_effective_target_hwaddress_exec):
Return 1 if Intel LAM_U57 is enabled.
(hwasan_init): Add -mlam=u57 on x86-64.

8 months agolibstdc++: Avoid -Wmaybe-uninitialized warnings in text_encoding.cc
Jonathan Wakely [Thu, 18 Jan 2024 12:40:52 +0000 (12:40 +0000)] 
libstdc++: Avoid -Wmaybe-uninitialized warnings in text_encoding.cc

These variables are only read from if we haven't reached the end of
either range, in which case they're guaranteed to be initialized to the
next alphanumeric character. But we can just initialize them to make the
compiler happy.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (__charset_alias_match): Initialize
__var_a and __var_b.

8 months agolibstdc++: Fix std::format test for Solaris [PR113450]
Jonathan Wakely [Wed, 17 Jan 2024 21:40:25 +0000 (21:40 +0000)] 
libstdc++: Fix std::format test for Solaris [PR113450]

When int8_t is a typedef for char (rather than signed char) this test
fails because it tries to format a char, which is treated differently
from formatting other integral types (including signed char).

Use signed char explicitly so the result doesn't depend on the
non-portable definition of int8_t.

libstdc++-v3/ChangeLog:

PR libstdc++/113450
* testsuite/std/format/functions/format.cc: Use signed char
instead of int8_t.

8 months agoFix memory leak in vect_analyze_loop_form
Richard Biener [Thu, 18 Jan 2024 10:22:34 +0000 (11:22 +0100)] 
Fix memory leak in vect_analyze_loop_form

The following fixes a memory leak in vect_analyze_loop_form which fails
to free the loop body it gets.  It also allows more countable exits,
matching what we can handle later, when we decide which exit to use
as main exit.  Finally some no longer applying comments are adjusted.

* tree-vect-loop.cc (vec_init_loop_exit_info): Adjust comment,
prefer all later exits we can handle.
(vect_analyze_loop_form): Free the allocated loop body.
Adjust comments.

8 months agoAVR: Tabify avr-log.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 11:17:58 +0000 (12:17 +0100)] 
AVR: Tabify avr-log.cc.

gcc/
* config/avr/avr-log.cc: Tabify.

8 months agoRISC-V: Support vi variant for vec_cmp
Juzhe-Zhong [Thu, 18 Jan 2024 09:53:24 +0000 (17:53 +0800)] 
RISC-V: Support vi variant for vec_cmp

While running various benchmarks, I notice we miss vi variant support for integer comparison.
That is, we can vectorize code into vadd.vi but we can't vectorize into vmseq.vi.

Consider this following case:

void
foo (int n, int **__restrict a)
{
  int b;
  int c;
  int d;
  for (b = 0; b < n; b++)
    for (long e = 8; e > 0; e--)
      a[b][e] = a[b][e] == 15;
}

Before this patch:

        vsetivli        zero,4,e32,m1,ta,ma
        vmv.v.i v4,15
        vmv.v.i v3,1
        vmv.v.i v2,0
.L3:
        ld      a5,0(a1)
        addi    a4,a5,4
        addi    a5,a5,20
        vle32.v v1,0(a5)
        vle32.v v0,0(a4)
        vmseq.vv        v0,v0,v4

After this patch:

        ld      a5,0(a1)
        addi    a4,a5,4
        addi    a5,a5,20
        vle32.v v1,0(a5)
        vle32.v v0,0(a4)
        vmseq.vi        v0,v0,15

It's the missing feature caused by our some mistakes, support vi variant for vec_cmp like other patterns (add, sub, ..., etc).

Tested with no regression, ok for trunk ?

gcc/ChangeLog:

* config/riscv/autovec.md: Support vi variant.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-1.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-2.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-3.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-4.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-5.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-6.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-7.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-8.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/cmp_vi-9.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/macro.h: New test.

8 months agoAVR: Tabify avr-devices.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 11:10:59 +0000 (12:10 +0100)] 
AVR: Tabify avr-devices.cc.

gcc/
* config/avr/avr-devices.cc: Tabify.

8 months agoAVR: Tabify avr-c.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 11:03:22 +0000 (12:03 +0100)] 
AVR: Tabify avr-c.cc.

gcc/
* config/avr/avr-c.cc: Tabify.

8 months agoAVR: Tabify driver-avr.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 10:56:20 +0000 (11:56 +0100)] 
AVR: Tabify driver-avr.cc.

gcc/
* config/avr/driver-avr.cc: Tabify.

8 months agoAVR: Tabify gen-avr-mmcu-texi.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 10:55:01 +0000 (11:55 +0100)] 
AVR: Tabify gen-avr-mmcu-texi.cc.

gcc/
* config/avr/gen-avr-mmcu-texi.cc: Tabify.

8 months agoAVR: Tabify gen-avr-mmcu-specs.cc.
Georg-Johann Lay [Thu, 18 Jan 2024 10:54:10 +0000 (11:54 +0100)] 
AVR: Tabify gen-avr-mmcu-specs.cc.

gcc/
* config/avr/gen-avr-mmcu-specs.cc: Tabify.

8 months agoriscv: Remove Bool keywords from riscv.opt
Jakub Jelinek [Thu, 18 Jan 2024 09:24:25 +0000 (10:24 +0100)] 
riscv: Remove Bool keywords from riscv.opt

As I wrote recently, Bool is an undocumented unsupported keyword, as
can be seen by
grep Bool doc/options.texi *.awk
The option parsing just parses and ignores all keywords it doesn't handle.
But, because it isn't a supported keyword, I think we shouldn't have it in
*.opt files, because that just means people copy it over to other places
even when it doesn't have any effect.

Tested with a cross to riscv64-linux, none of the generated
options.{h,cc} options-{save,urls}.cc
files change with the patch, only optionlist does (but that is just
used as a source for those files).

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

* config/riscv/riscv.opt (mshorten-memrefs, mrelax, mcsr-check,
minline-strcmp, minline-strncmp, minline-strlen,
-param=riscv-vector-abi): Remove Bool keywords.

8 months agoi386: Add -masm=intel profiling support [PR113122]
Jakub Jelinek [Thu, 18 Jan 2024 09:21:12 +0000 (10:21 +0100)] 
i386: Add -masm=intel profiling support [PR113122]

x86_function_profiler emits assembly directly into file and only emits
AT&T syntax.  The following patch adjusts it to emit MASM syntax
if -masm=intel.
As it doesn't use asm_fprintf, I can't use {|} syntax for the dialects.

I've tested using
for i in -mcmodel=large "-mcmodel=large -fpic" "" -fpic "-m32 -fpic" "-m32"; do
./xgcc -B ./ -c -O2 -fprofile $i -masm=att pr113122.c -o pr113122.o1;
./xgcc -B ./ -c -O2 -fprofile $i -masm=intel pr113122.c -o pr113122.o2;
objdump -dr pr113122.o1 > /tmp/1; objdump -dr pr113122.o2 > /tmp/2;
diff -up /tmp/1 /tmp/2; done
that the emitted sequences are identical after assembly.

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

PR target/113122
* config/i386/i386.cc (x86_function_profiler): Add -masm=intel
support.  Add missing space after , in emitted assembly in some
cases.  Formatting fixes.

* gcc.target/i386/pr113122-1.c: New test.
* gcc.target/i386/pr113122-2.c: New test.
* gcc.target/i386/pr113122-3.c: New test.
* gcc.target/i386/pr113122-4.c: New test.

8 months agoLoongArch: Remove constraint z from movsi_internal
Xi Ruoyao [Thu, 14 Dec 2023 12:19:47 +0000 (20:19 +0800)] 
LoongArch: Remove constraint z from movsi_internal

We don't allow SImode in FCC, so constraint z is never really used
here.

gcc/ChangeLog:

* config/loongarch/loongarch.md (movsi_internal): Remove
constraint z.

8 months agoAVR: Fix typo in device-specs generation. Reuse -m[no-]rodata-in-ram checker.
Georg-Johann Lay [Thu, 18 Jan 2024 08:59:38 +0000 (09:59 +0100)] 
AVR: Fix typo in device-specs generation.  Reuse -m[no-]rodata-in-ram checker.

gcc/
* config/avr/gen-avr-mmcu-specs.cc (diagnose_rodata_in_ram): Fix typo
in the diagnostic, and capitalize the device name.
(print_mcu): Generate specs such that:
<*check_rodata_in_ram>: New.
<*cc1_misc>: Use check_rodata_in_ram instead of cc1_rodata_in_ram.
<*link_misc>: Use check_rodata_in_ram instead of link_rodata_in_ram.
<*cc1_rodata_in_ram, *link_rodata_in_ram>: Remove.

8 months agorust_debug: Cast size_t values to unsigned long before printing.
Arthur Cohen [Wed, 17 Jan 2024 13:15:27 +0000 (14:15 +0100)] 
rust_debug: Cast size_t values to unsigned long before printing.

Using %lu to format size_t values breaks 32 bit targets, and %zu is not
supported by one of the hosts GCC aims to support - HPUX

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
Cast size_t value to unsigned long.
* expand/rust-proc-macro.cc (load_macros): Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.

8 months agotestsuite: Fix up scev-16.c test [PR113446]
Jakub Jelinek [Thu, 18 Jan 2024 07:51:53 +0000 (08:51 +0100)] 
testsuite: Fix up scev-16.c test [PR113446]

This test FAILs on i686-linux or e.g. sparc*-solaris*, because
it uses vect_int effective target outside of */vect/ testsuite.
That is wrong, vect_int assumes the extra added flags by vect.exp
by default, which aren't added in other testsuites.

The following patch fixes that by moving the test into gcc.dg/vect/
and doing small tweaks.

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

PR tree-optimization/112774
PR testsuite/113446
* gcc.dg/tree-ssa/scev-16.c: Move test ...
* gcc.dg/vect/pr112774.c: ... here.  Add PR comment line, use
dg-additional-options instead of dg-options and drop
-fdump-tree-vect-details.

8 months agotestsuite: Fix up gcc.target/i386/sse4_1-stv-1.c test [PR113452]
Jakub Jelinek [Thu, 18 Jan 2024 07:46:15 +0000 (08:46 +0100)] 
testsuite: Fix up gcc.target/i386/sse4_1-stv-1.c test [PR113452]

From what I can see, this test has been written for a backend fix and
assumes the loop isn't vectorized (at least, it wasn't when the test was
added, it contains an early exit), but that is no longer true and because
of the vectorization it now contains an instruction which the test scans
for not being present.

I think we should just disable vectorization here.

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

PR testsuite/113452
* gcc.target/i386/sse4_1-stv-1.c: Add -fno-tree-vectorize to
dg-options.

8 months agoopts: Fix up -ffold-mem-offsets option keywords
Jakub Jelinek [Thu, 18 Jan 2024 07:45:09 +0000 (08:45 +0100)] 
opts: Fix up -ffold-mem-offsets option keywords

While the option was originally meant to be a Target option for a single
target, it is an option for all targets, so should be Common rather than
Target, and because it is an optimization option which could be different
in between different LTO TUs, I've added Optimization keyword too.
From what I can see, Bool is a non-documented non-existing keyword (at
least, grep Bool *.awk shows nothing, so I've dropped that too.  Seems
that the option parsing simply parses and ignores any non-existing keywords.

Guess we should drop the Bool keywords from the gcc/config/riscv/riscv.opt
file eventually, so that people don't copy this around.

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

PR other/113399
* common.opt (ffold-mem-offsets): Remove Target and Bool keywords, add
Common and Optimization.

8 months agotree-optimization/113431 - wrong dependence with invariant load
Richard Biener [Wed, 17 Jan 2024 13:05:42 +0000 (14:05 +0100)] 
tree-optimization/113431 - wrong dependence with invariant load

The vectorizer dependence analysis is confused with invariant loads
when figuring whether the circumstances are so that we preserve
scalar stmt execution order.  The following rectifies this.

PR tree-optimization/113431
* tree-vect-data-refs.cc (vect_preserves_scalar_order_p):
When there is an invariant load we might not preserve
scalar order.

* gcc.dg/vect/pr113431.c: New testcase.

8 months agotree-optimization/113374 - early break vect and virtual operands
Richard Biener [Wed, 17 Jan 2024 12:24:22 +0000 (13:24 +0100)] 
tree-optimization/113374 - early break vect and virtual operands

The following fixes wrong virtual operands being used for peeled
early breaks where we can have different live ones and for multiple
exits it makes sure to update the correct PHI arguments.

I've introduced SET_PHI_ARG_DEF_ON_EDGE so we can avoid using
a wrong edge to compute the PHI arg index from.

I've took the liberty to understand the code again and refactor
and comment it a bit differently.  The main functional change
is that we preserve the live virtual operand on all exits.

PR tree-optimization/113374
* tree-ssa-operands.h (SET_PHI_ARG_DEF_ON_EDGE): New.
* tree-vect-loop.cc (move_early_exit_stmts): Update
virtual LC PHIs.
* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
Refactor.  Preserve virtual LC PHIs on all exits.

* gcc.dg/vect/vect-early-break_106-pr113374.c: New testcase.

8 months agotest regression fix: Add !vect128 for variable length targets of bb-slp-subgroups-3.c
Juzhe-Zhong [Thu, 18 Jan 2024 07:21:10 +0000 (15:21 +0800)] 
test regression fix: Add !vect128 for variable length targets of bb-slp-subgroups-3.c

gcc/testsuite/ChangeLog:

* gcc.dg/vect/bb-slp-subgroups-3.c: Add !vect128.

8 months agoLoongArch: testsuite:Fix fail in gen-vect-{2,25}.c file.
chenxiaolong [Sat, 13 Jan 2024 07:28:34 +0000 (15:28 +0800)] 
LoongArch: testsuite:Fix fail in gen-vect-{2,25}.c file.

1.Added  dg-do compile on LoongArch.
  When binutils does not support vector instruction sets, an error occurs
because the assembler does not recognize vector instructions.

2.Added "-mlsx" option for vectorization on LoongArch.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/gen-vect-2.c: Added detection of compilation
behavior and "-mlsx" option on LoongArch.
* gcc.dg/tree-ssa/gen-vect-25.c: Dito.

8 months agoLoongArch: Assign the '/u' attribute to the mem to which the global offset table...
Lulu Cheng [Fri, 12 Jan 2024 09:06:30 +0000 (17:06 +0800)] 
LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_split_symbol):
Assign the '/u' attribute to the mem.

gcc/testsuite/ChangeLog:

* g++.target/loongarch/got-load.C: New test.

8 months agotest regression fix: Add vect128 for bb-slp-43.c
Juzhe-Zhong [Tue, 16 Jan 2024 08:04:00 +0000 (16:04 +0800)] 
test regression fix: Add vect128 for bb-slp-43.c

gcc/testsuite/ChangeLog:

* gcc.dg/vect/bb-slp-43.c: Add vect128.

8 months agotestsuite, rs6000: Adjust fold-vec-extract-char.p7.c [PR111850]
Kewen Lin [Thu, 18 Jan 2024 06:00:52 +0000 (00:00 -0600)] 
testsuite, rs6000: Adjust fold-vec-extract-char.p7.c [PR111850]

As PR101169 comment #c4 shows, previsouly the addi count
update on fold-vec-extract-char.p7.c covered a sub-optimal
code gen issue.  On trunk, pass fold-mem-offsets helps to
recover the best code sequence, so this patch is to
revert the count back to the original which matches the
optimal addi count.

PR testsuite/111850

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/fold-vec-extract-char.p7.c: Update the
checking count of addi to 6.

8 months agoDocument negative forms of -Wtsan and -Wxor-used-as-pow [PR110847]
Sandra Loosemore [Thu, 18 Jan 2024 02:29:30 +0000 (02:29 +0000)] 
Document negative forms of -Wtsan and -Wxor-used-as-pow [PR110847]

These warnings are enabled by default, thus the manual should document the
-no form instead of the positive form.

gcc/ChangeLog
PR middle-end/110847
* doc/invoke.texi (Option Summary): Document negative forms of
-Wtsan and -Wxor-used-as-pow.
(Warning Options): Likewise.

8 months agoRISC-V: Add has compatible check for conflict vsetvl fusion
Juzhe-Zhong [Thu, 18 Jan 2024 01:08:15 +0000 (09:08 +0800)] 
RISC-V: Add has compatible check for conflict vsetvl fusion

V3: Rebase to trunk and commit it.

This patch fixes SPEC2017 cam4 mismatch issue due to we miss has compatible check
for conflict vsetvl fusion.

Buggy assembler before this patch:

.L69:
vsetvli a5,s1,e8,mf4,ta,ma                  -> buggy vsetvl
vsetivli zero,8,e8,mf2,ta,ma
vmv.v.i v1,0
vse8.v v1,0(a5)
j .L37
.L68:
vsetvli a5,s1,e8,mf4,ta,ma                  -> buggy vsetvl
vsetivli zero,8,e8,mf2,ta,ma
addi a3,a5,8
vmv.v.i v1,0
vse8.v v1,0(a5)
vse8.v v1,0(a3)
addi a4,a4,-16
li a3,8
bltu a4,a3,.L37
j .L69
.L67:
vsetivli zero,8,e8,mf2,ta,ma
vmv.v.i v1,0
vse8.v v1,0(a5)
addi a5,sp,56
vse8.v v1,0(a5)
addi s4,sp,64
addi a3,sp,72
vse8.v v1,0(s4)
vse8.v v1,0(a3)
addi a4,a4,-32
li a3,16
bltu a4,a3,.L36
j .L68

After this patch:

.L63:
ble s1,zero,.L49
slli a4,s1,3
li a3,32
addi a5,sp,48
bltu a4,a3,.L62
vsetivli zero,8,e8,mf2,ta,ma
vmv.v.i v1,0
vse8.v v1,0(a5)
addi a5,sp,56
vse8.v v1,0(a5)
addi s4,sp,64
addi a3,sp,72
vse8.v v1,0(s4)
addi a4,a4,-32
addi a5,sp,80
vse8.v v1,0(a3)
.L35:
li a3,16
bltu a4,a3,.L36
addi a3,a5,8
vmv.v.i v1,0
addi a4,a4,-16
vse8.v v1,0(a5)
addi a5,a5,16
vse8.v v1,0(a3)
.L36:
li a3,8
bltu a4,a3,.L37
vmv.v.i v1,0
vse8.v v1,0(a5)

Tested on both RV32/RV64 no regression, Ok for trunk ?

PR target/113429

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pre_vsetvl::earliest_fuse_vsetvl_info): Fix bug.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-4.c: Adapt test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-5.c: Ditto.

8 months agoRe-alphabetize attribute tables in extend.texi.
Sandra Loosemore [Thu, 18 Jan 2024 00:12:40 +0000 (00:12 +0000)] 
Re-alphabetize attribute tables in extend.texi.

These sections used to be alphabetized, but when I was working on the
fix for PR111659 I noticed documentation for some newer attributes had
been inserted at random places in the tables instead of maintaining
alphabetical order.  There's no change to content here, just moving
blocks of text around.

gcc/ChangeLog
* doc/extend.texi (Common Function Attributes): Re-alphabetize
the table.
(Common Variable Attributes): Likewise.
(Common Type Attributes): Likewise.

8 months agoDaily bump.
GCC Administrator [Thu, 18 Jan 2024 00:18:14 +0000 (00:18 +0000)] 
Daily bump.

8 months agoc++: Prevent overwriting arguments when merging duplicates [PR112588]
Nathaniel Shead [Sat, 16 Dec 2023 10:34:45 +0000 (21:34 +1100)] 
c++: Prevent overwriting arguments when merging duplicates [PR112588]

When merging duplicate instantiations of function templates, currently
read_function_def overwrites the arguments with that of the existing
duplicate. This is problematic, however, since this means that the
PARM_DECLs in the body of the function definition no longer match with
the PARM_DECLs in the argument list, which causes issues when it comes
to generating RTL.

There doesn't seem to be any reason to do this replacement, so this
patch removes that logic.

PR c++/112588

gcc/cp/ChangeLog:

* module.cc (trees_in::read_function_def): Don't overwrite
arguments.

gcc/testsuite/ChangeLog:

* g++.dg/modules/merge-16.h: New test.
* g++.dg/modules/merge-16_a.C: New test.
* g++.dg/modules/merge-16_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
8 months agoClean up documentation for -Wstrict-flex-arrays [PR111659]
Sandra Loosemore [Wed, 17 Jan 2024 21:37:19 +0000 (21:37 +0000)] 
Clean up documentation for -Wstrict-flex-arrays [PR111659]

gcc/ChangeLog
PR middle-end/111659
* doc/extend.texi (Common Variable Attributes): Fix long lines
in documentation of strict_flex_array + other minor copy-editing.
Add a cross-reference to -Wstrict-flex-arrays.
* doc/invoke.texi (Option Summary): Fix whitespace in tables
before -fstrict-flex-arrays and -Wstrict-flex-arrays.
(C Dialect Options): Combine the docs for the two
-fstrict-flex-arrays forms into a single entry.  Note this option
is for C/C++ only.  Add a cross-reference to -Wstrict-flex-arrays.
(Warning Options): Note -Wstrict-flex-arrays is for C/C++ only.
Minor copy-editing.  Add cross references to the strict_flex_array
attribute and -fstrict-flex-arrays option.  Add note that this
option depends on -ftree-vrp.

8 months agoaarch64: Fix aarch64_ldp_reg_operand predicate not to allow all subreg [PR113221]
Andrew Pinski [Tue, 16 Jan 2024 23:37:49 +0000 (15:37 -0800)] 
aarch64: Fix aarch64_ldp_reg_operand predicate not to allow all subreg [PR113221]

So the problem here is that aarch64_ldp_reg_operand will all subreg even subreg of lo_sum.
When LRA tries to fix that up, all things break. So the fix is to change the check to only
allow reg and subreg of regs.

Note the tendancy here is to use register_operand but that checks the mode of the register
but we need to allow a mismatch modes for this predicate for now.

Built and tested for aarch64-linux-gnu with no regressions
(Also tested with the LD/ST pair pass back on).

PR target/113221

gcc/ChangeLog:

* config/aarch64/predicates.md (aarch64_ldp_reg_operand): For subreg,
only allow REG operands instead of allowing all.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr113221-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 months agoRISC-V: fix some vsetvl debug info in pass's Phase 2 code [NFC]
Vineet Gupta [Tue, 16 Jan 2024 21:23:42 +0000 (13:23 -0800)] 
RISC-V: fix some vsetvl debug info in pass's Phase 2 code [NFC]

When staring at VSETVL pass for PR/113429, spotted some minor
improvements.

1. For readablity, remove some redundant condition check in Phase 2
   function  earliest_fuse_vsetvl_info ().
2. Add iteration count in debug prints in same function.

gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (earliest_fuse_vsetvl_info):
Remove redundant checks in else condition for readablity.
(earliest_fuse_vsetvl_info) Print iteration count in debug
prints.
(earliest_fuse_vsetvl_info) Fix misleading vsetvl info
dump details in certain cases.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
8 months agoRISC-V: RVV: add toggle to control vsetvl pass behavior
Vineet Gupta [Tue, 16 Jan 2024 21:17:27 +0000 (13:17 -0800)] 
RISC-V: RVV: add toggle to control vsetvl pass behavior

RVV requires VSET?VL? instructions to dynamically configure VLEN at
runtime. There's a custom pass to do that which has a simple mode
which generates a VSETVL for each V insn and a lazy/optimal mode which
uses LCM dataflow to move VSETVL around, identify/delete the redundant
ones.

Currently simple mode is default for !optimize invocations while lazy
mode being the default.

This patch allows simple mode to be forced via a toggle independent of
the optimization level. A lot of gcc developers are currently doing this
in some form in their local setups, as in the initial phase of autovec
development issues are expected. It makes sense to provide this facility
upstream. It could potentially also be used by distro builder for any
quick workarounds in autovec bugs of future.

gcc/ChangeLog:
* config/riscv/riscv.opt: New -param=vsetvl-strategy.
* config/riscv/riscv-opts.h: New enum vsetvl_strategy_enum.
* config/riscv/riscv-vsetvl.cc
(pre_vsetvl::pre_global_vsetvl_info): Use vsetvl_strategy.
(pass_vsetvl::execute): Use vsetvl_strategy.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
8 months agoRemove accidental hack in ipa_polymorphic_call_context::set_by_invariant
Jan Hubicka [Wed, 17 Jan 2024 18:16:47 +0000 (19:16 +0100)] 
Remove accidental hack in ipa_polymorphic_call_context::set_by_invariant

I managed to commit a hack setting offset to 0 in
ipa_polymorphic_call_context::set_by_invariant.  This makes it to give up on multiple
inheritance, but most likely won't give bad code since the ohter base will be of
different type.

gcc/ChangeLog:

* ipa-polymorphic-call.cc (ipa_polymorphic_call_context::set_by_invariant): Remove
accidental hack reseting offset.

8 months agoFix handling of X86_TUNE_AVOID_512FMA_CHAINS.
Jan Hubicka [Wed, 17 Jan 2024 18:14:16 +0000 (19:14 +0100)] 
Fix handling of X86_TUNE_AVOID_512FMA_CHAINS.

I have noticed quite bad pasto in handling of X86_TUNE_AVOID_512FMA_CHAINS.  At the
moment it is ignored, but X86_TUNE_AVOID_256FMA_CHAINS controls 512FMA too.
This patch fixes it, we may want to re-check how that works on AVX512 machines.

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_option_override_internal): Fix
handling of X86_TUNE_AVOID_512FMA_CHAINS.

8 months agoc++: address of class NTTP object as targ [PR113242]
Patrick Palka [Wed, 17 Jan 2024 18:01:01 +0000 (13:01 -0500)] 
c++: address of class NTTP object as targ [PR113242]

invalid_tparm_referent_p was rejecting using the address of a class NTTP
object as a template argument, but this should be fine.

PR c++/113242
PR c++/99493

gcc/cp/ChangeLog:

* pt.cc (invalid_tparm_referent_p) <case ADDR_EXPR>: Suppress
DECL_ARTIFICIAL rejection test for class NTTP objects.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class61.C: New test.
* g++.dg/cpp2a/nontype-class62.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
8 months agotestsuite: Reduce gcc.dg/torture/inline-mem-cpy-1.c by 11 for simulators
Hans-Peter Nilsson [Wed, 17 Jan 2024 17:02:34 +0000 (18:02 +0100)] 
testsuite: Reduce gcc.dg/torture/inline-mem-cpy-1.c by 11 for simulators

The test inline-mem-cpy-1.c takes 16 minutes at -O0 for the mmix
simulator on a 3.5 year old laptop and thus always times out, despite
the x 2 timeout (i.e. 10 minutes), and times out at all optimization
levels.  For the included file (when run as gcc.dg/memcmp-1.c), the
execution time on the same host is 9 minutes 54 seconds, so just
within 10 minutes timeout limit.  Seems pragmatically best to reduce
the torture-test by a factor of about 10, but there's no obvious small
set of entities to scale down to get the intended effect, and
splitting up the test into several tests seem a bit too intrusive.

Instead, introduce pseudo-random machinery to skip all but each
RUN_FRACTION:th iteration, defaulting to no change when RUN_FRACTION
isn't defined.  Use 11 for RUN_FRACTION, assuming this prime will lead
to even distribution within nested iterations with loops looking like
(0, 1) : (0, 1).  Do this only for the main loop in
test_driver_memcmp; the "outermost" two levels of iterations.

With this, execution time for -O0 as above is down to 1 minute 32
seconds.

* gcc.dg/torture/inline-mem-cpy-1.c: Pass -DRUN_FRACTION=11
when testing in a simulator.
* gcc.dg/memcmp-1.c [RUN_FRACTION]: Add machinery to run only
for each RUN_FRACTION:th iteration.
(main): Call initialize_skip_iteration_count.
(test_driver_memcmp): Check SKIP_ITERATION for each iteration.

8 months agoFix merging of value predictors
Jan Hubicka [Wed, 17 Jan 2024 14:19:32 +0000 (15:19 +0100)] 
Fix merging of value predictors

expr_expected_value is doing some guesswork when it is merging two or more
independent value predictions either in PHI node or in binary operation.
Since we do not know how the predictions interact with each other, we can
not really merge the values precisely.

The previous logic merged the prediciton and picked the later predictor
(since predict.def is sorted by reliability). This however leads to troubles
with __builtin_expect_with_probability since it is special cased as a predictor
with custom probabilities.  If this predictor is downgraded to something else,
we ICE since we have prediction given by predictor that is not expected
to have customprobability.

This patch fixies it by inventing new predictors PRED_COMBINED_VALUE_PREDICTIONS
and PRED_COMBINED_VALUE_PREDICTIONS_PHI which also allows custom values but
are considered less reliable then __builtin_expect_with_probability (they
are combined by ds theory rather then by first match).  This is less likely
going to lead to very stupid decisions if combining does not work as expected.

I also updated the code to be bit more careful about merging values and do not
downgrade the precision when unnecesary (as tested by new testcases).

Bootstrapped/regtested x86_64-linux, will commit it tomorrow if there are
no complains.

2024-01-17  Jan Hubicka  <jh@suse.cz>
    Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/110852

gcc/ChangeLog:

* predict.cc (expr_expected_value_1): Fix profile merging of PHI and
binary operations
(get_predictor_value): Handle PRED_COMBINED_VALUE_PREDICTIONS and
PRED_COMBINED_VALUE_PREDICTIONS_PHI
* predict.def (PRED_COMBINED_VALUE_PREDICTIONS): New predictor.
(PRED_COMBINED_VALUE_PREDICTIONS_PHI): New predictor.

gcc/testsuite/ChangeLog:

* gcc.dg/predict-18.c: Update template to expect combined value predictor.
* gcc.dg/predict-23.c: New test.
* gcc.dg/tree-ssa/predict-1.c: New test.
* gcc.dg/tree-ssa/predict-2.c: New test.
* gcc.dg/tree-ssa/predict-3.c: New test.

8 months agolower-bitint: Avoid overlap between destinations and sources in libgcc calls [PR113421]
Jakub Jelinek [Wed, 17 Jan 2024 13:43:40 +0000 (14:43 +0100)] 
lower-bitint: Avoid overlap between destinations and sources in libgcc calls [PR113421]

The following testcase is miscompiled because the bitint lowering emits a
  .MULBITINT (&a, 1024, &a, 1024, &x, 1024);
call.  The bug is in the overlap between the destination and source, that is
something the libgcc routines don't handle, they use the source arrays
during the entire algorithms which computes the destination array(s).
For the mapping of SSA_NAMEs to VAR_DECLs the code already supports that
correctly, but the checking whether a load from memory can be used directly
without a temporary even when earlier we decided to merge the
multiplication/division/modulo etc. with a store didn't.

The following patch implements that.

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

PR tree-optimization/113421
* gimple-lower-bitint.cc (stmt_needs_operand_addr): Adjust function
comment.
(bitint_dom_walker::before_dom_children): Add g temporary to simplify
formatting.  Start at vop rather than cvop even if stmt is a store
and needs_operand_addr.

* gcc.dg/torture/bitint-50.c: New test.

8 months agogimple-ssa-warn-access: Cast huge params to sizetype before using them in maybe_check...
Jakub Jelinek [Wed, 17 Jan 2024 12:57:07 +0000 (13:57 +0100)] 
gimple-ssa-warn-access: Cast huge params to sizetype before using them in maybe_check_access_sizes [PR113410]

WHen a VLA is created with some very high precision size expression
(say __int128, or _BitInt(65535) etc.), we cast it to sizetype, because
we can't have arrays longer than what can be expressed in sizetype.

But the maybe_check_access_sizes code when trying to determine ranges
wasn't doing this but was using fixed buffers for the sizes.  While
__int128 could still be handled (fit into the buffers), obviously
arbitrary _BitInt parameter ranges can't, they can be in the range of
up to almost 20KB per number.  It doesn't make sense to print such
ranges though, no array can be larger than sizetype precision, and
ranger's range_of_expr can handle NOP_EXPRs/CONVERT_EXPRs wrapping a
PARM_DECL just fine, so the following patch just casts the excessively
large counters for the range determination purposes to sizetype.

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

PR middle-end/113410
* gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes):
If access_nelts is integral with larger precision than sizetype,
fold_convert it to sizetype.

* gcc.dg/bitint-72.c: New test.

8 months agolower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408]
Jakub Jelinek [Wed, 17 Jan 2024 12:55:50 +0000 (13:55 +0100)] 
lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408]

Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR
is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped
in VIEW_CONVERT_EXPR tree.

So, to handle it like other casts we need to look through it.

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

PR tree-optimization/113408
* gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For
VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1
to handle_cast.

* gcc.dg/bitint-71.c: New test.

8 months agoipa-strub: Fix handling of _BitInt returns [PR113406]
Jakub Jelinek [Wed, 17 Jan 2024 12:54:44 +0000 (13:54 +0100)] 
ipa-strub: Fix handling of _BitInt returns [PR113406]

Seems pass_ipa_strub::execute contains a copy of the expand_thunk
code I've changed for _BitInt in r14-6805 PR112941 - larger _BitInts
are aggregate_value_p even when they are is_gimple_reg_type.

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

PR middle-end/113406
* ipa-strub.cc (pass_ipa_strub::execute): Check aggregate_value_p
regardless of whether is_gimple_reg_type (restype) or not.

* gcc.dg/bitint-70.c: New test.

8 months agolibstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]
Jonathan Wakely [Mon, 15 Jan 2024 15:42:50 +0000 (15:42 +0000)] 
libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]

This is another C++26 change, approved in Varna 2023. We require a new
static array of data that is extracted from the IANA Character Sets
database. A new Python script to generate a header from the IANA CSV
file is added.

The text_encoding class is basically just a pointer to an {ID,name} pair
in the static array. The aliases view is also just the same pointer (or
empty), and the view's iterator moves forwards and backwards in the
array while the array elements have the same ID (or to one element
further, for a past-the-end iterator).

Because those iterators refer to a global array that never goes out of
scope, there's no reason they should every produce undefined behaviour
or indeterminate values.  They should either have well-defined
behaviour, or abort. The overhead of ensuring those properties is pretty
low, so seems worth it.

This means that an aliases_view iterator should never be able to access
out-of-bounds. A non-value-initialized iterator always points to an
element of the static array even when not dereferenceable (the array has
unreachable entries at the start and end, which means that even a
past-the-end iterator for the last encoding in the array still points to
valid memory).  Dereferencing an iterator can always return a valid
array element, or "" for a non-dereferenceable iterator (but doing so
will abort when assertions are enabled).  In the language being proposed
for C++26, dereferencing an invalid iterator erroneously returns "".
Attempting to increment/decrement past the last/first element in the
view is erroneously a no-op, so aborts when assertions are enabled, and
doesn't change value otherwise.

Similarly, constructing a std::text_encoding with an invalid id (one
that doesn't have the value of an enumerator) erroneously behaves the
same as constructing with id::unknown, or aborts with assertions
enabled.

libstdc++-v3/ChangeLog:

PR libstdc++/113318
* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory.
(GLIBCXX_CHECK_TEXT_ENCODING): Define.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/bits/locale_classes.h (locale::encoding): Declare new
member function.
* include/bits/unicode.h (__charset_alias_match): New function.
* include/bits/text_encoding-data.h: New file.
* include/bits/version.def (text_encoding): Define.
* include/bits/version.h: Regenerate.
* include/std/text_encoding: New file.
* src/Makefile.am: Add new subdirectory.
* src/Makefile.in: Regenerate.
* src/c++26/Makefile.am: New file.
* src/c++26/Makefile.in: New file.
* src/c++26/text_encoding.cc: New file.
* src/experimental/Makefile.am: Include c++26 convenience
library.
* src/experimental/Makefile.in: Regenerate.
* python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New
printer.
* scripts/gen_text_encoding_data.py: New file.
* testsuite/22_locale/locale/encoding.cc: New test.
* testsuite/ext/unicode/charset_alias_match.cc: New test.
* testsuite/std/text_encoding/cons.cc: New test.
* testsuite/std/text_encoding/members.cc: New test.
* testsuite/std/text_encoding/requirements.cc: New test.

Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
8 months agolibstdc++: Do not use CTAD for _Utf32_view alias template
Jonathan Wakely [Tue, 16 Jan 2024 17:15:26 +0000 (17:15 +0000)] 
libstdc++: Do not use CTAD for _Utf32_view alias template

We were relying on P1814R0 (CTAD for alias templates) which isn't
supported by Clang. We can just not use CTAD and provide an explicit
template argument list for _Utf32_view.

Ideally we'd define a deduction guide for _Grapheme_cluster_view that
uses views::all_t to properly convert non-views to views, but all_t is
defined in <ranges> and we don't want to include all of that in
<bits/unicode.h>. So just make it require a view for now, which can be
cheaply copied.

Although it's not needed yet, it would also be more correct to
specialize enable_borrowed_range for the views in <bits/unicode.h>.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Grapheme_cluster_view): Require view.
Do not use CTAD for _Utf32_view.
(__format_width, __truncate): Do not use CTAD.
(enable_borrowed_range<_Utf_view<T, R>>): Define specialization.
(enable_borrowed_range<_Grapheme_cluster_view<R>>): Likewise.

8 months agotestsuite: Add testcase for already fixed PR [PR110251]
Jakub Jelinek [Wed, 17 Jan 2024 10:33:14 +0000 (11:33 +0100)] 
testsuite: Add testcase for already fixed PR [PR110251]

This testcase started to hang at -O3 with r13-4208 and got fixed
with r14-2097.

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

PR tree-optimization/110251
* gcc.c-torture/compile/pr110251.c: New test.

8 months agoFix comment typos
Jakub Jelinek [Wed, 17 Jan 2024 10:21:18 +0000 (11:21 +0100)] 
Fix comment typos

When looking at PR113410, I found a comment typo and just searched for
the same typo elsewhere and found some typos in the comments which had
that typo as well.

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

* tree-into-ssa.cc (pass_build_ssa::gate): Fix comment typo,
funcions -> functions, and use were instead of was.
* gengtype.cc (dump_typekind): Fix comment typos, funcion -> function
and guaranteee -> guarantee.
* attribs.h (struct attr_access): Fix comment typo funcion -> function.

8 months agoopenmp: Add OpenMP _BitInt support [PR113409]
Jakub Jelinek [Wed, 17 Jan 2024 09:47:31 +0000 (10:47 +0100)] 
openmp: Add OpenMP _BitInt support [PR113409]

The following patch adds support for _BitInt iterators of OpenMP canonical
loops (with the preexisting limitation that when not using compile time
static scheduling the iterators in the library are at most unsigned long long
or signed long, so one can't in the runtime/dynamic/guided etc. cases iterate
more than what those types can represent, like is the case of e.g. __int128
iterators too) and the testcase also covers linear/reduction clauses for them.

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

PR middle-end/113409
* omp-general.cc (omp_adjust_for_condition): Handle BITINT_TYPE like
INTEGER_TYPE.
(omp_extract_for_data): Use build_bitint_type rather than
build_nonstandard_integer_type if either iter_type or loop->v type
is BITINT_TYPE.
* omp-expand.cc (expand_omp_for_generic,
expand_omp_taskloop_for_outer, expand_omp_taskloop_for_inner): Handle
BITINT_TYPE like INTEGER_TYPE.

* testsuite/libgomp.c/bitint-1.c: New test.

8 months agoSanitizer/MIPS: Use $t9 for preemptible function call
YunQiang Su [Wed, 17 Jan 2024 07:11:33 +0000 (15:11 +0800)] 
Sanitizer/MIPS: Use $t9 for preemptible function call

Currently, almost all of the shared libraries of MIPS, rely on $t9
to get the address of current function, instead of PCREL instructions,
even on MIPSr6. So we have to set $t9 properly.

To get the address of preemptible function, we need the help of GOT.
MIPS/O32 has .cpload, which can help to generate 3 instructions to get GOT.
For __mips64, we can get GOT by:

lui $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
daddu $t8, $t8, $t9
daddiu $t8, $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))

And then get the address of __interceptor_func, and jump to it

ld $t9, %got_disp(_interceptor" SANITIZER_STRINGIFY(func) ")($t8)
jr $t9

Upstream-Commit: 0a64367a72f1634321f5051221f05f2f364bd882

libsanitizer

* interception/interception.h (substitution_##func_name):
Use macro C_ASM_TAIL_CALL.
* sanitizer_common/sanitizer_asm.h: Define C_ASM_TAIL_CALL
for MIPS with help of t9.

8 months agoRISC-V: Fix asm checks regression due to recent middle-end change
Pan Li [Wed, 17 Jan 2024 08:56:56 +0000 (16:56 +0800)] 
RISC-V: Fix asm checks regression due to recent middle-end change

The recent middle-end change result in some asm check failures.
This patch would like to fix the asm check by adjust the times.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/shift-1.c: Fix asm check
count.
* gcc.target/riscv/rvv/autovec/vls/shift-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/shift-3.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agotree-optimization/113371 - avoid prologue peeling for peeled early exits
Richard Biener [Tue, 16 Jan 2024 12:09:27 +0000 (13:09 +0100)] 
tree-optimization/113371 - avoid prologue peeling for peeled early exits

The following avoids prologue peeling when doing early exit
vectorization with the IV exit before the early exit.  That's because
we it invalidates the invariant that the effective latch of the loop
is empty causing wrong continuation to the main loop.  In particular
this is prone to break virtual SSA form.

PR tree-optimization/113371
* tree-vect-data-refs.cc (vect_enhance_data_refs_alignment):
Do not peel when LOOP_VINFO_EARLY_BREAKS_VECT_PEELED.
* tree-vect-loop-manip.cc (vect_do_peeling): Assert we do
not perform prologue peeling when LOOP_VINFO_EARLY_BREAKS_VECT_PEELED.

* gcc.dg/vect/pr113371.c: New testcase.

8 months agosched-deps.cc (find_modifiable_mems): Avoid exponential behavior [PR96388]
Maxim Kuvyrkov [Sun, 19 Nov 2023 08:43:05 +0000 (08:43 +0000)] 
sched-deps.cc (find_modifiable_mems): Avoid exponential behavior [PR96388]

This patch avoids sched-deps.cc:find_inc() creating exponential number
of dependencies, which become memory and compilation time hogs.
Consider example (simplified from PR96388) ...
===
sp=sp-4 // sp_insnA
mem_insnA1[sp+A1]
...
mem_insnAN[sp+AN]
sp=sp-4 // sp_insnB
mem_insnB1[sp+B1]
...
mem_insnBM[sp+BM]
===

[For simplicity, let's assume find_inc(backwards==true)].
In this example find_modifiable_mems() will arrange for mem_insnA*
to be able to pass sp_insnA, and, while doing this, will create
dependencies between all mem_insnA*s and sp_insnB -- because sp_insnB
is a consumer of sp_insnA.  After this sp_insnB will have N new
backward dependencies.
Then find_modifiable_mems() gets to mem_insnB*s and starts to create
N new dependencies for _every_ mem_insnB*.  This gets us N*M new
dependencies.

In PR96833's testcase N and M are 10k-15k, which causes RAM usage of
30GB and compilation time of 30 minutes, with sched2 accounting for
95% of both metrics.  After this patch the RAM usage is down to 1GB
and compilation time is down to 3-4 minutes, with sched2 no longer
standing out on -ftime-report or memory usage.

gcc/ChangeLog:

PR rtl-optimization/96388
PR rtl-optimization/111554
* sched-deps.cc (find_inc): Avoid exponential behavior.

8 months agoMove docs for -Wuse-after-free and -Wuseless-cast [PR111693]
Sandra Loosemore [Wed, 17 Jan 2024 04:41:52 +0000 (04:41 +0000)] 
Move docs for -Wuse-after-free and -Wuseless-cast [PR111693]

These options were categorized as C++ options, but they apply to all
C-family languages.

gcc/ChangeLog
PR c/111693
* doc/invoke.texi (Option Summary): Move -Wuseless-cast
from C++ Language Options to Warning Options.  Add entry for
-Wuse-after-free.
(C++ Dialect Options): Move -Wuse-after-free and -Wuseless-cast
from here....
(Warning Options): ...to here.  Minor copy-editing to fix typo
and grammar.

8 months agoMIPS: avoid $gp store if global_pointer is not $gp
YunQiang Su [Mon, 15 Jan 2024 01:28:51 +0000 (09:28 +0800)] 
MIPS: avoid $gp store if global_pointer is not $gp

$GP is used for expanding GOT load, but in the afterward passes,
a temporary register is tried to replace $gp.

If sucess, we have no need to store and reload $gp. The example
of failure is that the function calls a preemtive function.

We shouldn't use $GP for any other purpose in the code we generate.
If a user's inline asm code clobbers $GP, it's their duty to save
and restore $GP.

gcc
* config/mips/mips.cc (mips_compute_frame_info): If another
register is used as global_pointer, mark $GP live false.

gcc/testsuite
* gcc.target/mips/mips.exp (mips_option_groups):
Add -mxgot/-mno-xgot options.
* gcc.target/mips/xgot-n32-avoid-gp.c: New test.
* gcc.target/mips/xgot-n32-need-gp.c: New test.

8 months agoTidy documentation for BPF builtins [PR112973]
Sandra Loosemore [Wed, 17 Jan 2024 00:24:36 +0000 (00:24 +0000)] 
Tidy documentation for BPF builtins [PR112973]

gcc/Changelog
PR target/112973
* doc/extend.texi (BPF Built-in Functions): Wrap long lines and
give the section a light copy-editing pass.

8 months agolibstdc++: Implement P2540R1 change to views::cartesian_product()
Patrick Palka [Wed, 17 Jan 2024 02:20:12 +0000 (21:20 -0500)] 
libstdc++: Implement P2540R1 change to views::cartesian_product()

This paper changes the identity element of views::cartesian_product to a
singleton range instead of an empty range.  It was approved alongside
the main cartesian_product paper P2374R4, but unfortunately was overlooked
when implementing the main paper.

libstdc++-v3/ChangeLog:

* include/std/ranges (views::_CartesianProduct::operator()):
Adjust identity case as per P2540R1.
* testsuite/std/ranges/cartesian_product/1.cc (test01):
Adjust expected result of the identity case.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
8 months agoDaily bump.
GCC Administrator [Wed, 17 Jan 2024 00:21:29 +0000 (00:21 +0000)] 
Daily bump.

8 months agoc++: Support thread_local statics in header modules [PR113292]
Nathaniel Shead [Thu, 11 Jan 2024 05:49:39 +0000 (16:49 +1100)] 
c++: Support thread_local statics in header modules [PR113292]

Currently, thread_locals in header modules cause ICEs. This patch makes
the required changes for them to work successfully.

This requires additionally writing the DECL_TLS_MODEL for thread-local
variables to the module interface, and the TLS wrapper function needs to
have its DECL_BEFRIENDING_CLASSES written too as this is used to
retrieve what VAR_DECL it's a wrapper for when emitting a definition at
end of TU processing.

PR c++/113292

gcc/cp/ChangeLog:
* decl2.cc (get_tls_wrapper_fn): Set DECL_CONTEXT.
(c_parse_final_cleanups): Suppress warning for no definition of
TLS wrapper functions in header modules.
* module.cc (trees_out::lang_decl_vals): Write wrapped variable
for TLS wrapper functions.
(trees_in::lang_decl_vals): Read it.
(trees_out::decl_value): Write TLS model for thread-local vars.
(trees_in::decl_value): Read it for new decls. Remember to emit
definitions of TLS wrapper functions later.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr113292_a.H: New test.
* g++.dg/modules/pr113292_b.C: New test.
* g++.dg/modules/pr113292_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
8 months agoc++: Fix ENABLE_SCOPE_CHECKING printing
Nathaniel Shead [Tue, 16 Jan 2024 09:56:46 +0000 (20:56 +1100)] 
c++: Fix ENABLE_SCOPE_CHECKING printing

The lists of scope kinds used by ENABLE_SCOPE_CHECKING don't seem to
have been updated in a long while, causing ICEs and confusing output.
This patch brings the list into line.

Additionally, the comment on 'explicit_spec_p' says that the flag is
only valid if kind is 'sk_template_parms', so we rewrite the condition
to be more obviously correct here.

gcc/cp/ChangeLog:

* name-lookup.h (enum scope_kind): Add 'sk_count'.
* name-lookup.cc (cp_binding_level_descriptor): Add missing
scope kinds. Add assertion that the list is up to date. Fix
handling of explicit_spec_p.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
8 months agoc++: fix xobj diagnostic messages
Marek Polacek [Tue, 16 Jan 2024 21:17:19 +0000 (16:17 -0500)] 
c++: fix xobj diagnostic messages

Diagnostics should start with a lower-case letter.

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator) <case cdk_function>: Tweak diagnostic
messages.

8 months agoc++: fix ICE with xobj in destructor [PR113340]
Marek Polacek [Tue, 16 Jan 2024 20:49:46 +0000 (15:49 -0500)] 
c++: fix ICE with xobj in destructor [PR113340]

Here we crash in maybe_retrofit_in_chrg on an invalid dtor
with explicit this.  Such member functions do not get converted
to METHOD_TYPE.  If a dtor gets parameters, we reset arg_types
to void_list_node in grokdeclarator.  This results in m_r_in_c
receiving:
  void <T8d> (void)
and crashing on
  parms = DECL_CHAIN (DECL_ARGUMENTS (fn));

This patch avoids the ICE by resetting is_xobj_member_function after
emitting the error.  Then m_r_in_c gets
  void S::<T40b> (struct S *)
which does not cause a crash.

PR c++/113340

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator) <case cdk_function>: Clear
is_xobj_member_function in case of an error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.

8 months agoAdd hppa*-*-hpux* to targets which do not support split DWARF
John David Anglin [Tue, 16 Jan 2024 21:13:18 +0000 (21:13 +0000)] 
Add hppa*-*-hpux* to targets which do not support split DWARF

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

gcc/testsuite/ChangeLog:

* gcc.dg/pr111409.c: Add hppa*-*-hpux* to targets which do
not support split DWARF.

8 months agoc++: reject packs on xobj params [PR113307]
waffl3x [Fri, 12 Jan 2024 07:40:19 +0000 (07:40 +0000)] 
c++: reject packs on xobj params [PR113307]

Reject and diagnose xobj parameters declared as parameter packs.

PR c++/113307

gcc/cp/ChangeLog:

* parser.cc (cp_parser_parameter_declaration): Reject packs
on xobj params.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-diagnostics3.C: Add test for
rejection of packs.

Signed-off-by: Waffl3x <waffl3x@protonmail.com>
8 months agoAdd .data.rel.ro.local to read only sections in gcc.dg/array-quals-1.c
John David Anglin [Tue, 16 Jan 2024 21:03:57 +0000 (21:03 +0000)] 
Add .data.rel.ro.local to read only sections in gcc.dg/array-quals-1.c

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

gcc/testsuite/ChangeLog:

* gcc.dg/array-quals-1.c: Add .data.rel.ro.local to read only
sections.

8 months agoRemove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c
John David Anglin [Tue, 16 Jan 2024 20:51:26 +0000 (20:51 +0000)] 
Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c

Tests now pass on hppa64-hp-hpux11.11.

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

gcc/testsuite/ChangeLog:

* gcc.dg/atomic/stdatomic-flag.c: Remove xfail.
* gcc.dg/atomic/stdatomic-flag-2.c: Likewise.

8 months agoxfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
John David Anglin [Tue, 16 Jan 2024 20:38:50 +0000 (20:38 +0000)] 
xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*

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

gcc/testsuite/ChangeLog:

PR tree-optimization/110794
* g++.dg/pr99966.C: xfail scan-tree-dump-not throw on hppa*64*-*-*.

8 months agoRequire target lto in several tests
John David Anglin [Tue, 16 Jan 2024 20:18:29 +0000 (20:18 +0000)] 
Require target lto in several tests

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

gcc/testsuite/ChangeLog:

* gcc.dg/c23-tag-alias-2.c: Require target lto.
* gcc.dg/c23-tag-alias-3.c: Likewise.
* gcc.dg/gnu23-tag-alias-3.c: Likewise.
* gcc.dg/scantest-lto.c: Likewise.

8 months agoSkip various cmp-mem-const tests on lp64 hppa*-*-*
John David Anglin [Tue, 16 Jan 2024 20:04:11 +0000 (20:04 +0000)] 
Skip various cmp-mem-const tests on lp64 hppa*-*-*

Prior optimization already reduced the constant.

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

gcc/testsuite/ChangeLog:

* gcc.dg/cmp-mem-const-3.c: Skip on lp64 hppa*-*-*.
* gcc.dg/cmp-mem-const-4.c: Likewise.
* gcc.dg/cmp-mem-const-5.c: Likewise.
* gcc.dg/cmp-mem-const-6.c: Likewise.

8 months agoxfail all scan-tree-dump-times checks on hppa*64*-*-* in sra-17.c and sra-18.c
John David Anglin [Tue, 16 Jan 2024 19:32:56 +0000 (19:32 +0000)] 
xfail all scan-tree-dump-times checks on hppa*64*-*-* in sra-17.c and sra-18.c

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

gcc/testsuite/ChangeLog:

PR tree-optimization/91624
* gcc.dg/tree-ssa/sra-17.c: xfail all scan-tree-dump-times
checks on hppa*64*-*-*.
* gcc.dg/tree-ssa/sra-18.c: Likewise.

8 months agoAArch64: Add -mcpu=cobalt-100
Wilco Dijkstra [Tue, 16 Jan 2024 18:14:12 +0000 (18:14 +0000)] 
AArch64: Add -mcpu=cobalt-100

Add support for -mcpu=cobalt-100 (Neoverse N2 with a different implementer ID).

gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add 'cobalt-100' CPU.
* config/aarch64/aarch64-tune.md: Regenerated.
* doc/invoke.texi (-mcpu): Add cobalt-100 core.

8 months agogccrs: Adjust item kind enums for TupleStructItems and TuplePatternItems
Owen Avery [Fri, 6 Oct 2023 13:15:17 +0000 (09:15 -0400)] 
gccrs: Adjust item kind enums for TupleStructItems and TuplePatternItems

gcc/rust/ChangeLog:

* hir/tree/rust-hir-pattern.h
(TupleStructItems::ItemType::RANGE): Rename to...
(TupleStructItems::ItemType::RANGED): ...here.
(TupleStructItems::ItemType::NO_RANGE): Rename to...
(TupleStructItems::ItemType::MULTIPLE): ...here.

(TuplePatternItems::TuplePatternItemType): Rename to...
(TuplePatternItems::ItemType): ...here.

: Handle renames.

* backend/rust-compile-pattern.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Likewise.
* checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
8 months agogccrs: Add a new test for float disambiguation
Pierre-Emmanuel Patry [Tue, 31 Oct 2023 14:43:51 +0000 (15:43 +0100)] 
gccrs: Add a new test for float disambiguation

This new regression test highlight the behavior fixed for float
disambiguation with empty floating point.

gcc/testsuite/ChangeLog:

* rust/compile/tuple_float_index.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Fix float lexing and tuple index disambiguation
Pierre-Emmanuel Patry [Tue, 31 Oct 2023 14:23:45 +0000 (15:23 +0100)] 
gccrs: Fix float lexing and tuple index disambiguation

When a float has a floating point but no value after it, a zero was added
this lead to errors when trying to disambiguate a float into a tuple
index.

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::parse_decimal_int_or_float): Remove
additional zero after empty floating point.
* parse/rust-parse-impl.h (Parser::left_denotation): Handle float with
empty floating point.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: v0-mangle closures
Raiki Tamura [Thu, 12 Oct 2023 08:24:46 +0000 (17:24 +0900)] 
gccrs: v0-mangle closures

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::generate_closure_function):
Fix reference to node.
* backend/rust-mangle.cc (struct V0Path): Modified to accept closures.
(v0_crate_path): Modified to accept closures.
(v0_closure): New function to mangle closures.
(v0_path): Modified to accept closures
* util/rust-mapping-common.h (UNKNOWN_NODEID): Change to UINT32_MAX.
(UNKNOWN_HIRID): Change to UINT32_MAX.

gcc/testsuite/ChangeLog:

* rust/compile/v0-mangle2.rs: New test.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
8 months agogccrs: Move default visitor templates to header
Pierre-Emmanuel Patry [Tue, 7 Nov 2023 12:02:20 +0000 (13:02 +0100)] 
gccrs: Move default visitor templates to header

Move default ast visitor template implementation to headers in order to
match the codebase and avoid link errors.

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Move from here...
* ast/rust-ast-visitor.h: ... to here.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Move templated functions to header file
Pierre-Emmanuel Patry [Tue, 7 Nov 2023 10:37:39 +0000 (11:37 +0100)] 
gccrs: Move templated functions to header file

Templated functions shall remain in header files to stay in line with the
rest of the codebase.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Move to header
file.
(TokenCollector::visit_items_joined_by_separator): Likewise.
(TokenCollector::visit_as_line): Likewise.
(TokenCollector::visit_items_as_lines): Likewise.
(TokenCollector::visit_items_as_block): Likewise.
* ast/rust-ast-collector.h: Add implementation.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Rework function special parameters
Pierre-Emmanuel Patry [Sun, 12 Nov 2023 20:44:07 +0000 (21:44 +0100)] 
gccrs: Rework function special parameters

Make self param and variadic param Param, introduce Param class and make
function parameters param too.
Self can now be represented as a standard parameter and is thus no longer
required as a separate function attribute.
Prevent self pointers and allow self in standard functions during parsing
so they could be rejected at a later stage.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor for
VariadicParam and remove Self parameter visitor from Function visit.
* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_self_param): Remove
function.
(CfgStrip::maybe_strip_trait_method_decl): Remove self parameter visit.
(CfgStrip::maybe_strip_function_params): Handle new function
parameters.
(CfgStrip::visit): Handle VariadicParam, SelfParam and FunctionParam.
* expand/rust-expand-visitor.cc (ExpandVisitor::expand_self_param):
Remove function.
(ExpandVisitor::expand_trait_method_decl): Do not visit self parameter.
(ExpandVisitor::visit): Add visit for VariadicParam, FunctionParam and
SelfParam.
(ExpandVisitor::expand_function_params): Visit parameters instead.
* expand/rust-expand-visitor.h: Update function prototypes.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Update visit
with new parameters.
(ResolveTraitItems::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Update visit functions with the new visitor functions for VariadicParam
SelfParam and FunctionParam.
* resolve/rust-early-name-resolver.h: Update function prototypes.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Update visitor
according to the new function parameter structures.
* ast/rust-ast-visitor.h: Update prototypes and add visitor virtual
functions for SelfParam, FunctionParam and VariadicParam.
* ast/rust-ast.cc (Function::Function): Move constructor in
implementation instead of header.
(Function::operator=): Likewise.
(Function::as_string): Update function with pointer dereference.
(VariadicParam::as_string): Likewise.
(TraitFunctionDecl::as_string): Likewise.
(TraitMethodDecl::as_string): Likewise.
(FunctionParam::accept_vis): Add function for visitor.
(SelfParam::accept_vis): Likewise.
(VariadicParam::accept_vis): Likewise.
(TraitItemFunc::TraitItemFunc): Move constructor to implementation
file.
(TraitItemFunc::operator=): Likewise.
(TraitItemMethod::TraitItemMethod): Likewise.
(TraitItemMethod::operator=): Likewise.
* ast/rust-item.h (class Function): Remove self optional member.
(class TraitMethodDecl): Likewise.
(class TraitFunctionDecl): Likewise.
(class Param): Add abstract parameter class.
(class SelfParam): Inherit from Param and remove parameter common
members.
(class FunctionParam): Likewise.
(class VariadicParam): Likewise.
(struct Visibility): Move structure declaration.
(class VisItem):  Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
a self parameter check during AST validation.
* checks/errors/rust-ast-validation.h: Add function prototype.
* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Update function
constructor.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Rework
function for the new parameters.
(ASTLoweringBase::visit): Add visit functions for VariadicParam,
FunctionParam and SelfParam.
* hir/rust-ast-lower-base.h: Update function prototypes.
* parse/rust-parse-impl.h (Parser::parse_function): Update function
according to new function representation.
(Parser::parse_function_param): Return vector of abstract param instead
of FunctionParam.
(Parser::parse_method): Update according to new representation.
(Parser::parse_trait_item): Likewise.
(Parser::parse_self_param): Error out with
self pointers and prevent the lexer from eating regular function
parameters. Update return type.
* parse/rust-parse.h: Update function return types.
* ast/rust-ast-collector.h: Add VariadicParam visit prototype.
* ast/rust-ast.h (struct Visibility): Move struct declaration.
(class VisItem): Likewise.
* ast/rust-expr.h: Update included files.
* checks/errors/rust-feature-gate.h: Add visitor functions for
SelfParam, FunctionParam and VariadicParam.
* expand/rust-cfg-strip.h: Update function prototypes.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-implitem.h: Handle special arguments.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_function):
Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visitor
functions.
* resolve/rust-ast-resolve-base.h: Update prototypes.
* resolve/rust-ast-resolve-stmt.h: Handle new parameter kind.
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise.
* resolve/rust-default-resolver.h: Update prototype.
* util/rust-attributes.cc (AttributeChecker::visit): Add visitor
functions for SelfParam and VariadicParam.
* util/rust-attributes.h: Add visit prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add new test for invalid variadics
Pierre-Emmanuel Patry [Thu, 9 Nov 2023 22:29:05 +0000 (23:29 +0100)] 
gccrs: Add new test for invalid variadics

Highlight invalid variadic filtering through the ast validation checker.

gcc/testsuite/ChangeLog:

* rust/compile/invalid_variadics.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add multiple check on variadics position
Pierre-Emmanuel Patry [Thu, 9 Nov 2023 21:51:31 +0000 (22:51 +0100)] 
gccrs: Add multiple check on variadics position

Variadics are forbidden alone as well as non final position, this should
be checked during ast validation.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
check for additional named argument as well as variadic argument's
position.
* checks/errors/rust-ast-validation.h: Add visit function prototype for
external functions.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add trait context to ContextualASTVisitor
Pierre-Emmanuel Patry [Thu, 9 Nov 2023 18:45:08 +0000 (19:45 +0100)] 
gccrs: Add trait context to ContextualASTVisitor

Some construct are forbidden in trait context (eg. pub, async...) and
we'll need to reject those. To do so we need to identify a trait context.

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (ContextualASTVisitor::visit): Push the new
trait context when visiting a trait.
* ast/rust-ast-visitor.h: Add visit function prototype and TRAIT
context.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add regression test for invalid label name
Pierre-Emmanuel Patry [Thu, 9 Nov 2023 14:45:04 +0000 (15:45 +0100)] 
gccrs: Add regression test for invalid label name

An error message should be emitted when the rust code contains invalid
label name. Add a new test for this behavior.

gcc/testsuite/ChangeLog:

* rust/compile/invalid_label_name.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Change error location for LoopLabel
Pierre-Emmanuel Patry [Thu, 9 Nov 2023 14:30:32 +0000 (15:30 +0100)] 
gccrs: Change error location for LoopLabel

Loop label error reporting during ast validation was done at loop label
level. It lead to some innacurate error reporting in break loop labels
due to the way the label is built.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Change
reported error location to the lifetime location.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add validation pass for label name
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 15:50:50 +0000 (16:50 +0100)] 
gccrs: Add validation pass for label name

Prevent from using reserved keyword in label name.

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check if there is
a label before visit.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Emit an
error when a label has a forbidden name.
* checks/errors/rust-ast-validation.h: Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Use a loop label in break expression
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 15:34:19 +0000 (16:34 +0100)] 
gccrs: Use a loop label in break expression

Break expression were using a raw lifetime value instead of a loop label
this behavior would have lead to some errors in ast validation.

gcc/rust/ChangeLog:

* ast/rust-expr.h (class BreakExpr): Change Lifetime to LoopLabel.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower lifetime
inside the label instead.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve the
inner lifetime.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Use keyword const values instead of raw values
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 14:22:33 +0000 (15:22 +0100)] 
gccrs: Use keyword const values instead of raw values

Change the keyword values from a raw string value to their matching const
value in utils.

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::parse_raw_identifier): Use const value.
* parse/rust-parse-impl.h (Parser::parse_simple_path_segment):
Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Change keyword set to a map
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 13:54:51 +0000 (14:54 +0100)] 
gccrs: Change keyword set to a map

Some part of the code requires the token id behind a given keyword, a map
keep the "set" aspect whilst providing this additional feature.

gcc/rust/ChangeLog:

* lex/rust-lex.cc (RS_TOKEN): Remove local map.
(RS_TOKEN_KEYWORD): Likewise.
(Lexer::classify_keyword): Change call to utils.
* util/rust-keyword-values.cc (get_keywords): Add init function.
(RS_TOKEN_KEYWORD): Call to X macro.
* util/rust-keyword-values.h: Change from set to a map.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Replace local keyword set with the utils
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 09:57:48 +0000 (10:57 +0100)] 
gccrs: Replace local keyword set with the utils

We don't require that local set anymore.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (RS_TOKEN): Remove locale set.
(RS_TOKEN_KEYWORD): Likewise.
(ASTValidation::visit): Change keyword set call to the one from utils.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add new keyword utility class
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 09:50:00 +0000 (10:50 +0100)] 
gccrs: Add new keyword utility class

Much like attributes values, keywords are known beforehand and never
change. Instead of relying on handcrafted string we could centralize
everything in one place. We may require to check whether a word is a
keyword, which can now be done easily thanks to the keyword set.

gcc/rust/ChangeLog:

* Make-lang.in: Add rust-keyword-values.cc to the list.
* util/rust-keyword-values.cc: New file.
* util/rust-keyword-values.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
8 months agogccrs: Add licence text and change header guard name
Pierre-Emmanuel Patry [Wed, 8 Nov 2023 09:46:22 +0000 (10:46 +0100)] 
gccrs: Add licence text and change header guard name

This file was missing a licence text and it's header guard was not
matching the file name.

gcc/rust/ChangeLog:

* util/rust-attribute-values.h (RUST_ATTRIBUTES_VALUE_H): Remove old
header guard.
(RUST_ATTRIBUTE_VALUES_H): Add new one.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>