Compare commits

...
1691 Commits
Author SHA1 Message Date
Jiawei f1b04c0389 RISC-V: Minimal support for Zimop extension.
This patch support Zimop and Zcmop extension[1].To enable GCC to recognize
and process Zimop and Zcmop extension correctly at compile time.

https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc: New extension.
	* config/riscv/riscv.opt: New mask.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-42.c: New test.
	* gcc.target/riscv/arch-43.c: New test.
2025-07-29 10:55:21 +08:00
Jiawei 45db857e4e testsuite: Fix RISC-V arch-52.c format issue.
Fix incorrect regular expression.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-52.c: Fix regular expression.
2025-07-29 09:45:58 +08:00
Jiawei 3737d5ad2e RISC-V: Support RISC-V Profiles 23.
This patch introduces support for RISC-V Profiles RV23A and RV23B [1],
enabling developers to utilize these profiles through the -march option.

[1] https://github.com/riscv/riscv-profiles/releases/tag/rva23-rvb23-ratified

Version log:
Update the testcases, using lowercase letter.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc: New profile.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-53.c: New test.
	* gcc.target/riscv/arch-54.c: New test.
2025-07-29 08:45:24 +08:00
Jiawei 5420fcccc0 RISC-V: Support RISC-V Profiles 20/22.
This patch introduces support for RISC-V Profiles RV20 and RV22 [1],
enabling developers to utilize these profiles through the -march option.

[1] https://github.com/riscv/riscv-profiles/releases/tag/v1.0

Version log:
Using lowercase letters to present Profiles.
Using '_' as divsor between Profiles and other RISC-V extension.
Add descriptions in invoke.texi.
Checking if there exist '_' between Profiles and additional extensions.
Using std::string to avoid memory problems.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (struct riscv_profiles): New struct.
	(riscv_subset_list::parse_profiles): New parser.
	(riscv_subset_list::parse_base_ext): Ditto.
	* config/riscv/riscv-subset.h: New def.
	* doc/invoke.texi: New option descriptions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-49.c: New test.
	* gcc.target/riscv/arch-50.c: New test.
	* gcc.target/riscv/arch-51.c: New test.
	* gcc.target/riscv/arch-52.c: New test.
2025-07-29 08:45:17 +08:00
Dongyan Chen eea49b547c RISC-V: Describe -march behavior for dependent extensions
commit 70f6bc39c4
Author: Palmer Dabbelt <palmer@rivosinc.com>

    gcc/ChangeLog:

            * doc/invoke.texi: Describe -march behavior for dependent extensions on
            RISC-V.
2025-07-28 16:00:49 +08:00
Dongyan ChenandPatrick O'Neill 1c1a108239 RISC-V: Add support for Zabha extension
The Zabha extension adds support for subword Zaamo ops.

    Extension: https://github.com/riscv/riscv-zabha.git
    Ratification: https://jira.riscv.org/browse/RVS-1685

commit 7b2b2e3d66
Author: Gianluca Guida <gianluca@rivosinc.com>

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc
            (riscv_subset_list::to_string): Skip zabha when not supported by
            the assembler.
            * config.in: Regenerate.
            * config/riscv/arch-canonicalize: Make zabha imply zaamo.
            * config/riscv/iterators.md (amobh): Add iterator for amo
            byte/halfword.
            * config/riscv/riscv.opt: Add zabha.
            * config/riscv/sync.md (atomic_<atomic_optab><mode>): Add
            subword atomic op pattern.
            (zabha_atomic_fetch_<atomic_optab><mode>): Add subword
            atomic_fetch op pattern.
            (lrsc_atomic_fetch_<atomic_optab><mode>): Prefer zabha over lrsc
            for subword atomic ops.
            (zabha_atomic_exchange<mode>): Add subword atomic exchange
            pattern.
            (lrsc_atomic_exchange<mode>): Prefer zabha over lrsc for subword
            atomic exchange ops.
            * configure: Regenerate.
            * configure.ac: Add zabha assembler check.
            * doc/sourcebuild.texi: Add zabha documentation.

    gcc/testsuite/ChangeLog:

            * lib/target-supports.exp: Add zabha testsuite infra support.
            * gcc.target/riscv/amo/inline-atomics-1.c: Remove zabha to continue to
            test the lr/sc subword patterns.
            * gcc.target/riscv/amo/inline-atomics-2.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acq-rel.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acquire.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-relaxed.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-release.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-seq-cst.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acq-rel.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acquire.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-relaxed.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-release.c: Ditto.
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-seq-cst.c: Ditto.
            * gcc.target/riscv/amo/zabha-all-amo-ops-char-run.c: New test.
            * gcc.target/riscv/amo/zabha-all-amo-ops-short-run.c: New test.
            * gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-char.c: New test.
            * gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-short.c: New test.
            * gcc.target/riscv/amo/zabha-rvwmo-amo-add-char.c: New test.
            * gcc.target/riscv/amo/zabha-rvwmo-amo-add-short.c: New test.
            * gcc.target/riscv/amo/zabha-ztso-amo-add-char.c: New test.
            * gcc.target/riscv/amo/zabha-ztso-amo-add-short.c: New test.

    Co-Authored-By: Patrick O'Neill <patrick@rivosinc.com>
    Signed-Off-By: Gianluca Guida <gianluca@rivosinc.com>
    Tested-by: Andrea Parri <andrea@rivosinc.com>
2025-07-28 16:00:49 +08:00
Dongyan Chen 9cf625b8b2 RISC-V: Implement -m{,no}fence-tso
Some processors from T-Head don't implement the `fence.tso` instruction
natively and instead trap to firmware.  This breaks some users who
haven't yet updated the firmware and one could imagine it breaking users
who are trying to build firmware if they're using the C memory model.

So just add an option to disable emitting it, in a similar fashion to
how we allow users to forbid other instructions.

Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070959
---
I've just smoke tested this one, but

    void func(void) { __atomic_thread_fence(__ATOMIC_ACQ_REL); }

generates `fence.tso` without the argument and `fence rw,rw` with
`-mno-fence-tso`, so it seems to be at least mostly there.  I figured
I'd just send it up for comments before putting together the DG bits:
it's kind of a pain to carry around these workarounds for unimplemented
instructions, but it's in HW so there's not much we can do about that.

commit a6114c2a69
Author: Palmer Dabbelt <palmer@rivosinc.com>

gcc/ChangeLog:

	* config/riscv/riscv.opt: Add -mno-fence-tso.
	* config/riscv/sync-rvwmo.md (mem_thread_fence_rvwmo): Respect
	-mno-fence-tso.
	* doc/invoke.texi (RISC-V): Document -mno-fence-tso.
2025-07-28 16:00:49 +08:00
Dongyan Chen 22ac08720e RISC-V: Consolidate amo testcase variants
Many riscv/amo/ testcases use check-function-bodies. These testcases can be
    consolidated with related testcases (memory ordering variants) without affecting
    the assertions.

    Give functions descriptive names so testsuite failures are obvious from the
    'FAIL:' line.

commit aa89e86f70
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-fence-1.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-fence-2.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-fence-3.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-fence-4.c: Removed.
            * gcc.target/riscv/amo/amo-table-a-6-fence-5.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-fence-1.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-fence-2.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-fence-3.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-fence-4.c: Removed.
            * gcc.target/riscv/amo/amo-table-ztso-fence-5.c: Removed.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: Removed.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: Removed.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: Removed.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: Removed.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: Removed.
            * gcc.target/riscv/amo/a-rvwmo-fence.c: New test.
            * gcc.target/riscv/amo/a-ztso-fence.c: New test.
            * gcc.target/riscv/amo/zaamo-rvwmo-amo-add-int.c: New test.
            * gcc.target/riscv/amo/zaamo-ztso-amo-add-int.c: New test.
            * gcc.target/riscv/amo/zalrsc-rvwmo-amo-add-int.c: New test.
            * gcc.target/riscv/amo/zalrsc-ztso-amo-add-int.c: New test.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:49 +08:00
Dongyan Chen f31fec659c RISC-V: Rename amo testcases
Rename riscv/amo/ testcases to follow a '{ext}-{model}-{name}-{memory order}.c'
    naming convention.

commit 08498f81f0
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-load-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-load-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-load-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-store-compat-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-store-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Move to...
            * gcc.target/riscv/amo/a-rvwmo-store-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-load-2.c: Move to...
            * gcc.target/riscv/amo/a-ztso-load-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-load-1.c: Move to...
            * gcc.target/riscv/amo/a-ztso-load-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-load-3.c: Move to...
            * gcc.target/riscv/amo/a-ztso-load-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-store-3.c: Move to...
            * gcc.target/riscv/amo/a-ztso-store-compat-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-store-1.c: Move to...
            * gcc.target/riscv/amo/a-ztso-store-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-store-2.c: Move to...
            * gcc.target/riscv/amo/a-ztso-store-release.c: ...here.
            * gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c: Move to...
            * gcc.target/riscv/amo/zaamo-preferred-over-zalrsc.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-consume.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acq-rel.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-consume.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acq-rel.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acquire.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-relaxed.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-release.c: ...here.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-seq-cst.c: ...here.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:49 +08:00
Dongyan Chen 8e0a44d6e6 RISC-V: Add dg-remove-option for z* extensions
This introduces testsuite support infra for removing extensions.
    Since z* extensions don't have ordering requirements the logic for
    adding/removing those extensions has also been consolidated.

    This fixes RVWMO compile testcases failing on Ztso targets by removing
    the extension from the -march string.

commit 580c37f1ef
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/ChangeLog:

            * doc/sourcebuild.texi (dg-remove-option): Add documentation.
            (dg-add-option): Add documentation for riscv_{a,zaamo,zalrsc,ztso}

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: Add dg-remove-options
            for ztso.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-fence-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-fence-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-fence-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-fence-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-fence-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: Replace manually
            specified -march string with dg-add/remove-options directives.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: Ditto.
            * lib/target-supports-dg.exp: Add dg-remove-options.
            * lib/target-supports.exp: Add dg-remove-options and consolidate z*
            extension add/remove-option code.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:49 +08:00
Dongyan Chen 224e94c0ec RISC-V: Promote Zaamo/Zalrsc to a when using an old binutils
Binutils 2.42 and before don't support Zaamo/Zalrsc. When users specify
    both Zaamo and Zalrsc, promote them to 'a' in the -march string.

    This does not affect testsuite results for users with old versions of binutils.
    Testcases that failed due to 'call'/isa string continue to fail after this PATCH
    when using an old version of binutils.

commit e03583e
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc: Add 'a' extension to
            riscv_combine_info.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:49 +08:00
Dongyan Chen e314793f36 RISC-V: Add configure check for Zaamo/Zalrsc assembler support
RISC-V: Add configure check for Zaamo/Zalrsc assembler support
    Binutils 2.42 and before don't support Zaamo/Zalrsc. Add a configure
    check to prevent emitting Zaamo/Zalrsc in the arch string when the
    assember does not support it.

commit 4f18f75
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc
            (riscv_subset_list::to_string): Skip zaamo/zalrsc when not
            supported by the assembler.
            * config.in: Regenerate.
            * configure: Regenerate.
            * configure.ac: Add zaamo/zalrsc assmeber check.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
    Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
2025-07-28 16:00:48 +08:00
Dongyan Chen 7301fc98a4 RISC-V: Allow any temp register to be used in amo tests
We artifically restrict the temp registers to be a[0-9]+ when other
    registers like t[0-9]+ are valid too. Update to make the regex
    accept any register for the temp value.

commit 439c0cc
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Update temp register regex.
            * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-load-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-load-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-load-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-store-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-store-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-store-3.c: Ditto.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
Dongyan Chen bdb8ea7ab2 RISC-V: Fix amoadd call arguments
Update __atomic_add_fetch arguments to be a pointer and value rather
    than two pointers.

commit 6343adc
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: Update
            __atomic_add_fetch args.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: Ditto.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
Dongyan Chen 1ad2a01c95 RISC-V: Move amo tests into subfolder
There's a large number of atomic related testcases in the riscv folder.
    Move them into a subfolder similar to what was done for rvv testcases.

commit 8c944f2
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: ...here.
            * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c: ...here.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c: ...here.
            * gcc.target/riscv/amo-table-a-6-fence-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-fence-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-fence-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-fence-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-fence-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-fence-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-fence-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-fence-4.c: ...here.
            * gcc.target/riscv/amo-table-a-6-fence-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-fence-5.c: ...here.
            * gcc.target/riscv/amo-table-a-6-load-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-load-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-load-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-load-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-load-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-load-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-store-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-store-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-store-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-store-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-store-compat-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: ...here.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: ...here.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: ...here.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: ...here.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: ...here.
            * gcc.target/riscv/amo-table-ztso-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c: ...here.
            * gcc.target/riscv/amo-table-ztso-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-6.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c: ...here.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-7.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c: ...here.
            * gcc.target/riscv/amo-table-ztso-fence-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-fence-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-fence-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-fence-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-fence-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-fence-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-fence-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-fence-4.c: ...here.
            * gcc.target/riscv/amo-table-ztso-fence-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-fence-5.c: ...here.
            * gcc.target/riscv/amo-table-ztso-load-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-load-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-load-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-load-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-load-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-load-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-store-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-store-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-store-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-store-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-store-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-store-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c: ...here.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c: ...here.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c: ...here.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c: ...here.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c: ...here.
            * gcc.target/riscv/amo-zaamo-preferred-over-zalrsc.c: Move to...
            * gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c: ...here.
            * gcc.target/riscv/amo-zalrsc-amo-add-1.c: Move to...
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: ...here.
            * gcc.target/riscv/amo-zalrsc-amo-add-2.c: Move to...
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: ...here.
            * gcc.target/riscv/amo-zalrsc-amo-add-3.c: Move to...
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: ...here.
            * gcc.target/riscv/amo-zalrsc-amo-add-4.c: Move to...
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: ...here.
            * gcc.target/riscv/amo-zalrsc-amo-add-5.c: Move to...
            * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: ...here.
            * gcc.target/riscv/inline-atomics-1.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-1.c: ...here.
            * gcc.target/riscv/inline-atomics-2.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-2.c: ...here.
            * gcc.target/riscv/inline-atomics-3.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-3.c: ...here.
            * gcc.target/riscv/inline-atomics-4.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-4.c: ...here.
            * gcc.target/riscv/inline-atomics-5.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-5.c: ...here.
            * gcc.target/riscv/inline-atomics-6.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-6.c: ...here.
            * gcc.target/riscv/inline-atomics-7.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-7.c: ...here.
            * gcc.target/riscv/inline-atomics-8.c: Move to...
            * gcc.target/riscv/amo/inline-atomics-8.c: ...here.
            * gcc.target/riscv/pr114130.c: Move to...
            * gcc.target/riscv/amo/pr114130.c: ...here.
            * gcc.target/riscv/pr89835.c: Move to...
            * gcc.target/riscv/amo/pr89835.c: ...here.
            * gcc.target/riscv/amo/amo.exp: New file.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
Dongyan Chen aab6f6c6c4 RISC-V: Add Zalrsc amo-op patterns
All amo<op> patterns can be represented with lrsc sequences.
    Add these patterns as a fallback when Zaamo is not enabled.

commit 1588983
Author: Patrick O'Neill <patrick@rivosinc.com>

    gcc/ChangeLog:

            * config/riscv/sync.md (atomic_<atomic_optab><mode>): New expand pattern.
            (amo_atomic_<atomic_optab><mode>): Rename amo pattern.
            (atomic_fetch_<atomic_optab><mode>): New lrsc sequence pattern.
            (lrsc_atomic_<atomic_optab><mode>): New expand pattern.
            (amo_atomic_fetch_<atomic_optab><mode>): Rename amo pattern.
            (lrsc_atomic_fetch_<atomic_optab><mode>): New lrsc sequence pattern.
            (atomic_exchange<mode>): New expand pattern.
            (amo_atomic_exchange<mode>): Rename amo pattern.
            (lrsc_atomic_exchange<mode>): New lrsc sequence pattern.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo-zaamo-preferred-over-zalrsc.c: New test.
            * gcc.target/riscv/amo-zalrsc-amo-add-1.c: New test.
            * gcc.target/riscv/amo-zalrsc-amo-add-2.c: New test.
            * gcc.target/riscv/amo-zalrsc-amo-add-3.c: New test.
            * gcc.target/riscv/amo-zalrsc-amo-add-4.c: New test.
            * gcc.target/riscv/amo-zalrsc-amo-add-5.c: New test.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
YunQiang Su 16a32a839f RISC-V: Fix testsuite for Zalrsc and Zaamo
`.option arch,` in asm files are now using 'zaamo1p0_zalrsc1p0'.
Let's fix them in target-attr testcases.

gcc/testsuite/ChangeLog:
	* gcc.target/riscv/target-attr-01.c: Add zaamo1p0_zalrsc1p0
	into .option arch.
	* gcc.target/riscv/target-attr-02.c: Ditto.
	* gcc.target/riscv/target-attr-08.c: Ditto.
	* gcc.target/riscv/target-attr-11.c: Ditto.
	* gcc.target/riscv/target-attr-14.c: Ditto.
	* gcc.target/riscv/target-attr-15.c: Ditto.
	* gcc.target/riscv/target-attr-16.c: Ditto.
2025-07-28 16:00:48 +08:00
Dongyan Chen af096c2d90 RISC-V: Add Zalrsc and Zaamo testsuite support
Convert testsuite infrastructure to use Zalrsc and Zaamo rather than A.

commit 0fea902b1b
Author: Patrick O'Neill <patrick@rivosinc.com>

Add the zvbb code in lib/target-supports.exp according to the
commit 309ee005aa
Author: Robin Dapp <rdapp@ventanamicro.com>

    gcc/ChangeLog:

            * doc/sourcebuild.texi: Add docs for atomic extension testsuite infra.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Use Zaamo rather than A.
            * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Use Zalrsc rather
            than A.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Use Zaamo rather
            than A.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-amo-add-1.c: Add Zaamo option.
            * gcc.target/riscv/amo-table-ztso-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-amo-add-5.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-1.c: Use Zalrsc rather
            than A.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-2.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-3.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-4.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-5.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-6.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-compare-exchange-7.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c: Ditto.
            * gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c: Ditto.
            * lib/target-supports.exp: Add testsuite infrastructure support for
            Zaamo and Zalrsc.

    Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
Dongyan ChenandPatrick O'Neill 45d3c35f18 RISC-V: Add basic Zaamo and Zalrsc support
There is a proposal to split the A extension into two parts: Zaamo and Zalrsc.
    This patch adds basic support by making the A extension imply Zaamo and
    Zalrsc.

    Proposal: https://github.com/riscv/riscv-zaamo-zalrsc/tags

commit af139b3fc1
Author: Edwin Lu <ewlu@rivosinc.com>

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc: Add Zaamo and Zalrsc.
            * config/riscv/arch-canonicalize: Make A imply Zaamo and Zalrsc.
            * config/riscv/riscv.opt: Add Zaamo and Zalrsc
            * config/riscv/sync.md: Convert TARGET_ATOMIC to TARGET_ZAAMO and
            TARGET_ZALRSC.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/attribute-15.c: Adjust expected arch string.
            * gcc.target/riscv/attribute-16.c: Ditto.
            * gcc.target/riscv/attribute-17.c: Ditto.
            * gcc.target/riscv/attribute-18.c: Ditto.
            * gcc.target/riscv/pr110696.c: Ditto.
            * gcc.target/riscv/rvv/base/pr114352-1.c: Ditto.
            * gcc.target/riscv/rvv/base/pr114352-3.c: Ditto.

    Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
    Co-authored-by: Patrick O'Neill <patrick@rivosinc.com>
2025-07-28 16:00:48 +08:00
Dongyan Chen bffdb84f8a RISC-V: Regenerate opt urls.
I wasn't aware that I needed to regenerate the opt urls when
adding an option.  This patch does that.

commit 037fc4d101
Author: Robin Dapp <rdapp@ventanamicro.com>

gcc/ChangeLog:

	* config/riscv/riscv.opt.urls: Regenerate.
2025-07-28 16:00:48 +08:00
Dongyan Chen a81000bf61 RISC-V: Introduce -mvector-strict-align.
this patch disables movmisalign by default and introduces
    the -mno-vector-strict-align option to override it and re-enable
    movmisalign.  For now, generic-ooo is the only uarch that supports
    misaligned vector access.

    The patch also adds a check_effective_target_riscv_v_misalign_ok to
    the testsuite which enables or disables the vector misalignment tests
    depending on whether the target under test can execute a misaligned
    vle32.

    Changes from v3:
     - Adressed Kito's comments.
     - Made -mscalar-strict-align a real alias.

commit 68b0742a49
Author: Robin Dapp <rdapp.gcc@gmail.com>

The original patch commited base the code of `check_effective_target_riscv_zvbb_ok` in
target-supports.exp, but this commit based code hasn't so i add this, mabey the former
patch has this.

    gcc/ChangeLog:

            * config/riscv/riscv-opts.h (TARGET_VECTOR_MISALIGN_SUPPORTED):
            Move from here...
            * config/riscv/riscv.h (TARGET_VECTOR_MISALIGN_SUPPORTED):
            ...to here and map to riscv_vector_unaligned_access_p.
            * config/riscv/riscv.opt: Add -mvector-strict-align.
            * config/riscv/riscv.cc (struct riscv_tune_param): Add
            vector_unaligned_access.
            (riscv_override_options_internal): Set
            riscv_vector_unaligned_access_p.
            * doc/invoke.texi: Document -mvector-strict-align.

    gcc/testsuite/ChangeLog:

            * lib/target-supports.exp: Add
            check_effective_target_riscv_v_misalign_ok.
            * gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-7.c: Add
            -mno-vector-strict-align.
            * gcc.dg/vect/costmodel/riscv/rvv/vla_vs_vls-10.c: Ditto.
            * gcc.dg/vect/costmodel/riscv/rvv/vla_vs_vls-11.c: Ditto.
            * gcc.dg/vect/costmodel/riscv/rvv/vla_vs_vls-12.c: Ditto.
            * gcc.dg/vect/costmodel/riscv/rvv/vla_vs_vls-8.c: Ditto.
            * gcc.dg/vect/costmodel/riscv/rvv/vla_vs_vls-9.c: Ditto.
            * gcc.target/riscv/rvv/autovec/vls/misalign-1.c: Ditto.
2025-07-28 16:00:48 +08:00
Dongyan Chen 2252aa9a40 RISC-V: Add Zfbfmin extension
1 In the previous patch, the libcall for BF16 was implemented:
    <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8c7cee80eb50792e57d514be1418c453ddd1073e>

    2 Riscv provides Zfbfmin extension, which completes the "Scalar BF16 Converts":
    <https://github.com/riscv/riscv-bfloat16/blob/main/doc/riscv-bfloat16-zfbfmin.adoc>

    3 Implemented replacing libcall with Zfbfmin extension instruction.

    4 Reused previous testcases in:
    <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8c7cee80eb50792e57d514be1418c453ddd1073e>

commit 4638e508aa
Author: Xiao Zeng <zengxiao@eswincomputing.com>

    gcc/ChangeLog:

            * config/riscv/iterators.md: Add mode_iterator between
            floating-point modes and BFmode.
            * config/riscv/riscv.cc (riscv_output_move): Handle BFmode move
            for zfbfmin.
            * config/riscv/riscv.md (trunc<mode>bf2): New pattern for BFmode.
            (extendbfsf2): Dotto.
            (*movhf_hardfloat): Add BFmode.
            (*mov<mode>_hardfloat): Dotto.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/zfbfmin-bf16_arithmetic.c: New test.
            * gcc.target/riscv/zfbfmin-bf16_comparison.c: New test.
            * gcc.target/riscv/zfbfmin-bf16_float_libcall_convert.c: New test.
            * gcc.target/riscv/zfbfmin-bf16_integer_libcall_convert.c: New test.
2025-07-28 16:00:48 +08:00
Dongyan Chen 46f80d0495 RISC-V: Add Zvfbfwma extension to the -march= option
This patch would like to add new sub extension (aka Zvfbfwma) to the
    -march= option. It introduces a new data type BF16.

    1 In spec: "Zvfbfwma requires the Zvfbfmin extension and the Zfbfmin extension."
      1.1 In Embedded    Processor: Zvfbfwma -> Zvfbfmin -> Zve32f
      1.2 In Application Processor: Zvfbfwma -> Zvfbfmin -> V
      1.3 In both scenarios, there are: Zvfbfwma -> Zfbfmin

    2 Zvfbfmin's information is in:
    <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1ddf65c5fc6ba7cf5826e1c02c569c923a541c09>

    3 Zfbfmin's formation is in:
    <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=35224ead63732a3550ba4b1332c06e9dc7999c31>

    4 Depending on different usage scenarios, the Zvfbfwma extension may
    depend on 'V' or 'Zve32f'. This patch only implements dependencies in
    scenario of Embedded Processor. This is consistent with the processing
    strategy in Zvfbfmin. In scenario of Application Processor, it is
    necessary to explicitly indicate the dependent 'V' extension.

    5 You can locate more information about Zvfbfwma from below spec doc:
    <https://github.com/riscv/riscv-bfloat16/releases/download/v59042fc71c31a9bcb2f1957621c960ed36fac401/riscv-bfloat16.pdf>

We also add M extension to the testcases, as RISC-V Vector requires M extension since:
 b7d9759450

commit 38dd4e26e0
Author: Xiao Zeng <zengxiao@eswincomputing.com>

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc:
            (riscv_implied_info): Add zvfbfwma item.
            (riscv_ext_version_table): Ditto.
            (riscv_ext_flag_table): Ditto.
            * config/riscv/riscv.opt:
            (MASK_ZVFBFWMA): New macro.
            (TARGET_ZVFBFWMA): Ditto.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/arch-37.c: New test.
            * gcc.target/riscv/arch-38.c: New test.
            * gcc.target/riscv/predef-36.c: New test.
            * gcc.target/riscv/predef-37.c: New test.
2025-07-28 16:00:47 +08:00
Dongyan Chen 8e784464da RISC-V: Fix format issue for trailing operator [NFC]
This patch would like to fix below format issue of trailing operator.

    === ERROR type #1: trailing operator (4 error(s)) ===
    gcc/config/riscv/riscv-vector-builtins.cc:4641:39:  if ((exts &
    RVV_REQUIRE_ELEN_FP_16) &&
    gcc/config/riscv/riscv-vector-builtins.cc:4651:39:  if ((exts &
    RVV_REQUIRE_ELEN_FP_32) &&
    gcc/config/riscv/riscv-vector-builtins.cc:4661:39:  if ((exts &
    RVV_REQUIRE_ELEN_FP_64) &&
    gcc/config/riscv/riscv-vector-builtins.cc:4670:36:  if ((exts &
    RVV_REQUIRE_ELEN_64) &&

    Passed the ./contrib/check_GNU_style.sh for this patch,  and double
    checked there is no other format issue of the original patch.

    Committed as format change.

commit b6dc8464e6
Author: Pan Li <pan2.li@intel.com>

    gcc/ChangeLog:

            * config/riscv/riscv-vector-builtins.cc
            (validate_instance_type_required_extensions): Remove the
            operator from the trailing and put it to new line.

    Signed-off-by: Pan Li <pan2.li@intel.com>
2025-07-28 16:00:47 +08:00
Dongyan Chen 794c983775 RISC-V: Fix typos in code or comment [NFC]
Just found some typo when fixing bugs and then use aspell to find few
more typos, this patch didn't do anything other than fix typo.

commit d83070a
Author: Kito Cheng kito.cheng@sifive.com

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: Fix typos in comments.
	(get_all_predecessors): Ditto.
	(pre_vsetvl::m_unknow_info): Rename to...
	(pre_vsetvl::m_unknown_info): this.
	(pre_vsetvl::compute_vsetvl_def_data): Rename m_unknow_info to
	m_unknown_info.
	(pre_vsetvl::cleaup): Rename to...
	(pre_vsetvl::cleanup): this.
	(pre_vsetvl::compute_vsetvl_def_data): Fix typos.
	(pass_vsetvl::lazy_vsetvl): Update function name and fix typos.
	* config/riscv/riscv.cc: Fix typos in comments.
	(struct machine_function): Fix typo in comments.
	(riscv_valid_lo_sum_p): Ditto.
	(riscv_force_address): Ditto.
	(riscv_immediate_operand_p): Ditto.
	(riscv_in_small_data_p): Ditto.
	(riscv_first_stack_step): Ditto.
	(riscv_expand_prologue): Ditto.
	(riscv_convert_vector_chunks): Ditto.
	(riscv_override_options_internal): Ditto.
	(get_common_costs): Ditto.
2025-07-28 16:00:47 +08:00
Dongyan Chen 2845c9aac2 [PATCH 1/1] RISC-V: Add Zfbfmin extension to the -march= option
This patch would like to add new sub extension (aka Zfbfmin) to the
    -march= option. It introduces a new data type BF16.

    1 The Zfbfmin extension depend on 'F', and the FLH, FSH, FMV.X.H, and
    FMV.H.X instructions as defined in the Zfh extension.

    2 The Zfhmin extension includes the following instructions from the
    Zfh extension: FLH, FSH, FMV.X.H, FMV.H.X, FCVT.S.H, and FCVT.H.S.

    3 Zfhmin extension depend on 'F'.

    4 Simply put, just make Zfbfmin dependent on Zfhmin.

    Perhaps in the future, we could propose making the FLH, FSH, FMV.X.H, and
    FMV.H.X instructions an independent extension to achieve precise dependency
    relationships for the Zfbfmin.

    You can locate more information about Zfbfmin from below spec doc.

    <https://github.com/riscv/riscv-bfloat16/releases/download/v59042fc71c31a9bcb2f1957621c960ed36fac401/riscv-bfloat16.pdf>

commit 35224ead63
Author: Xiao Zeng <zengxiao@eswincomputing.com>

    gcc/
            * common/config/riscv/riscv-common.cc (riscv_implied_info): zfbfmin
            implies zfhmin.
            (riscv_ext_version_table, riscv_ext_flag_table): Add zfbfmin.
            * config/riscv/riscv.opt (ZFBFMIN): Add optoion.

    gcc/testsuite/
            * gcc.target/riscv/arch-35.c: New test.
            * gcc.target/riscv/arch-36.c: New test.
            * gcc.target/riscv/predef-34.c: New test.
            * gcc.target/riscv/predef-35.c: New test.
2025-07-28 16:00:47 +08:00
Xiao Zeng 542574da26 RISC-V: Modify _Bfloat16 to __bf16
According to the description in:
<https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/367>,
the type representation symbol of BF16 has been corrected.

Kito Cheng pointed out relevant information in the email:
<https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651850.html>

commit 6da1d6efde
Author: Xiao Zeng <zengxiao@eswincomputing.com>
Date:   Fri May 17 13:48:21 2024 +0800

gcc/ChangeLog:

	* config/riscv/riscv-builtins.cc (riscv_init_builtin_types):
	Modify _Bfloat16 to __bf16.
	* config/riscv/riscv.cc (riscv_mangle_type): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/_Bfloat16-nanboxing.c: Move to...
	* gcc.target/riscv/__bf16-nanboxing.c: ...here.
	* gcc.target/riscv/bf16_arithmetic.c: Modify _Bfloat16 to __bf16.
	* gcc.target/riscv/bf16_call.c: Ditto.
	* gcc.target/riscv/bf16_comparison.c: Ditto.
	* gcc.target/riscv/bf16_float_libcall_convert.c: Ditto.
	* gcc.target/riscv/bf16_integer_libcall_convert.c: Ditto.
2025-07-28 16:00:31 +08:00
Xiao Zeng 7324bacca5 RISC-V: Nan-box the result of movbf on soft-bf16
1 This patch implements the Nan-box of bf16.

2 Please refer to the Nan-box implementation of hf16 in:
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=057dc349021660c40699fb5c98fd9cac8e168653>

3 The discussion about Nan-box can be found on the website:
<https://www.mail-archive.com/search?q=Nan-box+the+result+of+movhf+on+soft-fp16&l=gcc-patches%40gcc.gnu.org>

4 Below test are passed for this patch
        * The riscv fully regression test.

commit ce51e6727c
Author: Xiao Zeng <zengxiao@eswincomputing.com>
Date:   Wed May 8 14:00:58 2024 -0600

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_legitimize_move): Expand movbf
	with Nan-boxing value.
	* config/riscv/riscv.md (*movbf_softfloat_boxing): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/_Bfloat16-nanboxing.c: New test.
2025-07-28 15:59:24 +08:00
Dongyan Chen 136772da85 [RISC-V] Add support for _Bfloat16
1 At point <https://github.com/riscv/riscv-bfloat16>,
      BF16 has already been completed "post public review".

    2 LLVM has also added support for RISCV BF16 in
      <https://reviews.llvm.org/D151313> and
      <https://reviews.llvm.org/D150929>.

    3 According to the discussion <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/367>,
      this use __bf16 and use DF16b in riscv_mangle_type like x86.

    Below test are passed for this patch
        * The riscv fully regression test.

commit 8c7cee80eb
Author: Xiao Zeng <zengxiao@eswincomputing.com>

    gcc/ChangeLog:

            * config/riscv/iterators.md: New mode iterator HFBF.
            * config/riscv/riscv-builtins.cc (riscv_init_builtin_types):
            Initialize data type _Bfloat16.
            * config/riscv/riscv-modes.def (FLOAT_MODE): New.
            (ADJUST_FLOAT_FORMAT): New.
            * config/riscv/riscv.cc (riscv_mangle_type): Support for BFmode.
            (riscv_scalar_mode_supported_p): Ditto.
            (riscv_libgcc_floating_mode_supported_p): Ditto.
            (riscv_init_libfuncs): Set the conversion method for BFmode and
            HFmode.
            (riscv_block_arith_comp_libfuncs_for_mode): Set the arithmetic
            and comparison libfuncs for the mode.
            * config/riscv/riscv.md (mode" ): Add BF.
            (movhf): Support for BFmode.
            (mov<mode>): Ditto.
            (*movhf_softfloat): Ditto.
            (*mov<mode>_softfloat): Ditto.

    libgcc/ChangeLog:

            * config/riscv/sfp-machine.h (_FP_NANFRAC_B): New.
            (_FP_NANSIGN_B): Ditto.
            * config/riscv/t-softfp32: Add support for BF16 libfuncs.
            * config/riscv/t-softfp64: Ditto.
            * soft-fp/floatsibf.c: For si -> bf16.
            * soft-fp/floatunsibf.c: For unsi -> bf16.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/bf16_arithmetic.c: New test.
            * gcc.target/riscv/bf16_call.c: New test.
            * gcc.target/riscv/bf16_comparison.c: New test.
            * gcc.target/riscv/bf16_float_libcall_convert.c: New test.
            * gcc.target/riscv/bf16_integer_libcall_convert.c: New test.

    Co-authored-by: Jin Ma <jinma@linux.alibaba.com>
2025-07-26 14:03:44 +08:00
Dongyan Chen fa510c23b8 RISC-V: Document -mcmodel=large
This slipped through the cracks.  Probably also NEWS-worthy.

commit 6ffea3e373
Author: Palmer Dabbelt <palmer@rivosinc.com>

gcc/ChangeLog:

	* doc/invoke.texi (RISC-V): Add -mcmodel=large.
2025-07-26 14:00:47 +08:00
Richard Biener c9cd41fba9 Update ChangeLog and version files for release 2025-05-23 11:02:58 +00:00
GCC Administrator 2eba786532 Daily bump. 2025-05-23 00:23:06 +00:00
Martin Jambor 92d8b9970e tree-sra: Do not create stores into const aggregates (PR111873)
This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates.  It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.

I have used testcases from duplicates because the original test-case
no longer reproduces for me.

gcc/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/111873
	* tree-sra.cc (sra_modify_expr): When processing a load which has
	a type-incompatible replacement, do not store the contents of the
	replacement into the original aggregate when that aggregate is
	const.

gcc/testsuite/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

	* gcc.dg/ipa/pr120044-1.c: New test.
	* gcc.dg/ipa/pr120044-2.c: Likewise.
	* gcc.dg/tree-ssa/pr114864.c: Likewise.

(cherry picked from commit 9d039eff45)
2025-05-22 23:10:58 +02:00
GCC Administrator d36a87c276 Daily bump. 2025-05-22 00:23:11 +00:00
GCC Administrator a7665128c5 Daily bump. 2025-05-21 00:23:07 +00:00
GCC Administrator 8a6e2f7148 Daily bump. 2025-05-20 00:23:52 +00:00
GCC Administrator b264cc293e Daily bump. 2025-05-19 00:21:05 +00:00
GCC Administrator 33d344bd90 Daily bump. 2025-05-18 00:21:12 +00:00
GCC Administrator 0d1a578d63 Daily bump. 2025-05-17 00:21:38 +00:00
GCC Administrator a9de71c206 Daily bump. 2025-05-16 00:23:13 +00:00
Jakub Jelinek aa4cd61445 i386: Change RTL representation of bt[lq] [PR118623]
The following testcase is miscompiled because of RTL represententation
of bt{l,q} insn followed by e.g. j{c,nc} being misleading to what it
actually does.
Let's look e.g. at
(define_insn_and_split "*jcc_bt<mode>"
  [(set (pc)
        (if_then_else (match_operator 0 "bt_comparison_operator"
                        [(zero_extract:SWI48
                           (match_operand:SWI48 1 "nonimmediate_operand")
                           (const_int 1)
                           (match_operand:QI 2 "nonmemory_operand"))
                         (const_int 0)])
                      (label_ref (match_operand 3))
                      (pc)))
   (clobber (reg:CC FLAGS_REG))]
  "(TARGET_USE_BT || optimize_function_for_size_p (cfun))
   && (CONST_INT_P (operands[2])
       ? (INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)
          && INTVAL (operands[2])
               >= (optimize_function_for_size_p (cfun) ? 8 : 32))
       : !memory_operand (operands[1], <MODE>mode))
   && ix86_pre_reload_split ()"
  "#"
  "&& 1"
  [(set (reg:CCC FLAGS_REG)
        (compare:CCC
          (zero_extract:SWI48
            (match_dup 1)
            (const_int 1)
            (match_dup 2))
          (const_int 0)))
   (set (pc)
        (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)])
                      (label_ref (match_dup 3))
                      (pc)))]
{
  operands[0] = shallow_copy_rtx (operands[0]);
  PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));
})
The define_insn part in RTL describes exactly what it does,
jumps to op3 if bit op2 in op1 is set (for op0 NE) or not set (for op0 EQ).
The problem is with what it splits into.
put_condition_code %C1 for CCCmode comparisons emits c for EQ and LTU,
nc for NE and GEU and ICEs otherwise.
CCCmode is used mainly for carry out of add/adc, borrow out of sub/sbb,
in those cases e.g. for add we have
(set (reg:CCC flags) (compare:CCC (plus:M x y) x))
and use (ltu (reg:CCC flags) (const_int 0)) for carry set and
(geu (reg:CCC flags) (const_int 0)) for carry not set.  These cases
model in RTL what is actually happening, compare in infinite precision
x from the result of finite precision addition in M mode and if it is
less than unsigned (i.e. overflow happened), carry is set.
Another use of CCCmode is in UNSPEC_* patterns, those are used with
(eq (reg:CCC flags) (const_int 0)) for carry set and ne for unset,
given the UNSPEC no big deal, the middle-end doesn't know what means
set or unset.
But for the bt{l,q}; j{c,nc} case the above splits it into
(set (reg:CCC flags) (compare:CCC (zero_extract) (const_int 0)))
for bt and
(set (pc) (if_then_else (eq (reg:CCC flags) (const_int 0)) (label_ref) (pc)))
for the bit set case (so that the jump expands to jc) and ne for
the bit not set case (so that the jump expands to jnc).
Similarly for the different splitters for cmov and set{c,nc} etc.
The problem is that when the middle-end reads this RTL, it feels
the exact opposite to it.  If zero_extract is 1, flags is set
to comparison of 1 and 0 and that would mean using ne ne in the
if_then_else, and vice versa.

So, in order to better describe in RTL what is actually happening,
one possibility would be to swap the behavior of put_condition_code
and use NE + LTU -> c and EQ + GEU -> nc rather than the current
EQ + LTU -> c and NE + GEU -> nc; and adjust everything.  The
following patch uses a more limited approach, instead of representing
bt{l,q}; j{c,nc} case as written above it uses
(set (reg:CCC flags) (compare:CCC (const_int 0) (zero_extract)))
and
(set (pc) (if_then_else (ltu (reg:CCC flags) (const_int 0)) (label_ref) (pc)))
which uses the existing put_condition_code but describes what the
insns actually do in RTL clearly.  If zero_extract is 1,
then flags are LTU, 0U < 1U, if zero_extract is 0, then flags are GEU,
0U >= 0U.  The patch adjusts the *bt<mode> define_insn and all the
splitters to it and its comparisons/conditional moves/setXX.

2025-02-10  Jakub Jelinek  <jakub@redhat.com>

	PR target/118623
	* config/i386/i386.md (*bt<mode>): Represent bt as
	compare:CCC of const0_rtx and zero_extract rather than
	zero_extract and const0_rtx.
	(*bt<SWI48:mode>_mask): Likewise.
	(*jcc_bt<mode>): Likewise.  Use LTU and GEU as flags test
	instead of EQ and NE.
	(*jcc_bt<mode>_mask): Likewise.
	(*jcc_bt<SWI48:mode>_mask_1): Likewise.
	(Help combine recognize bt followed by cmov splitter): Likewise.
	(*bt<mode>_setcqi): Likewise.
	(*bt<mode>_setncqi): Likewise.
	(*bt<mode>_setnc<mode>): Likewise.
	(*bt<mode>_setncqi_2): Likewise.
	(*bt<mode>_setc<mode>_mask): Likewise.

	* gcc.c-torture/execute/pr118623.c: New test.

(cherry picked from commit 92142019b6)
2025-05-15 13:28:41 +02:00
Jakub Jelinek db73411a72 c++: Fix up regressions caused by for/while loops with declarations [PR118822]
The recent PR86769 r15-7426 changes regressed the following two testcases,
the first one is more important as it is derived from real-world code.

The first problem is that the chosen
prep = do_pushlevel (sk_block);
// emit something
body = push_stmt_list ();
// emit further stuff
body = pop_stmt_list (body);
prep = do_poplevel (prep);
way of constructing the {FOR,WHILE}_COND_PREP and {FOR,WHILE}_BODY
isn't reliable.  If during parsing a label is seen in the body and then
some decl with destructors, sk_cleanup transparent scope is added, but
the correspondiong result from push_stmt_list is saved in
*current_binding_level and pop_stmt_list then pops even that statement list
but only do_poplevel actually attempts to pop the sk_cleanup scope and so we
ICE.
The reason for not doing do_pushlevel (sk_block); do_pushlevel (sk_block);
is that variables should be in the same scope (otherwise various e.g.
redeclaration*.C tests FAIL) and doing do_pushlevel (sk_block); do_pushlevel
(sk_cleanup); wouldn't work either as do_poplevel would silently unwind even
the cleanup one.

So, the following patch changes the earlier approach.  Nothing is removed
from the {FOR,WHILE}_COND_PREP subtrees while doing adjust_loop_decl_cond,
push_stmt_list isn't called either; all it does is remember as an integer
the number of cleanups (CLEANUP_STMT at the end of the STATEMENT_LISTs)
from querying stmt_list_stack and finding the initial *body_p in there
(that integer is stored into {FOR,WHILE}_COND_CLEANUP), and temporarily
{FOR,WHILE}_BODY is set to the last statement (if any) in the innermost
STATEMENT_LIST at the adjust_loop_decl_cond time; then at
finish_{for,while}_stmt a new finish_loop_cond_prep routine takes care of
do_poplevel for the scope (which is in {FOR,WHILE}_COND_PREP) and finds
given {FOR,WHILE}_COND_CLEANUP number and {FOR,WHILE}_BODY tree the right
spot where body statements start and moves that into {FOR,WHILE}_BODY.
Finally genericize_c_loop then inserts the cond, body, continue label, expr
into the right subtree of {FOR,WHILE}_COND_PREP.
The constexpr evaluation unfortunately had to be changed as well, because
we don't want to evaluate everything in BIND_EXPR_BODY (*_COND_PREP ())
right away, we want to evaluate it with the exception of the CLEANUP_STMT
cleanups at the end (given {FOR,WHILE}_COND_CLEANUP levels), and defer
the evaluation of the cleanups until after cond, body, expr are evaluated.

2025-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118822
gcc/
	* tree-iterator.h (tsi_split_stmt_list): Declare.
	* tree-iterator.cc (tsi_split_stmt_list): New function.
gcc/c-family/
	* c-common.h (WHILE_COND_CLEANUP): Change description in comment.
	(FOR_COND_CLEANUP): Likewise.
	* c-gimplify.cc (genericize_c_loop): Adjust for COND_CLEANUP
	being CLEANUP_STMT/TRY_FINALLY_EXPR trailing nesting depth
	instead of actual cleanup.
gcc/cp/
	* semantics.cc (adjust_loop_decl_cond): Allow multiple trailing
	CLEANUP_STMT levels in *BODY_P.  Set *CLEANUP_P to the number
	of levels rather than one particular cleanup, keep the cleanups
	in *PREP_P.  Set *BODY_P to the last stmt in the cur_stmt_list
	or NULL if *CLEANUP_P and the innermost cur_stmt_list is empty.
	(finish_loop_cond_prep): New function.
	(finish_while_stmt, finish_for_stmt): Use it.  Don't call
	set_one_cleanup_loc.
	* constexpr.cc (cxx_eval_loop_expr): Adjust handling of
	{FOR,WHILE}_COND_{PREP,CLEANUP}.
gcc/testsuite/
	* g++.dg/expr/for9.C: New test.

(cherry picked from commit 26baa2c09b)
2025-05-15 13:26:51 +02:00
Jakub Jelinek 24cd4753e4 c++: Fix up handling of for/while loops with declarations in condition [PR86769]
As the following testcase show (note, just for-{3,4,6,7,8}.C, constexpr-86769.C
and stmtexpr27.C FAIL without the patch, the rest is just that I couldn't
find coverage for some details and so added tests we don't regress or for5.C
is from Marek's attempt in the PR), we weren't correctly handling for/while
loops with declarations as conditions.

The C++ FE has the simplify_loop_decl_cond function which transforms
such loops as mentioned in the comment:
            while (A x = 42) { }
            for (; A x = 42;) { }
   becomes
            while (true) { A x = 42; if (!x) break; }
            for (;;) { A x = 42; if (!x) break; }
For for loops this is not enough, as the x declaration should be
still in scope when expr (if any) is executed, and injecting the
expr expression into the body in the FE needs to have the continue
label in between, something normally added by the c-family
genericization.  One of my thoughts was to just add there an artificial
label plus the expr expression in the FE and tell c-family about that
label, so that it doesn't create it but uses what has been emitted.

Unfortunately break/continue are resolved to labels only at c-family
genericization time and by moving the condition (and its preparation
statements such as the DECL_EXPR) into the body (and perhaps by also
moving there the (increment) expr as well) we resolve incorrectly any
break/continue statement appearing in cond (or newly perhaps also expr)
expression(s).  While in standard C++ one can't have something like that
there, with statement expressions they are possible there, and we actually
have testsuite coverage that when they appear outside of the body of the
loop they bind to an outer loop rather than the inner one.  When the FE
moves everything into the body, c-family can't distinguish any more between
the user body vs. the condition/preparation statements vs. expr expression.

So, the following patch instead keeps them separate and does the merging
only at the c-family loop genericization time.  For that the patch
introduces two new operands of FOR_STMT and WHILE_STMT, *_COND_PREP
which is forced to be a BIND_EXPR which contains the preparation statements
like DECL_EXPR, and the initialization of that variable, so basically what
{FOR,WHILE}_BODY has when we encounter the function dealing with this,
except one optional CLEANUP_STMT at the end which holds cleanups for the
variable if it needs to be destructed.  This CLEANUP_STMT is removed and
the actual cleanup saved into another new operand, *_COND_CLEANUP.

The c-family loop genericization handles such loops roughly the way
https://eel.is/c++draft/stmt.for and https://eel.is/c++draft/stmt.while
specifies, so the body is (if *_COND_CLEANUP is non-NULL)
{ A x = 42; try { if (!x) break; body; cont_label: expr; } finally { cleanup; } }
and otherwise
{ A x = 42; if (!x) break; body; cont_label: expr; }
i.e. the *_COND, *_BODY, optional continue label, FOR_EXPR  are appended
into the body of the *_COND_PREP BIND_EXPR.

And when doing constexpr evaluation of such FOR/WHILE loops, we treat
it similarly, first evaluate *_COND_PREP except the
      for (tree decl = BIND_EXPR_VARS (t); decl; decl = DECL_CHAIN (decl))
        destroy_value_checked (ctx, decl, non_constant_p);
part of BIND_EXPR handling for it, then evaluate *_COND (and decide based
on whether it was false or true like before), then *_BODY, then FOR_EXPR,
then *_COND_CLEANUP (similarly to the way how CLEANUP_STMT handling handles
that) and finally do those destroy_value_checked.

Note, the constexpr-86769.C testcase FAILs with both clang++ and MSVC (note,
the rest of tests PASS with clang++) but I believe it must be just a bug
in those compilers, new int is done in all the constructors and delete is
done in the destructor, so when clang++ reports one of the new int weren't
deallocated during constexpr evaluation I don't see how that would be
possible.  When the same test has all the constexpr stuff, all the new int
are properly deleted at runtime when compiled by both compilers and valgrind
is happy about it, no leaks.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>
	    Jason Merrill  <jason@redhat.com>

	PR c++/86769
gcc/c-family/
	* c-common.def (FOR_STMT): Add 2 operands and document them.
	(WHILE_STMT): Likewise.
	* c-common.h (WHILE_COND_PREP, WHILE_COND_CLEANUP): Define.
	(FOR_COND_PREP, FOR_COND_CLEANUP): Define.
	* c-gimplify.cc (genericize_c_loop): Add COND_PREP and COND_CLEANUP
	arguments, handle them if they are non-NULL.
	(genericize_for_stmt, genericize_while_stmt, genericize_do_stmt):
	Adjust callers.
gcc/c/
	* c-parser.cc (c_parser_while_statement): Add 2 further NULL_TREE
	operands to build_stmt.
	(c_parser_for_statement): Likewise.
gcc/cp/
	* semantics.cc (set_one_cleanup_loc): New function.
	(set_cleanup_locs): Use it.
	(simplify_loop_decl_cond): Remove.
	(adjust_loop_decl_cond): New function.
	(begin_while_stmt): Add 2 further NULL_TREE operands to build_stmt.
	(finish_while_stmt_cond): Call adjust_loop_decl_cond instead of
	simplify_loop_decl_cond.
	(finish_while_stmt): Call do_poplevel also on WHILE_COND_PREP if
	non-NULL and also use pop_stmt_list rather than do_poplevel for
	WHILE_BODY in that case.  Call set_one_cleanup_loc.
	(begin_for_stmt): Add 2 further NULL_TREE operands to build_stmt.
	(finish_for_cond): Call adjust_loop_decl_cond instead of
	simplify_loop_decl_cond.
	(finish_for_stmt): Call do_poplevel also on FOR_COND_PREP if non-NULL
	and also use pop_stmt_list rather than do_poplevel for FOR_BODY in
	that case.  Call set_one_cleanup_loc.
	* constexpr.cc (cxx_eval_loop_expr): Handle
	{WHILE,FOR}_COND_{PREP,CLEANUP}.
	(check_for_return_continue): Handle {WHILE,FOR}_COND_PREP.
	(potential_constant_expression_1): RECUR on
	{WHILE,FOR}_COND_{PREP,CLEANUP}.
gcc/testsuite/
	* g++.dg/diagnostic/redeclaration-7.C: New test.
	* g++.dg/expr/for3.C: New test.
	* g++.dg/expr/for4.C: New test.
	* g++.dg/expr/for5.C: New test.
	* g++.dg/expr/for6.C: New test.
	* g++.dg/expr/for7.C: New test.
	* g++.dg/expr/for8.C: New test.
	* g++.dg/ext/stmtexpr27.C: New test.
	* g++.dg/cpp2a/constexpr-86769.C: New test.
	* g++.dg/cpp26/name-independent-decl7.C: New test.
	* g++.dg/cpp26/name-independent-decl8.C: New test.

(cherry picked from commit 35d40b56eb)
2025-05-15 10:22:13 +02:00
Ian Lance Taylor ebef63ee3a crypto/tls: fix Config.Time in tests using expired certificates
This is a backport of https://go.dev/cl/640237 from the main repo.

Fixes PR go/118286

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/640435
(cherry picked from commit ed1493e12e)
2025-05-15 08:49:18 +01:00
GCC Administrator c5d50d0bc3 Daily bump. 2025-05-15 00:24:20 +00:00
Iain Sandoe 54846260bf c++, coroutines: Fix handling of early exceptions [PR113773].
This is a GCC-14 version of the same strategy as used on trunk, but
with the more wide-ranging code cleanups elided.  Since the return
expression could throw, but after the frame is destroyed, we must
also account for this, in addition to whether initial await_resume
has been called.

	PR c++/113773

gcc/cp/ChangeLog:

	* coroutines.cc (coro_rewrite_function_body): Do not set
	initial_await_resume_called here.
	(morph_fn_to_coro): Set it here, and introduce a new flag
	that indicates we have not yet reached the ramp return.
	Gate the EH cleanups on both of these flags.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/torture/pr113773.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-14 23:07:36 +01:00
Nathaniel Shead 9a16584beb c++: Partially revert "Support lambdas attached to more places in modules" [PR118245]
r14-9232-g3685fae23bb008 broke the ABI for lambdas in base classes,
causing ICEs when different lambdas got given the same mangled name.

This patch reverts the parser.cc changes from that patch to restore the
old behaviour.  The properly fixed behaviour is available in GCC 15.1
with r15-7202-g8990070b4297b9, but that change was not suitable for
backporting.

	PR c++/118245

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_class_head): Remove lambda scope when
	parsing base classes.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/lambda-7_a.H: Expect the test to fail.
	* g++.dg/modules/lambda-7_b.C: Likewise.
	* g++.dg/modules/lambda-7_c.C: Likewise.
	* g++.dg/cpp2a/lambda-uneval23.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-05-15 06:47:50 +10:00
Joseph Myers 05db28033e c: Allow bool and enum null pointer constants [PR112556]
As reported in bug 112556, GCC wrongly rejects conversion of null
pointer constants with bool or enum type to pointers in
convert_for_assignment (assignment, initialization, argument passing,
return).  Fix the code there to allow BOOLEAN_TYPE and ENUMERAL_TYPE;
it already allowed INTEGER_TYPE and BITINT_TYPE.

This bug (together with -std=gnu23 meaning false has type bool rather
than int) has in turn resulted in people thinking they need to fix
code using false as a null pointer constant for C23 compatibility.
While such a usage is certainly questionable, it has nothing to do
with C23 compatibility and the right place for warnings about such
usage is -Wzero-as-null-pointer-constant.  I think it would be
appropriate to extend -Wzero-as-null-pointer-constant to cover
BOOLEAN_TYPE, ENUMERAL_TYPE and BITINT_TYPE (in all the various
contexts in which that option generates warnings), though this patch
doesn't do anything about that option.

Bootstrapped with no regressions for x86-64-pc-linux-gnu.

	PR c/112556

gcc/c/
	* c-typeck.cc (convert_for_assignment): Allow conversion of
	ENUMERAL_TYPE and BOOLEAN_TYPE null pointer constants to pointers.

gcc/testsuite/
	* gcc.dg/c11-null-pointer-constant-1.c,
	gcc.dg/c23-null-pointer-constant-1.c: New tests.

(cherry picked from commit 3d525fce70)
2025-05-14 18:10:57 +01:00
Kyle Huey 36dd228f2e dwarf2out: Propagate dtprel into the .debug_addr table in resolve_addr_in_expr
For a debugger to display statically-allocated[0] TLS variables the compiler
must communicate information[1] that can be used in conjunction with knowledge
of the runtime enviroment[2] to calculate a location for the variable for
each thread. That need gives rise to dw_loc_dtprel in dwarf2out, a flag tracking
whether the location description is dtprel, or relative to the
"dynamic thread pointer". Location descriptions in the .debug_info section for
TLS variables need to be relocated by the static linker accordingly, and
dw_loc_dtprel controls emission of the needed relocations.

This is further complicated by -gsplit-dwarf. -gsplit-dwarf is designed to allow
as much debugging information as possible to bypass the static linker to improve
linking performance. One of the ways that is done is by introducing a layer of
indirection for relocatable values[3]. That gives rise to addr_index_table which
ultimately results in the .debug_addr section.

While the code handling addr_index_table clearly contemplates the existence of
dtprel entries[4] resolve_addr_in_expr does not, and the result is that when
using -gsplit-dwarf the DWARF for TLS variables contains an address[5] rather
than an offset, and debuggers can't work with that.

This is visible on a trivial example. Compile

```
static __thread int tls_var;

int main(void) {
  tls_var = 42;
  return 0;
}
```

with -g and -g -gsplit-dwarf. Run the program under gdb. When examining the
value of tls_var before and after the assignment, -g behaves as one would
expect but -g -gsplit-dwarf does not. If the user is lucky and the miscalculated
address is not mapped, gdb will print "Cannot access memory at address ...".
If the user is unlucky and the miscalculated address is mapped, gdb will simply
give the wrong value. You can further confirm that the issue is the address
calculation by asking gdb for the address of tls_var and comparing that to what
one would expect.[6]

Thankfully this is trivial to fix by modifying resolve_addr_in_expr to propagate
the dtprel character of the location where necessary. gdb begins working as
expected and the diff in the generated assembly is clear.

```
        .section        .debug_addr,"",@progbits
        .long   0x14
        .value  0x5
        .byte   0x8
        .byte   0
 .Ldebug_addr0:
-       .quad   tls_var
+       .long   tls_var@dtpoff, 0
        .quad   .LFB0
```

[0] Referring to e.g. __thread as statically-allocated vs. e.g. a
    dynamically-allocated pthread_key_create() call.
[1] Generally an offset in a TLS block.
[2] With glibc, provided by libthread_db.so.
[3] Relocatable values are moved to a table in the .debug_addr section, those
    values in .debug_info are replaced with special values that look up indexes
    in that table, and then the static linker elsewhere assigns a single per-CU
    starting index in the .debug_addr section, allowing those special values to
    remain permanently fixed and the resulting data to be ignored by the linker.
[4] ate_kind_rtx_dtprel exists, after all, and new_addr_loc_descr does produce
    it where appropriate.
[5] e.g. an address in the .tbss/.tdata section.
[6] e.g. on x86-64 by examining %fsbase and the offset in the assembly

2025-05-01  Kyle Huey  <me@kylehuey.com>

	* dwarf2out.cc (resolve_addr_in_expr): Propagate dtprel into the address
	table when appropriate.

(cherry picked from commit 02e95abdde)
2025-05-14 17:10:23 +02:00
Marek Polacek c11cb308c1 c++: fix propagating REF_PARENTHESIZED_P [PR116379]
Here we have:

  template<typename T>
  struct X{
      T val;
      decltype(auto) value(){
	  return (val);
      }
  };

where the return type of value should be 'int &' since '(val)' is an
expression, not a name, and decltype(auto) performs the type deduction
using the decltype rules.

The problem is that we weren't propagating REF_PARENTHESIZED_P
correctly: the return value of finish_non_static_data_member in this
test was a REFERENCE_REF_P, so we didn't set the flag.  We should
use force_paren_expr like below.

	PR c++/116379

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr) <COMPONENT_REF>: Use force_paren_expr to set
	REF_PARENTHESIZED_P.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/decltype-auto9.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14 10:40:54 -04:00
Marek Polacek 1dc1c1e7f0 c++: wrong-code with consteval constructor [PR117501]
We've had a wrong-code problem since r14-4140, due to which we
forget to initialize a variable.

In consteval39.C, we evaluate

    struct QQQ q;
  <<cleanup_point <<< Unknown tree: expr_stmt
    QQQ::QQQ (&q, TARGET_EXPR <D.2687, <<< Unknown tree: aggr_init_expr
      5
      __ct_comp
      D.2687
      (struct basic_string_view *) <<< Unknown tree: void_cst >>>
      (const char *) "" >>>>) >>>>>;

into

    struct QQQ q;
  <<cleanup_point <<< Unknown tree: expr_stmt
    {.data={._M_len=42, ._M_str=0}} >>>>>;

and then the useless expr_stmt is dropped on the floor, so q isn't
initialized.  As pre-r14-4140, we need to handle constructors specially.

With this patch, we generate:

    struct QQQ q;
  <<cleanup_point <<< Unknown tree: expr_stmt
    q = {.data={._M_len=42, ._M_str=0}} >>>>>;

initializing q properly.

	PR c++/117501

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_build_init_expr_for_ctor): New.
	(cp_fold_immediate_r): Call it.
	(cp_fold): Break out code into cp_build_init_expr_for_ctor.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/consteval39.C: New test.
	* g++.dg/cpp2a/consteval40.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14 10:38:47 -04:00
Marek Polacek 52202e4291 c++: auto in trailing-return-type in parameter [PR117778]
This PR describes a few issues, both ICE and rejects-valid, but
ultimately the problem is that we don't properly synthesize the
second auto in:

  int
  g (auto fp() -> auto)
  {
    return fp ();
  }

since r12-5860, which disabled auto_is_implicit_function_template_parm_p
in cp_parser_parameter_declaration after parsing the decl-specifier-seq.

If there is no trailing auto, there is no problem.

So we have to make sure auto_is_implicit_function_template_parm_p is
properly set when parsing the trailing auto.  A complication is that
one can write:

  auto f (auto fp(auto fp2() -> auto) -> auto) -> auto;
                                      ~~~~~~~

where only the underlined auto should be synthesized.  So when we
parse a parameter-declaration-clause inside another
parameter-declaration-clause, we should not enable the flag.  We
have no flags to keep track of such nesting, but I think I can walk
current_binding_level to see if we find ourselves in such an unlikely
scenario.

	PR c++/117778

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_late_return_type_opt): Maybe override
	auto_is_implicit_function_template_parm_p.
	(cp_parser_parameter_declaration): Move a make_temp_override below.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-generic-117778.C: New test.
	* g++.dg/cpp2a/abbrev-fn2.C: New test.
	* g++.dg/cpp2a/abbrev-fn3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit e6e40cb745)
2025-05-14 10:37:16 -04:00
Marek Polacek 9ce96b683a c++: fix reporting routines re-entered [PR119303]
We crash while we call warning_at ("inline function used but never defined")
since it invokes dump_template_bindings -> tsubst -> ... -> convert_like ->
... -> c_common_truthvalue_conversion -> warning_at ("enum constant in boolean
						     context")

cp_truthvalue_conversion correctly gets complain=0 but it calls
c_common_truthvalue_conversion from c-family which doesn't have
a similar parameter.

We can fix this by tweaking diagnostic_context::report_diagnostic to
check for recursion after checking if the diagnostic was enabled.

	PR c++/116960
	PR c++/119303

gcc/ChangeLog:

	* diagnostic.cc (diagnostic_context::report_diagnostic): Check for
	non-zero m_lock later, after checking diagnostic_enabled.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-uneval26.C: New test.
	* g++.dg/warn/undefined2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14 10:34:44 -04:00
Marek Polacek 97121b1355 c++: ICE with operator new[] in constexpr [PR118775]
Here we ICE since r11-7740 because we no longer say that (long)&a
(where a is a global var) is non_constant_p.  So VERIFY_CONSTANT
does not return and we crash on tree_to_uhwi.  We should check
tree_fits_uhwi_p before calling tree_to_uhwi.

	PR c++/118775

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Check tree_fits_uhwi_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-new24.C: New test.
	* g++.dg/cpp2a/constexpr-new25.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit aa55a6a30b)
2025-05-14 10:32:19 -04:00
Nathaniel Shead 6b1a99c3e2 c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]
The attached testcase ICEs in maybe_thunk_body because we haven't
created a node in the cgraph for an imported explicit instantiation yet.

We in fact really shouldn't be emitting calls at all, since an imported
explicit instantiation always exists in the TU we imported it from.  But
the required logic for that doesn't exist in this branch, so we'll just
xfail the relevant check.

	PR c++/120125

gcc/cp/ChangeLog:

	* optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph
	node created.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/clone-4_a.C: New test.
	* g++.dg/modules/clone-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2025-05-14 19:42:43 +10:00
GCC Administrator 74b9ae09ed Daily bump. 2025-05-14 00:23:21 +00:00
Jakub Jelinek 627d83c2b1 libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]
As mentioned in the PR, _gfortran_{,m,s}findloc2_s{1,4} iterate too many
times in the back case if nothing is found.
For !back, the loops are for (i = 1; i <= extent; i++) so i is in the
body [1, extent] if nothing is found, but for back it is
for (i = extent; i >= 0; i--) so i is in the body [0, extent] and compares
one element before the start of the array.
Note, findloc1_s{1,4} uses
          for (n = len; n > 0; n--, src -= delta * len_array)
for the back loop and
          for (n = 1; n <= len; n++, src += delta * len_array)
for !back.  This patch fixes that.
The testcase fails under valgrind without the libgfortran changes and
succeeds with those.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR libfortran/120196
	* m4/ifindloc2.m4 (header1, header2): For back use i > 0 rather than
	i >= 0 as for condition.
	* generated/findloc2_s1.c: Regenerate.
	* generated/findloc2_s4.c: Regenerate.

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

(cherry picked from commit 748a7bc462)
2025-05-13 16:31:44 +02:00
Jakub Jelinek a79e30dabb libfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191]
There is a bug in _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} which the
following testcase shows.
The functions return but then crash in the caller.
Seems that is because buffer overflows, I believe those functions for
if (mask == NULL || *mask) condition being false are supposed to fill in
the result array with all zeros (or allocate it and fill it with zeros).
My understanding is the result array in that case is integer(kind={4,8,16})
and should have the extents the character input array has.
The problem is that it uses * string_len in the extent multiplication:
      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n) * string_len;
and
      extent[n] =
        GFC_DESCRIPTOR_EXTENT(array,n + 1) * string_len;
which is I guess fine and desirable for the extents of the character array,
but not for the extents of the destination array.  Yet the code uses
that extent array for that purpose (and no other purposes).
Here it uses it to set the dimensions for the case where it needs to
allocate (as well as size):
      for (n = 0; n < rank; n++)
        {
          if (n == 0)
            str = 1;
          else
            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
          GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
        }
Here it uses it for bounds checking of the destination:
      if (unlikely (compile_options.bounds_check))
        {
          for (n=0; n < rank; n++)
            {
              index_type ret_extent;

              ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
              if (extent[n] != ret_extent)
                runtime_error ("Incorrect extent in return value of"
                               " MAXLOC intrinsic in dimension %ld:"
                               " is %ld, should be %ld", (long int) n + 1,
                               (long int) ret_extent, (long int) extent[n]);
            }
        }
and here to find out how many retarray elements to actually fill in each
dimension:
  while(1)
    {
      *dest = 0;
      count[0]++;
      dest += dstride[0];
      n = 0;
      while (count[n] == extent[n])
        {
          /* When we get to the end of a dimension, reset it and increment
             the next dimension.  */
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
          dest -= dstride[n] * extent[n];
Seems maxloc1s.m4 and minloc1s.m4 are the only users of ifunction-s.m4,
so we can change SCALAR_ARRAY_FUNCTION in there without breaking anything
else.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/120191
	* m4/ifunction-s.m4 (SCALAR_ARRAY_FUNCTION): Don't multiply
	GFC_DESCRIPTOR_EXTENT(array,) by string_len.
	* generated/maxloc1_4_s1.c: Regenerate.
	* generated/maxloc1_4_s4.c: Regenerate.
	* generated/maxloc1_8_s1.c: Regenerate.
	* generated/maxloc1_8_s4.c: Regenerate.
	* generated/maxloc1_16_s1.c: Regenerate.
	* generated/maxloc1_16_s4.c: Regenerate.
	* generated/minloc1_4_s1.c: Regenerate.
	* generated/minloc1_4_s4.c: Regenerate.
	* generated/minloc1_8_s1.c: Regenerate.
	* generated/minloc1_8_s4.c: Regenerate.
	* generated/minloc1_16_s1.c: Regenerate.
	* generated/minloc1_16_s4.c: Regenerate.

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

(cherry picked from commit 781cfc454b)
2025-05-13 16:31:28 +02:00
Jakub Jelinek 87c7061cc0 libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191]
I've tried to write a testcase for the BT_CHARACTER maxloc/minloc with named
or unnamed arguments and indeed the just posted patch fixed the arguments
in there in multiple cases to match what the library expects.
But the testcase still fails, due to library problems.

One dealt with in this patch are _gfortran_s{max,min}loc2_{4,8,16}_s{1,4}
functions.  Those are trivial wrappers around
_gfortrani_{max,min}loc2_{4,8,16}_s{1,4} which should call those functions
if the scalar mask is true and just return 0 otherwise.
The two bugs I see there is that the back, len arguments are swapped,
which means that it always acts as back=.true. and for len will use
character length of 1 or 0 instead of the desired one.
The _gfortrani_{max,min}loc2_{4,8,16}_s{1,4} functions have prototypes like
GFC_INTEGER_4
maxloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charlen_type len)
so back comes before len, ditto for the
GFC_INTEGER_4
smaxloc2_4_s1 (gfc_array_s1 * const restrict array,
               GFC_LOGICAL_4 *mask, GFC_LOGICAL_4 back, gfc_charlen_type len)
The other problem is that it was just testing if (mask).  In my limited
Fortran understanding that means that the optional argument mask was
supplied but nothing about its actual value.  Other scalar mask generated
routines use if (mask == NULL || *mask) as the condition when to call the
non-masked function, i.e. when mask is not supplied (then it should act like
.true. mask) or when it is supplied and evaluates to .true.).

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/120191
	* m4/maxloc2s.m4: For smaxloc2 call maxloc2 if mask is NULL or *mask.
	Swap back and len arguments.
	* m4/minloc2s.m4: Likewise.
	* generated/maxloc2_4_s1.c: Regenerate.
	* generated/maxloc2_4_s4.c: Regenerate.
	* generated/maxloc2_8_s1.c: Regenerate.
	* generated/maxloc2_8_s4.c: Regenerate.
	* generated/maxloc2_16_s1.c: Regenerate.
	* generated/maxloc2_16_s4.c: Regenerate.
	* generated/minloc2_4_s1.c: Regenerate.
	* generated/minloc2_4_s4.c: Regenerate.
	* generated/minloc2_8_s1.c: Regenerate.
	* generated/minloc2_8_s4.c: Regenerate.
	* generated/minloc2_16_s1.c: Regenerate.
	* generated/minloc2_16_s4.c: Regenerate.

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

(cherry picked from commit 482f2192d4)
2025-05-13 16:31:13 +02:00
Jakub Jelinek c12443e824 fortran: Fix up minloc/maxloc lowering [PR120191]
We need to drop the kind argument from what is passed to the
library, but need to do it not only when one uses the argument name
for it (so kind=4 etc.) but also when one passes all the arguments
to the intrinsics.

The following patch uses what gfc_conv_intrinsic_findloc uses,
which looks more efficient and cleaner, we already set automatic
vars to point to the kind and back actual arguments, so we can just
free/clear expr on the former and set name to "%VAL" on the latter.

And similarly clears dim argument for the BT_CHARACTER case when using
maxloc2/minloc2, again regardless of whether it was named or not.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>
	    Daniil Kochergin  <daniil2472s@gmail.com>
	    Tobias Burnus  <tburnus@baylibre.com>

	PR fortran/120191
	* trans-intrinsic.cc (strip_kind_from_actual): Remove.
	(gfc_conv_intrinsic_minmaxloc): Don't call strip_kind_from_actual.
	Free and clear kind_arg->expr if non-NULL.  Set back_arg->name to
	"%VAL" instead of a loop looking for last argument.  Remove actual
	variable, use array_arg instead.  Free and clear dim_arg->expr if
	non-NULL for BT_CHARACTER cases instead of using a loop.

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

(cherry picked from commit ec249be3c2)
2025-05-13 16:29:22 +02:00
Jonathan Wakely c50b8d550d libstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198]
This was a regression introduced with using version.def to define
feature test macros (r14-3248-g083b7f2833d71d). std::scoped_lock doesn't
need to depend on gthreads and so can be defined unconditionally, even
for freestanding.

libstdc++-v3/ChangeLog:

	PR libstdc++/120198
	* include/bits/version.def (scoped_lock): Do not depend on
	gthreads or hosted.
	* include/bits/version.h: Regenerate.
	* include/std/mutex (scoped_lock): Update comment.
	* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
	Remove dg-require-gthreads and use custom lockable type instead
	of std::mutex. Check that typedef is only present for a single
	template argument.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit bdd2753f5f)
2025-05-13 12:05:48 +01:00
Jakub Jelinek 346f3a27f6 c++: Fix build_omp_array_section for type dependent array_expr [PR118590]
As can be seen on the testcase, when array_expr is type dependent, assuming
it has non-NULL TREE_TYPE is just wrong, it can often have NULL type, and even
if not, blindly assuming it is a pointer or array type is also wrong.

So, like in many other spots in the C++ FE, for type dependent expressions
we want to create something which will survive until instantiation and can be
redone at that point.

Unfortunately, build_omp_array_section is called before we actually do any
kind of checking what array_expr really is, and on invalid code it can be e.g.
a TYPE_DECL on which type_dependent_expression_p ICEs (as can be seen on the
pr67522.C testcase).  So, I've hacked this by checking it is not TYPE_DECL,
I hope a TYPE_P can't make it through there when we just lookup an identifier.

Anyway, this patch is not enough, we can ICE e.g. on __uint128_t[0:something]
during instantiation, so I think something needs to be done for this in pt.cc
as well.

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118590
	* typeck.cc (build_omp_array_section): If array_expr is type dependent
	or a TYPE_DECL, build OMP_ARRAY_SECTION with NULL type.

	* g++.dg/goacc/pr118590.C: New test.

(cherry picked from commit b02c061bb8)
2025-05-13 09:15:00 +02:00
GCC Administrator de4d231125 Daily bump. 2025-05-13 00:23:46 +00:00
Andrew Pinski 102e10f022 final: Fix get_attr_length for asm goto [PR118411]
The problem is for inline-asm goto, the outer rtl insn type
is a jump_insn and get_attr_length does not handle ASM specially
unlike if the outer rtl insn type was just insn.

This fixes the issue by adding support for both CALL_INSN and JUMP_INSN
with asm.

OK? Bootstrapped and tested on x86_64-linux-gnu.

	PR middle-end/118411

gcc/ChangeLog:

	* final.cc (get_attr_length_1): Handle asm for CALL_INSN
	and JUMP_INSNs.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit c1729df6ec)
2025-05-12 16:30:12 -07:00
Harald Anlauf 4a0e88c0c3 Fortran: array subreferences and components of derived types [PR119986]
PR fortran/119986

gcc/fortran/ChangeLog:

	* expr.cc (is_subref_array): When searching for array references,
	do not terminate early so that inquiry references to complex
	components work.
	* primary.cc (gfc_variable_attr): A substring reference can refer
	to either a scalar or array character variable.  Adjust search
	accordingly.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit fceb602279)
2025-05-12 21:46:59 +02:00
Martin Jambor 51ffec744b ipa: Do not emit info about temporary clones to ipa-clones dump (PR119852)
As described in PR 119852, the output of -fdump-ipa-clones can contain
"(null)" as the suffix/reason for cloning when we need to create a
clone to hold the original function during recursive inlining.  Such
clone is never output and so should not be part of the dump output
either.

gcc/ChangeLog:

2025-04-23  Martin Jambor  <mjambor@suse.cz>

	PR ipa/119852
	* cgraphclones.cc (dump_callgraph_transformation): Document the
	function.  Do not dump if suffix is NULL.

gcc/testsuite/ChangeLog:

2025-04-23  Martin Jambor  <mjambor@suse.cz>

	PR ipa/119852
	* gcc.dg/ipa/pr119852.c: New test.

(cherry picked from commit fb5829a016)
2025-05-12 18:39:47 +02:00
Martin Jambor c817f833cf Document option -fdump-ipa-clones
I have noticed that the option -fdump-ipa-clones is not documented
although there are users who depend on it.  This patch adds the
missing documentation along with the description of the information it
dumps and the format it uses.

I am never quite sure which of the texinfo mark-ups is the most
appropriate in which situation, I'll of course incorporate any
feedback on this as well as the general wording of the text.

After we settle on a version, I'd like to backport the documentation
also at least to GCC 15, 14 and 13.

Is it perhaps OK for master and the branches or what would better be
changed?

Thanks,

Martin

gcc/ChangeLog:

2025-04-23  Martin Jambor  <mjambor@suse.cz>

	* doc/invoke.texi (Developer Options): Document -fdump-ipa-clones.

(cherry picked from commit 6ecc2fee06)
2025-05-12 18:39:33 +02:00
Jonathan Wakely 8f53df9116 libstdc++: Update C++23 status table
P2609 was backported to gcc-14.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2023.xml: Update status of proposal
	implemented after GCC 14.2 release.
	* doc/html/manual/status.html: Regenerate.
2025-05-12 15:09:10 +01:00
GCC Administrator e35f2b668f Daily bump. 2025-05-12 00:21:56 +00:00
Pan Li be76efab03 DSE: Fix ICE after allow vector type in get_stored_val
We allowed vector type for get_stored_val when read is less than or
equal to store in previous.  Unfortunately,  the valididate_subreg
treats the vector type's size is less than vector register as
invalid.  Then we will have ICE here.

This patch would like to fix it by filter-out the invalid type size,
and make sure the subreg is valid for both the read_mode and store_mode
before perform the real gen_lowpart.

The below test suites are passed for this patch:

* The x86 bootstrap test.
* The x86 regression test.
* The riscv rv64gcv regression test.
* The riscv rv64gc regression test.
* The aarch64 regression test.

gcc/ChangeLog:

	* dse.cc (get_stored_val): Make sure read_mode/write_mode
	is valid subreg before gen_lowpart.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/bug-6.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit 88b3f83238)
2025-05-11 11:34:43 +02:00
Dimitar Dimitrov aef1a618e2 testsuite: Require effective target pie for pr113197
The test for PR113197 explicitly enables PIE.  But targets without PIE
emit warnings when -fpie is passed (e.g. pru and avr), which causes the
test to fail.

Fix by adding an effective target requirement for PIE.

With this patch, the test now is marked as unsupported for
pru-unknown-elf.  Testing for x86_64-pc-linux-gnu passes with current
mainline, and fails if the fix from r15-4018-g02f4efe3c12cf7 is
reverted.

	PR ipa/113197

gcc/testsuite/ChangeLog:

	* gcc.dg/lto/pr113197_0.c: Require effective target pie.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
(cherry picked from commit bcd56224d7)
2025-05-11 11:13:07 +02:00
Richard Biener 0902cdb606 tree-optimization/113197 - bougs assert in PTA
PTA asserts that EAF_NO_DIRECT_READ is not set when flags are
set consistently which doesn't make sense.  The following removes
the assert.

	PR tree-optimization/113197
	* tree-ssa-structalias.cc (handle_call_arg): Remove bougs
	assert.

	* gcc.dg/lto/pr113197_0.c: New testcase.
	* gcc.dg/lto/pr113197_1.c: Likewise.

(cherry picked from commit 02f4efe3c1)
2025-05-11 11:13:07 +02:00
Jakub Jelinek cc589c2a4b testsuite: Add testcase for already fixed PR [PR117498]
This wrong-code issue has been fixed with r15-7249.
We still emit warnings which are questionable and perhaps we'd
get better generated code if niters determined the loop has only a single
iteration without UB and we'd punt on vectorizing it (or unrolling).

2025-01-31  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/117498
	* gcc.c-torture/execute/pr117498.c: New test.

(cherry picked from commit 9fc0683082)
2025-05-11 11:13:07 +02:00
GCC Administrator 4dc29023e4 Daily bump. 2025-05-11 00:22:05 +00:00
GCC Administrator 3bd63e20db Daily bump. 2025-05-10 00:22:27 +00:00
Eric Botcazou 81da797328 Fix wrong optimization of complex boolean expression
The VRP2 pass turns:

  # prephitmp_3 = PHI <0(4)>
  _1 = prephitmp_3 == 0;
  _5 = stretch_14(D) ^ 1;
  _39 = _1 & _5;
  _40 = _39 | last_20(D);

into

  _5 = stretch_14(D) ^ 1;
  _42 = ~stretch_14(D);
  _39 = _42;
  _40 = last_20(D) | _39;

using the following step:

Folding statement: _1 = prephitmp_3 == 0;
Queued stmt for removal.  Folds to: 1
Folding statement: _5 = stretch_14(D) ^ 1;
Not folded
Folding statement: _39 = _1 & _5;
gimple_simplified to _42 = ~stretch_14(D);
_39 = _42 & 1;
Folded into: _39 = _42;

Folding statement: _40 = _39 | last_20(D);
Folded into: _40 = last_20(D) | _39;

but stretch_14 is a 8-bit boolean so the two forms are not equivalent, that
is to say dropping the "& 1" is wrong.  It's another instance of the issue:
  https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558537.html

Here it's the reverse case: the bitwise NOT (~) is treated as logical by the
machinery in range-op.cc but the bitwise AND (&) is *not* treated as logical
by that of vr-values.cc, leading to the same problematic outcome.

gcc/
	* vr-values.cc (simplify_using_ranges::simplify) <BIT_AND_EXPR>:
	Do not call simplify_bit_ops_using_ranges for boolean types whose
	precision is not 1.

gcc/testsuite/
	* gnat.dg/opt106.adb: New test.
	* gnat.dg/opt106_pkg1.ads, gnat.dg/opt106_pkg1.adb: New helper.
	* gnat.dg/opt106_pkg2.ads, gnat.dg/opt106_pkg2.adb: Likewise.
2025-05-09 20:39:53 +02:00
Richard Biener 50d3f67c71 tree-optimization/120156 - ICE in ptr_derefs_may_alias_p
This picks the ptr_derefs_may_alias_p fix from the PR99954 fix
which said:  This makes us run into a latent issue in
ptr_deref_may_alias_decl_p when the pointer is something like &MEM[0].a
in which case we fail to handle non-SSA name pointers.  Add code
similar to what we have in ptr_derefs_may_alias_p.

	PR tree-optimization/120156
	* tree-ssa-alias.cc (ptr_deref_may_alias_decl_p): Verify
	the pointer is an SSA name.

(cherry picked from commit c290e6a0b7)
2025-05-09 09:35:44 +02:00
GCC Administrator 79dae83f62 Daily bump. 2025-05-09 00:23:23 +00:00
Richard Sandiford a9d390ab17 aarch64: Fix CFA offsets in non-initial stack probes [PR119610]
PR119610 is about incorrect CFI output for a stack probe when that
probe is not the initial allocation.  The main aarch64 stack probe
function, aarch64_allocate_and_probe_stack_space, implicitly assumed
that the incoming stack pointer pointed to the top of the frame,
and thus held the CFA.

aarch64_save_callee_saves and aarch64_restore_callee_saves use a
parameter called bytes_below_sp to track how far the stack pointer
is above the base of the static frame.  This patch does the same
thing for aarch64_allocate_and_probe_stack_space.

Also, I noticed that the SVE path was attaching the first CFA note
to the wrong instruction: it was attaching the note to the calculation
of the stack size, rather than to the r11<-sp copy.

gcc/
	PR target/119610
	* config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
	Add a bytes_below_sp parameter and use it to calculate the CFA
	offsets.  Attach the first SVE CFA note to the move into the
	associated temporary register.
	(aarch64_allocate_and_probe_stack_space): Update calls accordingly.
	Start out with bytes_per_sp set to the frame size and decrement
	it after each allocation.

gcc/testsuite/
	PR target/119610
	* g++.dg/torture/pr119610.C: New test.
	* g++.target/aarch64/sve/pr119610-sve.C: Likewise.

(cherry picked from commit fa61afef18)
2025-05-08 12:06:41 +01:00
Jakub Jelinek cdf689a1f1 rs6000: Ignore OPTION_MASK_SAVE_TOC_INDIRECT differences in inlining decisions [PR119327]
The following testcase FAILs because the always_inline function can't
be inlined.
The rs6000 backend has similarly to other targets a hook which rejects
inlining which would bring in new ISAs which aren't there in the caller.
And this hook rejects this because of OPTION_MASK_SAVE_TOC_INDIRECT
differences.
This flag is set if explicitly requested or by default depending on
whether the current function looks hot (or at least not cold):
  if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) == 0
      && flag_shrink_wrap_separate
      && optimize_function_for_speed_p (cfun))
    rs6000_isa_flags |= OPTION_MASK_SAVE_TOC_INDIRECT;
The target nodes that are being compared here are actually the default
target node (which was created when cfun was NULL) vs. one that was
created for the always_inline function when it wasn't NULL, so one
doesn't have it, the other does.
In any case, this flag feels like a tuning decision rather than hard
ISA requirement and I see no problems why we couldn't inline
even explicit -msave-toc-indirect function into -mno-save-toc-indirect
or vice versa.
We already ignore OPTION_MASK_P{8,10}_FUSION which are also more
like tuning flags.

2025-04-22  Jakub Jelinek  <jakub@redhat.com>

	PR target/119327
	* config/rs6000/rs6000.cc (rs6000_can_inline_p): Ignore also
	OPTION_MASK_SAVE_TOC_INDIRECT differences.

	* g++.dg/opt/pr119327.C: New test.

(cherry picked from commit 4b62cf555b)
2025-05-08 11:56:50 +02:00
Jakub Jelinek 8cbe033a8a libcpp: Further fixes for incorrect line numbers in large files [PR120061]
The backport of the PR108900 fix to 14 branch broke building chromium
because static_assert (__LINE__ == expected_line_number, ""); now triggers
as the __LINE__ values are off by one.
This isn't the case on the trunk and 15 branch because we've switched
to 64-bit location_t and so one actually needs far longer header files
to trigger it.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c12
contain (large) testcases in patch form which show on the 14 branch
that the first one used to fail before the PR108900 backport and now
works correctly, while the second one attempts to match the chromium
behavior and it used to pass before the PR108900 backport and now it
FAILs.
The two testcases show rare problematic cases, because
do_include_common -> parse_include -> check_eol -> check_eol_1 ->
cpp_get_token_1 -> _cpp_lex_token -> _cpp_lex_direct -> linemap_line_start
triggers there
      /* Allocate the new line_map.  However, if the current map only has a
         single line we can sometimes just increase its column_bits instead. */
      if (line_delta < 0
          || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map)
          || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits))
          || ( /* We can't reuse the map if the line offset is sufficiently
                  large to cause overflow when computing location_t values.  */
              (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
              >= (((uint64_t) 1)
                  << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
          || range_bits < map->m_range_bits)
        map = linemap_check_ordinary
                (const_cast <line_map *>
                  (linemap_add (set, LC_RENAME,
                                ORDINARY_MAP_IN_SYSTEM_HEADER_P (map),
                                ORDINARY_MAP_FILE_NAME (map),
                                to_line)));
and so creates a new ordinary map on the line right after the
(problematic) #include line.
Now, in the spot that r14-11679-g8a884140c2bcb7 patched,
pfile->line_table->highest_location in all 3 tests (also
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c13
) is before the decrement the start of the line after the #include line and so
the decrement is really desirable in that case to put highest_location
[jakub@tucnak gcc-15]$ git log -1 --format=%B r15-9638-gbfcb5da69a41f7a5e41faab39b763d9d7c8bd2ea | cat
libcpp: Further fixes for incorrect line numbers in large files [PR120061]

The backport of the PR108900 fix to 14 branch broke building chromium
because static_assert (__LINE__ == expected_line_number, ""); now triggers
as the __LINE__ values are off by one.
This isn't the case on the trunk and 15 branch because we've switched
to 64-bit location_t and so one actually needs far longer header files
to trigger it.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c12
contain (large) testcases in patch form which show on the 14 branch
that the first one used to fail before the PR108900 backport and now
works correctly, while the second one attempts to match the chromium
behavior and it used to pass before the PR108900 backport and now it
FAILs.
The two testcases show rare problematic cases, because
do_include_common -> parse_include -> check_eol -> check_eol_1 ->
cpp_get_token_1 -> _cpp_lex_token -> _cpp_lex_direct -> linemap_line_start
triggers there
      /* Allocate the new line_map.  However, if the current map only has a
         single line we can sometimes just increase its column_bits instead. */
      if (line_delta < 0
          || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map)
          || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits))
          || ( /* We can't reuse the map if the line offset is sufficiently
                  large to cause overflow when computing location_t values.  */
              (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
              >= (((uint64_t) 1)
                  << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
          || range_bits < map->m_range_bits)
        map = linemap_check_ordinary
                (const_cast <line_map *>
                  (linemap_add (set, LC_RENAME,
                                ORDINARY_MAP_IN_SYSTEM_HEADER_P (map),
                                ORDINARY_MAP_FILE_NAME (map),
                                to_line)));
and so creates a new ordinary map on the line right after the
(problematic) #include line.
Now, in the spot that r14-11679-g8a884140c2bcb7 patched,
pfile->line_table->highest_location in all 3 tests (also
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c13
) is before the decrement the start of the line after the #include line and so
the decrement is really desirable in that case to put highest_location
somewhere on the line where the #include actually is.
But at the same time it is also undesirable, because if we do decrement it,
then linemap_add LC_ENTER called from _cpp_do_file_change will then
  /* Generate a start_location above the current highest_location.
     If possible, make the low range bits be zero.  */
  location_t start_location = set->highest_location + 1;
  unsigned range_bits = 0;
  if (start_location < LINE_MAP_MAX_LOCATION_WITH_COLS)
    range_bits = set->default_range_bits;
  start_location += (1 << range_bits) - 1;
  start_location &=  ~((1 << range_bits) - 1);

  linemap_assert (!LINEMAPS_ORDINARY_USED (set)
                  || (start_location
                      >= MAP_START_LOCATION (LINEMAPS_LAST_ORDINARY_MAP (set))));
and we can end up with the new LC_ENTER ordinary map having the same
start_location as the preceding LC_RENAME one.
Next thing that happens is computation of included_from:
  if (reason == LC_ENTER)
    {
      if (set->depth == 0)
        map->included_from = 0;
      else
        /* The location of the end of the just-closed map.  */
        map->included_from
          = (((map[0].start_location - 1 - map[-1].start_location)
              & ~((1 << map[-1].m_column_and_range_bits) - 1))
             + map[-1].start_location);
The normal case (e.g. with the testcase included at the start of this comment) is
that map[-1] starts somewhere earlier and so map->included_from computation above
nicely computes location_t which expands to the start of the #include line.
With r14-11679 reverted, for #c11 as well as #c12
map[0].start_location == map[-1].start_location above, and so it is
((location_t) -1 & ~((1 << map[-1].m_column_and_range_bits) - 1)))
+ map[-1].start_location,
which happens to be start of the #include line.
For #c11 map[0].start_location is 0x500003a0 and map[-1] has
m_column_and_range_bits 7 and map[-2] has m_column_and_range_bits 12 and
map[0].included_from is set to 0x50000320.
For #c12 map[0].start_location is 0x606c0402 and map[-2].start_location is
0x606c0400 and m_column_and_range_bits is 0 for all 3 maps.
map[0].included_from is set to 0x606c0401.
The last important part is again in linemap_add when doing LC_LEAVE:
      /* (MAP - 1) points to the map we are leaving. The
         map from which (MAP - 1) got included should be the map
         that comes right before MAP in the same file.  */
      from = linemap_included_from_linemap (set, map - 1);

      /* A TO_FILE of NULL is special - we use the natural values.  */
      if (to_file == NULL)
        {
          to_file = ORDINARY_MAP_FILE_NAME (from);
          to_line = SOURCE_LINE (from, from[1].start_location);
          sysp = ORDINARY_MAP_IN_SYSTEM_HEADER_P (from);
        }
Here it wants to compute the right to_line which ought to be the line after
the #include directive.
On the #c11 testcase that doesn't work correctly though, because
map[-1].included_from is 0x50000320, from[0] for that is LC_ENTER with
start_location 0x4080 and m_column_and_range_bits 12 but note that we've
earlier computed map[-1].start_location + (-1 & 0xffffff80) and so only
decreased by 7 bits, so to_line is still on the line with #include and not
after it.  In the #c12 that doesn't happen, all the ordinary maps involved
there had 0 m_column_and_range_bits and so this computes correct line.

Below is a fix for the trunk including testcases using the
location_overflow_plugin hack to simulate the bugs without needing huge
files (in the 14 case it is just 330KB and almost 10MB, but in the 15
case it would need to be far bigger).
The pre- r15-9018 trunk has
FAIL: gcc.dg/plugin/location-overflow-test-pr116047.c -fplugin=./location_overflow_plugin.so  scan-file static_assert[^\n\r]*6[^\n\r]*== 6
and current trunk
FAIL: gcc.dg/plugin/location-overflow-test-pr116047.c -fplugin=./location_overflow_plugin.so  scan-file static_assert[^\n\r]*6[^\n\r]*== 6
FAIL: gcc.dg/plugin/location-overflow-test-pr120061.c -fplugin=./location_overflow_plugin.so  scan-file static_assert[^\n\r]*5[^\n\r]*== 5
and with the patch everything PASSes.

The patch reverts the r14-11679 change, because it is incorrect,
we really need to decrement it even when crossing ordinary map
boundaries, so that the location is not on the line after the #include
line but somewhere on the #include line.  It also patches two spots
in linemap_add mentioned above to make sure we get correct locations
both in the included_from location_t when doing LC_ENTER (second
line-map.cc hunk) and when doing LC_LEAVE to compute the right to_line
(first line-map.cc hunk), both in presence of an added LC_RENAME
with the same start_location as the following LC_ENTER (i.e. the
problematic cases).
The LC_ENTER hunk is mostly to ensure included_form location_t is
at the start of the #include line (column 0), without it we can
decrease include_from not enough and end up at some random column
in the middle of the line, because it is masking away
map[-1].m_column_and_range_bits bits even when in the end the resulting
include_from location_t will be found in map[-2] map with perhaps
different m_column_and_range_bits.  That alone doesn't fix the bug
though.
The more important is the LC_LEAVE hunk and the problem there is
caused by linemap_line_start not actually doing
    r = set->highest_line + (line_delta << map->m_column_and_range_bits);
when adding a new map (the LC_RENAME one because we need to switch to
different number of directly encoded ranges, or columns, etc.).
So, in the original PR108900 case that
  to_line = SOURCE_LINE (from, from[1].start_location);
doesn't do the right thing, from there is the last < 0x50000000 map
with m_column_and_range_bits 12, from[1] is the first one above it
and map[-1].included_from is the correct location of column 0 on
the #include line, but as the new LC_RENAME map has been created without
actually increasing highest_location to be on the new line (we've just
set to_line of the new LC_RENAME map to the correct line),
  to_line = SOURCE_LINE (from, from[1].start_location);
stays on the same source line.  I've tried to just replace that with
  to_line = SOURCE_LINE (from, linemap_included_from (map - 1)) + 1;
i.e. just find out the #include line from map[-1].included_from and
add 1 to it, unfortunately that breaks the
c-c++-common/cpp/line-4.c
test where we expect to stay on the same 0 line for LC_LEAVE from
<command line> and gcc.dg/cpp/trad/Wunused.c, gcc.dg/cpp/trad/builtins.c
and c-c++-common/analyzer/named-constants-via-macros-traditional.c tests
all with -traditional-cpp preprocessing where to_line is also off-by-one
from the expected one.
So, this patch instead conditionalizes it, uses the
  to_line = SOURCE_LINE (from, linemap_included_from (map - 1)) + 1;
way only if from[1] is a LC_RENAME map (rather than the usual
LC_ENTER one), that should limit it to the problematic cases of when
parse_include peeked after EOL and had to create LC_RENAME map with
the same start_location as the LC_ENTER after it.

Some further justification for the LC_ENTER hunk, using the
https://gcc.gnu.org/pipermail/gcc-patches/2025-May/682774.html testcase
(old is 14 before r14-11679, vanilla current 14 and new with the 14 patch)
I get
$ /usr/src/gcc-14/obj/gcc/cc1.old -quiet -std=c23 pr116047.c -nostdinc
In file included from pr116047-1.h:327677:21,
                 from pr116047.c:4:
pr116047-2.h:1:1: error: unknown type name ‘a’
    1 | a b c;
      | ^
pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
    1 | a b c;
      |     ^
pr116047-1.h:327677:1: error: static assertion failed: ""
327677 | #include "pr116047-2.h"
       | ^~~~~~~~~~~~~
$ /usr/src/gcc-14/obj/gcc/cc1.vanilla -quiet -std=c23 pr116047.c -nostdinc
In file included from pr116047-1.h:327678,
                 from pr116047.c:4:
pr116047-2.h:1:1: error: unknown type name ‘a’
    1 | a b c;
      | ^
pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
    1 | a b c;
      |     ^
$ /usr/src/gcc-14/obj/gcc/cc1.new -quiet -std=c23 pr116047.c -nostdinc
In file included from pr116047-1.h:327677,
                 from pr116047.c:4:
pr116047-2.h:1:1: error: unknown type name ‘a’
    1 | a b c;
      | ^
pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
    1 | a b c;
      |     ^

pr116047-1.h has on lines 327677+327678:
 #include "pr116047-2.h"
 static_assert (__LINE__ == 327678, "");
so the static_assert failure is something that was dealt mainly in the
LC_LEAVE hunk and files.cc reversion, but please have a look at the
In file included from lines.
14.2 emits correct line (#include "pr116047-2.h" is indeed on line
327677) but some random column in there (which is not normally printed
for smaller headers; 21 is the . before extension in the filename).
Current trunk emits incorrect line (327678 instead of 327677, clearly
it didn't decrement).
And the patched compiler emits the right line with no column, as would
be printed if I remove e.g. 300000 newlines from the file.

2025-05-08  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/108900
	PR preprocessor/116047
	PR preprocessor/120061
	* files.cc (_cpp_stack_file): Revert 2025-03-28 change.
	* line-map.cc (linemap_add): Use
	SOURCE_LINE (from, linemap_included_from (map - 1)) + 1; instead of
	SOURCE_LINE (from, from[1].start_location); to compute to_line
	for LC_LEAVE if from[1].reason is LC_RENAME.  For LC_ENTER
	included_from computation, look at map[-2] or even lower if map[-1]
	has the same start_location as map[0].

	* gcc.dg/plugin/plugin.exp: Add location-overflow-test-pr116047.c
	and location-overflow-test-pr120061.c.
	* gcc.dg/plugin/location_overflow_plugin.c (plugin_init): Don't error
	on unknown values, instead just break.
	* gcc.dg/plugin/location-overflow-test-pr116047.c: New test.
	* gcc.dg/plugin/location-overflow-test-pr116047-1.h: New test.
	* gcc.dg/plugin/location-overflow-test-pr116047-2.h: New test.
	* gcc.dg/plugin/location-overflow-test-pr120061.c: New test.
	* gcc.dg/plugin/location-overflow-test-pr120061-1.h: New test.
	* gcc.dg/plugin/location-overflow-test-pr120061-2.h: New test.
2025-05-08 11:14:24 +02:00
GCC Administrator 420aef6646 Daily bump. 2025-05-08 00:22:12 +00:00
Robin Dapp bed0053a28 vect: Use original LHS type for gather pattern [PR118950].
In PR118950 we do not zero masked elements in a gather load.
While recognizing a gather/scatter pattern we do not use the original
type of the LHS.  This matters because the type can differ with bool
patterns (e.g. _Bool vs unsigned char) and we don't notice the need
for zeroing out the padding bytes.

This patch just uses the original LHS's type.

	PR middle-end/118950

gcc/ChangeLog:

	* tree-vect-patterns.cc (vect_recog_gather_scatter_pattern): Use
	original LHS's type.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr118950.c: New test.

(cherry picked from commit f3d4208e79)
2025-05-07 13:11:37 +02:00
GCC Administrator 22eae52b54 Daily bump. 2025-05-07 00:23:50 +00:00
Andrew MacLeod 93b85bdf83 Allow IPA_CP to handle UNDEFINED as VARYING.
When applying a bitmask to reflect ranges, it is sometimes deferred and
this can result in an UNDEFINED result.  IPA is not expecting this, and
add a check for it, and convert to VARYING if encountered.

	PR tree-optimization/120048
	gcc/
	* ipa-cp.cc (ipcp_store_vr_results): Check for UNDEFINED.

	gcc/testsuite/
	* gcc.dg/pr120048.c: New.
2025-05-06 10:45:44 -04:00
Patrick Palka 9d9800938e c++: add fixed testcase [PR109464]
Seems to be fixed by r15-521-g6ad7ca1bb90573.

	PR c++/109464

gcc/testsuite/ChangeLog:

	* g++.dg/template/explicit-instantiation8.C: New test.

(cherry picked from commit 58a9f3ded1)
2025-05-06 14:37:00 +02:00
Jakub Jelinek 6d5a6a26e2 c++: Optimize in maybe_clone_body aliases even when not at_eof [PR113208]
This patch reworks the cdtor alias optimization, such that we can create
aliases even when maybe_clone_body is called not at at_eof time, without trying
to repeat it in maybe_optimize_cdtor.

2024-05-15  Jakub Jelinek  <jakub@redhat.com>
	    Jason Merrill  <jason@redhat.com>

	PR lto/113208
	* cp-tree.h (maybe_optimize_cdtor): Remove.
	* decl2.cc (tentative_decl_linkage): Call maybe_make_one_only
	for implicit instantiations of maybe in charge ctors/dtors
	declared inline.
	(import_export_decl): Don't call maybe_optimize_cdtor.
	(c_parse_final_cleanups): Formatting fixes.
	* optimize.cc (can_alias_cdtor): Adjust condition, for
	HAVE_COMDAT_GROUP && DECL_ONE_ONLY && DECL_WEAK return true even
	if not DECL_INTERFACE_KNOWN.
	(maybe_clone_body): Don't clear DECL_SAVED_TREE, instead set it
	to void_node.
	(maybe_clone_body): Remove.
	* decl.cc (cxx_comdat_group): For DECL_CLONED_FUNCTION_P
	functions if SUPPORTS_ONE_ONLY return DECL_COMDAT_GROUP if already
	set.

	* g++.dg/abi/comdat3.C: New test.
	* g++.dg/abi/comdat4.C: New test.

(cherry picked from commit 6ad7ca1bb9)
2025-05-06 14:36:36 +02:00
Dhruv Chawla 1db1249b83 libstdc++: Add missing feature-test macro in <memory>
Per version.syn#2, <memory> is required to define
__cpp_lib_addressof_constexpr as 201603L.

Bootstrapped and tested on aarch64-linux-gnu.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>

libstdc++-v3/ChangeLog:
	* include/std/memory: Define __glibcxx_want_addressof_constexpr.
	* testsuite/20_util/headers/memory/version.cc: Test for macro
	value.

(cherry picked from commit 0e65fef871)
2025-05-06 12:55:16 +01:00
GCC Administrator 59ec83c70e Daily bump. 2025-05-06 00:23:07 +00:00
Iain Sandoe b692099366 c++/coroutines: Fix awaiter var creation [PR116506]
Awaiters always need to have a coroutine state frame copy since
they persist across potential supensions.  It simplifies the later
analysis considerably to assign these early which we do when
building co_await expressions.

The cleanups in r15-3146-g47dbd69b1, unfortunately elided some of
processing used to cater for cases where the var created from an
xvalue, or is a pointer/reference type.

Corrected thus.

	PR c++/116506
	PR c++/116880

gcc/cp/ChangeLog:

	* coroutines.cc (build_co_await): Ensure that xvalues are
	materialised.  Handle references/pointer values in awaiter
	access expressions.
	(is_stable_lvalue): New.
	* decl.cc (cxx_maybe_build_cleanup): Handle null arg.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr116506.C: New test.
	* g++.dg/coroutines/pr116880.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 4c743798b1)
2025-05-05 23:35:43 +01:00
Jason Merrill b6094031ee c++: fix conversion issues
back-port the coroutine part of this.

Some issues caught by a check from another patch:

In build_ramp_function, we're assigning REFERENCE_TYPE things, so we need to
build the assignment directly rather than rely on functions that implement
C++ semantics.

gcc/cp/ChangeLog:

	* coroutines.cc (cp_coroutine_transform::build_ramp_function): Build
	INIT_EXPR directly.

(cherry picked from commit dd3f3c71df)
2025-05-05 23:31:02 +01:00
Iain Sandoe bcd0d98c9f c++, coroutines:Ensure bind exprs are visited once [PR98935].
Recent changes in the C++ FE and the coroutines implementation have
exposed a latent issue in which a bind expression containing a var
that we need to capture in the coroutine state gets visited twice.
This causes an ICE (from a checking assert).  Fixed by adding a pset
to the relevant tree walk.  Exit the callback early when the tree is
not a BIND_EXPR.

	PR c++/98935

gcc/cp/ChangeLog:

	* coroutines.cc (register_local_var_uses): Add a pset to the
	tree walk to avoid visiting the same BIND_EXPR twice.  Make
	an early exit for cases that the callback does not apply.
	(cp_coroutine_transform::apply_transforms): Add a pset to the
	tree walk for register_local_vars.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr98935.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit bd8c7e71f5)
2025-05-05 23:26:40 +01:00
Arsen Arsenović b4000f9224 c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]
If we reach a CLEANUP_POINT_EXPR while trying to walk statements, we
actually care about the statement or statement list contained within it.

Indeed, such a construction started happening with
r15-3513-g964577c31df206, after temporary promotion.  In the test case
presented in PR116793, the compiler generated:

  <<cleanup_point {
    struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    int T002 [value-expr: frame_ptr->T002_2_3];

      int T002 [value-expr: frame_ptr->T002_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (T002 = TARGET_EXPR <D.20994, 3>) >>>>>;
      struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (Aw0 = TARGET_EXPR <D.20995, func ((int &) &T002)>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.22450 = <<< Unknown tree: co_await
        TARGET_EXPR <D.20995, func ((int &) &T002)>
        Aw0

        {_cleanup_task::await_ready (&Aw0), _cleanup_task::await_suspend<_task1::promise_type> (&Aw0, TARGET_EXPR <D.21078, _Coro_self_handle>), <<< Unknown tree: aggr_init_expr
          4
          await_resume
          D.22443
          &Aw0 >>>}
        0 >>>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.20991 = (struct tuple &) &D.22450) >>>>>;
  }
  D.22467 = 1;
  int & i [value-expr: frame_ptr->i_1_2];
  <<cleanup_point <<< Unknown tree: expr_stmt
    (void) (i = std::get<0, int&> (NON_LVALUE_EXPR <D.20991>)) >>>>>;>>;

... i.e. a statement list within a cleanup point.  In such a case, we
don't actually care about the cleanup point, but we do care about the
statement inside, so, we can just walk down into the CLEANUP_POINT_EXPR.

	PR c++/116793

gcc/cp/ChangeLog:

	* coroutines.cc (await_statement_expander): Just process
	subtrees if encountering a CLEANUP_POINT_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr116793-1.C: New test.

(cherry picked from commit d888a8a8dc)
2025-05-05 23:20:23 +01:00
Arsen Arsenović 0ff545dbc2 c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void
convert_to_void has, so far, when converting a co_await expression to
void altered the await_resume expression of a co_await so that it is
also converted to void.  This meant that the type of the await_resume
expression, which is also supposed to be the type of the whole co_await
expression, was not the same as the type of the CO_AWAIT_EXPR tree.

While this has not caused problems so far, it is unexpected, I think.

Also, convert_to_void had a special case when an INDIRECT_REF wrapped a
CALL_EXPR.  In this case, we also diagnosed maybe_warn_nodiscard.  This
was a duplication of logic related to converting call expressions to
void.

Instead, we can generalize a bit, and rather discard the expression that
was implicitly dereferenced instead.

This patch changes the diagnostic of:

  void f(struct S* x) { static_cast<volatile S&>(*x); }

... from:

  warning: indirection will not access object of incomplete type
           'volatile S' in statement

... to:

  warning: implicit dereference will not access object of type
           ‘volatile S’ in statement

... but should have no impact in other cases.

gcc/cp/ChangeLog:

	* coroutines.cc (co_await_get_resume_call): Return a tree
	directly, rather than a tree pointer.
	* cp-tree.h (co_await_get_resume_call): Adjust signature
	accordingly.
	* cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when
	discarding them.  Simplify handling implicit INDIRECT_REFs.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/nodiscard-1.C: New test.

(cherry picked from commit de03ef6337)
2025-05-05 23:14:07 +01:00
Arsen Arsenović 694b942a17 c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]
If such a diagnostic is necessary, it has already been emitted,
otherwise, it is not correct and emitting it here is inactionable by the
user, and bogus.

	PR c++/116502

gcc/cp/ChangeLog:

	* coroutines.cc (maybe_promote_temps): Convert temporary
	initializers to void without complaining.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/maybe-unused-1.C: New test.
	* g++.dg/coroutines/pr116502.C: New test.

(cherry picked from commit 05e4f07cad)
2025-05-05 23:10:05 +01:00
Iain Sandoe 5dbf5f9f4f c++, coroutines: Revise promise construction/destruction.
In examining the coroutine testcases for unexpected diagnostic output
for 'Wall', I found a 'statement has no effect' warning for the promise
construction in one case.  In particular, the case is where the users
promise type has an implicit CTOR but a user-provided DTOR. Further, the
type does not actually need constructing.

In very early versions of the coroutines code we used to check
TYPE_NEEDS_CONSTRUCTING() to determine whether to attempt to build
a constructor call for the promise.  During review, it was suggested
to use type_build_ctor_call () instead.

This latter call checks the constructors in the type (both user-defined
and implicit) and returns true, amongst other cases if any of the found
CTORs are marked as deprecated.

In a number of places (for example [class.copy.ctor] / 6) the standard
says that some version of an implicit CTOR is deprecated when the user
provides a DTOR.

Thus, for this specific arrangement of promise type, type_build_ctor_call
returns true, because of (for example) a deprecated implicit copy CTOR.

We are not going to use any of the deprecated CTORs and thus will not
see warnings from this - however, since the call returned true, we have
now determined that we should attempt to build a constructor call.

Note as above, the type does not actually require construction and thus
one might expect either a NULL_TREE or error_mark_node in response to
the build_special_member_call ().  However, in practice the function
returns the original instance object instead of a call or some error.

When we add that as a statement it triggers the 'statement has no effect'
warning.

The patch here rearranges the promise construction/destruction code to
allow for the case that a DTOR is required independently of a CTOR. In
addition, we check that the return from build_special_member_call ()
has side effects before we add it as a statement.

gcc/cp/ChangeLog:

	* coroutines.cc
	(cp_coroutine_transform::build_ramp_function): Separate the
	build of promise constructor and destructor.  When evaluating
	the constructor, check that build_special_member_call returns
	an expression with side effects before adding it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 7d14839219)
2025-05-05 23:02:26 +01:00
Iain Sandoe eb600ecb6a c++, coroutines: Fix handling of bool await_suspend() [PR115905].
As noted in the PR the action of the existing implementation was to
treat a false value from await_suspend () as equivalent to "do not
suspend".  Actually it needs to be the equivalent of "resume" - and
we need to restart the dispatcher - since the await_suspend() body
could have already resumed the coroutine.
See also https://github.com/cplusplus/CWG/issues/601 (NAD) for more
discussion.

Since we need to amend the await expansion and the actor build, take
the opportunity to clean up and modernise the code there.  Note that
we need to make the jump back to the dispatcher without any scope
exit cleanups (so we have to use the .CO_SUSPN IFN to do this).

	PR c++/115905

gcc/cp/ChangeLog:

	* coroutines.cc (struct coro_aw_data): Add a member for the
	restart dispatch label.
	(expand_one_await_expression): Rework to modernise and to
	handle the boolean await_suspend() case.
	(build_actor_fn): Rework the dispatcher and allow for a jump
	back to the dispatcher.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/torture/pr115905.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 368ba7aed4)
2025-05-05 21:05:02 +01:00
Arsen Arsenović 74cfbedd24 coros: mark .CO_YIELD as LEAF [PR106973]
We rely on .CO_YIELD calls being followed by an assignment (optionally)
and then a switch/if in the same basic block.  This implies that a
.CO_YIELD can never end a block.  However, since a call to .CO_YIELD is
still a call, if the function containing it calls setjmp, GCC thinks
that the .CO_YIELD can introduce abnormal control flow, and generates an
edge for the call.

We know this is not the case; .CO_YIELD calls get removed quite early on
and have no effect, and result in no other calls, so .CO_YIELD can be
considered a leaf function, preventing generating an edge when calling
it.

PR c++/106973 - coroutine generator and setjmp

	PR c++/106973

gcc/ChangeLog:

	* internal-fn.def (CO_YIELD): Mark as ECF_LEAF.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr106973.C: New test.

(cherry picked from commit 7b7ad3f4b2)
2025-05-05 20:56:38 +01:00
Arsen Arsenović 5a275b5beb c++: don't remove labels during coro-early-expand-ifns [PR105104]
In some scenarios, it is possible for the CFG cleanup to cause one of
the labels mentioned in CO_YIELD, which coro-early-expand-ifns intends
to remove, to become part of some statement.  As a result, when that
label is removed, the statement it became part of becomes invalid,
crashing the compiler.

There doesn't appear to be a reason to remove the labels (anymore, at
least), so let's not do that.

	PR c++/105104

gcc/ChangeLog:

	* coroutine-passes.cc (execute_early_expand_coro_ifns): Don't
	remove any labels.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/torture/pr105104.C: New test.

(cherry picked from commit d9c54e9a03)
2025-05-05 20:52:03 +01:00
Iain Sandoe b2fa7e036e c++, coroutines: The frame pointer is used in the helpers [PR116482].
We have a bogus warning about the coroutine state frame pointers
being apparently unused in the resume and destroy functions.  Fixed
by making the parameters DECL_ARTIFICIAL.

	PR c++/116482

gcc/cp/ChangeLog:

	* coroutines.cc
	(coro_build_actor_or_destroy_function): Make the parameter
	decls DECL_ARTIFICIAL.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr116482.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 8d6d6c8644)
2025-05-05 20:47:20 +01:00
Arsen Arsenović 805b991484 c++/coros: do not assume coros don't nest [PR113457]
In the testcase presented in the PR, during template expansion, an
tsubst of an operand causes a lambda coroutine to be processed, causing
it to get an initial suspend and final suspend.  The code for assigning
awaitable var names (get_awaitable_var) assumed that the sequence Is ->
Is -> Fs -> Fs is impossible (i.e. that one could only 'open' one
coroutine before closing it at a time), and reset the counter used for
unique numbering each time a final suspend occured.  This assumption is
false in a few cases, usually when lambdas are involved.

Instead of storing this counter in a static-storage variable, we can
store it in coroutine_info.  This struct is local to each function, so
we don't need to worry about "cross-contamination" nor resetting.

	PR c++/113457

gcc/cp/ChangeLog:

	* coroutines.cc (struct coroutine_info): Add integer field
	awaitable_number.  This is a counter used for assigning unique
	names to awaitable temporaries.
	(get_awaitable_var): Use awaitable_number from coroutine_info
	instead of the static int awn.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr113457-1.C: New test.
	* g++.dg/coroutines/pr113457.C: New test.

(cherry picked from commit 5cca7517c5)
2025-05-05 20:42:38 +01:00
Iain Sandoe 4042cecd62 c++, coroutines: Look through initial_await target exprs [PR110635].
In the case that the initial awaiter returns an object, the initial await
can be a target expression and we need to look at its initializer to cast
the await_resume() to void and to wrap in a compound expression that sets
the initial_await_resume_called flag.

	PR c++/110635

gcc/cp/ChangeLog:

	* coroutines.cc
	(cp_coroutine_transform::wrap_original_function_body): Look through
	initial await target expressions to find the actual co_await_expr
	that we need to update.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr110635.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit c442a9b78b)
2025-05-05 20:38:54 +01:00
Iain Sandoe ce3f523f9c c++, coroutines: Rework handling of throwing_cleanups [PR102051].
In the fix for PR95822 (r11-7402) we set throwing_cleanup false in the top
level of the coroutine transform code.  However, as the current PR shows,
that is not sufficient.

Any use of cxx_maybe_build_cleanup() can reset the flag, which causes the
check_return_expr () logic to try to add a guard variable and set it.

For the coroutine code, we need to handle the cleanups separately, since
the responsibility for them changes after the first resume point, which
we handle in the ramp exception processing.

Fix this by forcing the "throwing_cleanup" flag false right before the
processing of the return expression.

	PR c++/102051

gcc/cp/ChangeLog:

	* coroutines.cc
	(cp_coroutine_transform::build_ramp_function): Handle
	"throwing_cleanup" here instead of ...
	(cp_coroutine_transform::apply_transforms): ... here.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr102051.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit f0315f7a32)
2025-05-05 20:35:09 +01:00
Iain Sandoe 1b3addb6fe c++, coroutines: Allow convertible get_return_on_allocation_fail [PR109682].
We have been requiring the get_return_on_allocation_fail() call to have the
same type as the ramp.  This is not intended by the standard, so relax that
to allow anything convertible to the ramp return.

	PR c++/109682

gcc/cp/ChangeLog:

	* coroutines.cc
	(cp_coroutine_transform::build_ramp_function): Allow for cases where
	get_return_on_allocation_fail has a type convertible to the ramp
	return type.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr109682.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit f4915e6c4c)
2025-05-05 20:31:04 +01:00
Iain Sandoe 98364636c1 c++, coroutines: Only allow void get_return_object if the ramp is void [PR100476].
Require that the value returned by get_return_object is convertible to
the ramp return.  This means that the only time we allow a void
get_return_object, is when the ramp is also a void function.

We diagnose this early to allow us to exit the ramp build if the return
values are incompatible.

	PR c++/100476

gcc/cp/ChangeLog:

	* coroutines.cc
	(cp_coroutine_transform::build_ramp_function): Remove special
	handling of void get_return_object expressions.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C:
	Adjust expected diagnostic.
	* g++.dg/coroutines/pr102489.C: Avoid void get_return_object.
	* g++.dg/coroutines/pr103868.C: Likewise.
	* g++.dg/coroutines/pr94879-folly-1.C: Likewise.
	* g++.dg/coroutines/pr94883-folly-2.C: Likewise.
	* g++.dg/coroutines/pr96749-2.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit a0b431033c)
2025-05-05 20:25:05 +01:00
GCC Administrator 64ef9df72f Daily bump. 2025-05-05 00:22:31 +00:00
GCC Administrator d76db8647f Daily bump. 2025-05-04 00:21:51 +00:00
GCC Administrator 93442cc0f5 Daily bump. 2025-05-03 00:23:31 +00:00
GCC Administrator 088f3168a9 Daily bump. 2025-05-02 00:24:15 +00:00
Iain SandoeandArsen Arsenović d3389c9623 c++, coroutines: check for members we use in handle_types [PR105475]
Currently, it is possible to ICE GCC by giving it sufficiently broken
code, where sufficiently broken means a std::coroutine_handle missing a
default on the promise_type template argument, and missing members.
As the code generator relies on lookups in the coroutine_handle never
failing (and has no way to signal that error), lets do it ahead of time,
save the result, and use that.  This saves us some lookups and allows us
to propagate an error.

PR c++/105475 - coroutines: ICE in coerce_template_parms, at cp/pt.cc:9183

This includes refactoring from 370a0dee55, ffd521d8dc and
00019b88e7.

gcc/cp/ChangeLog:

	PR c++/105475
	* coroutines.cc (struct coroutine_info): Add from_address.
	Carries the from_address member we looked up earlier.
	(coro_resume_identifier): Remove.  Unused.
	(coro_init_identifiers): Do not initialize the above.
	(struct susp_frame_data): Remove unused members, provide a CTOR.
	(void_coro_handle_address): New variable.  Contains the baselink
	for the std::coroutine_handle<void>::address() instance method.
	(get_handle_type_address): New function.  Looks up and validates
	handle_type::address in a given handle_type.
	(get_handle_type_from_address): New function.  Looks up and
	validates handle_type::from_address in a given handle_type.
	(coro_promise_type_found_p): Remove reliance on
	coroutine_handle<> defaulting the promise type to void.  Store
	get_handle_type_* results where appropriate.
	(struct local_vars_frame_data): Add a CTOR.
	(replace_continue): Look up expression type.
	(get_coroutine_from_address): New helper.  Gets the
	handle_type::from_address BASELINK from a coroutine_info.
	(morph_fn_to_coro): Use susp_frame_data CTOR, and make the suspend
	state hash map local to the morph function. Use CTOR for
	local_vars_frame_data instead of brace init.
	(build_actor_fn): Use the get_coroutine_from_address helper and
	void_coro_handle_address.

gcc/testsuite/ChangeLog:

	PR c++/105475
	* g++.dg/coroutines/pr103868.C: Add std::coroutine_handle
	members we check for now.
	* g++.dg/coroutines/pr105287.C: Ditto.
	* g++.dg/coroutines/pr105301.C: Ditto.
	* g++.dg/coroutines/pr94528.C: Ditto.
	* g++.dg/coroutines/pr94879-folly-1.C: Ditto.
	* g++.dg/coroutines/pr94883-folly-2.C: Ditto.
	* g++.dg/coroutines/pr98118.C: Ditto.
	* g++.dg/coroutines/pr105475.C: New test.
	* g++.dg/coroutines/pr105475-1.C: New test.
	* g++.dg/coroutines/pr105475-2.C: New test.
	* g++.dg/coroutines/pr105475-3.C: New test.
	* g++.dg/coroutines/pr105475-4.C: New test.
	* g++.dg/coroutines/pr105475-5.C: New test.
	* g++.dg/coroutines/pr105475-6.C: New test.
	* g++.dg/coroutines/pr105475-broken-spec.C: New test.
	* g++.dg/coroutines/pr105475-broken-spec-2.C: New test.

Co-authored-by: Arsen Arsenović <arsen@aarsen.me>

(cherry picked from commit 5b4476a165)
2025-05-01 20:02:02 +01:00
Arsen Arsenović ad4c136b90 c++/coroutines: only defer expanding co_{await,return,yield} if dependent [PR112341]
By doing so, we can get diagnostics in template decls when we know we
can.  For instance, in the following:

  awaitable g();
  template<typename>
  task f()
  {
    co_await g();
    co_yield 1;
    co_return "foo";
  }

... the coroutine promise type in each statement is always
std::coroutine_handle<task>::promise_type, and all of the operands are
not type-dependent, so we can always compute the resulting types (and
expected types) of these expressions and statements.

Also, when we do not know the type of the CO_AWAIT_EXPR or
CO_YIELD_EXPR, we now return NULL_TREE as the type rather than
unknown_type_node.  This is more correct, since the type is not unknown,
it just isn't determined yet.  This also means we can remove the
CO_AWAIT_EXPR and CO_YIELD_EXPR special-cases from
type_dependent_expression_p.

PR c++/112341 - error: insufficient contextual information to determine type on co_await result in function template

gcc/cp/ChangeLog:

	PR c++/112341
	* coroutines.cc (struct coroutine_info): Also cache the
	traits type.
	(ensure_coro_initialized): New function.  Makes sure we have
	initialized the coroutine state successfully, or informs the
	caller should it fail to do so.  Extracted from
	coro_promise_type_found_p.
	(coro_get_traits_class): New function.  Gets the (cached)
	coroutine traits type for a given coroutine.  Extracted from
	coro_promise_type_found_p and refactored to cache the result.
	(coro_promise_type_found_p): Use the two functions above.
	(build_template_co_await_expr): New function.  Builds a
	CO_AWAIT_EXPR representing a CO_AWAIT_EXPR in a template
	declaration.
	(build_co_await): Use the above if processing_template_decl, and
	give it a proper type.
	(coro_dependent_p): New function.  Returns true iff its
	argument is a type-dependent expression OR the current functions
	traits class is type dependent.
	(finish_co_await_expr): Defer expansion only in the case
	coro_dependent_p returns true.
	(finish_co_yield_expr): Ditto.
	(finish_co_return_stmt): Ditto.
	* pt.cc (type_dependent_expression_p): Do not treat
	CO_AWAIT/CO_YIELD specially.

gcc/testsuite/ChangeLog:

	PR c++/112341
	* g++.dg/coroutines/pr112341-2.C: New test.
	* g++.dg/coroutines/pr112341-3.C: New test.
	* g++.dg/coroutines/torture/co-yield-03-tmpl-nondependent.C: New
	test.
	* g++.dg/coroutines/pr112341.C: New test.

(cherry picked from commit 32e678b2ed)
2025-05-01 16:45:42 +01:00
Arsen Arsenović 7b4cb031cf c++: diagnose usage of co_await and co_yield in default args [PR115906]
This is a partial fix for PR115906.  Per [expr.await] 2s3, "An
await-expression shall not appear in a default argument
([dcl.fct.default])".  This patch introduces the diagnostic in that
case, and in the case of a co_yield (as co_yield is defined in terms of
co_await, so prerequisites of co_await hold).

PR c++/115906 - [coroutines] missing diagnostic and ICE when co_await used as default argument in function declaration

gcc/cp/ChangeLog:

	PR c++/115906
	* parser.cc (cp_parser_unary_expression): Reject await
	expressions if use of local variables is currently forbidden.
	(cp_parser_yield_expression): Reject yield expressions if use of
	local variables is currently forbidden.

gcc/testsuite/ChangeLog:

	PR c++/115906
	* g++.dg/coroutines/pr115906-yield.C: New test.
	* g++.dg/coroutines/pr115906.C: New test.
	* g++.dg/coroutines/co-await-syntax-02-outside-fn.C: Don't rely
	on default arguments.
	* g++.dg/coroutines/co-yield-syntax-01-outside-fn.C: Ditto.

(cherry picked from commit 0c382da094)
2025-05-01 16:45:08 +01:00
Arsen Arsenovic ee0736f665 c++: fix ICE on FUNCTION_DECLs inside coroutines [PR115906]
When register_local_var_uses iterates a BIND_EXPRs BIND_EXPR_VARS, it
fails to account for the fact that FUNCTION_DECLs might be present, and
later passes it to DECL_HAS_VALUE_EXPR_P.  This leads to a tree check
failure in DECL_HAS_VALUE_EXPR_P:

  tree check: expected var_decl or parm_decl or result_decl, have
  function_decl in register_local_var_uses

We only care about PARM_DECL and VAR_DECL, so select only those.

PR c++/115906 - [coroutines] missing diagnostic and ICE when co_await used as default argument in function declaration

gcc/cp/ChangeLog:

	PR c++/115906
	* coroutines.cc (register_local_var_uses): Only process
	PARM_DECL and VAR_DECLs.

gcc/testsuite/ChangeLog:

	PR c++/115906
	* g++.dg/coroutines/coro-function-decl.C: New test.

(cherry picked from commit a362c9ca4e)
2025-05-01 16:44:41 +01:00
Arsen Arsenović 074a89e4c5 cp/coroutines: do not rewrite parameters in unevaluated contexts
It is possible to use parameters of a parent function of a lambda in
unevaluated contexts without capturing them.  By not capturing them, we
work around the usual mechanism we use to prevent rewriting captured
parameters.  Prevent this by simply skipping rewrites in unevaluated
contexts.  Those won't mind the value not being present anyway.

This prevents an ICE during parameter substitution.  In the testcase
from the PR, the rewriting machinery finds a param in the body of the
coroutine, which it did not previously encounter while processing the
coroutine declaration, and that does not have a DECL_VALUE_EXPR, and
fails.

gcc/cp/ChangeLog:

	PR c++/111728
	* coroutines.cc (rewrite_param_uses): Skip unevaluated
	subexpressions.

gcc/testsuite/ChangeLog:

	PR c++/111728
	* g++.dg/coroutines/pr111728.C: New test.

(cherry picked from commit 1a37d6b732)
2025-05-01 16:44:17 +01:00
Iain Sandoe fbe351c9fa c++, coroutines, contracts: Handle coroutine and void functions [PR110871,PR110872,PR115434].
The current implementation of contracts emits the checks into function
bodies in three places; for pre-conditions at the start of the body,
for asserts in-line in the function body and for post-conditions as an
addition to return statements.

In general (at least with existing "2a" contract semantics) the in-line
contract asserts behave as expected.

However, the mechanism is not applicable to:

 * Handling pre conditions in coroutines since, for those, the standard
  specifies a wrapping of the original function body by functionality
  implementing initial and final suspends (along with some housekeeping
  to route exceptions).  Thus for such transformed function bodies, the
  preconditions then get actioned after the initial suspend, which does
  not behave as intended.

  * Handling post conditions in functions that do not have return
    statements (which applies to coroutines and void functions).

In the following, we identify a potentially transformed function body
(in the case of coroutines, this is usually called the "ramp()" function).

The patch here re-implements the code insertion in one of the two
following ways (code for exposition only):

  * For functions with no post-conditions we wrap the potentially
    transformed function as follows:

  {
     handle_pre_condition_checking ();
     potentially_transformed_function_body ();
  }

  This implements the intent that the preconditions are processed after
  the function parameters are initialised but before any other actions.

  * For functions with post-conditions:

  if (preconditions_exist)
    handle_pre_condition_checking ();
  try
   {
     potentially_transformed_function_body ();
   }
  finally
   {
     handle_post_condition_checking ();
   }
  else [only if the function is not marked noexcept(true) ]
   {
     ;
   }

In this, post-conditions [that might apply to the return value etc.]
are evaluated on every non-exceptional edge out of the function.

At present, the model here is that exceptions thrown by the function
propagate upwards as if there were no contracts present.  If the desired
semantic becomes that an exception is counted as equivalent to a contract
violation - then we can add a second handler in place of the empty
statement.

This patch specifically does not address changes to code-gen and constexpr
handling that are contained in P2900.

	PR c++/115434
	PR c++/110871
	PR c++/110872

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_constant_expression): Handle EH_ELSE_EXPR.
	* contracts.cc (finish_contract_attribute): Remove excess line.
	(build_contract_condition_function): Post condition handlers are
	void now.
	(emit_postconditions_cleanup): Remove.
	(emit_postconditions): New.
	(add_pre_condition_fn_call): New.
	(add_post_condition_fn_call): New.
	(apply_preconditions): New.
	(apply_postconditions): New.
	(maybe_apply_function_contracts): New.
	(apply_postcondition_to_return): Remove.
	* contracts.h (apply_postcondition_to_return): Remove.
	(maybe_apply_function_contracts): Add.
	* coroutines.cc (coro_build_actor_or_destroy_function): Do not
	copy contracts to coroutine helpers.
	* decl.cc (finish_function): Handle wrapping a possibly
	transformed function body in contract checks.
	* typeck.cc (check_return_expr): Remove handling of post
	conditions on return expressions.

gcc/ChangeLog:

	* gimplify.cc (struct gimplify_ctx): Add a flag to show we are
	expending a handler.
	(gimplify_expr): When we are expanding a handler, and the body
	transforms might have re-written DECL_RESULT into a gimple var,
	ensure that hander references to DECL_RESULT are also re-written
	to refer to the gimple var.  When we are processing an EH_ELSE
	expression, then add it if either of the cleanup slots is in
	use.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/pr115434.C: New test.
	* g++.dg/coroutines/pr110871.C: New test.
	* g++.dg/coroutines/pr110872.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit d1706235ed)
2025-05-01 16:43:34 +01:00
Iain Sandoe dbba3c9008 configure, Darwin: Recognise new naming for Xcode ld.
The latest editions of XCode have altered the identify reported by 'ld -v'
(again).  This means that GCC configure no longer detects the version.

Fixed by adding the new name to the set checked.

gcc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Recognise PROJECT:ld-mmmm.nn.aa as an identifier
	for Darwin's static linker.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 7f56a8e8ad)
2025-05-01 15:51:24 +01:00
Iain Sandoe 623aaebc7d includes, Darwin: Handle modular use for macOS SDKs [PR116827].
Recent changes to the OS SDKs have altered the way in which include guards
are used for a number of headers when C++ modules are enabled.  Instead of
placing the guards in the included header, they are being placed in the
including header.  This breaks the assumptions in the current GCC stddef.h
specifically, that the presence of __PTRDIFF_T and __SIZE_T means that the
relevant defs are already made.  However in the case of the module-enabled
C++ with these SDKs, that is no longer true.

stddef.h has a large body of special-cases already, but it seems that the
only viable solution here is to add a new one specifically for __APPLE__
and modular code.

This fixes around 280 new fails in the modules test-suite; it is needed on
all open branches that support modules.

	PR target/116827

gcc/ChangeLog:

	* ginclude/stddef.h: Undefine __PTRDIFF_T and __SIZE_T for module-
	enabled c++ on Darwin/macOS platforms.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 9cf6b52d04)
2025-05-01 15:50:57 +01:00
Iain Sandoe 84ac2f4661 testsuite, gm2: Use -B option for libstdc++ where required.
We need to add testsuite  options to locate gm2 libs and libstdc++.

Usually '-L' options are added to point to the relevant directories for
the uninstalled libraries.

In cases where libraries are available as both shared and convenience some
additional checks are made.

For some targets -static-xxxx options are handled by specs substitution and
need a '-B' option rather than '-L'.  For Darwin, when embedded runpaths are
in use (the default for all versions after macOS 10.11), '-B' is also needed
to provide the runpath.

When '-B' is used, this results in a '-L' for each path that exists (so that
appending a '-L' as well is a needless duplicate).  There are also cases
where tools warn for duplicates, leading to spurious fails.

Therefore the objective of the code here is to add just one '-L' or '-B' for
each of the libraries.

Currently, we are forcing the full paths to each of the gm2 convenience libs
onto the link line and therefore the B/L logic is not needed there.  It would
need to be added if/when gm2 is tested with shared libraries

gcc/testsuite/ChangeLog:

	* lib/gm2.exp: Arrange for a '-B' option to be added for the
	libstdc++ paths on targets that need it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 6b9ceac9e4)
2025-05-01 15:50:32 +01:00
Iain SandoeandAndrew Pinski 86b51d7287 Darwin: Pass -macos_version_min to the linker [PR119172].
For binaries to be notarised, the SDK version must be available.
Since we do not, at present, parse this information we have been
passing "0.0" to ld64.  This now results in a warning and a fail
to notarise.  As a quick-fix, we can fall back to letting ld64
figure out the SDK version (which it does for -macos_version_min).

TODO: Parse the SDKSetting.plist at some point.

cherry-picked from 952e17223d and fc728cfd56

	PR target/119172

gcc/ChangeLog:

	* config.in: Regenerate.
	* config/darwin.h (DARWIN_PLATFORM_ID): Add the option to
	use -macos_version_min where available.
	* configure: Regenerate.
	* configure.ac: Check for ld64 support of -macos_version_min.

Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-05-01 15:50:01 +01:00
Francois-Xavier Coudert bfed396d6a fixincludes: adjust stdio fix for macOS 15 headers
fixincludes/ChangeLog:

	* fixincl.x: Regenerate.
	* inclhack.def (apple_local_stdio_fn_deprecation): Also apply to
	_stdio.h.

(cherry picked from commit 1dc1431815)
2025-05-01 15:49:38 +01:00
Mark Mentovai cae584bddd libgcc, Darwin: Drop the legacy library build for macOS >= 10.12 [PR116809].
From macOSX15 SDK,  the unwinder no longer exports some of the symbols used
in that library which (a) causes bootstrap fail and (b) means that the
legacy library is no longer useful.

No open branch of GCC emits references to this library - and any already
-built code that depends on the symbols would need rework anyway.

We have been asked to extend this back to the earliest OS vesion supported
by the SDK (10.12).

	PR target/116809

libgcc/ChangeLog:

	* config.host: Build legacy libgcc_s.1 on hosts before macOS 10.12.
	* config/i386/t-darwin: Remove reference to legacy libgcc_s.1
	* config/rs6000/t-darwin: Likewise.
	* config/t-darwin-libgccs1: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit d9cafa0c4f)
2025-05-01 15:49:04 +01:00
GCC Administrator c120e047ec Daily bump. 2025-05-01 00:25:52 +00:00
Harald Anlauf 475cec3223 Fortran: pure subroutine with pure procedure as dummy [PR106948]
PR fortran/106948

gcc/fortran/ChangeLog:

	* resolve.cc (gfc_pure_function): If a function has been resolved,
	but esym is not yet set, look at its attributes to see whether it
	is pure or elemental.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 4e3060ee17)
2025-04-30 22:57:10 +02:00
Patrick Palka 30432ffd92 c++: UNBOUND_CLASS_TEMPLATE context substitution [PR119981]
In r15-123 and r14-11434 we unconditionally set processing_template_decl
when substituting the context of an UNBOUND_CLASS_TEMPLATE, in order to
handle instantiation of the dependently scoped friend declaration

  template<int N>
  template<class T>
  friend class A<N>::B;

where the scope A<N> remains dependent after instantiation.  But this
turns out to misbehave for the UNBOUND_CLASS_TEMPLATE in the below
testcase representing

  g<[]{}>::template fn

since with the flag set substituting the args of test3 into the lambda
causes us to defer the substitution and yield a lambda that still looks
dependent, which in turn makes g<[]{}> still dependent and not suitable
for qualified name lookup.

This patch restricts setting processing_template_decl during
UNBOUND_CLASS_TEMPLATE substitution to the case where there are multiple
levels of introduced template parameters, as in the friend declaration.
(This means we need to substitute the template parameter list(s) first,
which makes sense since they lexically appear first.)

	PR c++/119981
	PR c++/119378

gcc/cp/ChangeLog:

	* pt.cc (tsubst) <case UNBOUND_CLASS_TEMPLATE>: Substitute
	into template parameter list first.  When substituting the
	context, only set processing_template_decl if there's more
	than one level of introduced template parameters.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ15.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 05ea8baf6f)
2025-04-30 13:00:08 -04:00
Richard Sandiford fd9d35f68e testsuite: Force -mcmodel=small for gcc.target/aarch64/pr115258.c
The test implicitly assumed the default code model and so failed
for -mcmodel=tiny.

gcc/testsuite/
	* gcc.target/aarch64/pr115258.c: Add -mcmodel=small.

(cherry picked from commit 3584aab37f)
2025-04-30 16:40:44 +01:00
Eric Botcazou 51d7659394 Fix GNAT build failure for x86/FreeBSD
gcc/ada/
	PR ada/112958
	* Makefile.rtl (LIBGNAT_TARGET_PAIRS) [x86 FreeBSD]: Add specific
	version of s-dorepr.adb.
	* libgnat/s-dorepr__freebsd.adb: New file.
2025-04-30 12:45:12 +02:00
Georg-Johann Lay 1ca1c1fc3b AVR: target/119989 - Add missing clobbers to xload_<mode>_libgcc.
libgcc's __xload_1...4 is clobbering Z (and also R21 is some cases),
but avr.md had clobbers of respective GPRs only up to reload.
Outcome was that code reading from the same __memx address twice
could be wrong.  This patch adds respective clobbers.

gcc/
	* config/avr/avr.md (xload_<mode>_libgcc): Clobber R21, Z.

gcc/testsuite/
	* gcc.target/avr/torture/pr119989.h: New file.
	* gcc.target/avr/torture/pr119989-memx-1.c: New test.
	* gcc.target/avr/torture/pr119989-memx-2.c: New test.
	* gcc.target/avr/torture/pr119989-memx-3.c: New test.
	* gcc.target/avr/torture/pr119989-memx-4.c: New test.
2025-04-30 08:58:43 +02:00
François DumontandJonathan Wakely 3418d740b3 libstdc++: [_GLIBCXX_INLINE_VERSION] Fix tests failures
Adapt testsuite v3_target_compile to strip version namespace from compiler
output so that dg-error and dg-warning directives do not need to consider it.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (v3_target_compile): Strip version namespace
	from compiler output.
	* testsuite/20_util/function/cons/70692.cc: Remove now useless __8 namespace
	pattern.
	* testsuite/23_containers/map/48101_neg.cc: Likewise.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

(cherry picked from commit 8709d6a178)
2025-04-30 07:41:32 +02:00
Vineet Gupta e363940e1c RISC-V: vsetvl: elide abnormal edges from LCM computations [PR119533]
vsetvl phase4 uses LCM guided info to insert VSETVL insns, including a
straggler loop for "mising vsetvls" on certain edges. Currently it
asserts on encountering EDGE_ABNORMAL.

When enabling go frontend with V enabled, libgo build hits the assert.

The solution is to prevent abnormal edges from getting into LCM at all
(my prior attempt at this just ignored them after LCM which is not
right). Existing invalid_opt_bb_p () current does this for BB predecessors
but not for successors which is what the patch adds.

Crucially, the ICE/fix also depends on avoiding vsetvl hoisting past
non-transparent blocks: That is taken care of by Robin's patch
"RISC-V: Do not lift up vsetvl into non-transparent blocks [PR119547]"
for a different yet related issue.

Reported-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>

	PR target/119533

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (invalid_opt_bb_p): Check for
	EDGE_ABNOMAL.
	(pre_vsetvl::compute_lcm_local_properties): Initialize kill
	bitmap.
	Debug dump skipped edge.

gcc/testsuite/ChangeLog:

	* go.dg/pr119533-riscv.go: New test.
	* go.dg/pr119533-riscv-2.go: New test.

(cherry picked from commit edb4867412)
2025-04-30 10:59:25 +08:00
Robin Dapp ae6ce4cd33 RISC-V: Do not lift up vsetvl into non-transparent blocks [PR119547].
When lifting up a vsetvl into a block we currently don't consider the
block's transparency with respect to the vsetvl as in other parts of the
pass.  This patch does not perform the lift when transparency is not
guaranteed.

This condition is more restrictive than necessary as we can still
perform a vsetvl lift if the conflicting register is only every used
in vsetvls and no regular insns but given how late we are in the GCC 15
cycle it seems better to defer this.  Therefore
gcc.target/riscv/rvv/vsetvl/avl_single-68.c is XFAILed for now.

This issue was found in OpenCV where it manifests as a runtime error.
Zhijin Zeng debugged PR119547 and provided an initial patch.

Reported-By: 曾治金 <zhijin.zeng@spacemit.com>

	PR target/119547

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (pre_vsetvl::earliest_fuse_vsetvl_info):
	Do not perform lift if block is not transparent.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/avl_single-68.c: xfail.
	* g++.target/riscv/rvv/autovec/pr119547.C: New test.
	* g++.target/riscv/rvv/autovec/pr119547-2.C: New test.
	* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-3.c: Adjust.
	* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-12.c: Adjust.
	* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-10.c: Adjust.

(cherry picked from commit 517f7e3f02)
2025-04-30 10:59:11 +08:00
GCC Administrator eaa9b75984 Daily bump. 2025-04-30 00:24:00 +00:00
liuhongt 96729baa9e Remove other processors from X86_TUNE_DEST_FALSE_DEP_FOR_GLC except GLC
Since the tune if only for GLC(sapphirerapids and alderlake-P).

gcc/ChangeLog:

	* config/i386/x86-tune.def (X86_TUNE_DEST_FALSE_DEP_FOR_GLC):
	Remove other processor except for GLC since this one is only
	for GLC.

(cherry picked from commit 1ad6e171b1)
2025-04-29 00:08:22 -07:00
Patrick Palka d23d35d3b7 libstdc++: Improve optional's <=> constraint recursion workaround [PR104606]
It turns out the reason the behavior of this testcase changed after CWG
2369 is because validity of the substituted return type is now checked
later, after constraints.  So a more reliable workaround for this issue
is to add a constraint to check the validity of the return type earlier,
matching the pre-CWG 2369 semantics.

	PR libstdc++/104606

libstdc++-v3/ChangeLog:

	* include/std/optional (operator<=>): Revert r14-9771 change.
	Add constraint checking the validity of the return type
	compare_three_way_result_t before the three_way_comparable_with
	constraint.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 815f1f27a1)
2025-04-28 21:37:48 -04:00
Patrick Palka d03c58584d libstdc++: Add code comment documenting LWG 4027 change [PR118083]
PR libstdc++/118083

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h
	(ranges::__access::__possibly_const_range): Mention LWG 4027.

(cherry picked from commit 640697f7c2)
2025-04-28 21:37:48 -04:00
Patrick Palka d4f5243c6f libstdc++: Implement LWG 4027 change to possibly-const-range [PR118083]
LWG 4027 effectively makes the const range access CPOs ranges::cfoo behave
more consistently across C++23 and C++20 (pre-P2278R4) and also more
consistently with the std::cfoo range accessors, as the below testcase
adjustments demonstrate (which mostly consist of reverting workarounds
added by r14-3771-gf12e26f3496275 and r13-7186-g0d94c6df183375).

In passing fix PR118083 which reports that the input_range constraint on
possibly-const-range is missing in our implementation.  A consequence of
this is that the const range access CPOs now consistently reject a non-range
argument, and so in some our of tests we need to introduce otherwise
unused begin/end members.

	PR libstdc++/118083

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h
	(ranges::__access::__possibly_const_range): Adjust logic as per
	LWG 4027.  Add missing input_range constraint.
	* testsuite/std/ranges/access/cbegin.cc (test05): Verify LWG
	4027 testcases.
	* testsuite/std/ranges/access/cdata.cc: Adjust, simplify and
	consolidate some tests after the above.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/crbegin.cc: Likewise.
	* testsuite/std/ranges/access/crend.cc: Likewise.
	* testsuite/std/ranges/adaptors/join.cc: Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 1b9e4fe2ff)
2025-04-28 21:37:47 -04:00
Patrick Palka d3cb17bed3 c++: prev declared hidden tmpl friend inst, cont [PR119807]
When remapping existing specializations of a hidden template friend from
a previous declaration to the new definition, we must remap only those
specializations that match this new definition, but currently we
remap all specializations (since they all appear in the same
DECL_TEMPLATE_INSTANTIATIONS list of the most general template).

Concretely, in the first testcase below, we form two specializations of
the friend A::f, one with arguments {{0},{bool}} and another with
arguments {{1},{bool}}.  Later when instantiating B, we need to remap
these specializations.  During the B<0> instantiation we only want to
remap the first specialization, and during the B<1> instantiation only
the second specialization, but currently we remap both specializations
twice.

tsubst_friend_function needs to determine if an existing specialization
matches the shape of the new definition, which is tricky in general,
e.g. if the outer template parameters may not match up.  Fortunately we
don't have to reinvent the wheel here since is_specialization_of_friend
seems to do exactly what we need.  We can check this unconditionally,
but I think it's only necessary when dealing with specializations formed
from a class template scope previous declaration, hence the
TMPL_ARGS_HAVE_MULTIPLE_LEVELS check.

	PR c++/119807
	PR c++/112288

gcc/cp/ChangeLog:

	* pt.cc (tsubst_friend_function): Skip remapping an
	existing specialization if it doesn't match the shape of
	the new friend definition.

gcc/testsuite/ChangeLog:

	* g++.dg/template/friend86.C: New test.
	* g++.dg/template/friend87.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 369461d074)
2025-04-28 21:37:47 -04:00
GCC Administrator 615e392c8b Daily bump. 2025-04-29 00:25:10 +00:00
Jason Merrill 1e91580d64 c++: format attribute redeclaration [PR116954]
Here when merging the two decls, remove_contract_attributes loses
ATTR_IS_DEPENDENT on the format attribute, so apply_late_template_attributes
just returns, so the attribute doesn't get propagated to the type where the
warning looks for it.

Fixed by using copy_node instead of tree_cons to preserve flags.

	PR c++/116954

gcc/cp/ChangeLog:

	* contracts.cc (remove_contract_attributes): Preserve flags
	on the attribute list.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wformat-3.C: New test.

(cherry picked from commit b0d7d644f3)
2025-04-28 16:13:32 -04:00
Jason Merrill 8dce1aa057 c++: shortcut constexpr vector ctor [PR113835]
Since std::vector became usable in constant evaluation in C++20, a vector
variable with static storage duration might be manifestly
constant-evaluated, so we properly try to constant-evaluate its initializer.
But it can never succeed since the result will always refer to the result of
operator new, so trying is a waste of time.  Potentially a large waste of
time for a large vector, as in the testcase in the PR.

So, let's recognize this case and skip trying constant-evaluation.  I do
this only for the case of an integer argument, as that's the case that's
easy to write but slow to (fail to) evaluate.

In the test, I use dg-timeout-factor to lower the default timeout from 300
seconds to 15; on my laptop, compilation without the patch takes about 20
seconds versus about 2 with the patch.

is_std_class comes from r15-4953.

	PR c++/113835

gcc/cp/ChangeLog:

	* cp-tree.h (is_std_class): Declare.
	* constexpr.cc (is_std_class): New function.
	(is_std_allocator): Use it.
	(cxx_eval_outermost_constant_expr): Bail out early
	for std::vector(N).

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-vector1.C: New test.

(cherry picked from commit 764f02327f)
2025-04-28 16:13:32 -04:00
Tamar Christina 8f4df0d836 middle-end: fix masking for partial vectors and early break [PR119351]
The following testcase shows an incorrect masked codegen:

#define N 512
#define START 1
#define END 505

int x[N] __attribute__((aligned(32)));

int __attribute__((noipa))
foo (void)
{
  int z = 0;
  for (unsigned int i = START; i < END; ++i)
    {
      z++;
      if (x[i] > 0)
        continue;

      return z;
    }
  return -1;
}

notice how there's a continue there instead of a break.  This means we generate
a control flow where success stays within the loop iteration:

  mask_patt_9.12_46 = vect__1.11_45 > { 0, 0, 0, 0 };
  vec_mask_and_47 = mask_patt_9.12_46 & loop_mask_41;
  if (vec_mask_and_47 == { -1, -1, -1, -1 })
    goto <bb 4>; [41.48%]
  else
    goto <bb 15>; [58.52%]

However when loop_mask_41 is a partial mask this comparison can lead to an
incorrect match.  In this case the mask is:

  # loop_mask_41 = PHI <next_mask_63(6), { 0, -1, -1, -1 }(2)>

due to peeling for alignment with masking and compiling with
-msve-vector-bits=128.

At codegen time we generate:

	ptrue   p15.s, vl4
	ptrue   p7.b, vl1
	not     p7.b, p15/z, p7.b
.L5:
	ld1w    z29.s, p7/z, [x1, x0, lsl 2]
	cmpgt   p7.s, p7/z, z29.s, #0
	not     p7.b, p15/z, p7.b
	ptest   p15, p7.b
	b.none  .L2
	...<early exit>...

Here the basic blocks are rotated and a not is generated.
But the generated not is unmasked (or predicated over an ALL true mask in this
case).  This has the unintended side-effect of flipping the results of the
inactive lanes (which were zero'd by the cmpgt) into -1.  Which then incorrectly
causes us to not take the branch to .L2.

This is happening because we're not comparing against the right value for the
forall case.  This patch gets rid of the forall case by rewriting the
if(all(mask)) into if (!all(mask)) which is the same as if (any(~mask)) by
negating the masks and flipping the branches.

	1. For unmasked loops we simply reduce the ~mask.
	2. For masked loops we reduce (~mask & loop_mask) which is the same as
	   doing (mask & loop_mask) ^ loop_mask.

For the above we now generate:

.L5:
        ld1w    z28.s, p7/z, [x1, x0, lsl 2]
        cmple   p7.s, p7/z, z28.s, #0
        ptest   p15, p7.b
        b.none  .L2

This fixes gromacs with > 1 OpenMP threads and improves performance.

gcc/ChangeLog:

	PR tree-optimization/119351
	* tree-vect-stmts.cc (vectorizable_early_exit): Mask both operands of
	the gcond for partial masking support.

gcc/testsuite/ChangeLog:

	PR tree-optimization/119351
	* gcc.target/aarch64/sve/pr119351.c: New test.
	* gcc.target/aarch64/sve/pr119351_run.c: New test.

    (cherry picked from commit 7cf5503e0a)
2025-04-28 12:59:54 +01:00
Tamar Christina 9ce381170e aarch64: force operand to fresh register to avoid subreg issues [PR118892]
When the input is already a subreg and we try to make a paradoxical
subreg out of it for copysign this can fail if it violates the subreg
relationship.

Use force_lowpart_subreg instead of lowpart_subreg to then force the
results to a register instead of ICEing.

gcc/ChangeLog:

	PR target/118892
	* config/aarch64/aarch64.md (copysign<GPF:mode>3): Use
	force_lowpart_subreg instead of lowpart_subreg.

gcc/testsuite/ChangeLog:

	PR target/118892
	* gcc.target/aarch64/copysign-pr118892.c: New test.
2025-04-28 12:58:37 +01:00
GCC Administrator 3e448248f6 Daily bump. 2025-04-28 00:23:07 +00:00
GCC Administrator 035da7bc62 Daily bump. 2025-04-27 00:22:58 +00:00
GCC Administrator 294ed13676 Daily bump. 2025-04-26 00:24:19 +00:00
John David Anglin 57f930fa97 libbacktrace: Add hpux fileline support
Fixes libstdc++ stacktrace tests.

2025-04-10  John David Anglin  <danglin@gcc.gnu.org>

libbacktrace/ChangeLog:
	* fileline.c (hpux_get_executable_path): New.
	(fileline_initialize): Add pass to get hpux executable path.
2025-04-25 08:36:11 -04:00
GCC Administrator 2a9fd7eca8 Daily bump. 2025-04-25 00:23:24 +00:00
Martin Jambor cd7c5d9729 sra: Clear grp_same_access_path of acesses created by total scalarization (PR118924)
During analysis of PR 118924 it was discussed that total scalarization
invents access paths (strings of COMPONENT_REFs and possibly even
ARRAY_REFs) which did not exist in the program before which can have
unintended effects on subsequent AA queries.  Although not doing that
does not mean that SRA cannot create such situations (see the bug for
more info), it has been agreed that not doing this is generally better.
This patch therfore makes SRA fall back on creating simple MEM_REFs when
accessing components of an aggregate corresponding to what a SRA
variable now represents.

gcc/ChangeLog:

2025-03-26  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/118924
	* tree-sra.cc (create_total_scalarization_access): Set
	grp_same_access_path flag to zero.

(cherry picked from commit 40445711b8)
2025-04-24 16:49:39 +02:00
Martin Jambor 19dd791b3a sra: Avoid creating TBAA hazards (PR118924)
The testcase in PR 118924, when compiled on Aarch64, contains an
gimple aggregate assignment statement in between different types which
are types_compatible_p but behave differently for the purposes of
alias analysis.

SRA replaces the statement with a series of scalar assignments which
however have LHSs access chains modeled on the RHS type and so do not
alias with a subsequent reads and so are DSEd.

SRA clearly gets its "same_access_path" logic subtly wrong.  One issue
is that the same_access_path_p function probably should be implemented
more along the lines of (parts of ao_compare::compare_ao_refs) instead
of internally relying on operand_equal_p.  That is however not the
problem in the PR and so I will deal with it only later.

The issue here is that even when the access path is the same, it must
not be bolted on an aggregate type that does not match.  This patch
does that, taking just one simple function from the
ao_compare::compare_ao_refs machinery and using it to detect the
situation.  The rest is just merging the information in between
accesses of the same access group.

I looked at how many times we come across such assignment during
"make stage2-bubble" of GCC (configured with only c and C++ and
without multilib and libsanitizers) and on an x86_64 there were 87924
such assignments (though now I realize not all of them had to be
aggregate), so they do happen.  The patch leads to about 5% increase
of cases where we don't use an "access path" but resort to a
MEM_REF (from 90209 to 95204).  On an Aarch64, there were 92268 such
assignments and the increase of falling back to MEM_REFs was by
4% (but from a bigger base 132983 to 107991).

gcc/ChangeLog:

2025-04-04  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/118924
	* tree-ssa-alias-compare.h (types_equal_for_same_type_for_tbaa_p):
	Declare.
	* tree-ssa-alias.cc: Include ipa-utils.h.
	(types_equal_for_same_type_for_tbaa_p): New public overloaded variant.
	* tree-sra.cc: Include tree-ssa-alias-compare.h.
	(create_access): Initialzie grp_same_access_path to true.
	(build_accesses_from_assign): Detect tbaa hazards and clear
	grp_same_access_path fields of involved accesses when they occur.
	(sort_and_splice_var_accesses): Take previous values of
	grp_same_access_path into account.

gcc/testsuite/ChangeLog:

2025-03-25  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/118924
	* g++.dg/tree-ssa/pr118924.C: New test.

(cherry picked from commit 07d2436700)
2025-04-24 16:49:22 +02:00
Stefan Schulze Frielinghaus 29004acab5 s390: Accept only Pmode for registers AP/FP/RA [PR119235]
gcc/ChangeLog:

	PR target/119235
	* config/s390/s390.cc (s390_hard_regno_mode_ok): Accept only
	Pmode for registers AP/FP/RA.

(cherry picked from commit 2b383ae2a6)
2025-04-24 11:18:36 +02:00
Jason Merrill 8d70737492 c++: templates, attributes, #pragma target [PR114772]
Since r12-5426 apply_late_template_attributes suppresses various global
state to avoid applying active pragmas to earlier declarations; we also
need to override target_option_current_node.

	PR c++/114772
	PR c++/101180

gcc/cp/ChangeLog:

	* pt.cc (apply_late_template_attributes): Also override
	target_option_current_node.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/pragma-target2.C: New test.

(cherry picked from commit 5fdb0145fb)
2025-04-23 17:09:41 -04:00
Jeremy Bettis 8a884140c2 libcpp: Fix incorrect line numbers in large files [PR108900]
This patch addresses an issue in the C preprocessor where incorrect
line number information is generated when processing files with a
large number of lines. The problem arises from improper handling
of location intervals in the line map, particularly when locations
exceed LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES.

By ensuring that the highest location is not decremented if it
would move to a different ordinary map, this fix resolves
the line number discrepancies observed in certain test cases.
This change improves the accuracy of line number reporting, benefiting
users relying on precise code coverage and debugging information.

Tested x86_64-linux.

libcpp/ChangeLog:

	PR preprocessor/108900
	* files.cc (_cpp_stack_file): Do not decrement highest_location
	across distinct maps.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
(cherry picked from commit d9b56c65a2)
2025-04-23 17:07:15 -04:00
Jason Merrill 70eaec53f3 c++: constexpr, trivial, and non-alias target [PR111075]
On Darwin and other targets with !can_alias_cdtor, we instead go to
maybe_thunk_ctor, which builds a thunk function that calls the general
constructor.  And then cp_fold tries to constant-evaluate that call, and we
ICE because we don't expect to ever be asked to constant-evaluate a call to
a trivial function.

No new test because this fixes g++.dg/torture/tail-padding1.C on affected
targets.

	PR c++/111075

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Allow trivial
	call from a thunk.

(cherry picked from commit 628aecb050)
2025-04-23 05:15:38 -04:00
GCC Administrator 9ef0cf0199 Daily bump. 2025-04-23 00:22:52 +00:00
Richard Biener d7b5fe3400 [14] Use --param=aarch64-autovec-preference=2 instead of =sve-only
This updates the backported test.

	PR tree-optimization/119706
	* g++.target/aarch64/sve/pr119706.C: Adjust --param
	aarch64-autovec-preference.
2025-04-22 16:40:42 +02:00
Richard Biener 4108c75ea1 tree-optimization/119778 - properly mark abnormal edge sources during inlining
When inlining a call that abnormally transfers control-flow we make
all inlined calls that can possibly transfer abnormal control-flow
do so as well.  But we failed to mark the calls as altering
control-flow.  This results in inconsistent behavior later and
possibly wrong-code (we'd eventually prune those edges).

	PR tree-optimization/119778
	* tree-inline.cc (copy_edges_for_bb): Mark calls that are
	source of abnormal edges as altering control-flow.

	* g++.dg/torture/pr119778.C: New testcase.

(cherry picked from commit a48f934211)
2025-04-22 14:51:27 +02:00
Jennifer Schmitz 2bb4a431ea aarch64: Add test case.
This patch adds a test case to the testsuite for PR119706.
The bug was already fixed by
https://gcc.gnu.org/pipermail/gcc-patches/2025-April/680573.html.

OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>

gcc/testsuite/
	PR tree-optimization/119706
	* g++.target/aarch64/sve/pr119706.C: New test.

(cherry picked from commit f6e6e6d9ba)
2025-04-22 14:51:20 +02:00
Richard Biener c8fe937b4e middle-end/119706 - allow POLY_INT_CST as is_gimple_mem_ref_addr
We currently only INTEGER_CST, but not POLY_INT_CST, which leads
to the situation that when the POLY_INT_CST is only indrectly
present via a SSA def the IL is valid but when propagated it's not.
That's unsustainable.

	PR middle-end/119706
	* gimple-expr.cc (is_gimple_mem_ref_addr): Also allow
	POLY_INT_CST.

(cherry picked from commit bf812c6ad8)
2025-04-22 14:51:12 +02:00
Richard Biener a27f6a420c target/119549 - fixup handling of -mno-sse4 in target attribute
The following fixes ix86_valid_target_attribute_inner_p to properly
handle target("no-sse4") via OPT_mno_sse4 rather than as unset OPT_msse4.
I've added asserts to ix86_handle_option that RejectNegative is honored
for both.

	PR target/119549
	* common/config/i386/i386-common.cc (ix86_handle_option):
	Assert that both OPT_msse4 and OPT_mno_sse4 are never unset.
	* config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p):
	Process negated OPT_msse4 as OPT_mno_sse4.

	* gcc.target/i386/pr119549.c: New testcase.

(cherry picked from commit ae2912748b)
2025-04-22 14:51:03 +02:00
Richard Biener 97dde4260c tree-optimization/119534 - reject bogus emulated vectorized gather
The following makes sure to reject the attempts to emulate a vector
gather when the discovered index vector type is a vector mask.

	PR tree-optimization/119534
	* tree-vect-stmts.cc (get_load_store_type): Reject
	VECTOR_BOOLEAN_TYPE_P offset vector type for emulated gathers.

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

(cherry picked from commit d0cc14c62a)
2025-04-22 14:50:56 +02:00
GCC Administrator 721c6121e9 Daily bump. 2025-04-22 00:25:04 +00:00
GCC Administrator 9051989dc2 Daily bump. 2025-04-21 00:21:51 +00:00
GCC Administrator d338d6cd98 Daily bump. 2025-04-20 00:24:44 +00:00
Iain Buclaw 88b3c89660 d: Fix ICE: type variant differs by TYPE_MAX_VALUE with -g [PR119826]
Forward referenced enum types were never fixed up after the main
ENUMERAL_TYPE was finished.  All flags set are now propagated to all
variants after its mode, size, and alignment has been calculated.

	PR d/119826

gcc/d/ChangeLog:

	* types.cc (TypeVisitor::visit (TypeEnum *)): Propagate flags of main
	enum types to all forward-referenced variants.

gcc/testsuite/ChangeLog:

	* gdc.dg/debug/imports/pr119826b.d: New test.
	* gdc.dg/debug/pr119826.d: New test.

(cherry picked from commit c5ffab99a5)
2025-04-19 23:15:57 +02:00
Iain Buclaw d1b7ee4879 d: Fix ICE in dwarf2out_imported_module_or_decl, at dwarf2out.cc:27676 [PR119817]
The ImportVisitor method for handling the importing of overload sets was
pushing NULL_TREE to the array of import decls, which in turn got passed
to `debug_hooks->imported_module_or_decl', triggering the observed
internal compiler error.

NULL_TREE is returned from `build_import_decl' when the symbol was
ignored for being non-trivial to represent in debug, for example,
template or tuple declarations.  So similarly "skip" adding the symbol
when this is the case for overload sets too.

	PR d/119817

gcc/d/ChangeLog:

	* imports.cc (ImportVisitor::visit (OverloadSet *)): Don't push
	NULL_TREE to vector of import symbols.

gcc/testsuite/ChangeLog:

	* gdc.dg/debug/imports/m119817/a.d: New test.
	* gdc.dg/debug/imports/m119817/b.d: New test.
	* gdc.dg/debug/imports/m119817/package.d: New test.
	* gdc.dg/debug/pr119817.d: New test.

(cherry picked from commit f5ed7d19c9)
2025-04-19 23:14:41 +02:00
Iain Buclaw aec3b99d3d d: Fix forward referenced enums missing type names in debug info [PR118309]
Calling `rest_of_type_compilation' as the D types were built meant that
debug info was being emitted before all forward references were
resolved, resulting in DW_AT_name's to be missing.

Instead, defer outputting type debug information until all modules have
been parsed and generated in `d_finish_compilation'.

	PR d/118309

gcc/d/ChangeLog:

	* modules.cc: Include debug.h
	(d_finish_compilation): Call debug_hooks->type_decl on all TYPE_DECLs.
	* types.cc: Remove toplev.h include.
	(finish_aggregate_type): Don't call rest_of_type_compilation or
	rest_of_decl_compilation on type.
	(TypeVisitor::visit (TypeEnum *)): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/debug/dwarf2/pr118309.d: New test.

(cherry picked from commit cee353c265)
2025-04-19 23:11:42 +02:00
Jakub Jelinek d490c5884b libatomic: Fix up libat_{,un}lock_n for mingw [PR119796]
Here is just a port of the previously posted patch to mingw which
clearly has the same problems.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/101075
	PR libgcc/119796
	* config/mingw/lock.c (libat_lock_n, libat_unlock_n): Start with
	computing how many locks will be needed and take into account
	((uintptr_t)ptr % WATCH_SIZE).  If some locks from the end of the
	locks array and others from the start of it will be needed, first
	lock the ones from the start followed by ones from the end.

(cherry picked from commit 34fe8e9000)
2025-04-19 08:13:07 +02:00
Jakub Jelinek 50bd360f92 libatomic: Fix up libat_{,un}lock_n [PR119796]
As mentioned in the PR (and I think in PR101075 too), we can run into
deadlock with libat_lock_n calls with larger n.
As mentioned in PR66842, we use multiple locks (normally 64 mutexes
for each 64 byte cache line in 4KiB page) and currently can lock more
than one lock, in particular for n [0, 64] a single lock, for n [65, 128]
2 locks, for n [129, 192] 3 locks etc.
There are two problems with this:
1) we can deadlock if there is some wrap-around, because the locks are
   acquired always in the order from addr_hash (ptr) up to
   locks[NLOCKS-1].mutex and then if needed from locks[0].mutex onwards;
   so if e.g. 2 threads perform libat_lock_n with n = 2048+64, in one
   case at pointer starting at page boundary and in another case at
   page boundary + 2048 bytes, the first thread can lock the first
   32 mutexes, the second thread can lock the last 32 mutexes and
   then first thread wait for the lock 32 held by second thread and
   second thread wait for the lock 0 held by the first thread;
   fixed below by always locking the locks in order of increasing
   index, if there is a wrap-around, by locking in 2 loops, first
   locking some locks at the start of the array and second at the
   end of it
2) the number of locks seems to be determined solely depending on the
   n value, I think that is wrong, we don't know the structure alignment
   on the libatomic side, it could very well be 1 byte aligned struct,
   and so how many cachelines are actually (partly or fully) occupied
   by the atomic access depends not just on the size, but also on
   ptr % WATCH_SIZE, e.g. 2 byte structure at address page_boundary+63
   should IMHO lock 2 locks because it occupies the first and second
   cacheline

Note, before this patch it locked exactly one lock for n = 0, while
with this patch it could lock either no locks at all (if it is at cacheline
boundary) or 1 (otherwise).
Dunno of libatomic APIs can be called for zero sizes and whether
we actually care that much how many mutexes are locked in that case,
because one can't actually read/write anything into zero sized memory.
If you think it is important, I could add else if (nlocks == 0) nlocks = 1;
in both spots.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/101075
	PR libgcc/119796
	* config/posix/lock.c (libat_lock_n, libat_unlock_n): Start with
	computing how many locks will be needed and take into account
	((uintptr_t)ptr % WATCH_SIZE).  If some locks from the end of the
	locks array and others from the start of it will be needed, first
	lock the ones from the start followed by ones from the end.

(cherry picked from commit 61dfb0747a)
2025-04-19 08:13:07 +02:00
Jakub Jelinek 40c5065956 bitintlower: Fix interaction of gimple_assign_copy_p stmts vs. has_single_use [PR119808]
The following testcase is miscompiled, because we emit a CLOBBER in a place
where it shouldn't be emitted.
Before lowering we have:
  b_5 = 0;
  b.0_6 = b_5;
  b.1_1 = (unsigned _BitInt(129)) b.0_6;
...
  <retval> = b_5;
The bitint coalescing assigns the same partition/underlying variable
for both b_5 and b.0_6 (possible because there is a copy assignment)
and of course a different one for b.1_1 (and other SSA_NAMEs in between).
This is -O0 so stmts aren't DCEd and aren't propagated that much etc.
It is -O0 so we also don't try to optimize and omit some names from m_names
and handle multiple stmts at once, so the expansion emits essentially
  bitint.4 = {};
  bitint.4 = bitint.4;
  bitint.2 = cast of bitint.4;
  bitint.4 = CLOBBER;
...
  <retval> = bitint.4;
and the CLOBBER is the problem because bitint.4 is still live afterwards.
We emit the clobbers to improve code generation, but do it only for
(initially) has_single_use SSA_NAMEs (remembered in m_single_use_names)
being used, if they don't have the same partition on the lhs and a few
other conditions.
The problem above is that b.0_6 which is used in the cast has_single_use
and so was in m_single_use_names bitmask and the lhs in that case is
bitint.2, so a different partition.  But there is gimple_assign_copy_p
with SSA_NAME rhs1 and the partitioning special cases those and while
b.0_6 is single use, b_5 has multiple uses.  I believe this ought to be
a problem solely in the case of such copy stmts and its special case
by the partitioning, if instead of b.0_6 = b_5; there would be
b.0_6 = b_5 + 1; or whatever other stmts that performs or may perform
changes on the value, partitioning couldn't assign the same partition
to b.0_6 and b_5 if b_5 is used later, it couldn't have two different
(or potentially different) values in the same bitint.N var.  With
copy that is possible though.

So the following patch fixes it by being more careful when we set
m_single_use_names, don't set it if it is a has_single_use SSA_NAME
but SSA_NAME_DEF_STMT of it is a copy stmt with SSA_NAME rhs1 and that
rhs1 doesn't have single use, or has_single_use but SSA_NAME_DEF_STMT of it
is a copy stmt etc.

Just to make sure it doesn't change code generation too much, I've gathered
statistics how many times
      if (m_first
          && m_single_use_names
          && m_vars[p] != m_lhs
          && m_after_stmt
          && bitmap_bit_p (m_single_use_names, SSA_NAME_VERSION (op)))
        {
          tree clobber = build_clobber (TREE_TYPE (m_vars[p]),
                                        CLOBBER_STORAGE_END);
          g = gimple_build_assign (m_vars[p], clobber);
          gimple_stmt_iterator gsi = gsi_for_stmt (m_after_stmt);
          gsi_insert_after (&gsi, g, GSI_SAME_STMT);
        }
emits a clobber on
make check-gcc GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS="--target_board=unix\{-m64,-m32\} GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c pr116588.c pr116003.c pr113693.c pr113602.c flex-array-counted-by-7.c' dg-torture.exp='*bitint* pr116480-2.c pr114312.c pr114121.c' dfp.exp=*bitint* i386.exp='pr118017.c pr117946.c apx-ndd-x32-2a.c' vect.exp='vect-early-break_99-pr113287.c' tree-ssa.exp=pr113735.c"
and before this patch it was 41010 clobbers and after it is 40968,
so difference is 42 clobbers, 0.1% fewer.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/119808
	* gimple-lower-bitint.cc (gimple_lower_bitint): Don't set
	m_single_use_names bits for SSA_NAMEs which have single use but
	their SSA_NAME_DEF_STMT is a copy from another SSA_NAME which doesn't
	have a single use, or single use which is such a copy etc.

(cherry picked from commit 5a48e7732d)
2025-04-19 08:13:07 +02:00
Jakub Jelinek efb22612f9 expmed: Always use QImode for init_expmed set_zero_cost [PR119785]
This is a regression on some targets introduced I believe by r6-2055
which added mode argument to set_src_cost.

The problem here is that in the first iteration, mode is always QImode
and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false).
But then we use the mode variable for iterating over int, partial int
and vector int modes, so for the second iteration we call set_src_cost
with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1).

In the x86 case that happens to be V2HFmode and we don't crash (and
compute the same 0 cost as we would for QImode).
But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is
MAX_MACHINE_MODE and that does all kinds of weird things especially
when doing ubsan bootstrap.

Fixed by always using QImode.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/119785
	* expmed.cc (init_expmed): Always pass QImode rather than mode to
	set_src_cost passed to set_zero_cost.

(cherry picked from commit f96a54350a)
2025-04-19 08:13:07 +02:00
Jakub Jelinek 438c4df222 driver: On linux hosts disable ASLR during -freport-bug [PR119727]
Andi had a useful comment that even with the PR119727 workaround to
ignore differences in libbacktrace printed addresses, it is still better
to turn off ASLR when easily possible, e.g. in case some address leaks
in somewhere in the ICE message elsewhere, or to verify the ICE doesn't
depend on a particular library/binary load addresses.

The following patch adds a configure check and uses personality syscall
to turn off randomization for further -freport-bug subprocesses.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR driver/119727
	* configure.ac (HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE): New check.
	* gcc.cc: Include sys/personality.h if
	HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
	(try_generate_repro): Call
	personality (personality (0xffffffffU) | ADDR_NO_RANDOMIZE)
	if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
	* config.in: Regenerate.
	* configure: Regenerate.

(cherry picked from commit 5a32e85810)
2025-04-19 08:13:06 +02:00
Jakub Jelinek 2aa812386a driver: Fix up -freport-bug for ASLR [PR119727]
With --enable-host-pie -freport-bug almost never prepares preprocessed
source and instead emits
The bug is not reproducible, so it is likely a hardware or OS problem.
message even for bogus which are 100% reproducible.
The way -freport-bug works is that it reruns it 3 times, capturing stdout
and stderr from each and then tries to compare the outputs in between
different runs.
The libbacktrace emitted hexadecimal addresses at the start of the lines
can differ between runs due to ASLR, either of the PIE executable, or
even if not PIE if there is some frame with e.g. libc function (say
crash in strlen/memcpy etc.).

The following patch fixes it by ignoring such differences at the start of
the lines.

2025-04-12  Jakub Jelinek  <jakub@redhat.com>

	PR driver/119727
	* gcc.cc (files_equal_p): Rewritten using fopen/fgets/fclose instead
	of open/fstat/read/close.  At the start of lines, ignore lowercase
	hexadecimal addresses followed by space.

(cherry picked from commit 8b2ceb421f)
2025-04-19 08:13:06 +02:00
Jakub Jelinek 056a01f9fa bitintlower: Fix up handling of SSA_NAME copies in coalescing [PR119722]
The following patch is miscompiled, because during the limited
SSA name coalescing the bitintlower pass does we incorrectly don't
register a conflict.
This is on
  <bb 4> [local count: 1073741824]:
  # b_17 = PHI <b_19(3), 8(2)>
  g.4_13 = g;
  _14 = g.4_13 >> 50;
  _15 = (unsigned int) _14;
  _21 = b_17;
  _16 = (unsigned int) _21;
  s_22 = _15 + _16;
  return s_22;
basic block where in the map->bitint bitmap we track 14, 17 and 19.
The build_bitint_stmt_ssa_conflicts "hook" has special code where
it tracks uses at the final statements of mergeable operations, so
e.g. the
  _16 = (unsigned int) _21;
statement is considered to be use of b_17 because _21 is not in
map->bitmap (or large_huge.m_names), i.e. is mergeable.
The problem is that build_ssa_conflict_graph has special code to handle
SSA_NAME copies and _21 = b_17; is gimple_assign_copy_p.  In such cases
it calls live_track_clear_var on the rhs1.  The problem is that
on the above bb, after we note in the _16 = (unsigned int) _21;
stmt we need b_17 the generic code makes us forget that because
of the copy statement, and then build_bitint_stmt_ssa_conflicts
ignores it completely (because _21 is large/huge bitint and is
not in map->bitint, so assumed to be handled by a later stmt in the
bb, for backwards walk like this before this one).
As the b_17 use is ignored, the coalescing thinks it can put
all of b_17, b_19 and _14 into the same partition, which is wrong,
while we can and should coalesce b_17 and b_19, _14 needs to be a different
temporary because b_17 is set before and used after _14 has been written.

The following patch fixes it by handling gimple_assign_copy_p in two
separate spots, move the generic coalesce handling of it after
build_ssa_conflict_graph (where build_ssa_conflict_graph handling
doesn't fall through to that, it does continue after the call) and
inside of build_ssa_conflict_graph it performs it too, but only if
the lhs is not mergeable large/huge bitint.

2025-04-12  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/119722
	* gimple-lower-bitint.h (build_bitint_stmt_ssa_conflicts): Add
	CLEAR argument.
	* gimple-lower-bitint.cc (build_bitint_stmt_ssa_conflicts): Add
	CLEAR argument.  Call clear on gimple_assign_copy_p rhs1 if lhs
	is large/huge bitint unless lhs is not in names.
	* tree-ssa-coalesce.cc (build_ssa_conflict_graph): Adjust
	build_bitint_stmt_ssa_conflicts caller.  Move gimple_assign_copy_p
	handling to after the build_bitint_stmt_ssa_conflicts call.

(cherry picked from commit 3f9dfb94ea)
2025-04-19 08:13:06 +02:00
Jakub Jelinek 008ba21711 bitintlower: Fix up handling of nested casts in m_upward_2limbs cases [PR119707]
The following testcase is miscompiled I believe starting with
PR112941 r14-6742.  That commit fixed the bitint-55.c testcase.
The m_first initialization for such conversion initializes 2 SSA_NAMEs,
one is PHI result on the loop (m_data[save_data_cnt]) and the other
(m_data[save_data_cnt+1]) is the argument of that PHI from the latch
edge initialized somewhere in the loop.  Both of these are used to
propagate sign extension (i.e. either 0 or all ones limb) from the
iteration with the sign bit of a narrower type to following iterations.
The bitint-55.c testcase was ICEing with invalid SSA forms as it was
using unconditionally the PHI argument SSA_NAME even in places which
weren't dominated by that.  And the code which was touched is about
handling constant idx, so if e.g. there are nested casts and the
outer one does conditional code based on index comparison with
a particular constant index.
In the following testcase there are 2 nested casts, one from signed
_BitInt(129) to unsigned _BitInt(255) and the outer from unsigned
_BitInt(255) to unsigned _BitInt(256).  The m_upward_2limbs case which
is used for handling mergeable arithmetics (like +-|&^ and casts etc.)
one loop iteration handles 2 limbs, the first half the even ones, the
second half the odd ones.
And for these 2 conversions, the special one for the inner conversion
on x86_64 is with index 2 where the sign bit of _BitInt(129) is present,
while for the outer one index 3 where we need to mask off the most
significant bit.
The r15-6742 change started using m_data[save_data_cnt] for all constant
indexes if it is still inside of the loop (and it is sign extension).
But that doesn't work correctly for the case where the inner conversion
produces the sign extension limb in the loop for an even index and
the outer conversion needs to special case the immediately next conversion,
because in that case using the PHI result will see still 0 there rather
than the updated value from the handling of previous limb.
So the following patch special cases this and uses the other SSA_NAME.

Commented IL, trying to lower
  _1 = (unsigned _BitInt(255)) y_4(D);
  _2 = (unsigned _BitInt(256)) _1;
  _3 = _2 + x_5(D);
  <retval> = _3;
we were emitting
  <bb 3> [local count: 1073741824]:
  # _8 = PHI <0(2), _9(12)>     // This is the limb index
  # _10 = PHI <0(2), _11(12)>   // Sign extension limb from inner cast (0 or ~0UL)
  # _22 = PHI <0(2), _23(12)>   // Overflow bit from addition of previous limb
  if (_8 <= 2)
    goto <bb 4>; [80.00%]
  else
    goto <bb 7>; [20.00%]

  <bb 4> [local count: 1073741824]:
  if (_8 == 2)
    goto <bb 6>; [20.00%]
  else
    goto <bb 5>; [80.00%]

  <bb 5> [local count: 1073741824]:
  _12 = VIEW_CONVERT_EXPR<unsigned long[3]>(y)[_8];     // Full limbs in y
  goto <bb 7>; [100.00%]

  <bb 6> [local count: 214748360]:
  _13 = MEM <unsigned long> [(_BitInt(129) *)&y + 16B]; // y[2] which
  _14 = (<unnamed-signed:1>) _13;                       // needs to be
  _15 = (unsigned long) _14;                            // sign extended
  _16 = (signed long) _15;                              // to full
  _17 = _16 >> 63;                                      // limb
  _18 = (unsigned long) _17;

  <bb 7> [local count: 1073741824]:
  # _19 = PHI <_12(5), _10(3), _15(6)>  // Limb to add for result of casts
  # _20 = PHI <0(5), _10(3), _18(6)>    // Sign extension limb from previous limb
  _11 = _20;                            // PHI _10 argument above
  _21 = VIEW_CONVERT_EXPR<unsigned long[4]>(x)[_8];
  _24 = .UADDC (_19, _21, _22);
  _25 = IMAGPART_EXPR <_24>;
  _26 = REALPART_EXPR <_24>;
  VIEW_CONVERT_EXPR<unsigned long[4]>(<retval>)[_8] = _26;
  _27 = _8 + 1;
  if (_27 == 3)                 // For the outer cast limb 3 is special
    goto <bb 11>; [20.00%]
  else
    goto <bb 8>; [80.00%]

  <bb 8> [local count: 1073741824]:
  if (_27 < 2)
    goto <bb 9>; [80.00%]
  else
    goto <bb 10>; [20.00%]

  <bb 9> [local count: 1073741824]:
  _28 = VIEW_CONVERT_EXPR<unsigned long[3]>(y)[_27];    // These are used in full

  <bb 10> [local count: 1073741824]:
  # _29 = PHI <_28(9), _11(8)>
  goto <bb 12>; [100.00%]

  <bb 11> [local count: 214748360]:
// And HERE is the actual bug.  Using _10 for idx 3 will mean it is always
// zero there and doesn't contain the _18 value propagated to it.
// It should be
// _30 = (<unnamed-unsigned:63>) _11;
// Now if the outer conversion had special iteration say 5, we could
// have used _10 fine here, by that time it already propagates through
// the PHI.
  _30 = (<unnamed-unsigned:63>) _10;
  _31 = (unsigned long) _30;

  <bb 12> [local count: 1073741824]:
  # _32 = PHI <_29(10), _31(11)>
  _33 = VIEW_CONVERT_EXPR<unsigned long[4]>(x)[_27];
  _34 = .UADDC (_32, _33, _25);
  _23 = IMAGPART_EXPR <_34>;
  _35 = REALPART_EXPR <_34>;
  VIEW_CONVERT_EXPR<unsigned long[4]>(<retval>)[_27] = _35;
  _9 = _8 + 2;
  if (_9 != 4)
    goto <bb 3>; [0.05%]
  else
    goto <bb 13>; [99.95%]

2025-04-11  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/119707
	* gimple-lower-bitint.cc (bitint_large_huge::handle_cast): Only use
	m_data[save_data_cnt] instead of m_data[save_data_cnt + 1] if
	idx is odd and equal to low + 1.  Remember tree_to_uhwi (idx) in
	a temporary instead of calling the function multiple times.

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

(cherry picked from commit b57d7ef4bd)
2025-04-19 08:13:06 +02:00
Jakub Jelinek 8581982e8c libquadmath: Fix up THREEp96 constant in expq
Here is a cherry-pick from glibc [BZ #32411] fix.

As mentioned by the reporter in a pull request against gcc-mirror,
the THREEp96 constant in e_expl.c is incorrect, it is actually 0x3.p+94f128
rather than 0x3.p+96f128.

The algorithm uses that to compute the t2 integer (tval2), by whose
delta it adjusts the x+xl pair and then in the result uses the precomputed
exp value for that entry.
Using 0x3.p+94f128 rather than 0x3.p+96f128 results in tval2 sometimes
being one smaller, sometimes one larger than the desired value, thus can mean
the x+xl pair after adjustment will be larger in absolute value than it
should be.

DesWursters created a test program for this
https://github.com/DesWurstes/comparefloats
and his results were
total: 1135000000 not_equal: 4322 earlier_score: 674 later_score: 3648
I've modified this so with
https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c3
so that it actually tests pseudo-random _Float128 values with range
(-16384.,16384) with strong bias on values larger than 0.0002 in absolute
value (so that tval1/tval2 aren't zero most of the time) and that gave
total: 10000000000 not_equal: 29861 earlier_score: 4606 later_score: 25255
So, in both cases, in most cases the change doesn't result in any differences,
and in those rare cases where does, about 85% have smaller ulp than without
the patch.
Additionally I've tried
https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c4
and in 2 billion iterations it didn't find any case where x+xl after the
adjustments without this change would be smaller in absolute value compared
to x+xl after the adjustments with this change.

2025-04-09  Jakub Jelinek  <jakub@redhat.com>

	* math/expq.c (C): Fix up THREEp96 constant.

(cherry picked from commit e081ced345)
2025-04-19 08:13:05 +02:00
Jakub Jelinek 293a95b87c lto: lto-opts fixes [PR119625]
I can reproduce a really weird error in our distro i686 trunk gcc
(but haven't managed to reproduce it with vanilla trunk yet).
echo 'void foo (void) {}' > a.c; gcc -O2 -flto=auto -m32 -march=i686 -ffat-lto-objects -fhardened -o a.o -c a.c; gcc -O2 -flto=auto -m32 -march=i686 -r -o a.lo a.o
lto1: fatal error: open  failed: No such file or directory
compilation terminated.
lto-wrapper: fatal error: gcc returned 1 exit status
The error is because
cat ./a.lo.lto.o-args.0
""
a.o
My suspicion is that this "" in there is caused by weird .gnu.lto_.opts
section content during
gcc -O2 -flto=auto -m32 -march=i686 -ffat-lto-objects -fhardened -S -o a.s -c a.c
compilation (and I can reproduce that one with vanilla trunk).
The above results in
        .section        .gnu.lto_.opts,"e",@progbits
        .string "'-fno-openmp' '-fno-openacc' '-fPIC' '' '-m32' '-march=i686' '-O2' '-flto=auto' '-ffat-lto-objects'"
There are two weird things, one (IMHO the cause of the "" later on) is
the '' part, I think it comes from lto_write_options doing
append_to_collect_gcc_options (&temporary_obstack, &first_p, "");
IMHO it shouldn't call append_to_collect_gcc_options at all for that case.

The -fhardened option causes global_options.x_flag_cf_protection
to be set to CF_FULL and later on the backend option processing
sets it to CF_FULL | CF_SET (i.e. 7, a value not handled in
lto_write_options).

The following patch fixes it by not emitting anything there if
flag_cf_protection is one of the unhandled values.

Perhaps it could incrementally use
switch (global_options.x_flag_cf_protection & ~CF_SET)
instead, dunno.

And the other problem is that the -fPIC in there is really weird.
Our distro compiler or vanilla configured trunk certainly doesn't
default to -fPIC and -fhardened uses -fPIE when
-fPIC/-fpic/-fno-pie/-fno-pic is not specified, so I was expecting
-fPIE in there.
The thing is that the -fpie option causes setting of both
global_options.x_flag_pi{c,e} to 1, -fPIE both to 2:
      /* If -fPIE or -fpie is used, turn on PIC.  */
      if (opts->x_flag_pie)
        opts->x_flag_pic = opts->x_flag_pie;
      else if (opts->x_flag_pic == -1)
        opts->x_flag_pic = 0;
      if (opts->x_flag_pic && !opts->x_flag_pie)
        opts->x_flag_shlib = 1;
so checking first for flag_pic == 2 and then flag_pic == 1
and only afterwards for flag_pie means we never print
-fPIE/-fpie.

Or do you want something further (like
switch (global_options.x_flag_cf_protection & ~CF_SET)
)?

2025-04-04  Jakub Jelinek  <jakub@redhat.com>

	PR lto/119625
	* lto-opts.cc (lto_write_options): If neither flag_pic nor
	flag_pie are set, check first for flag_pie and only later
	for flag_pic rather than the other way around, use a temporary
	variable.  If flag_cf_protection is not set, don't append anything
	if flag_cf_protection is none of CF_{NONE,FULL,BRANCH,RETURN} and
	use a temporary variable.

(cherry picked from commit d25728c986)
2025-04-19 08:13:05 +02:00
Jakub Jelinek c0946fe4d2 c: Fix ICEs with -fsanitize=pointer-{subtract,compare} [PR119582]
The following testcase ICEs because c_fully_fold isn't performed on the
arguments of __sanitizer_ptr_{sub,cmp} builtins and so e.g.
C_MAYBE_CONST_EXPR can leak into the gimplifier where it ICEs.

2025-04-02  Jakub Jelinek  <jakub@redhat.com>

	PR c/119582
	* c-typeck.cc (pointer_diff, build_binary_op): Call c_fully_fold on
	__sanitizer_ptr_sub or __sanitizer_ptr_cmp arguments.

	* gcc.dg/asan/pr119582.c: New test.

(cherry picked from commit 29bc904cb8)
2025-04-19 08:13:05 +02:00
Jakub Jelinek 7381ea8fc4 combine: Use reg_used_between_p rather than modified_between_p in two spots [PR119291]
The following testcase is miscompiled on x86_64-linux at -O2 by the combiner.
We have from earlier combinations
(insn 22 21 23 4 (set (reg:SI 104 [ _7 ])
        (const_int 0 [0])) "pr119291.c":25:15 96 {*movsi_internal}
     (nil))
(insn 23 22 24 4 (set (reg/v:SI 117 [ e ])
        (reg/v:SI 116 [ e ])) 96 {*movsi_internal}
     (expr_list:REG_DEAD (reg/v:SI 116 [ e ])
        (nil)))
(note 24 23 25 4 NOTE_INSN_DELETED)
(insn 25 24 26 4 (parallel [
            (set (reg:CCZ 17 flags)
                (compare:CCZ (neg:SI (reg:SI 104 [ _7 ]))
                    (const_int 0 [0])))
            (set (reg/v:SI 116 [ e ])
                (neg:SI (reg:SI 104 [ _7 ])))
        ]) "pr119291.c":26:13 977 {*negsi_2}
     (expr_list:REG_DEAD (reg:SI 104 [ _7 ])
        (nil)))
(note 26 25 27 4 NOTE_INSN_DELETED)
(insn 27 26 28 4 (set (reg:DI 128 [ _9 ])
        (ne:DI (reg:CCZ 17 flags)
            (const_int 0 [0]))) "pr119291.c":26:13 1447 {*setcc_di_1}
     (expr_list:REG_DEAD (reg:CCZ 17 flags)
        (nil)))
and try_combine is called on i3 25 and i2 22 (second time)
and reach the hunk being patched with simplified i3
(insn 25 24 26 4 (parallel [
            (set (pc)
                (pc))
            (set (reg/v:SI 116 [ e ])
                (const_int 0 [0]))
        ]) "pr119291.c":28:13 977 {*negsi_2}
     (expr_list:REG_DEAD (reg:SI 104 [ _7 ])
        (nil)))
and
(insn 22 21 23 4 (set (reg:SI 104 [ _7 ])
        (const_int 0 [0])) "pr119291.c":27:15 96 {*movsi_internal}
     (nil))
Now, the try_combine code there attempts to split two independent
sets in newpat by moving one of them to i2.
And among other tests it checks
!modified_between_p (SET_DEST (set1), i2, i3)
which is certainly needed, if there would be say
(set (reg/v:SI 116 [ e ]) (const_int 42 [0x2a]))
in between i2 and i3, we couldn't do that, as that set would overwrite
the value set by set1 we want to move to the i2 position.
But in this case pseudo 116 isn't set in between i2 and i3, but used
(and additionally there is a REG_DEAD note for it).

This is equally bad for the move, because while the i3 insn
and later will see the pseudo value that we set, the insn in between
which uses the value will see a different value from the one that
it should see.

As we don't check for that, in the end try_combine succeeds and
changes the IL to:
(insn 22 21 23 4 (set (reg/v:SI 116 [ e ])
        (const_int 0 [0])) "pr119291.c":27:15 96 {*movsi_internal}
     (nil))
(insn 23 22 24 4 (set (reg/v:SI 117 [ e ])
        (reg/v:SI 116 [ e ])) 96 {*movsi_internal}
     (expr_list:REG_DEAD (reg/v:SI 116 [ e ])
        (nil)))
(note 24 23 25 4 NOTE_INSN_DELETED)
(insn 25 24 26 4 (set (pc)
        (pc)) "pr119291.c":28:13 2147483647 {NOOP_MOVE}
     (nil))
(note 26 25 27 4 NOTE_INSN_DELETED)
(insn 27 26 28 4 (set (reg:DI 128 [ _9 ])
        (const_int 0 [0])) "pr119291.c":28:13 95 {*movdi_internal}
     (nil))
(note, the i3 got turned into a nop and try_combine also modified insn 27).

The following patch replaces the modified_between_p
tests with reg_used_between_p, my understanding is that
modified_between_p is a subset of reg_used_between_p, so one
doesn't need both.

Looking at this some more today, I think we should special case
set_noop_p because that can be put into i2 (except for the JUMP_P
violations), currently both modified_between_p (pc_rtx, i2, i3)
and reg_used_between_p (pc_rtx, i2, i3) returns false.
I'll post a patch incrementally for that (but that feels like
new optimization, so probably not something that should be backported).

On Tue, Apr 01, 2025 at 11:27:25AM +0200, Richard Biener wrote:
> Can we constrain SET_DEST (set1/set0) to a REG_P in combine?  Why
> does the comment talk about memory?

I was worried about making too risky changes this late in stage4
(and especially also for backports).  Most of this code is 1992-ish.
I think many of the functions are just misnamed, the reg_ in there doesn't
match what those functions do (bet they initially supported just REGs
and later on support for other kinds of expressions was added, but haven't
done git archeology to prove that).

What we know for sure is:
           && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 0))) != ZERO_EXTRACT
           && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 0))) != STRICT_LOW_PART
           && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != ZERO_EXTRACT
           && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != STRICT_LOW_PART
that is checked earlier in the condition.
Then it calls
           && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 1)),
                                  XVECEXP (newpat, 0, 0))
           && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 0)),
                                  XVECEXP (newpat, 0, 1))
While it has reg_* in it, that function mostly calls reg_overlap_mentioned_p
which is also misnamed, that function handles just fine all of
REG, MEM, SUBREG of REG, (SUBREG of MEM not, see below), ZERO_EXTRACT,
STRICT_LOW_PART, PC and even some further cases.
So, IMHO SET_DEST (set0) or SET_DEST (set0) can be certainly a REG, SUBREG
of REG, PC (at least the REG and PC cases are triggered on the testcase)
and quite possibly also MEM (SUBREG of MEM not, see below).

Now, the code uses !modified_between_p (SET_SRC (set{1,0}), i2, i3) where that
function for constants just returns false, for PC returns true, for REG
returns reg_set_between_p, for MEM recurses on the address, for
MEM_READONLY_P otherwise returns false, otherwise checks using alias.cc code
whether the memory could have been modified in between, for all other
rtxes recurses on the subrtxes.  This part didn't change in my patch.

I've only changed those
-         && !modified_between_p (SET_DEST (set{1,0}), i2, i3)
+         && !reg_used_between_p (SET_DEST (set{1,0}), i2, i3)
where the former has been described above and clearly handles all of
REG, SUBREG of REG, PC, MEM and SUBREG of MEM among other things.

The replacement reg_used_between_p calls reg_overlap_mentioned_p on each
instruction in between i2 and i3.  So, there is clearly a difference
in behavior if SET_DEST (set{1,0}) is pc_rtx, in that case modified_between_p
returns unconditionally true even if there are no instructions in between,
but reg_used_between_p if there are no non-debug insns in between returns
false.  Sorry for missing that, guess I should check for that (with the
exception of the noop moves which are often (set (pc) (pc)) and handled
by the incremental patch).  In fact not just that, reg_used_between_p
will only return true for PC if it is mentioned anywhere in the insns
in between.
Anyway, except for that, for REG it calls refers_to_regno_p
and so should find any occurrences of any of the REG or parts of it for hard
registers, for MEM returns true if it sees any MEMs in insns in between
(conservatively), for SUBREGs apparently it relies on it being SUBREG of REG
(so doesn't handle SUBREG of MEM) and handles SUBREG of REG like the
SUBREG_REG, PC I've already described.

Now, because reg_overlap_mentioned_p doesn't handle SUBREG of MEM, I think
already the initial
           && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 1)),
                                  XVECEXP (newpat, 0, 0))
           && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 0)),
                                  XVECEXP (newpat, 0, 1))
calls would have failed --enable-checking=rtl or would have misbehaved, so
I think there is no need to check for it further.

To your question why I don't use reg_referenced_p, that is because
reg_referenced_p is something to call on one insn pattern, while
reg_used_between_p is pretty much that on all insns in between two
instructions (excluding the boundaries).

So, I think it would be safer to add && SET_DEST (set{1,0} != pc_rtx
checks to preserve former behavior, like in the following version.

2025-04-01  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/119291
	* combine.cc (try_combine): For splitting of PARALLEL with
	2 independent SETs into i2 and i3 sets check reg_used_between_p
	of the SET_DESTs rather than just modified_between_p.

	* gcc.c-torture/execute/pr119291.c: New test.

(cherry picked from commit 19ba913517)
2025-04-19 08:13:04 +02:00
Xing Li 2048dcc39b LoongArch: Change {dg-do-what-default} save and restore logical.
The set of {dg-do-what-default} to 'run' may lead some test hang
during make check.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/loongarch-vector.exp: Change
	{dg-do-what-default} save and restore logical.

(cherry picked from commit dd98219865)
2025-04-19 08:58:41 +08:00
GCC Administrator 022ef0b064 Daily bump. 2025-04-19 00:23:55 +00:00
GCC Administrator 459b93de78 Daily bump. 2025-04-18 00:23:01 +00:00
Tomasz Kamiński a295863e95 libstdc++: Correct preprocessing checks for floatX_t and bfloat_16 formatting
Floating points types _Float16, _Float32, _Float64, and bfloat16,
can be formatted only if std::to_chars overloads for such types
were provided. Currently this is only the case for architectures
where float and double are 32-bits and 64-bits IEEE floating points types.

This patch updates the preprocessing checks for formatters
for above types to check _GLIBCXX_FLOAT_IS_IEEE_BINARY32
and _GLIBCXX_DOUBLE_IS_IEEE_BINARY64. Making them non-formattable
on non-IEEE architectures.

Remove a potential UB, where we could produce basic_format_arg
with _M_type set to _Arg_fp32 or _Arg_fp64, that was later not
handled by `_M_visit`.

libstdc++-v3/ChangeLog:

	* include/std/format (formatter<_Float16, _CharT>): Define only if
	_GLIBCXX_FLOAT_IS_IEEE_BINARY32 macro is defined.
	(formatter<_Float16, _CharT>): As above.
	(formatter<__gnu_cxx::__bfloat16_t, _CharT>): As above.
	(formatter<_Float64, _CharT>): Define only if
	_GLIBCXX_DOUBLE_IS_IEEE_BINARY64 is defined.
	(basic_format_arg::_S_to_arg_type): Normalize _Float32 and _Float64
	only to float and double respectivelly.
	(basic_format_arg::_S_to_enum): Remove handling of _Float32 and _Float64.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 445128c12c)
2025-04-17 08:40:21 +02:00
Ard Biesheuvel 203bce172a i386: Enable -mnop-mcount for -fpic with PLTs [PR119386]
-mnop-mcount can be trivially enabled for -fPIC codegen as long as PLTs
are being used, given that the instruction encodings are identical, only
the target may resolve differently depending on how the linker decides
to incorporate the object file.

So relax the option check, and add a test to ensure that 5-byte NOPs are
emitted when -mnop-mcount is being used.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

gcc/ChangeLog:

	PR target/119386
	* config/i386/i386-options.cc: Permit -mnop-mcount when
	using -fpic with PLTs.

gcc/testsuite/ChangeLog:

	PR target/119386
	* gcc.target/i386/pr119386-3.c: New test.

(cherry picked from commit 6b4569a3eb)
2025-04-17 06:07:53 +02:00
Ard Biesheuvel 1500a9c9cd i386: Prefer PLT indirection for __fentry__ calls under -fPIC [PR119386]
Commit bde21de120 ("i386: Honour -mdirect-extern-access when calling
__fentry__") updated the logic that emits mcount() / __fentry__() calls
into function prologues when profiling is enabled, to avoid GOT-based
indirect calls when a direct call would suffice.

There are two problems with that change:
- it relies on -mdirect-extern-access rather than -fno-plt to decide
  whether or not a direct [PLT based] call is appropriate;
- for the PLT case, it falls through to x86_print_call_or_nop(), which
  does not emit the @PLT suffix, resulting in the wrong relocation to be
  used (R_X86_64_PC32 instead of R_X86_64_PLT32)

Fix this by testing flag_plt instead of ix86_direct_extern_access, and
updating x86_print_call_or_nop() to take flag_pic and flag_plt into
account. This also ensures that -mnop-mcount works as expected when
emitting the PLT based profiling calls.

While at it, fix the 32-bit logic as well, and issue a PLT call unless
PLTs are explicitly disabled.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

gcc/ChangeLog:

	PR target/119386
	* config/i386/i386.cc (x86_print_call_or_nop): Add @PLT suffix
	where appropriate.
	(x86_function_profiler): Fall through to x86_print_call_or_nop()
	for PIC codegen when flag_plt is set.

gcc/testsuite/ChangeLog:

	PR target/119386
	* gcc.target/i386/pr119386-1.c: New test.
	* gcc.target/i386/pr119386-2.c: New test.

(cherry picked from commit 9b0ae0a8d7)
2025-04-17 06:07:53 +02:00
GCC Administrator efe332f2ce Daily bump. 2025-04-17 00:23:31 +00:00
Eric Botcazou 62151c32e3 Fix wrong optimization of conditional expression with enumeration type
This is a regression introduced on the mainline and 14 branch by:
  https://gcc.gnu.org/pipermail/gcc-cvs/2023-October/391658.html

The change bypasses int_fits_type_p (essentially) to work around the
signedness constraints, but in doing so disregards the peculiarities
of boolean types whose precision is not 1 dealt with by the predicate,
leading to the creation of a problematic conversion here.

Fixed by special-casing boolean types whose precision is not 1, as done
in several other places.

gcc/
	* tree-ssa-phiopt.cc (factor_out_conditional_operation): Do not
	bypass the int_fits_type_p test for boolean types whose precision
	is not 1.

gcc/testsuite/
	* gnat.dg/opt105.adb: New test.
	* gnat.dg/opt105_pkg.ads, gnat.dg/opt105_pkg.adb: New helper.
2025-04-16 22:24:48 +02:00
Alice Carlotti c344377bb3 aarch64: Disable sysreg feature gating
This applies to the sysreg read/write intrinsics __arm_[wr]sr*.  It does
not depend on changes to Binutils, because GCC converts recognised
sysreg names to an encoding based form, which is already ungated in Binutils.

We have, however, agreed to make an equivalent change in Binutils (which
would then disable feature gating for sysreg accesses in inline
assembly), but this has not yet been posted upstream.

In the future we may introduce a new flag to renable some checking,
but these checks could not be comprehensive because many system
registers depend on architecture features that don't have corresponding
GCC/GAS --march options.  This would also depend on addressing numerous
inconsistencies in the existing list of sysreg feature dependencies.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc
	(aarch64_valid_sysreg_name_p): Remove feature check.
	(aarch64_retrieve_sysreg): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/rwsr-ungated.c: New test.
2025-04-16 20:56:33 +01:00
H.J. Lu 8cc672d3d3 x86: Update gcc.target/i386/apx-interrupt-1.c
ix86_add_cfa_restore_note omits the REG_CFA_RESTORE REG note for registers
pushed in red-zone.  Since

commit 0a074b8c7e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Apr 13 12:20:42 2025 -0700

    APX: Don't use red-zone with 32 GPRs and no caller-saved registers

disabled red-zone, update gcc.target/i386/apx-interrupt-1.c to expect
31 .cfi_restore directives.

	PR target/119784
	* gcc.target/i386/apx-interrupt-1.c: Expect 31 .cfi_restore
	directives.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 5ed2fa4768)
2025-04-16 12:31:13 -07:00
H.J. Lu a33e2808c8 APX: Don't use red-zone with 32 GPRs and no caller-saved registers
Don't use red-zone when there are no caller-saved registers with 32 GPRs
since 128-byte red-zone is too small for 31 GPRs.

gcc/

	PR target/119784
	* config/i386/i386.cc (ix86_using_red_zone): Don't use red-zone
	with 32 GPRs and no caller-saved registers.

gcc/testsuite/

	PR target/119784
	* gcc.target/i386/pr119784a.c: New test.
	* gcc.target/i386/pr119784b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 0a074b8c7e)
2025-04-16 12:28:05 -07:00
H.J. Lu d275b3748a Extend check-function-bodies to allow label and directives
As PR target/116174 shown, we may need to verify labels and the directive
order.  Extend check-function-bodies to support matched output lines to
allow label and directives.

gcc/

	* doc/sourcebuild.texi (check-function-bodies): Add an optional
	argument for matched output lines.

gcc/testsuite/

	* gcc.target/i386/pr116174.c: Use check-function-bodies.
	* lib/scanasm.exp (parse_function_bodies): Append the line if
	$up_config(matched) matches the line.
	(check-function-bodies): Add an argument for matched.  Set
	up_config(matched) to $matched.  Append the expected line without
	$config(line_prefix) to function_regexp if it starts with ".L".

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit d6bb1e257f)
2025-04-16 12:25:03 -07:00
Kito Cheng b61acf546e RISC-V: Put jump table in text for large code model
Large code model assume the data or rodata may put far away from
text section.  So we need to put jump table in text section for
large code model.

gcc/ChangeLog:

	* config/riscv/riscv.h (JUMP_TABLES_IN_TEXT_SECTION): Check if
	large code model.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/jump-table-large-code-model.c: New test.

(cherry picked from commit 1d9e02bb7e)
2025-04-17 01:05:36 +08:00
Robin Dapp 52c1f60bea RISC-V: Fix vec_duplicate[bimode] expander [PR119572].
Since r15-9062-g70391e3958db79 we perform vector bitmask initialization
via the vec_duplicate expander directly.  This triggered a latent bug in
ours where we missed to mask out the single bit which resulted in an
execution FAIL of pr119114.c

The attached patch adds the 1-masking of the broadcast operand.

	PR target/119572

gcc/ChangeLog:

	* config/riscv/autovec.md: Mask broadcast value.

(cherry picked from commit 716d39f0a2)
2025-04-17 01:05:36 +08:00
Richard Sandiford 94ef80629a aarch64: Split aarch64_combinev16qi before RA [PR115258]
Two-vector TBL instructions are fed by an aarch64_combinev16qi, whose
purpose is to put the two input data vectors into consecutive registers.
This aarch64_combinev16qi was then split after reload into individual
moves (from the first input to the first half of the output, and from
the second input to the second half of the output).

In the worst case, the RA might allocate things so that the destination
of the aarch64_combinev16qi is the second input followed by the first
input.  In that case, the split form of aarch64_combinev16qi uses three
eors to swap the registers around.

This PR is about a test where this worst case occurred.  And given the
insn description, that allocation doesn't semm unreasonable.

early-ra should (hopefully) mean that we're now better at allocating
subregs of vector registers.  The upcoming RA subreg patches should
improve things further.  The best fix for the PR therefore seems
to be to split the combination before RA, so that the RA can see
the underlying moves.

Perhaps it even makes sense to do this at expand time, avoiding the need
for aarch64_combinev16qi entirely.  That deserves more experimentation
though.

gcc/
	PR target/115258
	* config/aarch64/aarch64-simd.md (aarch64_combinev16qi): Allow
	the split before reload.
	* config/aarch64/aarch64.cc (aarch64_split_combinev16qi): Generalize
	into a form that handles pseudo registers.

gcc/testsuite/
	PR target/115258
	* gcc.target/aarch64/pr115258.c: New test.

(cherry picked from commit 39263ed2d3)
2025-04-16 13:20:29 +01:00
Richard Sandiford a38e9e06d0 aarch64: Avoid unnecessary use of 2-input TBLs [PR115258]
When using TBL for (say) a V4SI permutation, the aarch64 port first
asks target-independent code to lower to a V16QI permutation.
Then, during code generation, an input like:

  (reg:V4SI R)

gets converted to:

  (subreg:V16QI (reg:V4SI R) 0)

aarch64_vectorize_vec_perm_const had:

  d.op0 = op0 ? force_reg (op_mode, op0) : NULL_RTX;
  if (op0 == op1)
    d.op1 = d.op0;
  else
    d.op1 = op1 ? force_reg (op_mode, op1) : NULL_RTX;

But subregs (unlike regs) are not shared, so the op0 == op1 check
always failed for this case.  We'd then force each subreg into a
fresh register, meaning that during the later:

  aarch64_expand_vec_perm_1 (d->target, d->op0, d->op1, sel);

there is no way for aarch64_expand_vec_perm_1 to realise that
d->op0 and d->op1 are the same value.  It would therefore generate
a two-input TBL in the testcase, even though a single-input TBL
is enough.

I'm not sure forcing subregs to a fresh regiter is a good idea --
it caused problems for copysign & co. -- but that's not something
to fiddle with during stage 4.  Using op0 == op1 for rtx equality
is independently wrong, so we might as well just fix that for now.

The patch gets rid of extra MOVs that are a regression from GCC 14.

The testcase is based on one from Kugan, itself based on TSVC.

gcc/
	PR target/115258
	* config/aarch64/aarch64.cc (aarch64_vectorize_vec_perm_const): Use
	d.one_vector_p to decide whether op1 should be a copy of op0.

gcc/testsuite/
	PR target/115258
	* gcc.target/aarch64/pr115258_2.c: New test.

Co-authored-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
(cherry picked from commit 31dcf941ac)
2025-04-16 13:20:29 +01:00
Richard Sandiford 2a4b0a1d02 vect: Enforce dr_with_seg_len::align precondition [PR116125]
tree-data-refs.cc uses alignment information to try to optimise
the code generated for alias checks.  The assumption for "normal"
non-grouped, full-width scalar accesses was that the access size
would be a multiple of the alignment.  As Richi notes in the PR,
this is a documented precondition of dr_with_seg_len:

  /* The minimum common alignment of DR's start address, SEG_LEN and
     ACCESS_SIZE.  */
  unsigned int align;

PR115192 was a case in which this assumption didn't hold.  The access
was part of an aligned 4-element group, but only the first 2 elements
of the group were accessed.  The alignment was therefore double the
access size.

In r15-820-ga0fe4fb1c8d78045 I'd "fixed" that by capping the
alignment in one of the output routines.  But I think that was
misconceived.  The precondition means that we should cap the
alignment at source instead.

Failure to do that caused a similar wrong code bug in this PR,
where the alignment comes from a short bitfield access rather
than from a group access.

gcc/
	PR tree-optimization/116125
	* tree-vect-data-refs.cc (vect_prune_runtime_alias_test_list): Make
	the dr_with_seg_len alignment fields describe tha access sizes as
	well as the pointer alignment.
	* tree-data-ref.cc (create_intersect_range_checks): Don't compensate
	for invalid alignment fields here.

gcc/testsuite/
	PR tree-optimization/116125
	* gcc.dg/vect/pr116125.c: New test.

(cherry picked from commit e8651b80ae)
2025-04-16 13:20:28 +01:00
Xi Ruoyao e192f1f2c7 LoongArch: Fix invalid subregs in xorsign [PR118501]
The test case added in r15-7073 now triggers an ICE, indicating we need
the same fix as AArch64.

gcc/ChangeLog:

	PR target/118501
	* config/loongarch/loongarch.md (@xorsign<mode>3): Use
	force_lowpart_subreg.

(cherry picked from commit 9ddf4a6cc6)
2025-04-16 13:20:28 +01:00
Richard Sandiford 14fe427ab5 aarch64: Fix invalid subregs in xorsign [PR118501]
In the testcase, we try to use xorsign on:

   (subreg:DF (reg:TI R) 8)

i.e. the highpart of the TI.  xorsign wants to take a V2DF
paradoxical subreg of this, which is rightly rejected as a direct
operation.  In cases like this, we need to force the highpart into
a fresh register first.

gcc/
	PR target/118501
	* config/aarch64/aarch64.md (@xorsign<mode>3): Use
	force_lowpart_subreg.

gcc/testsuite/
	PR target/118501
	* gcc.c-torture/compile/pr118501.c: New test.

(cherry picked from commit 6612b8e554)
2025-04-16 13:20:27 +01:00
Richard Sandiford 17cce5f59a aarch64: Use force_lowpart_subreg in a BFI splitter [PR119133]
lowpart_subreg ICEs are the gift that keeps giving.  This is another
case where we need to use force_lowpart_subreg instead, to handle
cases where the input is already a subreg and where the combined
subreg is not allowed as a single operation.

We don't need to check can_create_pseudo_p since the input should
be a hard register rather than a subreg if !can_create_pseudo_p.

gcc/
	PR target/119133
	* config/aarch64/aarch64.md
	(*aarch64_bfi<GPI:mode><ALLX:mode>_<SUBDI_BITS>): Use
	force_lowpart_subreg.

gcc/testsuite/
	PR target/119133
	* gcc.dg/torture/pr119133.c: New test.

(cherry picked from commit 5ae621e2e8)
2025-04-16 13:20:27 +01:00
Richard Sandiford b079728cf3 Avoid using POINTER_DIFF_EXPR for overlap checks [PR119399]
In r10-4803-g8489e1f45b50600c I'd used POINTER_DIFF_EXPR to subtract
the two pointers involved in an overlap test.  I'm not sure whether
I'd specifically chosen that over MINUS_EXPR or not; if so, the only
reason I can think of is that it is probably faster on targets with
PSImode pointers.  Regardless, as the PR points out, subtracting
unrelated pointers using POINTER_DIFF_EXPR is undefined behaviour.

gcc/
	PR tree-optimization/119399
	* tree-data-ref.cc (create_waw_or_war_checks): Use a MINUS_EXPR
	on two converted pointers, rather than converting a POINTER_DIFF_EXPR
	on the pointers.

gcc/testsuite/
	PR tree-optimization/119399
	* gcc.dg/vect/pr119399.c: New test.

(cherry picked from commit 4c8c373495)
2025-04-16 13:20:26 +01:00
Richard Sandiford b33e9eb8d4 Add force_lowpart_subreg
optabs had a local function called lowpart_subreg_maybe_copy
that is very similar to the lowpart version of force_subreg.
This patch adds a force_lowpart_subreg wrapper around
force_subreg.

The only difference between the old and new functions is that
the old one asserted success while the new one doesn't.
It's common not to assert elsewhere when taking subregs;
normally a null result is enough.

Later patches will make more use of the new function.

gcc/
	* explow.h (force_lowpart_subreg): Declare.
	* explow.cc (force_lowpart_subreg): New function.

(cherry picked from commit 5f40d1c0cc)
2025-04-16 13:20:26 +01:00
Richard Sandiford 021ccf9dee Make force_subreg emit nothing on failure
While adding more uses of force_subreg, I realised that it should
be more careful to emit no instructions on failure.  This kind of
failure should be very rare, so I don't think it's a case worth
optimising for.

gcc/
	* explow.cc (force_subreg): Emit no instructions on failure.

(cherry picked from commit 01044471ea)
2025-04-16 13:20:25 +01:00
Jonathan Wakely 6f897be204 libstdc++: Adjust comment in <numeric>
We don't need to mention ranges::out_value_result in this comment,
because <numeric> doesn't care about that name.

libstdc++-v3/ChangeLog:

	* include/std/numeric: Only mention ranges::iota in comment.
2025-04-16 12:37:15 +01:00
Jonathan Wakely 3d03428400 libstdc++: Add test for not using reserved name 'ranges' before C++20
This is a test for a bug that was present on trunk, because 'ranges' is
not a reserved name before C++20.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Check ranges is not used as an
	identifier before C++20.
2025-04-16 09:39:24 +01:00
Jonathan Wakely 0a9f20ed39 libstdc++: Do not define __cpp_lib_ranges_iota in <ranges>
In r14-7153-gadbc46942aee75 we removed a duplicate definition of
__glibcxx_want_range_iota from <ranges>, but __cpp_lib_ranges_iota
should be defined in <ranges> at all.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__glibcxx_want_ranges_iota): Do not
	define.

(cherry picked from commit 25775e73ea)
2025-04-16 09:39:24 +01:00
Michael Levine 399ca30041 libstdc++: Fix std::ranges::iota is not included in numeric [PR108760]
Before this patch, using std::ranges::iota required including
<algorithm> when it should have been sufficient to only include
<numeric>.

For the backport to the release branch ranges::iota is defined in
<bits/ranges_algobase.h> so that it's available in both <numeric> and
<algorithm>. This avoids breaking code that compiles successfully using
existing releases where <algorithm> defines ranges::iota.

libstdc++-v3/ChangeLog:

	PR libstdc++/108760
	* include/bits/ranges_algo.h (ranges::out_value_result)
	(ranges::iota_result, ranges::__iota_fn, ranges::iota): Move to
	<bits/ranges_algobase.h>.
	* include/bits/ranges_algobase.h (ranges::out_value_result):
	(ranges::iota_result, ranges::__iota_fn, ranges::iota): Move to
	here.
	* include/std/numeric: Include <bits/ranges_algobase.h>.
	* testsuite/25_algorithms/iota/1.cc: Renamed to ...
	* testsuite/26_numerics/iota/2.cc: ... here.

Signed-off-by: Michael Levine <mlevine55@bloomberg.net>
(cherry picked from commit 0bb1db32cc)
2025-04-16 09:39:24 +01:00
Jonathan Wakely c29c3f713a libstdc++: Fix ranges::move and ranges::move_backward to use iter_move [PR105609]
The ranges::move and ranges::move_backward algorithms are supposed to
use ranges::iter_move(iter) instead of std::move(*iter), which matters
for an iterator type with an iter_move overload findable by ADL.

Currently those algorithms use std::__assign_one which uses std::move,
so define a new ranges::__detail::__assign_one helper function that uses
ranges::iter_move.

libstdc++-v3/ChangeLog:

	PR libstdc++/105609
	* include/bits/ranges_algobase.h (__detail::__assign_one): New
	helper function.
	(__copy_or_move, __copy_or_move_backward): Use new function
	instead of std::__assign_one.
	* testsuite/25_algorithms/move/constrained.cc: Check that
	ADL iter_move is used in preference to std::move.
	* testsuite/25_algorithms/move_backward/constrained.cc:
	Likewise.

(cherry picked from commit 3866ca796d)
2025-04-16 09:39:24 +01:00
Jonathan Wakely 542c7e9b3f libstdc++: Reuse std::__assign_one in <bits/ranges_algobase.h>
Use std::__assign_one instead of ranges::__assign_one. Adjust the uses,
because std::__assign_one has the arguments in the opposite order (the
same order as an assignment expression).

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h (ranges::__assign_one): Remove.
	(__copy_or_move, __copy_or_move_backward): Use std::__assign_one
	instead of ranges::__assign_one.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit d0a9ae1321)
2025-04-16 09:39:24 +01:00
Jonathan Wakely 27f7de3b80 libstdc++: Fix ranges::copy_backward for a single memcpyable element [PR117121]
The result iterator needs to be decremented before writing to it.

Improve the PR 108846 tests for all of std::copy, std::copy_n,
std::copy_backward, and the std::ranges versions.

libstdc++-v3/ChangeLog:

	PR libstdc++/117121
	* include/bits/ranges_algobase.h (copy_backward): Decrement
	output iterator before assigning one element through it.
	* testsuite/25_algorithms/copy/108846.cc: Ensure the algorithm's
	effects are correct for a single memcpyable element.
	* testsuite/25_algorithms/copy_backward/108846.cc: Likewise.
	* testsuite/25_algorithms/copy_n/108846.cc: Likewise.

(cherry picked from commit 27f6b376e8)
2025-04-16 09:39:23 +01:00
Giuseppe D'Angelo acd6031f5c libstdc++: Do not use use memmove for 1-element ranges [PR108846,PR116471]
This commit ports the fixes already applied by r13-6372-g822a11a1e642e0
to the range-based versions of copy/move algorithms.

When doing so, a further bug (PR116471) was discovered in the
implementation of the range-based algorithms: although the algorithms
are already constrained by the indirectly_copyable/movable concepts,
there was a failing static_assert in the memmove path.

This static_assert checked that iterator's value type was assignable by
using the is_copy_assignable (move) type traits. However, this is a
problem, because the traits are too strict when checking for constness;
a type like

  struct S { S& operator=(S &) = default; };

is trivially copyable (and thus could benefit of the memmove path),
but it does not satisfy is_copy_assignable because the operator takes
by non-const reference.

Now, the reason for the check to be there is because a type with
a deleted assignment operator like

  struct E { E& operator=(const E&) = delete; };

is still trivially copyable, but not assignable. We don't want
algorithms like std::ranges::copy to compile because they end up
selecting the memmove path, "ignoring" the fact that E isn't even
copy assignable.

But the static_assert isn't needed here any longer: as noted before,
the ranges algorithms already have the appropriate constraints; and
even if they didn't, there's now a non-discarded codepath to deal with
ranges of length 1 where there is an explicit assignment operation.

Therefore, this commit removes it. (In fact, r13-6372-g822a11a1e642e0
removed the same static_assert from the non-ranges algorithms.)

libstdc++-v3/ChangeLog:

	PR libstdc++/108846
	PR libstdc++/116471
	* include/bits/ranges_algobase.h (__assign_one): New helper
	function.
	(__copy_or_move): Remove a spurious static_assert; use
	__assign_one for memcpyable ranges of length 1.
	(__copy_or_move_backward): Likewise.
	* testsuite/25_algorithms/copy/108846.cc: Extend to range-based
	algorithms, and cover both memcpyable and non-memcpyable
	cases.
	* testsuite/25_algorithms/copy_backward/108846.cc: Likewise.
	* testsuite/25_algorithms/copy_n/108846.cc: Likewise.
	* testsuite/25_algorithms/move/108846.cc: Likewise.
	* testsuite/25_algorithms/move_backward/108846.cc: Likewise.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 5938e0681c)
2025-04-16 09:39:23 +01:00
Jonathan Wakely fb00f4e4f1 libstdc++: Add missing header to <bits/ranges_algobase.h> for std::__memcmp
As noticed by Michael Levine.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h: Include <bits/stl_algobase.h>.

(cherry picked from commit 674d213ab9)
2025-04-16 09:39:23 +01:00
Alexandre Oliva 56b3858b6a RISC-V: revert pr114194 tests on gcc-14 [PR118601]
The gcc-14 backport that split the pr114194 testcase for rv32 and rv64
would only generate the expected rv32 sequence if commit
6b315907c0 had also been backported, but
it wasn't.  Without it, we get the same code as before on both rv32
and rv64, so revert to the original test.


for  gcc/testsuite/ChangeLog

	PR target/118601
	* gcc.target/riscv/rvv/xtheadvector/pr114194.c: Restore.
	* gcc.target/riscv/rvv/xtheadvector/pr114194-rv64.c: Remove.
	* gcc.target/riscv/rvv/xtheadvector/pr114194-rv32.c: Likewise.
2025-04-16 01:10:54 -03:00
Alexandre Oliva b7b1aeea68 RISC-V: adjust testcase for gcc-14 [PR118182]
The pr118182-2.c testcase backported from gcc-15 depended on the late
combine pass after register allocation to substitute the zero constant
into the pred_broadcast to get to the expected vmv.s.x instruction.
Without that pass, we get a mfmv.s.f instead.  Expect that on gcc-14.


for  gcc/testsuite/ChangeLog

	PR target/118182
	* gcc.target/riscv/rvv/autovec/pr118182-2.c: Adjust.
2025-04-16 01:10:53 -03:00
GCC Administrator 0cb00fe889 Daily bump. 2025-04-16 00:23:25 +00:00
Andrew Pinski 5f6285f291 discriminators: Fix assigning discriminators on edge [PR113546]
The problem here is there was a compare debug since the discriminators
would still take into account debug statements. For the edge we would look
at the first statement after the labels and that might have been a debug statement.
So we need to skip over debug statements otherwise we could get different
discriminators # with and without -g.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR middle-end/113546

gcc/ChangeLog:

	* tree-cfg.cc (first_non_label_stmt): Rename to ...
	(first_non_label_nondebug_stmt): This and use gsi_start_nondebug_after_labels_bb.
	(assign_discriminators): Update call to first_non_label_nondebug_stmt.

gcc/testsuite/ChangeLog:

	* c-c++-common/torture/pr113546-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit c5ca45b806)
2025-04-15 09:47:22 -07:00
Patrick Palka 3dc43f7f43 c++: wrong targs in satisfaction diagnostic context line [PR99214]
In the three-parameter version of satisfy_declaration_constraints, when
't' isn't the most general template, then 't' won't correspond with
'args' after we augment the latter via add_outermost_template_args, and
so the instantiation context that we push via push_tinst_level isn't
quite correct: 'args' is a complete set of template arguments, but 't'
is not necessarily the most general template.  This manifests as
misleading diagnostic context lines when issuing a satisfaction failure
error, e.g.  the below testcase without this patch we emit:
  In substitution of '... void A<int>::f<U>() ... [with U = int]'
and with this patch we emit:
  In substitution of '... void A<int>::f<U>() ... [with U = char]'.

This patch fixes this by passing the original 'args' to push_tinst_level,
which ought to properly correspond to 't'.

	PR c++/99214

gcc/cp/ChangeLog:

	* constraint.cc (satisfy_declaration_constraints): Pass the
	original ARGS to push_tinst_level.

gcc/testsuite/ChangeLog:

	* g++.dg/concepts/diagnostic20.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 00966a7fdb)
2025-04-15 08:46:59 -04:00
Jonathan Wakely 4ec931c5e5 libstdc++: Document thread-safety for COW std::string [PR21334]
The gcc4-compatible copy-on-write std::string does not conform to the
C++11 requirements on data race avoidance in standard containers.
Specifically, calling non-const member functions such as begin() and
data() needs to do the "copy on write" operation and so is most
definitely a modification of the object. As such, those non-const
members must not be called concurrently with any other uses of the
string object.

libstdc++-v3/ChangeLog:

	PR libstdc++/21334
	* doc/xml/manual/using.xml: Document that container data race
	avoidance rules do not apply to COW std::string.
	* doc/html/*: Regenerate.

(cherry picked from commit dd35f66287)
2025-04-15 09:32:32 +01:00
Andrew Pinski 6f0d80202b phiopt: Reset the number of iterations information of a loop when changing an exit from the loop [PR117243]
After r12-5300-gf98f373dd822b3, phiopt could get the following bb structure:
      |
    middle-bb -----|
      |            |
      |   |----|   |
    phi<1, 2>  |   |
    cond       |   |
      |        |   |
      |--------+---|

Which was considered 2 loops. The inner loop had esimtate of upper_bound to be 8,
due to the original `for (b = 0; b <= 7; b++)`. The outer loop was already an
infinite one.
So phiopt would come along and change the condition to be unconditionally true,
we change the inner loop to being an infinite one but don't reset the estimate
on the loop and cleanup cfg comes along and changes it into one loop but also
does not reset the estimate of the loop. Then the loop unrolling uses the old estimate
and decides to add an unreachable there.o
So the fix is when phiopt changes an exit to a loop, reset the estimates, similar to
how cleanupcfg does it when merging some basic blocks.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/117243
	PR tree-optimization/116749

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (replace_phi_edge_with_variable): Reset loop
	estimates if the cond_block was an exit to a loop.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr117243-1.c: New test.
	* gcc.dg/torture/pr117243-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit b7c69cc072)
2025-04-14 17:32:50 -07:00
Andrew Pinski 0d93166349 phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]
After r12-5300-gf98f373dd822b3, value_replacement would be able to look at the
following cfg structure:
```
  <bb 5> [local count: 1014686024]:
  if (h_6 != 0)
    goto <bb 7>; [94.50%]
  else
    goto <bb 6>; [5.50%]

  <bb 6> [local count: 114863530]:
  # h_6 = PHI <0(4), 1(5)>

  <bb 7> [local count: 1073741824]:
  # f_8 = PHI <0(5), h_6(6)>
  _9 = f_8 ^ 1;
  a.0_10 = a;
  _11 = _9 + a.0_10;
  if (_11 != -117)
    goto <bb 5>; [94.50%]
  else
    goto <bb 8>; [5.50%]
```

value_replacement would incorrectly think the middle bb (6) was empty and so it decides
to remove condition in bb5 and replacing it with 0 as the function thought it was `h_6 ? 0 : h_6`.
But since the there is an incoming phi node to bb6 defining h_6 that is incorrect.

The fix is to check if there is phi nodes in the middle bb and set empty_or_with_defined_p to false.
This was not needed before r12-5300-gf98f373dd822b3 because the phi would have been dead otherwise due to
other checks.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/118922

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (value_replacement): Set empty_or_with_defined_p
	to false when there is phi nodes for the middle bb.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr118922-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 7232c005af)
2025-04-14 17:32:49 -07:00
GCC Administrator f3d5cd4c40 Daily bump. 2025-04-15 00:25:02 +00:00
Eric Botcazou 5457388f58 Revert very recent backport of changes to the type system
The backport of the change made for PR c/113688 onto the 14 branch a couple
of weeks ago has seriously broken the LTO compiler for the Ada language on
the 14 branch, because it changes the GCC type system for the sake of C in
a way that is not compatible with simple discriminated types in Ada.  To be
more precise, useless_type_conversion_p now returns true for some (view-)
conversions that are needed by the rest of the compiler.

gcc/
	PR lto/119792
	Revert

	Backported from master:
	    2024-12-12  Martin Uecker  <uecker@tugraz.at>

	PR c/113688
	PR c/114014
	PR c/114713
	PR c/117724
	* tree.cc (gimple_canonical_types_compatible_p): Add exception.
	(verify_type): Add exception.

gcc/lto/
	PR lto/119792
	Revert

	Backported from master:
	    2024-12-12  Martin Uecker  <uecker@tugraz.at>
	* lto-common.cc (hash_canonical_type): Add exception.

gcc/testsuite/
	* gcc.dg/pr113688.c: Delete.
	* gcc.dg/pr114014.c: Likewise.
	* gcc.dg/pr114713.c: Likewise.
	* gcc.dg/pr117724.c: Likewise
2025-04-14 23:59:20 +02:00
Andrew Pinski 52b97f984f testcase: Add testcase for already fixed PR [PR118476]
This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

	PR tree-optimization/118476

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr118476-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit d45a6502d1)
2025-04-14 12:14:51 -07:00
Andrew Pinski f6efcd3d48 match: Reject non-ssa name/min invariants in gimple_extract [PR116412]
After the conversion for phiopt's conditional operand
to use maybe_push_res_to_seq, it was found that gimple_extract
will extract out from REALPART_EXPR/IMAGPART_EXPR/VCE and BIT_FIELD_REF,
a memory load. But that extraction was not needed as memory loads are not
simplified in match and simplify. So gimple_extract should return false
in those cases.

Changes since v1:
* Move the rejection to gimple_extract from factor_out_conditional_operation.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/116412

gcc/ChangeLog:

	* gimple-match-exports.cc (gimple_extract): Return false if op0
	was not a SSA name nor a min invariant for REALPART_EXPR/IMAGPART_EXPR/VCE
	and BIT_FIELD_REF.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr116412-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit c7b76a076c)
2025-04-14 12:14:50 -07:00
Andrew Pinski 8ee9d7b263 vec-lowering: Fix ABSU lowering [PR111285]
ABSU_EXPR lowering incorrectly used the resulting type
for the new expression but in the case of ABSU the resulting
type is an unsigned type and with ABSU is folded away. The fix
is to use a signed type for the expression instead.

Bootstrapped and tested on x86_64-linux-gnu.

	PR middle-end/111285

gcc/ChangeLog:

	* tree-vect-generic.cc (do_unop): Use a signed type for the
	operand if the operation was ABSU_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/vect-absu-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit ad0084337e)
2025-04-14 12:14:50 -07:00
Andrew Pinski aaef5d6409 backprop: Fix deleting of a phi node [PR116922]
The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/116922

gcc/ChangeLog:

	* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
	nodes correctly.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit cea87c84ea)
2025-04-14 12:14:49 -07:00
Andrew Pinski 16446f19f1 aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]
Early-RA was considering throwing instructions as being dead and removing
them even if -fno-delete-dead-exceptions was in use. This fixes that oversight.

Built and tested for aarch64-linux-gnu.

	PR target/116927

gcc/ChangeLog:

	* config/aarch64/aarch64-early-ra.cc (early_ra::is_dead_insn): Insns
	that throw are not dead with -fno-delete-dead-exceptions.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/pr116927-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit edec4bfc99)
2025-04-14 12:14:49 -07:00
Andrew Pinski c2c1046b83 phiopt: Fix VCE moving by rewriting it into cast [PR116098]
Phiopt match_and_simplify might move a well defined VCE assign statement
from being conditional to being uncondtitional; that VCE might no longer
being defined. It will need a rewrite into a cast instead.

This adds the rewriting code to move_stmt for the VCE case.
This is enough to fix the issue at hand. It should also be using rewrite_to_defined_overflow
but first I need to move the check to see a rewrite is needed into its own function
and that is causing issues (see https://gcc.gnu.org/pipermail/gcc-patches/2024-September/663938.html).
Plus this version is easiest to backport.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/116098

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (move_stmt): Rewrite VCEs from integer to integer
	types to case.

gcc/testsuite/ChangeLog:

	* c-c++-common/torture/pr116098-2.c: New test.
	* g++.dg/torture/pr116098-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 1f619fe259)
2025-04-14 12:14:49 -07:00
Harald Anlauf 477d8ba89f Fortran: fix issue with impure elemental subroutine and interface [PR119656]
PR fortran/119656

gcc/fortran/ChangeLog:

	* interface.cc (gfc_compare_actual_formal): Fix front-end memleak
	when searching for matching interfaces.
	* trans-expr.cc (gfc_conv_procedure_call): If there is a formal
	dummy corresponding to an absent argument, use its type, and only
	fall back to inferred type otherwise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 334545194d)
2025-04-14 19:24:43 +02:00
Eric Botcazou 569f826774 Add testcase for PR lto/119792
It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
	PR lto/119792
	* gnat.dg/lto29.adb: New test.
	* gnat.dg/lto29_pkg.ads: New helper.
2025-04-14 09:29:32 +02:00
Simon Martin 7e79c32ac1 c++: Properly fold <COND_EXPR>.*<COMPONENT> [PR114525]
We've been miscompiling the following since r0-51314-gd6b4ea8592e338 (I
did not go compile something that old, and identified this change via
git blame, so might be wrong)

=== cut here ===
struct Foo { int x; };
Foo& get (Foo &v) { return v; }
void bar () {
  Foo v; v.x = 1;
  (true ? get (v) : get (v)).*(&Foo::x) = 2;
  // v.x still equals 1 here...
}
=== cut here ===

The problem lies in build_m_component_ref, that computes the address of
the COND_EXPR using build_address to build the representation of
  (true ? get (v) : get (v)).*(&Foo::x);
and gets something like
  &(true ? get (v) : get (v))  // #1
instead of
  (true ? &get (v) : &get (v)) // #2
and the write does not go where want it to, hence the miscompile.

This patch replaces the call to build_address by a call to
cp_build_addr_expr, which gives #2, that is properly handled.

	PR c++/114525

gcc/cp/ChangeLog:

	* typeck2.cc (build_m_component_ref): Call cp_build_addr_expr
	instead of build_address.

gcc/testsuite/ChangeLog:

	* g++.dg/expr/cond18.C: New test.

(cherry picked from commit 35ce9afc84)
2025-04-14 08:36:06 +02:00
GCC Administrator 11bc1e0a20 Daily bump. 2025-04-14 00:23:08 +00:00
Richard Biener 31e31bbeea rtl-optimization/119689 - compare-debug failure with LRA
The previous change to fix LRA rematerialization broke compare-debug
for i586 bootstrap.  Fixed by using prev_nonnote_nondebug_insn
instead of prev_nonnote_insn.

	PR rtl-optimization/119689
	PR rtl-optimization/115568
	* lra-remat.cc (create_cands): Use prev_nonnote_nondebug_insn
	to check whether insn2 is directly before insn.

	* g++.target/i386/pr119689.C: New testcase.

(cherry picked from commit 088887de77)
2025-04-13 17:09:35 +02:00
Vladimir N. Makarov dc93babdcc [PR115568][LRA]: Use more strict output reload check in rematerialization
In this PR case LRA rematerialized a value from inheritance insn
instead of output reload one.  This resulted in considering a
rematerilization candidate value available when it was actually
not.  As a consequence an insn after rematerliazation used the
unexpected value and this use resulted in fp exception.  The patch
fixes this bug.

gcc/ChangeLog:

	PR rtl-optimization/115568
	* lra-remat.cc (create_cands): Check that output reload insn is
	adjacent to given insn.  Update a comment.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/115568
	* gcc.target/i386/pr115568.c: New.

(cherry picked from commit 9854544130)
2025-04-13 17:09:34 +02:00
GCC Administrator fb723bafa6 Daily bump. 2025-04-13 00:22:17 +00:00
GCC Administrator 97ebe4389b Daily bump. 2025-04-12 00:22:43 +00:00
Jason Merrill 45c949fb69 c++: avoid ARM -Wunused-value [PR114970]
Because of the __builtin_is_constant_evaluated, maybe_constant_init in
expand_default_init fails, so the constexpr constructor isn't folded until
cp_fold, which builds a COMPOUND_EXPR in case the enclosing expression is
relying on the ARM behavior of returning 'this'.

As in other places, avoid -Wunused-value on artificial COMPOUND_EXPR.

	PR c++/114970

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_fold): Suppress warnings on
	return_this COMPOUND_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/opt/is_constant_evaluated4.C: New test.

(cherry picked from commit 4acdfb71d4)
2025-04-11 10:37:21 -04:00
Jin Ma 889e40576f [PATCH v2] RISC-V: Fixbug for slli + addw + zext.w into sh[123]add + zext.w
Assuming we have the following variables:

unsigned long long a0, a1;
unsigned int a2;

For the expression:

a0 = (a0 << 50) >> 49;  // slli a0, a0, 50 + srli a0, a0, 49
a2 = a1 + a0;           // addw a2, a1, a0 + slli a2, a2, 32 + srli a2, a2, 32

In the optimization process of ZBA (combine pass), it would be optimized to:

a2 = a0 << 1 + a1;      // sh1add a2, a0, a1 + zext.w a2, a2

This is clearly incorrect, as it overlooks the fact that a0=a0&0x7ffe, meaning
that the bits a0[32:14] are set to zero.

gcc/ChangeLog:

	* config/riscv/bitmanip.md: The optimization can only be applied if
	the high bit of operands[3] is set to 1.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zba-shNadd-09.c: New test.
	* gcc.target/riscv/zba-shNadd-10.c: New test.

(cherry picked from commit dd6ebc0a34)
2025-04-11 14:54:59 +08:00
GCC Administrator 0379129ebd Daily bump. 2025-04-11 00:22:16 +00:00
Jason Merrill 779e002a1d c++: nested lambda capture pack [PR119345]
tsubst_stmt already registers a local capture proxy as a
local_specialization of both an outer capture proxy and the captured
variable; we also need to do that in add_extra_args.

	PR c++/119345

gcc/cp/ChangeLog:

	* pt.cc (add_extra_args): Also register a specialization
	of the captured variable.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ14.C: New test.

(cherry picked from commit 5957b9919c)
2025-04-10 16:42:34 -04:00
Jason Merrill e13143ab02 c++: lambda in constraint of lambda [PR119175]
Here when we went to mangle the constraints of from<0>, the outer lambda has
no mangling scope, but the inner one was treated as having the outer one as
its scope.  And mangling the outer one means mangling its constraints, which
include the inner one.  So infinite recursion.

But a lambda closure type isn't a scope that anything should have for
mangling, the inner lambda should also have no mangling scope.

	PR c++/119175

gcc/cp/ChangeLog:

	* mangle.cc (decl_mangling_context): Look through lambda type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-lambda23.C: New test.

(cherry picked from commit 39892d9618)
2025-04-10 16:42:34 -04:00
Jason Merrill 708c393774 c++: self-dependent alias template [PR117530]
Here, instantiating B<short> means instantiating A<short>, which means
instantiating B<short>.  And then when we go to register the initial
instantiation, it conflicts with the inner one.  Fixed by checking after
tsubst whether there's already something in the hash table.  We already did
something much like this in tsubst_decl, but that doesn't handle this case.

	PR c++/117530

gcc/cp/ChangeLog:

	* pt.cc (instantiate_template): Check retrieve_specialization after
	tsubst.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-uneval27.C: New test.

(cherry picked from commit d034c78c7b)
2025-04-10 16:42:34 -04:00
Patrick Palka 93be6016da c++: alias_ctad_tweaks ICE w/ inherited CTAD [PR119687]
With inherited CTAD the set of guides may be a two-dimensional overload
set (i.e. OVERLOADs of OVERLOADs) so alias_ctad_tweaks (which also does
the inherited CTAD transformation) needs to use the 2D-aware lkp_iterator
instead of ovl_iterator, or better yet use the more idiomatic lkp_range.

	PR c++/119687

gcc/cp/ChangeLog:

	* pt.cc (alias_ctad_tweaks): Use lkp_range / lkp_iterator
	instead of ovl_iterator.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/class-deduction-inherited8.C: New test.

Reviewed-by: Jason Merill <jason@redhat.com>
(cherry picked from commit 493974aa0a)
2025-04-10 15:50:06 -04:00
Jonathan Wakely 5cfe086bea libstdc++: Fix conversions to key/value types for hash table insertion [PR115285]
The conversions to key_type and value_type that are performed when
inserting into _Hashtable need to be fixed to do any required
conversions explicitly. The current code assumes that conversions from
the parameter to the key_type or value_type can be done implicitly,
which isn't necessarily true.

Remove the _S_forward_key function which doesn't handle all cases and
either forward the parameter if it already has type cv key_type, or
explicitly construct a temporary of type key_type.

Similarly, the _ConvertToValueType specialization for maps doesn't
handle all cases either, for std::pair arguments only some value
categories are handled. Remove _ConvertToValueType and for the _M_insert
function for unique keys, either forward the argument unchanged or
explicitly construct a temporary of type value_type.

For the _M_insert overload for non-unique keys we don't need any
conversion at all, we can just forward the argument directly to where we
construct a node.

libstdc++-v3/ChangeLog:

	PR libstdc++/115285
	* include/bits/hashtable.h (_Hashtable::_S_forward_key): Remove.
	(_Hashtable::_M_insert_unique_aux): Replace _S_forward_key with
	a static_cast to a type defined using conditional_t.
	(_Hashtable::_M_insert): Replace _ConvertToValueType with a
	static_cast to a type defined using conditional_t.
	* include/bits/hashtable_policy.h (_ConvertToValueType): Remove.
	* testsuite/23_containers/unordered_map/insert/115285.cc: New test.
	* testsuite/23_containers/unordered_set/insert/115285.cc: New test.
	* testsuite/23_containers/unordered_set/96088.cc: Adjust
	expected number of allocations.

(cherry picked from commit 90c578654a)
2025-04-10 12:47:52 +01:00
Jonathan Wakely c4bf3291f2 libstdc++: Define __is_pair variable template for C++11
libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (__is_pair): Define for C++11 and
	C++14 as well.

(cherry picked from commit dd08cdccc3)
2025-04-10 12:47:52 +01:00
François Dumont 9119752d37 libstdc++: Fix test broken when using COW std::string
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/96088.cc (test03): Fix increments
	value when _GLIBCXX_USE_CXX11_ABI is equal to 0.

(cherry picked from commit d01dc97a26)
2025-04-10 12:47:52 +01:00
François Dumont 6343a0fef3 libstdc++: Always instantiate key_type to compute hash code [PR115285]
Even if it is possible to compute a hash code from the inserted arguments
we need to instantiate the key_type to guaranty hash code consistency.

Preserve the lazy instantiation of the mapped_type in the context of
associative containers.

libstdc++-v3/ChangeLog:

	PR libstdc++/115285
	* include/bits/hashtable.h (_S_forward_key<_Kt>): Always return a temporary
	key_type instance.
	* testsuite/23_containers/unordered_map/96088.cc: Adapt to additional instanciation.
	Also check that mapped_type is not instantiated when there is no insertion.
	* testsuite/23_containers/unordered_multimap/96088.cc: Adapt to additional
	instanciation.
	* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
	* testsuite/23_containers/unordered_set/pr115285.cc: New test case.

(cherry picked from commit ee030b2800)
2025-04-10 12:47:52 +01:00
Jin Ma 51e041a9db RISC-V: Disable unsupported vsext/vzext patterns for XTheadVector.
XThreadVector does not support the vsext/vzext instructions; however,
due to the reuse of RVV optimizations, it may generate these instructions
in certain cases. To prevent the error "Unknown opcode 'th.vsext.vf2',"
we should disable these patterns.

V2:
Change the value of dg-do in the test case from assemble to compile, and
remove the -save-temps option.

gcc/ChangeLog:

	* config/riscv/vector.md: Disable vsext/vzext for XTheadVector.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/vsext.c: New test.
	* gcc.target/riscv/rvv/xtheadvector/vzext.c: New test.

(cherry picked from commit 196b45caca)
2025-04-10 19:22:00 +08:00
Jin Ma f2e2e25500 RISC-V: unrecognizable insn ICE in xtheadvector/pr114194.c on 32bit targets
This is a follow-up to the patch below to avoid generating unrecognized
vsetivl instructions for XTheadVector.

https://gcc.gnu.org/pipermail/gcc-patches/2025-January/674185.html

	PR target/118601

gcc/ChangeLog:

	* config/riscv/riscv-string.cc (expand_block_move): Check with new
	constraint 'vl' instead of 'K'.
	(expand_vec_setmem): Likewise.
	(expand_vec_cmpmem): Likewise.
	* config/riscv/riscv-v.cc (force_vector_length_operand): Likewise.
	(expand_load_store): Likewise.
	(expand_strided_load): Likewise.
	(expand_strided_store): Likewise.
	(expand_lanes_load_store): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/pr114194.c: Move to...
	* gcc.target/riscv/rvv/xtheadvector/pr114194-rv64.c: ...here.
	* gcc.target/riscv/rvv/xtheadvector/pr114194-rv32.c: New test.
	* gcc.target/riscv/rvv/xtheadvector/pr118601.c: New test.

Reported-by: Edwin Lu <ewlu@rivosinc.com>
(cherry picked from commit 580f571be6)
2025-04-10 19:22:00 +08:00
Jin Ma 2631ac38d9 RISC-V: Add a new constraint to ensure that the vl of XTheadVector does not get a non-zero immediate
Although we have handled the vl of XTheadVector correctly in the
expand phase and predicates, the results show that the work is
still insufficient.

In the curr_insn_transform function, the insn is transformed from:
(insn 69 67 225 12 (set (mem:RVVM8SF (reg/f:DI 218 [ _77 ]) [0  S[128, 128] A32])
        (if_then_else:RVVM8SF (unspec:RVVMF4BI [
                    (const_vector:RVVMF4BI repeat [
                            (const_int 1 [0x1])
                        ])
                    (reg:DI 209)
                    (const_int 0 [0])
                    (reg:SI 66 vl)
                    (reg:SI 67 vtype)
                ] UNSPEC_VPREDICATE)
            (reg/v:RVVM8SF 143 [ _xx ])
            (mem:RVVM8SF (reg/f:DI 218 [ _77 ]) [0  S[128, 128] A32])))
     (expr_list:REG_DEAD (reg/v:RVVM8SF 143 [ _xx ])
        (nil)))
to
(insn 69 284 225 11 (set (mem:RVVM8SF (reg/f:DI 18 s2 [orig:218 _77 ] [218]) [0  S[128, 128] A32])
        (if_then_else:RVVM8SF (unspec:RVVMF4BI [
                    (const_vector:RVVMF4BI repeat [
                            (const_int 1 [0x1])
                        ])
                    (const_int 1 [0x1])
                    (const_int 0 [0])
                    (reg:SI 66 vl)
                    (reg:SI 67 vtype)
                ] UNSPEC_VPREDICATE)
            (reg/v:RVVM8SF 104 v8 [orig:143 _xx ] [143])
            (mem:RVVM8SF (reg/f:DI 18 s2 [orig:218 _77 ] [218]) [0  S[128, 128] A32])))
     (nil))

Looking at the log for the reload pass, it is found that "Changing pseudo 209 in
operand 3 of insn 69 on equiv 0x1".
It converts the vl operand in insn from the expected register(reg:DI 209) to the
constant 1(const_int 1 [0x1]).

This conversion occurs because, although the predicate for the vl operand is
restricted by "vector_length_operand" in the pattern, the constraint is still
"rK", which allows the transformation.

The issue is that changing the "rK" constraint to "rJ" for the constraint of vl
operand in the pattern would prevent this conversion, But unfortunately this will
conflict with RVV (RISC-V Vector Extension).

Based on the review's recommendations, the best solution for now is to create
a new constraint to distinguish between RVV and XTheadVector, which is exactly
what this patch does.

	PR target/116593

gcc/ChangeLog:

	* config/riscv/constraints.md (vl): New.
	* config/riscv/thead-vector.md: Replacing rK with rvl.
	* config/riscv/vector.md: Likewise.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/rvv.exp: Enable testsuite of XTheadVector.
	* g++.target/riscv/rvv/xtheadvector/pr116593.C: New test.

(cherry picked from commit 3024b12f2c)
2025-04-10 19:21:59 +08:00
Jin Ma 319b9a385d RISC-V: Enable and adjust the testsuite for XTheadVector.
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/rvv.exp: Enable testsuite of
	XTheadVector.
	* gcc.target/riscv/rvv/xtheadvector/pr114194.c: Adjust correctly.
	* gcc.target/riscv/rvv/xtheadvector/prefix.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlb-vsb.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlbu-vsb.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlh-vsh.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlhu-vsh.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlw-vsw.c: Likewise.
	* gcc.target/riscv/rvv/xtheadvector/vlwu-vsw.c: Likewise.

(cherry picked from commit ab24171d23)
2025-04-10 19:21:59 +08:00
Jin Ma 07d4c264a0 [PATCH] RISC-V: Bugfix for unrecognizable insn for XTheadVector
error: unrecognizable insn:

(insn 35 34 36 2 (set (subreg:RVVM1SF (reg/v:RVVM1x4SF 142 [ _r ]) 0)
        (unspec:RVVM1SF [
                (const_vector:RVVM1SF repeat [
                        (const_double:SF 0.0 [0x0.0p+0])
                    ])
                (reg:DI 0 zero)
                (const_int 1 [0x1])
                (reg:SI 66 vl)
                (reg:SI 67 vtype)
            ] UNSPEC_TH_VWLDST)) -1
     (nil))
during RTL pass: mode_sw

	PR target/116591

gcc/ChangeLog:

	* config/riscv/vector.md: Add restriction to call pred_th_whole_mov.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/pr116591.c: New test.

(cherry picked from commit 8564d0948c)
2025-04-10 19:21:59 +08:00
Kito Cheng fb0653a0e5 RISC-V: Fix the behavior for multilib-generator with --cmodel=large on rv32
Large code model is only supported on RV64, so we don't need to
generate the multilibs for RV32 with --cmodel=large. And the compact
code model is something we don't supported on upstream (which is
accidentally added in the past), so we need to remove it.

gcc/ChangeLog:

	* config/riscv/multilib-generator: Remove the compact code model
	and check large code model for RV32.

(cherry picked from commit 72dff34bcd)
2025-04-10 17:10:22 +08:00
GCC Administrator 8406aec4ff Daily bump. 2025-04-10 00:22:21 +00:00
Patrick Palka 630bca9fa8 libstdc++: Fix constraint recursion in basic_const_iterator operator- [PR115046]
It was proposed in PR112490 to also adjust basic_const_iterator's friend
operator-(sent, iter) overload alongside the r15-7757-g4342c50ca84ae5
adjustments to its comparison operators, but we lacked a concrete
testcase demonstrating fixable constraint recursion there.  It turns out
Hewill Kang's PR115046 is such a testcase!  So this patch makes the same
adjustments to that overload as well, fixing PR115046.  The LWG 4218 P/R
will need to get adjusted too.

	PR libstdc++/115046
	PR libstdc++/112490

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (basic_const_iterator::operator-):
	Replace non-dependent basic_const_iterator function parameter with
	a dependent one of type basic_const_iterator<_It2> where _It2
	matches _It.
	* testsuite/std/ranges/adaptors/as_const/1.cc (test04): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit d69f73c033)
2025-04-09 17:56:13 -04:00
Patrick Palka ff5fdb3cad c++: ICE with nested default targ lambdas [PR119574]
In GCC 14 we fixed PR116567 in a more conservative way that doesn't
distinguish between the two kinds of deferred substitutions, and so
for PR119574 we instead ICE from get_innermost_template_args due to
TMPL_PARMS_DEPTH of the lambda, 2, being greater than the depth of the
augmented args, 1.

This patch works around the ICE in a best effort kind of way by guarding
the get_innermost_template_args call appropriately; I don't think it's
possible to get this completely right in GCC 14 without backporting the
proper fix for PR116567.

Note that lambda-targ13b.C present in the GCC 15 version of this patch[1]
never worked in GCC 14, and still doesn't work, which is why it's not
present in this patch.

[1]: r15-9350-gf3862ab07943d1

	PR c++/119574

gcc/cp/ChangeLog:

	* pt.cc (tsubst_lambda_expr): Don't call
	get_innermost_template_args if we're requesting too many
	levels.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ13.C: New test.
	* g++.dg/cpp2a/lambda-targ13a.C: New test.
2025-04-09 17:55:36 -04:00
Patrick O'Neill 6a66212916 RISC-V: Fix vid const vector expander for non-npatterns size steps
Prior to this patch the expander would emit vectors like:
{ 0, 0, 5, 5, 10, 10, ...}
as:
{ 0, 0, 2, 2,  4,  4, ...}

This patch sets the step size to the requested value.

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (expand_const_vector): Fix STEP size in
	expander.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-04-09 22:15:15 +08:00
xuli 4bd63c709d RISC-V:Bugfix for vlmul_ext and vlmul_trunc with NULL return value[pr117286]
This patch fixes following ICE:

test.c: In function 'func':
test.c:37:24: internal compiler error: Segmentation fault
   37 |     vfloat16mf2_t vc = __riscv_vlmul_trunc_v_f16m1_f16mf2(vb);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The root cause is that vlmul_trunc has a null return value.
gimple_call <__riscv_vlmul_trunc_v_f16m1_f16mf2, NULL, vb_13>
                                                 ^^^

Passed the rv64gcv_zvfh regression test.

Singed-off-by: Li Xu <xuli1@eswincomputing.com>

	PR target/117286

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins-bases.cc: Do not expand NULL return.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr117286.c: New test.
2025-04-09 22:15:14 +08:00
xuli 6cd78e383a RISC-V: Bugfix for max_sew_overlap_and_next_ratio_valid_for_prev_sew_p[pr117483]
This patch fixs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117483

If prev and next satisfy the following rules, we should forbid the case
(next.get_sew() < prev.get_sew() && (!next.get_ta() || !next.get_ma()))
in the compatible function max_sew_overlap_and_next_ratio_valid_for_prev_sew_p.
Otherwise, the tail elements of next will be polluted.

DEF_SEW_LMUL_RULE (ge_sew, ratio_and_ge_sew, ratio_and_ge_sew,
 max_sew_overlap_and_next_ratio_valid_for_prev_sew_p,
 always_false, use_max_sew_and_lmul_with_next_ratio)

Passed the rv64gcv full regression test.

Signed-off-by: Li Xu <xuli1@eswincomputing.com>

	PR target/117483

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: Fix bug.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr117483.c: New test.
2025-04-09 22:15:14 +08:00
Jeff Law cdb987e977 [committed] [RISC-V] Fix false-positive uninitialized variable
Andreas noted we were getting an uninit warning after the recent constant
synthesis changes.  Essentially there's no way for the uninit analysis code to
know the first entry in the CODES array is a UNKNOWN which will set X before
its first use.

So trivial initialization with NULL_RTX is the obvious fix.

Pushed to the trunk.

gcc/

	* config/riscv/riscv.cc (riscv_move_integer): Initialize "x".
2025-04-09 22:15:14 +08:00
Robin Dapp b7d9759450 RISC-V: Error early with V and no M extension.
For calculating the value of a poly_int at runtime we use a
multiplication instruction that requires the M extension.
Instead of just asserting and ICEing this patch emits an early
error at option-parsing time.

gcc/ChangeLog:

	PR target/116036

	* config/riscv/riscv.cc (riscv_override_options_internal): Error
	with TARGET_VECTOR && !TARGET_MUL.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-31.c: Add m to arch string and expect it.
	* gcc.target/riscv/arch-32.c: Ditto.
	* gcc.target/riscv/predef-14.c: Ditto.
	* gcc.target/riscv/predef-15.c: Ditto.
	* gcc.target/riscv/predef-16.c: Ditto.
	* gcc.target/riscv/predef-26.c: Ditto.
	* gcc.target/riscv/predef-27.c: Ditto.
	* gcc.target/riscv/predef-32.c: Ditto.
	* gcc.target/riscv/predef-33.c: Ditto.
	* gcc.target/riscv/rvv/autovec/pr111486.c: Add m to arch string.
	* gcc.target/riscv/compare-debug-1.c: Ditto.
	* gcc.target/riscv/compare-debug-2.c: Ditto.
	* gcc.target/riscv/rvv/base/pr116036.c: New test.
2025-04-09 22:14:58 +08:00
Patrick O'Neill eaf423763c RISC-V: Reject 'd' extension with ILP32E ABI
Also add a testcase for -mabi=lp64d where 'd' is required.

gcc/ChangeLog:

	PR target/116111
	* config/riscv/riscv.cc (riscv_option_override): Add error.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-41.c: New test.
	* gcc.target/riscv/pr116111.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2025-04-09 22:03:12 +08:00
Robin Dapp 95ac2d8afb RISC-V: Correct mode_idx attribute for viwalu wx variants [PR116149].
In PR116149 we choose a wrong vector length which causes wrong values in
a reduction.  The problem happens in avlprop where we choose the
number of units in the instruction's mode as vector length.  For the
non-scalar variants the respective operand has the correct non-widened
mode.  For the scalar variants, however, the same operand has a scalar
mode which obviously only has one unit.  This makes us choose VL = 1
leaving three elements undisturbed (so potentially -1).  Those end up
in the reduction causing the wrong result.

This patch adjusts the mode_idx just for the scalar variants of the
affected instruction patterns.

gcc/ChangeLog:

	PR target/116149

	* config/riscv/vector.md: Fix mode_idx attribute of scalar
	widen add/sub variants.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr116149.c: New test.
2025-04-09 22:03:12 +08:00
Jeff Law 86b0f63adb [RISC-V][PR target/116240] Ensure object is a comparison before extracting arguments
This was supposed to go out the door yesterday, but I kept getting interrupted.

The target bits for rtx costing can't assume the rtl they're given actually
matches a target pattern.   It's just kind of inherent in how the costing
routines get called in various places.

In this particular case we're trying to cost a conditional move:

(set (dest) (if_then_else (cond) (true) (false))

On the RISC-V port the backend only allows actual conditionals for COND.  So
something like (eq (reg) (const_int 0)).  In the costing code for if-then-else
we did something like

(XEXP (XEXP (cond, 0), 0)))

Which fails miserably if COND is a terminal node like (reg) rather than (ne
(reg) (const_int 0)

So this patch tightens up the RTL scanning to ensure that we have a comparison
before we start looking at the comparison's arguments.

Run through my tester without incident, but I'll wait for the pre-commit tester
to run through a cycle before pushing to the trunk.

Jeff

ps.   We probably could support a naked REG for the condition and internally convert it to (ne (reg) (const_int 0)), but I don't think it likely happens with any regularity.

	PR target/116240
gcc/
	* config/riscv/riscv.cc (riscv_rtx_costs): Ensure object is a
	comparison before looking at its arguments.

gcc/testsuite
	* gcc.target/riscv/pr116240.c: New test.
2025-04-09 22:03:12 +08:00
Jin Ma 28fe2b087b RISC-V: Delete duplicate '#define RISCV_DWARF_VLENB'
gcc/ChangeLog:

	* config/riscv/riscv.h (RISCV_DWARF_VLENB): Delete.
2025-04-09 22:03:12 +08:00
曾治金 327c7c3812 RISC-V: Fix factor in dwarf_poly_indeterminate_value [PR116305]
This patch is to fix the bug (BugId:116305) introduced by the commit
bd93ef for risc-v target.

The commit bd93ef changes the chunk_num from 1 to TARGET_MIN_VLEN/128
if TARGET_MIN_VLEN is larger than 128 in riscv_convert_vector_bits. So
it changes the value of BYTES_PER_RISCV_VECTOR. For example, before
merging the commit bd93ef and if TARGET_MIN_VLEN is 256, the value
of BYTES_PER_RISCV_VECTOR should be [8, 8], but now [16, 16]. The value
of riscv_bytes_per_vector_chunk and BYTES_PER_RISCV_VECTOR are no longer
equal.

Prologue will use BYTES_PER_RISCV_VECTOR.coeffs[1] to estimate the vlenb
register value in riscv_legitimize_poly_move, and dwarf2cfi will also
get the estimated vlenb register value in riscv_dwarf_poly_indeterminate_value
to calculate the number of times to multiply the vlenb register value.

So need to change the factor from riscv_bytes_per_vector_chunk to
BYTES_PER_RISCV_VECTOR, otherwise we will get the incorrect dwarf
information. The incorrect example as follow:

```
csrr    t0,vlenb
slli    t1,t0,1
sub     sp,sp,t1

.cfi_escape 0xf,0xb,0x72,0,0x92,0xa2,0x38,0,0x34,0x1e,0x23,0x50,0x22
```

The sequence '0x92,0xa2,0x38,0' means the vlenb register, '0x34' means
the literal 4, '0x1e' means the multiply operation. But in fact, the
vlenb register value just need to multiply the literal 2.

	PR target/116305

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_dwarf_poly_indeterminate_value): Take
	BYTES_PER_RISCV_VECTOR for *factor instead of riscv_bytes_per_vector_chunk.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/scalable_vector_cfi.c: New test.

Signed-off-by: Zhijin Zeng <zhijin.zeng@spacemit.com>
2025-04-09 22:03:11 +08:00
Kito Cheng d2f5d28415 RISC-V: Add missing mode_idx for vrol and vror
We add pattern for vector rotate, but seems like we forgot adding
mode_idx which used in AVL propgation (riscv-avlprop.cc).

gcc/ChangeLog:

	* config/riscv/vector.md (mode_idx): Add vrol and vror.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/rotr.c: New.
2025-04-09 22:03:11 +08:00
Robin Dapp e19a21f8ed RISC-V: Fix subreg of VLS modes larger than a vector [PR116086].
When the source mode is potentially larger than one vector (e.g. an
LMUL2 mode for VLEN=128) we don't know which vector the subreg actually
refers to.  For zvl128b and LMUL=2 the subreg in (subreg:V2DI (reg:V4DI))
could actually be the a full (high) vector register of a two-register
group (at VLEN=128) or the higher part of a single register (at VLEN>128).

As the subreg is statically ambiguous we prevent such situations in
can_change_mode_class.

The culprit in PR116086 is

 _12 = BIT_FIELD_REF <vect_cst__42, 128, 128>;

which can be expanded with a vector-vector extract (from V4DI to V2DI).
This patch adds a VLS-mode vector-vector extract that handles "halving"
cases like this one by sliding down the source vector, thus making sure
the correct part is used.

	PR target/116086

gcc/ChangeLog:

	* config/riscv/autovec.md (vec_extract<mode><v_half>): Add
	vector-vector extract for VLS modes.
	* config/riscv/riscv.cc (riscv_can_change_mode_class): Forbid
	VLS modes larger than one vector.
	* config/riscv/vector-iterators.md: Add vector-vector extract
	iterators.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp: Add effective target checks for
	zvl256b and zvl512b.
	* gcc.target/riscv/rvv/autovec/pr116086-2-run.c: New test.
	* gcc.target/riscv/rvv/autovec/pr116086-2.c: New test.
	* gcc.target/riscv/rvv/autovec/pr116086.c: New test.
2025-04-09 22:03:10 +08:00
Jin Ma 4f41d8fa5a [PATCH v4] [target/116592] RISC-V: Fix illegal operands "th.vsetvli zero,0,e32,m8" for XTheadVector
Since the THeadVector vsetvli does not support vl as an immediate, we
need to convert 0 to zero when outputting asm.

	PR target/116592

gcc/ChangeLog:

	* config/riscv/thead.cc (th_asm_output_opcode): Change '0' to
	"zero"

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/pr116592.c: New test.
2025-04-09 22:03:10 +08:00
garthlei 94b774c5c1 RISC-V: Fix vl_used_by_non_rvv_insn logic of vsetvl pass
This patch fixes a bug in the current vsetvl pass.  The current pass uses
`m_vl` to determine whether the dest operand has been used by non-RVV
instructions.  However, `m_vl` may have been modified as a result of an
`update_avl` call, and thus would be no longer the dest operand of the
original instruction.  This can lead to incorrect vsetvl eliminations, as is
shown in the testcase.  In this patch, we create a `dest_vl` variable for
this scenerio.

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: Use `dest_vl` for dest VL operand

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/vsetvl_bug-3.c: New test.
2025-04-09 22:03:10 +08:00
Andreas Schwab 5615fea2fc riscv: Fix duplicate assmbler label in @tlsdesc<mode> insn
Use %= instead of maintaining a sequence number manually, so that it
doesn't result in a duplicate assembler label when the insn is duplicated.

	PR target/116693
	* config/riscv/riscv.cc (riscv_legitimize_tls_address): Don't pass
	seqno to gen_tlsdesc and remove it.
	* config/riscv/riscv.md (@tlsdesc<mode>): Remove operand 1.  Use
	%= instead of %1 in template.
2025-04-09 22:03:10 +08:00
Bohan Lei d0663c1430 [PATCH] RISC-V: Allow zero operand for DI variants of vssubu.vx
The RISC-V vector machine description relies on the helper function
`sew64_scalar_helper` to emit actual insns for the DI variants of
vssub.vx and vssubu.vx.  This works with vssub.vx, but can cause
problems with vssubu.vx with the scalar operand being constant zero,
because `has_vi_variant_p` returns false, and the operand will be taken
without being loaded into a reg.  The attached testcases can cause an
internal compiler error as a result.

Allowing a constant zero operand in those insns seems to be a simple
solution that only affects minimum existing code.

gcc/ChangeLog:

	* config/riscv/vector.md: Allow zero operand for DI variants of
	vssubu.vx

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/vssubu-1.c: New test.
	* gcc.target/riscv/rvv/base/vssubu-2.c: New test.
2025-04-09 22:03:09 +08:00
Xianmiao Qu 5b3558944a [PATCH] RISC-V: Fix th.extu operands exceeding range on rv32.
The Combine Pass may generate zero_extract instructions that are out of range.
Drawing from other architectures like AArch64, we should impose restrictions
on the "*th_extu<mode>4" pattern.

gcc/
	* config/riscv/thead.md (*th_extu<mode>4): Fix th.extu
	operands exceeding range on rv32.

gcc/testsuite/
	* gcc.target/riscv/xtheadbb-extu-4.c: New.
2025-04-09 22:03:09 +08:00
Xianmiao Qu 80ab251425 [PATCH 1/2] RISC-V: Fix the outer_code when calculating the cost of SET expression.
I think it is a typo. When calculating the 'SET_SRC (x)' cost,
outer_code should be set to SET.

gcc/
	* config/riscv/riscv.cc (riscv_rtx_costs): Fix the outer_code
	when calculating the cost of SET expression.
2025-04-09 22:03:09 +08:00
Jin Ma 37d1315363 [PATCH v3] RISC-V: Fixed incorrect semantic description in DF to DI pattern in the Zfa extension on rv32.
gcc/ChangeLog:

	* config/riscv/riscv.md: Change "truncate" to unspec for the Zfa extension on rv32.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zfa-fmovh-fmovp-bug.c: New test.
2025-04-09 22:03:09 +08:00
Robin Dapp 164aededa8 RISC-V: Ensure vtype for full-register moves [PR117544].
As discussed in PR117544 the VTYPE register is not preserved across
function calls.  Even though vmv1r-like instructions operate
independently of the actual vtype they still require a valid vtype.  As
we cannot guarantee that the vtype is valid we must make sure to emit a
vsetvl between a function call and a vmv1r.v.

This patch makes the necessary changes by splitting the full-reg-move
insns into patterns that use the vtype register and adding vmov to the
types of instructions requiring a vset.

	PR target/117544

gcc/ChangeLog:

	* config/riscv/vector.md (*mov<mode>_whole): Split.
	(*mov<mode>_fract): Ditto.
	(*mov<mode>): Ditto.
	(*mov<mode>_vls): Ditto.
	(*mov<mode>_reg_whole_vtype): New pattern with vtype use.
	(*mov<mode>_fract_vtype): Ditto.
	(*mov<mode>_vtype): Ditto.
	(*mov<mode>_vls_vtype): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/abi-call-args-4.c: Expect vsetvl.
	* gcc.target/riscv/rvv/base/pr117544.c: New test.
2025-04-09 22:03:09 +08:00
Pan Li acb636a9c3 RISC-V: Add assert for insn operand out of range access [PR117878][NFC]
According to the the initial analysis of PR117878, the ice comes from
the out-of-range operand access for recog_data.operand[].  Thus, add
one assert here to expose this explicitly.

	PR target/117878

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (vlmax_avl_type_p): Add assert for
	out of range access.
	(nonvlmax_avl_type_p): Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2025-04-09 22:03:08 +08:00
Robin Dapp ca6adeda37 RISC-V: Fix compress shuffle pattern [PR117383].
This patch makes vcompress use the tail-undisturbed policy by default
and also uses the proper VL.

	PR target/117383

gcc/ChangeLog:

	* config/riscv/riscv-protos.h (enum insn_type): Use TU policy.
	* config/riscv/riscv-v.cc (shuffle_compress_patterns): Set VL.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/binop/vcompress-avlprop-1.c:
	Expect tu.
	* gcc.target/riscv/rvv/autovec/pr117383.c: New test.
2025-04-09 22:03:08 +08:00
Jeff Law 6547906bdb [RISC-V][PR target/106544] Avoid ICEs due to bogus asms
This is a fix for a bug Andrew P filed a while back where essentially a poorly
crafted asm statement could trigger a ICE during assembly output.  Various
cases will use INTVAL (op) without verifying the operand is a CONST_INT node
first.

The usual way to handle this is via output_operand_lossage, which this patch
implements.

I focused primarily on the CONST_INT cases, there could well be other problems
in this space, if so they should get distinct bugs with testcases.

Tested in my tester on rv32 and rv64.  Waiting for pre-commit testing before
moving forward.

	PR target/106544
gcc/

	* config/riscv/riscv.cc (riscv_print_operand): Issue an error for
	invalid operands rather than invalidly accessing INTVAL of an
	object that is not a CONST_INT.  Fix one error string for 'N'.

gcc/testsuite
	* gcc.target/riscv/pr106544.c: New test.
2025-04-09 22:03:08 +08:00
Andreas Schwab 46732eb89d [PATCH] riscv: add mising masking in lrsc expander (PR118137)
gcc:
	PR target/118137
	* config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
	to shifted value.

gcc/testsuite:
	PR target/118137
	* gcc.dg/atomic/pr118137.c: New.
2025-04-09 22:03:08 +08:00
Robin Dapp 08e381e8af RISC-V: Disallow negative step for interleaving [PR117682]
Hi,

in PR117682 we build an interleaving pattern

  { 1, 201, 209, 25, 161, 105, 113, 185, 65, 9,
    17, 89, 225, 169, 177, 249, 129, 73, 81, 153,
    33, 233, 241, 57, 193, 137, 145, 217, 97, 41,
    49, 121 };

with negative step expecting wraparound semantics due to -fwrapv.

For building interleaved patterns we have an optimization that
does e.g.
  {1, 209, ...} = { 1, 0, 209, 0, ...}
and
  {201, 25, ...} >> 8 = { 0, 201, 0, 25, ...}
and IORs those.

The optimization only works if the lowpart bits are zero.  When
overflowing e.g. with a negative step we cannot guarantee this.

This patch makes us fall back to the generic merge handling for negative
steps.

I'm not 100% certain we're good even for positive steps.  If the
step or the vector length is large enough we'd still overflow and
have non-zero lower bits.  I haven't seen this happen during my
testing, though and the patch doesn't make things worse, so...

Regtested on rv64gcv_zvl512b.  Let's see what the CI says.

Regards
 Robin

	PR target/117682

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (expand_const_vector): Fall back to
	merging if either step is negative.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr117682.c: New test.
2025-04-09 22:03:07 +08:00
Robin Dapp 6f549f865d RISC-V: Fix vsetvl compatibility predicate [PR118154].
In PR118154 we emit strided stores but the first of those does not
always have the proper VTYPE.  That's because we erroneously delete
a necessary vsetvl.

In order to determine whether to elide

(1)
      Expr[7]: VALID (insn 116, bb 17)
        Demand fields: demand_ratio_and_ge_sew demand_avl
        SEW=8, VLMUL=mf2, RATIO=16, MAX_SEW=64
        TAIL_POLICY=agnostic, MASK_POLICY=agnostic
        AVL=(reg:DI 0 zero)

when e.g.

(2)
      Expr[3]: VALID (insn 360, bb 15)
        Demand fields: demand_sew_lmul demand_avl
        SEW=64, VLMUL=m1, RATIO=64, MAX_SEW=64
        TAIL_POLICY=agnostic, MASK_POLICY=agnostic
        AVL=(reg:DI 0 zero)
        VL=(reg:DI 13 a3 [345])

is already available, we use
sew_ge_and_prev_sew_le_next_max_sew_and_next_ratio_valid_for_prev_sew_p.

(1) requires RATIO = SEW/LMUL = 16 and an SEW >= 8.  (2) has ratio = 64,
though, so we cannot directly elide (1).

This patch uses ratio_eq_p instead of next_ratio_valid_for_prev_sew_p.

	PR target/118154

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (MAX_LMUL): New define.
	(pre_vsetvl::earliest_fuse_vsetvl_info): Use.
	(pre_vsetvl::pre_global_vsetvl_info): New predicate with equal
	ratio.
	* config/riscv/riscv-vsetvl.def: Use.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr118154-1.c: New test.
	* gcc.target/riscv/rvv/autovec/pr118154-2.c: New test.
2025-04-09 22:03:07 +08:00
Kito Cheng 1eb6bf3128 RISC-V: Fix code gen for reduction with length 0 [PR118182]
`.MASK_LEN_FOLD_LEFT_PLUS`(or `mask_len_fold_left_plus_m`) is expecting the
return value will be the start value even if the length is 0.

However current code gen in RISC-V backend is not meet that semantic, it will
result a random garbage value if length is 0.

Let example by current code gen for MASK_LEN_FOLD_LEFT_PLUS with f64:
        # _148 = .MASK_LEN_FOLD_LEFT_PLUS (stmp__148.33_134, vect__70.32_138, { -1, ... }, loop_len_161, 0);
        vsetvli zero,a5,e64,m1,ta,ma
        vfmv.s.f        v2,fa5     # insn 1
        vfredosum.vs    v1,v1,v2   # insn 2
        vfmv.f.s        fa5,v1     # insn 3

insn 1:
- vfmv.s.f won't do anything if VL=0, which means v2 will contain garbage value.
insn 2:
- vfredosum.vs won't do anything if VL=0, and keep vd unchanged even TA.
(v-spec say: `If vl=0, no operation is performed and the destination register
 is not updated.`)
insn 3:
- vfmv.f.s will move the value from v1 even VL=0, so this is safe.

So how we fix that? we need two fix for that:

1. insn 1: need always execute with VL=1, so that we can guarantee it will
           always work as expect.
2. insn 2: Add new pattern to force `vd` use same reg as `vs1` (start value) for
           all reduction patterns, then we can guarantee vd[0] will contain the
           start value when vl=0

For 1, it's just a simple change to riscv_vector::expand_reduction, but for 2,
we have to add _VL0_SAFE variant reduction to force `vd` use same reg as `vs1`
(start value).

Change since V3:
- Rename _AV to _VL0_SAFE for readability.
- Use non-VL0_SAFE version if VL is const or VLMAX.
- Only force VL=1 for vfmv.s.f when VL is non-const and non-VLMAX.
- Two more testcase.

gcc/ChangeLog:

	PR target/118182
	* config/riscv/autovec-opt.md (*widen_reduc_plus_scal_<mode>): Adjust
	argument for expand_reduction.
	(*widen_reduc_plus_scal_<mode>): Ditto.
	(*fold_left_widen_plus_<mode>): Ditto.
	(*mask_len_fold_left_widen_plus_<mode>): Ditto.
	(*cond_widen_reduc_plus_scal_<mode>): Ditto.
	(*cond_len_widen_reduc_plus_scal_<mode>): Ditto.
	(*cond_widen_reduc_plus_scal_<mode>): Ditto.
	* config/riscv/autovec.md (reduc_plus_scal_<mode>): Adjust argument for
	expand_reduction.
	(reduc_smax_scal_<mode>): Ditto.
	(reduc_umax_scal_<mode>): Ditto.
	(reduc_smin_scal_<mode>): Ditto.
	(reduc_umin_scal_<mode>): Ditto.
	(reduc_and_scal_<mode>): Ditto.
	(reduc_ior_scal_<mode>): Ditto.
	(reduc_xor_scal_<mode>): Ditto.
	(reduc_plus_scal_<mode>): Ditto.
	(reduc_smax_scal_<mode>): Ditto.
	(reduc_smin_scal_<mode>): Ditto.
	(reduc_fmax_scal_<mode>): Ditto.
	(reduc_fmin_scal_<mode>): Ditto.
	(fold_left_plus_<mode>): Ditto.
	(mask_len_fold_left_plus_<mode>): Ditto.
	* config/riscv/riscv-v.cc (expand_reduction): Add one more
	argument for reduction code for vl0-safe.
	* config/riscv/riscv-protos.h (expand_reduction): Ditto.
	* config/riscv/vector-iterators.md (unspec): Add _VL0_SAFE variant of
	reduction.
	(ANY_REDUC_VL0_SAFE): New.
	(ANY_WREDUC_VL0_SAFE): Ditto.
	(ANY_FREDUC_VL0_SAFE): Ditto.
	(ANY_FREDUC_SUM_VL0_SAFE): Ditto.
	(ANY_FWREDUC_SUM_VL0_SAFE): Ditto.
	(reduc_op): Add _VL0_SAFE variant of reduction.
	(order) Ditto.
	* config/riscv/vector.md (@pred_<reduc_op><mode>): New.

gcc/testsuite/ChangeLog:

	PR target/118182
	* gfortran.target/riscv/rvv/pr118182.f: New.
	* gcc.target/riscv/rvv/autovec/pr118182-1.c: New.
	* gcc.target/riscv/rvv/autovec/pr118182-2.c: New.
2025-04-09 22:03:07 +08:00
Kito Cheng af3ebb414e RISC-V: Move fortran testcase to gfortran.target
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/fortran/pr111395.f90: Move this file to...
	* gfortran.target/riscv/rvv/pr111395.f90: ...here.
	* gcc.target/riscv/rvv/fortran/pr111566.f90: Move this file to...
	* gfortran.target/riscv/rvv/pr111566.f90: ...here.
	* gcc.target/riscv/rvv/rvv-fortran.exp: Move this file to...
	* gfortran.target/riscv/rvv/rvv.exp: ...here.
2025-04-09 22:03:07 +08:00
Jin Ma e4586ae318 [PR target/118357] RISC-V: Disable fusing vsetvl instructions by VSETVL_VTYPE_CHANGE_ONLY for XTheadVector.
In RVV 1.0, the instruction "vsetvli	zero,zero,*" indicates that the
available vector length (avl) does not change. However, in XTheadVector,
this same instruction signifies that the avl should take the maximum value.
Consequently, when fusing vsetvl instructions, the optimization labeled
"VSETVL_VTYPE_CHANGE_ONLY" is disabled for XTheadVector.

	PR target/118357

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: Function change_vtype_only_p always
	returns false for XTheadVector.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/pr118357.c: New test.
2025-04-09 22:03:06 +08:00
Jeff Law f3ac41f842 [RISC-V][PR target/116308] Fix generation of initial RTL for atomics
While this wasn't originally marked as a regression, it almost certainly is
given that older versions of GCC would have used libatomic and would not have
ICE'd on this code.

Basically this is another case where we directly used simplify_gen_subreg when
we should have used gen_lowpart.

When I fixed a similar bug a while back I noted the code in question as needing
another looksie.  I think at that time my brain saw the mixed modes (SI & QI)
and locked up.  But the QI stuff is just the shift count, not some deeper
issue.  So fixing is trivial.

We just replace the simplify_gen_subreg with a gen_lowpart and get on with our
lives.

Tested on rv64 and rv32 in my tester.  Waiting on pre-commit testing for final
verdict.

	PR target/116308
gcc/
	* config/riscv/riscv.cc (riscv_lshift_subword): Use gen_lowpart
	rather than simplify_gen_subreg.

gcc/testsuite/

	* gcc.target/riscv/pr116308.c: New test.
2025-04-09 22:03:06 +08:00
Jeff Law 47b509fef5 [RISC-V][PR target/116256] Fix incorrect return value for predicate
Another bug found while chasing paths to fix the remaining issues in pr116256.

This case is sometimes benign when the optimizers are enabled.  But could show
up in a -O0 compile with some patterns I was playing around with.

Basically we have a predicate that is meant to return true if bits set in the
operand are all consecutive.

That predicate would return the wrong value when presented with (const_int 0)
indicating it had a run of on bits when obviously no bits are on 😉

It's pretty obvious once you look at the implementation.

if (exact_log2 ((val >> ctz_hwi (val)) + 1) < 0)
  return false
return true;

The right shift is always going to produce 0.  0 + 1 = 1 which is a power of 2.
So exact_log2 returns 0 and we get a true result rather than a false result.

The fix is trivial.  "<=".  While inside we might as well fix the formatting.

Tested on rv32 and rv64 in my tester.  Waiting on upstream pre-commit testing
to render a verdict.

	PR target/116256
gcc/
	* config/riscv/predicates.md (consecutive_bits_operand): Properly
	handle (const_int 0).
2025-04-09 22:03:06 +08:00
Yang Yujie 4d5fd1176d LoongArch: Fix awk / sed usage for compatibility
Tested with nawk, mawk, and gawk.

gcc/ChangeLog:

	* config/loongarch/genopts/gen-evolution.awk: remove
	usage of "asort".
	* config/loongarch/genopts/genstr.sh: replace sed with awk.

(cherry picked from commit 6ed8c17c2b)
2025-04-09 11:45:23 +08:00
Xi Ruoyao fd7d5a6b77 LoongArch: Make gen-evolution.awk compatible with FreeBSD awk
Avoid using gensub that FreeBSD awk lacks, use gsub and split those each
of gawk, mawk, and FreeBSD awk provides.

Reported-by: mpysw@vip.163.com
Link: https://man.freebsd.org/cgi/man.cgi?query=awk

gcc/ChangeLog:

	* config/loongarch/genopts/gen-evolution.awk: Avoid using gensub
	that FreeBSD awk lacks.

(cherry picked from commit 92ca72b41a)
2025-04-09 11:44:43 +08:00
GCC Administrator bbf9e7945e Daily bump. 2025-04-09 00:22:11 +00:00
Jonathan Wakely 059107eb22 libstdc++: Fix use-after-free in std::format [PR119671]
When formatting floating-point values to wide strings there's a case
where we invalidate a std::wstring buffer while a std::wstring_view is
still referring to it.

libstdc++-v3/ChangeLog:

	PR libstdc++/119671
	* include/std/format (__formatter_fp::format): Do not invalidate
	__wstr unless _M_localized returns a valid string.
	* testsuite/std/format/functions/format.cc: Check wide string
	formatting of floating-point types with classic locale.

Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
(cherry picked from commit e33b62eed7)
2025-04-08 10:13:39 +01:00
Jonathan Wakely 7e789f3420 libstdc++: Add new header to Doxygen config file
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add text_encoding.

(cherry picked from commit 5430fcd1a3)
2025-04-08 10:13:39 +01:00
Jonathan Wakely 7ad64ffe10 libstdc++: Replace use of __mindist in ranges::uninitialized_xxx algos [PR101587]
In r15-8980-gf4b6acfc36fb1f I introduced a new function object for
finding the smaller of two distances. In bugzilla Hewill Kang pointed
out that we still need to explicitly convert the result back to the
right difference type, because the result might be an integer-like class
type that doesn't convert to an integral type explicitly.

Rather than doing that conversion in the __mindist function object, I
think it's simpler to remove it again and just do a comparison and
assignment. We always want the result to have a specific type, so we can
just check if the value of the other type is smaller, and then convert
that to the other type if so.

libstdc++-v3/ChangeLog:

	PR libstdc++/101587
	* include/bits/ranges_uninitialized.h (__detail::__mindist):
	Remove.
	(ranges::uninitialized_copy, ranges::uninitialized_copy_n)
	(ranges::uninitialized_move, ranges::uninitialized_move_n): Use
	comparison and assignment instead of __mindist.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
	Check with ranges that use integer-like class type for
	difference type.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Likewise.

Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
Reviewed-by: Hewill Kang <hewillk@gmail.com>
(cherry picked from commit 03ac8886e5)
2025-04-08 10:13:39 +01:00
Jonathan Wakely ef11c1573d libstdc++: Replace use of std::min in ranges::uninitialized_xxx algos [PR101587]
Because ranges can have any signed integer-like type as difference_type,
it's not valid to use std::min(diff1, diff2). Instead of calling
std::min with an explicit template argument, this adds a new __mindist
helper that determines the common type and uses that with std::min.

libstdc++-v3/ChangeLog:

	PR libstdc++/101587
	* include/bits/ranges_uninitialized.h (__detail::__mindist):
	New function object.
	(ranges::uninitialized_copy, ranges::uninitialized_copy_n)
	(ranges::uninitialized_move, ranges::uninitialized_move_n): Use
	__mindist instead of std::min.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
	Check ranges with difference difference types.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Likewise.

(cherry picked from commit f4b6acfc36)
2025-04-08 10:13:39 +01:00
Lulu Cheng 73a62377ae LoongArch: Add LoongArch architecture detection to __float128 support in libgfortran and libquadmath [PR119408].
In GCC14, LoongArch added __float128 as an alias for _Float128.
In commit r15-8962, support for q/Q suffixes for 128-bit floating point
numbers.  This will cause the compiler to automatically link libquadmath
when compiling Fortran programs.  But on LoongArch `long double` is
IEEE quad, so there is no need to implement libquadmath.
This causes link failure.

	PR target/119408

libgfortran/ChangeLog:

	* acinclude.m4: When checking for __float128 support, determine
	whether the current architecture is LoongArch.  If so, return false.
	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure.ac: When checking for __float128 support, determine
	whether the current architecture is LoongArch.  If so, return false.
	* configure: Regenerate.

	Sigend-off-by: Xi Ruoyao <xry111@xry111.site>
	Sigend-off-by: Jakub Jelinek <jakub@redhat.com>

(cherry picked from commit 1534f0099c)
2025-04-08 09:19:14 +08:00
GCC Administrator da91ea5de5 Daily bump. 2025-04-08 00:23:26 +00:00
Patrick Palka 5cdf31f080 libstdc++: Work around C++20 tuple<tuple<any>> constraint recursion [PR116440]
The type tuple<tuple<any>> is clearly copy/move constructible, but for
reasons that are not yet completely understood checking this triggers
constraint recursion with our C++20 tuple implementation (but not the
C++17 implementation).

It turns out this recursion stems from considering the non-template
tuple(const _Elements&) constructor during the copy/move constructibility
check.  Considering this constructor is ultimately redundant, since the
defaulted copy/move constructors are better matches.

GCC has a non-standard "perfect candidate" optimization[1] that causes
overload resolution to shortcut considering template candidates if we
find a (non-template) perfect candidate.  So to work around this issue
(and as a general compile-time optimization) this patch turns the
problematic constructor into a template so that GCC doesn't consider it
when checking for copy/move constructibility of this tuple type.

Changing the template-ness of a constructor can affect overload
resolution (since template-ness is a tiebreaker) so there's a risk this
change could e.g. introduce overload resolution ambiguities.  But the
original C++17 implementation has long defined this constructor as a
template (in order to constrain it etc), so doing the same thing in the
C++20 mode should naturally be quite safe.

The testcase still fails with Clang (in C++20 mode) since it doesn't
implement said optimization.

[1]: See r11-7287-g187d0d5871b1fa and
https://isocpp.org/files/papers/P3606R0.html

	PR libstdc++/116440

libstdc++-v3/ChangeLog:

	* include/std/tuple (tuple::tuple(const _Elements&...))
	[C++20]: Turn into a template.
	* testsuite/20_util/tuple/116440.C: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 6570fa6f26)
2025-04-07 19:38:39 -04:00
Jason Merrill 749221fac5 c++: constinit and value-initialization [PR119652]
Value-initialization built an AGGR_INIT_EXPR to set AGGR_INIT_ZERO_FIRST on.
Passing that AGGR_INIT_EXPR to maybe_constant_value returned a TARGET_EXPR,
which potential_constant_expression_1 mistook for a temporary.

We shouldn't add a TARGET_EXPR to the AGGR_INIT_EXPR in this case, just like
we already avoid adding it to CONSTRUCTOR or CALL_EXPR.

	PR c++/119652

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_outermost_constant_expr): Also don't add a
	TARGET_EXPR around AGGR_INIT_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constinit20.C: New test.

(cherry picked from commit c7dc9b6f88)
2025-04-07 13:15:45 -04:00
Jason Merrill e2a178a511 c++: __FUNCTION__ in lambda return type [PR118629]
In this testcase, the use of __FUNCTION__ is within a function parameter
scope, the lambda's.  And P1787 changed __func__ to live in the parameter
scope.  But [basic.scope.pdecl] says that the point of declaration of
__func__ is immediately before {, so in the trailing return type it isn't in
scope yet, so this __FUNCTION__ should refer to foo().

Looking first for a block scope, then a function parameter scope, gives us
the right result.

	PR c++/118629

gcc/cp/ChangeLog:

	* name-lookup.cc (pushdecl_outermost_localscope): Look for an
	sk_block.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-__func__3.C: New test.

(cherry picked from commit 7d56182052)
2025-04-07 13:15:45 -04:00
GCC Administrator 2e58e23802 Daily bump. 2025-04-07 00:21:21 +00:00
GCC Administrator cfd1652f00 Daily bump. 2025-04-06 00:21:18 +00:00
GCC Administrator 4feaf39363 Daily bump. 2025-04-05 00:21:41 +00:00
Jason Merrill ecc2725d61 c++: lambda in requires outside template [PR99546]
Since r10-7441 we set processing_template_decl in a requires-expression so
that we can use tsubst_expr to evaluate the requirements, but that confuses
lambdas terribly; begin_lambda_type silently returns error_mark_node and we
continue into other failures.  This patch clears processing_template_decl
again while we're defining the closure and op() function, so it only remains
set while parsing the introducer (i.e. any init-captures) and building the
resulting object.  This properly avoids trying to create another lambda in
tsubst_lambda_expr.

	PR c++/99546
	PR c++/113925
	PR c++/106976
	PR c++/109961
	PR c++/117336

gcc/cp/ChangeLog:

	* lambda.cc (build_lambda_object): Handle fake
	requires-expr processing_template_decl.
	* parser.cc (cp_parser_lambda_expression): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-requires2.C: New test.
	* g++.dg/cpp2a/lambda-requires3.C: New test.
	* g++.dg/cpp2a/lambda-requires4.C: New test.
	* g++.dg/cpp2a/lambda-requires5.C: New test.

(cherry picked from commit 25992d8daf)
2025-04-04 16:31:59 -04:00
Patrick Palka 49b6308d25 c++: constraint variable used in evaluated context [PR117849]
Here we wrongly reject the type-requirement at parse time due to its use
of the constraint variable 't' within a template argument (an evaluated
context).  Fix this simply by refining the "use of parameter outside
function body" error path to exclude constraint variables.

PR c++/104255 tracks the same issue for function parameters, but fixing
that would be more involved, requiring changes to the PARM_DECL case of
tsubst_expr.

	PR c++/117849

gcc/cp/ChangeLog:

	* semantics.cc (finish_id_expression_1): Allow use of constraint
	variable outside an unevaluated context.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires41.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6e973e87e3)
2025-04-04 14:30:34 -04:00
Patrick Palka 9a747094ac c++: P2280R4 and speculative constexpr folding [PR119387]
Compiling the testcase in this PR uses 2.5x more memory and 6x more
time ever since r14-5979 which implements P2280R4.  This is because
our speculative constexpr folding now does a lot more work trying to
fold ultimately non-constant calls to constexpr functions, and in turn
produces a lot of garbage.  We do sometimes successfully fold more
thanks to P2280R4, but it seems to be trivial stuff like calls to
std::array::size or std::addressof.  The benefit of P2280 therefore
doesn't seem worth the cost during speculative constexpr folding, so
this patch restricts the paper to only manifestly-constant evaluation.

	PR c++/119387

gcc/cp/ChangeLog:

	* constexpr.cc (p2280_active_p): New.
	(cxx_eval_constant_expression) <case VAR_DECL>: Use it to
	restrict P2280 relaxations.
	<case PARM_DECL>: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit a926345f22)
2025-04-04 14:30:34 -04:00
Eric Botcazou a210011c5c Ada: Fix thinko in Eigensystem for complex Hermitian matrices
The implementation solves the eigensystem for a NxN complex Hermitian matrix
by first solving it for a 2Nx2N real symmetric matrix and then interpreting
the 2Nx1 real vectors as Nx1 complex ones, but the last step does not work.

The patch fixes the last step and also performs a small cleanup throughout
the implementation, mostly in the commentary and without functional changes.

gcc/ada/
	* libgnat/a-ngcoar.adb (Eigensystem): Adjust notation and fix the
	layout of the real symmetric matrix in the main comment.  Adjust
	the layout of the associated code accordingly and correctly turn
	the 2Nx1 real vectors into Nx1 complex ones.
	(Eigenvalues): Minor similar tweaks.
	* libgnat/a-ngrear.adb (Jacobi): Minor tweaks in the main comment.
	Adjust notation and corresponding parameter names of functions.
	Fix call to Unit_Matrix routine.  Adjust the comment describing
	the various kinds of iterations to match the implementation.
2025-04-04 11:50:12 +02:00
Victor Do Nascimento 2b9a842b82 vect: Relax scan-tree-dump strict pattern matching [PR118597]
Using specific SSA names in pattern matching in `dg-final' makes tests
"unstable", in that changes in passes prior to the pass whose dump is
analyzed in the particular test may change the numbering of the SSA
variables, causing the test to start failing spuriously.

We thus switch from specific SSA names to the use of a multi-line
regular expression making use of capture groups for matching particular
variables across different statements, ensuring the test will pass
more consistently across different versions of GCC.

	PR testsuite/118597

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-fncall-mask.c: Update test directives.
2025-04-04 10:45:52 +01:00
GCC Administrator 370f05455e Daily bump. 2025-04-04 00:21:55 +00:00
Tomasz Kamiński 83cd4bda12 libstdc++: Restored accidentally removed test case.
It was removed by accident r14-11523-gad1b71fc2882c1.

libstdc++-v3/ChangeLog:

	* testsuite/std/format/functions/format.cc: Restored line.

(cherry picked from commit 81c990aa84)
2025-04-03 15:03:54 +02:00
Tomasz Kamiński ad1b71fc28 libstdc++: Fix handling of field width for wide strings and characters [PR119593]
This patch corrects handling of UTF-32LE and UTF32-BE in
__unicode::__literal_encoding_is_unicode<_CharT>, so they are
recognized as unicode and functions produces correct result for wchar_t.

Use `__unicode::__field_width` to compute the estimated witdh
of the charcter for unicode wide encoding.

	PR libstdc++/119593

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h
	(__unicode::__literal_encoding_is_unicode<_CharT>):
	Corrected handing for UTF-16 and UTF-32 with "LE" or "BE" suffix.
	* include/std/format (__formatter_str::_S_character_width):
	Define.
	(__formatter_str::_S_character_width): Updated passed char
	length.
	* testsuite/std/format/functions/format.cc: Test for wchar_t.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-03 14:31:43 +02:00
Andre Vehreschild f955c5b409 Fortran: Fix freeing procedure pointer components [PR119380]
Backported from gcc-15.

	PR fortran/119380

gcc/fortran/ChangeLog:

	* trans-array.cc (structure_alloc_comps): Prevent freeing of
	procedure pointer components.

gcc/testsuite/ChangeLog:

	* gfortran.dg/proc_ptr_comp_54.f90: New test.
2025-04-03 11:38:33 +02:00
GCC Administrator 1fb3a8dd95 Daily bump. 2025-04-03 00:23:36 +00:00
Richard Biener 534a7895e9 tree-optimization/119145 - avoid stray .MASK_CALL after vectorization
When we BB vectorize an if-converted loop body we make sure to not
leave around .MASK_LOAD or .MASK_STORE created by if-conversion but
we failed to check for .MASK_CALL.

	PR tree-optimization/119145
	* tree-vectorizer.cc (try_vectorize_loop_1): Avoid BB
	vectorizing an if-converted loop body when there's a .MASK_CALL
	in the loop body.

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

(cherry picked from commit 7950d4cceb)
2025-04-02 14:00:18 +02:00
Richard Biener 2f87983131 middle-end/119119 - re-gimplification of empty CTOR assignments
The following testcase runs into a re-gimplification issue during
inlining when processing

  MEM[(struct e *)this_2(D)].a = {};

where re-gimplification does not handle assignments in the same
way than the gimplifier but instead relies on rhs_predicate_for
and gimplifying the RHS standalone.  This fails to handle
special-casing of CTORs.  The is_gimple_mem_rhs_or_call predicate
already handles clobbers but not empty CTORs so we end up in
the fallback code trying to force the CTOR into a separate stmt
using a temporary - but as we have a non-copyable type here that ICEs.

The following generalizes empty CTORs in is_gimple_mem_rhs_or_call
since those need no additional re-gimplification.

	PR middle-end/119119
	* gimplify.cc (is_gimple_mem_rhs_or_call): All empty CTORs
	are OK when not a register type.

	* g++.dg/torture/pr11911.C: New testcase.

(cherry picked from commit 3bd61c1dfa)
2025-04-02 14:00:18 +02:00
Richard Biener d3e4c092c4 tree-optimization/119096 - bogus conditional reduction vectorization
When we vectorize a .COND_ADD reduction and apply the single-use-def
cycle optimization we can end up chosing the wrong else value for
subsequent .COND_ADD.  The following rectifies this.

	PR tree-optimization/119096
	* tree-vect-loop.cc (vect_transform_reduction): Use the
	correct else value for .COND_fn.

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

(cherry picked from commit 10e4107dfc)
2025-04-02 14:00:18 +02:00
Richard Biener 85ed633f26 ipa/119067 - bogus TYPE_PRECISION check on VECTOR_TYPE
odr_types_equivalent_p can end up using TYPE_PRECISION on vector
types which is a no-go.  The following instead uses TYPE_VECTOR_SUBPARTS
for vector types so we also end up comparing the number of vector elements.

	PR ipa/119067
	* ipa-devirt.cc (odr_types_equivalent_p): Check
	TYPE_VECTOR_SUBPARTS for vectors.

	* g++.dg/lto/pr119067_0.C: New testcase.
	* g++.dg/lto/pr119067_1.C: Likewise.

(cherry picked from commit f22e89167b)
2025-04-02 14:00:17 +02:00
Richard Biener faadd1d27a tree-optimization/119057 - bogus double reduction detection
We are detecting a cycle as double reduction where the inner loop
cycle has extra out-of-loop uses.  This clashes at least with
assumptions from the SLP discovery code which says the cycle
isn't reachable from another SLP instance.  It also was not intended
to support this case, in fact with GCC 14 we seem to generate wrong
code here.

	PR tree-optimization/119057
	* tree-vect-loop.cc (check_reduction_path): Add argument
	specifying whether we're analyzing the inner loop of a
	double reduction.  Do not allow extra uses outside of the
	double reduction cycle in this case.
	(vect_is_simple_reduction): Adjust.

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

(cherry picked from commit 758de6263d)
2025-04-02 14:00:17 +02:00
Richard Biener ed7f67d951 lto/114501 - missed free-lang-data for CONSTRUCTOR index
The following makes sure to also walk CONSTRUCTOR element indexes
which can be FIELD_DECLs, referencing otherwise unused types we
need to clean.  walk_tree only walks CONSTRUCTOR element data.

	PR lto/114501
	* ipa-free-lang-data.cc (find_decls_types_r): Explicitly
	handle CONSTRUCTORs as walk_tree handling of those is
	incomplete.

	* g++.dg/pr114501_0.C: New testcase.

(cherry picked from commit fdd95e1cf2)
2025-04-02 14:00:17 +02:00
Richard Biener d9faa7c2eb ipa/111245 - bogus modref analysis for store in call that might throw
We currently record a kill for

  *x_4(D) = always_throws ();

because we consider the store always executing since the appropriate
check for whether the stmt could throw is guarded by
!cfun->can_throw_non_call_exceptions.

	PR ipa/111245
	* ipa-modref.cc (modref_access_analysis::analyze_store): Do
	not guard the check of whether the stmt could throw by
	cfun->can_throw_non_call_exceptions.

	* g++.dg/torture/pr111245.C: New testcase.

(cherry picked from commit e6037af6d5)
2025-04-02 14:00:17 +02:00
Andrew Carlotti 35ed15af7d aarch64: Use PAUTH instead of V8_3A in some places
PR target/119383

gcc/ChangeLog:

	* config/aarch64/aarch64.cc
	(aarch64_expand_epilogue): Use TARGET_PAUTH.
	* config/aarch64/aarch64.md: Update comment.

(cherry picked from commit 20385cb92c)
2025-04-02 09:32:08 +00:00
Jonathan Wakely 88f0c1fe28 libstdc++: Fix std::ranges::iter_move for function references [PR119469]
The result of std::move (or a cast to an rvalue reference) on a function
reference is always an lvalue. Because std::ranges::iter_move was using
the type std::remove_reference_t<X>&& as the result of std::move, it was
giving the wrong type for function references. Use a decltype-specifier
with declval<remove_reference_t<X>>() instead of just using the
remove_reference_t<X>&& type directly. This gives the right result,
while still avoiding the cost of doing overload resolution for
std::move.

libstdc++-v3/ChangeLog:

	PR libstdc++/119469
	* include/bits/iterator_concepts.h (_IterMove::__result): Use
	decltype-specifier instead of an explicit type.
	* testsuite/24_iterators/customization_points/iter_move.cc:
	Check results for function references.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 3e52eb28c5)
2025-04-02 09:55:46 +01:00
Jonathan Wakely 58a2b7f055 libstdc++: Fix ranges::iter_move handling of rvalues [PR106612]
The specification for std::ranges::iter_move apparently requires us to
handle types which do not satisfy std::indirectly_readable, for example
with overloaded operator* which behaves differently for different value
categories.

libstdc++-v3/ChangeLog:

	PR libstdc++/106612
	* include/bits/iterator_concepts.h (_IterMove::__iter_ref_t):
	New alias template.
	(_IterMove::__result): Use __iter_ref_t instead of
	std::iter_reference_t.
	(_IterMove::__type): Remove incorrect __dereferenceable
	constraint.
	(_IterMove::operator()): Likewise. Add correct constraints. Use
	__iter_ref_t instead of std::iter_reference_t. Forward parameter
	as correct value category.
	(iter_swap): Add comments.
	* testsuite/24_iterators/customization_points/iter_move.cc: Test
	that iter_move is found by ADL and that rvalue arguments are
	handled correctly.

Reviewed-by: Patrick Palka <ppalka@redhat.com>

(cherry picked from commit a8ee522c59)
2025-04-02 09:55:46 +01:00
Jonathan Wakely 9d5baaa92c libstdc++: Fix -Warray-bounds warning in std::vector<bool> [PR110498]
In this case, we need to tell the compiler that the current size is not
larger than the new size so that all the existing elements can be copied
to the new storage. This avoids bogus warnings about overflowing the new
storage when the compiler can't tell that that cannot happen.

We might as well also hoist the loads of begin() and end() before the
allocation too. All callers will have loaded at least begin() before
calling _M_reallocate.

libstdc++-v3/ChangeLog:

	PR libstdc++/110498
	* include/bits/vector.tcc (vector<bool, A>::_M_reallocate):
	Hoist loads of begin() and end() before allocation and use them
	to state an unreachable condition.
	* testsuite/23_containers/vector/bool/capacity/110498.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit aa3aaf2bfb)
2025-04-02 09:55:46 +01:00
Jonathan Wakely f0c4ffcd86 libstdc++: Fix -Wstringop-overread warning in std::vector<bool> [PR114758]
As in r13-4393-gcca06f0d6d76b0 and a few other commits, we can avoid
bogus warnings in std::vector<bool> by hoisting some loads to before the
allocation that calls operator new. This means that the compiler has
enough info to remove the dead branches that trigger bogus warnings.

On trunk this is only needed with -fno-assume-sane-operators-new-delete
but it will help on the branches where that option doesn't exist.

libstdc++-v3/ChangeLog:

	PR libstdc++/114758
	* include/bits/vector.tcc (vector<bool, A>::_M_fill_insert):
	Hoist loads of begin() and end() before allocation.
	* testsuite/23_containers/vector/bool/capacity/114758.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 1f6c19f307)
2025-04-02 09:55:46 +01:00
Jonathan Wakely 4366711d2d libstdc++: Fix bogus -Wstringop-overflow in std::vector::insert [PR117983]
This was fixed on trunk by r15-4473-g3abe751ea86e34, but that isn't
suitable for backporting. Instead, just add another unreachable
condition in std::vector::_M_range_insert so the compiler knows this
memcpy doesn't use a length originating from a negative ptrdiff_t
converted to a very positive size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/117983
	* include/bits/vector.tcc (vector::_M_range_insert): Add
	unreachable condition to tell the compiler begin() <= end().
	* testsuite/23_containers/vector/modifiers/insert/117983.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 878812b6f6)
2025-04-02 09:55:45 +01:00
Jonathan Wakely 6b11aed73f libstdc++: Fix -Warray-bounds warning in std::vector::resize [PR114945]
This is yet another false positive warning fix. This time the compiler
can't prove that when the vector has sufficient excess capacity to
append new elements, the pointer to the existing storage is not null.

libstdc++-v3/ChangeLog:

	PR libstdc++/114945
	* include/bits/vector.tcc (vector::_M_default_append): Add
	unreachable condition so the compiler knows that _M_finish is
	not null.
	* testsuite/23_containers/vector/capacity/114945.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 844eed3364)
2025-04-02 09:55:45 +01:00
Richard Biener c839965c2e debug/101533 - ICE with variant typedef DIE generation
There's a sanity check in gen_type_die_with_usage that trips
unnecessarily for a case where the relevant DIE has already been
generated successfully in other ways.  The following keys the
existing TREE_ASM_WRITTEN check on the correct object, honoring
this and does nothing instead of ICEing for the testcase at hand.

	PR debug/101533
	* dwarf2out.cc (gen_type_die_with_usage): When we have
	output the typedef already do nothing for a typedef variant.
	Do not set TREE_ASM_WRITTEN on the type.

	* g++.dg/debug/pr101533.C: New testcase.

(cherry picked from commit 99a3f013c3)
2025-04-02 09:23:07 +02:00
Richard Biener a57c877f88 middle-end/101478 - ICE with degenerate address during gimplification
When we gimplify &MEM[0B + 4] we are re-folding the address in case
types are not canonical which ends up with a constant address that
recompute_tree_invariant_for_addr_expr ICEs on.  Properly guard
that call.

	PR middle-end/101478
	* gimplify.cc (gimplify_addr_expr): Check we still have an
	ADDR_EXPR before calling recompute_tree_invariant_for_addr_expr.

	* gcc.dg/pr101478.c: New testcase.

(cherry picked from commit 33ead6400a)
2025-04-02 09:23:07 +02:00
Richard Biener 9d516fb8ea tree-optimization/98845 - ICE with tail-merging and DCE/DSE disabled
The following shows that tail-merging will make dead SSA defs live
in paths where it wasn't before, possibly introducing UB or as
in this case, uses of abnormals that eventually fail coalescing
later.  The fix is to register such defs for stmt comparison.

	PR tree-optimization/98845
	* tree-ssa-tail-merge.cc (stmt_local_def): Consider a
	def with no uses not local.

	* gcc.dg/pr98845.c: New testcase.
	* gcc.dg/pr81192.c: Adjust.

(cherry picked from commit 6b8a8c9fd6)
2025-04-02 09:23:07 +02:00
Richard Biener e3290933ea lto/91299 - weak definition inlined with LTO
The following fixes a thinko in the handling of interposed weak
definitions which confused the interposition check in
get_availability by setting DECL_EXTERNAL too early.

	PR lto/91299
gcc/lto/
	* lto-symtab.cc (lto_symtab_merge_symbols): Set DECL_EXTERNAL
	only after calling get_availability.

gcc/testsuite/
	* gcc.dg/lto/pr91299_0.c: New testcase.
	* gcc.dg/lto/pr91299_1.c: Likewise.

(cherry picked from commit bc34db5b12)
2025-04-02 09:23:07 +02:00
Richard Biener 3b84ac6481 tree-optimization/87984 - hard register assignments not preserved
The following disables redundant store elimination to hard register
variables which isn't valid.

	PR tree-optimization/87984
	* tree-ssa-dom.cc (dom_opt_dom_walker::optimize_stmt): Do
	not perform redundant store elimination to hard register
	variables.
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt):
	Likewise.

	* gcc.target/i386/pr87984.c: New testcase.

(cherry picked from commit 535115caaf)
2025-04-02 09:23:07 +02:00
Richard Biener 931277d91f c++/79786 - bougs invocation of DATA_ABI_ALIGNMENT macro
The first argument is supposed to be a type, not a decl.

	PR c++/79786
gcc/cp/
	* rtti.cc (emit_tinfo_decl): Fix DATA_ABI_ALIGNMENT invocation.

(cherry picked from commit 6ec19825b4)
2025-04-02 09:23:07 +02:00
Richard Biener 12b536c17d middle-end/66279 - gimplification clobbers shared asm constraints
When the C++ frontend clones a CTOR we do not copy ASM_EXPR constraints
fully as walk_tree does not recurse to TREE_PURPOSE of TREE_LIST nodes.
At this point doing that seems too dangerous so the following instead
avoids gimplification of ASM_EXPRs to clobber the shared constraints
and unshares it there, like it also unshares TREE_VALUE when it
re-writes a "+" output constraint to separate "=" output and matching
input constraint.

	PR middle-end/66279
	* gimplify.cc (gimplify_asm_expr): Copy TREE_PURPOSE before
	rewriting it for "+" processing.

	* g++.dg/pr66279.C: New testcase.

(cherry picked from commit 95f5d6cc17)
2025-04-02 09:23:07 +02:00
GCC Administrator 8274de2e61 Daily bump. 2025-04-02 00:23:54 +00:00
Marek Polacek 42a4f86395 c++: fix missing lifetime extension [PR119383]
Since r15-8011 cp_build_indirect_ref_1 won't do the *&TARGET_EXPR ->
TARGET_EXPR folding not to change its value category.  That fix seems
correct but it made us stop extending the lifetime in this testcase,
causing a wrong-code issue -- extend_ref_init_temps_1 did not see
through the extra *& because it doesn't use a tree walk.

This patch reverts r15-8011 and instead handles the problem in
build_over_call by calling force_lvalue in the is_really_empty_class
case as well as in the general case.

	PR c++/119383

gcc/cp/ChangeLog:

	* call.cc (build_over_call): Use force_lvalue to ensure op= returns
	an lvalue.
	* cp-tree.h (force_lvalue): Declare.
	* cvt.cc (force_lvalue): New.
	* typeck.cc (cp_build_indirect_ref_1): Revert r15-8011.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/temp-extend3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit e9803f10c9)
2025-04-01 13:43:40 -04:00
Martin Jambor 28c10781fd Fix a pasto in ao_compare::compare_ao_refs
When reading the function ao_compare::compare_ao_refs I came accross
what I believe to ba a copy-and-paste error which this patch fixes.

gcc/ChangeLog:

2025-03-10  Martin Jambor  <mjambor@suse.cz>

	* tree-ssa-alias.cc (ao_compare::compare_ao_refs): Fix a
	copy-and-paste error.

(cherry picked from commit dc47161c1f)
2025-04-01 15:37:07 +02:00
Jonathan Wakely 30d7bca6c2 libstdc++: Avoid bogus -Walloc-size-larger-than warning in test [PR116212]
The compiler can't tell that the vector size fits in int, so it thinks
it might overflow to a negative value, which would then be a huge
positive size_t.  In reality, the vector size never exceeds five.

There's no warning on trunk, so just change the local variable to use
type unsigned so that we get rid of the warning on the branches.

libstdc++-v3/ChangeLog:

	PR libstdc++/116212
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Use unsigned for vector size.
2025-04-01 11:07:17 +01:00
Martin Jambor 5312a8f62a ipa: Do not modify cgraph edges from thunk clones during inlining (PR116572)
In PR 116572 we hit an assert that a thunk which does not have a body
looks like it has one.  It does not, but the call_stmt of its outgoing
edge points to a statement, which should not.  In fact it has several
outgoing call graph edges, which cannot be.  The problem is that the
code updating the edges to reflect inlining into the master clone (an
ex-thunk, unlike the clone, which is still an unexpanded thunk) is
being updated during inling into the master clone.  This patch simply
makes the code to skip unexpanded thunk clones.

gcc/ChangeLog:

2025-03-13  Martin Jambor  <mjambor@suse.cz>

	PR ipa/116572
	* cgraph.cc (cgraph_update_edges_for_call_stmt): Do not update
	edges of clones that are unexpanded thunk.  Assert that the node
	passed as the parameter is not an unexpanded thunk.

gcc/testsuite/ChangeLog:

2025-03-13  Martin Jambor  <mjambor@suse.cz>

	PR ipa/116572
	* g++.dg/ipa/pr116572.C: New test.

(cherry picked from commit 075ec33030)
2025-04-01 11:33:22 +02:00
Jonathan Wakely b37d9e5381 libstdc++: Add ranges::range_common_reference_t for C++20 (LWG 3860)
LWG 3860 added this alias template. Both libc++ and MSVC treat this as a
DR for C++20, so this change does so too.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (range_common_reference_t): New
	alias template, as per LWG 3860.
	* testsuite/std/ranges/range.cc: Check it.

(cherry picked from commit 92b554a841)
2025-04-01 09:58:23 +01:00
Jonathan Wakely f9ff3cd95c libstdc++: Check feature test macro for associative container node extraction
Replace some `__cplusplus > 201402L` preprocessor checks with more
expressive checks for the appropriate feature test macro.

libstdc++-v3/ChangeLog:

	* include/bits/stl_map.h: Check __glibcxx_node_extract instead
	of __cplusplus.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_tree.h: Likewise.

(cherry picked from commit 408f5b847b)
2025-04-01 09:58:23 +01:00
Jonathan Wakely 6f93995b8d libstdc++: Add static_assert to std::packaged_task::packaged_task(F&&)
LWG 4154 (approved in Wrocław, November 2024) fixed the Mandates:
precondition for std::packaged_task::packaged_task(F&&) to match what
the implementation actually requires. We already gave a diagnostic in
the right cases as required by the issue resolution, so strictly
speaking we don't need to do anything. But the current diagnostic comes
from inside the implementation of std::__invoke_r and could be more
user-friendly.

For C++17 (when std::is_invocable_r_v is available) add a static_assert
to the constructor, so the error is clear:

.../include/c++/15.0.1/future: In instantiation of 'std::packaged_task<_Res(_ArgTypes ...)>::packaged_task(_Fn&&) [with _Fn = const F&; <template-parameter-2-2> = void; _Res = void; _ArgTypes = {}]':
lwg4154_neg.cc:15:31:   required from here
   15 | std::packaged_task<void()> p(f); // { dg-error "here" "" { target c++17 } }
      |                               ^
.../include/c++/15.0.1/future:1575:25: error: static assertion failed
 1575 |           static_assert(is_invocable_r_v<_Res, decay_t<_Fn>&, _ArgTypes...>);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also add a test to confirm we get a diagnostic as the standard requires.

libstdc++-v3/ChangeLog:

	* include/std/future (packaged_task::packaged_task(F&&)): Add
	static_assert.
	* testsuite/30_threads/packaged_task/cons/dangling_ref.cc: Add
	dg-error for new static assertion.
	* testsuite/30_threads/packaged_task/cons/lwg4154_neg.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 4d2683b04f)
2025-04-01 09:58:23 +01:00
Jonathan Wakely 5eb93522a6 libstdc++: Add testcase for std::filesystem::copy [PR118699]
This was fixed last year by r15-2409-g017e3f89b081e4 (and backports), so
just add the testcase.

libstdc++-v3/ChangeLog:

	PR libstdc++/118699
	* testsuite/27_io/filesystem/operations/copy.cc: Check copying a
	file to a directory.

(cherry picked from commit 466da4baba)
2025-04-01 09:58:22 +01:00
GCC Administrator c32e22f8a8 Daily bump. 2025-04-01 00:24:06 +00:00
Iain Buclaw a6a2da499a d: Fix error with -Warray-bounds and -O2 [PR117002]
The record layout of class types in D don't get any tail padding, so it
is possible for the `classInstanceSize' to not be a multiple of the
`classInstanceAlignment'.

Rather than setting the instance alignment on the underlying
RECORD_TYPE, instead give the type an alignment of 1, which will mark it
as TYPE_PACKED.  The value of `classInstanceAlignment' is instead
applied to the DECL_ALIGN of both the static `init' symbol, and the
stack allocated variable used when generating `new' for a `scope' class.

	PR d/117002

gcc/d/ChangeLog:

	* decl.cc (aggregate_initializer_decl): Set explicit decl alignment of
	class instance.
	* expr.cc (ExprVisitor::visit (NewExp *)): Likewise.
	* types.cc (TypeVisitor::visit (TypeClass *)): Mark the record type of
	classes as packed.

gcc/testsuite/ChangeLog:

	* gdc.dg/torture/pr117002.d: New test.

(cherry picked from commit 9fadadbbbc)
2025-03-31 19:19:24 +02:00
Jonathan Wakely da6cea6625 libstdc++: Add testcases for resolved bug [PR101527]
These tests were fixed by a front-end change r13-465-g4df735e01e3199 so
this just adds them to the testsuite to be sure we don't regress.

libstdc++-v3/ChangeLog:

	PR libstdc++/101527
	* testsuite/24_iterators/common_iterator/101527.cc: New test.
	* testsuite/24_iterators/counted_iterator/101527.cc: New test.

(cherry picked from commit f7c0b0fc4f)
2025-03-31 12:37:52 +01:00
Jonathan Wakely 0b49d8bc67 libstdc++: Remove stray comma in testing docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/test.xml: Remove stray comma.
	* doc/html/manual/test.html: Regenerate.

(cherry picked from commit ac16d6d74f)
2025-03-31 12:37:52 +01:00
Jonathan Wakely d22bd12554 libstdc++: Make std::erase for linked lists convert to bool
LWG 4135 (approved in Wrocław, November 2024) fixes the lambda
expressions used by std::erase for std::list and std::forward_list.
Previously they attempted to copy something that isn't required to be
copyable. Instead they should convert it to bool right away.

The issue resolution also changes the lambda's parameter to be const, so
that it can't modify the elements while comparing them.

libstdc++-v3/ChangeLog:

	* include/std/forward_list (erase): Change lambda to have
	explicit return type and const parameter type.
	* include/std/list (erase): Likewise.
	* testsuite/23_containers/forward_list/erasure.cc: Check lambda
	is correct.
	* testsuite/23_containers/list/erasure.cc: Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit e6e7b477bb)
2025-03-31 12:37:52 +01:00
Jonathan Wakely cf01493b1f libstdc++: Fix some broken links in the manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/policy_data_structures_biblio.xml: Fix two
	broken links.
	* doc/html/manual/policy_data_structures.html: Regenerate.

(cherry picked from commit 1e4d81aab2)
2025-03-31 12:37:52 +01:00
Jonathan Wakely d276541a82 doc: Fix minor grammar nit in -ftrivial-auto-var-init docs
gcc/ChangeLog:

	* doc/extend.texi (Common Variable Attributes): Fix grammar in
	final sentence of -ftrivial-auto-var-init description.

(cherry picked from commit f695d0392f)
2025-03-31 12:37:52 +01:00
Jonathan Wakely 5a830c6cd5 libstdc++: Optimize std::vector construction from input iterators [PR108487]
LWG 3291 make std::ranges::iota_view's iterator have input_iterator_tag
as its iterator_category, even though it satisfies the C++20
std::forward_iterator concept. This means that the traditional
std::vector::vector(InputIterator, InputIterator) constructor treats
iota_view iterators as input iterators, because it only understands the
C++17 iterator requirements, not the C++20 iterator concepts. This
results in a loop that calls emplace_back for each individual element of
the iota_view, requiring the vector to reallocate repeatedly as the
values are inserted. This makes it unnecessarily slow to construct a
vector from an iota_view.

This change adds a new _M_range_initialize_n function for initializing a
vector from a range (which doesn't have to be common) and a size. This
new function can be used by vector(InputIterator, InputIterator) when
std::ranges::distance can be used to get the size. It can also be used
by the _M_range_initialize overload that gets the size for a
Cpp17ForwardIterator pair using std::distance, and by the
vector(initializer_list) constructor.

With this new function constructing a std::vector from iota_view does
a single allocation of the correct size and so doesn't need to
reallocate in a loop.

libstdc++-v3/ChangeLog:

	PR libstdc++/108487
	* include/bits/stl_vector.h (vector(initializer_list)): Call
	_M_range_initialize_n instead of _M_range_initialize.
	(vector(InputIterator, InputIterator)): Use _M_range_initialize_n
	for C++20 sized sentinels and forward iterators.
	(vector::_M_range_initialize(FwIt, FwIt, forward_iterator_tag)):
	Use _M_range_initialize_n.
	(vector::_M_range_initialize_n): New function.
	* testsuite/23_containers/vector/cons/108487.cc: New test.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/initlist-opt1.C: Match _M_range_initialize_n
	instead of _M_range_initialize.
	* g++.dg/tree-ssa/initlist-opt2.C: Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit e200f53a55)
2025-03-31 11:23:39 +01:00
Jonathan Wakely a93c02154f libstdc++: Update tzdata to 2025b
Import the new 2025b tzdata.zi file.

libstdc++-v3/ChangeLog:

	* src/c++20/tzdata.zi: Import new file from 2025b release.

(cherry picked from commit fd3bb31405)
2025-03-31 11:23:38 +01:00
Jonathan Wakely ea45b49d3a libstdc++: Update tzdata to 2025a
Import the new 2025a tzdata.zi file. The leapseconds file was also
updated to have a new expiry (no new leap seconds were added).

libstdc++-v3/ChangeLog:

	* include/std/chrono (__detail::__get_leap_second_info): Update
	expiry date for leap seconds list.
	* src/c++20/tzdata.zi: Import new file from 2025a release.
	* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds)
	Update expiry date for leap seconds list.

(cherry picked from commit 0ce4c1c485)
2025-03-31 11:23:38 +01:00
Lulu Cheng 3d9c933c4c LoongArch: doc: Add same-address constraint to the description of '-mld-seq-sa'.
gcc/ChangeLog:

	* doc/invoke.texi: Modify the description of '-mld-seq-sa'.

(cherry picked from commit 8ad8f74972)
2025-03-31 10:06:30 +08:00
GCC Administrator 1feaea8547 Daily bump. 2025-03-31 00:23:05 +00:00
Martin Uecker 73549be0a3 Fix type compatibility for types with flexible array member 2/2 [PR113688,PR114713,PR117724]
For checking or computing TYPE_CANONICAL, ignore the array size when it is
the last element of a structure or union.  To not get errors because of
an inconsistent number of members, zero-sized arrays which are the last
element are not ignored anymore when checking the fields of a struct.

	PR c/113688
	PR c/114014
	PR c/114713
	PR c/117724

gcc/ChangeLog:
	* tree.cc (gimple_canonical_types_compatible_p): Add exception.

gcc/lto/ChangeLog:
	* lto-common.cc (hash_canonical_type): Add exception.

gcc/testsuite/ChangeLog:
	* gcc.dg/pr113688.c: New test.
	* gcc.dg/pr114014.c: New test.
	* gcc.dg/pr114713.c: New test.
	* gcc.dg/pr117724.c: New test.

(cherry picked from commit d46c7f313b)
2025-03-30 11:56:06 +02:00
Martin Uecker 450dc448ea Fix type compatibility for types with flexible array member 1/2 [PR113688,PR114713,PR117724]
Allow the TYPE_MODE of a type with an array as last member to differ from
another compatible type.

gcc/ChangeLog:
	* tree.cc (gimple_canonical_types_compatible_p): Add exception.
	(verify_type): Add exception.

gcc/lto/ChangeLog:
	* lto-common.cc (hash_canonical_type): Add exception.

(cherry picked from commit 1f48225a0d)
2025-03-30 11:56:06 +02:00
GCC Administrator 056f2b11fd Daily bump. 2025-03-30 00:22:20 +00:00
Denis Chertykov d54c8ebda8 Reuse scratch registers generated by LRA
Test file: udivmoddi.c
problem insn: 484

Before LRA pass we have:
(insn 484 483 485 72 (parallel [
            (set (reg/v:SI 143 [ __q1 ])
                (plus:SI (reg/v:SI 143 [ __q1 ])
                    (const_int -2 [0xfffffffffffffffe])))
            (clobber (scratch:QI))
        ]) "udivmoddi.c":163:405 discrim 5 186 {addsi3}
     (nil))

LRA substitute all scratches with new pseudos, so we have:
(insn 484 483 485 72 (parallel [
            (set (reg/v:SI 143 [ __q1 ])
                (plus:SI (reg/v:SI 143 [ __q1 ])
                    (const_int -2 [0xfffffffffffffffe])))
            (clobber (reg:QI 619))
        ]) "/mnt/d/avr-lra/udivmoddi.c":163:405 discrim 5 186 {addsi3}
     (expr_list:REG_UNUSED (reg:QI 619)
        (nil)))

Pseudo 619 is a special scratch register generated by LRA which is marked in `scratch_bitmap' and can be tested by call `ira_former_scratch_p(regno)'.

In dump file (udivmoddi.c.317r.reload) we have:
      Creating newreg=619
Removing SCRATCH to p619 in insn #484 (nop 3)
rescanning insn with uid = 484.

After that LRA tries to spill (reg:QI 619)
It's a bug because (reg:QI 619) is an output scratch register which is already something like spill register.

Fragment from udivmoddi.c.317r.reload:
      Choosing alt 2 in insn 484:  (0) r  (1) 0  (2) nYnn  (3) &d {addsi3}
      Creating newreg=728 from oldreg=619, assigning class LD_REGS to r728

IMHO: the bug is in lra-constraints.cc in function `get_reload_reg'
fragment of `get_reload_reg':
  if (type == OP_OUT)
    {
      /* Output reload registers tend to start out with a conservative
	 choice of register class.  Usually this is ALL_REGS, although
	 a target might narrow it (for performance reasons) through
	 targetm.preferred_reload_class.  It's therefore quite common
	 for a reload instruction to require a more restrictive class
	 than the class that was originally assigned to the reload register.

	 In these situations, it's more efficient to refine the choice
	 of register class rather than create a second reload register.
	 This also helps to avoid cycling for registers that are only
	 used by reload instructions.  */
      if (REG_P (original)
	  && (int) REGNO (original) >= new_regno_start
	  && INSN_UID (curr_insn) >= new_insn_uid_start
__________________________________^^
	  && in_class_p (original, rclass, &new_class, true))
	{
	  unsigned int regno = REGNO (original);
	  if (lra_dump_file != NULL)
	    {
	      fprintf (lra_dump_file, "	 Reuse r%d for output ", regno);
	      dump_value_slim (lra_dump_file, original, 1);
	    }

This condition incorrectly limits register reuse to ONLY newly generated instructions.
i.e. LRA can reuse registers only from insns generated by himself.

IMHO:It's wrong.
Scratch registers generated by LRA also have to be reused.

The patch is very simple.
On x86_64, it bootstraps+regtests fine.

gcc/
	PR target/116550
	PR target/119340
	* lra-constraints.cc (get_reload_reg): Reuse scratch registers
	generated by LRA.

(cherry picked from commit e7393cbb5f)
2025-03-29 15:49:37 +08:00
GCC Administrator 267e8a0da4 Daily bump. 2025-03-29 00:24:23 +00:00
GCC Administrator 91ef303f5a Daily bump. 2025-03-28 00:23:52 +00:00
Jakub Jelinek 6c7c25c282 widening_mul: Fix up further r14-8680 widening mul issues [PR119417]
The following testcase is miscompiled since r14-8680 PR113560 changes.
I've already tried to fix some of the issues caused by that change in
r14-8823 PR113759, but apparently didn't get it right.

The problem is that the r14-8680 changes sometimes set *type_out to
a narrower type than the *new_rhs_out actually has (because it will
handle stuff like _1 = rhs1 & 0xffff; and imply from that HImode type_out.

Now, if in convert_mult_to_widen or convert_plusminus_to_widen we actually
get optab for the modes we've asked for (i.e. with from_mode and to_mode),
everything works fine, if the operands don't have the expected types,
they are converted to those (for INTEGER_CSTs with fold_convert,
otherwise with build_and_insert_cast).
On the following testcase on aarch64 that is not the case, we ask
for from_mode HImode and to_mode DImode, but get actual_mode SImode.
The mult_rhs1 operand already has SImode and we change type1 to unsigned int
and so no cast is actually done, except that the & 0xffff is lost that way.

The following patch ensures that if we change typeN because of wider
actual_mode (or because of a sign change), we first cast to the old
typeN (if the r14-8680 code was encountered, otherwise it would have the
same precision) and only then change it, and then perhaps cast again.

On the testcase on aarch64-linux the patch results in the expected
-       add     x19, x19, w0, uxtw 1
+       add     x19, x19, w0, uxth 1
difference.

2025-03-26  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/119417
	* tree-ssa-math-opts.cc (convert_mult_to_widen): Before changing
	typeN because actual_precision/from_unsignedN differs cast rhsN
	to typeN if it has a different type.
	(convert_plusminus_to_widen): Before changing
	typeN because actual_precision/from_unsignedN differs cast mult_rhsN
	to typeN if it has a different type.

	* gcc.dg/torture/pr119417.c: New test.

(cherry picked from commit 02132faf4e)
2025-03-28 00:40:16 +01:00
Jakub Jelinek 4b36453105 i386: Require in peephole2 that memory is offsettable [PR119450]
The following testcase ICEs because a peephole2 attempts to offset
memory which is not offsettable (in particular address is a ZERO_EXTEND
in this case).

Because peephole2s don't support constraints, I've added a check for this
in the peephole2's condition.

2025-03-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/119450
	* config/i386/i386.md (narrow test peephole2): Test for
	offsettable_memref_p in condition.

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

(cherry picked from commit 84f0b648ae)
2025-03-28 00:40:16 +01:00
Jakub Jelinek f9dab50e6e Fix up some further cases of missing or extraneous spaces in diagnostics
Given the recent PR119406 I've tried to grep for concatenated string
literals without space at the end of one line and at the start of next line,
unless it was obviously intentional.
Furthermore, I've then looked through gcc.pot looking for 2 adjacent spaces
and looking back if that wasn't the case of "something "
" with spaces at both sides".

Here is the result from that.

I think just the c.opt change needs an explanation, the "" in the
description is simply eaten up somewhere during the option processing and
gcc -v --help before this patch was displaying
  -Wdeprecated-literal-operator Warn about deprecated space between  and suffix in a user-defined literal operator.

2025-03-22  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* gimplify.cc (warn_switch_unreachable_and_auto_init_r): Add missing
	space in the middle of diagnostics.
	* tree-vect-stmts.cc (vectorizable_load): Add missing space in the
	middle of debug dump message.
gcc/fortran/
	* resolve.cc (resolve_procedure_expression): Remove extraneous space
	from the middle of diagnostics.

(cherry picked from commit 20360e4b6b)
2025-03-28 00:40:16 +01:00
Jakub Jelinek 13fd7c971f c++: Evaluate immediate invocation call arguments with mce_true [PR119150]
Since Marek's r14-4140 which moved immediate invocation evaluation
from build_over_call to cp_fold_r, the following testcase is miscompiled.

The a = foo (bar ()); case is actually handled right, that is handled
in cp_fold_r and the whole CALL_EXPR is at that point evaluated by
cp_fold_immediate_r with cxx_constant_value (stmt, tf_none);
and that uses mce_true for evaluation of the argument as well as the actual
call.

But in the bool b = foo (bar ()); case we actually try to evaluate this
as non-manifestly constant-evaluated.  And while
          /* Make sure we fold std::is_constant_evaluated to true in an
             immediate function.  */
          if (DECL_IMMEDIATE_FUNCTION_P (fun))
            call_ctx.manifestly_const_eval = mce_true;
ensures that if consteval and __builtin_is_constant_evaluated () is true
inside of that call, this happens after arguments to the function
have been already constant evaluated in cxx_bind_parameters_in_call.
The call_ctx in that case also includes new call_ctx.call, something that
shouldn't be used for the arguments, so the following patch just arranges
to call cxx_bind_parameters_in_call with manifestly_constant_evaluated =
mce_true.

2025-03-13  Jakub Jelinek  <jakub@redhat.com>

	PR c++/119150
	* constexpr.cc (cxx_eval_call_expression): For
	DECL_IMMEDIATE_FUNCTION_P (fun) set manifestly_const_eval in new_ctx
	and new_call to mce_true and set ctx to &new_ctx.

	* g++.dg/cpp2a/consteval41.C: New test.

(cherry picked from commit ebf6e6241f)
2025-03-28 00:40:15 +01:00
Jakub Jelinek 4164c25429 builtins: Fix up strspn/strcspn folding [PR119219]
The PR119204 r15-7955 fix caused some regressions.
The problem is that the fold_builtin* APIs document that expr is
either a CALL_EXPR of the call or NULL, so using TREE_TYPE (expr)
can crash e.g. during constexpr evaluation etc.

As can be seen in the surrounding patch, for the neighbouring builtins
(both modf and strpbrk) fold_builtin_2 passes down type, which is the
result type, TREE_TYPE (TREE_TYPE (fndecl)) and those builtins use it
to build the return value, while strspn was always building size_type_node
and strcspn had this change from that to TREE_TYPE (expr).
The patch passes type to these two and uses it there as well.

The patch keeps passing expr because it is used in the
check_nul_terminated_array calls done for both strspn and strcspn,
those calls clearly can deal with NULL expr but prefer if it is non-NULL
for some warning.

2025-03-12  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/119204
	PR middle-end/119219
	* builtins.cc (fold_builtin_2): Pass type as another argument
	to fold_builtin_strspn and fold_builtin_strcspn.
	(fold_builtin_strspn): Add type argument, use it instead of
	size_type_node.
	(fold_builtin_strcspn): Add type argument, use it instead of
	TREE_TYPE (expr).

(cherry picked from commit da967f0ff3)
2025-03-28 00:40:15 +01:00
Richard Biener 01f20dec2d middle-end/119204 - ICE with strcspn folding
The following makes sure to convert the folded expression to the
original expression type.

	PR middle-end/119204
	* builtins.cc (fold_builtin_strcspn): Preserve the original
	expression type.

	* gcc.dg/pr119204.c: New testcase.

(cherry picked from commit 68932eeb38)
2025-03-28 00:40:15 +01:00
Jakub Jelinek c6b38a75fc tree: Improve skip_simple_arithmetic [PR119183]
The following testcase takes very long time to compile, because
skip_simple_arithmetic decides to first call tree_invariant_p on
the second argument (and indirectly recurse there).  I think before
canonicalization of operands for commutative binary expressions
(and for non-commutative ones always) it is pretty common that the
first operand is a constant, something which tree_invariant_p handles
immediately, so the following patch special cases that; I've added
there a tree_invariant_p call too after the checks, while it is not
really needed currently, tree_invariant_p has the same checks, I wanted
to be prepared in case tree_invariant_p changes.  But if you think
I should avoid it, I can drop it too.

This is just a partial fix, I think one can certainly construct a testcase
which will still have horrible compile time complexity (but I've tried and
haven't managed to do so), so perhaps we should just limit the recursion
depth through skip_simple_arithmetic/tree_invariant_p with some defaulted
argument.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	PR c/119183
	* tree.cc (skip_simple_arithmetic): If first operand of binary
	expr is TREE_CONSTANT or TREE_READONLY with no side-effects, call
	tree_invariant_p on that operand first instead of on the second.

	* gcc.dg/pr119183.c: New test.

(cherry picked from commit 20e5aa9cc1)
2025-03-28 00:40:14 +01:00
Jakub Jelinek 7fc02fc015 libgcc: Fix up unwind-dw2-btree.h [PR119151]
The following testcase shows a bug in unwind-dw2-btree.h.
In short, the header provides lock-free btree data structure (so no parent
link on nodes, both insertion and deletion are done in top-down walks
with some locking of just a few nodes at a time so that lookups can notice
concurrent modifications and retry, non-leaf (inner) nodes contain keys
which are initially the base address of the left-most leaf entry of the
following child (or all ones if there is none) minus one, insertion ensures
balancing of the tree to ensure [d/2, d] entries filled through aggressive
splitting if it sees a full tree while walking, deletion performs various
operations like merging neighbour trees, merging into parent or moving some
nodes from neighbour to the current one).
What differs from the textbook implementations is mostly that the leaf nodes
don't include just address as a key, but address range, address + size
(where we don't insert any ranges with zero size) and the lookups can be
performed for any address in the [address, address + size) range.  The keys
on inner nodes are still just address-1, so the child covers all nodes
where addr <= key unless it is covered already in children to the left.
The user (static executables or JIT) should always ensure there is no
overlap in between any of the ranges.

In the testcase a bunch of insertions are done, always followed by one
removal, followed by one insertion of a range slightly different from the
removed one.  E.g. in the first case [&code[0x50], &code[0x59]] range
is removed and then we insert [&code[0x4c], &code[0x53]] range instead.
This is valid, it doesn't overlap anything.  But the problem is that some
non-leaf (inner) one used the &code[0x4f] key (after the 11 insertions
completely correctly).  On removal, nothing adjusts the keys on the parent
nodes (it really can't in the top-down only walk, the keys could be many nodes
above it and unlike insertion, removal only knows the start address, doesn't
know the removed size and so will discover it only when reaching the leaf
node which contains it; plus even if it knew the address and size, it still
doesn't know what the second left-most leaf node will be (i.e. the one after
removal)).  And on insertion, if nodes aren't split at a level, nothing
adjusts the inner keys either.  If a range is inserted and is either fully
bellow key (keys are - 1, so having address + size - 1 being equal to key is
fine) or fully after key (i.e. address > key), it works just fine, but if
the key is in a middle of the range like in this case, &code[0x4f] is in the
middle of the [&code[0x4c], &code[0x53]] range, then insertion works fine
(we only use size on the leaf nodes), and lookup of the addresses below
the key work fine too (i.e. [&code[0x4c], &code[0x4f]] will succeed).
The problem is with lookups after the key (i.e. [&code[0x50, &code[0x53]]),
the lookup looks for them in different children of the btree and doesn't
find an entry and returns NULL.

As users need to ensure non-overlapping entries at any time, the following
patch fixes it by adjusting keys during insertion where we know not just
the address but also size; if we find during the top-down walk a key
which is in the middle of the range being inserted, we simply increase the
key to be equal to address + size - 1 of the range being inserted.
There can't be any existing leaf nodes overlapping the range in correct
programs and the btree rebalancing done on deletion ensures we don't have
any empty nodes which would also cause problems.

The patch adjusts the keys in two spots, once for the current node being
walked (the last hunk in the header, with large comment trying to explain
it) and once during inner node splitting in a parent node if we'd otherwise
try to add that key in the middle of the range being inserted into the
parent node (in that case it would be missed in the last hunk).
The testcase covers both of those spots, so succeeds with GCC 12 (which
didn't have btrees) and fails with vanilla GCC trunk and also fails if
either the
  if (fence < base + size - 1)
    fence = iter->content.children[slot].separator = base + size - 1;
or
  if (left_fence >= target && left_fence < target + size - 1)
    left_fence = target + size - 1;
hunk is removed (of course, only with the current node sizes, i.e. up to
15 children of inner nodes and up to 10 entries in leaf nodes).

2025-03-10  Jakub Jelinek  <jakub@redhat.com>
	    Michael Leuchtenburg  <michael@slashhome.org>

	PR libgcc/119151
	* unwind-dw2-btree.h (btree_split_inner): Add size argument.  If
	left_fence is in the middle of [target,target + size - 1] range,
	increase it to target + size - 1.
	(btree_insert): Adjust btree_split_inner caller.  If fence is smaller
	than base + size - 1, increase it and separator of the slot to
	base + size - 1.

	* gcc.dg/pr119151.c: New test.

(cherry picked from commit 21109b37e8)
2025-03-28 00:40:14 +01:00
Jakub Jelinek 5bb53795e8 c++: Update TYPE_FIELDS of variant types if cp_parser_late_parsing_default_args etc. modify it [PR98533]
The following testcases ICE during type verification, because TYPE_FIELDS
of e.g. S RECORD_TYPE in pr119123.C is different from TYPE_FIELDS of const S.
Various decls are added to S's TYPE_FIELDS first, then finish_struct
indirectly calls fixup_type_variants to sync the variant copies.
But later on cp_parser_class_specifier calls
cp_parser_late_parsing_default_args and that apparently adds a lambda
type (from default argument) to TYPE_FIELDS of S.
Dunno if that is right or not, assuming it is right, the following
patch fixes it by updating TYPE_FIELDS of variant types if there were
any changes in the various functions cp_parser_class_specifier defers and
calls on the outermost enclosing class.
There was quite a lot of code repetition already before, so the patch
uses a lambda to avoid the repetitions.
To my surprise, in some of the contract testcases (
g++.dg/contracts/contracts-friend1.C
g++.dg/contracts/contracts-nested-class1.C
g++.dg/contracts/contracts-nested-class2.C
g++.dg/contracts/contracts-redecl7.C
g++.dg/contracts/contracts-redecl8.C
) it is actually setting class_type and pushing TRANSLATION_UNIT_DECL
rather than some class types in some cases.

Or should the lambda pushing into the containing class be somehow avoided?

2025-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98533
	PR c++/119123
	* parser.cc (cp_parser_class_specifier): Update TYPE_FIELDS of
	variant types in case cp_parser_late_parsing_default_args etc. change
	TYPE_FIELDS on the main variant.  Add switch_to_class lambda and
	use it to simplify repeated class switching code.

	* g++.dg/cpp0x/pr98533.C: New test.
	* g++.dg/cpp0x/pr119123.C: New test.

(cherry picked from commit 179e01085b)
2025-03-28 00:40:14 +01:00
Jakub Jelinek 375cc5fb91 value-range: Fix up irange::union_bitmask [PR118953]
The following testcase is miscompiled during evrp.
Before vrp, we have (from ccp):
  # RANGE [irange] long long unsigned int [0, +INF] MASK 0xffffffffffffc000 VALUE 0x2d
  _3 = _2 + 18446744073708503085;
...
  # RANGE [irange] long long unsigned int [0, +INF] MASK 0xffffffffffffc000 VALUE 0x59
  _6 = (long long unsigned int) _5;
  # RANGE [irange] int [-INF, +INF] MASK 0xffffc000 VALUE 0x34
  _7 = k_11 + -1048524;
  switch (_7) <default: <L5> [33.33%], case 8: <L7> [33.33%], case 24: <L6> [33.33%], case 32: <L6> [33.33%]>
...
  # RANGE [irange] long long unsigned int [0, +INF] MASK 0xffffffffffffc07d VALUE 0x0
  # i_20 = PHI <_3(4), 0(3), _6(2)>
and evrp is now trying to figure out range for i_20 in range_of_phi.

All the ranges and MASK/VALUE pairs above are correct for the testcase,
k_11 and _2 based on it is a result of multiplication by a constant with low
14 bits cleared and then some numbers are added to it.

There is an obvious missed optimization for which I've filed PR119039,
simplify_switch_using_ranges could see that all the labels but default
are unreachable because the controlling expression has
MASK 0xffffc000 VALUE 0x34 and none of 8, 24 and 32 satisfy that.

Anyway, during range_of_phi for i_20, we process the PHI arguments
in order.  For the _3(4) case, we figure out that it is reachable
through the case 24: case 32: labels only of the switch and that
0x34 - 0x2d is 7, so derive
[irange] long long unsigned int [17, 17][25, 25] MASK 0xffffffffffffc000 VALUE 0x2d
(the MASK/VALUE just got inherited from the _3 earlier range).
Now (not suprisingly because those labels aren't actually reachable),
that range is inconsistent, 0x2d is 45, so there is conflict between the
values and the irange_bitmask.
value-range.{h,cc} code differentiates between actually stored
irange_bitmask, which is that MASK 0xffffffffffffc000 VALUE 0x2d, and
semantic bitmask, which is what get_bitmask returns.  That is
  // The mask inherent in the range is calculated on-demand.  For
  // example, [0,255] does not have known bits set by default.  This
  // saves us considerable time, because setting it at creation incurs
  // a large penalty for irange::set.  At the time of writing there
  // was a 5% slowdown in VRP if we kept the mask precisely up to date
  // at all times.  Instead, we default to -1 and set it when
  // explicitly requested.  However, this function will always return
  // the correct mask.
  //
  // This also means that the mask may have a finer granularity than
  // the range and thus contradict it.  Think of the mask as an
  // enhancement to the range.  For example:
  //
  // [3, 1000] MASK 0xfffffffe VALUE 0x0
  //
  // 3 is in the range endpoints, but is excluded per the known 0 bits
  // in the mask.
  //
  // See also the note in irange_bitmask::intersect.
  irange_bitmask bm
    = get_bitmask_from_range (type (), lower_bound (), upper_bound ());
  if (!m_bitmask.unknown_p ())
    bm.intersect (m_bitmask);
Now, get_bitmask_from_range here is MASK 0x1f VALUE 0x0 and it intersects
that with that MASK 0xffffffffffffc000 VALUE 0x2d.
Which triggers the ugly special case in irange_bitmask::intersect:
  // If we have two known bits that are incompatible, the resulting
  // bit is undefined.  It is unclear whether we should set the entire
  // range to UNDEFINED, or just a subset of it.  For now, set the
  // entire bitmask to unknown (VARYING).
  if (wi::bit_and (~(m_mask | src.m_mask),
                   m_value ^ src.m_value) != 0)
    {
      unsigned prec = m_mask.get_precision ();
      m_mask = wi::minus_one (prec);
      m_value = wi::zero (prec);
    }
so the semantic bitmask is actually MASK 0xffffffffffffffff VALUE 0x0.

Next, range_of_phi attempts to union it with the 0(3) PHI argument,
and during irange::union_ first adds the [0,0] to the subranges, so
[irange] long long unsigned int [0, 0][17, 17][25, 25] MASK 0xffffffffffffc000 VALUE 0x2d
and then goes on to irange::union_bitmask which does
  if (m_bitmask == r.m_bitmask)
    return false;
  irange_bitmask bm = get_bitmask ();
  irange_bitmask save = bm;
  bm.union_ (r.get_bitmask ());
  if (save == bm)
    return false;
  m_bitmask = bm;
  if (save == get_bitmask ())
    return false;
m_bitmask MASK 0xffffffffffffc000 VALUE 0x2d isn't the same as
r.m_bitmask MASK 0x0 VALUE 0x0, so we compute the semantic bitmask
(but note, not from the original range before union, but the modified one,
dunno if that isn't a problem as well), which is still the VARYING/unknown_p
one, union_ that with MASK 0x0 VALUE 0x0 and get still
MASK 0xffffffffffffffff VALUE 0x0, so don't update anything, the semantic
bitmask didn't change, so we are fine (not!, see later).

Except then we try to union with the third PHI argument.  And, because the
edge to that comes only from case 8: label and there is a known difference
between the two, the argument is actually already from earlier replaced by
45(2) constant.  So, irange::union_ adds the [45, 45] range to the list
of subranges, but voila, 45 is 0x2d and satisfies the stored
MASK 0xffffffffffffc000 VALUE 0x2d and so the semantic bitmask changed to
from MASK 0xffffffffffffffff VALUE 0x0 to MASK 0xffffffffffffc000 VALUE 0x2d
by that addition.  Eventually, we just optimize this to
[irange] long long unsigned int [45, 45] because that is the only range
which satisfies the bitmask.  And that is wrong, at runtime i_20 has
value 0.

The following patch attempts to detect this case where get_bitmask
turns some non-VARYING m_bitmask into VARYING one because of a conflict
and in that case makes sure m_bitmask is actually updated rather than
unmodified, so that later union_ doesn't cause problems.

I also wonder whether e.g. get_bitmask couldn't have special case for this
and if bm.intersect (m_bitmask); yields unknown_p from something not
originally unknown_p, perhaps chooses to just use get_bitmask_from_range
value and ignore the stored m_bitmask.  Though, dunno how union_bitmask
in that case would figure out it needs to update m_bitmask.

2025-03-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/118953
	* value-range.cc (irange::union_bitmask): Update m_bitmask if
	get_bitmask () is unknown_p and m_bitmask is not even when the
	semantic bitmask didn't change and returning false.

	* gcc.dg/torture/pr118953.c: New test.

(cherry picked from commit 54da358ff5)
2025-03-28 00:40:13 +01:00
Jakub Jelinek fc39a29f75 openmp: Fix up simd clone mask argument creation on x86 [PR115871]
The following testcase ICEs since r14-5057.
The Intel vector ABI says that in the ZMM case the masks is passed
in unsigned int or unsigned long long arguments and how many bits in
them and how many of those arguments are is determined by the characteristic
data type of the function.  In the testcase simdlen is 32 and characteristic
data type is double, so return as well as first argument is passed in 4
V8DFmode arguments and the mask is supposed to be passed in 4 unsigned int
arguments (8 bits in each).
Before the r14-5057 change there was
      sc->args[i].orig_type = parm_type;
...
        case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP:
        case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP:
        case SIMD_CLONE_ARG_TYPE_VECTOR:
          if (INTEGRAL_TYPE_P (parm_type) || POINTER_TYPE_P (parm_type))
            veclen = sc->vecsize_int;
          else
            veclen = sc->vecsize_float;
          if (known_eq (veclen, 0U))
            veclen = sc->simdlen;
          else
            veclen
              = exact_div (veclen,
                           GET_MODE_BITSIZE (SCALAR_TYPE_MODE (parm_type)));
for the argument handling and
  if (sc->inbranch)
    {
      tree base_type = simd_clone_compute_base_data_type (sc->origin, sc);
...
      if (INTEGRAL_TYPE_P (base_type) || POINTER_TYPE_P (base_type))
        veclen = sc->vecsize_int;
      else
        veclen = sc->vecsize_float;
      if (known_eq (veclen, 0U))
        veclen = sc->simdlen;
      else
        veclen = exact_div (veclen,
                            GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type)));
for the mask handling.  r14-5057 moved this argument creation later and
unified that:
        case SIMD_CLONE_ARG_TYPE_MASK:
        case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP:
        case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP:
        case SIMD_CLONE_ARG_TYPE_VECTOR:
          if (sc->args[i].arg_type == SIMD_CLONE_ARG_TYPE_MASK
              && sc->mask_mode != VOIDmode)
            elem_type = boolean_type_node;
          else
            elem_type = TREE_TYPE (sc->args[i].vector_type);
          if (INTEGRAL_TYPE_P (elem_type) || POINTER_TYPE_P (elem_type))
            veclen = sc->vecsize_int;
          else
            veclen = sc->vecsize_float;
          if (known_eq (veclen, 0U))
            veclen = sc->simdlen;
          else
            veclen
              = exact_div (veclen,
                           GET_MODE_BITSIZE (SCALAR_TYPE_MODE (elem_type)));
This is correct for the argument cases (so linear or vector) (though
POINTER_TYPE_P will never appear as TREE_TYPE of a vector), but the
boolean_type_node in there is completely bogus, when using AVX512 integer
masks as I wrote above we need the characteristic data type, not bool,
and bool is strange in that it has bitsize of 8 (or 32 on darwin), while
the masks are 1 bit per lane anyway.

Fixed thusly.

2025-03-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/115871
	* omp-simd-clone.cc (simd_clone_adjust): For SIMD_CLONE_ARG_TYPE_MASK
	and sc->mask_mode not VOIDmode, set elem_type to the characteristic
	type rather than boolean_type_node.

	* gcc.dg/gomp/simd-clones-8.c: New test.

(cherry picked from commit 6589eb4efe)
2025-03-28 00:40:13 +01:00
Jakub Jelinek ab908fdb91 c++: Fix cxx_eval_store_expression {REAL,IMAG}PART_EXPR handling [PR119045]
I've added the asserts that probe == target because {REAL,IMAG}PART_EXPR
always implies a scalar type and so applying ARRAY_REF/COMPONENT_REF
etc. on it further doesn't make sense and the later code relies on it
to be the last one in refs array.  But as the following testcase shows,
we can fail those assertions in case there is a reference or pointer
to the __real__ or __imag__ part, in that case we just evaluate the
constant expression and so probe won't be the same as target.
That case doesn't push anything into the refs array though.

The following patch changes those asserts to verify that refs is still
empty, which fixes it.

2025-02-28  Jakub Jelinek  <jakub@redhat.com>

	PR c++/119045
	* constexpr.cc (cxx_eval_store_expression) <case REALPART_EXPR>:
	Assert that refs->is_empty () rather than probe == target.
	(cxx_eval_store_expression) <case IMAGPART_EXPR>: Likewise.

	* g++.dg/cpp1y/constexpr-complex2.C: New test.

(cherry picked from commit 7eb8ec1856)
2025-03-28 00:40:12 +01:00
Jakub Jelinek a266e7354b c: stddef.h C23 fixes [PR114870]
The stddef.h header for C23 defines __STDC_VERSION_STDDEF_H__ and
unreachable macros multiple times in some cases.
The header doesn't have normal multiple inclusion guard, because it supports
for glibc inclusion with __need_{size_t,wchar_t,ptrdiff_t,wint_t,NULL}.
While the definition of __STDC_VERSION_STDDEF_H__ and unreachable is done
solely in the #ifdef _STDDEF_H part, so they are defined only if stddef.h
is included without those __need_* macros defined.  But actually once
stddef.h is included without the __need_* macros, _STDDEF_H is then defined
and while further stddef.h includes without __need_* macros don't do
anything:
 #if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
      && !defined(__STDDEF_H__)) \
     || defined(__need_wchar_t) || defined(__need_size_t) \
     || defined(__need_ptrdiff_t) || defined(__need_NULL) \
     || defined(__need_wint_t)
if one includes whole stddef.h first and then stddef.h with some of the
__need_* macros defined, the #ifdef _STDDEF_H part is used again.
It isn't that big deal for most cases, as it uses extra guarding macros
like:
 #ifndef _GCC_MAX_ALIGN_T
 #define _GCC_MAX_ALIGN_T
 ...
 #endif
etc., but for __STDC_VERSION_STDDEF_H__/unreachable nothing like that is
used.

So, either we do what the following patch does and just don't define
__STDC_VERSION_STDDEF_H__/unreachable second time, or use #ifndef
unreachable separately for the #define unreachable() case, or use
new _GCC_STDC_VERSION_STDDEF_H macro to guard this (or two, one for
__STDC_VERSION_STDDEF_H__ and one for unreachable), or rework the initial
condition to be just
 #if !defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
     && !defined(__STDDEF_H__)
- I really don't understand why the header should do anything at all after
it has been included once without __need_* macros.  But changing how this
behaves after 35 years might be risky for various OS/libc combinations.

2025-02-26  Jakub Jelinek  <jakub@redhat.com>

	PR c/114870
	* ginclude/stddef.h (__STDC_VERSION_STDDEF_H__, unreachable): Don't
	redefine multiple times if stddef.h is first included without __need_*
	defines and later with them.  Move nullptr_t and unreachable and
	__STDC_VERSION_STDDEF_H__ definitions into the same
	defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L #if block.

	* gcc.dg/c23-stddef-2.c: New test.

(cherry picked from commit 8d22474af7)
2025-03-28 00:40:12 +01:00
Jakub Jelinek f140941777 openmp: Mark OpenMP atomic write expression as read [PR119000]
The following testcase was emitting false positive warning that
the rhs of #pragma omp atomic write was stored but not read,
when the atomic actually does read it.  The following patch
fixes that by calling default_function_array_read_conversion
on it, so that it is marked as read as well as converted from
lvalue to rvalue.
Furthermore, the code had
if (code == NOP_EXPR) ... else ... if (code == NOP_EXPR) ...
with none of ... parts changing code, so I've merged the two ifs.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR c/119000
	* c-parser.cc (c_parser_omp_atomic): For omp write call
	default_function_array_read_conversion on the rhs expression.
	Merge the two adjacent if (code == NOP_EXPR) blocks.

	* c-c++-common/gomp/pr119000.c: New test.

(cherry picked from commit cdffc76393)
2025-03-28 00:40:12 +01:00
Jakub Jelinek 0a3a15cd1c reassoc: Fix up optimize_range_tests_to_bit_test [PR118915]
The following testcase is miscompiled due to a bug in
optimize_range_tests_to_bit_test.  It is trying to optimize
check for a in [-34,-34] or [-26,-26] or [-6,-6] or [-4,inf] ranges.
Another reassoc optimization folds the the test for the first
two ranges into (a + 34U) & ~8U in [0U,0U] range, and extract_bit_test_mask
actually has code to virtually undo it and treat that again as test
for a being -34 or -26.  The problem is that optimize_range_tests_to_bit_test
remembers in the type variable TREE_TYPE (ranges[i].exp); from the first
range.  If extract_bit_test_mask doesn't do that virtual undoing of the
BIT_AND_EXPR handling, that is just fine, the returned exp is ranges[i].exp.
But if the first range is BIT_AND_EXPR, the type could be different, the
BIT_AND_EXPR form has the optional cast to corresponding unsigned type
in order to avoid introducing UB.  Now, type was used to fill in the
max value if ranges[j].high was missing in subsequently tested range,
and so in this particular testcase the [-4,inf] range which was
signed int and so [-4,INT_MAX] was treated as [-4,UINT_MAX] instead.
And we were subtracting values of 2 different types and trying to make
sense out of that.

The following patch fixes this by using the type of the low bound
(which is always non-NULL) for the max value of the high bound instead.

2025-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/118915
	* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): For
	highj == NULL_TREE use TYPE_MAX_VALUE (TREE_TYPE (lowj)) rather
	than TYPE_MAX_VALUE (type).

	* gcc.c-torture/execute/pr118915.c: New test.

(cherry picked from commit 5806279610)
2025-03-28 00:40:11 +01:00
Roland McGrath 184e07c769 libcpp: Add missing configure check for setlocale.
libcpp/
	* configure.ac: Check for setlocale.
	* configure, config.in: Regenerated.
2025-03-27 22:19:03 +00:00
Lulu Cheng 243e634f5b LoongArch: Support Q suffix for __float128.
In r14-3635 supports `__float128`, but does not support the 'q/Q' suffix.

	PR target/119408

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_c_mode_for_suffix): New.
	(TARGET_C_MODE_FOR_SUFFIX): Define.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/pr119408.c: New test.

(cherry picked from commit 7c8da04c41)
2025-03-27 15:56:01 +08:00
GCC Administrator 1989dd3898 Daily bump. 2025-03-27 00:23:16 +00:00
Alex Coplan 23108ab2bd df: Treat partial defs as uses in df_simulate_defs [PR116564]
The PR shows us spinning in dce.cc:fast_dce at the start of combine.
This spinning appears to be because of a disagreement between the fast_dce code
and the code in df-problems.cc:df_lr_bb_local_compute.  Specifically, they
disagree on the treatment of partial defs.  For the testcase in the PR, we have
the following insn in bb 3:

(insn 10 8 13 3 (clobber (subreg:V1DF (reg/v:V2x1DF 104 [ __val ]) 8)) -1
     (nil))

which gives rise to a DF def with DF_REF_FLAGS = 0x8b0, i.e.
DF_REF_PARTIAL | DF_REF_READ_WRITE | DF_REF_MUST_CLOBBER | DF_REF_SUBREG.

Eliding the large block comment for readability, the code in
df_lr_bb_local_compute does the following (for each insn):

      FOR_EACH_INSN_INFO_DEF (def, insn_info)
        {
          unsigned int dregno = DF_REF_REGNO (def);
          bitmap_set_bit (&bb_info->def, dregno);
          if (DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))
            bitmap_set_bit (&bb_info->use, dregno);
          else
            bitmap_clear_bit (&bb_info->use, dregno);
        }

i.e. it models partial defs as a RMW operation; thus for the def arising
from i10 above, it records a use of r104; hence it ends up in the
live-in set for bb 3.

However, as it stands, the code in dce.cc:fast_dce (and its callee
dce_process_block) has no such provision for DF_REF_PARTIAL defs.  It
does not treat these as a RMW and does not compute r104 above as being
live-in to bb 3.  At the end of dce_process_block we compute the
following "did something happen" condition used to decide termination of
the analysis:

  block_changed = !bitmap_equal_p (local_live, DF_LR_IN (bb));
  if (block_changed)
    bitmap_copy (DF_LR_IN (bb), local_live);

  BITMAP_FREE (local_live);
  return block_changed;

because of the disagreement between df_lr_local_compute and the local
analysis done by fast_dce, we invariably have r104 in DF_LR_IN, but not
in local_live.  Hence we always return true here, call
df_analyze_problem (which re-computes DF_LR_IN according to
df_lr_bb_local_compute, re-adding r104), and so the analysis never
terminates.

This patch therefore adjusts df_simulate_defs (called from
dce_process_block) to match the behaviour of df_lr_bb_local_compute in
this respect, namely we make it model partial defs as RMW operations by
setting the relevant register live.  This fixes the spinning in fast_dce
for this testcase.

gcc/ChangeLog:

	PR rtl-optimization/116564
	* df-problems.cc (df_simulate_defs): For partial defs, mark the
	register live (treat it as a RMW operation).

gcc/testsuite/ChangeLog:

	PR rtl-optimization/116564
	* gcc.target/aarch64/torture/pr116564.c: New test.

(cherry picked from commit 758e617bcf)
2025-03-26 15:27:54 +00:00
Jonathan Wakely 5b4e362239 libstdc++: Allow std::ranges::to to create unions
LWG 4229 points out that the std::ranges::to wording refers to class
types, but I added an assertion using std::is_class_v which only allows
non-union class types. LWG consensus is that unions should be allowed,
so this additionally uses std::is_union_v.

libstdc++-v3/ChangeLog:

	* include/std/ranges (ranges::to): Allow unions as well as
	non-union class types.
	* testsuite/std/ranges/conv/lwg4229.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 479a0a8644)
2025-03-26 14:41:23 +00:00
Jonathan Wakely 679af7b103 libstdc++: Add static_assertions to ranges::to adaptor factory [PR112803]
The standard requires that we reject attempts to create a ranges::to
adaptor for cv-qualified types and non-class types. Currently we only
diagnose it once the adaptor is used in a pipeline.

This adds static assertions to diagnose it immediately.

libstdc++-v3/ChangeLog:

	PR libstdc++/112803
	* include/std/ranges (ranges::to): Add static assertions to
	enforce Mandates conditions.
	* testsuite/std/ranges/conv/112803.cc: New test.

(cherry picked from commit a9cfcd0d9e)
2025-03-26 14:41:23 +00:00
Jonathan Wakely 65670b788d libstdc++: Cast -1 to size_t in <format> [PR119429]
This avoids a runtime error from Clang's annoying -fsanitize=integer
(even though it's not undefined and behaves correctly).

libstdc++-v3/ChangeLog:

	PR libstdc++/119429
	* include/std/format (__format::_Scanner::_Scanner): Cast
	default argument to size_t.

(cherry picked from commit 039cc50867)
2025-03-26 14:41:23 +00:00
Jonathan Wakely b5d04ffcdf libstdc++: Define operator== for hash table iterators [PR115939]
Currently iterators for unordered containers do not directly define
operator== and operator!= overloads. Instead they rely on the base class
defining them, which is done so that iterator and const_iterator
comparisons work using the same overloads.

However this means a derived-to-base conversion is needed to call those
operators, and PR libstdc++/115939 shows that this can be ambiguous (for
-pedantic) when another overloaded operator could be used after an
implicit conversion.

This change defines operator== and operator!= directly for
_Node_iterator and _Node_const_iterator so that no derived-to-base
conversions are needed. The new overloads just forward to the base class
ones, so the implementation is still shared and doesn't need to be
duplicated.

libstdc++-v3/ChangeLog:

	PR libstdc++/115939
	* include/bits/hashtable_policy.h (_Node_iterator): Add
	operator== and operator!=.
	(_Node_const_iterator): Likewise.
	* testsuite/23_containers/unordered_map/115939.cc: New test.

(cherry picked from commit 591b71993f)
2025-03-26 14:41:23 +00:00
GCC Administrator f8c281d5c9 Daily bump. 2025-03-26 00:21:44 +00:00
Harald Anlauf de9500d93e Fortran: fix bogus bounds check for reallocation on assignment [PR116706]
PR fortran/116706

gcc/fortran/ChangeLog:

	* trans-array.cc (gfc_is_reallocatable_lhs): Fix check on
	allocatable components of derived type or class objects.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 3292ca9b08)
2025-03-25 22:14:39 +01:00
Martin Jambor 82bd83122a ipa-cp: Avoid ICE when redistributing nodes among edges to recursive clones (PR 118318)
PR 118318 reported an ICE during PGO build of Firefox when IPA-CP, in
the final stages of update_counts_for_self_gen_clones where it
attempts to guess how to distribute profile count among clones created
for recursive edges and the various edges that are created in the
process.  If one such edge has profile count of kind GUESSED_GLOBAL0,
the compatibility check in the operator+ will lead to an ICE.  After
discussing the situation with Honza, we concluded that there is little
more we can do other than check for this situation before touching the
edge count, so this is what this patch does.

gcc/ChangeLog:

2025-02-28  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118318
	* ipa-cp.cc (adjust_clone_incoming_counts): Add a compatible_p check.

(cherry picked from commit 7deb498425)
2025-03-25 16:57:09 +01:00
Patrick Palka 925a744efe libstdc++: Fix ref_view branch of views::as_const [PR119135]
Unlike for span<X> and empty_view<X>, the range_reference_t of
ref_view<X> doesn't correspond to X.  This patch fixes the ref_view
branch of views::as_const to correctly query its underlying range
type X.

	PR libstdc++/119135

libstdc++-v3/ChangeLog:

	* include/std/ranges: Include <utility>.
	(views::__detail::__is_ref_view): Replace with ...
	(views::__detail::__is_constable_ref_view): ... this.
	(views::_AsConst::operator()): Replace bogus use of element_type
	in the ref_view branch.
	* testsuite/std/ranges/adaptors/as_const/1.cc (test03): Extend
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 50359c0a44)
2025-03-25 10:43:41 -04:00
Simon Martin f078a613bf c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504]
We have been miscompiling the following valid code since GCC8, and
r8-3497-g281e6c1d8f1b4c

=== cut here ===
struct span {
  span (const int (&__first)[1]) : _M_ptr (__first) {}
  int operator[] (long __i) { return _M_ptr[__i]; }
  const int *_M_ptr;
};
void foo () {
  constexpr int a_vec[]{1};
  auto vec{[&a_vec]() -> span { return a_vec; }()};
}
=== cut here ===

The problem is that perform_implicit_conversion_flags (via
mark_rvalue_use) replaces "a_vec" in the return statement by a
CONSTRUCTOR representing a_vec's constant value, and then takes its
address when invoking span's constructor. So we end up with an instance
that points to garbage instead of a_vec's storage.

As per Jason's suggestion, this patch simply removes the calls to
mark_*_use from perform_implicit_conversion_flags, which fixes the PR.

	PR c++/117504

gcc/cp/ChangeLog:

	* call.cc (perform_implicit_conversion_flags): Don't call
	mark_{l,r}value_use.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-117504.C: New test.
	* g++.dg/cpp2a/constexpr-117504a.C: New test.

(cherry picked from commit fdf846fddd)
2025-03-25 07:08:16 +01:00
GCC Administrator 96be9838ae Daily bump. 2025-03-25 00:23:58 +00:00
Haochen Jiang 5ba6fdc547 i386: Add -mavx10.1 back with 512 bit alias
When AVX10.1 options are added into GCC 14, E-core is supposed to
support up to 256 bit vector width, while P-core up to 512 bit vector
width. Therefore, we added avx10.1-256 and avx10.1-512 options into
compiler and alias avx10.1 to 256 bit for compatibility since there
will be real platforms with 256 bit only support.

However, all the future platforms will now support 512 bit vector width,
including P-core and E-core. Therefore, we could alias avx10.1 directly
to 512 bit. However, avx10.1 alias to 256 bit has been there in GCC 14.1
and GCC 14.2, so we have to raise a warning since GCC 14.3 for this
behavior change.

While backporting the patch from GCC 15, we choose to only warn when
users use -mavx10.1 option in order not to interrupt the usage of other
options since -mavx10.1-256/512 and -mevex512 will be dropped in GCC 16.
There is no need to warn them this early in GCC 14 to overwhelm users.

gcc/ChangeLog:

	* common/config/i386/i386-isas.h: Add avx10.1.
	* config/i386/i386-c.cc (ix86_target_macros_internal): Ditto.
	* config/i386/i386-options.cc
	(ix86_valid_target_attribute_inner_p): Ditto.
	* config/i386/i386.opt: Ditto.
	* config/i386/i386.opt.urls: Ditto.
	* doc/extend.texi: Ditto.
	* doc/sourcebuild.texi: Ditto.
2025-03-24 16:01:59 +08:00
Simon Martin 8bac228171 c++: Don't mix timevar_start and auto_cond_timevar for TV_NAME_LOOKUP [PR116681]
We currently ICE upon the following testcase when using -ftime-report

=== cut here ===
template < int> using __conditional_t = int;
template < typename _Iter >
concept random_access_iterator = requires { new _Iter; };
template < typename _Iterator >
struct reverse_iterator {
  using iterator_concept =
    __conditional_t< random_access_iterator< _Iterator>>;
};
void RemoveBottom() {
  int iter;
  for (reverse_iterator< int > iter;;)
      ;
}
=== cut here ===

The problem is that qualified_namespace_lookup does a plain start() of
the TV_NAME_LOOKUP timer (that asserts that the timer is not already
started). However this timer has already been cond_start()'d in the call
stack - by pushdecl - so the assert fails.

This patch simply ensures that we always conditionally start this timer
(which is done in all other places that use it).

	PR c++/116681

gcc/cp/ChangeLog:

	* name-lookup.cc (qualified_namespace_lookup): Use an
	auto_cond_timer instead of using timevar_start and timevar_stop.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-pr116681.C: New test.

(cherry picked from commit 005f7176e0)
2025-03-24 08:15:54 +01:00
GCC Administrator 2ba7823653 Daily bump. 2025-03-24 00:22:06 +00:00
Georg-Johann Lay 18f6f54901 AVR: Add AVR-SD devices.
gcc/
	* config/avr/avr-mcus.def: Add AVR32SD20, AVR32SD28, AVR32SD32,
	AVR64SD28, AVR64SD32, AVR64SD48.
	* doc/avr-mmcu.texi: Rebuild.

(cherry picked from commit 82e3832760)
2025-03-23 14:04:46 +01:00
Iain Buclaw e4e7d446ec d: Fix ICE type variant differs by TYPE_PACKED [PR117621]
Introduced by r13-1104-gf4c3ce32fa54c1, which had an accidental self
assignment of TYPE_PACKED when it should have been assigned to the
type's variants.

	PR d/117621

gcc/d/ChangeLog:

	* types.cc (finish_aggregate_type): Propagate TYPE_PACKED to variants.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr117621.d: New test.

(cherry picked from commit a12dd79ff4e469652be6d8ef501e1d70178b44cd)
2025-03-23 13:03:15 +01:00
GCC Administrator bfcf402446 Daily bump. 2025-03-23 00:22:26 +00:00
Martin Uecker a3989d8158 c: Set attributes for fields when forming a composite type [PR117806]
We need to call decl_attributes when creating the fields for a composite
type.

	PR c/117806

gcc/c/ChangeLog:
	* c-typeck.cc (composite_type_internal): Call decl_attributes.

gcc/testsuite/ChangeLog:
	* gcc.dg/pr117806.c: New test.

(cherry picked from commit 1539bcd19c)
2025-03-22 17:35:58 +01:00
Martin Uecker 432f918f11 c: minor fixes related to arrays of unspecified size
The patch for PR117145 and PR117245 also fixed PR100420 and PR116284 which
are bugs related to arrays of unspecified size.  Those are now represented
as variable size arrays with size (0, 0).  There are still some loose ends,
which are resolved here by

1. adding a testcase for PR116284,
2. moving code related to creation and detection of arrays of unspecified
sizes in their own functions,
3. preferring a specified size over an unspecified size when forming
a composite type as required by C99 (PR118391)
4. removing useless code in comptypes_internal and composite_type_internal.

	PR c/116284
	PR c/117391

gcc/c/ChangeLog:
	* c-tree.h (c_type_unspecified_p): New inline function.
	* c-typeck.cc (c_build_array_type_unspecified): New function.
	(comptypes_interal): Remove useless code.
	(composite_type_internal): Update.
	* c-decl.cc (grokdeclarator): Revise.

gcc/testsuite/ChangeLog:
	* gcc.dg/pr116284.c: New test.
	* gcc.dg/pr117391.c: New test.

(cherry picked from commit 114abf075c)
2025-03-22 17:05:51 +01:00
Martin Uecker 9d9dc4be67 c: detect variably-modified types [PR117145,PR117245,PR100420]
This fixes two cases where variably-modified types were not recognized as
such.  The first is when building composite types and the other when a type
is reconstructed for the 'vector' attribute.  Construction of types in
the C FE is reorganized to use c_build_* functions which are responsible for
setting C_TYPE_VARIABLE_SIZE, C_TYPE_VARIABLY_MODIFIED and TYPE_TYPELESS_STORAGE
based on the properties of the type itself and these replace all other logic
elsewhere (e.g. in grokdeclarator).  A new 'c_reconstruct_complex_type' based
on these functions is introduced which is called via a language hook when the
'vector' attribute is processed (as for C++).

One problem is are arrays of unspecified size 'T[*]' which were represented
identically to zero-sized arrays but with C_TYPE_VARIABLE_SIZE set.  To avoid
having to create distinct type copies for this, the representation was changed
to make it a natural VLA by giving it an upper bound of '(0, 0)'.  This also
then allows fixing of PR100420 where such arrays were printed as 'T[0]'.

Finally, a new function 'c_verify_type' checks consistency of properties
specific to C FE and is called when checking is on.

	PR c/117145
	PR c/117245
	PR c/100420

gcc/c/ChangeLog:
	* c-decl.cc (c_build_pointer_type): Move to c-typeck.cc
	(grokdeclarator): Simplify logic.
	(match_builtin_function_types): Adapt.
	(push_decl): Adapt.
	(implicitly_declare): Adapt.
	(c_update_type_canonical): Adapt.
	(c_make_fname_decl): Adapt.
	(start_function): Adapt.
	* c-objc-common.h: Add LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE.
	* c-tree.h: Add prototypes.
	* c-typeck.cc (c_verify_type): New function.
	(c_set_type_bits). New function.
	(c_build_pointer_type): Moved from c-decl.cc.
	(c_build_pointer_type_for_mode): New function.
	(c_build_function_type): New function.
	(c_build_array_type): New function.
	(c_build_type_attribute_variant): New function.
	(c_reconstruct_complex_type): New function.
	(c_build_functype_attribute_variant): Renamed.
	(array_to_pointer_conversion): Simplify logic.
	(composite_type_internal): Simplify logic..
	(build_unary_op): Simplify logic..
	(comptypes_verify): Add checking assertions.
	(c_build_qualified_type): Add checking assertions.
	(c_build_function_call_vec): Adapt.
	(qualify_type): Adapt.
	(build_functype_attribute_variant): Adapt.
	(common_pointer_type): Adapt.
	(c_common_type): Adapt.
	(convert_for_assignment): Adapt.
	(type_or_builtin_type): Adapt.
	(build_access_with_size_for_counted_by): Adapt.
	(build_conditional_expr): Adapt.
	(build_modify_expr): Adapt.
	(build_binary_op): Adapt.
	(build_omp_array_section): Adapt.
	(handle_omp_array_sections): Adapt.
	(c_finish_omp_clauses): Adapt.
	* c-parser.cc (c_parser_typeof_specifier): Adapt.
	(c_parser_generic_selection): Adapt.

gcc/c-family/ChangeLog:
	* c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
	Detect arrays of unspecified size.

gcc/testsuite/ChangeLog:
	* gcc.dg/c23-tag-composite-11.c: New test.
	* gcc.dg/Warray-parameter-4.c: Resolve xfails.
	* gcc.dg/Wvla-parameter-2.c: Resolve xfails.
	* gcc.dg/Wvla-parameter-3.c: Resolve xfails.
	* gcc.dg/pr117145-1.c: New test.
	* gcc.dg/pr117145-2.c: New test.
	* gcc.dg/pr117245.c: New test.

(cherry picked from commit 9eae9268e4)
2025-03-22 16:08:27 +01:00
Patrick Palka d025b6880c c++: ICE w/ dependently scoped template friend [PR119378]
Here we ICE during instantiation of the dependently scoped template
friend

  template<int N>
  struct<class T>
  friend class A<N>::B;

ultimately because processing_template_decl isn't set during
substitution into the A<N> scope.  Since it's naturally a partial
substitution, we need to make sure the flag is set.

For GCC 15, this is already fixed similarly by r15-123.

	PR c++/119378

gcc/cp/ChangeLog:

	* pt.cc (tsubst) <case UNBOUND_CLASS_TEMPLATE>: Set
	processing_template_decl when substituting the context.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
2025-03-22 10:18:07 -04:00
GCC Administrator 9c0c533c15 Daily bump. 2025-03-22 09:30:52 +00:00
Jason Merrill 8a624a1279 ipa: target clone and mangling alias [PR114992]
Since the mangling of the second lambda changed (previously we counted all
lambdas, now we only count lambdas with the same signature), we
generate_mangling_alias for handler<lambda2> for backward compatibility.
Since handler is COMDAT, resolve_alias puts the alias in the same comdat
group as handler itself.  Then create_dispatcher_calls tries to add the
alias to the same comdat group as the dispatcher, but it's already in a
same_comdat_group, so we ICE.

It seems like we're just missing a remove_from_same_comdat_group before
add_to_same_comdat_group.

	PR c++/114992

gcc/ChangeLog:

	* multiple_target.cc (create_dispatcher_calls):
	remove_from_same_comdat_group before add_to_same_comdat_group.

gcc/testsuite/ChangeLog:

	* g++.target/i386/mangling-alias1.C: New test.

(cherry picked from commit ab716829da)
2025-03-21 13:42:29 -04:00
Filip Kastl 1395073774 gimple: sccopy: Don't increment i after vec::unordered_remove()
I increment the index variable in a loop even when I do
vec::unordered_remove() which causes the vector traversal to miss some
elements.  Mikael notified me of this mistake I made in my last patch.

gcc/ChangeLog:

	* gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Don't
	increment after vec::unordered_remove().

Reported-by: Mikael Morin <mikael@gcc.gnu.org>
Signed-off-by: Filip Kastl <fkastl@suse.cz>
(cherry picked from commit a1363f8dd8)
2025-03-21 14:00:59 +01:00
Jonathan Wakely 084dacc205 libstdc++: Correct statement about default -std option
The default is -std=gnu++17 now, not -std=gnu++14.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/test.xml: Fix default for -std option.
	* doc/html/manual/test.html: Regenerate.

(cherry picked from commit b93e60e790)
2025-03-21 12:09:23 +00:00
Jakub Jelinek e7a0f04ddb libstdc++: Fix comment typo
Another IEE typo.

2025-03-20  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/18_support/numeric_limits/traps.cc (main): Fix comment
	typo.

(cherry picked from commit d458020e19)
2025-03-21 12:09:22 +00:00
Jonathan Wakely b685234cb5 libstdc++: Fix "IEE" typo in comment in std::time_put::do_put
libstdc++-v3/ChangeLog:

	* include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix
	typo in comment.

(cherry picked from commit b8e39b4c33)
2025-03-21 12:09:22 +00:00
GCC Administrator 9920673703 Daily bump. 2025-03-21 00:22:55 +00:00
Simon Martin f86d274ab7 c++: Don't prune constant capture proxies only used in array dimensions [PR114292]
We currently ICE upon the following valid (under -Wno-vla) code

=== cut here ===
void f(int c) {
  constexpr int r = 4;
  [&](auto) { int t[r * c]; }(0);
}
=== cut here ===

When parsing the lambda body, and more specifically the multiplication,
we mark the lambda as LAMBDA_EXPR_CAPTURE_OPTIMIZED, which indicates to
prune_lambda_captures that it might be possible to optimize out some
captures.

The problem is that prune_lambda_captures then misses the use of the r
capture (because neither walk_tree_1 nor cp_walk_subtrees walks the
dimensions of array types - here "r * c"), hence believes the capture
can be pruned... and we trip on an assert when instantiating the lambda.

This patch changes cp_walk_subtrees so that (1) when walking a
DECL_EXPR, it also walks the DECL's type, and (2) when walking an
INTEGER_TYPE and processing a template declaration, it also walks its
TYPE_{MIN,MAX}_VALUE.

	PR c++/114292

gcc/cp/ChangeLog:

	* tree.cc (cp_walk_subtrees): Walk the type of DECL_EXPR
	declarations, as well as the TYPE_{MIN,MAX}_VALUE of
	INTEGER_TYPEs for template declarations.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-ice4.C: New test.
2025-03-20 20:37:28 +01:00
Iain Buclaw c6b1b62f11 d: Merge upstream dmd, druntime af92b68a81, phobos c970ca67f
D front-end changes:

	- Import dmd v2.108.1.

D runtime changes:

	- Import druntime v2.108.1.

Phobos changes:

	- Import phobos v2.108.1.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd af92b68a81.
	* dmd/VERSION: Bump version to v2.108.1.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime af92b68a81.
	* src/MERGE: Merge upstream phobos c970ca67f.
2025-03-20 02:10:01 +01:00
GCC Administrator bc8569984e Daily bump. 2025-03-20 00:24:19 +00:00
Jason Merrill a2dcdbfa34 c++: mangling of array new [PR119316]
Because we build an array type to represent an array new, we hit a VLA
error in compute_array_index_type for a variable length array new.  To avoid
this, let's build the MINUS_EXPR and index type directly.

I also noticed that the non-constant case in write_array_type was assuming
MINUS_EXPR without verifying it, so I added a checking_assert.

I also noticed that Clang doesn't mangle the length of an array new at all,
so I opened https://github.com/itanium-cxx-abi/cxx-abi/issues/199 to clarify
this.

	PR c++/119316

gcc/cp/ChangeLog:

	* mangle.cc (write_expression) [NEW_EXPR]: Avoid using
	compute_array_index_type.
	(write_array_type): Add checking_assert.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/mangle-new1.C: New test.

(cherry picked from commit 80e1dac384)
2025-03-19 18:23:51 -04:00
Patrick Palka 9a69c36417 c++: memfn pointer as NTTP argument considered unused [PR119233]
This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

	PR c++/119233

gcc/cp/ChangeLog:

	* pt.cc (mark_template_arguments_used): Also handle member
	function pointers.

gcc/testsuite/ChangeLog:

	* g++.dg/template/fn-ptr5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 51b1c0a2dd)
2025-03-19 14:23:49 -04:00
Eric Botcazou 5497ff92a3 Fix misoptimization at -O2 in LTO mode
This is a regression in recent releases. The problem is that the IPA mod/ref
pass looks through the (nominal) type of a pointer-to-discriminated-type
parameter in a call to a subprogram in order to see the (actual) type used
for the dereferences of the parameter in the callee, which is a
pointer-to-constrained-subtype.

Historically the discriminated type is marked with the may_alias attribute
because of the symmetric effect for the argument in the caller, so we mark
the constrained subtype with the attribute now for the sake of the callee.

gcc/ada/
	* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
	the may_alias attribute if a specific GCC type is built.
2025-03-19 08:57:37 +01:00
Eric Botcazou 21c83cd473 Fix spurious visibility error with partially parameterized formal package
This is not a regression but the issue is quite annoying and the fix is
trivial.  The problem is that a formal parameter covered by a box in the
formal package is not visible in the instance when it comes after another
formal parameter that is also a formal package.

It comes from a discrepancy internal to Instantiate_Formal_Package, where
a specific construct (the abbreviated instance) built for the nested formal
package discombobulates the processing done for the outer formal package.

gcc/ada/
	* gen_il-gen-gen_nodes.adb (N_Formal_Package_Declaration): Use
	N_Declaration instead of Node_Kind as ancestor.
	* sem_ch12.adb (Get_Formal_Entity): Remove obsolete alternative.
	(Instantiate_Formal_Package): Take into account the abbreviated
	instances in the main loop running over the actuals of the local
	package created for the formal package.

gcc/testsuite/
	* gnat.dg/generic_inst14.adb: New test.
	* gnat.dg/generic_inst14_pkg.ads: New helper.
	* gnat.dg/generic_inst14_pkg-child.ads: Likewise.
2025-03-19 08:44:43 +01:00
GCC Administrator d97aa3bee7 Daily bump. 2025-03-19 00:22:50 +00:00
Jason Merrill 49ccf5238b c++: constexpr ref template arg [PR119194]
Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

	PR c++/119194

gcc/cp/ChangeLog:

	* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 145c907206)
2025-03-18 18:21:52 -04:00
Marek Polacek 0910ebacff c++: ICE with ptr-to-member-fn [PR119344]
This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR<CAST_EXPR<>> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

	PR c++/119344

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of save_expr.

gcc/testsuite/ChangeLog:

	* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6fc1f70f0b)
2025-03-18 16:47:22 -04:00
Marek Polacek 22bdc4d9dd c++: ICE when substituting packs into type aliases [PR118104]
r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> <int, int>, Us -> <A, P...> }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

	PR c++/118104

gcc/cp/ChangeLog:

	* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6751bd4ac4)
2025-03-18 16:10:02 -04:00
Marek Polacek a9f88741a9 c++: tweak for -Wrange-loop-construct [PR116731]
This PR reports that the warning would be better off using a check
for trivially constructible rather than trivially copyable.

LLVM accepted a similar fix:
https://github.com/llvm/llvm-project/issues/47355

	PR c++/116731

gcc/cp/ChangeLog:

	* parser.cc (warn_for_range_copy): Check if TYPE is trivially
	constructible, not copyable.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wrange-loop-construct3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6ac4e2f4b2)
2025-03-18 15:35:44 -04:00
Patrick Palka a3c01af5e3 libstdc++: Fix constraint recursion in basic_const_iterator relops [PR112490]
Here for

  using RCI = reverse_iterator<basic_const_iterator<vector<int>::iterator>>
  static_assert(std::totally_ordered<RCI>);

we effectively need to check the requirement

  requires (RCI x) { x RELOP x; }  for each RELOP in {<, >, <=, >=}

which we expect to be straightforwardly satisfied by reverse_iterator's
namespace-scope relops.  But due to ADL we find ourselves also
considering the basic_const_iterator relop friends, which before CWG
2369 would be quickly discarded since RCI clearly isn't convertible to
basic_const_iterator.  After CWG 2369 though we must first check these
relops' constraints (with _It = vector<int>::iterator and _It2 = RCI),
which entails checking totally_ordered<RCI> recursively.

This patch fixes this by turning the problematic non-dependent function
parameters of type basic_const_iterator<_It> into dependent ones of
type basic_const_iterator<_It3> where _It3 is constrained to match _It.
Thus the basic_const_iterator relop friends now get quickly discarded
during deduction and before the constraint check if the second operand
isn't a specialization of basic_const_iterator (or derived from one)
like before CWG 2369.

	PR libstdc++/112490

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (basic_const_iterator::operator<):
	Replace non-dependent basic_const_iterator function parameter with
	a dependent one of type basic_const_iterator<_It3> where _It3
	matches _It.
	(basic_const_iterator::operator>): Likewise.
	(basic_const_iterator::operator<=): Likewise.
	(basic_const_iterator::operator>=): Likewise.
	* testsuite/24_iterators/const_iterator/112490.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 4342c50ca8)
2025-03-18 10:52:13 -04:00
GCC Administrator 3d99c22011 Daily bump. 2025-03-18 00:23:27 +00:00
GCC Administrator 5ef1aa4908 Daily bump. 2025-03-17 00:21:57 +00:00
GCC Administrator bf9c2eec28 Daily bump. 2025-03-16 00:22:35 +00:00
GCC Administrator f8504e361c Daily bump. 2025-03-15 00:23:47 +00:00
GCC Administrator 158987a288 Daily bump. 2025-03-14 00:21:46 +00:00
Eric Botcazou 1016eea220 Plug small loophole in the pattern matching done by -fdump-ada-spec
gcc/c-family/
	PR ada/119265
	* c-ada-spec.cc (dump_ada_node) <INTEGER_TYPE>: Deal with typedefs
	of unsigned __int128.
2025-03-14 00:05:09 +01:00
GCC Administrator 6fcad2bfa0 Daily bump. 2025-03-13 00:22:45 +00:00
Marek Polacek a27b24c9f4 c++: ICE with aligned member and trivial assign op [PR117512]
build_over_call has:

	  t = build2 (MODIFY_EXPR, void_type_node,
		      build2 (MEM_REF, array_type, arg0, alias_set),
		      build2 (MEM_REF, array_type, arg, alias_set));
	  val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);

which creates an expression that can look like:

  d = MEM <unsigned char[4]> [(struct A *)&TARGET_EXPR <D.2894, foo()]
    = MEM <unsigned char[4]> [(struct A *)(const struct A &) &e],
      TARGET_EXPR <D.2894, foo()>

that is, a COMPOUND_EXPR where a TARGET_EXPR is used twice, and its
address is taken in the left-hand side operand, so it can't be elided.
But set_target_expr_eliding simply recurses on the second operand of
a COMPOUND_EXPR and marks the TARGET_EXPR as eliding.  This then causes
a crash.

cp_build_indirect_ref_1 should not be changing the value category.
While *&TARGET_EXPR is an lvalue, folding it into TARGET_EXPR would
render is a prvalue of class type.

	PR c++/117512

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_indirect_ref_1): Only do the *&e -> e
	folding if the result would be an lvalue.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alignas23.C: New test.
	* g++.dg/ext/align3.C: New test.
	* g++.dg/ext/align4.C: New test.
	* g++.dg/ext/align5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 3dd7b59806)
2025-03-12 17:33:03 -04:00
Marek Polacek e5ae0a014f c++: ICE with lambda in fold expression in requires [PR119134]
The r12-8258 fix assumes that DECL_CONTEXT of 'pack' in
check_for_bare_parameter_packs is going to be an operator()
but as this test shows, it can be empty.

	PR c++/119134

gcc/cp/ChangeLog:

	* pt.cc (check_for_bare_parameter_packs): Check DECL_CONTEXT.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-uneval24.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 0e47062ce7)
2025-03-12 13:52:20 -04:00
Richard Earnshaw de08b13018 arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch
GCC will complain if the -mcpu flag specifies a different architecture
to that specified in -march, but if the floating-point ABI is "soft",
then differences in the floating-point architecture features are
ignored.

However, the arm_libc_fp_abi checks whether we change the FP ABI by
adding -mfloat-abi=hard/softfp to override the defaults.  If that
fails it won't add anything.

Unfortunately arm_neon_h_ok wasn't correctly checking whether the libc
check had worked and just assumed that it would always add something
to enable FP.  That's insufficient and we need to consider this failure.
We simply mark tests as unsupported in this case.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp
	(check_effective_target_arm_neon_h_ok_nocache): Return zero if
	check_effective_target_arm_libc_fp_abi_ok reports failure.

(cherry picked from commit 1b7a057708)
2025-03-12 06:39:57 +01:00
Richard Earnshaw f1dd3a17cf arm: testsuite: improve guard checks for arm_neon.h
The header file arm_neon.h provides the Advanced SIMD intrinsics that
are available on armv7 or later A & R profile cores.  However, they
are not compatible with M-profile and we also need to ensure that the
FP instructions are enabled (with -mfloat-abi=softfp/hard).  That
leads to some complicated checking as arm_neon.h includes stdint.h
and, at least on linux, that can require that the appropriate ABI
bits/ headers are also installed.

This patch adds a new check to target-supports.exp to establish the
minimal set of option overrides needed to enable use of this header in
a test.

gcc/testsuite:
	* lib/target-supports.exp
	(check_effective_target_arm_neon_h_ok_nocache): New function.
	(check_effective_target_arm_neon_h_ok): Likewise.
	(add_options_for_arm_neon_h): Likewise.
	(check_effective_target_arm_libc_fp_abi_ok_nocache): Allow any
	Arm target, not just arm32.
	* gcc.target/arm/attr-neon-builtin-fail.c: Use it.
	* gcc.target/arm/attr-neon-builtin-fail2.c: Likewise.
	* gcc.target/arm/attr-neon-fp16.c: Likewise.
	* gcc.target/arm/attr-neon2.c: Likewise.

(cherry picked from commit b7f5d91148)
2025-03-12 06:39:56 +01:00
GCC Administrator 3a07660a5a Daily bump. 2025-03-12 00:23:02 +00:00
Iain Buclaw af69315f84 d: Fix regression returning from function with invariants [PR119139]
An optimization was added in GDC-12 which sets the TREE_READONLY flag on
all local variables with the storage class `const' assigned.  For some
reason, const is also being added by the front-end to `__result'
variables in non-virtual functions, which ends up getting wrong code by
the gimplify pass promoting the local to static storage.

A bug has been raised upstream, as this looks like an error in the AST.
For now, turn off setting TREE_READONLY on all result variables.

	PR d/119139

gcc/d/ChangeLog:

	* decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result
	declarations.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr119139.d: New test.

(cherry picked from commit 81582ca6cb)
2025-03-11 20:22:47 +01:00
GCC Administrator 79366d9bec Daily bump. 2025-03-11 00:22:48 +00:00
Iain Buclaw ca0ea3d419 libphobos: Default to libc closefrom in spawnProcessPosix [PR119112]
This is a backport of two changes in upstream Phobos.

- The current implementation of spawnProcessPosix is broken on systems
with a large `ulimit -n' because it always OOMs making it impossible to
spawn processes. Using the libc implementation, when available, for
doing file descriptor operations en-mass solves this problem.

- The fallback code now reads the list of file descriptors in use from
/dev/fd or /proc/this/fd, avoiding the need to scroll through the entire
list of possible file descriptors. This fixes the fork process being
very slow and memory intensive when RLIMIT_NOFILE is too high.

	PR d/119112

libphobos/ChangeLog:

	* libdruntime/core/sys/freebsd/unistd.d (closefrom): Add binding.
	* libdruntime/core/sys/linux/unistd.d (closefrom): Likewise.
	* libdruntime/core/sys/openbsd/unistd.d (closefrom): Likewise.
	* src/std/process.d (enum InternalError): Add closefds_dup2.
	(spawnProcessPosix): Use closefrom when available.

Reviewed-on: https://github.com/dlang/phobos/pull/9048
Reviewed-on: https://github.com/dlang/phobos/pull/9077
2025-03-10 23:11:52 +01:00
Paul Thomas 5cb69a5e4f Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
2025-01-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/118640
	* resolve.cc (generate_component_assignments): Make sure that
	the rhs temporary does not pick up the optional attribute from
	the lhs.

gcc/testsuite/
	PR fortran/118640
	* gfortran.dg/pr118640.f90: New test.

(cherry picked from commit 3600b1ff14)
2025-03-09 19:55:16 -07:00
GCC Administrator 89fa4d8996 Daily bump. 2025-03-10 00:21:35 +00:00
Paul Thomas f6f90e015f Fortran: Fix segmentation fault in defined assignment [PR109066]
2024-11-16  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/109066
	* resolve.cc (generate_component_assignments): If the temporary
	for 'var' is a pointer and 'expr' is neither a constant or
	a variable, change its attribute from pointer to allocatable.
	This avoids assignment to a temporary point that has neither
	been allocated or associated.

gcc/testsuite/
	PR fortran/109066
	* gfortran.dg/defined_assignment_12.f90: New test.

(cherry picked from commit 27ff8049bb)
2025-03-09 11:39:57 -07:00
Jerry DeLisle e4f886c463 Fortran: Fix ICE in resolve.cc with -pedantic
Fixes an ICE in gfc_resolve_code when passing an
optional array to an elemental procedure with `-pedantic` enabled.
PR95446 added the original check, this patch fixes the case where the
other actual argument is an array literal (or something else other
than a variable).

	PR fortran/119054

gcc/fortran/ChangeLog:

	* resolve.cc (resolve_elemental_actual): When checking other
	actual arguments to elemental procedures, don't check
	attributes of literals and function calls.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr95446.f90: Expand test case to literals and
	function calls.

	Signed-off-by: Peter Hill <peter.hill@york.ac.uk>

(cherry picked from commit 3014f87871)
2025-03-09 11:36:10 -07:00
Andre Vehreschild c6b2a359d3 Fortran: Fix gimplification error on assignment to pointer [PR103391]
PR fortran/103391

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_trans_assignment_1): Do not use poly assign
	for pointer arrays on lhs (as it is done for allocatables
	already).

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 04909c7ecc)
2025-03-09 08:18:26 +00:00
GCC Administrator 2b9cfa7608 Daily bump. 2025-03-09 00:21:44 +00:00
GCC Administrator 9608070a38 Daily bump. 2025-03-08 00:22:25 +00:00
Christophe Lyon 1c99a8f255 arm: Handle fixed PIC register in require_pic_register (PR target/115485)
Commit r9-4307-g89d7557202d25a forgot to accept a fixed PIC register
when extending the assert in require_pic_register.

arm_pic_register can be set explicitly by the user
(e.g. -mpic-register=r9) or implicitly as the default value with
-fpic/-fPIC/-fPIE and -mno-pic-data-is-text-relative -mlong-calls, and
we want to use/accept it when recording cfun->machine->pic_reg as used
to be the case.

	PR target/115485
	gcc/
	* config/arm/arm.cc (require_pic_register): Fix typos in
	comment. Handle fixed arm_pic_register.

	gcc/testsuite/
	* g++.target/arm/pr115485.C: New test.

(cherry picked from commit b1d0ac28de)
2025-03-07 10:42:52 +00:00
GCC Administrator fa7630698e Daily bump. 2025-03-07 00:22:10 +00:00
Xi Ruoyao 43d7770783 LoongArch: Fix incorrect reorder of __lsx_vldx and __lasx_xvldx [PR119084]
They could be incorrectly reordered with store instructions like st.b
because the RTL expression does not have a memory_operand or a (mem)
expression.  The incorrect reorder has been observed in openh264 LTO
build.

Expand them to a (mem) expression instead of unspec to fix the issue.

Closes: https://github.com/cisco/openh264/issues/3857

(cherry picked from commit 4856292f7a)

Edited to remove the loongarch.cc change which is not needed for gcc-14
branch.

gcc/ChangeLog:

	PR target/119084
	* config/loongarch/lasx.md (UNSPEC_LASX_XVLDX): Remove.
	(lasx_xvldx): Remove.
	* config/loongarch/lsx.md (UNSPEC_LSX_VLDX): Remove.
	(lsx_vldx): Remove.
	* config/loongarch/simd.md (QIVEC): New define_mode_iterator.
	(<simd_isa>_<x>vldx): New define_expand.

gcc/testsuite/ChangeLog:

	PR target/119084
	* gcc.target/loongarch/pr119084.c: New test.
2025-03-06 13:03:43 +08:00
GCC Administrator 844f5f1f0e Daily bump. 2025-03-06 00:24:11 +00:00
Marek Polacek 8c635072ae c++: disable -Wnonnull in unevaluated context [PR115580]
This PR complains that we issue a -Wnonnull even in a decltype.
This fix disables even -Wformat and -Wrestrict.  I think that's fine.

	PR c++/115580

gcc/c-family/ChangeLog:

	* c-common.cc (check_function_arguments): Return early if
	c_inhibit_evaluation_warnings.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wnonnull16.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 459c8a5556)
2025-03-05 16:09:21 -05:00
Richard SandifordandAlex Coplan 1a4f1e5f91 aarch64: Check for invalid use arrays in ldp_fusion [PR118320]
As Andrew says in the bugzilla comments, this PR is about a case where
we tried to fuse two stores of x0, one in which x0 was defined and one
in which it was undefined.  merge_access_arrays failed on the conflict,
but the failure wasn't caught.

Normally the hazard detection code would fail if the instructions
had incompatible uses.  However, an undefined use doesn't impose
many restrictions on movements.  I think this is likely to be the
only case where hazard detection isn't enough.

As Andrew notes in bugzilla, it might be possible to allow uses
of defined and undefined values to be merged to the defined value.
But that sounds dangerous in the general case, as an rtl-ssa-level
decision.  We might run the risk of turning conditional UB into
unconditional UB.  And LLVM proves that the definition of "undef"
isn't simple.

This is a backport of
r15-7282-gf559ac896942ffe0e2315d0a4d8b8b517a16d607.

gcc/
	PR rtl-optimization/118320
	* config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::fuse_pair):
	Commonize the merge of input_uses and return early if it
	fails.

gcc/testsuite/
	PR rtl-optimization/118320
	* g++.dg/torture/pr118320.C: New test.

Co-authored-by: Alex Coplan <alex.coplan@arm.com>
2025-03-05 17:38:57 +00:00
Hannes Braun 6e17b356a7 arm: Fix signedness of vld1q intrinsic parms [PR118942]
vld1q_s8_x3, vld1q_s16_x3, vld1q_s8_x4 and vld1q_s16_x4 were expecting
pointers to unsigned integers. These parameters should be pointers to
signed integers.

gcc/ChangeLog:
	PR target/118942
	* config/arm/arm_neon.h (vld1q_s8_x3): Use int8_t instead of
	uint16_t.
	(vld1q_s16_x3): Use int16_t instead of uint16_t.
	(vld1q_s8_x4): Likewise.
	(vld1q_s16_x4): Likewise.

gcc/testsuite/ChangeLog:
	PR target/118942
	* gcc.target/arm/simd/vld1q_base_xN_1.c: Add -Wpointer-sign.

Signed-off-by: Hannes Braun <hannes@hannesbraun.net>
(cherry picked from commit 4d0a333ef1)
2025-03-05 16:27:49 +00:00
Tomasz Kamiński 750d691077 libstdc++: Fix subrange conversion to pair-like [PR119121]
Fix regression introduced by r14-8710-g65b4cba9d6a9ff

	PR libstdc++/119121

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (__detail::__pair_like_convertible_from):
	Use `_Tp` in `is_reference_v` check
	* testsuite/std/ranges/subrange/tuple_like.cc: New tests for
	pair-like conversion

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 95b2f8d8fb)
2025-03-05 13:54:34 +01:00
GCC Administrator e834308d70 Daily bump. 2025-03-05 00:25:17 +00:00
Patrick Palka 2ed37595a3 c++: generic lambda, implicit 'this' capture, xobj memfn [PR119038]
When a generic lambda calls an overload set containing an iobj member
function we speculatively capture 'this'.  We need to do the same
for an xobj member function.

	PR c++/119038

gcc/cp/ChangeLog:

	* lambda.cc (maybe_generic_this_capture): Consider xobj
	member functions as well, not just iobj.  Update function
	comment.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 1a150f1f68)
2025-03-04 13:26:58 -05:00
Richard Sandiford df9c10d18b aarch64: Add missing simd requirements for INS [PR118531]
In g:b096a6ebe9d9f9fed4c105f6555f724eb32af95c I'd forgotten
to gate some uses of INS on TARGET_SIMD.

gcc/
	PR target/118531
	* config/aarch64/aarch64.md (*insv_reg<mode>_<SUBDI_BITS>)
	(*aarch64_bfi<GPI:mode><ALLX:mode>_<SUBDI_BITS>)
	(*aarch64_bfidi<ALLX:mode>_subreg_<SUBDI_BITS>): Add missing
	simd requirements.

gcc/testsuite/
	* gcc.target/aarch64/ins_bitfield_1a.c: New test.
	* gcc.target/aarch64/ins_bitfield_3a.c: Likewise.
	* gcc.target/aarch64/ins_bitfield_5a.c: Likewise.

(cherry picked from commit 1b88204214)
2025-03-04 17:49:31 +00:00
Richard Sandiford aa8793daa4 Fix folding of BIT_NOT_EXPR for POLY_INT_CST [PR118976]
There was an embarrassing typo in the folding of BIT_NOT_EXPR for
POLY_INT_CSTs: it used - rather than ~ on the poly_int.  Not sure
how that happened, but it might have been due to the way that
~x is implemented as -1 - x internally.

gcc/
	PR tree-optimization/118976
	* fold-const.cc (const_unop): Use ~ rather than - for BIT_NOT_EXPR.
	* config/aarch64/aarch64.cc (aarch64_test_sve_folding): New function.
	(aarch64_run_selftests): Run it.

(cherry picked from commit 78380fd7f7)
2025-03-04 17:49:30 +00:00
Richard Earnshaw 7fb1d7bff1 arm: xfail gcc.target/arm/unsigned-extend-1.c for thumb1
Partial backport of 2a502f9e4c.

gcc/testsuite:
	* gcc.target/arm/unsigned-extend-1.c: Expand check for any
	insn suggesting a zero-extend.  XFAIL for thumb1 code.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2025-03-04 18:05:13 +01:00
Torbjörn SVENSSON a42ef0938f testsuite: arm: Use effective-target for pr68674.c test
gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr68674.c: Use effective-target arm_arch_v7a
	and arm_libc_fp_abi.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 879fd9c822)
2025-03-04 16:34:46 +01:00
Jakub Jelinek e79fc5a7bc testsuite: Add tests for already fixed PR [PR119071]
Uros' r15-7793 fixed this PR as well, I'm just committing tests
from the PR so that it can be closed.

2025-03-04  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/119071
	* gcc.dg/pr119071.c: New test.
	* gcc.c-torture/execute/pr119071.c: New test.

(cherry picked from commit ccf9db9a6f)
2025-03-04 16:20:54 +01:00
Uros Bizjak b7b8307893 combine: Discard REG_UNUSED note in i2 when register is also referenced in i3 [PR118739]
The combine pass is trying to combine:

Trying 16, 22, 21 -> 23:
   16: r104:QI=flags:CCNO>0
   22: {r120:QI=r104:QI^0x1;clobber flags:CC;}
      REG_UNUSED flags:CC
   21: r119:QI=flags:CCNO<=0
      REG_DEAD flags:CCNO
   23: {r110:QI=r119:QI|r120:QI;clobber flags:CC;}
      REG_DEAD r120:QI
      REG_DEAD r119:QI
      REG_UNUSED flags:CC

and creates the following two insn sequence:

modifying insn i2    22: r104:QI=flags:CCNO>0
      REG_DEAD flags:CC
deferring rescan insn with uid = 22.
modifying insn i3    23: r110:QI=flags:CCNO<=0
      REG_DEAD flags:CC
deferring rescan insn with uid = 23.

where the REG_DEAD note in i2 is not correct, because the flags
register is still referenced in i3.  In try_combine() megafunction,
we have this part:

--cut here--
    /* Distribute all the LOG_LINKS and REG_NOTES from I1, I2, and I3.  */
    if (i3notes)
      distribute_notes (i3notes, i3, i3, newi2pat ? i2 : NULL,
			elim_i2, elim_i1, elim_i0);
    if (i2notes)
      distribute_notes (i2notes, i2, i3, newi2pat ? i2 : NULL,
			elim_i2, elim_i1, elim_i0);
    if (i1notes)
      distribute_notes (i1notes, i1, i3, newi2pat ? i2 : NULL,
			elim_i2, local_elim_i1, local_elim_i0);
    if (i0notes)
      distribute_notes (i0notes, i0, i3, newi2pat ? i2 : NULL,
			elim_i2, elim_i1, local_elim_i0);
    if (midnotes)
      distribute_notes (midnotes, NULL, i3, newi2pat ? i2 : NULL,
			elim_i2, elim_i1, elim_i0);
--cut here--

where the compiler distributes REG_UNUSED note from i2:

   22: {r120:QI=r104:QI^0x1;clobber flags:CC;}
      REG_UNUSED flags:CC

via distribute_notes() using the following:

--cut here--
	  /* Otherwise, if this register is used by I3, then this register
	     now dies here, so we must put a REG_DEAD note here unless there
	     is one already.  */
	  else if (reg_referenced_p (XEXP (note, 0), PATTERN (i3))
		   && ! (REG_P (XEXP (note, 0))
			 ? find_regno_note (i3, REG_DEAD,
					    REGNO (XEXP (note, 0)))
			 : find_reg_note (i3, REG_DEAD, XEXP (note, 0))))
	    {
	      PUT_REG_NOTE_KIND (note, REG_DEAD);
	      place = i3;
	    }
--cut here--

Flags register is used in I3, but there already is a REG_DEAD note in I3.
The above condition doesn't trigger and continues in the "else" part where
REG_DEAD note is put to I2.  The proposed solution corrects the above
logic to trigger every time the register is referenced in I3, avoiding the
"else" part.

	PR rtl-optimization/118739

gcc/ChangeLog:

	* combine.cc (distribute_notes) <case REG_UNUSED>: Correct the
	logic when the register is used by I3.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit a92dc3fe31)
2025-03-04 16:20:16 +01:00
Martin Jambor 455ea90d6e ipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243)
Among other things, IPA-SRA checks whether splitting out a bit of an
aggregate or something passed by reference would lead into a clash
with an already known IPA-CP constant a way which would cause problems
later on.  Unfortunately the test is done only in
adjust_parameter_descriptions and is missing when accesses are
propagated from callees to callers, which leads to miscompilation
reported as PR 118243 (where the callee is a function created by
ipa-split).

The matter is then further complicated by the fact that we consider
complex numbers as scalars even though they can be modified piecemeal
(IPA-CP can detect and propagate the pieces separately too) which then
confuses the parameter manipulation machinery furter.

This patch simply adds the missing check to avoid the IPA-SRA
transform in these cases too, which should be suitable for backporting
to all affected release branches.  It is a bit of a shame as in the PR
testcase we do propagate both components of the complex number in
question and the transformation phase could recover.  I have some
prototype patches in this direction but that is something for (a)
stage 1.

gcc/ChangeLog:

2025-02-10  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118243
	* ipa-sra.cc (pull_accesses_from_callee): New parameters
	caller_ipcp_ts and param_idx.  Check that scalar pulled accesses would
	not clash with a known IPA-CP aggregate constant.
	(param_splitting_across_edge): Pass IPA-CP transformation summary and
	caller parameter index to pull_accesses_from_callee.

gcc/testsuite/ChangeLog:

2025-02-10  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118243
	* g++.dg/ipa/pr118243.C: New test.

(cherry picked from commit 0bffcd469e)
2025-03-04 14:54:16 +01:00
GCC Administrator dd09f67512 Daily bump. 2025-03-04 00:22:48 +00:00
Filip Kastl 6ffbc711af gimple: sccopy: Prune removed statements from SCCs [PR117919]
While writing the sccopy pass I didn't realize that 'replace_uses_by ()' can
remove portions of the CFG.  This happens when replacing arguments of some
statement results in the removal of an EH edge.  Because of this sccopy can
then work with GIMPLE statements that aren't part of the IR anymore.  In
PR117919 this triggered an assertion within the pass which assumes that
statements the pass works with are reachable.

This patch tells the pass to notice when a statement isn't in the IR anymore
and remove it from it's worklist.

	PR tree-optimization/117919

gcc/ChangeLog:

	* gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Prune
	statements that 'replace_uses_by ()' removed.

gcc/testsuite/ChangeLog:

	* g++.dg/pr117919.C: New test.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
(cherry picked from commit 5349aa2acc)
2025-03-03 17:03:59 +01:00
GCC Administrator 19cf198287 Daily bump. 2025-03-03 00:24:30 +00:00
Jeff Law c1535f242f [PR target/116720] Fix test for valid mempair operands
So this BZ is a case where we incorrectly indicated that the operand array was
suitable for the t-head load/store pair instructions.

In particular there's a test which checks alignment, but that happens *before*
we know if the operands are going to be reversed.  So the routine reported the
operands are suitable.

At a later point the operands have been reversed into the proper order and we
realize the alignment test should have failed, resulting in the unrecognized
insn.

This fixes the code by moving the reversal check earlier and actually swapping
the local variables with the operands.  That in turn allows for simpler testing
of alignments, ordering, etc.

I've tested this on rv32 and rv64 in my tester.  I don't offhand know if the
patch from Filip that's been causing headaches for the RISC-V port has been
reverted/fixed.  So there's a nonzero chance the pre-commit CI tester will
fail.  I'll keep an eye on it and act appropriately.

	PR target/116720
gcc/
	* config/riscv/thead.cc (th_mempair_operands_p): Test for
	aligned memory after swapping operands.  Simplify test for
	first memory access as well.

gcc/testsuite/
	* gcc.target/riscv/pr116720.c: New test.

(cherry picked from commit 0b06abe027)
2025-03-02 14:58:50 -07:00
Iain Buclaw 04b5c8b90c d: Fix comparing uninitialized memory in dstruct.d [PR116961]
Floating-point emulation in the D front-end is done via a type named
`struct longdouble`, which in GDC is a small interface around the
real_value type. Because the D code cannot include gcc/real.h directly,
a big enough buffer is used for the data instead.

On x86_64, this buffer is actually bigger than real_value itself, so
when a new longdouble object is created with

    longdouble r;
    real_from_string3 (&r.rv (), buffer, mode);
    return r;

there is uninitialized padding at the end of `r`.  This was never a
problem when D was implemented in C++ (until GCC 12) as comparing two
longdouble objects with `==' would be forwarded to the relevant
operator== overload that extracted the underlying real_value.

However when the front-end was translated to D, such conditions were
instead rewritten into identity comparisons

    return exp.toReal() is CTFloat.zero

The `is` operator gets lowered as a call to `memcmp() == 0', which is
where the read of uninitialized memory occurs, as seen by valgrind.

==26778== Conditional jump or move depends on uninitialised value(s)
==26778==    at 0x911F41: dmd.dstruct._isZeroInit(dmd.expression.Expression) (dstruct.d:635)
==26778==    by 0x9123BE: StructDeclaration::finalizeSize() (dstruct.d:373)
==26778==    by 0x86747C: dmd.aggregate.AggregateDeclaration.determineSize(ref const(dmd.location.Loc)) (aggregate.d:226)
[...]

To avoid accidentally reading uninitialized data, explicitly initialize
all `longdouble` variables with an empty constructor on C++ side of the
implementation before initializing underlying real_value type it holds.

	PR d/116961

gcc/d/ChangeLog:

	* d-codegen.cc (build_float_cst): Change new_value type from real_t to
	real_value.
	* d-ctfloat.cc (CTFloat::fabs): Default initialize the return value.
	(CTFloat::ldexp): Likewise.
	(CTFloat::parse): Likewise.
	* d-longdouble.cc (longdouble::add): Likewise.
	(longdouble::sub): Likewise.
	(longdouble::mul): Likewise.
	(longdouble::div): Likewise.
	(longdouble::mod): Likewise.
	(longdouble::neg): Likewise.
	* d-port.cc (Port::isFloat32LiteralOutOfRange): Likewise.
	(Port::isFloat64LiteralOutOfRange): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr116961.d: New test.

(cherry picked from commit f7bc17ebc9)
2025-03-02 16:45:59 +01:00
GCC Administrator faa15a3453 Daily bump. 2025-03-02 00:24:16 +00:00
GCC Administrator 451791981b Daily bump. 2025-03-01 13:10:14 +00:00
Jonathan Wakely 3a8d05b61a libstdc++: Use init_priority attribute for tzdb globals [PR118811]
When linking statically to libstdc++.a (or to libstdc++_nonshared.a in
the RHEL devtoolset compiler) there's a static initialization order
problem where user code might be constructed before the
std::chrono::tzdb_list globals, and so might try to use them after
they've already been destroyed.

Use the init_priority attribute on those globals so that they are
initialized early. Since r15-7511-g4e7f74225116e7 we can disable the
warnings for using a reserved priority using a diagnostic pragma.

However, for the backport to the release branch the warnings can only be
suppressed by defining the objects in a system header.  Move them to a
new file that uses '#pragma GCC system_header' and then include that in
tzdb.cc.

libstdc++-v3/ChangeLog:

	PR libstdc++/118811
	* src/c++20/tzdb.cc (tzdb_list::_Node): Move definitions of
	static data members to new header.
	* src/c++20/tzdb_globals.h: New header. Use init_priority
	attribute on static data members.
	* testsuite/std/time/tzdb_list/pr118811.cc: New test.

(cherry picked from commit 99f57446e6)
2025-02-28 15:33:22 +00:00
Jonathan Wakely 9c02bad2b5 libstdc++: Hide std::tuple internals from Doxygen docs
libstdc++-v3/ChangeLog:

	* include/std/tuple: Do not include implementation details in
	Doxygen documentation.

(cherry picked from commit 5cfee9360c)
2025-02-28 15:33:22 +00:00
Jonathan Wakely 2b9449c2c1 libstdc++: Fix outdated comment in <stacktrace>
My r15-998-g2a83084ce55363 change replaced the use of nothrow
operator new with a call to __get_temporary_buffer, so update the
comment to match.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (_Impl::_M_allocate): Fix outdated
	comment.

(cherry picked from commit e8302282cd)
2025-02-28 15:33:21 +00:00
Jonathan Wakely 85f4136aa8 libstdc++: Reuse temporary buffer utils in <stacktrace>
The non-throwing allocation logic in std::stacktrace duplicates the
logic in <bits/stl_tempbuf.h>, so we can just reuse those utilities.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
	Use __detail::__get_temporary_buffer.
	(basic_stacktrace::_Impl::_M_deallocate): Use
	__detail::__return_temporary_buffer.

(cherry picked from commit 2a83084ce5)
2025-02-28 15:33:21 +00:00
Jonathan Wakely 8443a90c43 libstdc++: Optimize std::basic_string_view::starts_with
We get smaller code at all optimization levels by not creating a
temporary object, just comparing lengths first and then using
traits_type::compare. This does less work than calling substr then
operator==.

libstdc++-v3/ChangeLog:

	* include/std/string_view (starts_with(basic_string_view)):
	Compare lengths first and then call traits_type::compare
	directly.

(cherry picked from commit 482f97e79f)
2025-02-28 15:33:21 +00:00
Jonathan Wakely 3b9885ac4d libstdc++: Do not use C++11 alignof in C++98 mode [PR104395]
When -faligned-new (or Clang's -faligned-allocation) is used our
allocators try to support extended alignments, gated on the
__cpp_aligned_new macro. However, because they use alignof(_Tp) which is
not a keyword in C++98 mode, using -std=c++98 -faligned-new results in
errors from <memory> and other headers.

We could change them to use __alignof__ instead of alignof, but that
would potentially alter the result of the conditions, because e.g.
alignof(long long) != __alignof__(long long) on some targets. That's
probably not an issue for any types with extended alignment, so maybe it
would be a safe change.

For now, it seems acceptable to just disable the extended alignment
support in C++98 mode, so that -faligned-new enables std::align_val_t
and the corresponding operator new overloads, but doesn't affect
std::allocator, __gnu_cxx::__bitmap_allocator etc.

libstdc++-v3/ChangeLog:

	PR libstdc++/104395
	* include/bits/new_allocator.h: Disable extended alignment
	support in C++98 mode.
	* include/bits/stl_tempbuf.h: Likewise.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* testsuite/ext/104395.cc: New test.

(cherry picked from commit 03d3aeb0e0)
2025-02-28 15:33:21 +00:00
Jonathan Wakely c795413cf3 libstdc++: Fix warning regressions in <bits/stl_tempbuf.h>
I caused some new warnings with -Wsystem-headers with my recent changes
to std::get_temporary_buffer and std::_Temporary_buffer. There's a
-Wsign-compare warning which can be avoided by casting the ptrdiff_t
argument to size_t (which also conveniently rejects negative values).

There's also a -Wdeprecated-declarations warning because I moved where
std::get_temporary_buffer is called, but didn't move the diagnostic
pragmas that suppress the warning for calling it.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h (__get_temporary_buffer): Cast
	argument to size_t to handle negative values and suppress
	-Wsign-compare warning.
	(_Temporary_buffer): Move diagnostic pragmas to new location of
	call to std::get_temporary_buffer.

(cherry picked from commit 8c52adcf5f)
2025-02-28 15:33:21 +00:00
Jonathan Wakely fb9a2af992 libstdc++: Handle extended alignment in std::get_temporary_buffer [PR105258]
This adds extended alignment support to std::get_temporary_buffer etc.
so that when std::stable_sort uses a temporary buffer it works for
overaligned types.

Also simplify the _Temporary_buffer type by using RAII for the
allocation, via a new data member. This simplifies the _Temporary_buffer
constructor and destructor by makingthem only responsible for
constructing and destroying the elements, not managing the memory.

libstdc++-v3/ChangeLog:

	PR libstdc++/105258
	* include/bits/stl_tempbuf.h (__detail::__get_temporary_buffer):
	New function to do allocation for get_temporary_buffer, with
	extended alignment support.
	(__detail::__return_temporary_buffer): Support extended
	alignment.
	(get_temporary_buffer): Use __get_temporary_buffer.
	(return_temporary_buffer): Support extended alignment. Add
	deprecated attribute.
	(_Temporary_buffer): Move allocation and deallocation into a
	subobject and remove try-catch block in constructor.
	(__uninitialized_construct_buf): Use argument deduction for
	value type.
	* testsuite/20_util/temporary_buffer.cc: Add dg-warning for new
	deprecated warning.
	* testsuite/25_algorithms/stable_sort/overaligned.cc: New test.

(cherry picked from commit b0efdcbf58)
2025-02-28 15:33:20 +00:00
Giuseppe D'Angelo f83bc0edb5 libstdc++: fix a dangling reference crash in ranges::is_permutation [PR118160]
The code was caching the result of `invoke(proj, *it)` in a local
`auto &&` variable. The problem is that this may create dangling
references, for instance in case `proj` is `std::identity` (the common
case) and `*it` produces a prvalue: lifetime extension does not
apply here due to the expressions involved.

Instead, store (and lifetime-extend) the result of `*it` in a separate
variable, then project that variable. While at it, also forward the
result of the projection to the predicate, so that the predicate can
act on the proper value category.

libstdc++-v3/ChangeLog:

	PR libstdc++/118160
	PR libstdc++/100249
	* include/bits/ranges_algo.h (__is_permutation_fn): Avoid a
	dangling reference by storing the result of the iterator
	dereference and the result of the projection in two distinct
	variables, in order to lifetime-extend each one.
	Forward the projected value to the predicate.
	* testsuite/25_algorithms/is_permutation/constrained.cc: Add a
	test with a range returning prvalues. Test it in a constexpr
	context, in order to rely on the compiler to catch UB.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 2a2bd96d0d)
2025-02-28 15:27:46 +00:00
Jonathan Wakely 6561de33c3 libstdc++: Qualify calls in <bits/stl_uninitialized.h> to prevent ADL
libstdc++-v3/ChangeLog:

	* include/bits/stl_uninitialized.h (uninitialized_default_construct)
	(uninitialized_default_construct_n, uninitialized_value_construct)
	(uninitialized_value_construct_n): Qualify calls to prevent ADL.

(cherry picked from commit 09ca26cd24)
2025-02-28 15:27:46 +00:00
Jonathan Wakely 70452d24fa libstdc++: Add missing character to __to_wstring_numeric map
The mapping from char to wchar_t needs to handle 'i' and 'I' but those
were absent from the table that is used for some non-ASCII encodings.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__to_wstring_numeric): Add 'i'
	and 'I' to mapping.

(cherry picked from commit e1937cf33a)
2025-02-28 15:27:45 +00:00
Jonathan Wakely 6e97d601f1 libstdc++: Add missing equality comparison in new tests [PR117921]
These new tests fail in Debug Mode because the allocator types aren't
equality comparable.

libstdc++-v3/ChangeLog:

	PR libstdc++/117921
	* testsuite/23_containers/set/modifiers/swap/adl.cc: Add
	equality comparison for Allocator.
	* testsuite/23_containers/unordered_set/modifiers/swap-2.cc:
	Likewise.

(cherry picked from commit 5cdd78b397)
2025-02-28 15:27:45 +00:00
Jonathan Wakely dd8866d796 libstdc++: Use ADL swap for containers' function objects [PR117921]
The standard says that Compare, Pred and Hash objects should be swapped
as described in [swappable.requirements] which means calling swap
unqualified with std::swap visible to name lookup.

libstdc++-v3/ChangeLog:

	PR libstdc++/117921
	* include/bits/hashtable_policy.h (_Hash_code_base::_M_swap):
	Use ADL swap for Hash members.
	(_Hashtable_base::_M_swap): Use ADL swap for _Equal members.
	* include/bits/stl_tree.h (_Rb_tree::swap): Use ADL swap for
	_Compare members.
	* testsuite/23_containers/set/modifiers/swap/adl.cc: New test.
	* testsuite/23_containers/unordered_set/modifiers/swap-2.cc: New
	test.

(cherry picked from commit 0368c42507)
2025-02-28 15:27:45 +00:00
Jonathan Wakely 1921b0c043 libstdc++: Add debug assertions to std::list and std::forward_list
While working on fancy pointer support for the linked lists I noticed
they didn't have any debug assertions. This adds the obvious non-empty
assertions to front() and back().

libstdc++-v3/ChangeLog:

	* include/bits/forward_list.h (forward_list::front): Add
	non-empty assertions.
	* include/bits/stl_list.h (list::front, list::back): Add
	non-empty assertions.

(cherry picked from commit e7aa614d73)
2025-02-28 15:27:45 +00:00
Jonathan Wakely a66d9754b8 libstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]
Do not report an error for (is_other(s1) && is_other(s2)) as the
standard originally said, nor for (is_other(s1) || is_other(s2)) as
libstdc++ was doing. We can compare inode numbers for special files and
so give sensible answers.

libstdc++-v3/ChangeLog:

	PR libstdc++/118158
	* src/c++17/fs_ops.cc (fs::equivalent): Remove error reporting
	for is_other(s1) && is_other(s2) case, as per LWG 2937.
	* testsuite/27_io/filesystem/operations/pr118158.cc: New test.

(cherry picked from commit 301a961ffd)
2025-02-28 15:27:45 +00:00
GCC Administrator ac47b3b766 Daily bump. 2025-02-28 00:23:33 +00:00
Jason Merrill 59b0946824 testsuite: limit concepts-pr67774.C to C++20
This test breaks with -std=c++23 -fconcepts-ts, but works at the default
-std=c++20 -fconcepts-ts.  Since we're removing -fconcepts-ts in GCC 15,
it's not worth trying to fix this conflict.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-pr67774.C: Change target to c++20_only.
2025-02-27 12:26:48 -05:00
Jason Merrill 7e7a1b6126 c++: NRVO, constexpr, lambda [PR118053]
Here during constant evaluation we encounter a VAR_DECL with DECL_VALUE_EXPR
of the RESULT_DECL, where the latter has been adjusted for
pass-by-invisible-reference.  We already had the code to deal with this, we
just need to use it in the non-capture case of DECL_VALUE_EXPR as well.

	PR c++/118053

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_constant_expression): Generalize
	DECL_VALUE_EXPR invisiref handling.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-lambda1.C: New test.

(cherry picked from commit de66529f2e)
2025-02-27 12:26:48 -05:00
Jason Merrill a72e782528 c++: disable initializer_list transformation
PRs 118673 and 118285 are wrong-code bugs with the transformation to build
an initializer_list backing array from a static array of the initializer
expressions; let's disable that transformation on the GCC 14 branch.

	PR c++/118673
	PR c++/118285

gcc/cp/ChangeLog:

	* call.cc (convert_like_internal) [ck_list]: Stop using
	maybe_init_list_as_array for GCC 14.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/initlist-opt5.C: Add xfail.
2025-02-27 12:26:22 -05:00
Iain Sandoe 19bf2732ae c++: Update const_decl handling after r15-7259 [PR118673].
Objective-C++ uses CONST_DECLs to hold constant string objects
these should also be treated as mergable lvalues.

	PR c++/118673

gcc/cp/ChangeLog:

	* tree.cc (lvalue_kind): Mark CONST_DECLs as mergable
	when they are also TREE_STATIC.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-02-27 05:34:09 -05:00
Jason Merrill b4f66a79e0 c++: init-list opt and lvalue initializers [PR118673]
When fn returns {extension}, the ArrayRef in the initializer_list is
constructed to point to 'extension', the variable with static storage
duration.  The optimization was copying extension's value into a temporary
array and constructing the ArrayRef to point to that temporary copy instead,
resulting in a dangling pointer.  So suppress this optimization if the
element constructor takes a reference and the initializer is a non-mergeable
lvalue.

	PR c++/118673

gcc/cp/ChangeLog:

	* call.cc (maybe_init_list_as_array): Check for lvalue
	initializers.
	* cp-tree.h (enum cp_lvalue_kind_flags): Add clk_mergeable.
	* tree.cc (lvalue_kind): Return it.
	(non_mergeable_glvalue_p): New.
	(test_lvalue_kind): Adjust.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-opt6.C: New test.
2025-02-27 05:34:09 -05:00
Jason Merrill 3003d404b4 c++: constexpr VEC_INIT_EXPR [PR118285]
cxx_eval_vec_init_1 was doing the wrong thing for an array of
self-referential class type; just evaluating the TARGET_EXPR initializer
creates a new object that refers to the TARGET_EXPR_SLOT, if we want it to
refer properly to the initialization target we need to provide it.

	PR c++/118285

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_vec_init_1): Build INIT_EXPR for
	initializing a class.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-opt7.C: New test.
2025-02-27 05:34:09 -05:00
Haochen Jiang ba488a332a i386: Treat Granite Rapids/Granite Rapids-D similar as Sapphire Rapids in x86-tune.def
Since GNR, GNR-D are both P-core based, we should treat them
just like SPR for now.

gcc/ChangeLog:

	* config/i386/x86-tune.def
	(X86_TUNE_DEST_FALSE_DEP_FOR_GLC): Add GNR, GNR-D.
	(X86_TUNE_AVOID_256FMA_CHAINS): Ditto.
	(X86_TUNE_AVX512_MOVE_BY_PIECES): Ditto.
	(X86_TUNE_AVX512_STORE_BY_PIECES): Ditto.
2025-02-27 16:08:24 +08:00
GCC Administrator 460a803a62 Daily bump. 2025-02-27 00:23:41 +00:00
GCC Administrator d13602d210 Daily bump. 2025-02-26 00:23:33 +00:00
Stefan Schulze Frielinghaus ce4cb48c33 s390: Fix s390_valid_shift_count() for TI mode [PR118835]
During combine we may end up with

(set (reg:DI 66 [ _6 ])
     (ashift:DI (reg:DI 72 [ x ])
                (subreg:QI (and:TI (reg:TI 67 [ _1 ])
                                   (const_wide_int 0x0aaaaaaaaaaaaaabf))
                           15)))

where the shift count operand does not trivially fit the scheme of
address operands.  Reject those operands, especially since
strip_address_mutations() expects expressions of the form
(and ... (const_int ...)) and fails for (and ... (const_wide_int ...)).

Thus, be more strict here and accept only CONST_INT operands.  Done by
replacing immediate_operand() with const_int_operand() which is enough
since the former only additionally checks for LEGITIMATE_PIC_OPERAND_P
and targetm.legitimate_constant_p which are always true for CONST_INT
operands.

While on it, fix indentation of the if block.

gcc/ChangeLog:

	PR target/118835
	* config/s390/s390.cc (s390_valid_shift_count): Reject shift
	count operands which do not trivially fit the scheme of
	address operands.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/pr118835.c: New test.

(cherry picked from commit ac9806dae3)
2025-02-25 11:49:59 +01:00
Richard Biener 09cc01ca00 jit/118780 - make sure to include dlfcn.h when plugin support is disabled
The following makes the dlfcn.h explicitly requested which avoids
build failure when JIT is enabled but plugin support disabled as
currently the include is conditional on plugin support.

	PR jit/118780
gcc/
	* system.h: Check INCLUDE_DLFCN_H for including dlfcn.h instead
	of ENABLE_PLUGIN.
	* plugin.cc: Define INCLUDE_DLFCN_H.

gcc/jit/
	* jit-playback.cc: Define INCLUDE_DLFCN_H.
	* jit-result.cc: Likewise.

(cherry picked from commit e22962538f)
2025-02-25 08:31:51 +01:00
GCC Administrator dbb91c392d Daily bump. 2025-02-25 00:22:55 +00:00
Richard Biener 93e7442f08 tree-optimization/118717 - store commoning vs. abnormals
When we sink common stores in cselim or the sink pass we have to
make sure to not introduce overlapping lifetimes for abnormals
used in the ref.  The easiest is to avoid sinking stmts which
reference abnormals at all which is what the following does.

	PR tree-optimization/118717
	* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1):
	Do not common stores referencing abnormal SSA names.
	* tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise.

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

(cherry picked from commit fbcbbfe2bf)
2025-02-24 11:47:57 +01:00
Richard Biener 422f65add3 tree-optimization/118653 - ICE in vectorizable_live_operation
The checking code didn't take into account debug uses.

	PR tree-optimization/118653
	* tree-vect-loop.cc (vectorizable_live_operation): Also allow
	out-of-loop debug uses.

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

(cherry picked from commit 6a510dea7f)
2025-02-24 11:47:40 +01:00
Richard Biener 62ae21874e tree-optimization/117979 - failed irreducible loop update from DCE
When CD-DCE creates forwarders to reduce false control dependences
it fails to update the irreducible state of edge and the forwarder
block in case the fowarder groups both normal (entry) and edges
from an irreducible region (necessarily backedges).  This is because
when we split the first edge, if that's a normal edge, the forwarder
and its edge to the original block will not be marked as part
of the irreducible region but when we then redirect an edge from
within the region it becomes so.

The following fixes this up.

Note I think creating a forwarder that includes backedges is
likely not going to help, but at this stage I don't want to change
the CFG going into DCE.  For regular loops we'll have a single
entry and a single backedge by means of loop init and will never
create a forwarder - so this is solely happening for irreducible
regions where it's harder to prove that such forwarder doesn't help.

	PR tree-optimization/117979
	* tree-ssa-dce.cc (make_forwarders_with_degenerate_phis):
	Properly update the irreducible region state.

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

(cherry picked from commit eca04660a2)
2025-02-24 11:47:22 +01:00
Richard Biener a760d18770 tree-optimization/117119 - ICE with int128 IV in dataref analysis
Here's another fix for a missing check that an IV value fits in a
HIW.  It's originally from Stefan.

	PR tree-optimization/117119
	* tree-data-ref.cc (initialize_matrix_A): Check whether
	an INTEGER_CST fits in HWI, otherwise return chrec_dont_know.

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

Co-Authored-By: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
(cherry picked from commit d3904a3ad9)
2025-02-24 11:46:54 +01:00
Richard Biener 79025d0713 tree-optimization/117113 - ICE with unroll-and-jam
When there's an inner loop without virtual header PHI but the outer
loop has one the fusion process cannot handle the need to create
an inner loop virtual header PHI.  Punt in this case.

	PR tree-optimization/117113
	* gimple-loop-jam.cc (unroll_jam_possible_p): Detect when
	we cannot handle virtual SSA update.

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

(cherry picked from commit 0675eb1748)
2025-02-24 11:46:46 +01:00
Richard Biener 5759b5f4af lto/113207 - fix free_lang_data_in_type
When we process function types we strip volatile and const qualifiers
after building a simplified type variant (which preserves those).
The qualified type handling of both isn't really compatible, so avoid
bad interaction by swapping this, first dropping const/volatile
qualifiers and then building the simplified type thereof.

	PR lto/113207
	* ipa-free-lang-data.cc (free_lang_data_in_type): First drop
	const/volatile qualifiers from function argument types,
	then build a simplified type.

	* gcc.dg/pr113207.c: New testcase.

(cherry picked from commit a55e14b239)
2025-02-24 11:46:34 +01:00
Richard Biener 7c36056ede rtl-optimization/118662 - wrong combination of vector sign-extends
The following fixes an issue in the RTL combiner where we correctly
combine two vector sign-extends with a vector load

Trying 7, 9 -> 10:
    7: r106:V4QI=[r119:DI]
      REG_DEAD r119:DI
    9: r108:V4HI=sign_extend(vec_select(r106:V4QI#0,parallel))
   10: r109:V4SI=sign_extend(vec_select(r108:V4HI#0,parallel))
      REG_DEAD r108:V4HI

to

modifying insn i2     9: r109:V4SI=sign_extend([r119:DI])

but since r106 is used we wrongly materialize it using a subreg:

modifying insn i3    10: r106:V4QI=r109:V4SI#0

which of course does not work for modes with more than one component,
specifically vector and complex modes.

	PR rtl-optimization/118662
	* combine.cc (try_combine): When re-materializing a load
	from an extended reg by a lowpart subreg make sure we're
	not dealing with vector or complex modes.

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

(cherry picked from commit 343e1083eb)
2025-02-24 09:05:24 +01:00
Richard Biener a42b180b4b tree-optimization/117424 - invalid LIM of trapping ref
The following addresses a bug in tree_could_trap_p leading to
hoisting of a possibly trapping, because of out-of-bound, access.
We only ensured the first accessed byte is within a decl there,
the patch makes sure the whole base of the reference is within it.
This is pessimistic if a handled component would then subset to
a sub-object within the decl but upcasting of a decl to larger
types should be uncommon, questionable, and wrong without
-fno-strict-aliasing.

The testcase is a bit fragile, but I could not devise a (portable)
way to ensure an out-of-bound access to a decl would fault.

	PR tree-optimization/117424
	* tree-eh.cc (tree_could_trap_p): Verify the base is
	fully contained within a decl.

	* gcc.dg/tree-ssa/ssa-lim-25.c: New testcase.

(cherry picked from commit f1e776ce58)
2025-02-24 09:05:24 +01:00
Richard Biener fbecb7df97 tree-optimization/116906 - unsafe PRE with never executed edges
When we're computing ANTIC for PRE we treat edges to not yet visited
blocks as having a maximum ANTIC solution to get at an optimistic
solution in the iteration.  That assumes the edges visted eventually
execute.  This is a wrong assumption that can lead to wrong code
(and not only non-optimality) when possibly trapping expressions
are involved as the testcases in the PR show.  The following mitigates
this by pruning trapping expressions from ANTIC computed when
maximum sets are involved.

	PR tree-optimization/116906
	* tree-ssa-pre.cc (prune_clobbered_mems): Add clean_traps
	argument.
	(compute_antic_aux): Direct prune_clobbered_mems to prune
	all traps when any MAX solution was involved in the ANTIC
	computation.
	(compute_partial_antic_aux): Adjust.

	* gcc.dg/pr116906-1.c: New testcase.
	* gcc.dg/pr116906-2.c: Likewise.

(cherry picked from commit 3e1bd6470e)
2025-02-24 09:05:24 +01:00
Richard Biener 95c98c5368 tree-optimization/115494 - PRE PHI translation and ranges
When we PHI translate dependent expressions we keep SSA defs in
place of the translated expression in case the expression itself
did not change even though it's context did and thus the validity
of ranges associated with it.  That eventually leads to simplification
errors given we violate the precondition that used SSA defs fed to
vn_valueize are valid to use (including their associated ranges).
The following makes sure to replace those with new representatives
always, not only when the dependent expression translation changed it.

The fix was originally discovered by Michael Morin.

	PR tree-optimization/115494
	* tree-ssa-pre.cc (phi_translate_1): Always generate a
	representative for translated dependent expressions.

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

Co-Authored-By: Mikael Morin <mikael@gcc.gnu.org>
(cherry picked from commit ea1deefe54)
2025-02-24 09:05:24 +01:00
Richard Biener c886bd9ab2 tree-optimization/114052 - consider infinite sub-loops when lowering iter bound
When we walk stmts to find always executed stmts with UB in the last
iteration to be able to reduce the iteration count by one we fail
to consider infinite subloops in the last iteration that would make
such stmt not execute.  The following adds this.

	PR tree-optimization/114052
	* tree-ssa-loop-niter.cc (maybe_lower_iteration_bound): Check
	for infinite subloops we might not exit.

	* gcc.dg/pr114052-1.c: New testcase.
2025-02-24 09:05:24 +01:00
Richard Biener a3871eead4 tree-optimization/112859 - add comment
This adds a comment before the workaround, indicating flaky
dependence analysis.

	PR tree-optimization/112859
	* tree-loop-distribution.cc
	(loop_distribution::pg_add_dependence_edges): Add comment.

(cherry picked from commit 3ccbc8c9d1)
2025-02-24 09:05:24 +01:00
Richard Biener 2456fd2c73 tree-optimization/112859 - bogus loop distribution
When we get a zero distance vector we still have to check for the
situation of a common inner loop with zero distance.  But we can
still allow a zero distance for the loop we distribute
(gcc.dg/tree-ssa/ldist-33.c is such a case).  This is because
zero distances in non-outermost loops are a misrepresentation
of dependence by dependence analysis.

Note that test coverage of loop distribution of loop nests is
very low.

	PR tree-optimization/112859
	PR tree-optimization/115347
	* tree-loop-distribution.cc
	(loop_distribution::pg_add_dependence_edges): For a zero
	distance vector still make sure to not have an inner
	loop with zero distance.

	* gcc.dg/torture/pr112859.c: New testcase.
	* gcc.dg/torture/pr115347.c: Likewise.

(cherry picked from commit 04ba130040)
2025-02-24 09:05:24 +01:00
GCC Administrator fd386b345a Daily bump. 2025-02-24 00:23:13 +00:00
GCC Administrator c3da353948 Daily bump. 2025-02-23 00:22:25 +00:00
Harald Anlauf 02eedd2932 Fortran: passing of derived type to VALUE,OPTIONAL dummy argument [PR118080]
For scalar OPTIONAL dummy arguments with the VALUE attribute, gfortran
passes a hidden flag to denote presence or absence of the actual argument
for intrinsic types.  Extend this treatment to derived type (user-defined
as well as from intrinsic module ISO_C_BINDING).

	PR fortran/118080

gcc/fortran/ChangeLog:

	* gfortran.texi: Adjust documentation.
	* trans-decl.cc (create_function_arglist): Adjust to pass hidden
	presence flag also for derived type dummies with VALUE,OPTIONAL
	attribute.
	* trans-expr.cc (gfc_conv_expr_present): Expect hidden presence
	flag also for derived type dummies with VALUE,OPTIONAL attribute.
	(conv_cond_temp): Adjust to allow derived types.
	(conv_dummy_value): Extend to handle derived type dummies with
	VALUE,OPTIONAL attribute.
	(gfc_conv_procedure_call): Adjust for actual arguments passed to
	derived type dummies with VALUE,OPTIONAL attribute.
	* trans-types.cc (gfc_get_function_type): Adjust fndecl for
	hidden presence flag.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 8859dce903)
2025-02-22 15:12:25 +01:00
GCC Administrator 68d50c95af Daily bump. 2025-02-22 00:22:48 +00:00
GCC Administrator 3a6e6b8d66 Daily bump. 2025-02-21 00:22:41 +00:00
Lulu Cheng 9ffecde121 LoongArch: Fix the issue of function jump out of range caused by crtbeginS.o [PR118844].
Due to the presence of R_LARCH_B26 in
/usr/lib/gcc/loongarch64-linux-gnu/14/crtbeginS.o, its addressing
range is [PC-128MiB, PC+128MiB-4]. This means that when the code
segment size exceeds 128MB, linking with lld will definitely fail
(ld will not fail because the order of the two is different).

The linking order:
  lld: crtbeginS.o + .text + .plt
  ld : .plt + crtbeginS.o + .text

To solve this issue, add '-mcmodel=extreme' when compiling crtbeginS.o.

	PR target/118844

libgcc/ChangeLog:

	* config/loongarch/t-crtstuff: Add '-mcmodel=extreme'
	to CRTSTUFF_T_CFLAGS_S.

(cherry picked from commit ae14d7d04d)
2025-02-20 20:28:05 +08:00
GCC Administrator 2abb1f170a Daily bump. 2025-02-20 00:21:46 +00:00
GCC Administrator cbff381ded Daily bump. 2025-02-19 00:22:07 +00:00
GCC Administrator fdc640e553 Daily bump. 2025-02-18 00:22:39 +00:00
Andreas Tobler 4467274fac FreeBSD: Stop linking _p libs for -pg as of FreeBSD 14
As of FreeBSD version 14, FreeBSD no longer provides profiled system
libraries like libc_p and libpthread_p. Stop linking against them if
the FreeBSD major version is 14 or more.

gcc:
	* config/freebsd-spec.h: Change fbsd-lib-spec for FreeBSD > 13,
	do not link against profiled system libraries if -pg is invoked.
	Add a define to note about this change.
	* config/aarch64/aarch64-freebsd.h: Use the note to inform if
	-pg is invoked on FreeBSD > 13.
	* config/arm/freebsd.h: Likewise.
	* config/i386/freebsd.h: Likewise.
	* config/i386/freebsd64.h: Likewise.
	* config/riscv/freebsd.h: Likewise.
	* config/rs6000/freebsd64.h: Likewise.
	* config/rs6000/sysv4.h: Likeise.
2025-02-17 09:38:16 +01:00
Lulu Cheng 889fb66025 LoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843].
PR target/118843

gcc/ChangeLog:

	* config/loongarch/loongarch-c.cc
	(loongarch_update_cpp_builtins): Fix macro definition issues.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/pr118843.c: New test.

(cherry picked from commit ee579b7c25)
2025-02-17 14:55:19 +08:00
Haochen Jiang de562367d3 i386: Deprecate -m[no-]avx10.1 and make -mno-avx10.1-512 to disable the whole AVX10.1
Based on the feedback we got, we would like to re-alias avx10.x to 512
bit in the future. This leaves the current avx10.1 alias to 256 bit
inconsistent. Since it has been there for GCC 14.1 and GCC 14.2,
we decide to deprecate avx10.1 alias. The current proposal is not
adding it back in the future, but it might change if necessary.

For -mno- options, it is confusing what it is disabling when it comes
to avx10. Since there is barely usage enabling AVX10 with 512 bit
then disabling it, we will only provide -mno-avx10.x options in the
future, disabling the whole AVX10.x. If someone really wants to disable
512 bit after enabling it, -mavx10.x-512 -mno-avx10.x -mavx10.x-256 is
the only way to do that since we also do not want to break the usual
expression on -m- options enabling everything mentioned.

However, for avx10.1, since we deprecated avx10.1, there is no reason
we should have -mno-avx10.1. Thus, we need to keep -mno-avx10.1-[256,512].
To avoid confusion, we will make -mno-avx10.1-512 to disable the
whole AVX10.1 set to match the future -mno-avx10.x.

gcc/ChangeLog:

	* common/config/i386/i386-common.cc
	(OPTION_MASK_ISA2_AVX2_UNSET): Change AVX10.1 unset macro.
	(OPTION_MASK_ISA2_AVX10_1_256_UNSET): Removed.
	(OPTION_MASK_ISA2_AVX10_1_512_UNSET): Removed.
	(OPTION_MASK_ISA2_AVX10_1_UNSET): New.
	(ix86_handle_option): Adjust AVX10.1 unset macro.
	* common/config/i386/i386-isas.h: Remove avx10.1.
	* config/i386/i386-options.cc
	(ix86_valid_target_attribute_inner_p): Ditto.
	(ix86_option_override_internal): Adjust warning message.
	* config/i386/i386.opt: Remove mavx10.1.
	* config/i386/i386.opt.urls: Regenerated.
	* doc/extend.texi: Remove avx10.1 and adjust doc.
	* doc/sourcebuild.texi: Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx10_1-1.c: Change to avx10.1-256.
	* gcc.target/i386/avx10_1-13.c: Ditto.
	* gcc.target/i386/avx10_1-14.c: Ditto.
	* gcc.target/i386/avx10_1-21.c: Ditto.
	* gcc.target/i386/avx10_1-22.c: Ditto.
	* gcc.target/i386/avx10_1-23.c: Ditto.
	* gcc.target/i386/avx10_1-24.c: Ditto.
	* gcc.target/i386/avx10_1-3.c: Ditto.
	* gcc.target/i386/avx10_1-5.c: Ditto.
	* gcc.target/i386/avx10_1-6.c: Ditto.
	* gcc.target/i386/avx10_1-8.c: Ditto.
	* gcc.target/i386/avx10_1-12.c: Adjust warning message.
	* gcc.target/i386/avx10_1-19.c: Ditto.
	* gcc.target/i386/avx10_1-17.c: Adjust to no-avx10.1-512.
2025-02-17 14:10:51 +08:00
Haochen Jiang 31cbac836b i386: Do not check vector size conflict when AVX512 is not explicitly set [PR 118815]
When AVX512 is not explicitly set, we should not take EVEX512 bit into
consideration when checking vector size. It will solve the intrin header
file reporting warnings when compiling with -Wsystem-headers.

However, there is side effect on the usage for '-march=xxx -mavx10.1-256',
where xxx is with AVX512. It will not report warning on vector size for now.
Since it is a rare usage, we will take it.

gcc/ChangeLog:

	PR target/118815
	* config/i386/i386-options.cc (ix86_option_override_internal):
	Do not check vector size conflict when AVX512 is not explicitly
	set.
2025-02-17 11:03:39 +08:00
GCC Administrator 5dcf4ec72d Daily bump. 2025-02-17 00:26:29 +00:00
GCC Administrator e4f3c404c8 Daily bump. 2025-02-16 00:26:05 +00:00
GCC Administrator b56db32e8b Daily bump. 2025-02-15 00:26:41 +00:00
Gaius Mulley 9c38d0a79c [PATCH] PR modula2/118761: gm2 driver doesnt behave as gcc for -fhelp=BLA
This patch enables the gm2 driver to handle -fsyntax-only -fhelp=optimizers,
for example, correctly without terminating with gm2: fatal error:
no input files.

gcc/m2/ChangeLog:

	PR modula2/118761
	* gm2spec.cc (lang_specific_driver): Add case clauses for
	OPT__help, OPT__help_ set in_added_libraries to 0 and early
	return.

(cherry picked from commit 3c5422e719)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-02-14 19:17:02 +00:00
Harald Anlauf 5ec7193faa Fortran: fix initialization of allocatable non-deferred character [PR59252]
PR fortran/59252

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_trans_subcomponent_assign): Initialize
	allocatable non-deferred character with NULL properly.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 818c36a85e)
2025-02-14 16:45:45 +01:00
GCC Administrator 3e7c48f4ee Daily bump. 2025-02-14 00:22:20 +00:00
Marek Polacek 88ca0670c7 driver: -fhardened and -z lazy/-z norelro [PR117739]
As the manual states, using "-fhardened -fstack-protector" will produce
a warning because -fhardened wants to enable -fstack-protector-strong,
but it can't since it's been overriden by the weaker -fstack-protector.

-fhardened also attempts to enable -Wl,-z,relro,-z,now.  By the same
logic as above, "-fhardened -z norelro" or "-fhardened -z lazy" should
produce the same warning.  But we don't detect this combination, so
this patch fixes it.  I also renamed a variable to better reflect its
purpose.

Also don't check warn_hardened in process_command, since it's always
true there.

Also tweak wording in the manual as Jon Wakely suggested on IRC.

	PR driver/117739

gcc/ChangeLog:

	* doc/invoke.texi: Tweak wording for -Whardened.
	* gcc.cc (driver_handle_option): If -z lazy or -z norelro was
	specified, don't enable linker hardening.
	(process_command): Don't check warn_hardened.

gcc/testsuite/ChangeLog:

	* c-c++-common/fhardened-16.c: New test.
	* c-c++-common/fhardened-17.c: New test.
	* c-c++-common/fhardened-18.c: New test.
	* c-c++-common/fhardened-19.c: New test.
	* c-c++-common/fhardened-20.c: New test.
	* c-c++-common/fhardened-21.c: New test.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
(cherry picked from commit a134dcd8a0)
2025-02-13 17:22:15 -05:00
Gaius Mulley 3d961691e0 [PATCH] PR modula2/115112 Incorrect line debugging information occurs during INC builtin
This patch fixes location bugs in BuildDecProcedure,
BuildIncProcedure, BuildInclProcedure, BuildExclProcedure and
BuildThrow.  All these procedure functions use the token position
passed as a parameter (rather than from the quad stack).  It also
fixes location bugs in CheckRangeIncDec to ensure that the token
position is stored on the quad stack before calling subsidiary
procedure functions.

gcc/m2/ChangeLog:

	PR modula2/115112
	* gm2-compiler/M2Quads.mod (BuildPseudoProcedureCall): Pass
	tokno to each build procedure.
	(BuildThrowProcedure): New parameter functok.
	(BuildIncProcedure): New parameter proctok.
	Pass proctok on the quad stack during every push.
	(BuildDecProcedure): Ditto.
	(BuildInclProcedure): New parameter proctok.
	(BuildExclProcedure): New parameter proctok.

gcc/testsuite/ChangeLog:

	PR modula2/115112
	* gm2/pim/run/pass/dectest.mod: New test.
	* gm2/pim/run/pass/inctest.mod: New test.

(cherry picked from commit 4d0faaaaf9)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-02-13 18:17:17 +00:00
Nathaniel Shead 9fa962a5db c++: Constrain visibility for CNTTPs with internal types [PR118849]
While looking into PR118846 I noticed that we don't currently constrain
the linkage of functions involving CNTTPs of internal-linkage types.  It
seems to me that this would be sensible to do.

	PR c++/118849

gcc/cp/ChangeLog:

	* decl2.cc (min_vis_expr_r): Constrain visibility according to
	the type of decl_constant_var_p decls.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-02-13 22:31:52 +11:00
GCC Administrator 6569505d4c Daily bump. 2025-02-13 00:22:19 +00:00
Gaius Mulley 209de720fb [PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr
This patch builds access to the gcc builtins clz, clzl, clzll,
ctz, ctzl and ctzll within m2builtins.cc.  The patch provides
modula2 api access to clz, clzll, ctz and ctzll though the
Builtins definition module.  This PR was raised because of
PR118689.

gcc/m2/ChangeLog:

	PR modula2/118703
	* gm2-gcc/m2builtins.cc (define_builtin_gcc): New function.
	(m2builtins_init): Call define_builtin_gcc.
	* gm2-libs/Builtins.def (clz): New procedure function.
	(clzll): Ditto.
	(ctz): Ditto.
	(ctzll): Ditto.
	* gm2-libs/Builtins.mod (clz): New procedure function.
	(clzll): Ditto.
	(ctz): Ditto.
	(ctzll): Ditto.
	* gm2-libs/cbuiltin.def (clz): New procedure function.
	(clzll): Ditto.
	(ctz): Ditto.
	(ctzll): Ditto.

gcc/testsuite/ChangeLog:

	PR modula2/118703
	* gm2/builtins/run/pass/testbitfns.mod: New test.

(cherry picked from commit e2d32c81a9)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-02-12 21:26:04 +00:00
GCC Administrator 0075e4a842 Daily bump. 2025-02-12 00:22:40 +00:00
H.J. Lu 5f47dc6e9a x86: Correct ASM_OUTPUT_SYMBOL_REF
x is not a macro argument.  It just happens to work as final.cc passes
x for 2nd argument:

final.cc:      ASM_OUTPUT_SYMBOL_REF (file, x);

	PR target/118825
	* config/i386/i386.h (ASM_OUTPUT_SYMBOL_REF): Replace x with
	SYM.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 7317fc0b03)
2025-02-12 05:22:49 +08:00
Haochen Jiang cec0326137 i386: Fix AVX512BW intrin header with __OPTIMIZE__ [PR 118813]
When moving intrins around for AVX10 implementation in GCC 14,
the intrin _kshiftli_mask32 and _kshiftri_mask32 are wrongly
wrapped by "#if __OPTIMIZE__" instead of "#ifdef __OPTIMIZE__",
leading to the intrin file not `-Wsystem-headers -Wundef` clean
since r14-4490.

gcc/ChangeLog:

	PR target/118813
	* config/i386/avx512bwintrin.h: Fix wrong __OPTIMIZE__
	wrap.
2025-02-11 10:51:56 +08:00
GCC Administrator 818b5cac39 Daily bump. 2025-02-11 00:22:44 +00:00
Jakub Jelinek 7cb0224424 i386: Fix ICE with conditional QI/HI vector maxmin [PR118776]
The following testcase ICEs starting with GCC 12 since r12-4526
although the bug has been introduced already in r12-2751.
The problem was in the addition of cond_<code><mode> define_expand
which uses nonimmediate_operand predicates for both maxmin operands
for all VI1248_AVX512VLBW modes.  It works fine with
VI48_AVX512VL modes because the <code><mode>3_mask VI48_AVX512VL
define_expand uses ix86_fixup_binary_operands_no_copy and the
*avx512f_<code><mode>3<mask_name> VI48_AVX512VL define_insn uses
% in constraint and !(MEM_P && MEM_P) check in condition (and
<code><mode>3 define_expand with VI124_256_AVX512F_AVX512BW iterator
does that too), but eventhough the 8-bit and 16-bit element maxmin
is commutative too, the <mask_codefor><code><mode>3<mask_name>
define_insn with VI12_AVX512VL iterator didn't use % in constraint
to make it commutative.  So, e.g. cond_umaxv32qi define_expand
allowed nonimmediate_operand for both umax operands, but used
gen_umaxv32qi_mask which wasn't commutative and only allowed
nonimmediate_operand for the second operand.

The following patch fixes it by keeping the <code><mode>3
VI124_256_AVX512F_AVX512BW define_expand as is (it does
ix86_fixup_binary_operands_no_copy) but extending the
<code><mode>3_mask define_expand from VI48_AVX512VL to
VI1248_AVX512VLBW which keeps the current modes with their
ISA conditions and adds the VI12_AVX512VL modes under additional
TARGET_AVX512BW condition, and turning the actual define_insn
into an * prefixed name (which it was before just for the non-masked
case) and having the same commutative operand handling as in other
define_insns.

2025-02-08  Jakub Jelinek  <jakub@redhat.com>

	PR target/118776
	* config/i386/sse.md (<code><mode>3_mask): Use VI1248_AVX512VLBW
	iterator rather than VI48_AVX512VL.
	(<mask_codefor><code><mode>3<mask_name>): Rename to ...
	(*avx512bw_<code><mode>3<mask_name>): ... this.  Use
	nonimmediate_operand rather than register_operand predicate and %v
	rather than v constraint for operand 1 and adjust condition to reject
	MEMs in both operand 1 and 2.

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

(cherry picked from commit 64d8ea056a)
2025-02-10 15:54:59 +01:00
Jakub Jelinek 08bfa32ae9 c++: Fix up name independent decl in structured binding handling in range for [PR115586]
cp_parser_range_for temporarily reverts IDENTIFIER_BINDING changes
to hide the decls from the structured bindings from lookup during
parsing of the expression after :
If there are 2 or more name independent decls, we undo IDENTIFIER_BINDING
for the same name multiple times, even when just one has been added
(with a TREE_LIST inside of it as decl).

The following patch fixes it by handling the _ name at most once, the
later loop will DTRT then and just reinstall the temporarily hidden
binding with the TREE_LIST in there.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/115586
	* parser.cc (cp_parser_range_for): For name independent decls in
	structured bindings, only push the name/binding once per
	structured binding.

	* g++.dg/cpp26/name-independent-decl9.C: New test.
	* g++.dg/cpp26/name-independent-decl10.C: New test.

(cherry picked from commit ca7c6d1212)
2025-02-10 15:54:07 +01:00
Jakub Jelinek 6cd1daf520 c++: Don't use CLEANUP_EH_ONLY for new expression cleanup [PR118763]
The following testcase is miscompiled since r12-6325 stopped
preevaluating the initializers for new expression.
If evaluating the initializers throws, there is a correct cleanup
for that, but it is marked CLEANUP_EH_ONLY.  While in standard
C++ that is just fine, if it has statement expressions, it can
return or goto out of the expression and we should delete the
pointer in that case too.

There is already a sentry variable initialized to true and
set to false after everything is initialized and used as a guard
for the cleanup, so just removing the CLEANUP_EH_ONLY flag does
everything we need.  And in the normal case of the initializer
not using statement expressions at least with -O2 we get the same code,
while the change changes one
try { sentry = true; ... sentry = false; } catch { if (sentry) delete ...; }
into
try { sentry = true; ... sentry = false; } finally { if (sentry) delete ...; }
optimizations will see that sentry is false when reaching the finally
other than through an exception.

Though, wonder what other CLEANUP_EH_ONLY cleanups might be an issue
with statement expressions.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118763
	* init.cc (build_new_1): Don't set CLEANUP_EH_ONLY.

	* g++.dg/asan/pr118763.C: New test.

(cherry picked from commit fcecc74cb3)
2025-02-10 15:53:27 +01:00
Jakub Jelinek 6f5ada5716 c++: Allow constexpr reads from volatile std::nullptr_t objects [PR118661]
As mentioned in the PR, https://eel.is/c++draft/conv.lval#note-1
says that even volatile reads from std::nullptr_t typed objects actually
don't read anything and https://eel.is/c++draft/expr.const#10.9
says that even those are ok in constant expressions.

So, the following patch adjusts the r9-4793 changes to have an exception
for NULLPTR_TYPE.
As [conv.lval]/3 also talks about accessing to inactive member, I've added
testcase to cover that as well.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118661
	* constexpr.cc (potential_constant_expression_1): Don't diagnose
	lvalue-to-rvalue conversion of volatile lvalue if it has NULLPTR_TYPE.
	* decl2.cc (decl_maybe_constant_var_p): Return true for constexpr
	decls with NULLPTR_TYPE even if they are volatile.

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

(cherry picked from commit 6c8e6d6feb)
2025-02-10 15:51:46 +01:00
Jakub Jelinek ab9518d081 loop-iv, riscv: Fix get_biv_step_1 for RISC-V [PR117506]
The following test ICEs on RISC-V at least latently since
r14-1622-g99bfdb072e67fa3fe294d86b4b2a9f686f8d9705 which added
RISC-V specific case to get_biv_step_1 to recognize also
({zero,sign}_extend:DI (plus:SI op0 op1))

The reason for the ICE is that op1 in this case is CONST_POLY_INT
which unlike the really expected VOIDmode CONST_INTs has its own
mode and still satisfies CONSTANT_P.
GET_MODE (rhs) (SImode) is different from outer_mode (DImode), so
the function later does
        *inner_step = simplify_gen_binary (code, outer_mode,
                                           *inner_step, op1);
but that obviously ICEs because while *inner_step is either VOIDmode
or DImode, op1 has SImode.

The following patch fixes it by extending op1 using code so that
simplify_gen_binary can handle it.  Another option would be
to change the !CONSTANT_P (op1) 3 lines above this to
!CONST_INT_P (op1), I think it isn't very likely that we get something
useful from other constants there.

2025-02-06  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/117506
	* loop-iv.cc (get_biv_step_1): For {ZERO,SIGN}_EXTEND
	of PLUS apply {ZERO,SIGN}_EXTEND to op1.

	* gcc.dg/pr117506.c: New test.
	* gcc.target/riscv/pr117506.c: New test.

(cherry picked from commit bb9cee8928)
2025-02-10 15:51:04 +01:00
Jakub Jelinek 916daed4ec icf: Compare call argument types in certain cases and asm operands [PR117432]
compare_operand uses operand_equal_p under the hood, which e.g. for
INTEGER_CSTs will just match the values rather regardless of their types.
Now, in many comparing the type is redundant, if we have
  x_2 = y_3 + 1;
we've already compared the type for the lhs and also for rhs1, there won't
be any surprises on rhs2.
As noted in the PR, there are cases where the type of the operand is the
sole place of information and we don't want to ICF merge functions if the
types differ.
One case is stdarg functions, arguments passed to ..., it is different
if we pass 1, 1L, 1LL.
Another case are the K&R unprototyped functions (sure, gone in C23).
And yet another case are inline asm operands, "r" (1) is different from "r"
(1L) from "r" (1LL).

So, the following patch determines based on lack of fntype (e.g. for
internal functions), or on !prototype_p, or on stdarg_p (in that case
using number of named arguments) which arguments need to have type checked
and does that, plus compares types on inline asm operands (maybe it would be
enough to do that just for input operands but we have just a routine to
handle both and I didn't feel we need to differentiate).

Furthermore, I've noticed fntype{1,2} isn't actually compared if it is a
direct call (gimple_call_fndecl is non-NULL).  That is wrong too, we could
have
  void (*fn) (int, long long) = (void (*) (int, long long)) foo;
  fn (1, 1LL);
in one case and
  void (*fn) (long long, int) = (void (*) (long long, int)) foo;
  fn (1LL, 1);
in another, both folded into a direct call of foo with different
gimple_call_fntype.  Sure, one of them would be UB at runtime (or both), but
what if we ICF merge it into something that into the one UB at runtime
and the program actually calls the correct one only?

2025-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/117432
	* ipa-icf-gimple.cc (func_checker::compare_asm_inputs_outputs):
	Also return_false if operands have incompatible types.
	(func_checker::compare_gimple_call): Check fntype1 vs. fntype2
	compatibility for all non-internal calls and assume fntype1 and
	fntype2 are non-NULL for those.  For calls to non-prototyped
	calls or for stdarg_p functions after the last named argument (if any)
	check type compatibility of call arguments.

	* gcc.c-torture/execute/pr117432.c: New test.
	* gcc.target/i386/pr117432.c: New test.

(cherry picked from commit ebd111a289)
2025-02-10 15:50:48 +01:00
Jakub Jelinek 3f475f4ffa niter: Make build_cltz_expr more robust [PR118689]
Since my r15-7223 the niter analysis can recognize one loop during bootstrap
as being ctz like.
The patch just turned
@@ -2173,7 +2173,7 @@ PROC m2pim_NumberIO_BinToStr (CARDINAL x
   _T535_44 = &buf[i.40_2]{lb: 1 sz: 4};
   _T536_45 = x_21 & 1;
   *_T535_44 = _T536_45;
-  _T537_47 = x_21 / 2;
+  _T537_47 = x_21 >> 1;
   x_48 = _T537_47;
   # DEBUG x => x_48
   if (x_48 != 0)
which is not a big deal for the number_of_iterations_cltz optimization, it
recognizes both right shift by 1 and unsigned division by 2 (and similarly
for clz left shift by 1 or multiplication by 2).
But starting with forwprop1 that change also resulted in
@@ -1875,9 +1875,9 @@ PROC m2pim_NumberIO_BinToStr (CARDINAL x
   i.40_2 = (INTEGER) _T530_34;
   _T536_45 = x_21 & 1;
   MEM <CARDINAL[1:64]> [(CARDINAL *)&buf][i.40_2]{lb: 1 sz: 4} = _T536_45;
-  _T537_47 = x_21 / 2;
+  _T537_47 = x_21 >> 1;
   # DEBUG x => _T537_47
-  if (x_21 > 1)
+  if (_T537_47 != 0)
     goto <bb 3>; [INV]
   else
     goto <bb 8>; [INV]
and apparently it is only the latter form that number_of_iterations_cltz
pattern matches, not the former (after all, that was the exact reason
for r15-7223).
The problem is that build_cltz_expr assumes if IFN_C[LT]Z can't be used it
can use the __builtin_c[lt]z{,l,ll} builtins, and while most of the FEs do
create them, modula 2 does not.

The following patch just lets us punt if the FE doesn't build those builtins.
I've filed a PR against modula2 so that they add the builtins too.

2025-01-31  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/118689
	PR modula2/115032
	* tree-ssa-loop-niter.cc (build_cltz_expr): Return NULL_TREE if fn is
	NULL and use_ifn is false.

(cherry picked from commit 85e1714b06)
2025-02-10 15:47:17 +01:00
Arsen Arsenović acd0e21e96 d: give dependency files better filenames [PR118477]
Currently, the dependency files for root-file.o and common-file.o were
both d/.deps/file.Po, which would cause parallel builds to fail
sometimes with:

  make[3]: Leaving directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  make[3]: Entering directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  mv: cannot stat 'd/.deps/file.TPo': No such file or directory
  make[3]: *** [/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/gcc-14-20240511/gcc/d/Make-lang.in:421: d/root-file.o] Error 1 shuffle=131581365

Also, this means that dependencies of one of root-file or common-file
are missing when developing.  After this patch, those two files get
assigned dependency files d/.deps/root-file.Po and
d/.deps/common-file.Po respectively, so match the actual object
files in the d/ subdirectory.

There are other files with similar conflicts (mangle-package.o,
visitor-package.o for instance).

2025-01-29  Arsen Arsenović  <arsen@aarsen.me>
	    Jakub Jelinek  <jakub@redhat.com>

	PR d/118477
	* Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F))
	instead of $(*F).

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
(cherry picked from commit d9ac0ad1e9)
2025-02-10 15:47:05 +01:00
Jakub Jelinek b7553f76a7 c++: Return false from __is_bounded_array for zero-sized arrays [PR118655]
This is basically Marek's PR114479 r14-9759 __is_array fix applied to
__is_bounded_array as well.  Similarly to that trait, when not using
the builtin it returned false for zero sized arrays but when using
the builtin it returns true.

2025-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118655
	* semantics.cc (trait_expr_value) <case CPTK_IS_BOUNDED_ARRAY>: Return
	false for zero-sized arrays.

	* g++.dg/ext/is_bounded_array.C: Extend.

(cherry picked from commit 3a6ddbf7b2)
2025-02-10 15:46:24 +01:00
Jakub Jelinek 1dac899a10 combine: Fix up make_extraction [PR118638]
The following testcase is miscompiled at -Os on x86_64-linux.
The problem is during make_compound_operation of
(ashiftrt:SI (ashift:SI (mult:SI (reg:SI 107 [ a_5 ])
            (const_int 3 [0x3]))
        (const_int 31 [0x1f]))
    (const_int 31 [0x1f]))
where it incorrectly returns
(mult:SI (sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 2 [0x2])
        (const_int 0 [0]))
    (const_int 3 [0x3]))
which isn't obviously true, the former returns either 0 or -1 depending
on the least significant bit of the multiplication,
the latter returns either 0 or -3 depending on the second least significant
bit of the multiplication argument.

The bug has been introduced in PR96998 r11-4563, which added handling of x
* (2^N) similar to x << N.  In the above case, pos is 0 and len is 1,
sign extracting a single least significant bit of the multiplication.
As 3 is not a power of 2, shift_amt is -1.
But IN_RANGE (-1, 1, 1 - 1) is still true, because the basic requirement of
IN_RANGE that LOWER is not greater than UPPER is violated.
The intention of using 1 as LOWER is to avoid matching multiplication by 1,
that really shouldn't appear in the IL.  But to avoid violating IN_RANGE
requirement, we need to verify that len is at least 2.

I've added this len > 1 check to the inner if rather than outer because I
think for GCC 16 we should add a further optimization.
In the particular case of 1 least significant bit sign extraction from
multiplication by 3, we could actually say it is equivalent to
(sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 1 [0x2])
        (const_int 0 [0]))
That is because 3 is an odd number and multiplication by 2 will yield the
least significant bit 0 (we are sign extracting just one) and so the
multiplication doesn't change anything on the outcome.
More generally, even for larger len, multiplication by C which is
(1 << X) + 1 where X is >= len should be optimizable just to extraction
of the multiplicand's least significant len bits.

2025-01-28  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/118638
	* combine.cc (make_extraction): Only optimize (mult x 2^n) if len is
	larger than 1.

	* gcc.c-torture/execute/pr118638.c: New test.

(cherry picked from commit b529a41724)
2025-02-10 15:43:51 +01:00
Jakub Jelinek 15e66f7c24 c++: Only destruct elts of array for new expression if exception is thrown during the initialization [PR117827]
The following testcase r12-6328, because the elements of the array
are destructed twice, once when the callee encounters delete[] p;
and then second time when the exception is thrown.
The array elts should be only destructed if exception is thrown from
one of the constructors during the build_vec_init emitted code in case of
new expressions, but when the new expression completes, it is IMO
responsibility of user code to delete[] it when it is no longer needed.

So, the following patch uses the cleanup_flags argument to build_vec_init
to get notified of the flags that need to be changed when the expression
is complete and build_disable_temp_cleanup to do the changes.

2025-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR c++/117827
	* init.cc (build_new_1): Pass address of a make_tree_vector ()
	initialized gc tree vector to build_vec_init and append
	build_disable_temp_cleanup to init_expr from it.

	* g++.dg/init/array66.C: New test.

(cherry picked from commit ce268ca2a9)
2025-02-10 15:42:47 +01:00
Jakub Jelinek 7a369b6a55 tree-assume: Fix UB in assume_query [PR118605]
The assume_query constructor does
assume_query::assume_query (function *f, bitmap p) : m_parm_list (p),
                                                     m_func (f)
where m_parm_list is bitmap &.  This is compile time UB, because
as soon as the constructor returns, m_parm_list reference is still
bound to the parameter of the constructor which is no longer in scope.

Now, one possible fix would be change the ctor argument to be bitmap &,
but that doesn't really work because in the only user of that class
we have
      auto_bitmap decls;
...
      assume_query query (fun, decls);
and auto_bitmap just has
  operator bitmap () { return &m_bits; }
Could be perhaps const bitmap &, but why?  bitmap is a pointer:
typedef class bitmap_head *bitmap;
and the EXECUTE_IF_SET_IN_BITMAP macros don't really change that point,
they just inspect what is inside of that bitmap_head the pointer points
to.

So, the simplest I think is avoid references (which cause even worse
code as it has to be dereferenced twice rather than once).

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/118605
	* tree-assume.cc (assume_query::m_parm_list): Change type
	from bitmap & to bitmap.

(cherry picked from commit 27a05f8d11)
2025-02-10 15:42:16 +01:00
Jakub Jelinek 2c9ebb837b builtins: Store unspecified value to *exp for inf/nan [PR114877]
The fold_builtin_frexp folding for NaN/Inf just returned the first argument
with evaluating second arguments side-effects, rather than storing something
to what the second argument points to.

The PR argues that the C standard requires the function to store something
there but what exactly is stored is unspecified, so not storing there
anything can result in UB if the value isn't initialized and is read later.

glibc and newlib store there 0, musl apparently doesn't store anything.

The following patch stores there zero (or would you prefer storing there
some other value, 42, INT_MAX, INT_MIN, etc.?; zero is cheapest to form
in assembly though) and adjusts the test so that it
doesn't rely on not storing there anything but instead checks for
-Wmaybe-uninitialized warning to find out that something has been stored
there.
Unfortunately I had to disable the NaN tests for -O0, while we can fold
__builtin_isnan (__builtin_nan ("")) at compile time, we can't fold
__builtin_isnan ((i = 0, __builtin_nan (""))) at compile time.
fold_builtin_classify uses just tree_expr_nan_p and if that isn't true
(because expr is a COMPOUND_EXPR with tree_expr_nan_p on the second arg),
it does
      arg = builtin_save_expr (arg);
      return fold_build2_loc (loc, UNORDERED_EXPR, type, arg, arg);
and that isn't folded at -O0 further, as we wrap it into SAVE_EXPR and
nothing propagates the NAN to the comparison.
I think perhaps tree_expr_nan_p etc. could have case COMPOUND_EXPR:
added and recurse on the second argument, but that feels like stage1
material to me if we want to do that at all.

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/114877
	* builtins.cc (fold_builtin_frexp): Handle rvc_nan and rvc_inf cases
	like rvc_zero, return passed in arg and set *exp = 0.

	* gcc.dg/torture/builtin-frexp-1.c: Add -Wmaybe-uninitialized as
	dg-additional-options.
	(bar): New function.
	(TESTIT_FREXP2): Rework the macro so that it doesn't test whether
	nothing has been stored to what the second argument points to, but
	instead that something has been stored there, whatever it is.
	(main): Temporarily don't enable the nan tests for -O0.

(cherry picked from commit d19b0682f1)
2025-02-10 15:40:02 +01:00
Jakub Jelinek 2349c6a442 match.pd: Fix (FTYPE) N CMP (FTYPE) M optimization for GENERIC [PR118522]
The last case of this optimization assumes that if 2 integral types
have same precision and TYPE_UNSIGNED, then they are uselessly convertible.
While that is very likely the case for GIMPLE, it is not the case for
GENERIC, so the following patch adds there a convert so that the
optimization produces also valid GENERIC.  Without it we got
(int) p == b where b had _BitInt(32) type, so incompatible types.

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

	PR tree-optimization/118522
	* match.pd ((FTYPE) N CMP (FTYPE) M): Add convert, as in GENERIC
	integral types with the same precision and sign might actually not
	be compatible types.

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

(cherry picked from commit 3ab9eb6946)
2025-02-10 15:37:43 +01:00
Jakub Jelinek 0faffd526d vec.h: Properly destruct elements in auto_vec auto storage [PR118400]
For T with non-trivial destructors, we were destructing objects in the
vector on release only when not using auto storage of auto_vec.

The following patch calls truncate (0) instead of m_vecpfx.m_num clearing,
and truncate takes care of that destruction:
  unsigned l = length ();
  gcc_checking_assert (l >= size);
  if (!std::is_trivially_destructible <T>::value)
    vec_destruct (address () + size, l - size);
  m_vecpfx.m_num = size;

2025-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/118400
	* vec.h (vec<T, va_heap, vl_ptr>::release): Call m_vec->truncate (0)
	instead of clearing m_vec->m_vecpfx.m_num.

(cherry picked from commit 43f4d44beb)
2025-02-10 15:37:26 +01:00
GCC Administrator 282dedf440 Daily bump. 2025-02-10 00:22:46 +00:00
Dimitry Andric 796849274c libgcc: On FreeBSD use GCC's crt objects for static linking
Add crtbeginT.o to extra_parts on FreeBSD. This ensures we use GCC's
crt objects for static linking. Otherwise it could mix crtbeginT.o
from the base system with libgcc's crtend.o, possibly leading to
segfaults.

libgcc:
	PR target/118685
	* config.host (*-*-freebsd*): Add crtbeginT.o to extra_parts.

Signed-off-by: Dimitry Andric <dimitry@andric.com>
2025-02-09 12:23:58 +01:00
GCC Administrator f93541fc86 Daily bump. 2025-02-09 00:21:48 +00:00
GCC Administrator 4098d67d92 Daily bump. 2025-02-08 00:22:01 +00:00
Paul Thomas 1cd744a682 Fortran: FIx ICE in associate with elemental function [PR118750]
2025-02-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/118750
	* resolve.cc (resolve_assoc_var): If the target expression has
	a rank, do not use gfc_expression_rank, since it will return 0
	if the function is elemental. Resolution will have produced the
	correct rank.

gcc/testsuite/
	PR fortran/118750
	* gfortran.dg/associate_72.f90: New test.

(cherry picked from commit a03303b4d5)
2025-02-07 12:56:38 +00:00
Paul Thomas 4d4c5ec93d Fortran: Fix error recovery for bad component arrayspecs [PR108434]
2025-01-11  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/
	PR fortran/108434
	* class.cc (generate_finalization_wrapper): To avoid memory
	leaks from callocs, return immediately if the derived type
	error flag is set.
	* decl.cc (build_struct): If the declaration of a derived type
	or class component does not have a deferred arrayspec, correct,
	set the error flag of the derived type and emit an immediate
	error.

gcc/testsuite/
	PR fortran/108434
	* gfortran.dg/pr108434.f90 : Add tests from comment 1.

(cherry picked from commit d64ca15351)
2025-02-07 12:56:38 +00:00
GCC Administrator 373e2dbc5d Daily bump. 2025-02-07 00:24:04 +00:00
Harald Anlauf ca652aebd3 Fortran: host association issue with symbol in COMMON block [PR108454]
When resolving a flavorless symbol that is already registered with a COMMON
block, and which neither has the intrinsic, generic, or external attribute,
skip searching among interfaces to avoid false resolution to a derived type
of the same name.

	PR fortran/108454

gcc/fortran/ChangeLog:

	* resolve.cc (resolve_common_blocks): Initialize variable.
	(resolve_symbol): If a symbol is already registered with a COMMON
	block, do not search for an interface with the same name.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit d6418fe226)
2025-02-06 20:41:55 +01:00
Lulu Cheng 9a09fc9b84 LoongArch: Fix ICE caused by illegal calls to builtin functions [PR118561].
PR target/118561

gcc/ChangeLog:

	* config/loongarch/loongarch-builtins.cc
	(loongarch_expand_builtin_lsx_test_branch):
	NULL_RTX will not be returned when an error is detected.
	(loongarch_expand_builtin): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/pr118561.c: New test.

(cherry picked from commit 50d2bde68a)
2025-02-06 19:06:30 +08:00
GCC Administrator 8bca14a479 Daily bump. 2025-02-06 00:22:56 +00:00
Sebastian Huber 6a4df914f6 RTEMS: Add Cortex-M33 multilib
Enable use of Armv8-M instruction set.

Account for CVE-2021-35465 mitigation [PR102035].
The -mfix-cmse-cve-2021-35465 option is enabled by default,
if -mcpu=cortex-m33 is used.

gcc/

	* config/arm/t-rtems: Add Cortex-M33 multilib.

(cherry picked from commit f2a8f3c364)
2025-02-05 01:25:09 +01:00
GCC Administrator 6f08060518 Daily bump. 2025-02-05 00:23:06 +00:00
Paul Thomas 65ecfbabb0 Fortran: F2008 passing of internal procs to a proc pointer [PR117434]
2024-11-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/117434
	* interface.cc (gfc_compare_actual_formal): Skip 'Expected a
	procedure pointer error' if the formal argument typespec has an
	interface and the type of the actual arg is BT_PROCEDURE.

gcc/testsuite/
	PR fortran/117434
	* gfortran.dg/proc_ptr_54.f90: New test. This is temporarily
	compile-only until one one seven four five five is fixed.
	* gfortran.dg/proc_ptr_55.f90: New test.
	* gfortran.dg/proc_ptr_56.f90: New test.

(cherry picked from commit 4dbf4c0fdb)
2025-02-03 16:25:54 -08:00
GCC Administrator b0bb0d9c58 Daily bump. 2025-02-04 00:22:40 +00:00
Lewis Hyatt 1e77549e18 options: Adjust cl_optimization_compare to avoid checking ICE [PR115913]
At the end of a sequence like:
 #pragma GCC push_options
 ...
 #pragma GCC pop_options

the handler for pop_options calls cl_optimization_compare() (as generated by
optc-save-gen.awk) to make sure that all global state has been restored to
the value it had prior to the push_options call. The verification is
performed for almost all entries in the global_options struct. This leads to
unexpected checking asserts, as discussed in the PR, in case the state of
warnings-related options has been intentionally modified in between
push_options and pop_options via a call to #pragma GCC diagnostic. Address
that by skipping the verification for CL_WARNING-flagged options.

gcc/ChangeLog:

	PR middle-end/115913
	* optc-save-gen.awk (cl_optimization_compare): Skip options with
	CL_WARNING flag.

gcc/testsuite/ChangeLog:

	PR middle-end/115913
	* c-c++-common/cpp/pr115913.c: New test.
2025-02-02 21:03:34 -05:00
GCC Administrator c2b2e9cf14 Daily bump. 2025-02-03 00:22:01 +00:00
GCC Administrator f89f3e5d4f Daily bump. 2025-02-02 00:22:57 +00:00
Eric Botcazou 8c79b66dbc Ada: Fix segfault on uninitialized variable as operand of primitive operator
...of derived real type.  It comes from an unexpected internal adjustment.

gcc/ada/
	PR ada/118712
	* sem_warn.adb (Check_References): Deal with small adjustments of
	references.

gcc/testsuite/
	* gnat.dg/warn33.adb: New test.
	* gnat.dg/warn33_pkg.ads: New helper.
2025-02-01 11:42:14 +01:00
GCC Administrator 7bc54a84a5 Daily bump. 2025-02-01 00:22:48 +00:00
Harald Anlauf 63ea47f594 Fortran: fix bogus diagnostics on renamed interface import [PR110993]
PR fortran/110993

gcc/fortran/ChangeLog:

	* frontend-passes.cc (check_externals_procedure): Do not compare
	interfaces of a non-bind(C) procedure against a bind(C) global one.
	(check_against_globals): Use local name from rename-on-use in the
	search for interfaces.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 9104472b64)
2025-01-31 20:34:00 +01:00
GCC Administrator 58ad709f8a Daily bump. 2025-01-31 00:24:43 +00:00
GCC Administrator a0550ff9f3 Daily bump. 2025-01-30 00:24:13 +00:00
Harald Anlauf b53d19a152 Fortran: fix passing of component ref to assumed-rank dummy [PR118683]
While the fix for pr117774 addressed the passing of an inquiry reference
to an assumed-rank dummy, it missed the similar case of passing a component
reference.  The newer testcase gfortran.dg/pr81978.f90 uncovered this
latent issue with a UBSAN instrumented compiler.

	PR fortran/118683

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): The bounds update for
	passing to assumed-rank dummies shall also handle component
	references besides inquiry references.

(cherry picked from commit 5d001fa122)
2025-01-29 19:15:07 +01:00
Siddhesh Poyarekar 50c111ecd1 testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles
Denormal behaviour is well defined for IEEE128 long doubles, so
XFAIL some gfortran tests only for targets with the IBM128 long double
ABI.

gcc/testsuite/ChangeLog:

	PR testsuite/118127
	* lib/target-supports.exp
	(check_effective_target_long_double_is_ibm128): New
	procedure.
	* gfortran.dg/default_format_2.f90: xfail for
	long_double_is_ibm128.
	* gfortran.dg/default_format_denormal_2.f90: Likewise.
	* gfortran.dg/large_real_kind_form_io_2.f90: Likewise.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
(cherry picked from commit d4d4e874de)
2025-01-29 11:04:40 -05:00
Patrick Palka f0420cc224 libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]
The range adaptor perfect forwarding simplification mechanism is currently
only enabled for trivially copyable bound arguments, to prevent undesirable
copies of complex objects.  But "trivially copyable" is the wrong property
to check for here, since a move-only type with a trivial move constructor
is considered trivially copyable, and after P2492R2 we can't assume copy
constructibility of the bound arguments.  This patch makes the mechanism
more specifically check for trivial copy constructibility instead so
that it's properly disabled for move-only bound arguments.

	PR libstdc++/118413

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::__adaptor::_Partial): Adjust
	constraints on the "simple" partial specializations to require
	is_trivially_copy_constructible_v instead of
	is_trivially_copyable_v.
	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04):
	Extend P2494R2 test.
	* testsuite/std/ranges/adaptors/transform.cc (test09): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 09d1cbee10)
2025-01-29 10:27:49 -05:00
Marek Polacek 8774d5076d c++: re-enable NSDMI CONSTRUCTOR folding [PR118355]
In c++/102990 we had a problem where massage_init_elt got {},
digest_nsdmi_init turned that {} into { .value = (int) 1.0e+0 },
and we crashed in the call to fold_non_dependent_init because
a FIX_TRUNC_EXPR/FLOAT_EXPR got into tsubst*.  So we avoided
calling fold_non_dependent_init for a CONSTRUCTOR.

But that broke the following test, where we no longer fold the
CONST_DECL in
  { .type = ZERO }
to
  { .type = 0 }
and then process_init_constructor_array does:

            if (next != error_mark_node
                && (initializer_constant_valid_p (next, TREE_TYPE (next))
                    != null_pointer_node))
              {
                /* Use VEC_INIT_EXPR for non-constant initialization of
                   trailing elements with no explicit initializers.  */
                picflags |= PICFLAG_VEC_INIT;

because { .type = ZERO } isn't initializer_constant_valid_p.  Then we
create a VEC_INIT_EXPR and say we can't convert the argument.

So we have to fold the elements of the CONSTRUCTOR.  We just can't
instantiate the elements in a template.

This also fixes c++/118047.

	PR c++/118047
	PR c++/118355

gcc/cp/ChangeLog:

	* typeck2.cc (massage_init_elt): Call fold_non_dependent_init
	unless for a CONSTRUCTOR in a template.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/nsdmi-list10.C: New test.
	* g++.dg/cpp0x/nsdmi-list9.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit e939005c49)
2025-01-29 10:16:27 -05:00
GCC Administrator a48161638e Daily bump. 2025-01-29 00:24:29 +00:00
Patrick Palka c061ad5a36 c++: friend vs inherited guide confusion [PR117855]
We recently started using the lang_decl_fn::context field to track
inheritedness of a deduction guide (for C++23 inherited CTAD).  This
new overloading of the field accidentally made DECL_FRIEND_CONTEXT
return non-NULL for inherited guides, which breaks the below testcase
during overload resolution with an inherited guide.

This patch fixes this by refining DECL_FRIEND_CONTEXT appropriately.

	PR c++/117855

gcc/cp/ChangeLog:

	* cp-tree.h (DECL_FRIEND_CONTEXT): Exclude deduction guides.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/class-deduction-inherited7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit ea578dd251)
2025-01-28 09:28:09 -05:00
Tamar Christina f8daec2ad9 AArch64: don't override march to assembler with mcpu if march is specified [PR110901]
When both -mcpu and -march are specified, the value of -march wins out.

This is done correctly for the calls to cc1 and for the assembler directives we
put out in assembly files.

However in the call to as we don't do this and instead use the arch from the
cpu.  This leads to a situation that GCC cannot reliably be used to compile
assembly files which don't have a .arch directive.

This is quite common with .S files which use macros to selectively enable
codepath based on what the preprocessor sees.

The fix is to change MCPU_TO_MARCH_SPEC to not override the march if an march
is already specified.

gcc/ChangeLog:

	PR target/110901
	* config/aarch64/aarch64.h (MCPU_TO_MARCH_SPEC): Don't override if
	march is set.

gcc/testsuite/ChangeLog:

	PR target/110901
	* gcc.target/aarch64/options_set_29.c: New test.

(cherry picked from commit 773beeaafb)
2025-01-28 10:15:46 +00:00
Tamar Christina 7c6fde4bac AArch64: have -mcpu=native detect architecture extensions for unknown non-homogenous systems [PR113257]
in g:e91a17fe39c39e98cebe6e1cbc8064ee6846a3a7 we added the ability for
-mcpu=native on unknown CPUs to still enable architecture extensions.

This has worked great but was only added for homogenous systems.

However the same thing works for big.LITTLE as in such system the cores must
have the same extensions otherwise it doesn't fundamentally work.

i.e. task migration from one core to the other wouldn't work.

This extends the same handling to non-homogenous systems.

gcc/ChangeLog:

	PR target/113257
	* config/aarch64/driver-aarch64.cc (get_cpu_from_id, DEFAULT_CPU): New.
	(host_detect_local_cpu): Use it.

gcc/testsuite/ChangeLog:

	PR target/113257
	* gcc.target/aarch64/cpunative/info_34: New test.
	* gcc.target/aarch64/cpunative/native_cpu_34.c: New test.
	* gcc.target/aarch64/cpunative/info_35: New test.
	* gcc.target/aarch64/cpunative/native_cpu_35.c: New test.

Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
(cherry picked from commit 1ff85affe4)
2025-01-28 10:15:19 +00:00
Ilya Leoshkevich 946c17e456 asan: Fix missing FakeStack flag cleanup
The FakeStack flag is not zeroed out when can_store_by_pieces()
returns false.  Over time, this causes FakeStack::Allocate() to perform
the maximum number of loop iterations, significantly slowing down the
instrumented program.

Link: https://inbox.sourceware.org/gcc-patches/20250109001702.154685-1-iii@linux.ibm.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

gcc/ChangeLog:

	* asan.cc (asan_emit_stack_protection): Always zero the flag
	unless it is cleared by the __asan_stack_free_N() libcall.

(cherry picked from commit 13d9716011)
2025-01-28 01:31:42 +01:00
GCC Administrator fb0e3f9132 Daily bump. 2025-01-28 00:27:40 +00:00
Giuseppe D'Angelo d121d1e1dd libstdc++: perfectly forward std::ranges::clamp arguments
As reported in PR118185, std::ranges::clamp does not correctly forward
the projected value to the comparator. Add the missing forward.

libstdc++-v3/ChangeLog:

	PR libstdc++/118185
	PR libstdc++/100249
	* include/bits/ranges_algo.h (__clamp_fn): Correctly forward the
	projected value to the comparator.
	* testsuite/25_algorithms/clamp/118185.cc: New test.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit b342614139)
2025-01-27 13:28:52 -05:00
Patrick Palka 0af8fc2233 c++: explicit spec of constrained member tmpl [PR107522]
When defining a explicit specialization of a constrained member template
(of a class template) such as f and g in the below testcase, the
DECL_TEMPLATE_PARMS of the corresponding TEMPLATE_DECL are partially
instantiated, whereas its associated constraints are carried over
from the original template and thus are in terms of the original
DECL_TEMPLATE_PARMS.  So during normalization for such an explicit
specialization we need to consider the (parameters of) the most general
template, since that's what the constraints are in terms of and since we
always use the full set of template arguments during satisfaction.

	PR c++/107522

gcc/cp/ChangeLog:

	* constraint.cc (get_normalized_constraints_from_decl): Use the
	most general template for an explicit specialization of a
	member template.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-explicit-spec7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 62daa81308)
2025-01-27 13:28:52 -05:00
GCC Administrator 18f447ac09 Daily bump. 2025-01-27 00:24:04 +00:00
GCC Administrator 1eafda360d Daily bump. 2025-01-26 00:23:24 +00:00
GCC Administrator 18a09944e8 Daily bump. 2025-01-25 00:26:39 +00:00
Jerry DeLisle b69eb2c594 Fortran: Fix UTF-8 output with A edit descriptor.
This adjusts the source len for the case where the user has
	specified a field width with the A descriptor.

	PR libfortran/118571

libgfortran/ChangeLog:

	* io/write.c (write_utf8_char4): Adjust the src_len to the
	format width w_len when greater than zero.

gcc/testsuite/ChangeLog:

	* gfortran.dg/utf8_3.f03: New test.

(cherry picked from commit 4daf088123)
2025-01-24 15:14:21 -08:00
Harald Anlauf d4df61dc6e Fortran: do not copy back for parameter actual arguments [PR81978]
When an array is packed for passing as an actual argument, and the array
has the PARAMETER attribute (i.e., it is a named constant that can reside
in read-only memory), do not copy back (unpack) from the temporary.

	PR fortran/81978

gcc/fortran/ChangeLog:

	* trans-array.cc (gfc_conv_array_parameter): Do not copy back data
	if actual array parameter has the PARAMETER attribute.
	* trans-expr.cc (gfc_conv_subref_array_arg): Likewise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 0d1e62b835)
2025-01-24 21:22:16 +01:00
Marek Polacek 504fbafd45 c++: ICE with nested anonymous union [PR117153]
In a template, for

  union {
    union {
      T d;
    };
  };

build_anon_union_vars crates a malformed COMPONENT_REF: we have no
DECL_NAME for the nested anon union so we create something like "object.".
Most of the front end doesn't seem to care, but if such a tree gets to
potential_constant_expression, it can cause a crash.

We can use FIELD directly for the COMPONENT_REF's member.  tsubst_stmt
should build up a proper one in:

    if (VAR_P (decl) && !DECL_NAME (decl)
	&& ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
      /* Anonymous aggregates are a special case.  */
      finish_anon_union (decl);

	PR c++/117153

gcc/cp/ChangeLog:

	* decl2.cc (build_anon_union_vars): Use FIELD for the second operand
	of a COMPONENT_REF.

gcc/testsuite/ChangeLog:

	* g++.dg/other/anon-union6.C: New test.
	* g++.dg/other/anon-union7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 10850f92b2)
2025-01-24 12:38:25 -05:00
Torbjörn SVENSSON 1836a65efc testsuite: arm: Use -Os -fno-math-errno in vfp-1.c [PR116448]
gcc/testsuite/ChangeLog:

	PR testsuite/116448
	* gcc.target/arm/vfp-1.c: Use -Os -fno-math-errno.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 062c04c45b)
2025-01-24 18:11:22 +01:00
Peter Bergner a1acb1c0ed rs6000: Fix ICE for invalid constants in built-in functions
For invalid constant operand values used in built-in functions, return
const0_rtx to signify an error occurred during expansion.

2025-01-16  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Return
	const0_rtx when there is an error.

gcc/testsuite/
	* gcc.target/powerpc/mma-builtin-error.c: New test.

(cherry picked from commit 0696af74b3)
2025-01-23 20:30:15 -06:00
Peter Bergner 68df37647b rs6000: Fix loop limit for built-in constant checking
The loop checking for built-in constant operand restrictions was missing
some operands due to the loop limit being too small.  Fixing that exposed
a testsuite failure which is caused by a typo in the pmxvi4ger8pp definition
where we had made the PMASK field too small.

2025-01-16  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Use correct
	array size for the loop limit.
	* config/rs6000/rs6000-builtins.def: Fix field size for PMASK operand.

(cherry picked from commit 1a2d63a78f)
2025-01-23 20:30:15 -06:00
GCC Administrator 1a80a0401d Daily bump. 2025-01-24 00:24:23 +00:00
John David Anglin 11abd61656 hppa: Fix typo in ADDITIONAL_REGISTER_NAMES in pa32-regs.h
2025-01-23  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa32-regs.h (ADDITIONAL_REGISTER_NAMES): Change
	register 86 name to "%fr31L".
2025-01-23 14:37:11 -05:00
GCC Administrator 80fddadbc3 Daily bump. 2025-01-23 00:25:48 +00:00
Richard Sandiford 3228df20cf rtl: Remove invalid compare simplification [PR117186]
g:d882fe5150fbbeb4e44d007bb4964e5b22373021, posted at
https://gcc.gnu.org/pipermail/gcc-patches/2000-July/033786.html ,
added code to treat:

  (set (reg:CC cc) (compare:CC (gt:M (reg:CC cc) 0) (lt:M (reg:CC cc) 0)))

as a nop.  This PR shows that that isn't always correct.
The compare in the set above is between two 0/1 booleans (at least
on STORE_FLAG_VALUE==1 targets), whereas the unknown comparison that
produced the incoming (reg:CC cc) is unconstrained; it could be between
arbitrary integers, or even floats.  The fold is therefore replacing a
cc that is valid for both signed and unsigned comparisons with one that
is only known to be valid for signed comparisons.

  (gt (compare (gt cc 0) (lt cc 0) 0)

does simplify to:

  (gt cc 0)

but:

  (gtu (compare (gt cc 0) (lt cc 0) 0)

does not simplify to:

  (gtu cc 0)

The optimisation didn't come with a testcase, but it was added for
i386's cmpstrsi, now cmpstrnsi.  That probably doesn't matter as much
as it once did, since it's now conditional on -minline-all-stringops.
But the patch is almost 25 years old, so whatever the original
motivation was, it seems likely that other things now rely on it.

It therefore seems better to try to preserve the optimisation on rtl
rather than get rid of it.  To do that, we need to look at how the
result of the outer compare is used.  We'd therefore be looking at four
instructions (the gt, the lt, the compare, and the use of the compare),
but combine already allows that for 3-instruction combinations thanks
to:

  /* If the source is a COMPARE, look for the use of the comparison result
     and try to simplify it unless we already have used undobuf.other_insn.  */

When applied to boolean inputs, a comparison operator is
effectively a boolean logical operator (AND, ANDNOT, XOR, etc.).
simplify_logical_relational_operation already had code to simplify
logical operators between two comparison results, but:

* It only handled IOR, which doesn't cover all the cases needed here.
  The others are easily added.

* It treated comparisons of integers as having an ORDERED/UNORDERED result.
  Therefore:

  * it would not treat "true for LT + EQ + GT" as "always true" for
    comparisons between integers, because the mask excluded the UNORDERED
    condition.

  * it would try to convert "true for LT + GT" into LTGT even for comparisons
    between integers.  To prevent an ICE later, the code used:

       /* Many comparison codes are only valid for certain mode classes.  */
       if (!comparison_code_valid_for_mode (code, mode))
         return 0;

    However, this used the wrong mode, since "mode" is here the integer
    result of the comparisons (and the mode of the IOR), not the mode of
    the things being compared.  Thus the effect was to reject all
    floating-point-only codes, even when comparing floats.

  I think instead the code should detect whether the comparison is between
  integer values and remove UNORDERED from consideration if so.  It then
  always produces a valid comparison (or an always true/false result),
  and so comparison_code_valid_for_mode is not needed.  In particular,
  "true for LT + GT" becomes NE for comparisons between integers but
  remains LTGT for comparisons between floats.

* There was a missing check for whether the comparison inputs had
  side effects.

While there, it also seemed worth extending
simplify_logical_relational_operation to unsigned comparisons, since
that makes the testing easier.

As far as that testing goes: the patch exhaustively tests all
combinations of integer comparisons in:

  (cmp1 (cmp2 X Y) (cmp3 X Y))

for the 10 integer comparisons, giving 1000 fold attempts in total.
It then tries all combinations of (X in {-1,0,1} x Y in {-1,0,1})
on the result of the fold, giving 9 checks per fold, or 9000 in total.
That's probably more than is typical for self-tests, but it seems to
complete in neglible time, even for -O0 builds.

gcc/
	PR rtl-optimization/117186
	* rtl.h (simplify_context::simplify_logical_relational_operation): Add
	an invert0_p parameter.
	* simplify-rtx.cc (unsigned_comparison_to_mask): New function.
	(mask_to_unsigned_comparison): Likewise.
	(comparison_code_valid_for_mode): Delete.
	(simplify_context::simplify_logical_relational_operation): Add
	an invert0_p parameter.  Handle AND and XOR.  Handle unsigned
	comparisons.  Handle always-false results.  Ignore the low bit
	of the mask if the operands are always ordered and remove the
	then-redundant check of comparison_code_valid_for_mode.  Check
	for side-effects in the operands before simplifying them away.
	(simplify_context::simplify_binary_operation_1): Remove
	simplification of (compare (gt ...) (lt ...)) and instead...
	(simplify_context::simplify_relational_operation_1): ...handle
	comparisons of comparisons here.
	(test_comparisons): New function.
	(test_scalar_ops): Call it.

gcc/testsuite/
	PR rtl-optimization/117186
	* gcc.dg/torture/pr117186.c: New test.
	* gcc.target/aarch64/pr117186.c: Likewise.
2025-01-22 15:23:54 +00:00
Richard Sandiford 51761b3b8b aarch64: Detect word-level modification in early-ra [PR118184]
REGMODE_NATURAL_SIZE is set to 64 bits for everything except
VLA SVE modes.  This means that it's possible to modify (say)
the highpart of a TI pseudo or a V2DI pseudo independently
of the lowpart.  Modifying such highparts requires a reload
if the highpart ends up in the upper 64 bits of an FPR,
since RTL semantics do not allow the highpart of a single
hard register to be modified independently of the lowpart.

early-ra missed a check for this case, which meant that it
effectively treated an assignment to (subreg:DI (reg:TI R) 0)
as an assignment to the whole of R.

gcc/
	PR target/118184
	* config/aarch64/aarch64-early-ra.cc (allocno_assignment_is_rmw):
	New function.
	(early_ra::record_insn_defs): Mark the live range information as
	untrustworthy if an assignment would change part of an allocno
	but preserve the rest.

gcc/testsuite/
	* gcc.dg/torture/pr118184.c: New test.
2025-01-22 15:23:54 +00:00
GCC Administrator 0d9479e1a7 Daily bump. 2025-01-22 00:26:41 +00:00
Jakub Jelinek 0e4f03c670 c++: Wrap force_target_expr in get_member_function_from_ptrfunc with save_expr [PR118509]
My October PR117259 fix to get_member_function_from_ptrfunc to use a
TARGET_EXPR rather than SAVE_EXPR unfortunately caused some regressions as
well as the following testcase shows.
What happens is that
get_member_function_from_ptrfunc -> build_base_path calls save_expr,
so since the PR117259 change in mnay cases it will call save_expr on
a TARGET_EXPR.  And, for some strange reason a TARGET_EXPR is not considered
an invariant, so we get a SAVE_EXPR wrapped around the TARGET_EXPR.
That SAVE_EXPR <TARGET_EXPR <...>> gets initially added only to the second
operand of ?:, so at that point it would still work fine during expansion.
But unfortunately an expression with that subexpression is handed to the
caller also through *instance_ptrptr = instance_ptr; and gets evaluated
once again when computing the first argument to the method.
So, essentially, we end up with
(TARGET_EXPR <D.2907, ...>, (... ? ... SAVE_EXPR <TARGET_EXPR <D.2907, ...>
 ... : ...)) (... SAVE_EXPR <TARGET_EXPR <D.2907, ...> ..., ...);
and while D.2907 is initialized during gimplification in the code dominating
everything that uses it, the extra temporary created for the SAVE_EXPR
is initialized only conditionally (if the ?: condition is true) but then
used unconditionally, so we get
pmf-4.C: In function ‘void foo(C, B*)’:
pmf-4.C:12:11: warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |   (y->*x) ();
      |   ~~~~~~~~^~
pmf-4.C:12:11: note: ‘<anonymous>’ was declared here
   12 |   (y->*x) ();
      |   ~~~~~~~~^~
diagnostic and wrong-code issue too.

As the trunk fix to just treat TARGET_EXPR as invariant seems a little bit risky
and I'd like to get it tested on the trunk for a while, for 14.2.1 this patch
instead wraps those TARGET_EXPRs into SAVE_EXPRs.  Eventually that can be reverted
and the trunk fix backported.

2025-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118509
	* typeck.cc (get_member_function_from_ptrfunc): Wrap force_target_expr
	with save_expr.

	* g++.dg/expr/pmf-4.C: New test.
2025-01-22 00:18:24 +01:00
Nathaniel Shead a82352a2a0 c++/modules: Propagate FNDECL_USED_AUTO when propagating deduced return types [PR118049]
In the linked testcase, we're erroring because the declared return types
of the functions do not appear to match.  This is because when merging
the deduced return types for 'foo' in 'auto-5_b.C', we overwrote the
return type for the declaration with the deduced return type from
'auto-5_a.C' but neglected to track that we were originally declared
with 'auto'.

As a drive-by improvement to QOI, also add checks for if the deduced
return types do not match; this is currently useful because we do not
check the equivalence of the bodies of functions yet.

	PR c++/118049

gcc/cp/ChangeLog:

	* module.cc (trees_in::is_matching_decl): Propagate
	FNDECL_USED_AUTO as well.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/auto-5_a.C: New test.
	* g++.dg/modules/auto-5_b.C: New test.
	* g++.dg/modules/auto-5_c.C: New test.
	* g++.dg/modules/auto-6_a.H: New test.
	* g++.dg/modules/auto-6_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit f054c36c4f)
2025-01-21 18:16:40 +11:00
GCC Administrator 3f9d6afecb Daily bump. 2025-01-21 00:23:29 +00:00
Joseph Myers 696b87db7d Update gcc zh_CN.po
* zh_CN.po: Update.
2025-01-20 21:24:59 +00:00
Iain Buclaw ffa44df676 d: Fix failing test with 32-bit compiler [PR114434]
Since the introduction of gdc.test/runnable/test23514.d, it's exposed an
incorrect compilation when adding a 64-bit constant to a link-time
address.  The current cast to size_t causes a loss of precision, which
can result in incorrect compilation.

	PR d/114434

gcc/d/ChangeLog:

	* expr.cc (ExprVisitor::visit (PtrExp *)): Get the offset as a
	dinteger_t rather than a size_t.
	(ExprVisitor::visit (SymOffExp *)): Likewise.

(cherry picked from commit 9ab38952a2)
2025-01-20 20:23:55 +01:00
GCC Administrator 7780f2cefe Daily bump. 2025-01-20 00:23:17 +00:00
Uros Bizjak 9a1daeb9cd i386: Reorder *movdi_internal ISA attribute by ascending alternative index
Reorder ISA attribute by ascending alternative index. No functional change.

gcc/ChangeLog:

	* config/i386/i386.md (*movdi_internal): Reorder ISA attribute
	by ascending alternative index.

(cherry picked from commit 9d4b1e3772)
2025-01-19 22:30:21 +01:00
Uros Bizjak 94338cdf59 i386: Disable SImode/DImode moves from/to mask regs without avx512bw [PR118067]
SImode and DImode moves from/to mask registers are valid only with AVX512BW,
so mark relevant alternatives in *movsi_internal and *movdi_internal as such.

Even with the patch, the testcase still fails, but now with:

pr118067.c: In function ‘foo’:
pr118067.c:13:1: internal compiler error: maximum number of generated reload insns per insn achieved (90)
   13 | }
      | ^
0x2c3b581 internal_error(char const*, ...)
        ../../git/gcc/gcc/diagnostic-global-context.cc:517
0xb68938 lra_constraints(bool)
        ../../git/gcc/gcc/lra-constraints.cc:5411
0xb51a0d lra(_IO_FILE*, int)
        ../../git/gcc/gcc/lra.cc:2449
0xaf9f4d do_reload
        ../../git/gcc/gcc/ira.cc:5977
0xafa462 execute
        ../../git/gcc/gcc/ira.cc:6165

	PR target/118067

gcc/ChangeLog:

	* config/i386/i386.md (*movdi_internal):
	Disable alternatives from/to mask registers without AVX512BW.
	(*movsi_internal): Ditto.

(cherry picked from commit 219ddae16f)
2025-01-19 22:30:21 +01:00
Simon Martin b1f9fb0e13 c++: Friend classes don't shadow enclosing template class paramater [PR118255]
We currently reject the following code

=== code here ===
template <int non_template> struct S { friend class non_template; };
class non_template {};
S<0> s;
=== code here ===

While EDG agrees with the current behaviour, clang and MSVC don't (see
https://godbolt.org/z/69TGaabhd), and I believe that this code is valid,
since the friend clause does not actually declare a type, so it cannot
shadow anything. The fact that we didn't error out if the non_template
class was declared before S backs this up as well.

This patch fixes this by skipping the call to check_template_shadow for
hidden bindings.

	PR c++/118255

gcc/cp/ChangeLog:

	* name-lookup.cc (pushdecl): Don't call check_template_shadow
	for hidden bindings.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/pr99116-1.C: Adjust test expectation.
	* g++.dg/template/friend84.C: New test.

(cherry picked from commit b5a069203f)
2025-01-19 11:45:48 +01:00
GCC Administrator 78a8316269 Daily bump. 2025-01-19 00:23:25 +00:00
GCC Administrator 511920a21d Daily bump. 2025-01-18 00:23:38 +00:00
Iain Buclaw 4abeaeba43 d: Fix ICE in expand_d_format when diagnosing empty enum [PR117115]
This was fixed in upstream dmd, and merged in r15-6824. Backport the
individual fix from the upstream merge for releases/gcc-14.

	PR d/117115

gcc/testsuite/ChangeLog:

	* gdc.dg/pr117115.d: New test.

(cherry picked from commit 975c4f1a5d)
2025-01-17 20:24:20 +01:00
Georg-Johann Lay 1ba0d18323 AVR: Use INT_N to built-in define __int24.
This patch uses the INT_N interface to define __int24 in avr-modes.def.

Since the testsuite uses -Wpedantic and __int24 is a C/C++ extension,
uses of __int24 and __uint24 is now marked as __extension__.

	PR target/118329
gcc/
	* config/avr/avr-modes.def: Add INT_N (PSI, 24).
	* config/avr/avr.cc (avr_init_builtin_int24)
	<__int24>: Remove definition.
	<__uint24>: Adjust definition to INT_N interface.
gcc/testsuite/
	* gcc.target/avr/torture/get-mem.c: (__int24, __uint24):
	Add __extension__ to respective typedefs.
	* gcc.target/avr/torture/set-mem.c: Same.
	* gcc.target/avr/torture/int24-mul.c: Same.
	* gcc.target/avr/torture/pr109907-2.c: Same.
	* gcc.target/avr/torture/pr61443.c: Same.
	* gcc.target/avr/torture/pr63633-ice-mult.c: Same.

(cherry picked from commit 6580b89957)
2025-01-17 15:18:27 +01:00
Nathaniel Shead f400d065a2 c++: Allow pragmas in NSDMIs [PR118147]
This patch removes the (unnecessary) CPP_PRAGMA_EOL case from
cp_parser_cache_defarg, which currently has the result that any pragmas
in the NSDMI cause an error.

	PR c++/118147

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_cache_defarg): Don't error when
	CPP_PRAGMA_EOL.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/nsdmi-defer7.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit f3ccc57e5f)
2025-01-17 23:53:54 +11:00
Simon Martin b4578c16a4 c++: Make sure fold_sizeof_expr returns the correct type [PR117775]
We currently ICE upon the following code, that is valid under
-Wno-pointer-arith:

=== cut here ===
int main() {
  decltype( [](auto) { return sizeof(void); } ) x;
  return x.operator()(0);
}
=== cut here ===

The problem is that "fold_sizeof_expr (sizeof(void))" returns
size_one_node, that has a different TREE_TYPE from that of the sizeof
expression, which later triggers an assert in cxx_eval_store_expression.

This patch makes sure that fold_sizeof_expr always returns a tree with
the size_type_node type.

	PR c++/117775

gcc/cp/ChangeLog:

	* decl.cc (fold_sizeof_expr): Make sure the folded result has
	type size_type_node.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-117775.C: New test.

(cherry picked from commit 37f38b0f97)
2025-01-17 06:39:41 +01:00
Eugene Rozenfeld 802771f228 Fix setting of call graph node AutoFDO count
We are initializing both the call graph node count and
the entry block count of the function with the head_count value
from the profile.

Count propagation algorithm may refine the entry block count
and we may end up with a case where the call graph node count
is set to zero but the entry block count is non-zero. That becomes
a problem because we have this code in execute_fixup_cfg:

 profile_count num = node->count;
 profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
 bool scale = num.initialized_p () && !(num == den);

Here if num is 0 but den is not 0, scale becomes true and we
lose the counts in

if (scale)
  bb->count = bb->count.apply_scale (num, den);

This is what happened in the issue reported in PR116743
(a 10% regression in MySQL HAMMERDB tests).
3d9e676793 made an improvement in
AutoFDO count propagation, which caused a mismatch between
the call graph node count (zero) and the entry block count (non-zero)
and subsequent loss of counts as described above.

The fix is to update the call graph node count once we've done count propagation.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:
	PR gcov-profile/116743
	* auto-profile.cc (afdo_annotate_cfg): Fix mismatch between the call graph node count
	and the entry block count.

(cherry picked from commit e683c6b029)
2025-01-16 17:44:49 -08:00
GCC Administrator e3ba027111 Daily bump. 2025-01-17 00:27:03 +00:00
Iain Buclaw 1487310d27 d: Fix record layout of compiler-generated TypeInfo_Class [PR115249]
In r14-8766, the layout of TypeInfo_Class changed in the runtime
library, but didn't get reflected in the compiler-generated data,
causing a corruption of runtime type introspection on BigEndian targets.

This adjusts the size of the `ClassFlags' field from uint to ushort, and
adds a new ushort `depth' field in the space where ClassFlags used to
occupy.

	PR d/115249

gcc/d/ChangeLog:

	* typeinfo.cc (create_tinfo_types): Update internal Typenfo
	representation.
	(TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Likewise.

(cherry picked from commit d740694ff8)
2025-01-17 00:58:32 +01:00
Iain Buclaw 258d5c0627 d: Fix ICE in dmd.expressionsem.resolveLoc
This was fixed in upstream, and merged in r15-6559-g332cf038fda109.
Backport the individual fix from the upstream merge for releases/gcc-14.

	PR d/116373

gcc/d/ChangeLog:

	* dmd/expressionsem.d (resolveLoc): Check for null pointer before
	resolving bounds of slice.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr116373.d: New test.

(cherry picked from commit c7dab40d75)
2025-01-16 19:24:18 +01:00
Jonathan Wakely 7df6af205f libstdc++: Fix reversed args in unreachable assumption [PR109849]
libstdc++-v3/ChangeLog:

	PR libstdc++/109849
	* include/bits/vector.tcc (vector::_M_range_insert): Fix
	reversed args in length calculation.

(cherry picked from commit 6f85a97248)
2025-01-16 09:47:09 +00:00
Jonathan Wakely 9ea74d9ba8 libstdc++: Fix more pedwarns in headers for C++98
Some tests e.g.  17_intro/headers/c++1998/all_pedantic_errors.cc FAIL
with GLIBCXX_TESTSUITE_STDS=98 due to numerous C++11 extensions still in
use in the library headers. The recent changes to not make them system
headers means we get warnings now.

This change adds more diagnostic pragmas to suppress those warnings.

libstdc++-v3/ChangeLog:

	* include/bits/istream.tcc: Add diagnostic pragmas around uses
	of long long and extern template.
	* include/bits/locale_facets.h: Likewise.
	* include/bits/locale_facets.tcc: Likewise.
	* include/bits/locale_facets_nonio.tcc: Likewise.
	* include/bits/ostream.tcc: Likewise.
	* include/bits/stl_algobase.h: Likewise.
	* include/c_global/cstdlib: Likewise.
	* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
	Likewise.
	* include/ext/pointer.h: Likewise.
	* include/ext/stdio_sync_filebuf.h: Likewise.
	* include/std/istream: Likewise.
	* include/std/ostream: Likewise.
	* include/tr1/cmath: Likewise.
	* include/tr1/type_traits: Likewise.
	* include/tr1/functional_hash.h: Likewise. Remove semi-colons
	at namespace scope that aren't needed after macro expansion.
	* include/tr1/tuple: Remove semi-colon at namespace scope.
	* include/bits/vector.tcc: Change LL suffix to just L.

(cherry picked from commit 6885407123)
2025-01-16 09:47:09 +00:00
Jonathan Wakely a5ce37b32d libstdc++: Fix std::deque::emplace calling wrong _M_insert_aux [PR90389]
We have several overloads of std::deque::_M_insert_aux, one of which is
variadic and called by std::deque::emplace. With a suitable set of
arguments to emplace, it's possible for one of the non-variadic
_M_insert_aux overloads to be selected by overload resolution, making
emplace ill-formed.

Rename the variadic _M_insert_aux to _M_emplace_aux so that calls to
emplace never select an _M_insert_aux overload. Also add an inline
_M_insert_aux for the const lvalue overload that is called from
insert(const_iterator, const value_type&).

libstdc++-v3/ChangeLog:

	PR libstdc++/90389
	* include/bits/deque.tcc (_M_insert_aux): Rename variadic
	overload to _M_emplace_aux.
	* include/bits/stl_deque.h (_M_insert_aux): Define inline.
	(_M_emplace_aux): Declare.
	* testsuite/23_containers/deque/modifiers/emplace/90389.cc: New
	test.

(cherry picked from commit 5f44b1776e)
2025-01-16 09:47:09 +00:00
GCC Administrator 57563a6bf8 Daily bump. 2025-01-16 00:25:47 +00:00
GCC Administrator 1434baad95 Daily bump. 2025-01-15 00:22:11 +00:00
Robin Dapp 9b8488f662 match: Keep conditional in simplification to constant [PR118140].
In PR118140 we simplify

  _ifc__33 = .COND_IOR (_41, d_lsm.7_11, _46, d_lsm.7_11);

to 1:

Match-and-simplified .COND_IOR (_41, d_lsm.7_11, _46, d_lsm.7_11) to 1

when _46 == 1.  This happens by removing the conditional and applying
a | 1 = 1.  Normally we re-introduce the conditional and its else value
if needed but that does not happen here as we're not dealing with a
vector type.  For correctness's sake, we must not remove the conditional
even for non-vector types.

This patch re-introduces a COND_EXPR in such cases.  For PR118140 this
result in a non-vectorized loop.

	PR middle-end/118140

gcc/ChangeLog:

	* gimple-match-exports.cc (maybe_resimplify_conditional_op): Add
	COND_EXPR when we simplified to a scalar gimple value but still
	have an else value.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/pr118140.c: New test.
	* gcc.target/riscv/rvv/autovec/pr118140.c: New test.

(cherry picked from commit 14cb061055)
2025-01-14 17:29:34 +01:00
GCC Administrator 33c38e48d8 Daily bump. 2025-01-14 00:24:01 +00:00
GCC Administrator ea6d74ee80 Daily bump. 2025-01-13 00:22:58 +00:00
Torbjörn SVENSSON f43a6bd087 testsuite: The expect framework might introduce CR in output
When running tests using the "sim" config, the command is launched in
non-readonly mode and the text retrieved from the expect command will
then replace all LF with CRLF. (The problem can be found in sim_load
where it calls remote_spawn without an input file).

libstdc++-v3/ChangeLog:

	* testsuite/27_io/print/1.cc: Allow both LF and CRLF in test.
	* testsuite/27_io/print/3.cc: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 4b29be7216)
2025-01-12 08:36:02 +01:00
Torbjörn SVENSSON d82fc939f9 testsuite: libstdc++: Use effective-target libatomic
Test assumes libatomic.a is always available, but for some embedded
targets, there is no libatomic.a and the test thus fail.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic_float/compare_exchange_padding.cc:
	Use effective-target libatomic_available.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 4b0ef49d02)
2025-01-12 08:35:59 +01:00
GCC Administrator 3a5a601c37 Daily bump. 2025-01-12 00:23:12 +00:00
Nathaniel Shead f7ddb2b6db testsuite: Fix flag used for modules test
GCC14 doesn't have the new spelling '-fmodules' for enabling modules;
use the old '-fmodules-ts' spelling instead.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr114630_a.C: Use -fmodules-ts instead of
	-fmodules in testcase.
	* g++.dg/modules/pr114630_b.C: Likewise.
	* g++.dg/modules/pr114630_c.C: Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-01-12 04:35:08 +11:00
Nathaniel Shead 7c013a681c c++/modules: Handle chaining already-imported local types [PR114630]
In the linked testcase, an ICE occurs because when reading the
(duplicate) function definition for _M_do_parse from module Y, the local
type definitions have already been streamed from module X and setup as
regular backreferences, rather than being found with find_duplicate,
causing issues with managing DECL_CHAIN.

It is tempting to just skip setting up the DECL_CHAIN for this case.
However, for the future it would be best to ensure that the block vars
for the duplicate definition are accurate, so that we could implement
ODR checking on function definitions at some point.

So to solve this, this patch creates a copy of the streamed-in local
type and chains that; it will be discarded along with the rest of the
duplicate function after we've finished processing.

A couple of suggested implementations from the discussion on the PR that
don't work:

- Replacing the `DECL_CHAIN` assertion with `(*chain && *chain != decl)`
  doesn't handle the case where type definitions are followed by regular
  local variables, since those won't have been imported as separate
  backreferences and so the chains will diverge.

- Correcting the purviewness of GMF template instantiations to force Y
  to emit copies of the local types rather than backreferences into X is
  insufficient, as it's still possible that the local types got streamed
  in a separate cluster to the function definition, and so will be again
  referred to via regular backreferences when importing.

- Likewise, preventing the emission of function definitions where an
  import has already provided that same definition also is insufficient,
  for much the same reason.

	PR c++/114630

gcc/cp/ChangeLog:

	* module.cc (trees_in::core_vals) <BLOCK>: Chain a new node if
	DECL_CHAIN already is set.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr114630.h: New test.
	* g++.dg/modules/pr114630_a.C: New test.
	* g++.dg/modules/pr114630_b.C: New test.
	* g++.dg/modules/pr114630_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-01-12 00:26:28 +11:00
GCC Administrator 76167875f2 Daily bump. 2025-01-11 00:24:26 +00:00
Harald Anlauf 5ae344e3ac Fortran: Cray pointer comparison wrongly optimized away [PR106692]
PR fortran/106692

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_expr_op): Inhibit excessive optimization
	of Cray pointers by treating them as volatile in comparisons.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit c7754a2fb2)
2025-01-10 22:57:38 +01:00
Tamar Christina e4a9fb7448 libstdc++: backport inline keyword on std::find
This is a backport version of the same patch as
g:18aff7644ad1e44dc146d36a2b7e397977aa47ac

In GCC 12 there was a ~40% regression in the performance of hashmap->find.

This regression came about accidentally:

Before GCC 12 the find function was small enough that IPA would inline it even
though it wasn't marked inline.  In GCC-12 an optimization was added to perform
a linear search when the entries in the hashmap are small.

This increased the size of the function enough that IPA would no longer inline.
Inlining had two benefits:

1.  The return value is a reference. so it has to be returned and dereferenced
    even though the search loop may have already dereference it.
2.  The pattern is a hard pattern to track for branch predictors.  This causes
    a large number of branch misses if the value is immediately checked and
    branched on. i.e. if (a != m.end()) which is a common pattern.

The patch fixes both these issues by adding the inline keyword to _M_locate
to allow the inliner to consider inlining again.

This and the other patches have been ran through serveral benchmarks where
the size, number of elements searched for and type (reference vs value) etc
were tested.

The change shows no statistical regression, but an average find improvement of
~27% and a range between ~10-60% improvements.

Thanks,
Tamar

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h (find): Add inline keyword.
2025-01-10 21:37:40 +00:00
Tamar Christina 26f78a4249 AArch64: correct Cortex-X4 MIDR
The Parts Num field for the MIDR for Cortex-X4 is wrong.  It's currently the
parts number for a Cortex-A720 (which does have the right number).

The correct number can be found in the Cortex-X4 Technical Reference Manual [1]
on page 382 in Issue Number 5.

[1] https://developer.arm.com/documentation/102484/latest/

gcc/ChangeLog:

	* config/aarch64/aarch64-cores.def (AARCH64_CORE): Fix cortex-x4 parts
	num.
2025-01-10 21:34:15 +00:00
Torbjörn SVENSSON a2de88e5d4 testsuite: arm: Add pattern for armv8-m.base to cmse-15.c test
Since armv8-m.base uses thumb1 that does not suport sibcall/tailcall,
a pattern is needed that uses PUSH/BL/POP sequence instead of a single
B instruction to reuse an already existing function in the compile unit.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/cmse/cmse-15.c: Added pattern for armv8-m.base.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit cfd7c54bdf)
2025-01-10 19:34:49 +01:00
Andrew Carlotti d0191d1631 Disable a broken multiversioning optimisation
This patch skips redirect_to_specific clone for aarch64 and riscv,
because the optimisation has two flaws:

1. It checks the value of the "target" attribute, even on targets that
don't use this attribute for multiversioning.

2. The algorithm used is too aggressive, and will eliminate the
indirection in some cases where the runtime choice of callee version
can't be determined statically at compile time.  A correct would need to
verify that:
 - if the current caller version were selected at runtime, then the
   chosen callee version would be eligible for selection.
 - if any higher priority callee version were selected at runtime, then
   a higher priority caller version would have been eligble for
   selection (and hence the current caller version wouldn't have been
   selected).

The current checks only verify a more restrictive version of the first
condition, and don't check the second condition at all.

Fixing the optimisation properly would require implementing target hooks
to check for implications between version attributes, which is too
complicated for this stage.  However, I would like to see this hook
implemented in the future, since it could also help deduplicate other
multiversioning code.

Since this behavior has existed for x86 and powerpc for a while, I
think it's best to preserve the existing behavior on those targets,
unless any maintainer for those targets disagrees.

gcc/ChangeLog:

	* multiple_target.cc
	(redirect_to_specific_clone): Assert that "target" attribute is
	used for FMV before checking it.
	(ipa_target_clone): Skip redirect_to_specific_clone on some
	targets.

gcc/testsuite/ChangeLog:

	* g++.target/aarch64/mv-pragma.C: New test.
2025-01-10 14:18:16 +00:00
Richard Biener 02b1172dad tree-optimization/117912 - bogus address equivalences for __builtin_object_size
VN again is the culprit for exploiting address equivalences before
__builtin_object_size got the chance to do its job.  This time
it isn't about union members but adjacent structure fields where
an address to one after the last element of an array field can
spill over to the next field.

The following protects all out-of-bound accesses on the upper bound
side (singling out TYPE_MAX_VALUE + 1 is more expensive).  It
ignores other out-of-bound addresses that would invoke UB.

Zero-sized arrays are a bit awkward because the C++ represents them
with a -1U upper bound.

There's a similar issue for zero-sized components whose address can
be the same as the adjacent field in C.

	PR tree-optimization/117912
	* tree-ssa-sccvn.cc (copy_reference_ops_from_ref): For addresses
	of zero-sized components do not set ->off if the object size pass
	didn't run.
	For OOB ARRAY_REF accesses in address expressions avoid setting
	->off if the object size pass didn't run.
	(valueize_refs_1): Likewise.

	* c-c++-common/torture/pr117912-1.c: New testcase.
	* c-c++-common/torture/pr117912-2.c: Likewise.
	* c-c++-common/torture/pr117912-3.c: Likewise.

(cherry picked from commit 233972ab3b)
2025-01-10 10:22:46 +01:00
Sam James 91b524aa80 doc: cpp: fix version test example syntax
gcc/ChangeLog:

	* doc/cpp.texi (Common Predefined Macros): Fix syntax.
2025-01-10 02:06:29 +00:00
GCC Administrator 1bf4bfc2f5 Daily bump. 2025-01-10 00:24:10 +00:00
Jonathan Wakely a4c0f16f04 libstdc++: Use feature test macro for pmr::polymorphic_allocator<>
Check the __glibcxx_polymorphic_allocator macro instead of just checking
whether __cplusplus > 201703L.

libstdc++-v3/ChangeLog:

	* include/bits/memory_resource.h (polymoprhic_allocator): Use
	feature test macro for P0339R6 features.

(cherry picked from commit b26d92f4f7)
2025-01-09 23:52:33 +00:00
Jonathan Wakely e6d2bcf742 libstdc++: Improve Doxygen docs for std::allocator_traits specializations
The main fix here is to use @header so that the docs show the correct
header file instead of an internal header like alloc_traits.h.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h: Improve doxygen docs for
	allocator_traits specializations.
	* include/bits/memory_resource.h: Likewise.

(cherry picked from commit cd8e0ea727)
2025-01-09 23:52:33 +00:00
Jonathan Wakely 734d7dae42 libstdc++: Undeprecate std::pmr::polymorphic_allocator::destroy (P2875R4)
This member function was previously deprecated, but that was reverted by
P2875R4, approved earlier this year in Tokyo. Since it's not going to be
deprecated in C++26, and so presumably not removed, there is no point in
giving deprecated warnings for C++23 mode.

libstdc++-v3/ChangeLog:

	* include/bits/memory_resource.h (polymorphic_allocator::destroy):
	Remove deprecated attribute.

(cherry picked from commit c3e237338e)
2025-01-09 23:52:33 +00:00
Jonathan Wakely 72fe42c9a0 libstdc++: Give std::memory_order a fixed underlying type [PR89624]
Prior to C++20 this enum type doesn't have a fixed underlying type,
which means it can be modified by -fshort-enums, which then means the
HLE bits are outside the range of valid values for the type.

As it has a fixed type of int in C++20 and later, do the same for
earlier standards too. This is technically a change for C++17 down,
because the implicit underlying type (without -fshort-enums) was
unsigned before. I doubt it matters in practice. That incompatibility
already exists between C++17 and C++20 and nobody has noticed or
complained. Now at least the underlying type will be int for all -std
modes.

libstdc++-v3/ChangeLog:

	PR libstdc++/89624
	* include/bits/atomic_base.h (memory_order): Use int as
	underlying type.
	* testsuite/29_atomics/atomic/89624.cc: New test.

(cherry picked from commit 99dd1be141)
2025-01-09 23:52:32 +00:00
Jonathan Wakely d05d583f80 libstdc++: Fix typo in comment in src/c++17/fs_dir.cc
libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc: Fix typo in comment.

(cherry picked from commit 9306960694)
2025-01-09 23:52:32 +00:00
Jonathan Wakely 0cdd4c97c4 libstdc++: Make std::println use locale from ostream (LWG 4088)
This was just approved in Wrocław.

libstdc++-v3/ChangeLog:

	* include/std/ostream (println): Pass stream's locale to
	std::format, as per LWG 4088.
	* testsuite/27_io/basic_ostream/print/1.cc: Check std::println
	with custom locale. Remove unused brit_punc class.

(cherry picked from commit 1fd7e36e99)
2025-01-09 23:52:32 +00:00
Jonathan Wakely 2f20d092fc libstdc++: Fix some typos and grammatical errors in docs
Also remove some redundant 'void' parameters from code examples.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/using_exceptions.xml: Fix typos and grammatical
	errors.
	* doc/html/manual/using_exceptions.html: Regenerate.

(cherry picked from commit 96566cc46d)
2025-01-09 23:52:31 +00:00
Jonathan Wakely b84070e7bd libstdc++: Document when std::string::shrink_to_fit was added
This section can be misread to say that shrink_to_fit is available from
GCC 3.4, but it was added later.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/strings.xml: Clarify that GCC 4.5 added
	std::string::shrink_to_fit.
	* doc/html/manual/strings.html: Regenerate.

(cherry picked from commit 0a99ad5c52)
2025-01-09 23:52:31 +00:00
Jonathan Wakely cfe866ebfb libstdc++: Remove __builtin_expect from consteval assertion
libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert): Remove useless
	__builtin_expect from constexpr-only assertion. Improve
	comments.

(cherry picked from commit 73e5d2f87c)
2025-01-09 23:52:31 +00:00
Jonathan Wakely f0eb0ba218 libstdc++: Fix parallel std::exclusive_scan [PR108236]
The standard says that std::exclusive_scan can be used to work in
place, i.e. where the output range is the same as the input range. This
means that the first sum cannot be written to the output until after
reading the first input value, otherwise we'll already have overwritten
the first input value.

While writing a new testcase I also realised that the serial version of
std::exclusive_scan uses copy construction for the accumulator variable,
but the standard only requires Cpp17MoveConstructible. We also require
move assignable, which is missing from the standard's requirements, but
we should at least use move construction not copy construction.

A similar problem exists for some other new C++17 numeric algos, but
I'll fix the others in a subsequent commit.

libstdc++-v3/ChangeLog:

	PR libstdc++/108236
	* include/pstl/glue_numeric_impl.h (exclusive_scan): Pass __init
	as rvalue.
	* include/pstl/numeric_impl.h (__brick_transform_scan): Do not
	write through __result until after reading through __first. Move
	__init into return value.
	(__pattern_transform_scan): Pass __init as rvalue.
	* include/std/numeric (exclusive_scan): Move construct instead
	of copy constructing.
	* testsuite/26_numerics/exclusive_scan/2.cc: New test.
	* testsuite/26_numerics/pstl/numeric_ops/108236.cc: New test.

(cherry picked from commit cd107a6343)
2025-01-09 23:52:30 +00:00
Jonathan Wakely 3590d9f682 libstdc++: Fix debug containers for constant evaluation [PR117962]
Using a stateful allocator with std::vector would fail in Debug Mode,
because the allocator-extended move constructor tries to swap all the
attached safe iterators, but that uses a non-inline function which isn't
constexpr. We don't actually need to swap any iterators in constant
expressions, because we never attach them to the container in the first
place.

This bug went unnoticed because the tests for constexpr std::vector were
using a stateful allocator with a std::allocator base class, but were
failing to override the inherited is_always_equal trait from
std::allocator. That meant that the allocators took the always-equal
code paths, and didn't try to use the buggy constructor. In C++26 the
std::allocator::is_always_equal trait goes away, and so the tests
changed behaviour, revealing the bug.

libstdc++-v3/ChangeLog:

	PR libstdc++/117962
	* include/debug/safe_container.h: Make allocator-extended move
	constructor a no-op during constant evaluation.

(cherry picked from commit 6fbe9e6564)
2025-01-09 23:52:30 +00:00
Jonathan Wakely 845a0b71c8 libstdc++: Disable __gnu_debug::__is_singular(T*) in constexpr [PR109517]
Because of PR c++/85944 we have several bugs where _GLIBCXX_DEBUG causes
errors for constexpr code. Although Bug 117966 could be fixed by
avoiding redundant debug checks in std::span, and Bug 106212 could be
fixed by avoiding redundant debug checks in std::array, there are many
more cases where similar __glibcxx_requires_valid_range checks fail to
compile and removing the checks everywhere isn't desirable.

This just disables the __gnu_debug::__check_singular(T*) check during
constant evaluation. Attempting to dereference a null pointer will
certainly fail during constant evaluation (if it doesn't fail then it's
a compiler bug and not the library's problem). Disabling this check
during constant evaluation shouldn't do any harm.

libstdc++-v3/ChangeLog:

	PR libstdc++/109517
	PR libstdc++/109976
	* include/debug/helper_functions.h (__valid_range_aux): Treat
	all input iterator ranges as valid during constant evaluation.

(cherry picked from commit 9616deb23a)
2025-01-09 23:52:30 +00:00
Jonathan Wakely 1e696cac2b libstdc++: Skip redundant assertions in std::array equality [PR106212]
As PR c++/106212 shows, the Debug Mode checks cause a compilation error
for equality comparisons involving std::array prvalues in constant
expressions. Those Debug Mode checks are redundant when
comparing two std::array objects, because we already know we have a
valid range. We can also avoid the unnecessary step of using
std::__niter_base to do __normal_iterator unwrapping, which isn't needed
because our std::array iterators are just pointers. Using
std::__equal_aux1 instead of std::equal avoids the redundant checks in
std::equal and std::__equal_aux.

libstdc++-v3/ChangeLog:

	PR libstdc++/106212
	* include/std/array (operator==): Use std::__equal_aux1 instead
	of std::equal.
	* testsuite/23_containers/array/comparison_operators/106212.cc:
	New test.

(cherry picked from commit 3aeb2edee2)
2025-01-09 23:52:29 +00:00
Jonathan Wakely 83fa0822ae libstdc++: Skip redundant assertions in std::span construction [PR117966]
As PR c++/117966 shows, the Debug Mode checks cause a compilation error
for a global constexpr std::span. Those debug checks are redundant when
constructing from an array or a range, because we already know we have a
valid range and we know its size. Instead of delegating to the
std::span(contiguous_iterator, contiguous_iterator) constructor, just
initialize the data members directly.

libstdc++-v3/ChangeLog:

	PR libstdc++/117966
	* include/std/span (span(T (&)[N])): Do not delegate to
	constructor that performs redundant checks.
	(span(array<T, N>&), span(const array<T, N>&)): Likewise.
	(span(Range&&), span(const span<T, N>&)): Likewise.
	* testsuite/23_containers/span/117966.cc: New test.

(cherry picked from commit e95bda027e)
2025-01-09 23:52:29 +00:00
Jonathan Wakely 67c457de5a libstdc++: Fix std::deque::insert(pos, first, last) undefined behaviour [PR118035]
Inserting an empty range into a std::deque results in undefined calls to
either std::copy, std::copy_backward, std::move, or std::move_backward.
We call those algos with invalid arguments where the output range is the
same as the input range, e.g.  std::copy(first, last, first) which
violates the preconditions for the algorithms.

This fix simply returns early if there's nothing to insert. Most callers
already ensure that we don't even call _M_range_insert_aux with an empty
range, but some callers don't. Rather than checking for n == 0 in each
of the callers, this just does the check once and uses __builtin_expect
to treat empty insertions as unlikely.

libstdc++-v3/ChangeLog:

	PR libstdc++/118035
	* include/bits/deque.tcc (_M_range_insert_aux): Return
	immediately if inserting an empty range.
	* testsuite/23_containers/deque/modifiers/insert/118035.cc: New
	test.

(cherry picked from commit b273e25e11)
2025-01-09 23:52:29 +00:00
Patrick Palka f73ecaf195 c++: ICE during requires-expr partial subst [PR118060]
Here during partial substitution of the requires-expression (as part of
CTAD constraint rewriting) we segfault from the INDIRECT_REF case of
convert_to_void due *f(u) being type-dependent.  We should just defer
checking convert_to_void until satisfaction.

	PR c++/118060

gcc/cp/ChangeLog:

	* constraint.cc (tsubst_valid_expression_requirement): Don't
	check convert_to_void during partial substitution.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires40.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit ca79349c05)
2025-01-09 17:55:11 -05:00
Patrick Palka 70cea067dd c++: constexpr potentiality of CAST_EXPR [PR117925]
We're incorrectly treating the templated callee (FnPtr)fnPtr, represented
as CAST_EXPR with TREE_LIST operand, as potentially constant here due to
neglecting to look through the TREE_LIST in the CAST_EXPR case of p_c_e_1.

	PR c++/117925

gcc/cp/ChangeLog:

	* constexpr.cc (potential_constant_expression_1) <case CAST_EXPR>:
	Fix check for class conversion to literal type to properly look
	through the TREE_LIST operand of a CAST_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/template/non-dependent35.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 76d1061237)
2025-01-09 17:55:11 -05:00
Patrick Palka aa1e19d821 c++: relax ICE for unexpected trees during constexpr [PR117925]
When we encounter an unexpected (likely templated) tree code during
constexpr evaluation we currently ICE even in release mode.  But it
seems more user-friendly to just gracefully treat the expression as
non-constant, which will be harmless most of the time (e.g. in the case
of warning-specific or speculative constexpr folding as in the PR), and
at worst will transform an ICE-on-valid bug into a rejects-valid bug.
This is also what e.g. tsubst_expr does when it encounters an unexpected
tree code.

	PR c++/117925

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_constant_expression) <default>:
	Relax ICE when encountering an unexpected tree code into a
	checking ICE guarded by flag_checking.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit eeedc54cc8)
2025-01-09 17:55:11 -05:00
Patrick Palka 4dbfc2ff0a c++: template-id dependence wrt local static arg [PR117792]
Here we end up ICEing at instantiation time for the call to
f<local_static> ultimately because we wrongly consider the call to be
non-dependent, and so we specialize f ahead of time and then get
confused when fully substituting this specialization.

The call is dependent due to [temp.dep.temp]/3 and we miss that because
function template-id arguments aren't coerced until overload resolution,
and so the local static template argument lacks an implicit cast to
reference type that value_dependent_expression_p looks for before
considering dependence of the address.  Other kinds of template-ids aren't
affected since they're coerced ahead of time.

So when considering dependence of a function template-id, we need to
conservatively consider dependence of the address of each argument (if
applicable).

	PR c++/117792

gcc/cp/ChangeLog:

	* pt.cc (type_dependent_expression_p): Consider the dependence
	of the address of each template argument of a function
	template-id.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 40f0f6ab75)
2025-01-09 17:55:10 -05:00
Patrick Palka f236c897af libstdc++: Avoid unnecessary copies in ranges::min/max [PR112349]
Use a local reference for the (now possibly lifetime extended) result of
*__first so that we copy it only when necessary.

	PR libstdc++/112349

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__min_fn::operator()): Turn local
	object __tmp into a reference.
	* include/bits/ranges_util.h (__max_fn::operator()): Likewise.
	* testsuite/25_algorithms/max/constrained.cc (test04): New test.
	* testsuite/25_algorithms/min/constrained.cc (test04): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit b8314ebff2)
2025-01-09 17:55:10 -05:00
Patrick Palka 03d0440d73 libstdc++: Implement LWG 3563 changes to keys_view and values_view
This LWG issue corrects the definition of these alias templates to make
them suitable for alias CTAD.

libstdc++-v3/ChangeLog:

	* include/std/ranges (keys_view): Adjust as per LWG 3563.
	(values_view): Likewise.
	* testsuite/std/ranges/adaptors/elements.cc (test08): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 361050589b)
2025-01-09 17:55:10 -05:00
Patrick Palka 9d650c2956 libstdc++: Fix complexity of drop_view::begin() const [PR112641]
Views are required to have a amortized O(1) begin(), but our drop_view's
const begin overload is O(n) for non-common ranges with a non-sized
sentinel.  This patch reimplements it so that it's O(1) always.  See
also LWG 4009.

	PR libstdc++/112641

libstdc++-v3/ChangeLog:

	* include/std/ranges (drop_view::begin): Reimplement const
	overload so that it's O(1) always.
	* testsuite/std/ranges/adaptors/drop.cc (test10): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 7f622ee83f)
2025-01-09 17:55:10 -05:00
Torbjörn SVENSSON 1f509da6d7 testsuite: arm: Use -Os in memset-inline-8* tests
When the test was initially created, -fcommon was the default, but in
commit r10-4867-g6271dd984d7 the default value changed to -fno-common.
This change made the test start failing. To counter the over-alignment
caused by 'a' no longer being common, use -Os.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/memset-inline-8.c: Use -Os and prefix assembler
	instructions with a tab to improve test stability.
	* gcc.target/arm/memset-inline-8-exe.c: Use -Os.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 681934aead)
2025-01-09 22:25:04 +01:00
Marek Polacek dedaccb4a0 c++: ICE initializing array of aggrs [PR117985]
This crash started with my r12-7803 but I believe the problem lies
elsewhere.

build_vec_init has cleanup_flags whose purpose is -- if I grok this
correctly -- to avoid destructing an object multiple times.  Let's
say we are initializing an array of A.  Then we might end up in
a scenario similar to initlist-eh1.C:

  try
    {
      call A::A in a loop
      // #0
      try
        {
	  call a fn using the array
	}
      finally
	{
	  // #1
	  call A::~A in a loop
	}
    }
  catch
    {
      // #2
      call A::~A in a loop
    }

cleanup_flags makes us emit a statement like

  D.3048 = 2;

at #0 to disable performing the cleanup at #2, since #1 will take
care of the destruction of the array.

But if we are not emitting the loop because we can use a constant
initializer (and use a single { a, b, ...}), we shouldn't generate
the statement resetting the iterator to its initial value.  Otherwise
we crash in gimplify_var_or_parm_decl because it gets the stray decl
D.3048.

	PR c++/117985

gcc/cp/ChangeLog:

	* init.cc (build_vec_init): Pop CLEANUP_FLAGS if we're not
	generating the loop.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-array23.C: New test.
	* g++.dg/cpp0x/initlist-array24.C: New test.

(cherry picked from commit 40e5636e08)
2025-01-09 14:47:54 -05:00
Marek Polacek 21600f3a6f c++: unresolved overload with comma op [PR115430]
This works:

  template<typename T>
  int Func(T);
  typedef int (*funcptrtype)(int);
  funcptrtype fp0 = &Func<int>;

but this doesn't:

  funcptrtype fp2 = (0, &Func<int>);

because we only call resolve_nondeduced_context on the LHS (via
convert_to_void) but not on the RHS, so cp_build_compound_expr's
type_unknown_p check issues an error.

	PR c++/115430

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_compound_expr): Call resolve_nondeduced_context
	on RHS.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/noexcept41.C: Remove dg-error.
	* g++.dg/overload/addr3.C: New test.

(cherry picked from commit c847dcf944)
2025-01-09 14:47:33 -05:00
Marek Polacek 3fe6135b62 c++: noexcept and pointer to member function type [PR113108]
We ICE in nothrow_spec_p because it got a DEFERRED_NOEXCEPT.
This DEFERRED_NOEXCEPT was created in implicitly_declare_fn
when declaring

  Foo& operator=(Foo&&) = default;

in the test.  The problem is that in resolve_overloaded_unification
we call maybe_instantiate_noexcept before try_one_overload only in
the TEMPLATE_ID_EXPR case.

	PR c++/113108

gcc/cp/ChangeLog:

	* pt.cc (resolve_overloaded_unification): Call
	maybe_instantiate_noexcept.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/noexcept-type28.C: New test.

(cherry picked from commit c755c7a325)
2025-01-09 14:46:49 -05:00
Marek Polacek df3ae94a5e c++: ICE with structured bindings and m-d array [PR102594]
We ICE in decay_conversion with this test:

  struct S {
    S() {}
  };
  S arr[1][1];
  auto [m](arr3);

But not when the last line is:

  auto [n] = arr3;

Therefore the difference is between copy- and direct-init.  In
particular, in build_vec_init we have:

  if (direct_init)
    from = build_tree_list (NULL_TREE, from);

and then we call build_vec_init again with init==from.  Then
decay_conversion gets the TREE_LIST and it crashes.

build_aggr_init has:

              /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init
                 recognizes it as direct-initialization.  */
              init = build_constructor_single (init_list_type_node,
                                               NULL_TREE, init);
              CONSTRUCTOR_IS_DIRECT_INIT (init) = true;

so I propose to do the same in build_vec_init.

	PR c++/102594

gcc/cp/ChangeLog:

	* init.cc (build_vec_init): Build up a CONSTRUCTOR to signal
	direct-initialization rather than a TREE_LIST.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/decomp61.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 96e0370f4d)
2025-01-09 14:46:34 -05:00
Marek Polacek 078089a084 c++: mutable temps in rodata [PR116369]
Here we wrongly mark the reference temporary for g TREE_READONLY,
so it's put in .rodata and so we can't modify its subobject even
when the subobject is marked mutable.  This is so since r9-869.
r14-1785 fixed a similar problem, but not in set_up_extended_ref_temp.

	PR c++/116369

gcc/cp/ChangeLog:

	* call.cc (set_up_extended_ref_temp): Don't mark a temporary
	TREE_READONLY if its type is TYPE_HAS_MUTABLE_P.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/initlist-opt7.C: New test.

(cherry picked from commit 2801a49d11)
2025-01-09 14:46:16 -05:00
Marek Polacek 13242e5bb6 c++: ICE with enum and conversion fn in template [PR115657]
Here we initialize an enumerator with a class prvalue with a conversion
function.  When we fold it in build_enumerator, we create a TARGET_EXPR
for the object, and subsequently crash in tsubst_expr, which should not
see such a code.

Normally, we fix similar problems by using an IMPLICIT_CONV_EXPR but here
I may get away with not using the result of fold_non_dependent_expr unless
the result is a constant.  A TARGET_EXPR is not constant.

	PR c++/115657

gcc/cp/ChangeLog:

	* decl.cc (build_enumerator): Call maybe_fold_non_dependent_expr
	instead of fold_non_dependent_expr.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-recursion2.C: New test.
	* g++.dg/template/conv21.C: New test.

(cherry picked from commit 53283c3231)
2025-01-09 14:45:58 -05:00
Marek Polacek da983b3287 c++: ICE with reference NSDMI [PR114854]
Here we crash on a cp_gimplify_expr/TARGET_EXPR assert:

      /* A TARGET_EXPR that expresses direct-initialization should have been
         elided by cp_gimplify_init_expr.  */
      gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (*expr_p));

the TARGET_EXPR in question is created for the NSDMI in:

  class Vector { int m_size; };
  struct S {
    const Vector &vec{};
  };

where we first need to create a Vector{} temporary, and then bind the
vec reference to it.  The temporary is represented by a TARGET_EXPR
and it cannot be elided.  When we create an object of type S, we get

  D.2848 = {.vec=(const struct Vector &) &TARGET_EXPR <D.2840, {.m_size=0}>}

where the TARGET_EXPR is no longer direct-initializing anything.

Fixed by not setting TARGET_EXPR_DIRECT_INIT_P in convert_like_internal/ck_user.

	PR c++/114854

gcc/cp/ChangeLog:

	* call.cc (convert_like_internal) <case ck_user>: Don't set
	TARGET_EXPR_DIRECT_INIT_P.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/nsdmi-aggr22.C: New test.

(cherry picked from commit 1a05332bba)
2025-01-09 14:45:27 -05:00
Marek Polacek e6dfe71f5a c++: concept in default argument [PR109859]
1) We're hitting the assert in cp_parser_placeholder_type_specifier.
It says that if it turns out to be false, we should do error() instead.
Do so, then.

2) lambda-targ8.C should compile fine, though.  The problem was that
local_variables_forbidden_p wasn't cleared when we're about to parse
the optional template-parameter-list for a lambda in a default argument.

	PR c++/109859

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_lambda_declarator_opt): Temporarily clear
	local_variables_forbidden_p.
	(cp_parser_placeholder_type_specifier): Turn an assert into an
	error.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-defarg3.C: New test.
	* g++.dg/cpp2a/lambda-targ8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 4bcfaaed25)
2025-01-09 14:44:53 -05:00
Christophe Lyon 61de759f94 arm: [MVE intrinsics] Fix support for predicate constants [PR target/114801]
This backport is a cherry pick of commit
2089009210, with a small change needed
because force_lowpart_subreg does not exist in gcc-14: the patch
replaces it with the equivalent:

-    x = force_lowpart_subreg (mode, x, GET_MODE (x));
+    {
+      auto byte = subreg_lowpart_offset (mode, GET_MODE (x));
+      x = force_subreg (mode, x, GET_MODE (x), byte);
+    }

In this PR, we have to handle a case where MVE predicates are supplied
as a const_int, where individual predicates have illegal boolean
values (such as 0xc for a 4-bit boolean predicate).  To avoid the ICE,
fix the constant (any non-zero value is converted to all 1s) and emit
a warning.

On MVE, V8BI and V4BI multi-bit masks are interpreted byte-by-byte at
instruction level, but end-users should describe lanes rather than
bytes (so all bytes of a true-predicated lane should be '1'), see the
section on MVE intrinsics in the Arm ACLE specification.

Since force_lowpart_subreg cannot handle const_int (because they have VOID mode),
use gen_lowpart on them, force_lowpart_subreg otherwise.

2024-11-20  Christophe Lyon  <christophe.lyon@linaro.org>
	    Jakub Jelinek  <jakub@redhat.com>

	PR target/114801
	gcc/
	* config/arm/arm-mve-builtins.cc
	(function_expander::add_input_operand): Handle CONST_INT
	predicates.

	gcc/testsuite/
	* gcc.target/arm/mve/pr108443.c: Update predicate constant.
	* gcc.target/arm/mve/pr108443-run.c: Likewise.
	* gcc.target/arm/mve/pr114801.c: New test.

(cherry picked from commit 2089009210)
2025-01-09 13:49:11 +00:00
Gerald Pfeifer 409e766bea libstdc++: Update references to gcc.gnu.org/onlinedocs
libstdc++-v3:
	* doc/xml/manual/abi.xml: Update reference to
	gcc.gnu.org/onlinedocs.
	* doc/xml/manual/concurrency_extensions.xml (interface): Ditto.
	* doc/xml/manual/extensions.xml: Ditto.
	* doc/xml/manual/parallel_mode.xml: Ditto.
	* doc/xml/manual/shared_ptr.xml: Ditto.
	* doc/xml/manual/using_exceptions.xml: Ditto. And change GNU GCC
	to GCC.
	* doc/html/index.html: Regenerate.
	* doc/html/manual/abi.html: Ditto.
	* doc/html/manual/ext_concurrency_impl.html: Ditto.
	* doc/html/manual/ext_demangling.html: Ditto.
	* doc/html/manual/memory.html: Ditto.
	* doc/html/manual/parallel_mode_design.html: Ditto.
	* doc/html/manual/parallel_mode_using.html: Ditto.
	* doc/html/manual/using_exceptions.html: Ditto.

(cherry picked from commit e68ab0f160)
2025-01-09 13:30:38 +00:00
Jonathan Wakely a7c5c4931f libstdc++: Fix std::future::wait_until for subsecond negative times [PR118093]
The current check for negative times (i.e. before the epoch) only checks
for a negative number of seconds. For a time 1ms before the epoch the
seconds part will be zero, but the futex syscall will still fail with an
EINVAL error. Extend the check to handle this case.

This change adds a redundant check in the headers too, so that we avoid
even calling into the library for negative times. Both checks can be
marked [[unlikely]]. The check in the headers avoids the cost of
splitting the time into seconds and nanoseconds and then making a PLT
call. The check inside the library matches where we were checking
already, and fixes existing binaries that were compiled against older
headers but use a newer libstdc++.so.6 at runtime.

libstdc++-v3/ChangeLog:

	PR libstdc++/118093
	* include/bits/atomic_futex.h (_M_load_and_test_until_impl):
	Return false for times before the epoch.
	* src/c++11/futex.cc (_M_futex_wait_until): Extend check for
	negative times to check for subsecond times. Add unlikely
	attribute.
	(_M_futex_wait_until_steady): Likewise.
	* testsuite/30_threads/future/members/118093.cc: New test.

(cherry picked from commit 8ade3c3ea7)
2025-01-09 13:08:47 +00:00
Jonathan Wakely 785ddc26e2 libstdc++: Add Doxygen docs for std::forward_like
Also add "@since C++11" to std::move, std::forward etc.

libstdc++-v3/ChangeLog:

	* include/bits/move.h (forward, move, move_if_noexcept, addressof):
	Add @since to Doxygen comments.
	(forward_like): Add Doxygen comment.

(cherry picked from commit 4a4e5394b3)
2025-01-09 13:03:18 +00:00
Jonathan Wakely 7178e38e89 libstdc++: Fix incorrect DocBook element in manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Replace invalid <variable>
	elements with <varname>.
	* doc/html/*: Regenerate.

(cherry picked from commit 720945e8bc)
2025-01-09 13:03:18 +00:00
Jakub Jelinek da82bf0a5f c++: Honor complain in cp_build_function_call_vec for check_function_arguments warnings [PR117825]
The following testcase ICEs due to re-entering diagnostics.
When diagnosing -Wformat-security warning, we try to print instantiation
context, which calls tsubst with tf_none, but that in the end calls
cp_build_function_call_vec which calls check_function_arguments which
diagnoses another warning (again -Wformat-security).

The other check_function_arguments caller, build_over_call, doesn't call
that function if !(complain & tf_warning), so I think the best fix is
to do it the same in cp_build_function_call_vec as well.

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

	PR c++/117825
	* typeck.cc (cp_build_function_call_vec): Don't call
	check_function_arguments if complain doesn't have tf_warning bit set.

	* g++.dg/warn/pr117825.C: New test.

(cherry picked from commit e5180fbcbc)
2025-01-09 10:10:59 +01:00
Jakub Jelinek ec9ccda503 c++: Diagnose earlier non-static data members with cv containing class type [PR116108]
In r10-6457 aka PR92593 fix a check has been added to reject
earlier non-static data members with current_class_type in templates,
as the deduction then can result in endless recursion in reshape_init.
It fixed the
template <class T>
struct S { S s = 1; };
S t{2};
crashes, but as the following testcase shows, didn't catch when there
are cv qualifiers on the non-static data member.

Fixed by using TYPE_MAIN_VARIANT.

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

	PR c++/116108
gcc/cp/
	* decl.cc (grokdeclarator): Pass TYYPE_MAIN_VARIANT (type)
	rather than type to same_type_p when checking if the non-static
	data member doesn't have current class type.
gcc/testsuite/
	* g++.dg/cpp1z/class-deduction117.C: New test.

(cherry picked from commit 88bfee5606)
2025-01-09 10:09:04 +01:00
Jakub Jelinek 1dd428c751 warn-access: Fix up matching_alloc_calls_p [PR118024]
The following testcase ICEs because of a bug in matching_alloc_calls_p.
The loop was apparently meant to be walking the two attribute chains
in lock-step, but doesn't really do that.  If the first lookup_attribute
returns non-NULL, the second one is not done, so rmats in that case can
be some random unrelated attribute rather than "malloc" attribute; the
body assumes even rmats if non-NULL is "malloc" attribute and relies
on its argument to be a "malloc" argument and if it is some other
attribute with incompatible attribute, it just crashes.

Now, fixing that in the obvious way, instead of doing
(amats = lookup_attribute ("malloc", amats))
 || (rmats = lookup_attribute ("malloc", rmats))
in the condition do
((amats = lookup_attribute ("malloc", amats)),
 (rmats = lookup_attribute ("malloc", rmats)),
 (amats || rmats))
fixes the testcase but regresses Wmismatched-dealloc-{2,3}.c tests.
The problem is that walking the attribute lists in a lock-step is obviously
a very bad idea, there is no requirement that the same deallocators are
present in the same order on both decls, e.g. there could be an extra malloc
attribute without argument in just one of the lists, or the order of say
free/realloc could be swapped, etc.  We don't generally document nor enforce
any particular ordering of attributes (even when for some attributes we just
handle the first one rather than all).

So, this patch instead simply splits it into two loops, the first one walks
alloc_decl attributes, the second one walks dealloc_decl attributes.
If the malloc attribute argument is a built-in, that doesn't change
anything, and otherwise we have the chance to populate the whole
common_deallocs hash_set in the first loop and then can check it in the
second one (and don't need to use more expensive add method on it, can just
check contains there).  Not to mention that it also fixes the case when
the function would incorrectly return true if there wasn't a common
deallocator between the two, but dealloc_decl had 2 malloc attributes with
the same deallocator.

2024-12-14  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/118024
	* gimple-ssa-warn-access.cc (matching_alloc_calls_p): Walk malloc
	attributes of alloc_decl and dealloc_decl in separate loops rather
	than in lock-step.  Use common_deallocs.contains rather than
	common_deallocs.add in the second loop.

	* gcc.dg/pr118024.c: New test.

(cherry picked from commit 9537ca5ad9)
2025-01-09 10:08:21 +01:00
Jakub Jelinek fbbc1a4ac5 cse: Fix up record_jump_equiv checks [PR117095]
The following testcase is miscompiled on s390x-linux with -O2 -march=z15.
The problem happens during cse2, which sees in an extended basic block
(jump_insn 217 78 216 10 (parallel [
            (set (pc)
                (if_then_else (ne (reg:SI 165)
                        (const_int 1 [0x1]))
                    (label_ref 216)
                    (pc)))
            (set (reg:SI 165)
                (plus:SI (reg:SI 165)
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (scratch:SI))
            (clobber (reg:CC 33 %cc))
        ]) "t.c":14:17 discrim 1 2192 {doloop_si64}
     (int_list:REG_BR_PROB 955630228 (nil))
 -> 216)
...
(insn 99 98 100 12 (set (reg:SI 138)
        (const_int 1 [0x1])) "t.c":9:31 1507 {*movsi_zarch}
     (nil))
(insn 100 99 103 12 (parallel [
            (set (reg:SI 137)
                (minus:SI (reg:SI 138)
                    (subreg:SI (reg:HI 135 [ a ]) 0)))
            (clobber (reg:CC 33 %cc))
        ]) "t.c":9:31 1904 {*subsi3}
     (expr_list:REG_DEAD (reg:SI 138)
        (expr_list:REG_DEAD (reg:HI 135 [ a ])
            (expr_list:REG_UNUSED (reg:CC 33 %cc)
                (nil)))))
Note, cse2 has df_note_add_problem () before df_analyze, which add
     (expr_list:REG_UNUSED (reg:SI 165)
        (expr_list:REG_UNUSED (reg:CC 33 %cc)
notes to the first insn (correctly so, %cc is clobbered there and pseudo
165 isn't used after the insn).
Now, cse_extended_basic_block has an extra optimization on conditional
jumps, where it records equivalence on the edge which continues in the ebb.
Here it sees (ne reg:SI 165) (const_int 1) is false on the edge and
remembers that pseudo 165 is comparison equivalent to (const_int 1),
so on insn 100 it decides to replace (reg:SI 138) with (reg:SI 165).

This optimization isn't correct here though, because the JUMP_INSN has
multiple sets.  Before r0-77890 record_jump_equiv has been called from
cse_insn guarded on n_sets == 1 && any_condjump_p (insn), so it wouldn't
be done on the above JUMP_INSN where n_sets == 2.  But since that change
it is guarded with single_set (insn) && any_condjump_p (insn) and that
is true because of the REG_UNUSED note.  Looking at that note is
inappropriate in CSE though, because the whole intent of the pass is to
extend the lifetimes of the pseudos if equivalence is found, so the fact
that there is REG_UNUSED note for (reg:SI 165) and that the reg isn't used
later doesn't imply that it won't be used after the optimization.
So, unless we manage to process the other sets on the JUMP_INSN (it wouldn't
be terribly hard in this exact case, the doloop insn decreases the register
by 1 and so we could just record equivalence to (const_int 0) instead, but
generally it might be hard), we should IMHO just punt if there are multiple
sets.

The patch below adds !multiple_sets (insn) check instead of replacing with
it the single_set (insn) check, because apparently any_condjump_p uses
pc_set which supports the case where PATTERN is a SET to PC (that is a
single_set (insn) && !multiple_sets (insn), PATTERN is a PARALLEL with a
single SET to PC (likewise) and some CLOBBERs, PARALLEL with two or more
SETs where the first one is SET to PC (that could be single_set (insn)
with REG_UNUSED notes but is not !multiple_sets (insn)) or PATTERN
is UNSPEC/UNSPEC_VOLATILE with SET inside of it.  For the last case
!multiple_sets (insn) will be true, but IMHO we shouldn't try to derive
anything from those because we haven't checked the rest of the UNSPEC*
and we don't really know what it does.

2024-12-13  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/117095
	* cse.cc (cse_extended_basic_block): Don't call record_jump_equiv
	if multiple_sets (insn).

	* gcc.c-torture/execute/pr117095.c: New test.

(cherry picked from commit b626ebc0d7)
2025-01-09 10:07:13 +01:00
Jakub Jelinek 7ae55c2f73 c++: allow stores to anon union vars to change current union member in constexpr [PR117614]
Since r14-4771 the FE tries to differentiate between cases where the lhs
of a store allows changing the current union member and cases where it
doesn't, and cases where it doesn't includes everything that has gone
through the cxx_eval_constant_expression path on the lhs.
As the testcase shows, DECL_ANON_UNION_VAR_P vars were handled like that
too, even when stores to them are the only way how to change the current
union member in the sources.

So, the following patch just handles that case manually without calling
cxx_eval_constant_expression and without setting evaluated to true.

2024-12-11  Jakub Jelinek  <jakub@redhat.com>

	PR c++/117614
	* constexpr.cc (cxx_eval_store_expression): For stores to
	DECL_ANON_UNION_VAR_P vars just continue with DECL_VALUE_EXPR
	of it, without setting evaluated to true or full
	cxx_eval_constant_expression.

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

(cherry picked from commit 337815c8bb)
2025-01-09 10:06:30 +01:00
Jakub Jelinek 5a78e369a3 docs: Clarify -fsanitize=hwaddress target support [PR117960]
Since GCC 13 -fsanitize=hwaddress is not supported just on AArch64, but also
on x86_64 (but only with -mlam=u48 or -mlam=u57).

2024-12-09  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/117960
	* doc/invoke.texi (fsanitize=hwaddress): Clarify on which targets
	it is supported.

(cherry picked from commit 2e958291ff)
2025-01-09 10:06:06 +01:00
Jakub Jelinek 26615af93c doloop: Fix up doloop df use [PR116799]
The following testcases are miscompiled on s390x-linux, because the
doloop_optimize
  /* Ensure that the new sequence doesn't clobber a register that
     is live at the end of the block.  */
  {
    bitmap modified = BITMAP_ALLOC (NULL);

    for (rtx_insn *i = doloop_seq; i != NULL; i = NEXT_INSN (i))
      note_stores (i, record_reg_sets, modified);

    basic_block loop_end = desc->out_edge->src;
    bool fail = bitmap_intersect_p (df_get_live_out (loop_end), modified);
check doesn't work as intended.
The problem is that it uses df, but the df analysis was only done using
  iv_analysis_loop_init (loop);
->
  df_analyze_loop (loop);
which computes df inside on the bbs of the loop.
While loop_end bb is inside of the loop, df_get_live_out computed that
way includes registers set in the loop and used at the start of the next
iteration, but doesn't include registers set in the loop (or before the
loop) and used after the loop.

The following patch fixes that by doing whole function df_analyze first,
changes the loop iteration mode from 0 to LI_ONLY_INNERMOST (on many
targets which use can_use_doloop_if_innermost target hook a so are known
to only handle innermost loops) or LI_FROM_INNERMOST (I think only bfin
actually allows non-innermost loops) and checking not just
df_get_live_out (loop_end) (that is needed for something used by the
next iteration), but also df_get_live_in (desc->out_edge->dest),
i.e. what will be used after the loop.  df of such a bb shouldn't
be affected by the df_analyze_loop and so should be from df_analyze
of the whole function.

2024-12-05  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/113994
	PR rtl-optimization/116799
	* loop-doloop.cc: Include targhooks.h.
	(doloop_optimize): Also punt on intersection of modified
	with df_get_live_in (desc->out_edge->dest).
	(doloop_optimize_loops): Call df_analyze.  Use
	LI_ONLY_INNERMOST or LI_FROM_INNERMOST instead of 0 as
	second loops_list argument.

	* gcc.c-torture/execute/pr116799.c: New test.
	* g++.dg/torture/pr113994.C: New test.

(cherry picked from commit 0eed81612a)
2025-01-09 10:05:21 +01:00
Jakub Jelinek b602b32ff0 bitintlower: Fix up ?ROTATE_EXPR lowering [PR117847]
In the ?ROTATE_EXPR lowering I forgot to handle rotation by 0 correctly.
INTEGER_CST 0 is very unlikely, it would be probably folded away, but
a non-constant count can't use just p - n because then the shift count
is out of bounds for zero.

In the FE I use n == 0 ? x : (x << n) | (x >> (p - n)) but bitintlower
here isn't prepared at this point to have bb split and am not sure if
using COND_EXPR is a good idea either, so the patch uses (p - n) % p.
Perhaps I should just disable lowering the rotate in the FE for the
non-mode precision BITINT_TYPEs too.

2024-12-03  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/117847
	* gimple-lower-bitint.cc (gimple_lower_bitint) <case LROTATE_EXPR>:
	Use m = (p - n) % p instead of m = p - n for the other shift count.

(cherry picked from commit 0b89341f12)
2025-01-09 10:05:01 +01:00
Jakub Jelinek 326b6bac1f openmp: Add crtoffloadtableS.o and use it [PR117851]
Unlike crtoffload{begin,end}.o which just define some symbols at the start/end
of the various .gnu.offload* sections, crtoffloadtable.o contains
const void *const __OFFLOAD_TABLE__[]
  __attribute__ ((__visibility__ ("hidden"))) =
{
  &__offload_func_table, &__offload_funcs_end,
  &__offload_var_table, &__offload_vars_end,
  &__offload_ind_func_table, &__offload_ind_funcs_end,
};
The problem is that linking this into PIEs or shared libraries doesn't
work when it is compiled without -fpic/-fpie - __OFFLOAD_TABLE__ for non-PIC
code is put into .rodata section, but it really needs relocations, so for
PIC it should go into .data.rel.ro/.data.rel.ro.local.
As I think we don't want .data.rel.ro section in non-PIE binaries, this patch
follows the path of e.g. crtbegin.o vs. crtbeginS.o and adds crtoffloadtableS.o
next to crtoffloadtable.o, where crtoffloadtableS.o is compiled with -fpic.

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

	PR libgomp/117851
gcc/
	* lto-wrapper.cc (find_crtoffloadtable): Add PIE_OR_SHARED argument,
	search for crtoffloadtableS.o rather than crtoffloadtable.o if
	true.
	(run_gcc): Add pie_or_shared variable.  If OPT_pie or OPT_shared or
	OPT_static_pie is seen, set pie_or_shared to true, if OPT_no_pie is
	seen, set pie_or_shared to false.  Pass it to find_crtoffloadtable.
libgcc/
	* configure.ac (extra_parts): Add crtoffloadtableS.o.
	* Makefile.in (crtoffloadtableS$(objext)): New goal.
	* configure: Regenerated.

(cherry picked from commit f089ef880e)
2025-01-09 10:00:43 +01:00
Jakub Jelinek 5d7186159f docs: Fix up __sync_* documentation [PR117642]
The PR14311 commit which added support for __sync_* builtins documented that
there is a warning if a particular operation cannot be implemented.
But that commit nor anything later on implemented such warning, it was
always silent generation of the mentioned calls (which can in most cases
result in linker errors of course because those functions aren't implemented
anywhere, in libatomic or elsewhere in code shipped in gcc).

So, the following patch just adjust the documentation to match the
implementation.

2024-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR target/117642
	* doc/extend.texi: Remove documentation of warning for unimplemented
	__sync_* operations, such warning has never been implemented.

(cherry picked from commit 0dcc09a8b5)
2025-01-09 09:56:44 +01:00
Jakub Jelinek 448f84a49c builtins: Handle BITINT_TYPE in __builtin_iseqsig folding [PR117802]
In check_builtin_function_arguments in the _BitInt patchset I've changed
INTEGER_TYPE tests to INTEGER_TYPE or BITINT_TYPE, but haven't done the
same in fold_builtin_iseqsig, which now ICEs because of that.

The following patch fixes that.

BTW, that TYPE_PRECISION (type0) >= TYPE_PRECISION (type1) test
for REAL_TYPE vs. REAL_TYPE looks pretty random and dangerous, I think
it would be useful to handle this builtin also in the C and C++ FEs,
if both arguments have REAL_TYPE, use the FE specific routine to decide
which types to use and error if a comparison between types would be
erroneous (e.g. complain about _Decimal* vs. float/double/long
double/_Float*, pick up the preferred type, complain about
__ibm128 vs. _Float128 in C++, etc.).
But the FEs can just promote one argument to the other in that case
and keep fold_builtin_iseqsig as is for say Fortran and other FEs.

2024-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR c/117802
	* builtins.cc (fold_builtin_iseqsig): Handle BITINT_TYPE like
	INTEGER_TYPE.

	* gcc.dg/builtin-iseqsig-1.c: New test.
	* gcc.dg/bitint-118.c: New test.

(cherry picked from commit 88aeea14c2)
2025-01-09 09:55:48 +01:00
Jakub Jelinek 0183fb1cef c: Fix sizeof error recovery [PR117745]
Compilation of the following testcase hangs forever after emitting first
error.  The problem is that in one place we just return error_mark_node
directly rather than going through c_expr_sizeof_expr or c_expr_sizeof_type.
The parsing of the expression could have called record_maybe_used_decl
though, but nothing calls pop_maybe_used which needs to be called after
parsing of every sizeof/typeof, successful or not.
At the end of the toplevel declaration we free the parser_obstack and in
another function record_maybe_used_decl is called again and due to the
missing pop_maybe_unused we end up with a cycle in the chain.

The following patch fixes it by just setting error and goto to the
    sizeof_expr:
      c_inhibit_evaluation_warnings--;
      in_sizeof--;
      mark_exp_read (expr.value);
      if (TREE_CODE (expr.value) == COMPONENT_REF
          && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
        error_at (expr_loc, "%<sizeof%> applied to a bit-field");
      result = c_expr_sizeof_expr (expr_loc, expr);
where c_expr_sizeof_expr will do:
  struct c_expr ret;
  if (expr.value == error_mark_node)
    {
      ret.value = error_mark_node;
      ret.original_code = ERROR_MARK;
      ret.original_type = NULL;
      ret.m_decimal = 0;
      pop_maybe_used (false);
    }
...
  return ret;
which is exactly what the old code did manually except for the missing
pop_maybe_used call.  mark_exp_read does nothing on error_mark_node and
error_mark_node doesn't have COMPONENT_REF tree_code.

2024-11-27  Jakub Jelinek  <jakub@redhat.com>

	PR c/117745
	* c-parser.cc (c_parser_sizeof_expression): If type_name is NULL,
	just expr.set_error () and goto sizeof_expr instead of doing error
	recovery manually.

	* gcc.dg/pr117745.c: New test.

(cherry picked from commit 958f0025f4)
2025-01-09 09:54:31 +01:00
Jakub Jelinek 54c381d5a8 builtins: Fix up DFP ICEs on __builtin_fpclassify [PR102674]
This patch is similar to the one I've just posted, __builtin_fpclassify also
needs to print decimal float minimum differently and use real_from_string3.
Plus I've done some formatting fixes.

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

	PR middle-end/102674
	* builtins.cc (fold_builtin_fpclassify): Use real_from_string3 rather
	than real_from_string.  Use "1E%d" format string rather than "0x1p%d"
	for decimal float minimum.  Formatting fixes.

	* gcc.dg/dfp/pr102674.c: New test.

(cherry picked from commit 5bb36d832c)
2025-01-09 09:53:50 +01:00
Jakub Jelinek 59eec2ee71 builtins: Fix up DFP ICEs on __builtin_is{inf,finite,normal} [PR43374]
__builtin_is{inf,finite,normal} builtins ICE on _Decimal{32,64,128,64x}
operands unless those operands are constant.

The problem is that we fold the builtins to comparisons with the largest
finite number, but
a) get_max_float was only handling binary floats
b) real_from_string again assumes binary float
and so we were ICEing in the build_real called after the two calls.

This patch adds decimal handling into get_max_float (well, moves it
from c-cppbuiltin.cc which was printing those for __DEC{32,64,128}_MAX__
macros) and uses real_from_string3 (perhaps it is time to rename it
to just real_from_string now that we can use function overloading)
so that it handles both binary and decimal floats.

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

	PR middle-end/43374
gcc/
	* real.cc (get_max_float): Handle decimal float.
	* builtins.cc (fold_builtin_interclass_mathfn): Use
	real_from_string3 rather than real_from_string.  Use
	"1E%d" format string rather than "0x1p%d" for decimal
	float minimum.
gcc/c-family/
	* c-cppbuiltin.cc (builtin_define_decimal_float_constants): Use
	get_max_float.
gcc/testsuite/
	* gcc.dg/dfp/pr43374.c: New test.

(cherry picked from commit f39e6b4f5c)
2025-01-09 09:52:58 +01:00
Jakub Jelinek 6b417daf0c c-family: Yet another fix for _BitInt & __sync_* builtins [PR117641]
Sorry, the last patch only partially fixed the __sync_* ICEs with
_BitInt(128) on ia32.
Even for !fetch we need to error out and return 0.  I was afraid of
APIs like __atomic_exchange/__atomic_compare_exchange, those obviously
need to be supported even on _BitInt(128) on ia32, but they actually never
sync_resolve_size, they are handled by adding the size argument and using
the library version much earlier.
For fetch && !orig_format (i.e. __atomic_fetch_* etc.) we need to return -1
so that we handle it with a manualy __atomic_load +
__atomic_compare_exchange loop in the caller, all other cases should
be rejected.

2024-11-22  Jakub Jelinek  <jakub@redhat.com>

	PR c/117641
	* c-common.cc (sync_resolve_size): For size 16 with _BitInt
	on targets where TImode isn't supported, use goto incompatible if
	!fetch.

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

(cherry picked from commit 44984f7f75)
2025-01-09 09:52:09 +01:00
Jakub Jelinek 3190d6263c phiopt: Fix a pasto in spaceship_replacement [PR117612]
When working on the PR117612 fix, I've noticed a pasto in
tree-ssa-phiopt.cc (spaceship_replacement).
The code is
      if (absu_hwi (tree_to_shwi (arg2)) != 1)
        return false;
      if (e1->flags & EDGE_TRUE_VALUE)
        {
          if (tree_to_shwi (arg0) != 2
              || absu_hwi (tree_to_shwi (arg1)) != 1
              || wi::to_widest (arg1) == wi::to_widest (arg2))
            return false;
        }
      else if (tree_to_shwi (arg1) != 2
               || absu_hwi (tree_to_shwi (arg0)) != 1
               || wi::to_widest (arg0) == wi::to_widest (arg1))
        return false;
where arg{0,1,2,3} are PHI args and wants to ensure that if e1 is a
true edge, then arg0 is 2 and one of arg{1,2} is -1 and one is 1,
otherwise arg1 is 2 and one of arg{0,2} is -1 and one is 1.
But due to pasto in the latte case doesn't verify that arg0
is different from arg2, it could be both -1 or both 1 and we wouldn't
punt.  The wi::to_widest (arg0) == wi::to_widest (arg1) test
is always false when we've made sure in the earlier conditions that
arg1 is 2 and arg0 is -1 or 1, so never 2.

2024-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/94589
	PR tree-optimization/117612
	* tree-ssa-phiopt.cc (spaceship_replacement): Fix up
	a pasto in check when arg1 is 2.

(cherry picked from commit ca7430f145)
2025-01-09 09:51:38 +01:00
Jakub Jelinek 6d0503f878 c-family: Fix ICE with __sync_*_and_* on _BitInt [PR117641]
Only __atomic_* builtins are meant to work on arbitrary _BitInt types
(if not supported in hw we emit a CAS loop which uses __atomic_load_*
in that case), the compatibility __sync_* builtins work only if there
is a corresponding normal integral type (for _BitInt on 32-bit ARM
we'll need to limit even that to no padding, because the padding bits
are well defined there and the hw or libatomic __sync_* APIs don't
guarantee that), IMHO people shouldn't mix very old APIs with very
new ones and I don't see a replacement for the __atomic_load_*.

For size > 16 that is how it already correctly behaves,
in the hunk shown in the patch it is immediately followed by

  if (fetch && !orig_format && TREE_CODE (type) == BITINT_TYPE)
    return -1;

which returns -1 for the __atomic_* builtins (i.e. !orig_format),
which causes caller to use atomic_bitint_fetch_using_cas_loop,
and otherwise does diagnostic and return 0 (which causes caller
to punt).  But for size == 16 if TImode isn't suipported (i.e.
mostly 32-bit arches), we return (correctly) -1 if !orig_format,
so again force atomic_bitint_fetch_using_cas_loop on those arches
for e.g. _BitInt(115), but for orig_format the function returns
16 as if it could do 16 byte __sync_*_and_* (which it can't
because TImode isn't supported; for 16 byte it can only do
(perhaps using libatomic) normal compare and swap).  So we need
to error and return 0, rather than return 16.

The following patch ensures that.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR c/117641
	* c-common.cc (sync_resolve_size): For size == 16 fetch of
	BITINT_TYPE if TImode isn't supported scalar mode diagnose
	and return 0 if orig_format instead of returning 16.

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

(cherry picked from commit 8663fc1c28)
2025-01-09 09:50:45 +01:00
Jakub Jelinek 98eabdaddc expand: Fix up ICE on VCE from _Complex types to _BitInt [PR117458]
extract_bit_field can't handle extraction of non-mode precision
from complex mode operands which don't live in memory, e.g. gen_lowpart
crashes on those.
The following patch in that case defers the extract_bit_field call
until op0 is forced into memory.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/117458
	* expr.cc (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Don't
	call extract_bit_field if op0 has complex mode and isn't a MEM,
	instead first force op0 into memory and then call extract_bit_field.

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

(cherry picked from commit 694613a7f9)
2025-01-09 09:50:04 +01:00
Jakub Jelinek e3b2c176d3 bitintlower: Handle PAREN_EXPR [PR117459]
The following patch handles PAREN_EXPR in bitint lowering, and handles it
as an optimization barrier, so that temporary arithmetics from PAREN_EXPR
isn't mixed with temporary arithmetics from outside of the PAREN_EXPR.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/117459
	* gimple-lower-bitint.cc (bitint_large_huge::handle_stmt,
	bitint_large_huge::lower_stmt): Handle PAREN_EXPR.

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

(cherry picked from commit 600cab162c)
2025-01-09 09:49:10 +01:00
Jakub Jelinek 04d7d02d58 m2: Fix up dependencies some more
Every now and then my x86_64-linux bootstrap fails due to missing
dependencies somewhere in m2, usually during stage3.  I'm using
make -j32 and run 2 bootstraps concurrently (x86_64-linux and i686-linux)
on the same box.

Last night the same happened to me again,
with the first error
In file included from ./tm.h:29,
                 from ../../gcc/backend.h:28,
                 from ../../gcc/m2/gm2-gcc/gcc-consolidation.h:27,
                 from m2/gm2-compiler-boot/M2AsmUtil.c:26:
../../gcc/config/i386/i386.h:2484:10: fatal error: insn-attr-common.h: No such file or directory
 2484 | #include "insn-attr-common.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [../../gcc/m2/Make-lang.in:1576: m2/gm2-compiler-boot/M2AsmUtil.o] Error 1
make[3]: *** Waiting for unfinished jobs....

Now, gcc/Makefile.in has a general rule:
 # In order for parallel make to really start compiling the expensive
 # objects from $(OBJS) as early as possible, build all their
 # prerequisites strictly before all objects.
 $(ALL_HOST_OBJS) : | $(generated_files)
which ensures that everything that might depend on the generated files
waits for those to be generated.
The above error clearly shows that such waiting didn't happen for
m2/gm2-compiler-boot/M2AsmUtil.o and some others.
ALL_HOST_OBJS includes $(ALL_HOST_FRONTEND_OBJS),
where the latter is
ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS))
m2_OBJS already includes various *.o files, for all those we wait until
the generated files are generated.  Though, seems
cc1gm2 depends on m2/stage1/cc1gm2 (which is just copied there),
and that depends on m2/gm2-compiler-boot/m2flex.o,
$(GM2_C_OBJS) and m2/gm2-gcc/rtegraph.o already included in m2_OBJS,
but also on
$(GM2_LIBS_BOOT) $(MC_LIBS)
where
MC_LIBS=m2/mc-boot-ch/Glibc.o m2/mc-boot-ch/Gmcrts.o
GM2_LIBS_BOOT     = m2/gm2-compiler-boot/gm2.a \
                    m2/gm2-libs-boot/libgm2.a \
                    $(GM2-BOOT-O)
GM2-BOOT-O isn't defined, and the 2 libraries depend on
$(BUILD-LIBS-BOOT) $(BUILD-COMPILER-BOOT)

So, the following patch adds those to m2_OBJS.

I'm not sure if something further is needed, like some objects
used to build the helper programs, mc and whatever else is needed,
I guess it depends on if they use or can use say tm.h or similar
headers which depend on the generated headers.

2024-11-09  Jakub Jelinek  <jakub@redhat.com>

gcc/m2/
	* Make-lang.in (m2_OBJS): Add $(BUILD-LIBS-BOOT),
	$(BUILD-COMPILER-BOOT) and $(MC_LIBS).

(cherry picked from commit 44682fbead)
2025-01-09 09:48:56 +01:00
Jakub Jelinek bef6c31f18 c++: Fix ICE on constexpr virtual function [PR117317]
Since C++20 virtual methods can be constexpr, and if they are
constexpr evaluated, we choose tentative_decl_linkage for those
defer their output and decide at_eof again.
On the following testcases we ICE though, because if
expand_or_defer_fn_1 decides to use tentative_decl_linkage, it
returns true and the caller in that case cals emit_associated_thunks,
where use_thunk which it calls asserts DECL_INTERFACE_KNOWN on the
thunk destination, which isn't the case for tentative_decl_linkage.

The following patch fixes the ICE by not emitting the thunks
for the DECL_DEFER_OUTPUT fns just yet but waiting until at_eof
time when we return to those.
Note, the second testcase ICEs already since r0-110035 with -std=c++0x
before it gets a chance to diagnose constexpr virtual method.

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

	PR c++/117317
	* semantics.cc (emit_associated_thunks): Do nothing for
	!DECL_INTERFACE_KNOWN && DECL_DEFER_OUTPUT fns.

	* g++.dg/cpp2a/pr117317-1.C: New test.
	* g++.dg/cpp2a/pr117317-2.C: New test.

(cherry picked from commit 5ff9e21c1e)
2025-01-09 09:48:17 +01:00
Jakub Jelinek c56b465044 store-merging: Apply --param=store-merging-max-size= in more spots [PR117439]
Store merging assumes a merged region won't be too large.  The assumption is
e.g. in using inappropriate types in various spots (e.g. int for bit sizes
and bit positions in a few spots, or unsigned for the total size in bytes of
the merged region), in doing XNEWVEC for the whole total size of the merged
region and preparing everything in there and even that XALLOCAVEC in two
spots.  The last case is what was breaking the test below in the patch,
64MB XALLOCAVEC is just too large, but even with that fixed I think we just
shouldn't be merging gigabyte large merge groups.

We already have --param=store-merging-max-size= parameter, right now with
65536 bytes maximum (if needed, we could raise that limit a little bit).
That parameter is currently used when merging two adjacent stores, if the
size of the already merged bitregion together with the new store's bitregion
is above that limit, we don't merge those.
I guess initially that was sufficient, at that time a store was always
limited to MAX_BITSIZE_MODE_ANY_INT bits.
But later on we've added support for empty ctors ({} and even later
{CLOBBER}) and also added another spot where we merge further stores into
the merge group, if there is some overlap, we can merge various other stores
in one coalesce_immediate_stores iteration.
And, we weren't applying the --param=store-merging-max-size= parameter
in either of those cases.  So a single store can be gigabytes long, and
if there is some overlap, we can extend the region again to gigabytes in
size.

The following patch attempts to apply that parameter even in those cases.
So, if testing if it should merge the merged group with info (we've already
punted if those together are above the parameter) and some other stores,
the first two hunks just punt if that would make the merge group too large.
And the third hunk doesn't even add stores which are over the limit.

2024-11-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/117439
	* gimple-ssa-store-merging.cc
	(imm_store_chain_info::coalesce_immediate_stores): Punt if merging of
	any of the additional overlapping stores would result in growing the
	bitregion size over param_store_merging_max_size.
	(pass_store_merging::process_store): Terminate all aliasing chains
	for stores with bitregion larger than param_store_merging_max_size.

	* g++.dg/opt/pr117439.C: New test.

(cherry picked from commit 6d8764cc1f)
2025-01-09 09:45:58 +01:00
Jakub Jelinek 67379c5b6e store-merging: Don't use sub_byte_op_p mode for empty_ctor_p unless necessary [PR117439]
encode_tree_to_bitpos uses the more expensive sub_byte_op_p mode in which
it has to allocate a buffer and do various extra work like shifting the bits
etc. if bitlen or bitpos aren't multiples of BITS_PER_UNIT, or if bitlen
doesn't have corresponding integer mode.
The last case is explained later in the comments:
  /* The native_encode_expr machinery uses TYPE_MODE to determine how many
     bytes to write.  This means it can write more than
     ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT bytes (for example
     write 8 bytes for a bitlen of 40).  Skip the bytes that are not within
     bitlen and zero out the bits that are not relevant as well (that may
     contain a sign bit due to sign-extension).  */
Now, we've later added empty_ctor_p support, either {} CONSTRUCTOR
or {CLOBBER}, which doesn't use native_encode_expr at all, just memset,
so that case doesn't need those fancy games unless bitlen or bitpos
aren't multiples of BITS_PER_UNIT (unlikely, but let's pretend it is
possible).

The following patch makes us use the fast path even for empty_ctor_p
which occupy full bytes, we can just memset that in the provided buffer and
don't need to XALLOCAVEC another buffer.

This patch in itself fixes the testcase from the PR (which was about using
huge XALLLOCAVEC), but I want to do some other changes, to be posted in a
next patch.

2024-11-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/117439
	* gimple-ssa-store-merging.cc (encode_tree_to_bitpos): For
	empty_ctor_p use !sub_byte_op_p even if bitlen doesn't have an
	integral mode.

(cherry picked from commit aab572240a)
2025-01-09 09:45:00 +01:00
GCC Administrator c4d23084c2 Daily bump. 2025-01-09 00:23:12 +00:00
GCC Administrator d259c9268c Daily bump. 2025-01-08 00:23:45 +00:00
GCC Administrator 4bd2620b24 Daily bump. 2025-01-07 00:25:22 +00:00
Stafford Horne f690bd46da or1k: add .note.GNU-stack section on linux
In the OpenRISC build we get the following warning:

    ld: warning: __modsi3_s.o: missing .note.GNU-stack section implies executable stack
    ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Fix this by adding a .note.GNU-stack to indicate the stack does not need to be
executable for the lib1funcs.

Note, this is also needed for the upcoming glibc 2.41.

libgcc/
	* config/or1k/lib1funcs.S: Add .note.GNU-stack section on linux.
2025-01-06 17:23:32 +00:00
Eric Botcazou 5d4e9c7043 ada: Fix small thinko in previous change to two-pass aggregate expansion
We need a type tailored to the base index type to compute the length.

gcc/ada/ChangeLog:

	* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use the base type of
	the index type to find the type used to compute the length.
2025-01-06 12:24:02 +01:00
GCC Administrator 6735679c2b Daily bump. 2025-01-06 00:23:05 +00:00
Estevan Castilho (Tevo) 81f74b83f9 Ada: Fix build for dummy s-taprop
gcc/ada
	* libgnarl/s-taprop__dummy.adb: Remove use clause for
	System.Parameters.
	(Unlock): Remove Global_Lock formal parameter.
	(Write_Lock): Likewise.
2025-01-05 12:54:55 +01:00
GCC Administrator 1e33053542 Daily bump. 2025-01-05 00:22:17 +00:00
GCC Administrator d828a97c00 Daily bump. 2025-01-04 00:24:17 +00:00
Nathaniel Shead 1c3dee768a c++/modules: Fallback to ftruncate if posix_fallocate fails [PR115008]
Depending on the libc and filesystem, in cases where posix_fallocate
cannot do an efficient preallocation it may return EINVAL.  In such a
case we should fall back to ftruncate instead.

Apparently, depending on the system the use of posix_fallocate can have
a noticeable speedup over ftruncate in general (depending on the system)
so it probably isn't worth it to use ftruncate in all cases.

	PR c++/100358
	PR c++/115008

gcc/cp/ChangeLog:

	* module.cc (elf_out::create_mapping): Fallback to ftruncate if
	posix_fallocate fails.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit 84aa7065de)
2025-01-03 23:02:43 +11:00
GCC Administrator e0584c728b Daily bump. 2025-01-03 00:24:22 +00:00
GCC Administrator 979d5bffe7 Daily bump. 2025-01-02 00:27:35 +00:00
GCC Administrator 9a29512042 Daily bump. 2025-01-01 00:26:20 +00:00
GCC Administrator 12dda7ccb5 Daily bump. 2024-12-31 00:25:22 +00:00
GCC Administrator ca80e35a58 Daily bump. 2024-12-30 00:24:02 +00:00
GCC Administrator 656425e162 Daily bump. 2024-12-29 00:24:55 +00:00
GCC Administrator ef7cda7eac Daily bump. 2024-12-28 00:24:07 +00:00
GCC Administrator cf6595595c Daily bump. 2024-12-27 00:23:02 +00:00
GCC Administrator 49ec5f8120 Daily bump. 2024-12-26 00:25:05 +00:00
GCC Administrator 02defddd1d Daily bump. 2024-12-25 00:24:43 +00:00
GCC Administrator 1d6f91c1c5 Daily bump. 2024-12-24 00:25:25 +00:00
Patrick Palka 83646dd485 c++: integer overflow during constraint subsumption [PR118069]
For the testcase in the PR we hang during constraint subsumption
ultimately because one of the constraints is complex enough that its
conjunctive normal form is calculated to have more than 2^31 clauses,
which causes the size calculation (through an int) to overflow and so
the optimization in subsumes_constraints_nonnull

  if (dnf_size (lhs) <= cnf_size (rhs))
    // iterate over DNF of LHS
  else
    // iterate over CNF of RHS

incorrectly decides to loop over the CNF (>> billions of clauses)
instead of the DNF (thousands of clauses).

I haven't verified that the result of cnf_size is correct for the
problematic constraint but integer overflow is definitely plausible
given that CNF/DNF can be exponentially larger than the original
constraint in the worst case.

This patch fixes this by using 64-bit saturating arithmetic during
these size calculations (via new add/mul_sat_hwi functions) so that
overflow is less likely and if it does occur we handle it gracefully.
It should be highly unlikely that both the DNF and CNF sizes overflow,
and if they do then it doesn't matter which form we select, subsumption
will take forever either way.  The testcase now compiles in ~3 seconds
on my machine after this change.

	PR c++/118069

gcc/ChangeLog:

	* hwint.h (add_sat_hwi): New function.
	(mul_sat_hwi): Likewise.

gcc/cp/ChangeLog:

	* logic.cc (dnf_size_r): Use HOST_WIDE_INT instead of int, and
	handle overflow gracefully via add_sat_hwi and mul_sat_hwi.
	(cnf_size_r): Likewise.
	(dnf_size): Use HOST_WIDE_INT instead of int.
	(cnf_size): Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 875f14e15d)
2024-12-23 12:01:37 -05:00
Christophe Lyon ecd031a947 Revert "arm: [MVE intrinsics] Fix support for predicate constants [PR target/114801]"
This reverts commit 0631c5770e.
2024-12-23 08:13:39 +00:00
GCC Administrator 597daaafda Daily bump. 2024-12-23 00:23:56 +00:00
Torbjörn SVENSSON e79105ad8c testsuite: arm: Check for short circuit instructions [PR103298]
Instead of checking that a certain transformation is not used by
counting the number of return instructions and the number of BEQ
instructions, check that none of CMP, MOV, ORR and AND instructions are
suffixed with EQ or NE.
Also removed size check as it's very unstable (depends on optimization
in use).

gcc/testsuite/ChangeLog:

	PR testsuite/103298
	* gcc.target/arm/pr43920-2.c: Change to assembler pattern
	"(cmp|mov|orr|and)(eq|ne)" for the check. Remove size check.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 9e1063ca1c)
2024-12-22 16:33:52 +01:00
Paul Thomas d1710c420a Fortran: Fix testsuite regressions after r15-5083 [PR117797]
2024-12-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/117797
	* trans-array.cc (class_array_element_size): New function.
	(gfc_get_array_span): Refactor, using class_array_element_size
	to return the span for descriptors that are the _data component
	of a class expression and then class dummy references. Revert
	the conditions to those before r15-5083 tidying up using 'sym'.

gcc/testsuite/
	PR fortran/117797
	* gfortran.dg/pr117797.f90: New test.

(cherry picked from commit d4330ff9bc)
2024-12-22 09:20:50 +00:00
GCC Administrator 5c9fcacc0f Daily bump. 2024-12-22 00:25:11 +00:00
GCC Administrator 7cdf335617 Daily bump. 2024-12-21 00:24:11 +00:00
GCC Administrator e883a7082f Daily bump. 2024-12-20 00:25:04 +00:00
Christophe Lyon 0631c5770e arm: [MVE intrinsics] Fix support for predicate constants [PR target/114801]
In this PR, we have to handle a case where MVE predicates are supplied
as a const_int, where individual predicates have illegal boolean
values (such as 0xc for a 4-bit boolean predicate).  To avoid the ICE,
fix the constant (any non-zero value is converted to all 1s) and emit
a warning.

On MVE, V8BI and V4BI multi-bit masks are interpreted byte-by-byte at
instruction level, but end-users should describe lanes rather than
bytes (so all bytes of a true-predicated lane should be '1'), see the
section on MVE intrinsics in the Arm ACLE specification.

Since force_lowpart_subreg cannot handle const_int (because they have VOID mode),
use gen_lowpart on them, force_lowpart_subreg otherwise.

2024-11-20  Christophe Lyon  <christophe.lyon@linaro.org>
	    Jakub Jelinek  <jakub@redhat.com>

	PR target/114801
	gcc/
	* config/arm/arm-mve-builtins.cc
	(function_expander::add_input_operand): Handle CONST_INT
	predicates.

	gcc/testsuite/
	* gcc.target/arm/mve/pr108443.c: Update predicate constant.
	* gcc.target/arm/mve/pr108443-run.c: Likewise.
	* gcc.target/arm/mve/pr114801.c: New test.

(cherry picked from commit 2089009210)
2024-12-19 18:07:50 +01:00
Andrew Carlotti 87f9c0e4ae Fix comment typos in tree-assume.cc
gcc/ChangeLog:

	* tree-assume.cc: Fix comment typos.
2024-12-19 15:18:48 +00:00
Torbjörn SVENSSON 4bbb74c75c testsuite: arm: Use effective-target for memset-inline* tests
Split tests into 2 parts:
- The first part checkes the assmbler generated.
- The second part does the run test and this part now requires
  effective-target arm_neon_hw.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/memset-inline-4.c: Only check assembler output.
	* gcc.target/arm/memset-inline-5.c: Likewise.
	* gcc.target/arm/memset-inline-6.c: Likewise.
	* gcc.target/arm/memset-inline-8.c: Likewise.
	* gcc.target/arm/memset-inline-9.c: Likewise.
	* gcc.target/arm/memset-inline-4-exe.c: New test.
	* gcc.target/arm/memset-inline-5-exe.c: Likewise.
	* gcc.target/arm/memset-inline-6-exe.c: Likewise.
	* gcc.target/arm/memset-inline-8-exe.c: Likewise.
	* gcc.target/arm/memset-inline-9-exe.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 8462a5fdbf)
2024-12-19 13:11:18 +01:00
GCC Administrator 44da17c12b Daily bump. 2024-12-19 00:25:25 +00:00
Wilco Dijkstra 9366c32851 arm: Fix LDRD register overlap [PR117675]
The register indexed variants of LDRD have complex register overlap constraints
which makes them hard to use without using output_move_double (which can't be
used for atomics as it doesn't guarantee to emit atomic LDRD/STRD when required).
Add a new predicate and constraint for plain LDRD/STRD with base or base+imm.
This blocks register indexing and fixes PR117675.

gcc:
	PR target/117675
	* config/arm/arm.cc (arm_ldrd_legitimate_address): New function.
	* config/arm/arm-protos.h (arm_ldrd_legitimate_address): New prototype.
	* config/arm/constraints.md: Add new Uo constraint.
	* config/arm/predicates.md (arm_ldrd_memory_operand): Add new predicate.
	* config/arm/sync.md (arm_atomic_loaddi2_ldrd): Use
	arm_ldrd_memory_operand and Uo.

gcc/testsuite:
	PR target/117675
	* gcc.target/arm/pr117675.c: Add new test.

(cherry picked from commit 21fbfae2e5)
2024-12-18 15:12:01 +00:00
GCC Administrator f0caa19ff1 Daily bump. 2024-12-18 00:25:44 +00:00
Torbjörn SVENSSON 0361b4c440 testsuite: arm: Mark pr81812.C as xfail for thumb1
Test fails for Cortex-M0 with:

.../pr81812.C:6:8: error: generic thunk code fails for method 'virtual void ChildNode::_ZTv0_n12_NK9ChildNode5errorEz(...) const' which uses '...'

According to PR108277, it's expected that thumb1 targets does not
support empty virtual functions with ellipsis.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/pr81812.C: Add xfail for thumb1.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit f111d8e20b)
2024-12-17 19:14:15 +01:00
Paul Thomas 3b6ed0c741 Fortran: Pointer fcn results must not be finalized [PR117897]
2024-12-15  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/117897
	* trans-expr.cc (gfc_trans_assignment_1): RHS pointer function
	results must not be finalized.

gcc/testsuite/
	PR fortran/117897
	* gfortran.dg/finalize_59.f90: New test.

(cherry picked from commit a87bf1d20a)
2024-12-17 08:35:22 +00:00
GCC Administrator feeacb4edc Daily bump. 2024-12-17 00:25:13 +00:00
Joseph Myers e420277307 Update cpplib sr.po
* sr.po: Update.
2024-12-16 23:53:42 +00:00
Jonathan Wakely 29d07244bf libstdc++: Fix typo in Doxygen comment in <format>
libstdc++-v3/ChangeLog:

	* include/std/format: Fix typo in Doxygen comment.

(cherry picked from commit b7dd0d9760)
2024-12-16 15:53:18 +00:00
Heiko Eißfeldt 3396834cd1 doc: Fix typos for --enable-host-pie docs in install.texi
gcc/ChangeLog:

	* doc/install.texi (Configuration): Fix typos in documentation
	for --enable-host-pie.

(cherry picked from commit a7df4961d1)
2024-12-16 15:52:33 +00:00
Eric Botcazou dfd4d76b01 ada: Fix internal error with Atomic Volatile_Full_Access object
The initial implementation of the GNAT aspect/pragma Volatile_Full_Access
made it incompatible with Atomic, because it was not decided whether the
read-modify-write sequences generated by Volatile_Full_Access would need
to be implemented atomically when Atomic was also specified, which would
have required a compare-and-swap primitive from the target architecture.

But Ada 2022 introduced Full_Access_Only and retrofitted it into Atomic
in the process, answering the above question by the negative, so the
incompatibility between Volatile_Full_Access and Atomic was lifted in
Ada 2012 as well, unfortunately without adjusting the implementation.

gcc/ada/

	* gcc-interface/trans.cc (get_atomic_access): Deal specifically with
	nodes that are both Atomic and Volatile_Full_Access in Ada 2012.
2024-12-16 11:57:03 +01:00
GCC Administrator c1f2408220 Daily bump. 2024-12-16 00:23:19 +00:00
Paul Thomas 1572e634de Fortran: Fix non_overridable typebound proc problems [PR84674/117730].
2024-12-15  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/ChangeLog

	PR fortran/117730
	PR fortran/84674
	* class.cc (add_proc_comp): If the present typebound procedure
	component is abstract, unconditionally check the replacement.
	Only reject a non_overridable if it has no overridden procedure
	and the component is already present in the vtype.

gcc/testsuite/ChangeLog

	PR fortran/117730
	* gfortran.dg/pr117730_a.f90: New test.
	* gfortran.dg/pr117730_b.f90: New test.

	PR fortran/84674
	* gfortran.dg/pr84674.f90: New test.
2024-12-15 14:49:27 +00:00
GCC Administrator 9fc9b64098 Daily bump. 2024-12-15 00:23:20 +00:00
Gaius Mulley cfe21668f3 [PATCH] PR modula2/117120: case ch with a nul char constant causes ICE
This patch fixes the ICE caused when a case clause contains
a character constant ''.  The fix was to walk the caselist and
convert any 0 length string into a char constant of value 0.

gcc/m2/ChangeLog:

	PR modula2/117120
	* gm2-compiler/M2CaseList.mod (CaseBoundsResolved): Rewrite.
	(ConvertNulStr2NulChar): New procedure function.
	(NulStr2NulChar): Ditto.
	(GetCaseExpression): Ditto.
	(OverlappingCaseBound): Rewrite.
	* gm2-compiler/M2GCCDeclare.mod (CheckResolveSubrange): Allow
	'' to be used as the subrange low limit.
	* gm2-compiler/M2GenGCC.mod (FoldConvert): Rewrite.
	(PopKindTree): Ditto.
	(BuildHighFromString): Reformat.
	* gm2-compiler/SymbolTable.mod (PushConstString): Add test for
	length 0 and PushChar (nul).

gcc/testsuite/ChangeLog:

	PR modula2/117120
	* gm2/pim/pass/forloopnulchar.mod: New test.
	* gm2/pim/pass/nulcharcase.mod: New test.
	* gm2/pim/pass/nulcharvar.mod: New test.

(cherry picked from commit e0ab8816ea)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-14 11:46:57 +00:00
GCC Administrator 980e12480b Daily bump. 2024-12-14 00:25:58 +00:00
Marek Polacek 3454cca24a driver: fix crash with --diagnostics-plain-output [PR117942]
We are crashing here because decode_cmdline_options_to_array has:

  if (!strcmp (opt, "-fdiagnostics-plain-output"))
    ...

but that doesn't handle the '--FLAG' variant.

	PR driver/117942

gcc/ChangeLog:

	* opts-common.cc (decode_cmdline_options_to_array): Also detect
	--diagnostics-plain-output.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
(cherry picked from commit be2062be9a)
2024-12-13 12:25:54 -05:00
Marek Polacek 2fd2f40e04 c++: ICE with -Wduplicated-branches in template [PR117880]
In a template, for things like void() we'll create a CAST_EXPR with
a null operand.  That causes a crash with -Wduplicated-branches on:

  false ? void() : void();

because we do

  if (warn_duplicated_branches
      && (complain & tf_warning)
      && (arg2 == arg3 || operand_equal_p (arg2, arg3,
                                           OEP_ADDRESS_OF_SAME_FIELD)))

even in a template.  So one way to fix the ICE would be to check
!processing_template_decl.  But we can also do the following and
continue warning even in templates.

This ICE appeared with the removal of NON_DEPENDENT_EXPR; before,
operand_equal_p would bail on this code so there was no problem.

	PR c++/117880

gcc/ChangeLog:

	* fold-const.cc (operand_compare::operand_equal_p) <case tcc_unary>:
	Use OP_SAME_WITH_NULL instead of OP_SAME.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wduplicated-branches8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit d26c166001)
2024-12-13 12:22:39 -05:00
Gaius Mulley da470844ae [PATCH] PR modula2/115328: use enable forward bool and set default true
This patch introduces GetEnableForward and SetEnableForward
against which the forward procedure declaration feature is checked.
Currently this is set as default true.

gcc/m2/ChangeLog:

	PR modula2/115328
	* gm2-compiler/M2Options.def (GetEnableForward): New procedure
	function.
	(SetEnableForward): New procedure.
	* gm2-compiler/M2Options.mod (GetEnableForward): New procedure
	function.
	(SetEnableForward): New procedure.
	(EnableForward): New boolean.
	* gm2-compiler/P1SymBuild.mod (EndBuildForward): Check
	GetEnableForward and generate an error message if false.

gcc/testsuite/ChangeLog:

	PR modula2/115328
	* gm2/pim/fail/forward.mod: Move to...
	* gm2/pim/pass/forward.mod: ...here.

(cherry picked from commit 548afd73cd)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-13 14:10:19 +00:00
GCC Administrator c27a18962a Daily bump. 2024-12-13 00:24:16 +00:00
Eric Botcazou d470d64b39 Fix precondition failure with Ada.Numerics.Generic_Real_Arrays.Eigenvalues
This fixes a precondition failure triggered when the Eigenvalues routine
of Ada.Numerics.Generic_Real_Arrays is instantiated with -gnata, beause
it calls Sort_Eigensystem on an empty vector.

gcc/ada
	PR ada/117996
	* libgnat/a-ngrear.adb (Jacobi): Remove default value for
	Compute_Vectors formal parameter.
	(Sort_Eigensystem): Add Compute_Vectors formal parameter.  Do not
	modify the Vectors if Compute_Vectors is False.
	(Eigensystem): Pass True as Compute_Vectors to Sort_Eigensystem.
	(Eigenvalues): Pass False as Compute_Vectors to Sort_Eigensystem.

gcc/testsuite
	* gnat.dg/matrix1.adb: New test.
2024-12-12 16:32:20 +01:00
Torbjörn SVENSSON cbedb3394a testsuite: arm: Use -mtune=cortex-m4 for thumb-ifcvt.c test
On Cortex-M4, the code generated is:
     cmp     r0, r1
     itte    ne
     lslne   r0, r0, r1
     asrne   r0, r0, #1
     moveq   r0, r1
     add     r0, r0, r1
     bx      lr

On Cortex-M7, the code generated is:
     cmp     r0, r1
     beq     .L3
     lsls    r0, r0, r1
     asrs    r0, r0, #1
     add     r0, r0, r1
     bx      lr
.L3:
     mov     r0, r1
     add     r0, r0, r1
     bx      lr

As Cortex-M7 only allow maximum one conditional instruction, force
Cortex-M4 to have a stable test case.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/thumb-ifcvt.c: Use -mtune=cortex-m4.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit e7615f6c99)
2024-12-12 12:40:27 +01:00
Torbjörn SVENSSON add35600a6 testsuite: arm: Fix build error for thumb2-slow-flash-data-3.c test
gcc/testsuite/ChangeLog:

	* gcc.target/arm/thumb2-slow-flash-data-3.c: Added argument to
	fn1 to avoid compile error.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 09499ffbb3)
2024-12-12 12:40:26 +01:00
GCC Administrator 7121921723 Daily bump. 2024-12-12 00:23:25 +00:00
Jerry DeLisle 2d9dbaf06e Fortran: Fix READ with padding in BLANK ZERO mode.
PR fortran/117819

libgfortran/ChangeLog:

	* io/read.c (read_decimal): If the read value is short of the
	specified width and pad mode is PAD yes, check for BLANK ZERO
	and adjust the value accordingly.
	(read_radix): Likewise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit cf406a6c79)
2024-12-11 10:59:08 -08:00
GCC Administrator 6ddd89591c Daily bump. 2024-12-11 00:23:27 +00:00
GCC Administrator 21a09f0507 Daily bump. 2024-12-10 00:25:55 +00:00
Juergen Christ 7b58a7e27a s390: Fix UNSPEC_CC_TO_INT canonicalization
Canonicalization of comparisons for UNSPEC_CC_TO_INT missed one case
causing unnecessarily complex code.  This especially seems to hit the
Linux kernel.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_canonicalize_comparison): Add
	missing UNSPEC_CC_TO_INT case.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/ccusage.c: New test.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
(cherry picked from commit bdc572f9a4)
2024-12-09 15:26:54 +01:00
Simon Martin ac054467bf tree-eh: Don't crash on GIMPLE_TRY_FINALLY with empty cleanup sequence [PR117845]
The following valid code triggers an ICE with -fsanitize=address

=== cut here ===
void l() {
    auto const ints = {0,1,2,3,4,5};
    for (auto i : { 3 } ) {
        __builtin_printf("%d ", i);
    }
}
=== cut here ===

The problem is that honor_protect_cleanup_actions does not expect the
cleanup sequence of a GIMPLE_TRY_FINALLY to be empty. It is however the
case here since r14-8681-gceb242f5302027, because lower_stmt removes the
only statement in the sequence: a ASAN_MARK statement for the array that
backs the initializer_list).

This patch simply checks that the finally block is not 0 before
accessing it in honor_protect_cleanup_actions.

	PR c++/117845

gcc/ChangeLog:

	* tree-eh.cc (honor_protect_cleanup_actions): Support empty
	finally sequences.

gcc/testsuite/ChangeLog:

	* g++.dg/asan/pr117845-2.C: New test.
	* g++.dg/asan/pr117845.C: New test.

(cherry picked from commit 3076539544)
2024-12-09 09:24:53 +01:00
GCC Administrator 7b8f236187 Daily bump. 2024-12-09 00:23:27 +00:00
Uros Bizjak c08ae0cf33 i386: Fix unwanted fwprop to 3dNOW! insn [PR117926]
The compiler is able to forward propagate a partial vector V4SF instruction
using XMM registers to a 3dNOW! V2SF instruction using MM registers.  Prevent
unwanted transformation by tagging 3dNOW! V2SF instructions using generic
RTXes with "(unspec [(const_int 0)] UNSPEC_3DNOW)" tag.

	PR target/117926

gcc/ChangeLog:

	* config/i386/mmx.md (UNSPEC_3DNOW): New unspec.
	(mmx_addv2sf3): Tag insn with UNSPEC_3DNOW tag.
	(*mmx_addv2sf3): Ditto.
	(mmx_sub2vsf3): Ditto.
	(mmx_subrv2sf3): Ditto.
	(*mmx_subv2sf3): Ditto.
	(mmx_mulv2sf3): Ditto.
	(mmx_<smaxmin:code>v2sf3): Ditto.
	(*mmx_<smaxmin:code>v2sf3): Ditto.
	(mmx_ieee_<ieee_maxmin>v2sf3): Ditto.
	(mmx_eqv2sf3): Ditto.
	(*mmx_eqv2sf3): Ditto.
	(mmx_gtv2sf3): Ditto.
	(mmx_gev2sf3): Ditto.
	(mmx_fix_truncv2sfv2si2): Ditto.
	(mmx_floatv2siv2sf2): Ditto.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 1acc5cffbb)
2024-12-08 15:04:13 +01:00
GCC Administrator 5e9cd91ce2 Daily bump. 2024-12-08 00:23:12 +00:00
Gaius Mulley 6385000d36 [PATCH] PR modula2/117948: Forward procedure declaration should only be available in ISO
This patch restricts the forward procedure declaration to the ISO dialect.

gcc/m2/ChangeLog:

	PR modula2/117948
	* gm2-compiler/P1Build.bnf (ForwardDeclaration): Pass token
	position of the FORWARD keyword to EndBuildForward.
	* gm2-compiler/P1SymBuild.def (EndBuildForward): New parameter
	forwardPos.
	* gm2-compiler/P1SymBuild.mod (EndBuildForward): Issue an error at
	forwardPos if the Iso boolean is false.

gcc/testsuite/ChangeLog:

	PR modula2/117948
	* gm2/pim/fail/forward.mod: New test.

(cherry picked from commit 4180037214)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-07 15:56:21 +00:00
GCC Administrator 5e55168b76 Daily bump. 2024-12-07 00:23:41 +00:00
Jerry DeLisle 1dbbfe23b1 Fortran: Fix B64.0 formatted write output.
PR fortran/117820

libgfortran/ChangeLog:

	* io/write.c (write_b): Add test for zero needed by write_boz.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 7a92ba7668)
2024-12-06 10:12:10 -08:00
Jerry DeLisle be532c74fd Fortran: Eliminate error prone translations.
PR fortran/109105

gcc/fortran/ChangeLog:

	* resolve.cc (CHECK_INTERFACES): New helper macro.
	(resolve_operator): Replace use of snprintf with
	gfc_error.

(cherry picked from commit 000045fdf8)
2024-12-06 10:04:21 -08:00
Gaius Mulley 7dff53cb7b [PATCH] PR modula2/117904: cc1gm2 ICE when compiling a const built from VAL and SIZE
This patch fixes an ICE which occurs when a positive ZType constant
increment is used during a FOR loop.

gcc/m2/ChangeLog:

	PR modula2/117904
	* gm2-compiler/M2GenGCC.mod (PerformLastForIterator): Add call to
	BuildConvert when increment is > 0.

gcc/testsuite/ChangeLog:

	PR modula2/117904
	* gm2/iso/pass/forloopbyconst.mod: New test.

(cherry picked from commit 363382ac7c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-06 13:06:58 +00:00
Andrew Pinski ad590070fd fortran: Add default to switch in gfc_trans_transfer [PR117843]
This fixes a bootstrap failure due to a warning on enum values not being
handled. In this case, it is just checking two values and the rest should
are not handled so adding a default case fixes the issue.

Pushed as obvious.

	PR fortran/117843
gcc/fortran/ChangeLog:

	* trans-io.cc (gfc_trans_transfer): Add default case.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 48b72743b0)
2024-12-06 10:04:48 +01:00
Harald Anlauf d3c18b92c9 Fortran: fix crash with bounds check writing array section [PR117791]
PR fortran/117791

gcc/fortran/ChangeLog:

	* trans-io.cc (gfc_trans_transfer): When an array index depends on
	a function evaluation or an expression, do not use optimized array
	I/O of an array section and fall back to normal scalarization.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 2261a15c07)
2024-12-06 10:04:37 +01:00
GCC Administrator de7dc9bb0e Daily bump. 2024-12-06 00:24:09 +00:00
Simon Martin 4a73efcbdc c++: Don't reject pointer to virtual method during constant evaluation [PR117615]
We currently reject the following valid code:

=== cut here ===
struct Base {
    virtual void doit (int v) const {}
};
struct Derived : Base {
    void doit (int v) const {}
};
using fn_t = void (Base::*)(int) const;
struct Helper {
    fn_t mFn;
    constexpr Helper (auto && fn) : mFn(static_cast<fn_t>(fn)) {}
};
void foo () {
    constexpr Helper h (&Derived::doit);
}
=== cut here ===

The problem is that since r6-4014-gdcdbc004d531b4, &Derived::doit is
represented with an expression with type pointer to method and using an
INTEGER_CST (here 1), and that cxx_eval_constant_expression rejects any
such expression with a non-null INTEGER_CST.

This patch uses the same strategy as r12-4491-gf45610a45236e9 (fix for
PR c++/102786), and simply lets such expressions go through.

	PR c++/117615

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_constant_expression): Don't reject
	INTEGER_CSTs with type POINTER_TYPE to METHOD_TYPE.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-virtual22.C: New test.

(cherry picked from commit 72a2380a30)
2024-12-05 12:46:35 +01:00
Georg-Johann Lay 0eb7f0a860 AVR: target/64242 - Copy FP to a local reg in nonlocal_goto.
In nonlocal_goto sets, change hard_frame_pointer_rtx only after
emit_stack_restore() restored SP.  This is needed because SP
my be stored in some frame location.

gcc/
	PR target/64242
	* config/avr/avr.md (nonlocal_goto): Don't restore
	hard_frame_pointer_rtx directly, but copy it to local
	register, and only set hard_frame_pointer_rtx from it
	after emit_stack_restore().

(cherry picked from commit f7b5527d1b)
2024-12-05 11:47:42 +01:00
GCC Administrator 524ba3a600 Daily bump. 2024-12-05 00:25:32 +00:00
Gaius Mulley 5902ea4a34 [PATCH] PR modula2/117660: Errors referring to variables of type array could display full declaration
This patch ensures that the tokens defining the full declaration of an
ARRAY type is stored in the symbol table and used during production of
error messages.

gcc/m2/ChangeLog:

	PR modula2/117660
	* gm2-compiler/P2Build.bnf (ArrayType): Update tok with the
	composite token produced during array type declaration.
	* gm2-compiler/P2SymBuild.mod (EndBuildArray): Create the
	combinedtok and store it into the symbol table.
	Also ensure combinedtok is pushed to the quad stack.
	(BuildFieldArray): Preserve typetok.
	* gm2-compiler/SymbolTable.def (PutArray): Rename parameters.
	* gm2-compiler/SymbolTable.mod (PutArray): Rename parameters.

gcc/testsuite/ChangeLog:

	PR modula2/117660
	* gm2/iso/fail/arraymismatch.mod: New test.

(cherry picked from commit ab7abf1db0)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-04 09:03:36 +00:00
Gaius Mulley f43c2ee451 [PATCH] PR modula2/117371: Add check for zero step in for loop
This patch is a follow on from PR modula2/117371 which could include
a check to enforce the ISO restriction on a zero for loop step.

gcc/m2/ChangeLog:

	PR modula2/117371
	* gm2-compiler/M2GenGCC.mod (PerformLastForIterator):
	Add check for zero step value and issue an error message.

gcc/testsuite/ChangeLog:

	PR modula2/117371
	* gm2/iso/fail/forloopbyzero.mod: New test.

(cherry picked from commit e37641458e)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-04 08:01:13 +00:00
GCC Administrator 5ce16f91f0 Daily bump. 2024-12-04 00:27:27 +00:00
Gaius Mulley c1409e1955 [PATCH] PR modula2/117371: type incompatibility between INTEGER and CARDINAL
This patch enforces a const expression increment in a FOR loop.
It also fixes missing error locations.  The FOR loop last iterator
value is now calculated during M2GenGCC after all types and constants have
been resolved.  This results in fewer quadruples (as there is no need to
build two paths for step > 0 and step < 0).

gcc/m2/ChangeLog:

	PR modula2/117371
	* gm2-compiler/M2Base.mod (MixMetaTypes): Add parameter TRUE to
	MetaErrorDecl.
	(IsUserType): Test against ZType.
	(MixTypesDecl): Test for ZType.
	* gm2-compiler/M2GenGCC.mod (ErrorMessageDecl): Add parameter TRUE to
	MetaErrorDecl.
	(CodeLastForIterator): New procedure.
	(FoldLastForIterator): Ditto.
	(PerformLastForIterator): Ditto.
	(CodeStatement): Add case clause for LastForIteratorOp.
	(ErrorMessageDecl): Add iserror parameter.
	Call MetaErrorDecl with iserror parameter.
	(checkIncorrectMeta): Call MetaErrorDecl with TRUE parameter.
	(CheckBinaryExpressionTypes): Ditto.
	(CheckElementSetTypes): Ditto.
	* gm2-compiler/M2LexBuf.def (MakeVirtualTok): Update comment
	detailing the fall back when UnknownTokenNo is encountered.
	(MakeVirtual2Tok): Ditto.
	* gm2-compiler/M2LexBuf.mod (MakeVirtualTok): Check against
	UnknownTokenNo.
	(MakeVirtual2Tok): Ditto.
	* gm2-compiler/M2MetaError.def (MetaErrorDecl): Add error parameter.
	* gm2-compiler/M2MetaError.mod (MetaErrorDecl): Add error
	parameter.
	Issue warning if error is FALSE.
	* gm2-compiler/M2Quads.def (QuadOperator): Add LastForIteratorOp.
	* gm2-compiler/M2Quads.mod (AddQuadInformation): New case clause
	LastForIteratorOp.
	(CheckAddTuple2Read): New procedure.
	(BuildForLoopToRangeCheck): Remove.
	(ForLoopLastIteratorVariable): Ditto.
	(ForLoopLastIteratorConstant): Ditto.
	(ForLoopLastIterator): Reimplement.
	(BuildForToByDo): Remove ByType from call to ForLoopLastIterator.
	(WriteQuad): New case clause LastForIteratorOp.
	(WriteOperator): Ditto.
	* gm2-compiler/M2Students.def
	(CheckForVariableThatLooksLikeKeyword): Replace with ...
	(CheckVariableAgainstKeyword): ... this.
	* gm2-compiler/M2Students.mod
	(CheckForVariableThatLooksLikeKeyword): Replace with ...
	(CheckVariableAgainstKeyword): ... this.
	* gm2-compiler/M2SymInit.mod (CheckLastForIterator): New
	procedure.
	(CheckReadBeforeInitQuad): New case clause to call
	CheckLastForIterator.
	* gm2-compiler/P2SymBuild.mod: Replace
	CheckForVariableThatLooksLikeKeyword with CheckVariableAgainstKeyword.

gcc/testsuite/ChangeLog:

	PR modula2/117371
	* gm2/iso/fail/forloopbyvar.mod: New test.
	* gm2/iso/fail/forloopbyvar4.mod: New test.
	* gm2/iso/fail/forloopbyvar5.mod: New test.
	* gm2/iso/pass/forloopbyvar3.mod: New test.

(cherry picked from commit f242f79b8a)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-04 00:11:22 +00:00
Gaius Mulley de4f10f07c [PATCH] modula2: Add dependencies for generated sources
This patch adds rules and dependencies for the automatically
generated grammar sources.  Bootstrapped using make -j 160.

gcc/m2/ChangeLog:

	* Make-lang.in (m2/gm2-compiler-boot/P0SyntaxCheck.c):
	New rule.
	(m2/gm2-compiler-boot/P0SyntaxCheck.o): Ditto.
	(m2/gm2-compiler-boot/P1Build.c): Ditto.
	(m2/gm2-compiler-boot/P1Build.o): Ditto.
	(m2/gm2-compiler-boot/P2Build.c): Ditto.
	(m2/gm2-compiler-boot/P2Build.o): Ditto.
	(m2/gm2-compiler-boot/P3Build.c): Ditto.
	(m2/gm2-compiler-boot/P3Build.o): Ditto.
	(m2/gm2-compiler-boot/PCBuild.c): Ditto.
	(m2/gm2-compiler-boot/PCBuild.o): Ditto.
	(m2/gm2-compiler-boot/PHBuild.c): Ditto.
	(m2/gm2-compiler-boot/PHBuild.o): Ditto.

(cherry picked from commit 3e6a782403)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-03 21:17:20 +00:00
Gaius Mulley 3dff2f932c [PATCH] modula2: Reimplement parameter declaration and checking.
This patch improves the parameter declaration by saving all parameter
kinds: proper procedure, definition module procedure and forward
procedures.  This allows error messages to reference any parameter
in the three kinds of procedures.  Variables and their declaration
are also stored.  The expression, assignment and parameter checking
has been improved to highlight any variable or parameter and
its declaration causing a conflict.

gcc/m2/ChangeLog:

	* gm2-compiler/M2Base.def (MixTypes): Rename parameters.
	(MixTypesDecl): New procedure function.
	* gm2-compiler/M2Base.mod (BuildOrdFunctions): Add
	DefProcedure parameter to PutFunction.
	(BuildTruncFunctions): Ditto.
	(BuildFloatFunctions): Ditto.
	(BuildIntFunctions): Ditto.
	(InitBaseFunctions): Ditto.
	(MixTypesDecl): New procedure function.
	(MixTypes): Reimplement.
	* gm2-compiler/M2Check.mod (checkProcType): Replace
	NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	(checkProcedureProcType): Ditto.
	* gm2-compiler/M2Error.def: Remove unnecessary export qualified list.
	* gm2-compiler/M2GCCDeclare.mod: Replace NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	(DeclareProcedureToGccWholeProgram): Rename son to
	Variable.
	(DeclareProcedureToGccSeparateProgram): Ditto.
	(PrintKind): New procedure.
	(PrintProcedureParameters): Ditto.
	(PrintProcedureReturnType): Ditto.
	(PrintProcedure): Reimplement.
	(PrintProcTypeParameters): New procedure.
	(PrintProcType): Ditto.
	(DeclareProcType): Rename Son to Parameter.
	* gm2-compiler/M2GenGCC.mod: Replace NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	(ErrorMessageDecl): New procedure.
	(checkIncorrectMeta): Replace call to MetaErrorT2 with
	ErrorMessageDecl.
	(ComparisonMixTypes): Add varleft and varright parameters.
	Adjust all callers of ComparisonMixTypes.
	* gm2-compiler/M2MetaError.def (MetaErrorDecl): New procedure.
	* gm2-compiler/M2MetaError.mod (MetaErrorDecl): New procedure.
	* gm2-compiler/M2Options.def (SetXCode): Add -fd flag description
	to comment.
	* gm2-compiler/M2Options.mod (SetXCode): Add -fd flag description
	to comment.
	* gm2-compiler/M2Quads.mod (CheckBreak): New procedure.
	Replace NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	(FailParameter): Reimplement using GetVarDeclFullTok.
	Generate message for formal parameter, actual parameter and
	declaration of actual parameter.
	(WarnParameter): Ditto.
	(CheckBuildFunction): Reimplement error message using MetaErrorT1.
	* gm2-compiler/M2Range.mod: Replace NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	* gm2-compiler/M2Scaffold.mod (DeclareScaffoldFunctions): Call
	PutProcedureDefined after every procedure declaration.
	(DeclareArgEnvParams): Add ProperProcedure parameter to PutParam.
	* gm2-compiler/M2Size.mod (MakeSize): Add DefProcedure parameter
	to PutFunction.
	* gm2-compiler/M2Swig.mod: Replace NoOfParam with NoOfParamAny.
	Replace IsVarParam with IsVarParamAny.
	* gm2-compiler/M2SymInit.mod: Ditto.
	* gm2-compiler/M2System.mod (InitSystem): Add DefProcedure
	parameter to PutFunction.
	* gm2-compiler/P1SymBuild.mod (StartBuildProcedure): Reimplement.
	(EndBuildProcedure): Ditto.
	(EndBuildForward): Ditto.
	* gm2-compiler/P2Build.bnf (BuildProcedureDefinedByForward):
	Remove.
	(BuildProcedureDefinedByProper): Ditto.
	(ForwardDeclaration): Remove BuildProcedureDefinedByForward.
	(BuildNoReturnAttribute): Remove parameter.
	* gm2-compiler/P2SymBuild.def (BuildNoReturnAttribute): Remove
	parameter.
	(BuildProcedureDefinedByForward): Remove.
	(BuildProcedureDefinedByProper): Ditto.
	* gm2-compiler/P2SymBuild.mod (Import): Remove
	AreParametersDefinedInDefinition,
	AreParametersDefinedInImplementation,
	AreProcedureParametersDefined,
	ParametersDefinedInDefinition,
	ParametersDefinedInImplementation,
	GetProcedureDeclaredDefinition,
	GetProcedureDeclaredForward,
	GetProcedureDeclaredProper,
	GetParametersDefinedByForward,
	GetParametersDefinedByProper and
	PutProcedureNoReturn.
	Add PutProcedureParametersDefined,
	GetProcedureParametersDefined,
	GetProcedureKindDesc,
	GetProcedureDeclaredTok,
	GetProcedureKind,
	GetReturnTypeTok,
	SetReturnOptional,
	IsReturnOptional,
	PutProcedureNoReturn and
	PutProcedureDefined.
	(Debug): New procedure.
	(P2StartBuildDefModule): Space formatting.
	(BuildVariable): Reimplement to record full declaration.
	(StartBuildProcedure): Reimplement using token to determine
	the kind of procedure.
	(BuildProcedureHeading): Ditto.
	(BuildFPSection): Ditto.
	(BuildVarArgs): Ditto.
	(BuildOptArg): Ditto.
	(BuildProcedureDefinedByForward): Remove.
	(BuildProcedureDefinedByProper): Ditto.
	(BuildFormalParameterSection): Reimplement so that the
	quad stack is unchanged.
	(CheckFormalParameterSection): Ditto.
	(RemoveFPParameters): New procedure.
	(ParameterError): Reimplement.
	(StartBuildFormalParameters): Add annotation.
	(ParameterMismatch): Reimplement.
	(EndBuildFormalParameters): Reimplement to check against
	all procedure kinds.
	(GetSourceDesc): Remove.
	(GetCurSrcDesc): Ditto.
	(GetDeclared): Ditto.
	(ReturnTypeMismatch): Reimplement.
	(BuildFunction): Ditto.
	(BuildOptFunction): Ditto.
	(CheckOptFunction): New procedure.
	(BuildNoReturnAttribute): Remove parameter and obtain
	procedure symbol from quad stack.
	(CheckProcedureReturn): New procedure.
	* gm2-compiler/P3SymBuild.mod (BuildOptArgInitializer):
	Preserve ProcSym tok on the quad stack.
	Add Assert.
	* gm2-compiler/PCSymBuild.mod (fixupProcedureType): Replace
	NoOfParam with NoOfParamAny.
	* gm2-compiler/SymbolTable.def (GetNthParam): Add ProcedureKind
	parameter.
	(PutFunction): Ditto.
	(PutOptFunction): Ditto.
	(IsReturnOptional): Ditto.
	(PutParam): Ditto.
	(PutVarParam): Ditto.
	(PutParamName): Ditto.
	(PutProcedureNoReturn): Ditto.
	(IsProcedureNoReturn): Ditto.
	(IsVarParam): Ditto.
	(IsUnboundedParam): Ditto.
	(NoOfParam): Ditto.
	(ForeachLocalSymDo): Ditto.
	(GetProcedureKind): Ditto.
	(GetProcedureDeclaredTok): Ditto.
	(PutProcedureDeclaredTok): Ditto.
	(GetReturnTypeTok): Ditto.
	(PutReturnTypeTok): Ditto.
	(PutParametersDefinedByForward): New procedure.
	(PutProcedureParametersDefined): Ditto.
	(PutProcedureDefined): Ditto.
	(GetParametersDefinedByProper): Ditto.
	(GetProcedureDeclaredForward): Ditto.
	(GetProcedureDeclaredProper): Ditto.
	(PutProcedureDeclaredProper): Ditto.
	(GetProcedureDeclaredDefinition): Ditto.
	(PutProcedureDeclaredDefinition): Ditto.
	(GetProcedureDefined): Ditto.
	(PutUseOptArg): Ditto.
	(UsesOptArg): Ditto.
	(PutOptArgInit): Ditto.
	(SetReturnOptional): Ditto.
	(UsesOptArgAny): Ditto.
	(GetProcedureKindDesc): Ditto.
	(IsReturnOptionalAny): New procedure function.
	(GetNthParamAny): Ditto.
	(NoOfParamAny): Ditto.
	(IsProcedureAnyNoReturn): Ditto.
	(AreParametersDefinedInImplementation): Remove.
	(ParametersDefinedInImplementation): Ditto.
	(AreParametersDefinedInDefinition): Ditto.
	(AreProcedureParametersDefined): Ditto.
	(ParametersDefinedInDefinition): Ditto.
	(ProcedureParametersDefined): Ditto.
	(PutParametersDefinedByProper): Ditto.
	(PutProcedureDeclaredForward): Ditto.
	(GetParametersDefinedByForward): Ditto.
	(GetProcedureParametersDefined): Ditto.
	(PushOffset): Ditto.
	(PopSize): Ditto.
	(PushParamSize): Ditto.
	(PushSumOfLocalVarSize): Ditto.
	(PushSumOfParamSize): Ditto.
	(PopOffset): Ditto.
	(PopSumOfParamSize): Ditto.
	* gm2-compiler/SymbolTable.mod (MakeProcedure): Reimplement.
	(PutProcedureNoReturn): Add ProcedureKind parameter.
	(GetNthParam): Ditto.
	(PutFunction): Ditto.
	(PutOptFunction): Ditto.
	(IsReturnOptional): Ditto.
	(MakeVariableForParam): Ditto.
	(PutParam): Ditto.
	(PutVarParam): Ditto.
	(PutParamName): Ditto.
	(AddParameter): Ditto.
	(IsVarParam): Ditto.
	(IsVarParamAny): Ditto.
	(NoOfParam): Ditto.
	(HasVarParameters): Ditto.
	(IsUnboundedParam): Ditto.
	(PutUseVarArgs): Ditto.
	(UsesVarArgs): Ditto.
	(PutUseOptArg): Ditto.
	(UsesOptArg): Ditto.
	(UsesOptArgAny): Ditto.
	(PutOptArgInit): Ditto.
	(IsProcedure): Ditto.
	(IsPointer): Ditto.
	(IsRecord): Ditto.
	(IsArray): Ditto.
	(IsEnumeration): Ditto.
	(IsUnbounded): Ditto.
	(IsSet): Ditto.
	(IsSetPacked): Ditto.
	(CheckUnbounded): Ditto.
	(IsOAFamily): Ditto.
	(IsModuleWithinProcedure): Ditto.
	(GetDeclaredDef): Ditto.
	(GetDeclaredMod): Ditto.
	(GetDeclaredFor): Ditto.
	(GetProcedureDeclaredForward): Ditto.
	(GetProcedureKind): Ditto.
	(PutProcedureDeclaredForward): Ditto.
	(GetProcedureDeclaredTok): Ditto.
	(GetProcedureDeclaredProper): Ditto.
	(PutProcedureDeclaredTok): Ditto.
	(PutProcedureDeclaredProper): Ditto.
	(GetReturnTypeTok): Ditto.
	(GetProcedureDeclaredDefinition): Ditto.
	(PutReturnTypeTok): Ditto.
	(PutProcedureDeclaredDefinition): Ditto.
	(GetProcedureKindDesc): Ditto.
	(IsProcedureVariable): Ditto.
	(IsAModula2Type): Ditto.
	(GetParam): Ditto.
	(ProcedureParametersDefined): Ditto.
	(AreParametersDefinedInImplementation): Remove.
	(AreParametersDefinedInDefinition): Ditto.
	(AreProcedureParametersDefined): Ditto.
	(IsSizeSolved): Ditto.
	(IsOffsetSolved): Ditto.
	(IsValueSolved): Ditto.
	(IsSumOfParamSizeSolved): Ditto.
	(PushSize): Ditto.
	(PushOffset): Ditto.
	(PopSize): Ditto.
	(PushValue): Ditto.
	(PushParamSize): Ditto.
	(PushSumOfLocalVarSize): Ditto.
	(PushSumOfParamSize): Ditto.
	(PushVarSize): Ditto.
	(PopValue): Ditto.
	(PopSize): Ditto.
	(PopOffset): Ditto.
	(PopSumOfParamSize): Ditto.
	(PutParametersDefinedByForward): New procedure.
	(PutProcedureParametersDefined): Ditto.
	(PutProcedureDefined): Ditto.
	(GetParametersDefinedByProper): Ditto.
	(GetProcedureDeclaredForward): Ditto.
	(GetProcedureDeclaredProper): Ditto.
	(PutProcedureDeclaredProper): Ditto.
	(GetProcedureDeclaredDefinition): Ditto.
	(PutProcedureDeclaredDefinition): Ditto.
	(GetProcedureDefined): Ditto.
	(PutUseOptArg): Ditto.
	(UsesOptArg): Ditto.
	(PutOptArgInit): Ditto.
	(SetReturnOptional): Ditto.
	(UsesOptArgAny): Ditto.
	(GetProcedureKindDesc): Ditto.
	(PutParametersDefinedByProper): Ditto.
	(GetParametersDefinedByProper): Ditto.
	(IsReturnOptionalAny): New procedure function.
	(IsProcedureAnyDefaultBoolean): Ditto.
	(IsProcedureAnyBoolean): Ditto.
	(IsProcedureAnyNoReturn): Ditto.
	(GetNthParamAny): Ditto.
	(NoOfParamAny): Ditto.
	(IsProcedureAnyNoReturn): Ditto.
	(GetProcedureKind): Ditto.
	(IsVarParamAny): Ditto.
	(IsUnboundedParamAny): Ditto.
	(ForeachParamSymDo): New comment.
	* gm2-libs-coroutines/SYSTEM.mod: Reformat.

gcc/testsuite/ChangeLog:

	* gm2/iso/fail/badexpression3.mod: New test.
	* gm2/iso/fail/badparam4.def: New test.
	* gm2/iso/fail/badparam4.mod: New test.

(cherry picked from commit 95960cd473)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-03 21:16:25 +00:00
Joseph Myers 92014ea7ca Update gcc zh_CN.po
* zh_CN.po: Update.
2024-12-03 18:28:09 +00:00
Tamar Christina f01f01f0eb middle-end:For multiplication try swapping operands when matching complex multiply [PR116463]
This commit fixes the failures of complex.exp=fast-math-complex-mls-*.c on the
GCC 14 branch and some of the ones on the master.

The current matching just looks for one order for multiplication and was relying
on canonicalization to always give the right order because of the TWO_OPERANDS.

However when it comes to the multiplication trying only one order is a bit
fragile as they can be flipped.

The failing tests on the branch are:

void fms180snd(_Complex TYPE a[restrict N], _Complex TYPE b[restrict N],
               _Complex TYPE c[restrict N]) {
  for (int i = 0; i < N; i++)
    c[i] -= a[i] * (b[i] * I * I);
}

void fms180fst(_Complex TYPE a[restrict N], _Complex TYPE b[restrict N],
               _Complex TYPE c[restrict N]) {
  for (int i = 0; i < N; i++)
    c[i] -= (a[i] * I * I) * b[i];
}

The issue is just a small difference in commutative operations.
we look for {R,R} * {R,I} but found {R,I} * {R,R}.

Since the DF analysis is cached, we should be able to swap operands and retry
for multiply cheaply.

There is a constraint being checked by vect_validate_multiplication for the data
flow of the operands feeding the multiplications.  So e.g.

between the nodes:

note:   node 0x4d1d210 (max_nunits=2, refcnt=3) vector(2) double
note:   op template: _27 = _10 * _25;
note:      stmt 0 _27 = _10 * _25;
note:      stmt 1 _29 = _11 * _25;
note:   node 0x4d1d060 (max_nunits=2, refcnt=2) vector(2) double
note:   op template: _26 = _11 * _24;
note:      stmt 0 _26 = _11 * _24;
note:      stmt 1 _28 = _10 * _24;

we require the lanes to come from the same source which
vect_validate_multiplication checks.  As such it doesn't make sense to flip them
individually because that would invalidate the earlier linear_loads_p checks
which have validated that the arguments all come from the same datarefs.

This patch thus flips the operands in unison to still maintain this invariant,
but also honor the commutative nature of multiplication.

gcc/ChangeLog:

	PR tree-optimization/116463
	* tree-vect-slp-patterns.cc (complex_mul_pattern::matches,
	complex_fms_pattern::matches): Try swapping operands on multiply.

(cherry picked from commit a9473f9c6f)
2024-12-03 16:20:07 +00:00
Gaius Mulley d35eeeca7b [PATCH] modula2: M2MetaError.{def,mod} and P2SymBuild.mod further cleanup
Further cleanups and improve the wording of an error message.

gcc/m2/ChangeLog:

	* gm2-compiler/M2MetaError.mod (op): Corrected ordering.
	* gm2-compiler/P2SymBuild.def: Remove comment.
	* gm2-compiler/P2SymBuild.mod (GetComparison): Replace
	the word less with fewer.

(cherry picked from commit 961c02313f)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-03 15:58:27 +00:00
Gaius Mulley b16824e10d [PATCH] modula2: Tidyup gm2-compiler/M2MetaError.mod
This patch is a tidyup for gm2-compiler/M2MetaError.mod.

gcc/m2/ChangeLog:

	* gm2-compiler/M2MetaError.mod (op): Alphabetically order
	each case label and comment.

(cherry picked from commit 7fa9fd47f1)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-03 14:39:03 +00:00
Gaius Mulley e8acf6816c [PATCH] PR modula2/115328 The FORWARD keyword is not implemented
This patch implements the FORWARD keyword found in the ISO standard.
The patch checks incoming parameters against the prior declaration
found in definition/forward sections and will issue an error based
on virtual tokens highlighing the full parameter declaration.

gcc/m2/ChangeLog:

	PR modula2/115328
	* gm2-compiler/M2MetaError.def: Extend comment documentating
	new format specifiers.
	* gm2-compiler/M2MetaError.mod (GetTokProcedure): New declaration.
	(doErrorScopeModule): New procedure.
	(doErrorScopeForward): Ditto.
	(doErrorScopeMod): Reimplement.
	(doErrorScopeFor): New procedure.
	(declarationMod): Ditto.
	(doErrorScopeDefinition): Ditto.
	(doErrorScopeDef): Reimplement.
	(declaredDef): New procedure.
	(declaredFor): Ditto.
	(doErrorScopeProc): Ditto.
	(declaredVar): Ditto.
	(declaredType): Ditto.
	(declaredFull): Ditto.
	* gm2-compiler/M2Options.mod (SetAutoInit): Add missing
	return type.
	(GetDumpGimple): Remove duplicate implementation.
	* gm2-compiler/M2Quads.def (DupFrame): New procedure.
	* gm2-compiler/M2Quads.mod (DupFrame): New procedure.
	* gm2-compiler/M2Reserved.def (ForwardTok): New variable.
	* gm2-compiler/M2Reserved.mod (ForwardTok): Initialize variable.
	* gm2-compiler/M2Scaffold.mod (DeclareArgEnvParams): Add
	tokno parameter for call to PutParam.
	* gm2-compiler/P0SymBuild.def (EndForward): New procedure.
	* gm2-compiler/P0SymBuild.mod (EndForward): New procedure.
	* gm2-compiler/P0SyntaxCheck.bnf (BlockAssert): New procedure.
	(ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/P1Build.bnf (ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/P1SymBuild.def (Export): Removed unnecessary
	export.
	(EndBuildForward): New procedure.
	* gm2-compiler/P1SymBuild.mod (StartBuildProcedure): Reimplement.
	(EndBuildProcedure): Ditto.
	(EndBuildForward): Ditto.
	* gm2-compiler/P2Build.bnf (ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/P2SymBuild.def (BuildProcedureDefinedByForward):
	New procedure.
	(BuildProcedureDefinedByProper): Ditto.
	(CheckProcedure): Ditto.
	(EndBuildForward): Ditto.
	* gm2-compiler/P2SymBuild.mod (EndBuildProcedure): Reimplement.
	(EndBuildForward): New procedure.
	(BuildFPSection): Reimplement to allow forward declaration or
	checking of parameters.
	(BuildProcedureDefinedByProper): New procedure.
	(BuildProcedureDefinedByForward): Ditto
	(FailParameter): Remove.
	(ParameterError): New procedure.
	(ParameterMismatch): Ditto.
	(EndBuildFormalParameters): Add parameter number check.
	(GetComparison): New procedure function.
	(GetSourceDesc): Ditto.
	(GetCurSrcDesc): Ditto.
	(GetDeclared): New procedure.
	(ReturnTypeMismatch): Ditto.
	(BuildFunction): Reimplement.
	(CheckProcedure): New procedure.
	(CheckFormalParameterSection): Reimplement using ParameterError.
	* gm2-compiler/P3Build.bnf (ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/P3SymBuild.def (Export): Remove unnecessary export.
	(EndBuildForward): New procedure.
	* gm2-compiler/P3SymBuild.mod (EndBuildForward): New procedure.
	* gm2-compiler/PCBuild.bnf (ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/PCSymBuild.def (EndBuildForward): New procedure.
	* gm2-compiler/PCSymBuild.mod (EndBuildForward): Ditto.
	* gm2-compiler/PHBuild.bnf (ProcedureDeclaration): Reimplement rule.
	(PostProcedureHeading): New rule.
	(ForwardDeclaration): Ditto.
	(ProperProcedure): Ditto.
	* gm2-compiler/SymbolTable.def (PutVarTok): New procedure.
	(PutParam): Add typetok parameter.
	(PutVarParam): Ditto.
	(PutParamName): Ditto.
	(GetDeclaredFor): New procedure function.
	(AreParametersDefinedInDefinition): Ditto.
	(PutParametersDefinedByForward): New procedure.
	(GetParametersDefinedByForward): New procedure function.
	(PutParametersDefinedByProper): New procedure.
	(GetParametersDefinedByProper): New procedure function.
	(GetProcedureDeclaredForward): Ditto.
	(PutProcedureDeclaredForward): New procedure.
	(GetProcedureDeclaredProper): New procedure function.
	(PutProcedureDeclaredProper): New procedure.
	(GetProcedureDeclaredDefinition): New procedure function.
	(PutProcedureDeclaredDefinition): New procedure.
	(GetVarDeclTypeTok): Ditto.
	(PutVarDeclTypeTok): New procedure.
	(GetVarDeclTok): Ditto.
	(PutVarDeclTok): New procedure.
	(GetVarDeclFullTok): Ditto.
	* gm2-compiler/SymbolTable.mod (ProcedureDecl): New record type.
	(VarDecl): Ditto.
	(SymProcedure): Add new field Declared.
	(SymVar): Add new field Declared.
	(PutVarTok): New procedure.
	(PutParam): Add typetok parameter.
	(PutVarParam): Ditto.
	(PutParamName): Ditto.
	(GetDeclaredFor): New procedure function.
	(AreParametersDefinedInDefinition): Ditto.
	(PutParametersDefinedByForward): New procedure.
	(GetParametersDefinedByForward): New procedure function.
	(PutParametersDefinedByProper): New procedure.
	(GetParametersDefinedByProper): New procedure function.
	(GetProcedureDeclaredForward): Ditto.
	(PutProcedureDeclaredForward): New procedure.
	(GetProcedureDeclaredProper): New procedure function.
	(PutProcedureDeclaredProper): New procedure.
	(GetProcedureDeclaredDefinition): New procedure function.
	(PutProcedureDeclaredDefinition): New procedure.
	(GetVarDeclTypeTok): Ditto.
	(PutVarDeclTypeTok): New procedure.
	(GetVarDeclTok): Ditto.
	(PutVarDeclTok): New procedure.
	(GetVarDeclFullTok): Ditto.
	(MakeProcedure): Initialize Declared field.
	(MakeVar): Initialize Declared field.
	* gm2-libs-log/FileSystem.def (FileNameChar): Add
	missing return type.
	* m2.flex: Add FORWARD keyword.

gcc/testsuite/ChangeLog:

	PR modula2/115328
	* gm2/iso/fail/badparam.def: New test.
	* gm2/iso/fail/badparam.mod: New test.
	* gm2/iso/fail/badparam2.def: New test.
	* gm2/iso/fail/badparam2.mod: New test.
	* gm2/iso/fail/badparam3.def: New test.
	* gm2/iso/fail/badparam3.mod: New test.
	* gm2/iso/fail/badparamarray.def: New test.
	* gm2/iso/fail/badparamarray.mod: New test.
	* gm2/iso/fail/simpledef1.def: New test.
	* gm2/iso/fail/simpledef1.mod: New test.
	* gm2/iso/fail/simpleforward.mod: New test.
	* gm2/iso/fail/simpleforward2.mod: New test.
	* gm2/iso/fail/simpleforward3.mod: New test.
	* gm2/iso/fail/simpleforward4.mod: New test.
	* gm2/iso/fail/simpleforward5.mod: New test.
	* gm2/iso/fail/simpleforward7.mod: New test.
	* gm2/iso/pass/simpleforward.mod: New test.
	* gm2/iso/pass/simpleforward6.mod: New test.

(cherry picked from commit e751639e3d)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-03 13:37:01 +00:00
GCC Administrator 960fe2cbb1 Daily bump. 2024-12-03 00:26:40 +00:00
Jonathan Wakely 986c71c169 libstdc++: Use constexpr instead of _GLIBCXX20_CONSTEXPR in <vector>
For the operator<=> overload we can use the 'constexpr' keyword
directly, because we know the language dialect is at least C++20.

libstdc++-v3/ChangeLog:

	* include/bits/stl_vector.h (operator<=>): Use constexpr
	instead of _GLIBCXX20_CONSTEXPR macro.

(cherry picked from commit b6463161c3)
2024-12-02 22:41:43 +00:00
Jason Merrill 3a1a3ba916 libstdc++: avoid -Wsign-compare
-Wsign-compare complained about these comparisons between (unsigned) size_t
and (signed) streamsize, or between (unsigned) native_handle_type
and (signed) -1.  Fixed by adding casts to unify the types.

libstdc++-v3/ChangeLog:

	* include/std/istream: Add cast to avoid -Wsign-compare.
	* include/std/stacktrace: Likewise.

(cherry picked from commit 4246cf4f18)
2024-12-02 22:41:43 +00:00
Jason Merrill 61f4509151 libstdc++: fix testcase regexp
The unescaped * broke the match.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/default_delete/void_neg.cc: Fix regexp quoting.

(cherry picked from commit 7bd2a2f9e3)
2024-12-02 22:41:43 +00:00
Jason Merrill 38569170f8 libstdc++: avoid -Wzero-as-null-pointer-constant
libstdc++-v3/ChangeLog:

	* include/std/coroutine (coroutine_handle): Use nullptr instead of
	0 as initializer for _M_fr_ptr.

(cherry picked from commit 28f94bf91a)
2024-12-02 22:41:43 +00:00
Jason Merrill f9e34b1aef libstdc++: remove extra semicolons
The semicolons after each macro invocation here end up following the closing
brace of a function, leading to -Wextra-semi pedwarns.

libstdc++-v3/ChangeLog:

	* include/decimal/decimal.h (_DEFINE_DECIMAL_BINARY_OP_WITH_INT):
	Remove redundant semicolons.

(cherry picked from commit 7b500fa34a)
2024-12-02 22:41:43 +00:00
Jonathan Wakely d85ad17c2b libstdc++: Fix -Wunused-parameter warnings in Networking TS headers
libstdc++-v3/ChangeLog:

	* include/experimental/io_context: Remove name of unused
	parameter.
	* include/experimental/socket: Add [[maybe_unused]] attribute.

(cherry picked from commit 51b0fef4e6)
2024-12-02 22:41:42 +00:00
Jonathan Wakely 31c7539e26 libstdc++: Silence -Woverloaded-virtual warning in cxx11-ios_failure.cc
libstdc++-v3/ChangeLog:

	* src/c++11/cxx11-ios_failure.cc (__iosfail_type_info): Unhide
	the three-arg overload of __do_upcast.

(cherry picked from commit d842eb5ee6)
2024-12-02 22:41:42 +00:00
Jonathan Wakely 4b7a1dbd3c libstdc++: Silence -Wattributes warning in exception_ptr
libstdc++-v3/ChangeLog:

	* libsupc++/exception_ptr.h (__exception_ptr::_M_safe_bool_dummy):
	Remove __attribute__((const)) from function returning void.

(cherry picked from commit 164c1b1f81)
2024-12-02 22:41:42 +00:00
Jonathan Wakely f2b027a9ef libstdc++: Remove unused typedef in <ranges>
This local typedef should have been removed in r14-6199-g45630fbcf7875b.

libstdc++-v3/ChangeLog:

	* include/std/ranges (to): Remove unused typedef.

(cherry picked from commit a59f1cc31c)
2024-12-02 22:41:42 +00:00
Jonathan Wakely 3fe1629a68 libstdc++: Improve comment for _Hashtable::_M_insert_unique_node
Clarify the effects if rehashing is needed. Document the __n_elt
parameter.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h (_M_insert_unique_node): Improve
	comment.

(cherry picked from commit e97179bacd)
2024-12-02 22:41:42 +00:00
Jonathan Wakely b1be40e99a libstdc++: Fix get<0> constraint for lvalue ranges::subrange (LWG 3589)
Approved at October 2021 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::begin): Fix constraint,
	as per LWG 3589.
	* testsuite/std/ranges/subrange/lwg3589.cc: New test.

(cherry picked from commit 4a3a0be34f)
2024-12-02 22:41:42 +00:00
Jonathan Wakely 0a1c4afe2f libstdc++: Check feature test macros in unordered containers
Replace some `__cplusplus > 201402L` preprocessor checks with more
expressive checks for the appropriate feature test macros.

libstdc++-v3/ChangeLog:

	* include/bits/unordered_map.h: Check __glibcxx_node_extract and
	__glibcxx_unordered_map_try_emplace instead of __cplusplus.
	* include/bits/unordered_set.h: Check __glibcxx_node_extract
	instead of __cplusplus.

(cherry picked from commit 1a5bdeb112)
2024-12-02 22:41:41 +00:00
Jonathan Wakely d4c402b517 libstdc++: Use appropriate feature test macro for std::byte
libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h (__is_byte<byte>): Guard with
	__glibcxx_byte macro instead of checking __cplusplus.

(cherry picked from commit 00a87ee76f)
2024-12-02 22:41:41 +00:00
Jonathan Wakely 671c22a2e0 libstdc++: Make equal and is_permutation short-circuit (LWG 3560)
We already implement short-circuiting for random access iterators, but
we also need to do so for ranges::equal and ranges::is_permutation when
given sized ranges that are not random access ranges (e.g. std::list).

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__is_permutation_fn::operator()):
	Short-circuit for sized ranges with different sizes, as per LWG
	3560.
	* include/bits/ranges_algobase.h (__equal_fn::operator()):
	Likewise.
	* include/bits/stl_algo.h (__is_permutation): Use if-constexpr
	for random access iterator branches.
	* include/bits/stl_algobase.h (__equal4): Likewise.
	* testsuite/25_algorithms/equal/lwg3560.cc: New test.
	* testsuite/25_algorithms/is_permutation/lwg3560.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit 45cc42d6dc)
2024-12-02 22:41:41 +00:00
Jonathan Wakely a088552e13 libstdc++: Implement LWG 3798 for range adaptors [PR106676]
LWG 3798 modified the iterator_category of the iterator types for
transform_view, join_with_view, zip_transform_view and
adjacent_transform_view, to allow the iterator's reference type to be an
rvalue reference.

libstdc++-v3/ChangeLog:

	PR libstdc++/106676
	* include/bits/iterator_concepts.h (__cpp17_fwd_iterator): Use
	is_reference instead of is_value_reference.
	rvalue references.
	* include/std/ranges (transform_view:__iter_cat::_S_iter_cat):
	Likewise.
	(zip_transform_view::__iter_cat::_S_iter_cat): Likewise.
	(adjacent_transform_view::__iter_cat::_S_iter_cat): Likewise.
	(join_with_view::__iter_cat::_S_iter_cat): Likewise.
	* testsuite/std/ranges/adaptors/transform.cc: Check
	iterator_category when the transformation function returns an
	rvalue reference type.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit 7f65f94917)
2024-12-02 22:41:41 +00:00
Jonathan Wakely c61255e2d8 libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite
libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc (resize_for_overwrite): Fix
	-Wsign-compare warning.
	* include/bits/cow_string.h (resize_for_overwrite): Likewise.

(cherry picked from commit 7040c207ba)
2024-12-02 22:41:41 +00:00
Jonathan Wakely cdd110e7f1 libstdc++: Fix std::vector<bool>::emplace to forward parameter
If the parameter is not lvalue-convertible to bool then the current code
will fail to compile. The parameter should be forwarded to restore the
original value category.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h (emplace_back, emplace): Forward
	parameter pack to preserve value category.
	* testsuite/23_containers/vector/bool/emplace_rvalue.cc: New
	test.

(cherry picked from commit f1c844be52)
2024-12-02 22:41:40 +00:00
Jonathan Wakely 22ce6e2dbc libstdc++: Fix typo in comment in hashtable.h
And tweak grammar in a couple of comments.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h: Fix spelling in comment.

(cherry picked from commit bcf40c70f8)
2024-12-02 22:41:40 +00:00
Jonathan Wakely 3a4c9a2c66 libstdc++: Minor comment improvements in <bits/hashtable.h>
libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h: Improve comments.

(cherry picked from commit db798ee38a)
2024-12-02 22:41:40 +00:00
Jonathan Wakely edbe164af1 libstdc++: Add missing parts of LWG 3480 for directory iterators [PR117560]
It looks like I only read half the resolution of LWG 3480 and decided we
already supported it. As well as making the non-member overloads of end
take their parameters by value, we need some specializations of the
enable_borrowed_range and enable_view variable templates.

libstdc++-v3/ChangeLog:

	PR libstdc++/117560
	* include/bits/fs_dir.h (enable_borrowed_range, enable_view):
	Define specializations for directory iterators, as per LWG 3480.
	* testsuite/27_io/filesystem/iterators/lwg3480.cc: New test.

(cherry picked from commit eec6e89235)
2024-12-02 22:41:40 +00:00
Jonathan Wakely ea95ef3bec libstdc++: Fix calculation of system time in performance tests
The system_time() function used the wrong element of the splits array.

Also add a comment about the units for time measurements.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_performance.h (time_counter): Add
	comment about times.
	(time_counter::system_time): Use correct split value.

(cherry picked from commit 19d0720f68)
2024-12-02 22:41:40 +00:00
Jonathan Wakely b3b430ed99 libstdc++: Use __is_single_threaded() in performance tests
With recent glibc releases the __gthread_active_p() function is always
true, so we always append "-thread" onto performance benchmark names.

Use the __gnu_cxx::__is_single_threaded() function instead.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_performance.h: Use
	__gnu_cxx::__is_single_threaded instead of __gthread_active_p().

(cherry picked from commit 2b92007016)
2024-12-02 22:41:40 +00:00
Jonathan Wakely 7a656281d8 libstdc++: Add missing constraint to operator+ for std::move_iterator
This constraint was added by the One Ranges proposal (P0896R4) and
then fixed by LWG 3293, but it was missing from libstdc++.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (operator+): Add constraint to
	move_iterator operator.
	* testsuite/24_iterators/move_iterator/rel_ops_c++20.cc:

(cherry picked from commit f91e34644e)
2024-12-02 22:41:39 +00:00
Jonathan Wakely 136ff35dd3 libstdc++: Fix allocator-extended move ctor for std::basic_stacktrace [PR117822]
libstdc++-v3/ChangeLog:

	PR libstdc++/117822
	* include/std/stacktrace (stacktrace(stacktrace&&, const A&)):
	Fix typo in qualified-id for is_always_equal trait.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Test
	allocator-extended constructors and allocator propagation.

(cherry picked from commit fe04901737)
2024-12-02 22:41:39 +00:00
Jonathan Wakely 5425886d1d libstdc++: Fix std::basic_stracktrace to not assume allocators throw std::bad_alloc
The standard allows allocators to throw any kind of exception, not only
something that can be caught as std::bad_alloc. std::basic_stracktrace
was assuming std::bad_alloc.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
	Do not assume allocators only throw std::bad_alloc.

(cherry picked from commit c45844eb7d)
2024-12-02 22:41:39 +00:00
Gaius Mulley 58ef1c521c [PATCH] PR modula2/116918 -fswig correct syntax fixup
This patch adds a missing % escape in DoCheckUnbounded.

gcc/m2/ChangeLog:

	PR modula2/116918
	* gm2-compiler/M2Swig.mod (DoCheckUnbounded): Escape
	the % character used in array_functions with %%.

(cherry picked from commit e2a701cd04)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-02 21:34:38 +00:00
Harald Anlauf e81edf9d86 Fortran: passing inquiry ref of complex array to assumed rank dummy [PR117774]
PR fortran/117774

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): When passing an array
	to an assumed-rank dummy, terminate search for array reference of
	actual argument before an inquiry reference (e.g. INQUIRY_RE,
	INQUIRY_IM) so that bounds update works properly.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit eff7e72815)
2024-12-02 22:09:04 +01:00
Gaius Mulley aa38196eb4 [PATCH] PR modula2/116918 -fswig correct syntax
This patch fixes the syntax for the generated swig interface file.
The % characters in fprintf require escaping.

gcc/m2/ChangeLog:

	PR modula2/116918
	* gm2-compiler/M2Swig.mod (AnnotateProcedure): Capitalize
	the generated comment, split comment into multiple lines and
	terminate the comment with ".  */".
	(DoCheckUnbounded): Escape the % character with %%.
	(DoWriteFile): Ditto.

(cherry picked from commit fda30a3c8a)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-02 20:25:25 +00:00
Gaius Mulley 89e7b9b2bb [PATCH] modula2: Add noreturn attribute to m2/gm2-libs/M2RTS.mod
This patch removes a build warning by adding a noreturn attribute
to the M2RTS.mod:HaltC procedure.  Also add an infinite loop to
gm2-libs-min/M2RTS.mod.

gcc/m2/ChangeLog:

	* Make-lang.in (m2/gm2-libs-boot/M2RTS.o): Remove
	--suppress-noreturn.
	* gm2-libs/M2RTS.mod (HaltC): Add noreturn attribute.
	* gm2-libs-min/M2RTS.mod (HALT): Add LOOP END.

(cherry picked from commit 5ef52ec422)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-02 18:03:31 +00:00
Gaius Mulley 89761f1f03 [PATCH] PR modula2/117555: Add missing return statement after raise
This patch adds missing return statements after a call to RAISE.  Four
of the modules in libgm2 have procedure functions with missing return
statements.  These errors were exposed after the reimplementation of
parameter declaration patch and triggered by -Wreturn-type.  The patch
also adds exit statements to the M2RTS noreturn functions.

gcc/m2/ChangeLog:

	PR modula2/117555
	* gm2-libs-iso/EXCEPTIONS.mod (CurrentNumber): Add return
	statement.
	* gm2-libs-iso/IOChan.mod (ReadResult): Ditto.
	(CurrentFlags): Ditto.
	(DeviceError): Ditto.
	* gm2-libs-iso/IOLink.mod (DeviceTablePtrValue): Ditto.
	* gm2-libs-iso/LongConv.mod (ValueReal): Ditto.
	* gm2-libs/M2RTS.mod (Halt): Add noreturn attribute.
	Add exit (1).
	(HaltC): Add exit (1).
	* pge-boot/GM2RTS.cc (M2RTS_Halt): Add exit (1).
	(M2RTS_HaltC): Ditto.

(cherry picked from commit e77fd9aa89)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-02 14:34:32 +00:00
Andre Vieira b11f53a912 arm, mve: Adding missing Runtime Library Exception to header files
Add missing Runtime Library Exception to mve header files to bring them into
line with other similar headers. Not adding it in the first place was an
oversight.

gcc/ChangeLog:

	* config/arm/arm_mve.h: Add Runtime Library Exception.
	* config/arm/arm_mve_types.h: Likewise.

(cherry picked from commit cde7ce0628)
2024-12-02 13:44:07 +00:00
Gaius Mulley 9c926d8b83 [PATCH] PR modula2/117555: libgm2 build failure after r15-5081-g95960cd473297c
This patch adds missing return statements to library procedure
functions.  These missing statements occur after a call to RAISE.

gcc/m2/ChangeLog:

	PR modula2/117555
	* gm2-libs-iso/M2EXCEPTION.mod (M2Exception): Add missing
	return statement.
	* gm2-libs-iso/RealConv.mod (ValueReal): Ditto.
	* gm2-libs-iso/RndFile.mod (StartPos): Ditto.
	(EndPos): Ditto.
	(NewPos): Ditto.
	* gm2-libs-iso/ShortConv.mod (ValueReal): Ditto.
	* gm2-libs-iso/WholeConv.mod (ValueInt): Ditto.
	(ValueCard): Ditto.

(cherry picked from commit 6d90f5d0ae)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-02 13:25:14 +00:00
GCC Administrator efd59e24e4 Daily bump. 2024-12-02 00:24:12 +00:00
Gaius Mulley 7e8a67e023 [PATCH] modula2: Tidyup remove unnecessary parameters
This patch removes ununsed parameters from gm2-compiler/M2Comp.mod.

gcc/m2/ChangeLog:

	* gm2-compiler/M2Comp.mod (GenerateDependencies): Remove
	unused parameter.
	(WriteDep): Remove parameter dep.
	(WritePhoneDep): Ditto.

(cherry picked from commit 20486ec757)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-01 23:09:44 +00:00
Gaius Mulley 92ed383eb0 [PATCH] modula2: Remove unused parameter warnings seen in build
This patch removes unused parameters in gm2-compiler/M2Check.mod.
It also removes a --fixme-- and completes the missing code
which type checks unbounded arrays.  The patch also fixes a
build error seen when building m2/stage2/cc1gm2.

gcc/m2/ChangeLog:

	* gm2-compiler/M2Check.mod (checkUnboundedArray): New
	procedure function.
	(checkUnboundedUnbounded): Ditto.
	(checkUnbounded): Rewrite to check the unbounded data
	type.
	(checkPair): Add comment.
	(doCheckPair): Add comment.
	Remove tinfo parameter from the call to checkTypeKindViolation.
	(checkTypeKindViolation): Remove ununsed parameter tinfo.
	* gm2-libs-ch/UnixArgs.cc (GM2RTS.h): Remove include.
	* gm2-libs-ch/m2rts.h (M2RTS_INIT): New define.
	(M2RTS_DEP): Ditto.
	(M2RTS_RegisterModule): New prototype.
	(GM2RTS.h): Add include to the MC_M2 block.

gcc/testsuite/ChangeLog:

	* gm2/iso/fail/testarrayunbounded2.mod: New test.
	* gm2/iso/fail/testarrayunbounded3.mod: New test.
	* gm2/iso/fail/testarrayunbounded4.mod: New test.
	* gm2/iso/fail/testarrayunbounded5.mod: New test.
	* gm2/iso/fail/testarrayunbounded6.mod: New test.
	* gm2/iso/pass/testarrayunbounded.mod: New test.

(cherry picked from commit 2828ec526e)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-12-01 14:41:40 +00:00
GCC Administrator b67efb62cf Daily bump. 2024-12-01 00:26:11 +00:00
Paul Thomas dd1d74cb54 Fortran: Fix failing character pointer fcn assignment [PR105054]
2024-11-14  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/105054
	* resolve.cc (get_temp_from_expr): If the pointer function has
	a deferred character length, generate a new deferred charlen
	for the temporary.

gcc/testsuite/
	PR fortran/105054
	* gfortran.dg/ptr_func_assign_6.f08: New test.

(cherry picked from commit f530a8c613)
2024-11-30 10:23:12 +00:00
Gaius Mulley 7b22d9cb9b [PATCH] modula2: gcc/m2/Make-lang.in fix includes during bootstrap build
This patch fixes the include directories used when building objects in
gm2-compiler-boot.  It adds the missing gm2-gcc directory and uses a
new variable GM2_BOOT_INCLUDES for all gm2-compiler-boot rules.

gcc/m2/ChangeLog:

	* Make-lang.in (GM2_BOOT_INCLUDES): New variable.
	(m2/gm2-compiler-boot/M2GCCDeclare.o): Rewrite to use
	GM2_BOOT_INCLUDES.
	(m2/gm2-compiler-boot/M2Error.o): Ditto.
	(m2/gm2-compiler-boot/%.o): Ditto.

(cherry picked from commit 58bc39c73c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-30 02:22:37 +00:00
GCC Administrator 6af1aca9f3 Daily bump. 2024-11-30 00:25:55 +00:00
Gaius Mulley 2e117b9238 [PATCH] PR modula2/116181 Use GCC tree location_t and separate pointer types
This patch fixes all remaining -Wodr warnings in the modula-2 front end.
It removes the m2 Tree and m2 Location definitions and uses tree and
location_t throughout.  This allows the bootstrap tool mc to pick up the
GCC definitions for these data types (for the C translation of m2 sources).

The patch introduces a new module CDataTypes which contain two pointer
types: CharStar and ConstCharStar.  These map onto their C counterparts
when processed by mc however currently gm2 treats them as ADDRESS.
It might be sensible to have the gm2 versions of these data types
implemented though a builtin module in the future.

gcc/m2/ChangeLog:

	PR modula2/116181
	* Make-lang.in (GM2-GCC-DEFS): Add gcctypes.def and
	CDataTypes.def.
	(MC-LIB-DEFS): Add CDataTypes.def.
	* Make-maintainer.in (m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o):
	Change include path to pge-boot.
	(m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto.
	(GM2PATH): Add -I$(srcdir)/m2/gm2-gcc.
	(m2/mc-boot-gen/$(SRC_PREFIX)%.h): Add -I$(srcdir)/m2/gm2-gcc.
	(m2/mc-boot-gen/$(SRC_PREFIX)%.cc): Ditto.
	* gm2-compiler/M2ALU.def (PushIntegerTree): Replace Tree with tree.
	(PopIntegerTree): Ditto.
	(PushRealTree): Ditto.
	(PopRealTree): Ditto.
	(PushComplexTree): Ditto.
	(PopComplexTree): Ditto.
	(PushSetTree): Ditto.
	(PopSetTree): Ditto.
	(PopConstructorTree): Ditto.
	(ConstructSetConstant): Ditto.
	(BuildRange): Ditto.
	(CheckOrResetOverflow): Ditto.
	(PushTypeOfTree): Ditto.
	* gm2-compiler/M2ALU.mod (Tree): Replace with ...
	(tree): ... this.
	(gcctypes): Import location_t and tree.
	(m2linemap): Remove import of location_t.
	* gm2-compiler/M2Base.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2Base.mod (gcctypes): Import of location_t.
	(m2linemap): Remove import of location_t.
	* gm2-compiler/M2Bitset.mod (m2tree): Remove import of Tree.
	* gm2-compiler/M2CaseList.mod (gcctypes): Import tree.
	(m2tree): Remove import of Tree.
	(Tree): Replace with ...
	(tree): ... this.
	* gm2-compiler/M2Emit.def (gcctypes): Import location_t.
	* gm2-compiler/M2GCCDeclare.def (gcctypes): Import tree.
	(PromoteToString): Replace Tree with tree.
	(PromoteToCString): Ditto.
	(ConstantKnownAndUsed): Ditto.
	* gm2-compiler/M2GCCDeclare.mod (gcctypes): Import tree.
	(m2tree): Remove import of Tree.
	(Tree): Replace with ...
	(tree): ... this.
	* gm2-compiler/M2GenGCC.def (gcctypes): Import tree.
	(m2tree): Remove import of Tree.
	(Tree): Replace with ...
	(tree): ... this.
	(GetHighFromUnbounded): Replace Tree with tree.
	(StringToChar): Ditto.
	(LValueToGenericPtr): Ditto.
	(ZConstToTypedConst): Ditto.
	(PrepareCopyString): Ditto.
	* gm2-compiler/M2GenGCC.mod (gcctypes): Import tree.
	(m2tree): Remove import of Tree.
	(Tree): Replace with ...
	(tree): ... this.
	* gm2-compiler/M2LangDump.def (gcctypes): Import tree.
	(m2tree): Remove import of Tree.
	(Tree): Replace with ...
	(tree): ... this.
	* gm2-compiler/M2LangDump.mod (Tree): Replace with ...
	(tree): ... this.
	* gm2-compiler/M2LexBuf.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2LexBuf.mod (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2Options.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2Options.mod (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2Range.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	(CDataTypes): Import ConstCharStar.
	(CodeErrorCheck): Replace Tree with tree.
	(OverlapsRange): Ditto.
	(IsEqual): Ditto.
	(IsGreaterOrEqual): Ditto.
	(IsGreater): Ditto.
	(BuildIfCallWholeHandlerLoc): Replace Tree with tree.
	Replace ADDRESS with ConstCharStar.
	(BuildIfCallRealHandlerLoc): Ditto.
	(GetMinMax): Ditto.
	* gm2-compiler/M2Range.mod (m2tree): Remove Tree.
	(CodeErrorCheck): Replace Tree with tree.
	(OverlapsRange): Ditto.
	(IsEqual): Ditto.
	(IsGreaterOrEqual): Ditto.
	(IsGreater): Ditto.
	(GetMinMax): Ditto.
	(BuildIfCallWholeHandlerLoc): Replace Tree with tree.
	Replace ADDRESS with ConstCharStar.
	(BuildIfCallRealHandlerLoc): Ditto.
	* gm2-compiler/M2System.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/M2System.mod (m2linemap): Replace with ...
	(gcctypes): ... this.
	(CreateMinMaxFor): Replace Tree with tree.
	(CreateType): Ditto.
	(AttemptToCreateType): Ditto.
	(CreateSetType): Ditto.
	(AttemptToCreateSetType): Ditto.
	* gm2-compiler/P2SymBuild.mod (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-compiler/SymbolConversion.def (m2tree): Replace with ...
	(gcctypes): ... this.
	(Mod2Gcc): Replace Tree with tree.
	(Gcc2Mod): Ditto.
	(AddModGcc): Ditto.
	* gm2-compiler/SymbolConversion.mod (m2tree): Replace with ...
	(gcctypes): ... this.
	(Mod2Gcc): Replace Tree with tree.
	(Gcc2Mod): Ditto.
	(AddModGcc): Ditto.
	(Mod2GccWithoutGCCPoison): Ditto.
	* gm2-compiler/SymbolTable.def (m2tree): Replace with ...
	(gcctypes): ... this.
	(PutModuleFinallyFunction): Replace Tree with tree.
	(GetModuleFinallyFunction): Ditto.
	* gm2-compiler/SymbolTable.mod (m2tree): Replace with ...
	(gcctypes): ... this.
	(PutModuleFinallyFunction): Replace Tree with tree.
	(GetModuleFinallyFunction): Ditto.
	* gm2-compiler/m2flex.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	* gm2-gcc/init.def (PerCompilationInit): Replace ADDRESS with ConstCharStar.
	(CDataTypes): Import ConstCharStar.
	* gm2-gcc/m2block.def (SYSTEM): Remove import.
	(CDataTypes): Import ConstCharStar.
	(m2linemap): Remove import.
	(m2tree): Remove import.
	(gcctypes): Import tree.
	(global_constant): Replace Tree with tree.
	(RememberInitModuleFunction): Ditto.
	(DumpGlobalConstants): Ditto.
	(RememberConstant): Ditto.
	(RememberType): Ditto.
	(pushDecl): Ditto.
	(popFunctionScope): Ditto.
	(pushFunctionScope): Ditto.
	(finishFunctionCode): Ditto.
	(finishFunctionDecl): Ditto.
	(GetErrorNode): Ditto.
	(includeDecl): Ditto.
	(GetGlobals): Ditto.
	(GetGlobalContext): Ditto.
	(begin_statement_list): Ditto.
	(push_statement_list): Ditto.
	(pop_statement_list): Ditto.
	(getLabel): Replace Tree with tree.
	Replace ADDRESS with ConstCharStar.
	* gm2-gcc/m2builtins.def (CDataTypes): Import ConstCharStar.
	(GetBuiltinConst): Replace Tree with tree.
	(GetBuiltinConstType): Ditto.
	(GetBuiltinTypeInfoType): Ditto.
	(GetBuiltinTypeInfo): Ditto.
	(BuiltinExists): Ditto.
	(BuildBuiltinTree): Ditto.
	(BuiltinMemCopy): Ditto.
	(BuiltinMemSet): Ditto.
	(BuiltInAlloca): Ditto.
	(BuiltInIsfinite): Ditto.
	* gm2-gcc/m2convert.def (CDataTypes): Import ConstCharStar.
	(ToWord): Ditto.
	(ToCardinal): Ditto.
	(ToInteger): Ditto.
	(ToBitset): Ditto.
	(ConvertToPtr): Ditto.
	(BuildConvert): Ditto.
	(ConvertConstantAndCheck): Ditto.
	(ConvertString): Ditto.
	(GenericToType): Ditto.
	* gm2-gcc/m2decl.cc (m2decl_BuildParameterDeclaration): Add
	const attribute.
	* gm2-gcc/m2decl.def (CDataTypes): Import ConstCharStar.
	(BuildModuleCtor): Ditto.
	(DeclareModuleCtor): Ditto.
	(DeclareM2linkForcedModuleInitOrder): Ditto.
	(DeclareM2linkStaticInitialization): Ditto.
	(BuildPtrToTypeString): Ditto.
	(BuildIntegerConstant): Ditto.
	(BuildStringConstantType): Ditto.
	(DeclareKnownVariable): Ditto.
	(DeclareKnownConstant): Ditto.
	(BuildParameterDeclaration): Ditto.
	(BuildEndFunctionDeclaration): Ditto.
	(RememberVariables): Ditto.
	(BuildConstLiteralNumber): Ditto.
	(BuildStringConstant): Ditto.
	(BuildCStringConstant): Ditto.
	(GetDeclContext): Ditto.
	* gm2-gcc/m2decl.h (m2decl_BuildParameterDeclaration): Add
	const attribute.
	* gm2-gcc/m2except.def (CDataTypes): Import ConstCharStar.
	(BuildThrow): Ditto.
	(BuildTryBegin): Ditto.
	(BuildTryEnd): Ditto.
	(BuildCatchBegin): Ditto.
	(BuildCatchEnd): Ditto.
	* gm2-gcc/m2expr.def (CDataTypes): Import ConstCharStar.
	(CSTIntToString): Ditto.
	(CSTIntToChar): Ditto.
	(CheckConstStrZtypeRange): Ditto.
	(CompareTrees): Ditto.
	(GetPointerOne): Ditto.
	(GetPointerZero): Ditto.
	(GetWordOne): Ditto.
	(GetWordZero): Ditto.
	(GetIntegerOne): Ditto.
	(GetIntegerZero): Ditto.
	(GetCardinalOne): Ditto.
	(GetCardinalZero): Ditto.
	(GetSizeOfInBits): Ditto.
	(GetSizeOf): Ditto.
	(BuildLogicalRotate): Ditto.
	(BuildLRRn): Ditto.
	(BuildLRLn): Ditto.
	(BuildMask): Ditto.
	(BuildMult): Ditto.
	(BuildMultCheck): Ditto.
	(BuildLRR): Ditto.
	(BuildLRL): Ditto.
	(BuildLogicalShift): Ditto.
	(BuildLSR): Ditto.
	(BuildLSL): Ditto.
	(BuildDivM2): Ditto.
	(BuildDivM2Check): Ditto.
	(BuildModM2): Ditto.
	(BuildModM2Check): Ditto.
	(BuildModFloor): Ditto.
	(BuildDivCeil): Ditto.
	(BuildModCeil): Ditto.
	(BuildDivFloor): Ditto.
	(BuildModTrunc): Ditto.
	(BuildDivTrunc): Ditto.
	(BuildDivTruncCheck): Ditto.
	(BuildRDiv): Ditto.
	(BuildSubCheck): Ditto.
	(BuildAddCheck): Ditto.
	(BuildSub): Ditto.
	(BuildAdd): Ditto.
	(FoldAndStrip): Ditto.
	(StringLength): Ditto.
	(TreeOverflow): Ditto.
	(RemoveOverflow): Ditto.
	(BuildCoerce): Ditto.
	(BuildTrunc): Ditto.
	(BuildNegate): Ditto.
	(BuildNegateCheck): Ditto.
	(BuildSetNegate): Ditto.
	(BuildTBitSize): Ditto.
	(BuildSize): Ditto.
	(BuildAddr): Ditto.
	(BuildOffset1): Ditto.
	(BuildOffset): Ditto.
	(BuildLogicalOrAddress): Ditto.
	(BuildLogicalOr): Ditto.
	(BuildLogicalAnd): Ditto.
	(BuildSymmetricDifference): Ditto.
	(BuildLogicalDifference): Ditto.
	(BuildLessThan): Ditto.
	(BuildGreaterThan): Ditto.
	(BuildLessThanOrEqual): Ditto.
	(BuildGreaterThanOrEqual): Ditto.
	(BuildEqualTo): Ditto.
	(BuildNotEqualTo): Ditto.
	(BuildIsSuperset): Ditto.
	(BuildIsNotSuperset): Ditto.
	(BuildIsSubset): Ditto.
	(BuildIsNotSubset): Ditto.
	(BuildIfConstInVar): Ditto.
	(BuildIfNotConstInVar): Ditto.
	(BuildIfVarInVar): Ditto.
	(BuildIfNotVarInVar): Ditto.
	(BuildForeachWordInSetDoIfExpr): Ditto.
	(BuildIfInRangeGoto): Ditto.
	(BuildIfNotInRangeGoto): Ditto.
	(BuildArray): Ditto.
	(BuildComponentRef): Ditto.
	(BuildIndirect): Ditto.
	(IsTrue): Ditto.
	(IsFalse): Ditto.
	(GetCstInteger): Ditto.
	(AreConstantsEqual): Ditto.
	(AreRealOrComplexConstantsEqual): Ditto.
	(DetermineSign): Ditto.
	(BuildCap): Ditto.
	(BuildAbs): Ditto.
	(BuildRe): Ditto.
	(BuildIm): Ditto.
	(BuildCmplx): Ditto.
	(BuildBinaryForeachWordDo): Ditto.
	(BuildBinarySetDo): Ditto.
	(ConstantExpressionWarning): Ditto.
	(BuildAddAddress): Ditto.
	(calcNbits): Ditto.
	(OverflowZType): Ditto.
	(BuildCondIfExpression): Ditto.
	* gm2-gcc/m2linemap.def (CDataTypes): Import ConstCharStar.
	* gm2-gcc/m2misc.def (m2tree): Replace with ...
	(gcctypes): ... this.
	(DebugTree): Replace Tree with tree.
	* gm2-gcc/m2pp.def (m2tree): Replace with ...
	(gcctypes): ... this.
	(DumpGimpleFd): Replace Tree with tree.
	* gm2-gcc/m2statement.cc (m2statement_BuildBuiltinCallTree):
	Remove unused location parameter.
	* gm2-gcc/m2statement.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	(CDataTypes): Import CharStar.
	(DoJump): Replace Tree with tree.
	Replace ADDRESS with CharStar.
	(BuildStartFunctionCode): Replace Tree with tree.
	(BuildEndFunctionCode): Ditto.
	(BuildReturnValueCode): Ditto.
	(BuildAssignmentTree): Ditto.
	(BuildAssignmentStatement): Ditto.
	(BuildGoto): Ditto.
	(DeclareLabel): Ditto.
	(BuildIfThenDoEnd): Ditto.
	(BuildIfThenElseEnd): Ditto.
	(BuildParam): Ditto.
	(BuildFunctionCallTree): Ditto.
	(BuildProcedureCallTree): Ditto.
	(BuildIndirectProcedureCallTree): Ditto.
	(BuildFunctValue): Ditto.
	(BuildCall2): Ditto.
	(BuildCall3): Ditto.
	(SetLastFunction): Ditto.
	(GetLastFunction): Ditto.
	(GetParamTree): Ditto.
	(BuildTryFinally): Ditto.
	(BuildCleanUp): Ditto.
	(BuildAsm): Ditto.
	(BuildUnaryForeachWordDo): Ditto.
	(BuildExcludeVarConst): Ditto.
	(BuildExcludeVarVar): Ditto.
	(BuildIncludeVarConst): Ditto.
	(BuildIncludeVarVar): Ditto.
	(BuildStart): Ditto.
	(BuildEnd): Ditto.
	(BuildCallInner): Ditto.
	(BuildBuiltinCallTree):  Remove unused location parameter.
	* gm2-gcc/m2statement.h (m2statement_BuildBuiltinCallTree): Remove
	unused location parameter.
	* gm2-gcc/m2tree.def (gcctypes): Import tree.
	(IsAConstant): Replace Tree with tree.
	(IsOrdinal): Ditto.
	(IsTreeOverflow): Ditto.
	(skip_const_decl): Ditto.
	(skip_type_decl): Ditto.
	(is_type): Ditto.
	(is_array): Ditto.
	(is_var): Ditto.
	(debug_tree): Ditto.
	(IstreeOverflow): Ditto.
	* gm2-gcc/m2treelib.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	(get_set_address_if_var): Ditto.
	(get_set_field_rhs): Ditto.
	(get_set_field_lhs): Ditto.
	(get_set_address): Ditto.
	(get_set_value): Ditto.
	(get_field_no): Ditto.
	(get_rvalue): Ditto.
	(DoCall): Ditto.
	(build_modify_expr): Ditto.
	(do_jump_if_bit): Ditto.
	* gm2-gcc/m2type.def (m2linemap): Replace with ...
	(gcctypes): ... this.
	(m2tree): Remove.
	(CDataTypes): Import ConstCharStar and charStar.
	(ValueInTypeRange): Replace Tree with tree.
	(ValueOutOfTypeRange): Ditto.
	(ExceedsTypeRange): Ditto.
	(WithinTypeRange): Ditto.
	(BuildSubrangeType): Ditto.
	(BuildCharConstant): Ditto.
	(BuildCharConstantChar): Ditto.
	(BuildArrayConstructorElement): Ditto.
	(BuildEndArrayConstructor): Ditto.
	(BuildStartArrayConstructor): Ditto.
	(BuildRecordConstructorElement): Ditto.
	(BuildEndRecordConstructor): Ditto.
	(BuildStartRecordConstructor): Ditto.
	(BuildEndSetConstructor): Ditto.
	(BuildSetConstructorElement): Ditto.
	(BuildStartSetConstructor): Ditto.
	(BuildSetType): Ditto.
	(BuildConstPointerType): Ditto.
	(BuildPointerType): Ditto.
	(BuildEnumerator): Ditto.
	(BuildEndEnumeration): Ditto.
	(BuildStartEnumeration): Ditto.
	(BuildTypeDeclaration): Ditto.
	(GetMaxFrom): Ditto.
	(GetMinFrom): Ditto.
	(GetDefaultType): Ditto.
	(BuildEndType): Ditto.
	(BuildStartType): Ditto.
	(BuildVariableArrayAndDeclare): Ditto.
	(BuildProcTypeParameterDeclaration): Ditto.
	(BuildStartFunctionType): Ditto.
	(BuildEndFunctionType): Ditto.
	(GetTreeType): Ditto.
	(DeclareKnownType): Ditto.
	(GetM2ZType): Ditto.
	(GetM2RType): Ditto.
	(BuildSetTypeFromSubrange): Ditto.
	(BuildSmallestTypeRange): Ditto.
	(GetBooleanType): Ditto.
	(GetBooleanFalse): Ditto.
	(GetBooleanTrue): Ditto.
	(GetPackedBooleanType): Ditto.
	(GetCharType): Ditto.
	(GetByteType): Ditto.
	(GetVoidType): Ditto.
	(GetBitnumType): Ditto.
	(GetRealType): Ditto.
	(GetLongRealType): Ditto.
	(GetShortRealType): Ditto.
	(GetLongIntType): Ditto.
	(GetPointerType): Ditto.
	(GetCardinalType): Ditto.
	(GetIntegerType): Ditto.
	(GetWordType): Ditto.
	(GetM2CardinalType): Ditto.
	(GetBitsetType): Ditto.
	(GetM2CType): Ditto.
	(GetProcType): Ditto.
	(GetM2ComplexType): Ditto.
	(GetM2LongComplexType): Ditto.
	(GetM2ShortComplexType): Ditto.
	(GetM2Complex128): Ditto.
	(GetM2Complex96): Ditto.
	(GetM2Complex64): Ditto.
	(GetM2Complex32): Ditto.
	(GetM2Real128): Ditto.
	(GetM2Real96): Ditto.
	(GetM2Real64): Ditto.
	(GetM2Real32): Ditto.
	(GetM2Bitset32): Ditto.
	(GetM2Bitset16): Ditto.
	(GetM2Bitset8): Ditto.
	(GetM2Word64): Ditto.
	(GetM2Word32): Ditto.
	(GetM2Word16): Ditto.
	(GetM2Cardinal64): Ditto.
	(GetM2Cardinal32): Ditto.
	(GetM2Cardinal16): Ditto.
	(GetM2Cardinal8): Ditto.
	(GetM2Integer64): Ditto.
	(GetM2Integer32): Ditto.
	(GetM2Integer16): Ditto.
	(GetM2Integer8): Ditto.
	(GetISOLocType): Ditto.
	(GetISOByteType): Ditto.
	(GetISOWordType): Ditto.
	(GetShortCardType): Ditto.
	(GetM2ShortCardType): Ditto.
	(GetShortIntType): Ditto.
	(GetM2ShortIntType): Ditto.
	(GetM2LongCardType): Ditto.
	(GetM2LongIntType): Ditto.
	(GetM2LongRealType): Ditto.
	(GetM2RealType): Ditto.
	(GetM2ShortRealType): Ditto.
	(GetM2IntegerType): Ditto.
	(GetM2CharType): Ditto.
	(GetCSizeTType): Ditto.
	(GetCSSizeTType): Ditto.
	(BuildArrayStringConstructor): Ditto.
	(RealToTree): Ditto.
	(BuildStartRecord): Ditto.
	(BuildStartUnion): Ditto.
	(BuildStartVarient): Ditto.
	(BuildEndVarient): Ditto.
	(BuildStartFieldVarient): Ditto.
	(BuildEndFieldVarient): Ditto.
	(BuildStartFieldRecord): Ditto.
	(BuildFieldRecord): Ditto.
	(ChainOn): Ditto.
	(ChainOnParamValue): Ditto.
	(AddStringToTreeList): Ditto.
	(BuildEndRecord): Ditto.
	(SetAlignment): Ditto.
	(SetDeclPacked): Ditto.
	(SetTypePacked): Ditto.
	(SetRecordFieldOffset): Ditto.
	(BuildPackedFieldRecord): Ditto.
	(BuildNumberOfArrayElements): Ditto.
	(AddStatement): Ditto.
	(MarkFunctionReferenced): Ditto.
	(BuildArrayIndexType): Ditto.
	(GetArrayNoOfElements): Ditto.
	(BuildEndArrayType): Ditto.
	(PutArrayType): Ditto.
	(BuildStartArrayType): Ditto.
	(IsAddress): Ditto.
	(SameRealType): Ditto.
	* m2.flex (Gm2linemap.h): Include.
	* mc-boot/GDynamicStrings.cc: Rebuild.
	* mc-boot/GFIO.cc: Ditto.
	* mc-boot/GIndexing.cc: Ditto.
	* mc-boot/GM2Dependent.cc: Ditto.
	* mc-boot/GSArgs.cc: Ditto.
	* mc-boot/GStringConvert.cc: Ditto.
	* mc-boot/Gdecl.cc: Ditto.
	* mc-boot/Gdecl.h: Ditto.
	* mc-boot/Gdtoa.h: Ditto.
	* mc-boot/Gkeyc.cc: Ditto.
	* mc-boot/Gkeyc.h: Ditto.
	* mc-boot/Glibc.h: Ditto.
	* mc-boot/GmcComp.cc: Ditto.
	* mc-boot/GmcLexBuf.cc: Ditto.
	* mc-boot/GmcPreprocess.cc: Ditto.
	* mc-boot/GmcStream.cc: Ditto.
	* mc-boot/Gmcp1.cc: Ditto.
	* mc-boot/Gmcp3.cc: Ditto.
	* mc-boot/Gmcp4.cc: Ditto.
	* mc-boot/Gmcp5.cc: Ditto.
	* mc-boot/GnameKey.cc: Ditto.
	* mc-boot/Gvarargs.cc: Ditto.
	* mc/decl.def (putDefUnqualified): New procedure function.
	(isDefUnqualified): Ditto.
	* mc/decl.mod (defT): Add unqualified field.
	(charStarN): New variable.
	(constCharStarN): Ditto.
	(checkGccType): New procedure.
	(checkCDataTypes): Ditto.
	(import): Call checkGccType and checkCDataTypes.
	(putDefUnqualified): New procedure function.
	(isDefUnqualified): Ditto.
	* mc/keyc.def (useGccTree): New procedure.
	(useGccLocation): Ditto.
	* mc/keyc.mod (checkGccConfigSystem): Call checkGccConfigSystem.
	(useGccTree): New procedure.
	(useGccLocation): Ditto.
	* mc/mcp1.bnf (decl): Import putDefUnqualified.
	(Export): Call putDefUnqualified.
	* gm2-gcc/CDataTypes.def: New file.
	* gm2-gcc/gcctypes.def: New file.

(cherry picked from commit f6e629a713)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-29 22:34:49 +00:00
Gaius Mulley 59f5d4ef99 [PATCH] PR modula2/116557 Remove physical address from the GPL header comment
This patch removes the physical address from all the header comments
in the m2 subdirectory.  The physical address is replaced with the
text "You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>." instead.

gcc/m2/ChangeLog:

	PR modula2/116557
	* gm2-lang.cc: Replace physical address with URL in GPL header.
	* gm2-lang.h: Ditto.
	* images/LICENSE.IMG: Ditto.
	* m2-tree.def: Ditto.
	* mc-boot/GIndexing.cc: Ditto.
	* mc-boot/Gkeyc.cc: Ditto.
	* mc-boot/Glists.cc: Ditto.
	* mc-boot/GmcComp.cc: Ditto.
	* mc-boot/GmcDebug.cc: Ditto.
	* mc-boot/GmcFileName.cc: Ditto.
	* mc-boot/GmcMetaError.cc: Ditto.
	* mc-boot/GmcOptions.cc: Ditto.
	* mc-boot/GmcPreprocess.cc: Ditto.
	* mc-boot/GmcPretty.cc: Ditto.
	* mc-boot/GmcPrintf.cc: Ditto.
	* mc-boot/GmcQuiet.cc: Ditto.
	* mc-boot/GmcReserved.cc: Ditto.
	* mc-boot/GmcSearch.cc: Ditto.
	* mc-boot/GmcStack.cc: Ditto.
	* mc/Indexing.mod: Ditto.
	* mc/keyc.mod: Ditto.
	* mc/lists.mod: Ditto.
	* mc/mcComp.mod: Ditto.
	* mc/mcDebug.mod: Ditto.
	* mc/mcFileName.mod: Ditto.
	* mc/mcMetaError.mod: Ditto.
	* mc/mcOptions.mod: Ditto.
	* mc/mcPreprocess.mod: Ditto.
	* mc/mcPretty.mod: Ditto.
	* mc/mcPrintf.mod: Ditto.
	* mc/mcQuiet.mod: Ditto.
	* mc/mcReserved.mod: Ditto.
	* mc/mcSearch.mod: Ditto.
	* mc/mcStack.mod: Ditto.
	* tools-src/buildpg: Ditto.
	* tools-src/calcpath: Ditto.
	* tools-src/checkmeta.py: Ditto.
	* tools-src/def2doc.py: Ditto.
	* tools-src/makeSystem: Ditto.
	* tools-src/tidydates.py: Ditto.

(cherry picked from commit 78dc2e2575)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-29 18:34:33 +00:00
Gaius Mulley bead6de23e [PATCH] PR modula2/116181: m2rts fix -Wodr warning
This patch fixes the -Wodr warning seen in pge-boot/m2rts.h
when building pge.

gcc/m2/ChangeLog:

	PR modula2/116181
	* pge-boot/GM2RTS.h: Regenerate.
	* pge-boot/m2rts.h: Ditto.

(cherry picked from commit 87ce8172f0)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-29 16:36:14 +00:00
Gaius Mulley eb73f78634 [PATCH] PR modula2/116181 remove ODR warnings from library interface files
This patch removes the warnings generated by -Wodr from the library
interface between modula-2 and C.

gcc/m2/ChangeLog:

	PR modula2/116181
	* Make-lang.in (MC_SRC_FLAGS): New macro.
	(m2/mc-boot/$(SRC_PREFIX)%.o): Use MC_SRC_FLAGS.
	(m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto.
	(m2/gm2-libs-boot/M2RTS.o): Ditto.
	(m2/gm2-libs-boot/%.o): Ditto.
	(GM2-LIBS-BOOT-H): New macro.
	(m2/gm2-libs-boot/RTcodummy.o): Use MC_SRC_FLAGS.
	Remove gm2-libs-host.h from the dependancy.
	(m2/gm2-libs-boot/wrapc.o): Use MC_SRC_FLAGS.
	Add dependancy GM2-LIBS-BOOT-H.
	(m2/gm2-libs-boot/UnixArgs.o): Ditto.
	(m2/gm2-libs-boot/choosetemp.o): Ditto.
	(m2/gm2-libs-boot/errno.o): Ditto.
	(m2/gm2-libs-boot/dtoa.o): Ditto.
	(m2/gm2-libs-boot/ldtoa.o): Ditto.
	(m2/gm2-libs-boot/termios.o): Ditto.
	(m2/gm2-libs-boot/SysExceptions.o): Ditto.
	(m2/gm2-compiler-boot/M2GCCDeclare.o): Add gm2-libs-ch to the
	search path.
	(m2/gm2-compiler-boot/M2Error.o): Ditto.
	(m2/gm2-compiler-boot/%.o): Ditto.
	(m2/pge-boot/%.o): Ditto.
	* gm2-gcc/m2color.cc (m2color_colorize_start): Replace parameter
	type char to void and recast to char * when calling colorize_start.
	* gm2-gcc/m2color.h (m2color_colorize_start): Replace parameter
	type char to void.
	* gm2-gcc/m2type.h: Remove #if 0 block.
	* gm2-libs-ch/SysExceptions.c (DECL_PROC_T): Provide alternative
	defines for MC an gm2.
	(PROC_FUNC): Ditto.
	(EXTERN): Force undefine and redefine.
	(SysExceptions_InitExceptionHandlers): Rewrite function
	declaration using defined macros.
	(_M2_SysExceptions_init): Use EXTERN.
	(_M2_SysExceptions_finish): Replace with ...
	(_M2_SysExceptions_fini): ... this and add parameters.
	* gm2-libs-ch/UnixArgs.cc (gm2-libs-host.h): Include.
	(GUnixArgs.h): Include.
	(GM2RTS.h): Include.
	(UnixArgs_GetArgV): Change return type to void *.
	(UnixArgs_GetEnvV): Ditto.
	* gm2-libs-ch/m2rts.h (M2RTS_RegisterModule_Cstr): Add new
	conditional macro.
	(M2RTS_RequestDependant): Remove.
	(M2RTS_RegisterModule): Ditto.
	(M2RTS_Terminate): Ditto.
	(M2RTS_DeconstructModules): Ditto.
	(M2RTS_Halt): Ditto.
	(_M2_M2RTS_init): Ditto.
	(M2RTS_ConstructModules): Ditto.
	* gm2-libs-ch/termios.c (_termios_C): Define.
	(EXTERN): Add conditional definition.
	(doSetUnset): New function.
	(_M2_termios_init): Add correct parameters.
	(_M2_termios_finish): Ditto.
	(_M2_termios_fini): Ditto.
	* mc-boot-ch/GSysExceptions.c (DECL_PROC_T): New define.
	(PROC_FUNC): Ditto.
	(EXTERN): Force undef.
	(SysExceptions_InitExceptionHandlers): Rewrite.
	* mc-boot-ch/Glibc.c (libc_open): Rename parameter
	oflag to flags.
	* mc-boot-ch/Gtermios.cc (_termios_C): New define.
	(KillTermios): Change parameter type from
	struct termios * to termios_TERMIOS.
	(tcsnow): Rewrite.
	(tcsnow): Rewrite.
	(tcsdrain): Rewrite.
	(tcsflush): Rewrite.
	(cfgetospeed): Rewrite.
	(cfgetispeed): Rewrite.
	(cfsetospeed): Rewrite.
	(cfsetispeed): Rewrite.
	(cfsetspeed): Rewrite.
	(cfsetspeed): Rewrite.
	(tcgetattr): Rewrite.
	(tcsetattr): Rewrite.
	(cfmakeraw): Rewrite.
	(tcsendbreak): Rewrite.
	(tcdrain): Rewrite.
	(tcflushi): Rewrite.
	(tcflusho): Rewrite.
	(tcflushio): Rewrite.
	(tcflowoni): Rewrite.
	(tcflowoffi): Rewrite.
	(tcflowono): Rewrite.
	(tcflowoffo): Rewrite.
	(GetFlag): Rewrite.
	(SetFlag): Rewrite.
	(GetChar): Rewrite.
	(SetChar): Rewrite.
	(InitTermios): Rewrite.
	* pge-boot/GM2RTS.cc: Regenerate.
	* pge-boot/GSysExceptions.cc: Ditto.
	* pge-boot/Gtermios.cc: Ditto.
	* pge-boot/m2rts.h: Rewrite.
	* mc-boot-ch/GSYSTEM.h: New file.
	* mc-boot-ch/GSysExceptions.h: New file.
	* mc-boot-ch/Gtermios.h: New file.

(cherry picked from commit b8ef805e4d)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-29 15:30:44 +00:00
Richard Biener b1e14fc244 tree-optimization/117594 - fix live op vectorization for length masked case
The code was passing factor == 0 to vect_get_loop_len which always
returns an unmodified length, even if the number of scalar elements
doesn't agree.  It also failed to insert the eventually generated
code.

	PR tree-optimization/117594
	* tree-vect-loop.cc (vectorizable_live_operation_1): Pass
	factor == 1 to vect_get_loop_len, insert generated stmts.

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

(cherry picked from commit c108785c42)
2024-11-29 13:49:57 +01:00
Richard Biener 8764b8543b tree-optimization/117574 - bougs niter lt-to-ne
When trying to change a IV from IV0 < IV1 to IV0' != IV1' we apply
fancy adjustments to the may_be_zero condition we compute rather
than using the obvious IV0->base >= IV1->base expression (to be
able to use > instead of >=?).  This doesn't seem to go well.

	PR tree-optimization/117574
	* tree-ssa-loop-niter.cc (number_of_iterations_lt_to_ne):
	Use the obvious may_be_zero condition.

	* gcc.dg/torture/pr117574-1.c: New testcase.

(cherry picked from commit ff5a14abeb)
2024-11-29 13:49:36 +01:00
Richard Biener a8e01b735a middle-end/117433 - ICE with gimple BLKmode reg copy
When we end up expanding a SSA name copy with BLKmode regs which can
happen for vectors, possibly wrapped in a NOP-conversion or
a PAREN_EXPR and we are not optimizing we can end up with two
BLKmode MEMs that expand_gimple_stmt_1 doesn't properly handle
when expanding, trying to emit_move_insn them.  Looking at store_expr
which what expand_gimple_stmt_1 is really doing reveals a lot of
magic that's missing.  It eventually falls back to emit_block_move
(store_expr isn't exported), so this is what I ended up using here
given I think we'll only have BLKmode "registers" for vectors.

	PR middle-end/117433
	* cfgexpand.cc (expand_gimple_stmt_1): Use emit_block_move
	when moving temp to BLKmode target.

	* gcc.dg/pr117433.c: New testcase.

(cherry picked from commit 2fc25a2182)
2024-11-29 13:49:05 +01:00
Richard Biener 1fce679616 tree-optimization/117417 - ICE with complex load optimization
When we decompose a complex load only used as real and imaginary
parts we fail to honor IL constraints which are that a BIT_FIELD_REF
of register type should be outermost in a ref.  The following
simply avoids the transform when the complex load has such a
BIT_FIELD_REF.

	PR tree-optimization/117417
	* tree-ssa-forwprop.cc (pass_forwprop::execute): Avoid
	decomposing BIT_FIELD_REF complex load.

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

(cherry picked from commit d976daa931)
2024-11-29 13:48:52 +01:00
Richard Biener 8a13eef887 tree-optimization/117333 - ICE with NULL access size DR
dr_may_alias_p ICEs when TYPE_SIZE of DR->ref is NULL but this is
valid IL when the access size of an aggregate copy can be infered
from the RHS.

	PR tree-optimization/117333
	* tree-data-ref.cc (dr_may_alias_p): Guard against NULL
	access size.

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

(cherry picked from commit 0e99b22aa6)
2024-11-29 13:48:33 +01:00
Richard Biener bbe47a2d76 tree-optimization/117307 - STMT_VINFO_SLP_VECT_ONLY mis-computation
STMT_VINFO_SLP_VECT_ONLY isn't properly computed as union of all
group members and when the group is later split due to duplicates
not all sub-groups inherit the flag.

	PR tree-optimization/117307
	* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
	Properly compute STMT_VINFO_SLP_VECT_ONLY.  Set it on all
	parts of a split group.

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

(cherry picked from commit 19722308a2)
2024-11-29 13:47:59 +01:00
Richard Biener 6cfe4fd3fb tree-optimization/117254 - ICE with access diangostics
The diagnostics code fails to handle non-constant domain max.

	PR tree-optimization/117254
	* gimple-ssa-warn-access.cc (maybe_warn_nonstring_arg):
	Check the array domain max is constant before using it.

	* gcc.dg/pr117254.c: New testcase.

(cherry picked from commit d464a52d06)
2024-11-29 13:47:32 +01:00
GCC Administrator 9431ca6fcd Daily bump. 2024-11-29 00:25:26 +00:00
Martin Jambor 8fd9461976 tree-sra: Avoid SRAing arguments to a function returning_twice (PR 117142)
PR 117142 shows that the current SRA probably never worked reliably
with arguments passed to a function returning twice, because it then
creates statements before the call which however needs to be at the
beginning of a basic block.

While it should be possible to make at least the case of passing
arguments by value work with SRA (the statements would need to be put
just on the non-abnormal edges leading to the BB), this would mean
large surgery of function sra_modify_expr and I guess the time would
better be spent re-organizing the whole pass.

gcc/ChangeLog:

2024-10-21  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/117142
	* tree-sra.cc (build_access_from_call_arg): Disqualify any
	candidate passed to a function returning twice.

gcc/testsuite/ChangeLog:

2024-10-21  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/117142
	* gcc.dg/tree-ssa/pr117142.c: New test.

(cherry picked from commit 29d8f1f0b7)
2024-11-28 22:33:13 +01:00
Vladimir N. Makarov ea36e9d179 [PR117105][LRA]: Use unique value reload pseudo for early clobber operand
LRA did not generate insn satisfying insn constraints on the PR
test.  The reason for this is that LRA assigned the same hard reg for
two conflicting reload pseudos.  The two insn reload pseudos are
originated from the same pseudo and LRA tried to optimize as it
assigned the same value for the reload pseudos.  It is an LRA
optimization to minimize reload insns.  The two reload pseudos
conflict as one of them is an early clobber insn operands.  The patch
solves this problem by assigning unique value if the operand is early
clobber one.

gcc/ChangeLog:

	PR target/117105
	* lra-constraints.cc (get_reload_reg): Create unique value reload
	pseudos for early clobbered operands.

gcc/testsuite/ChangeLog:

	PR target/117105
	* gcc.target/i386/pr117105.c: New test.

(cherry picked from commit 4b09e2c67e)
2024-11-28 16:58:13 +01:00
Vladimir N. Makarov 196ab7853e [PR114942][LRA]: Don't reuse input reload reg of inout early clobber operand
The insn in question has the same reg in inout operand and input
operand.  The inout operand is early clobber.  LRA reused input reload
reg of the inout operand for the input operand which is wrong.  It
were a good decision if the inout operand was not early clobber one.
The patch rejects the reuse for the PR test case.

gcc/ChangeLog:

	PR target/114942
	* lra-constraints.cc (struct input_reload): Add new member early_clobber_p.
	(get_reload_reg): Add new arg early_clobber_p, don't reuse input
	reload with true early_clobber_p member value, use the arg for new
	element of curr_insn_input_reloads.
	(match_reload): Assign false to early_clobber_p member.
	(process_addr_reg, simplify_operand_subreg, curr_insn_transform):
	Adjust get_reload_reg calls.

gcc/testsuite/ChangeLog:

	PR target/114942
	* gcc.target/i386/pr114942.c: New.

(cherry picked from commit 9585317f07)
2024-11-28 16:57:53 +01:00
GCC Administrator 3161e4c2da Daily bump. 2024-11-28 00:25:21 +00:00
Paul Thomas da1305a9fe Fortran: Partial reversion of r15-5083 [PR117763]
2024-11-26  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/117763
	* trans-array.cc (gfc_get_array_span): Guard against derefences
	of 'expr'. Clean up some typos. Use 'gfc_get_vptr_from_expr'
	for clarity and apply a functional reversion of last section
	that deals with class dummies.

gcc/testsuite/
	PR fortran/117763
	* gfortran.dg/pr117763.f90: New test.

(cherry picked from commit 8278d9551d)
2024-11-27 07:08:56 +00:00
GCC Administrator e17defc4c0 Daily bump. 2024-11-27 00:25:01 +00:00
Arsen Arsenović 29c9213c37 gnat: fix lto-type-mismatch between C_Version_String and gnat_version_string [PR115917]
gcc/ada/ChangeLog:

	PR ada/115917
	* gnatvsn.ads: Add note about the duplication of this value in
	version.c.
	* version.c (VER_LEN_MAX): Define to the same value as
	Gnatvsn.Ver_Len_Max.
	(gnat_version_string): Use VER_LEN_MAX as bound.

(cherry picked from commit 9cbcf8d1de)
2024-11-26 18:32:25 +00:00
Gaius Mulley 3851751ab9 [PATCH] modula2: change identifier names to avoid build warnings
This fix avoids the following warnings: In implementation module
‘StdChans’: either the identifier has the same name as a keyword or
alternatively a keyword has the wrong case (‘IN’ and ‘in’)
   54 |    stdnull: ChanId ;

the symbol name ‘in’ is legal as an identifier, however as such it
might cause confusion and is considered bad programming practice.

gcc/m2/ChangeLog:

	* gm2-libs-iso/StdChans.mod (in): Rename to ...
	(inch): ... this.
	(out): Rename to ...
	(outch): ... this.
	(err): Rename to ...
	(errch): ... this.

(cherry picked from commit b584f387bf)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 16:05:03 +00:00
Gaius Mulley 5a809d4196 [PATCH] PR modula2/116378 m2 bootstrap fails on x86_64-darwin
This patch fixes m2 bootstrap failure on x86_64-darwin.  libc_open
is defined with three parameters the last of which is an int for
portability (rather than a vararg).  This avoids portability
problems by promoting mode_t to an int.  In the future it could
be tidied up by using the m2 optarg extension.

gcc/m2/ChangeLog:

	PR modula2/116378
	* gm2-libs-iso/TermFile.mod (termOpen): Add third argument
	for open.
	* gm2-libs/libc.def (open): Remove vararg and use INTEGER for
	mode parameter three.
	* mc-boot-ch/Glibc.c (tracedb_open): Replace mode_t with int.
	(libc_open): Rewrite without varargs.
	* mc-boot/Glibc.h (libc_open): Replace varargs with int mode.
	* pge-boot/Glibc.cc (libc_open): Rewrite.
	* pge-boot/Glibc.h (libc_open): Replace varargs with int mode.

gcc/testsuite/ChangeLog:

	PR modula2/116378
	* gm2/extensions/run/pass/testopen.mod: Add third argument
	for open.
	* gm2/isolib/run/pass/openlibc.mod: Ditto.
	* gm2/pim/run/pass/testaddr3.mod: Ditto.

(cherry picked from commit 9cdde72d1c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 15:56:48 +00:00
Gaius Mulley eed230db42 [PATCH] PR modula2/116181 fix ODR warnings for C/m2 interface library modules
This patch fixes many ODR warnings which appear when compiling the
interface files found in gcc/m2/*-ch/ and gcc/m2/{pge,mc}-boot
directories.

gcc/m2/ChangeLog:

	PR modula2/116181
	* gm2-compiler/ppg.mod (FindStr): Initialize j.
	* gm2-libs-ch/UnixArgs.cc (_M2_UnixArgs_ctor): Replace
	M2RTS_RegisterModule with M2RTS_RegisterModule_Cstr.
	* gm2-libs-ch/dtoa.cc (_M2_dtoa_ctor): Ditto.
	* gm2-libs-ch/ldtoa.cc (ldtoa_strtold): Cast parameter s
	for strtod.
	(_M2_ldtoa_ctor): Replace M2RTS_RegisterModule with
	M2RTS_RegisterModule_Cstr.
	* gm2-libs-ch/m2rts.h (M2RTS_RegisterModule_Cstr): New
	define.
	(M2RTS_RegisterModule): Remove const.
	* mc-boot-ch/GSelective.c (Selective_FdIsSet): Return bool
	rather than int.
	* mc-boot-ch/Gldtoa.cc (ldtoa_strtold): Change const char to
	void.
	Cast s before passing as a parameter to strtod.
	* mc-boot-ch/Glibc.c (tracedb_open): Replace const char with const
	void.
	(libc_perror): Replace char with const char.
	(libc_printf): Replace char with void.
	(libc_snprintf): Replace char with void.
	Add const_cast for parameter to index.
	Add reinterpret_cast for parameter to vsnprintf.
	(libc_open): Replace first paramter type char with void.
	Add vararg for the third parameter.
	* mc-boot-ch/Gm2rtsdummy.cc (M2RTS_RequestDependant): Remove #if 0 code.
	(m2pim_M2RTS_RegisterModule): Change const char parameters to void
	(M2RTS_RegisterModule): Ditto.
	(_M2_M2RTS_init): Remove #if 0 code.
	(M2RTS_ConstructModules): Ditto.
	(M2RTS_Terminate): Ditto.
	(M2RTS_DeconstructModules): Ditto.
	(M2RTS_Halt): Ditto.
	* mc-boot-ch/Gtermios.cc (SetFlag): Return bool.
	* mc-boot-ch/m2rts.h (M2RTS_RegisterModule_Cstr): New define.
	(M2RTS_RegisterModule): Change const char parameters to void.
	* mc-boot/Gdecl.cc: Regenerate.
	* mc/decl.mod (getNextConstExp): Reimplement.
	* pge-boot/GDynamicStrings.cc: Regenerate.
	* pge-boot/GDynamicStrings.h: Ditto.
	* pge-boot/GM2RTS.h (M2RTS_RegisterModule_Cstr): New function.
	(M2RTS_RegisterModule): Reformat.
	* pge-boot/GSymbolKey.cc: Regenerate.
	* pge-boot/GSysExceptions.cc (_M2_SysExceptions_init): Add correct parameters.
	(_M2_SysExceptions_fini): Ditto.
	* pge-boot/GUnixArgs.cc (_M2_UnixArgs_ctor::_M2_UnixArgs_ctor):
	Replace call to M2RTS_RegisterModule with M2RTS_RegisterModuleCstr.
	* pge-boot/Gerrno.cc (_M2_errno_init): Add correct parameters.
	(_M2_errno_fini): Ditto.
	* pge-boot/Gldtoa.cc (ldtoa_strtold): Replace const char with
	void.
	Use reinterpret_cast when passing s to strtod.
	Replace true with TRUE.
	* pge-boot/Gldtoa.h (ldtoa_strtold): Tidy up.
	* pge-boot/Glibc.cc (libc_read): Use size_t as the return type.
	(libc_write): Ditto.
	(libc_strlen): Ditto.
	(libc_perror): Replace char with const char.
	(libc_printf): Replace char to const char.
	Cast parameter to index using const_cast.
	(libc_snprintf): Replace char with void.
	Cast parameter to index using const_cast.
	(libc_malloc): Replace parameter type with size_t.
	(libc_memcpy): Replace third parameter type with size_t.
	(libc_open): Use varargs.
	* pge-boot/Glibc.h (libc_perror): Add _string_high parameter.
	* pge-boot/Gpge.cc: Regenerate.
	* pge-boot/Gtermios.cc (SetFlag): Replace return type with bool.
	(_M2_termios_init): Add correct parameters.
	(_M2_termios_fini): Ditto.
	* pge-boot/m2rts.h (M2RTS_RegisterModule_Cstr): New define.
	(M2RTS_RegisterModule): Replace const char with void.

(cherry picked from commit 9f3b5c2314)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 15:52:55 +00:00
Torbjörn SVENSSON 407970fdd3 testsuite: arm: Use correct the expected asm in epilog-1.c test
In r14.2.0-376-g724446556e5, I accidentally introduced a regression in
the expected assembler as the csinc instruction was not used for
armv8.1-m.main.

The generated assembler for armv8.1-m.main is:
        push    {r3, r4, r5, lr}
        ldr     r4, .L5
        ldr     r5, [r4]
        adds    r4, r2, #1
        tst     r5, #4
        it      ne
        movne   r2, r4
        bl      bar
        movs    r0, #0
        pop     {r3, r4, r5, pc}

gcc/testsuite/ChangeLog:

	* gcc.target/arm/epilog-1.c: Corrected armv8.1.m-main asm.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2024-11-26 16:45:59 +01:00
Gaius Mulley 056448490e [PATCH] PR modula2/115823 Wrong expansion of isnormal optab
This patch corrects the function declaration of a builtin
(using the libname rather than the source name).

gcc/m2/ChangeLog:

	PR modula2/115823
	* gm2-gcc/m2builtins.cc (define_builtin): Build
	the function decl using the libname.

gcc/testsuite/ChangeLog:

	PR modula2/115823
	* gm2/builtins/run/pass/testisnormal.mod: Change to an
	implementation module.
	* gm2/builtins/run/pass/testisnormal.def: New test.
	* gm2/builtins/run/pass/testsinl.def: New test.
	* gm2/builtins/run/pass/testsinl.mod: New test.

(cherry picked from commit 79e029a418)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 13:18:27 +00:00
Gaius Mulley 2665f3e027 [PATCH] modula2: Improve error message to include symbol name.
gcc/m2/ChangeLog:

	* gm2-compiler/M2StateCheck.mod (GenerateError): Add
	symbol name to the error message.

(cherry picked from commit 6a99f3ae96)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 13:15:56 +00:00
Gaius Mulley 0891093e65 [PATCH] modula2: Add GNU flex as a build and install prerequisite.
gcc/ChangeLog:

	* doc/install.texi (GM2-prerequisite): Add GNU flex.

(cherry picked from commit 52f3473e37)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 13:11:31 +00:00
Gaius Mulley bcb8f40110 [PATCH] PR modula2/116048 ICE when encountering wrong kind of qualident
Following on from PR-115957 further ICEs can be generated by using the
wrong kind of qualident symbol.  For example using a variable instead of
a type or using a type instead of a const.  This fix tracks the expected
qualident kind state when parsing const, type and variable declarations.
If the error is unrecoverable then a detailed message explaining the
context of the qualident (and why the seen qualident is wrong) is
generated.

gcc/m2/ChangeLog:

	PR modula2/116048
	* Make-lang.in (GM2-COMP-BOOT-DEFS): Add M2StateCheck.def.
	(GM2-COMP-BOOT-MODS): Add M2StateCheck.mod.
	(GM2-COMP-DEFS): Add M2StateCheck.def.
	(GM2-COMP-MODS): Add M2StateCheck.mod.
	* gm2-compiler/M2Quads.mod (StartBuildWith): Generate
	unrecoverable error is the qualident type is NulSym.
	Replace MetaError1 with MetaErrorT1 and position the error
	to the qualident.
	* gm2-compiler/P3Build.bnf (M2StateCheck): Import procedures.
	(seenError): New variable.
	(WasNoError): Remove variable.
	(BlockState): New variable.
	(ErrorString): Rewrite using seenError.
	(CompilationUnit): Ditto.
	(QualidentCheck): New rule.
	(ConstantDeclaration): Bookend with InclConst and ExclConst.
	(Constructor): Add InclConstructor, ExclConstructor and call
	CheckQualident.
	(ConstActualParameters): Call PushState, PopState, InclConstFunc
	and CheckQualident.
	(TypeDeclaration): Bookend with InclType and ExclType.
	(SimpleType): Call QualidentCheck.
	(CaseTag): Ditto.
	(OptReturnType): Ditto.
	(VariableDeclaration): Bookend with InclVar and ExclVar.
	(Designator): Call QualidentCheck.
	(Formal;Type): Ditto.
	* gm2-compiler/PCBuild.bnf (M2StateCheck): Import procedures.
	(ConstantDeclaration): Rewrite using InclConst and ExclConst.
	(Constructor): Bookend with InclConstructor and ExclConstructor.
	Call CheckQualident.
	(ConstructorOrConstActualParameters): Rewrite and cal
	l CheckQualident.
	(ConstActualParameters): Bookend with PushState PopState.
	Call InclConstFunc and CheckQualident.
	* gm2-gcc/init.cc (_M2_M2StateCheck_init): New declaration.
	(_M2_P3Build_init): New declaration.
	(init_PerCompilationInit): Call _M2_M2StateCheck_init and
	_M2_P3Build_init.
	* gm2-compiler/M2StateCheck.def: New file.
	* gm2-compiler/M2StateCheck.mod: New file.

gcc/testsuite/ChangeLog:

	PR modula2/116048
	* gm2/errors/fail/errors-fail.exp: Remove -Wstudents
	and add -Wuninit-variable-checking=all.
	Replace gm2_init_pim with gm2_init_iso.
	* gm2/errors/fail/testfio.mod: Modify test code to
	provoke an error in the first basic block.
	* gm2/errors/fail/testparam.mod: Ditto.
	* gm2/errors/fail/array1.mod: Ditto.
	* gm2/errors/fail/badtype.mod: New test.
	* gm2/errors/fail/badvar.mod: New test.

(cherry picked from commit 7f8064ff0e)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 13:04:05 +00:00
Gaius Mulley 99d537558e [PATCH] PR modula2/115957 ICE on procedure local const declaration
An ICE would occur if a constant was declared using a variable term.
This fix catches variable terms in constant expressions and generates
an unrecoverable error.

gcc/m2/ChangeLog:

	PR modula2/115957
	* gm2-compiler/M2StackAddress.mod (PopAddress): Detect tail=NIL
	and generate an internal error.
	* gm2-compiler/PCBuild.bnf (InConstParameter): New variable.
	(InConstBlock): New variable.
	(ErrorString): Rewrite using MetaErrorStringT0.
	(ErrorArrayAt): Rewrite using MetaErrorStringT0.
	(WarnMissingToken): Use MetaErrorStringT0.
	(CompilationUnit): Set seenError FALSE.
	(init): Initialize InConstParameter and InConstBlock.
	(ConstantDeclaration): Set InConstBlock.
	(ConstSetOrQualidentOrFunction): Call CheckNotVar if not
	InConstParameter and InConstBlock.
	(ConstActualParameters): Set InConstParameter TRUE and restore
	value at the end.
	* gm2-compiler/PCSymBuild.def (CheckNotVar): New procedure.
	Remove all unnecessary export qualified list.
	* gm2-compiler/PCSymBuild.mod (CheckNotVar): New procedure.

gcc/testsuite/ChangeLog:

	PR modula2/115957
	* gm2/errors/fail/badconst.mod: New test.
	* gm2/pim/fail/tinyadr.mod: New test.

(cherry picked from commit d9709fafb2)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-26 12:57:12 +00:00
GCC Administrator 93a1cf3296 Daily bump. 2024-11-26 00:24:56 +00:00
Lewis Hyatt 9214e3fdf9 libcpp: Fix ICE lexing invalid raw string in a deferred pragma [PR117118]
The PR shows that we ICE after lexing an invalid unterminated raw string,
because lex_raw_string() pops the main buffer unexpectedly. Resolve by
handling this case the same way as for other directives.

libcpp/ChangeLog:
	PR preprocessor/117118
	* lex.cc (lex_raw_string): Treat an unterminated raw string the same
	way for a deferred pragma as is done for other directives.

gcc/testsuite/ChangeLog:
	PR preprocessor/117118
	* c-c++-common/raw-string-directive-3.c: New test.
	* c-c++-common/raw-string-directive-4.c: New test.
2024-11-25 13:36:09 -05:00
liuhongt 4a63cc6de7 Fix uninitialized operands[2] in vec_unpacks_hi_v4sf.
It could cause weired spill in RA when register pressure is high.

gcc/ChangeLog:

	PR target/117562
	* config/i386/sse.md (vec_unpacks_hi_v4sf): Initialize
	operands[2] with CONST0_RTX.

(cherry picked from commit ba4cf2e296)
2024-11-25 00:44:52 -08:00
GCC Administrator dbb5d067f5 Daily bump. 2024-11-25 00:23:17 +00:00
Paul Thomas 911a870a61 Fortran: Fix segfault in allocation of unlimited poly array [PR84869]
2024-11-24  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/ChangeLog

	PR fortran/84869
	* trans-expr.cc (trans_class_vptr_len_assignment): To access
	the '_len' field, 're' must be unlimited polymorphic.

gcc/testsuite/
	PR fortran/84869
	* gfortran.dg/pr84869.f90: Comment out test of component refs.
2024-11-24 14:22:18 +00:00
GCC Administrator 1e18a1ba27 Daily bump. 2024-11-24 00:24:53 +00:00
Paul Thomas c53a8c0410 Fortran: Suppress invalid finalization of artificial variable [PR116388]
2024-11-11  Tomas Trnka  <trnka@scm.com>
	    Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/116388
	* class.cc (finalize_component): Leading underscore in the name
	of 'byte_stride' to suppress invalid finalization.

gcc/testsuite/
	PR fortran/116388
	* gfortran.dg/finalize_58.f90: New test.

(cherry picked from commit 42a2df0b79)
2024-11-23 16:20:28 +00:00
Paul Thomas d65a599795 Fortran: Fix elemental array refs in SELECT TYPE [PR109345]
2024-11-10  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/109345
	* trans-array.cc (gfc_get_array_span): Unlimited polymorphic
	expressions are now treated separately since the span need not
	be the same as the element size.

gcc/testsuite/
	PR fortran/109345
	* gfortran.dg/character_workout_1.f90: Cut trailing whitespace.
	* gfortran.dg/pr109345.f90: New test.

(cherry picked from commit e22d80d4f0)
2024-11-23 16:13:16 +00:00
Gaius Mulley b6b8893094 [PATCH] modula2: bootstrap fix for string and vector headers.
This patch fixes the include of headers (<string> and <vector>) which
are included after GCC's system.h has been included.  It defines
INCLUDE_STRING before including "system.h".  This allows gcc to
bootstrap with Apple clang 15.

gcc/m2/ChangeLog:

	* gm2-gcc/m2linemap.cc (INCLUDE_STRING): Define before
	include of gcc-consolidation.h.
	* gm2spec.cc (INCLUDE_STRING): Define before include of
	system.h.
	(INCLUDE_VECTOR): Ditto.

(cherry picked from commit f4047a8614)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-23 15:27:45 +00:00
Gaius Mulley 8e3b5a7414 [PATCH] PR modula2/115823 Wrong expansion of isnormal optab
The bug fix changes gcc/m2/gm2-gcc/m2builtins.c:m2builtins_BuiltinExists
to recognise both __builtin_<functionname> and functionname as a builtin.

gcc/m2/ChangeLog:

	PR modula2/115823
	* gm2-gcc/m2builtins.cc (struct builtin_macro_definition): New
	field builtinname.
	(builtin_function_match): New function.
	(builtin_macro_match): Ditto.
	(m2builtins_BuiltinExists): Use builtin_function_match and
	builtin_macro_match.
	(lookup_builtin_macro): Use builtin_macro_match.
	(lookup_builtin_function): Use builtin_function_match.
	(define_builtin): Assign builtinname field.

gcc/testsuite/ChangeLog:

	PR modula2/115823
	* gm2/builtins/run/pass/testalloa.mod: New test.

(cherry picked from commit 2d1f68e796)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-23 14:27:06 +00:00
8a6b30148d [PATCH] PR modula2/115804 ICE during gimplification with new isfinite optab
The calls to five m2 builtins have the incorrect return type.
This was detected when adding isfinitedf2 optab to the s390
backend which results in ICEs during gimplification in the
gm2 testsuite.

gcc/m2/ChangeLog:

	PR modula2/115804
	* gm2-gcc/m2builtins.cc (builtin_function_entry): Add GTY.
	(DoBuiltinMemCopy): Add rettype and use rettype in the call.
	(DoBuiltinAlloca): Ditto.
	(DoBuiltinIsfinite): Ditto.
	(DoBuiltinIsnan): Ditto.
	(m2builtins_BuiltInHugeVal): Ditto.
	(m2builtins_BuiltInHugeValShort): Ditto.
	(m2builtins_BuiltInHugeValLong): Ditto.

Co-Authored-By: Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
Co-Authored-By: Andrew Pinski  <quic_apinski@quicinc.com>

(cherry picked from commit 4594d555aa)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-23 13:16:15 +00:00
Georg-Johann Lay f66748d61d AVR: target/117744 - Fix asm for partial clobber of address reg,
gcc/
	PR target/117744
	* config/avr/avr.cc (out_movqi_r_mr): Fix code when a load
	only partially clobbers an address register due to
	changing the address register temporally to accommodate for
	faked addressing modes.

(cherry picked from commit ee8e678487)
2024-11-23 13:04:42 +01:00
GCC Administrator 62b878b141 Daily bump. 2024-11-23 00:27:49 +00:00
Gaius Mulley ed9129c27d [PATCH] modula2: tidyup remove unused procedures and unused parameters
This patch removes M2GenGCC.mod:QuadCondition and
M2Quads.mod:GenQuadOTypeUniquetok.  It also removes unused parameter
WalkAction for all FoldIf procedures.

gcc/m2/ChangeLog:

	* gm2-compiler/M2GenGCC.mod (QuadCondition): Remove.
	(FoldIfEqu): Remove WalkAction parameter.
	(FoldIfNotEqu): Ditto.
	(FoldIfGreEqu): Ditto.
	(FoldIfLessEqu): Ditto.
	(FoldIfGre): Ditto.
	(FoldIfLess): Ditto.
	(FoldIfIn): Ditto.
	(FoldIfNotIn): Ditto.
	* gm2-compiler/M2Quads.mod (GenQuadOTypeUniquetok): Remove.

(cherry picked from commit 038144534a)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 21:09:10 +00:00
Gaius Mulley 8701cdbf8d [PATCH] PR modula2/115540 gcc/m2/mc-boot-ch/Gtermios.cc error return-statement with a value
This patch fixes three occurrences of cfmakeraw use in the hand built
m2 support libraries which incorrectly attempt to return a void
result.

gcc/m2/ChangeLog:

	PR modula2/115540
	* gm2-libs-ch/termios.c (cfmakeraw): Remove return.
	* mc-boot-ch/Gtermios.cc (cfmakeraw): Remove return.
	* pge-boot/Gtermios.cc (cfmakeraw): Remove return.

(cherry picked from commit d16355c72c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 19:46:44 +00:00
Gaius Mulley 3adceba04e [PATCH] PR modula2/115536 Expression is evaluated incorrectly when encountering relops and indirection
This fix ensures that we only call BuildRelOpFromBoolean if we are
inside a constant expression (where no indirection can be used).
The fix creates a temporary variable when a boolean is created from
a relop in other cases.
The previous pattern implementation would not work if the operands required
dereferencing during non const expressions.  Comparison of relop results
in a constant expression are resolved by constant propagation, basic
block analysis and dead code removal.  After the quadruples have been
optimized only one assignment to the boolean variable will remain for
const expressions.  All quadruple pattern checking for boolean
expressions is removed by the patch.  Thus the implementation becomes
more generic.

gcc/m2/ChangeLog:

	PR modula2/115536
	* gm2-compiler/M2BasicBlock.def (GetBasicBlockScope): New procedure.
	(GetBasicBlockStart): Ditto.
	(GetBasicBlockEnd): Ditto.
	(IsBasicBlockFirst): New procedure function.
	* gm2-compiler/M2BasicBlock.mod (ConvertQuads2BasicBlock): Allow
	conditional boolean quads to be removed.
	(GetBasicBlockScope): Implement new procedure.
	(GetBasicBlockStart): Ditto.
	(GetBasicBlockEnd): Ditto.
	(IsBasicBlockFirst): Implement new procedure function.
	* gm2-compiler/M2GCCDeclare.def (FoldConstants): New parameter
	declaration.
	* gm2-compiler/M2GCCDeclare.mod (FoldConstants): New parameter
	declaration.
	(DeclareTypesConstantsProceduresInRange): Recreate basic blocks
	after resolving constant expressions.
	(CodeBecomes): Guard IsVariableSSA with IsVar.
	* gm2-compiler/M2GenGCC.def (ResolveConstantExpressions): New
	parameter declaration.
	* gm2-compiler/M2GenGCC.mod (FoldIfLess): Remove relop pattern
	detection.
	(FoldIfGre): Ditto.
	(FoldIfLessEqu): Ditto.
	(FoldIfGreEqu): Ditto.
	(FoldIfIn): Ditto.
	(FoldIfNotIn): Ditto.
	(FoldIfEqu): Ditto.
	(FoldIfNotEqu): Ditto.
	(FoldBecomes): Add BasicBlock parameter and allow conditional
	boolean becomes to be folded in the first basic block.
	(ResolveConstantExpressions): Reimplement.
	* gm2-compiler/M2Quads.def (IsConstQuad): New procedure function.
	(IsConditionalBooleanQuad): Ditto.
	* gm2-compiler/M2Quads.mod (IsConstQuad): Implement new procedure function.
	(IsConditionalBooleanQuad): Ditto.
	(MoveWithMode): Use GenQuadOTypetok.
	(IsInitialisingConst): Rewrite using OpUsesOp1.
	(OpUsesOp1): New procedure function.
	(doBuildAssignment): Mark des as a VarConditional.
	(ConvertBooleanToVariable): Call PutVarConditional.
	(DumpQuadSummary): New procedure.
	(BuildRelOpFromBoolean): Updated debugging and improved comments.
	(BuildRelOp): Only call BuildRelOpFromBoolean if we are in a const
	expression and both operands are boolean relops.
	(GenQuadOTypeUniquetok): New procedure.
	(BackPatch): Correct comment.
	* gm2-compiler/SymbolTable.def (PutVarConditional): New procedure.
	(IsVarConditional): New procedure function.
	* gm2-compiler/SymbolTable.mod (PutVarConditional): Implement new
	procedure.
	(IsVarConditional): Implement new procedure function.
	(SymConstVar): New field IsConditional.
	(SymVar): New field IsConditional.
	(MakeVar): Initialize IsConditional field.
	(MakeConstVar): Initialize IsConditional field.
	* gm2-compiler/M2Swig.mod (DoBasicBlock): Change parameters to
	use BasicBlock.
	* gm2-compiler/M2Code.mod (SecondDeclareAndOptimize): Use iterator
	to FoldConstants over basic block list.
	* gm2-compiler/M2SymInit.mod (AppendEntry): Replace parameters
	with BasicBlock.
	* gm2-compiler/P3Build.bnf (Relation): Call RecordOp for #, <> and =.

gcc/testsuite/ChangeLog:

	PR modula2/115536
	* gm2/iso/const/pass/constbool4.mod: New test.
	* gm2/iso/const/pass/constbool5.mod: New test.
	* gm2/iso/run/pass/condtest2.mod: New test.
	* gm2/iso/run/pass/condtest3.mod: New test.
	* gm2/iso/run/pass/condtest4.mod: New test.
	* gm2/iso/run/pass/condtest5.mod: New test.
	* gm2/iso/run/pass/constbool4.mod: New test.

(cherry picked from commit 9f168b412f)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 18:38:51 +00:00
Harald Anlauf 9fd8cd1990 Fortran: fix passing of NULL() actual argument to character dummy [PR104819]
Ensure that character length is set and passed by the call to a procedure
when its dummy argument is NULL() with MOLD argument present, or set length
to either 0 or the callee's expected character length.  For assumed-rank
dummies, use the rank of the MOLD argument.  Generate temporaries for
passed arguments when needed.

	PR fortran/104819

gcc/fortran/ChangeLog:

	* trans-expr.cc (conv_null_actual): Helper function to handle
	passing of NULL() to non-optional dummy arguments of non-bind(c)
	procedures.
	(gfc_conv_procedure_call): Use it for character dummies.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit f70c1d517e)
2024-11-22 18:51:53 +01:00
Gaius Mulley 0750bda126 [PATCH] PR modula2/114529 Avoid ODR violations in bootstrap translated sources
This patch changes the bootstrap tool mc to avoid redefining any data
types and therefore preventing ODR violations.  All exported opaque type
usages are implemented as void *.  Local opaque type usages (static
functions containing opaque type parameters) use the full declaration.
mc casts usages between void * and full opaque type as necessary.
The --extended-opaque option in mc has been disabled, as this generated
ODR violations.  The extended-opaque option inlined all declarations in
the translated implementation module.  As this is no longer used there
is now a .h file for each .def file and a .cc file for every .mod file.
This results in more Makefile rules for the ppg tool in Make-maintainer.in.

gcc/m2/ChangeLog:

	PR modula2/114529
	* Make-lang.in (MC_EXTENDED_OPAQUE): Assign to nothing.
	* Make-maintainer.in (mc-basetest): New rule.
	(mc-devel-basetest): New rule.
	(mc-clean): Remove mc.
	(m2/mc-boot-gen/$(SRC_PREFIX)decl.cc): Replace --extended-opaque
	with $(EXTENDED_OPAQUE).
	(PG-SRC): Move define before generic rules.
	(PGE-DEF): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)%.h): New rule.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)libc.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)mcrts.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)UnixArgs.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)Selective.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)termios.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)SysExceptions.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)ldtoa.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)wrapc.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)SYSTEM.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)errno.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)Output.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.h): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.o): Ditto.
	(m2/gm2-ppg-boot/$(SRC_PREFIX)%.o): Ditto.
	(m2/ppg$(exeext)): Ditto.
	(m2/gm2-ppg-boot/main.o): Ditto.
	(m2/gm2-auto): Ditto.
	(c-family/m2pp.o): Ditto.
	(BUILD-BOOT-PG-H): Correct macro definition.
	(m2/gm2-pg-boot/$(SRC_PREFIX)%.h): New rule.
	(m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.o): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)Lists.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)Lists.o): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)Output.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)Output.o): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.o): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)RTco.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.h): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)RTco.o): Ditto.
	(m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.o): Ditto.
	(BUILD-BOOT-PGE-H): Correct macro definition.
	(m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Output.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTco.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTco.o): Ditto.
	(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto.
	(mc-basetest): Ditto.
	(mc-devel-basetest): Ditto.
	* gm2-compiler/M2Options.def (SetM2Dump): Add BOOLEAN return.
	* gm2-compiler/M2Quads.def (BuildAlignment): Add tokno parameter.
	(BuildBitLength): Ditto.
	* gm2-compiler/P3Build.bnf (ByteAlignment): Move tokpos assignment
	to the start of the block.
	* gm2-compiler/PCBuild.bnf (ConstSetOrQualidentOrFunction): Ditto.
	(SetOrDesignatorOrFunction): Ditto.
	* gm2-compiler/PHBuild.bnf (ConstSetOrQualidentOrFunction): Ditto.
	(SetOrDesignatorOrFunction): Ditto.
	(ByteAlignment): Ditto.
	* gm2-libs/dtoa.def (dtoa): Change mode to INTEGER.
	* gm2-libs/ldtoa.def (ldtoa): Ditto.
	* mc-boot-ch/GSYSTEM.c (_M2_SYSTEM_init): Correct parameter list.
	(_M2_SYSTEM_fini): Ditto.
	* mc-boot-ch/Gdtoa.cc (dtoa_calcsign): Return bool.
	(dtoa_dtoa): Return void * and use bool in the fifth parameter.
	(_M2_dtoa_init): Correct parameter list.
	(_M2_dtoa_fini): Ditto.
	* mc-boot-ch/Gerrno.cc (_M2_errno_init): Ditto.
	(_M2_errno_fini): Ditto.
	* mc-boot-ch/Gldtoa.cc (dtoa_calcsign): Return bool.
	(ldtoa_ldtoa): Return void * and use bool in the fifth parameter.
	(_M2_ldtoa_init): Correct parameter list.
	(_M2_ldtoa_fini): Ditto.
	* mc-boot-ch/Glibc.c (tracedb_zresult): New function.
	(libc_read): Return size_t and use size_t in parameter three.
	(libc_write): Return size_t and use size_t in parameter three.
	(libc_printf): Add const to the format specifier.
	Change declaration of c to use const.
	(libc_snprintf): Add const to the format specifier.
	Change declaration of c to use const.
	(libc_malloc): Use size_t.
	(libc_memcpy): Ditto.
	* mc-boot/GASCII.cc: Regenerate.
	* mc-boot/GArgs.cc: Ditto.
	* mc-boot/GAssertion.cc: Ditto.
	* mc-boot/GBreak.cc: Ditto.
	* mc-boot/GCmdArgs.cc: Ditto.
	* mc-boot/GDebug.cc: Ditto.
	* mc-boot/GDynamicStrings.cc: Ditto.
	* mc-boot/GEnvironment.cc: Ditto.
	* mc-boot/GFIO.cc: Ditto.
	* mc-boot/GFormatStrings.cc: Ditto.
	* mc-boot/GFpuIO.cc: Ditto.
	* mc-boot/GIO.cc: Ditto.
	* mc-boot/GIndexing.cc: Ditto.
	* mc-boot/GM2Dependent.cc: Ditto.
	* mc-boot/GM2EXCEPTION.cc: Ditto.
	* mc-boot/GM2RTS.cc: Ditto.
	* mc-boot/GMemUtils.cc: Ditto.
	* mc-boot/GNumberIO.cc: Ditto.
	* mc-boot/GPushBackInput.cc: Ditto.
	* mc-boot/GRTExceptions.cc: Ditto.
	* mc-boot/GRTint.cc: Ditto.
	* mc-boot/GSArgs.cc: Ditto.
	* mc-boot/GSFIO.cc: Ditto.
	* mc-boot/GStdIO.cc: Ditto.
	* mc-boot/GStorage.cc: Ditto.
	* mc-boot/GStrCase.cc: Ditto.
	* mc-boot/GStrIO.cc: Ditto.
	* mc-boot/GStrLib.cc: Ditto.
	* mc-boot/GStringConvert.cc: Ditto.
	* mc-boot/GSysStorage.cc: Ditto.
	* mc-boot/GTimeString.cc: Ditto.
	* mc-boot/Galists.cc: Ditto.
	* mc-boot/Gdecl.cc: Ditto.
	* mc-boot/Gkeyc.cc: Ditto.
	* mc-boot/Glists.cc: Ditto.
	* mc-boot/GmcComment.cc: Ditto.
	* mc-boot/GmcComp.cc: Ditto.
	* mc-boot/GmcDebug.cc: Ditto.
	* mc-boot/GmcError.cc: Ditto.
	* mc-boot/GmcFileName.cc: Ditto.
	* mc-boot/GmcLexBuf.cc: Ditto.
	* mc-boot/GmcMetaError.cc: Ditto.
	* mc-boot/GmcOptions.cc: Ditto.
	* mc-boot/GmcPreprocess.cc: Ditto.
	* mc-boot/GmcPretty.cc: Ditto.
	* mc-boot/GmcPrintf.cc: Ditto.
	* mc-boot/GmcQuiet.cc: Ditto.
	* mc-boot/GmcReserved.cc: Ditto.
	* mc-boot/GmcSearch.cc: Ditto.
	* mc-boot/GmcStack.cc: Ditto.
	* mc-boot/GmcStream.cc: Ditto.
	* mc-boot/Gmcp1.cc: Ditto.
	* mc-boot/Gmcp2.cc: Ditto.
	* mc-boot/Gmcp3.cc: Ditto.
	* mc-boot/Gmcp4.cc: Ditto.
	* mc-boot/Gmcp5.cc: Ditto.
	* mc-boot/GnameKey.cc: Ditto.
	* mc-boot/GsymbolKey.cc: Ditto.
	* mc-boot/Gvarargs.cc: Ditto.
	* mc-boot/Gwlists.cc: Ditto.
	* mc-boot/Gdecl.h: Ditto.
	* mc-boot/Gldtoa.h: Ditto.
	* mc-boot/Glibc.h: Ditto.
	* mc/decl.def (putTypeOpaque): New procedure.
	(isTypeOpaque): New procedure function.
	* mc/decl.mod (debugOpaque): New constant.
	(nodeT): New enumeration field opaquecast.
	(node): New record field opaquecastF.
	(opaqueCastState): New record.
	(opaquecastT): New record.
	(typeT): New field isOpaque.
	(varT): New field opaqueState.
	(arrayT): Ditto.
	(varparamT): Ditto.
	(paramT): Ditto.
	(pointerT): Ditto.
	(recordfieldT): Ditto.
	(componentrefT): Ditto.
	(pointerrefT): Ditto.
	(arrayrefT): Ditto.
	(procedureT): Ditto.
	(proctypeT): Ditto.
	(makeType): Initialize field isOpaque.
	(makeTypeImp): Initialize field isOpaque.
	(putVar): Call initNodeOpaqueCastState.
	(putReturnType): Ditto.
	(makeProcType): Ditto.
	(putProcTypeReturn): Ditto.
	(makeVarParameter): Ditto.
	(makeNonVarParameter): Ditto.
	(makeFuncCall): Ditto.
	(putTypeOpaque): New procedure.
	(isTypeOpaque): New procedure function.
	(doMakeComponentRef): Call initNodeOpaqueCastState.
	(makePointerRef): Call initNodeOpaqueCastState.
	(doGetFuncType): Call initNodeOpaqueCastState.
	(doBinary): Add FALSE parameter to doExprCup.
	(doDeRefC): Rewrite.
	(doComponentRefC): Call flushOpaque.
	(doPointerRefC): Call flushOpaque.
	(doArrayRefC): Add const_cast for unbounded array.
	(doExprCup): Rewrite.
	(doTypeAliasC): Remove.
	(isDeclType): New procedure function.
	(doEnumerationC): New procedure function.
	(doParamTypeEmit): Ditto.
	(doParamTypeNameModifier): Ditto.
	(initOpaqueCastState): Ditto.
	(initNodeOpaqueCastState): Ditto.
	(setOpaqueCastState): Ditto.
	(setNodeOpaqueVoidStar): Ditto.
	(nodeUsesOpaque): Ditto.
	(getNodeOpaqueVoidStar): Ditto.
	(getOpaqueFlushNecessary): Ditto.
	(makeOpaqueCast): Ditto.
	(flushOpaque): Ditto.
	(castOpaque): Ditto.
	(isTypeOpaqueDefImp): Ditto.
	(isParamVoidStar): Ditto.
	(isRefVoidStar): Ditto.
	(isReturnVoidStar): Ditto.
	(isVarVoidStar): Ditto.
	(initNodeOpaqueState): Ditto.
	(assignNodeOpaqueCastState): Ditto.
	(assignNodeOpaqueCastFalse): Ditto.
	(dumpOpaqueState): Ditto.
	(doProcTypeC): Rewrite.
	(isDeclInImp): New procedure function.
	(doTypeNameModifier): Ditto.
	(doTypeC): Emit typedef if enum is declared in this module.
	(doCompletePartialProcType): Rewrite.
	(outputCompletePartialProcType): New procedure.
	(doOpaqueModifier): Ditto.
	(doVarC): Ditto.
	(doProcedureHeadingC): Add opaque modifier to return type if
	necessary.
	(doReturnC): Cast opaque type for return if necessary.
	(forceCastOpaque): New procedure.
	(forceReintCastOpaque): New procedure.
	(doUnConstCastUnbounded): New procedure.
	(doAssignmentC): Cast opaque for both des and expr if necessary.
	(doAdrExprC): Use static_cast for void * casting.
	(doFuncVarParam): New procedure.
	(doFuncParamC): Rewrite.
	(doAdrArgC): Rewrite.
	(getFunction): New procedure function.
	(stop): Rename to ...
	(localstop): ... this.
	(dupFunccall): Call assignNodeOpaqueCastState.
	(dbg): Rewrite.
	(addDone): Rewrite.
	(addDoneDef): Do not add opaque types to the doneQ when declared in
	the definition module.
	* mc/mc.flex (openSource): Return bool.
	(_M2_mcflex_init): Correct parameter list.
	(_M2_mcflex_fini): Ditto.
	* mc/mcComment.h (stdbool.h): Include.
	(mcComment_initComment): Change unsigned int to bool.
	* mc/mcOptions.mod (handleOption): Disable --extended-opaque
	and issue warning.
	* mc/mcp1.bnf (DefTypeDeclaration): Call putTypeOpaque.

gcc/testsuite/ChangeLog:

	PR modula2/114529
	* gm2/base-lang/pass/SYSTEM.def: New test.
	* gm2/base-lang/pass/base-lang-test.sh: New test.
	* gm2/base-lang/pass/globalproctype.def: New test.
	* gm2/base-lang/pass/globalproctype.mod: New test.
	* gm2/base-lang/pass/globalvar.def: New test.
	* gm2/base-lang/pass/globalvar.mod: New test.
	* gm2/base-lang/pass/globalvarassign.def: New test.
	* gm2/base-lang/pass/globalvarassign.mod: New test.
	* gm2/base-lang/pass/localproctype.def: New test.
	* gm2/base-lang/pass/localproctype.mod: New test.
	* gm2/base-lang/pass/localvar.def: New test.
	* gm2/base-lang/pass/localvar.mod: New test.
	* gm2/base-lang/pass/localvarassign.def: New test.
	* gm2/base-lang/pass/localvarassign.mod: New test.
	* gm2/base-lang/pass/opaquefield.def: New test.
	* gm2/base-lang/pass/opaquefield.mod: New test.
	* gm2/base-lang/pass/opaquenew.def: New test.
	* gm2/base-lang/pass/opaquenew.mod: New test.
	* gm2/base-lang/pass/opaqueparam.def: New test.
	* gm2/base-lang/pass/opaqueparam.mod: New test.
	* gm2/base-lang/pass/opaquestr.def: New test.
	* gm2/base-lang/pass/opaqueuse.def: New test.
	* gm2/base-lang/pass/opaqueuse.mod: New test.
	* gm2/base-lang/pass/opaqueusestr.def: New test.
	* gm2/base-lang/pass/opaqueusestr.mod: New test.
	* gm2/base-lang/pass/opaquevariant.def: New test.
	* gm2/base-lang/pass/opaquevariant.mod: New test.
	* gm2/base-lang/pass/opaquevarparam.def: New test.
	* gm2/base-lang/pass/opaquevarparam.mod: New test.
	* gm2/base-lang/pass/simplelist.def: New test.
	* gm2/base-lang/pass/simplelist.mod: New test.
	* gm2/base-lang/pass/simplelistiter.def: New test.
	* gm2/base-lang/pass/simplelistiter.mod: New test.
	* gm2/base-lang/pass/simpleopaque.def: New test.
	* gm2/base-lang/pass/simpleopaque.mod: New test.
	* gm2/base-lang/pass/straddress.def: New test.
	* gm2/base-lang/pass/straddress.mod: New test.
	* gm2/base-lang/pass/straddressexport.def: New test.
	* gm2/base-lang/pass/straddressexport.mod: New test.
	* gm2/base-lang/pass/unboundedarray.def: New test.
	* gm2/base-lang/pass/unboundedarray.mod: New test.

(cherry picked from commit a0004feb87)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 16:05:27 +00:00
Gaius Mulley 53b0e42ac4 [PATCH] modula2: Fix typos, grammar, and a link
gcc:
	* doc/gm2.texi (Documentation): Fix typos, grammar, and a link.
(cherry picked from commit ec0865623f)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 11:39:26 +00:00
Gaius Mulley 6bae5e6fef [PATCH] modula2: Simplify REAL/LONGREAL/SHORTREAL node creation.
This patch simplifies the real type build functions by using
the default float_type_node, double_type_node rather than create
new nodes.  It also uses the default GCC long_double_type_node
or float128_type_nodes for longreal.

gcc/m2/ChangeLog:

	* gm2-gcc/m2type.cc (build_m2_short_real_node): Rewrite
	to use the default float_type_node.
	(build_m2_real_node): Rewrite to use the default
	double_type_node.
	(build_m2_long_real_node): Rewrite to use the default
	long_double_type_node or float128_type_node.

Co-Authored-By: Kewen.Lin  <linkw@linux.ibm.com>
(cherry picked from commit 30ce9dfcc6)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-22 10:32:05 +00:00
Lulu Cheng 8cf47ce60c LoongArch: Fix clerical errors in lasx_xvreplgr2vr_* and lsx_vreplgr2vr_*.
[x]vldi.{b/h/w/d} is not implemented in LoongArch.
Use the macro [x]vrepli.{b/h/w/d} to replace.

gcc/ChangeLog:

	* config/loongarch/lasx.md: Fixed.
	* config/loongarch/lsx.md: Fixed.

(cherry picked from commit f0cb64fb3f)
2024-11-22 10:02:51 +08:00
Xi Ruoyao bd82a141ee LoongArch: Make __builtin_lsx_vorn_v and __builtin_lasx_xvorn_v arguments and return values unsigned
Align them with other vector bitwise builtins.

This may break programs directly invoking __builtin_lsx_vorn_v or
__builtin_lasx_xvorn_v, but doing so is not supported (as builtins are
not documented, only intrinsics are documented and users should use them
instead).

gcc/ChangeLog:

	* config/loongarch/loongarch-builtins.cc (vorn_v, xvorn_v): Use
	unsigned vector modes.
	* config/loongarch/lsxintrin.h (__lsx_vorn_v): Cast arguments to
	v16u8.
	* config/loongarch/lasxintrin.h (__lasx_xvorn_v): Cast arguments
	to v32u8.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lsx/lsx-builtin.c (__lsx_vorn_v):
	Change arguments and return value to v16u8.
	* gcc.target/loongarch/vector/lasx/lasx-builtin.c
	(__lasx_xvorn_v): Change arguments and return value to v32u8.

(cherry picked from commit ae7e25662f)
2024-11-22 10:01:47 +08:00
GCC Administrator f39a960967 Daily bump. 2024-11-22 00:25:21 +00:00
GCC Administrator 7f0f9f83a3 Daily bump. 2024-11-21 00:26:12 +00:00
David Malcolm 41344d6077 SARIF output: fix schema URL [§3.13.3, PR116603]
We were using
  https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json
as the URL for the SARIF 2.1 schema, but this is now a 404.

Update it to the URL listed in the spec (§3.13.3 "$schema property"),
which is:
  https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json
and update the copy in
  gcc/testsuite/lib/sarif-schema-2.1.0.json
used by the "verify-sarif-file" DejaGnu directive to the version found at
that latter URL; the sha256 sum changes
from: 2b19d2358baef0251d7d24e208d05ffabf1b2a3ab5e1b3a816066fc57fd4a7e8
  to: c3b4bb2d6093897483348925aaa73af03b3e3f4bd4ca38cef26dcb4212a2682e

Doing so added a validation error on
  c-c++-common/diagnostic-format-sarif-file-pr111700.c
for which we emit this textual output:
  this-file-does-not-exist.c: warning: #warning message [-Wcpp]
with no line number, and these invalid SARIF regions within the
physical location of the warning:
  "region": {"startColumn": 2,
             "endColumn": 9},
  "contextRegion": {}

This is due to this directive:
  # 0 "this-file-does-not-exist.c"
with line number 0.

The patch fixes this by not creating regions that have startLine <= 0.

gcc/ChangeLog:
	PR other/116603
	* diagnostic-format-sarif.cc (SARIF_SCHEMA): Update URL.
	(sarif_builder::maybe_make_region_object): Don't create regions
	with startLine <= 0.
	(sarif_builder::maybe_make_region_object_for_context): Likewise.

gcc/testsuite/ChangeLog:
	PR other/116603
	* lib/sarif-schema-2.1.0.json: Update with copy downloaded from
	https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 38dc2c6471)
2024-11-20 10:00:04 -05:00
David Malcolm 0f26f4f769 analyzer: handle <error.h> at -O0 [PR115724]
At -O0, glibc's:

__extern_always_inline void
error (int __status, int __errnum, const char *__format, ...)
{
  if (__builtin_constant_p (__status) && __status != 0)
    __error_noreturn (__status, __errnum, __format, __builtin_va_arg_pack ());
  else
    __error_alias (__status, __errnum, __format, __builtin_va_arg_pack ());
}

becomes just:

__extern_always_inline void
error (int __status, int __errnum, const char *__format, ...)
{
  if (0)
    __error_noreturn (__status, __errnum, __format, __builtin_va_arg_pack ());
  else
    __error_alias (__status, __errnum, __format, __builtin_va_arg_pack ());
}

and thus calls to "error" are calls to "__error_alias" by the
time -fanalyzer "sees" them.

Handle them with more special-casing in kf.cc.

gcc/analyzer/ChangeLog:
	PR analyzer/115724
	* kf.cc (register_known_functions): Add __error_alias and
	__error_at_line_alias.

gcc/testsuite/ChangeLog:
	PR analyzer/115724
	* c-c++-common/analyzer/error-pr115724.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit a6fdb1a2a2)
2024-11-20 10:00:04 -05:00
David Malcolm d5d62a3849 testsuite: use check-jsonschema for validating .sarif files [PR109360]
As reported here:
  https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655434.html
the schema validation I added for generated .sarif files in
r15-1541-ga84fe222029ff2 used the "jsonschema" command line tool, which
has been deprecated by more recent versions of the Python 3 "jsonschema"
module.

This patch updates the validation to use the more recent
"check-jsonschema" command line tool, from the Python 3 "check-jsonschema"
module, fixing the testsuite FAILs due to the deprecation message.

As an added bonus, the output on validation failures is *much* nicer, e.g.
if I undo r15-1540-g9f4fdc3acebcf6, the error messages begin like this:
verify-sarif-file: res: Schema validation errors were encountered.
  diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].locations[0].physicalLocation.region.startColumn: 0 is less than the minimum of 1
  diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[0].physicalLocation.region.startColumn: 0 is less than the minimum of 1
  diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[1].physicalLocation.region.startColumn: 0 is less than the minimum of 1
  diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[2].physicalLocation.region.startColumn: 0 is less than the minimum of 1
child process exited abnormally
FAIL: c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-1.c  -Wc++-compat   (test .sarif output against SARIF schema)

Tested with Python 3.8 with check_jsonschema 0.28.6

gcc/ChangeLog:
	PR testsuite/109360
	* doc/install.texi (Python3 modules): Update SARIF validation
	requirement to use check-jsonschema rather than jsonschema.

gcc/testsuite/ChangeLog:
	PR testsuite/109360
	* lib/scansarif.exp (verify-sarif-file): Use check-jsonschema
	rather than jsonschema, updating the invocation accordingly.
	* lib/target-supports.exp (check_effective_target_jsonschema): Convert
	to...
	(check_effective_target_check_jsonschema): ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 1796790710)
2024-11-20 10:00:03 -05:00
David Malcolm bf01dcd117 testsuite: check that generated .sarif files validate against the SARIF schema [PR109360]
This patch extends the dg directive verify-sarif-file so that if
the "jsonschema" tool is available, it will be used to validate the
generated .sarif file.

Tested with jsonschema 3.2 with Python 3.8

gcc/ChangeLog:
	PR testsuite/109360
	* doc/install.texi: Mention optional usage of "jsonschema" tool.

gcc/testsuite/ChangeLog:
	PR testsuite/109360
	* lib/sarif-schema-2.1.0.json: New file, downloaded from
	https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/schemas/sarif-schema-2.1.0.json
	Licensing information can be seen at
	https://github.com/oasis-tcs/sarif-spec/issues/583
	which states "They are free to incorporate it into their
	implementation. No need for special permission or paperwork from
	OASIS."
	* lib/scansarif.exp (verify-sarif-file): If "jsonschema" is
	available, use it to verify that the .sarif file complies with the
	SARIF schema.
	* lib/target-supports.exp (check_effective_target_jsonschema):
	New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit a84fe22202)
2024-11-20 10:00:03 -05:00
David Malcolm 07485ccd31 diagnostics: fixes to SARIF output [PR109360]
When adding validation of .sarif files against the schema
(PR testsuite/109360) I discovered various issues where we were
generating invalid .sarif files.

Specifically, in
  c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-1.c
the relatedLocations for the "note" diagnostics were missing column
numbers, leading to validation failure due to non-unique elements,
such as multiple:
	"message": {"text": "invalid UTF-8 character <bf>"}},
on line 25 with no column information.

Root cause is that for some diagnostics in libcpp we have a location_t
representing the line as a whole, setting a column_override on the
rich_location (since the line hasn't been fully read yet).  We were
handling this column override for plain text output, but not for .sarif
output.

Similarly, in diagnostic-format-sarif-file-pr111700.c there is a warning
emitted on "line 0" of the file, whereas SARIF requires line numbers to
be positive.

We also use column == 0 internally to mean "the line as a whole",
whereas SARIF required column numbers to be positive.

This patch fixes these various issues.

gcc/ChangeLog:
	PR testsuite/109360
	* diagnostic-format-sarif.cc
	(sarif_builder::make_location_object): Pass any column override
	from rich_loc to maybe_make_physical_location_object.
	(sarif_builder::maybe_make_physical_location_object): Add
	"column_override" param and pass it to maybe_make_region_object.
	(sarif_builder::maybe_make_region_object): Add "column_override"
	param and use it when the location has 0 for a column.  Don't
	add "startLine", "startColumn", "endLine", or "endColumn" if
	the values aren't positive.
	(sarif_builder::maybe_make_region_object_for_context): Don't
	add "startLine" or "endLine" if the values aren't positive.

libcpp/ChangeLog:
	PR testsuite/109360
	* include/rich-location.h (rich_location::get_column_override):
	New accessor.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 9f4fdc3ace)
2024-11-20 10:00:02 -05:00
David Malcolm 54504e8c70 regenerate-opt-urls.py: fix transposed values for "vax" and "v850"
gcc/ChangeLog:
	* config/v850/v850.opt.urls: Regenerate, with fix.
	* config/vax/vax.opt.urls: Likewise.
	* regenerate-opt-urls.py (TARGET_SPECIFIC_PAGES): Fix transposed
	values for "vax" and "v850".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 7cc529fe51)
2024-11-20 10:00:02 -05:00
David Malcolm 156051d083 testsuite: fix analyzer C++ failures on Solaris [PR111475]
As part of PR analyzer/96395, these patches moved testcases from
gcc.dg/analyzer to c-c++-common/analyzer:
- r14-3503-g55f6a7d949abc7
- r14-3823-g50b5199cff6908
- r14-6564-gae034b9106fbdd

Unfortunately this led to numerous g++ testsuite failures on Solaris,
tracked as PR analyzer/111475.

Almost all of the failures are due to standard library differences where
including a C standard library on C++ e.g. <stdlib.h> leads to the plain
symbols referencing the symbols "std::" via a "using" declaration,
whereas I had written the code expecting them to use symbols in the root
namespace.

The analyzer has special-case handling of many functions by name.
This patch generalizes such handling to also match against functions
in "std::" for all of the cases I found in the testsuite (via manual
inspection of the preprocessed test cases against Solaris headers).
This fixes cases where the analyzer was failing to "know about" the
behavior of such functions.

Other such failures are due to "std::" prefixes appearing in names of
functions in the output, leading to mismatches against expected output.
The patch adds regexes to some cases, and moves some other cases back
from c-c++-common to gcc.dg where the dg-multiline syntax isn't
expressive enough.

Various "fd-*.c" failures relate to Solaris's socket-handling functions
not being marked with "noexcept", where due to PR analyzer/97111 we
mishandle the exception-handling edges in the CFG, leading to leak
false positives.  The patch works around this by adding -fno-exceptions
to these cases, pending a proper fix for PR analyzer/97111.

gcc/analyzer/ChangeLog:
	PR analyzer/111475
	* analyzer.cc (is_special_named_call_p): Add "look_in_std" param.
	(is_std_function_p): Make non-static.
	* analyzer.h (is_special_named_call_p): Add optional "look_in_std"
	param.
	(is_std_function_p): New decl.
	* engine.cc (stmt_requires_new_enode_p): Look for both "signal"
	and "std::signal".
	* kf.cc (register_known_functions): Add various "std::" copies
	of the known functions.
	* known-function-manager.cc
	(known_function_manager::~known_function_manager): Clean up
	m_std_ns_map_id_to_kf.
	(known_function_manager::add_std_ns): New.
	(known_function_manager::get_match): Also look for known "std::"
	functions.
	(known_function_manager::get_by_identifier_in_std_ns): New.
	* known-function-manager.h
	(known_function_manager::add_std_ns): New decl.
	(known_function_manager::get_by_identifier_in_std_ns): New decl.
	(known_function_manager::m_std_ns_map_id_to_kf): New field.
	* sm-file.cc (register_known_file_functions): Add various "std::"
	copies of the known functions.
	* sm-malloc.cc (malloc_state_machine::on_stmt): Handle
	"std::realloc".
	* sm-signal.cc (signal_unsafe_p): Consider "std::" copies of the
	functions as also being async-signal-unsafe.
	(signal_state_machine::on_stmt): Consider "std::signal".

gcc/testsuite/ChangeLog:
	PR analyzer/111475
	* c-c++-common/analyzer/fd-glibc-byte-stream-socket.c: Add
	-fno-exceptions for now.
	* c-c++-common/analyzer/fd-manpage-getaddrinfo-client.c: Likewise.
	* c-c++-common/analyzer/fd-mappage-getaddrinfo-server.c: Rename to...
	* c-c++-common/analyzer/fd-manpage-getaddrinfo-server.c: ...this, and
	add -fno-exceptions for now.
	* c-c++-common/analyzer/fd-socket-meaning.c: Add -fno-exceptions
	for now.
	* c-c++-common/analyzer/fd-symbolic-socket.c: Likewise.
	* c-c++-common/analyzer/flexible-array-member-1.c: Use regexp to
	handle C vs C++ differences in spelling of function name, which
	could have a "std::" prefix on some targets.
	* c-c++-common/analyzer/pr106539.c: Likewise.
	* c-c++-common/analyzer/malloc-ipa-8-unchecked.c: Move back to...
	* gcc.dg/analyzer/malloc-ipa-8-unchecked.c: ...here, dropping
	attempt to generalize output for C vs C++.
	* c-c++-common/analyzer/signal-4a.c: Move back to...
	* gcc.dg/analyzer/signal-4a.c: ...here, dropping attempt to
	generalize output for C vs C++.
	* c-c++-common/analyzer/signal-4b.c: Move back to...
	* gcc.dg/analyzer/signal-4b.c: ...here, dropping attempt to
	generalize output for C vs C++.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 5219414f3c)
2024-11-20 10:00:02 -05:00
Gaius Mulley 0e3e2cc03e [PATCH] PR modula2/115276 bugfix libgm2 wraptime.InitTM returns NIL
This patch fixes libgm2/libm2iso/wraptime.cc:InitTM so that
it does not always return NULL.  The incorrect autoconf macro
was used (inside InitTM) and the function short circuited
to return NULL.  The fix is to use HAVE_SYS_TIME_H and use
AC_HEADER_TIME in libgm2/configure.ac.

libgm2/ChangeLog:

	PR modula2/115276
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use AC_HEADER_TIME.
	* libm2iso/wraptime.cc (InitTM): Check HAVE_SYS_TIME_H
	before using struct tm to obtain the size.

gcc/testsuite/ChangeLog:

	PR modula2/115276
	* gm2/isolib/run/pass/testinittm.mod: New test.

(cherry picked from commit d1a1f7e9f0)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-20 09:22:53 +00:00
Gaius Mulley 83c51f98e7 [PATCH] modula2: simplify xref usage in documentation, remove external ref to gm2.
This patch simplifies all the xref usage for gm2 nodes in the
modula-2 documentation.

gcc/ChangeLog:

	* doc/gm2.texi: Replace all occurrences of xref
	{foo, , , gm2} with xref {foo}.

(cherry picked from commit a209f219b8)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-20 08:15:45 +00:00
Gaius Mulley a6ee740ff3 [PATCH] modula2: fix xref fourth parameter in documentation, change from gm2 to m2
This patch corrects the gm2.texi xref for the modula-2 documentation.

gcc/ChangeLog:

	* doc/gm2.texi: Replace all occurrences of xref {, , , gm2}
	with xref {, , , m2}.

(cherry picked from commit 5833e5b8ef)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-20 08:14:10 +00:00
GCC Administrator 84198cba68 Daily bump. 2024-11-20 00:23:31 +00:00
Gaius Mulley 9a23dff4f8 [PATCH] modula2: use groups in the type resolver of the bootstrap tool mc
This patch introduces groups to maintain the lists used when resolving
types in the bootstrap tool mc.  The groups and type resolver are very
similar to that used in cc1gm2.  Specifically the resolver uses the group
to detect any change to any element in any list within a group.  This is
much cleaner and safer than the previous list length comparisons.

gcc/m2/ChangeLog:

	* Make-lang.in (MC_EXTENDED_OPAQUE): New definition.
	* mc-boot/GDynamicStrings.cc: Rebuild.
	* mc-boot/GDynamicStrings.h: Rebuild.
	* mc-boot/Galists.cc: Rebuild.
	* mc-boot/Galists.h: Rebuild.
	* mc-boot/Gdecl.cc: Rebuild.
	* mc/alists.def (equalList): New procedure.
	* mc/alists.mod (equalList): New procedure implementation.
	* mc/decl.mod (group): New type.
	(freeGroup): New variable.
	(globalGroup): Ditto.
	(todoQ): Remove declaration and prefix all occurances with globalGroup^.
	(partialQ): Ditto.
	(doneQ): Ditto.
	(newGroup): New procedure.
	(initGroup): Ditto.
	(killGroup): Ditto.
	(dupGroup): Ditto.
	(equalGroup): Ditto.
	(topologicallyOut): Rewrite.

(cherry picked from commit 20e6f36771)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-20 00:17:23 +00:00
Gaius Mulley b1d2c143e8 [PATCH] modula2: Pass --destdir for dir index during install of m2.info.
This patch adds DESTDIR to the infodir when installing m2.info.

gcc/m2/ChangeLog

	* Make-lang.in (m2.install-info): Pass --destdir for dir index.

(cherry picked from commit 232a86f964)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-19 22:28:04 +00:00
Gaius Mulley aefb471444 [PATCH] PR modula2/115164 initial test code highlighting the problem
This patch includes some trivial testcode which highlights
PR 115164.  Expect future test code to perform runtime checks
for a series of trailing zeros.

gcc/testsuite/ChangeLog:

	PR modula2/115164
	* gm2/isolib/run/pass/testlowread.mod: New test.
	* gm2/isolib/run/pass/testwritereal.mod: New test.

(cherry picked from commit d642b66a29)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-19 19:33:18 +00:00
Gaius Mulley 399065ea44 [PATCH] PR modula2/115057 TextIO.ReadRestLine raises an exception when buffer is exceeded
TextIO.ReadRestLine will raise an "attempting to read beyond end of file"
exception if the buffer is exceeded.  This bug is caused by the
TextIO.ReadRestLine calling IOChan.Skip without a preceeding IOChan.Look.
The Look procedure will update the status result whereas
Skip always sets read result to allRight.

gcc/m2/ChangeLog:

	PR modula2/115057
	* gm2-libs-iso/TextIO.mod (ReadRestLine): Use ReadChar to
	skip unwanted characters as this calls IOChan.Look and updates
	the cid result status.  A Skip without a Look does not update
	the status.  Skip always sets read result to allRight.
	* gm2-libs-iso/TextUtil.def (SkipSpaces): Improve comments.
	(CharAvailable): Improve comments.
	* gm2-libs-iso/TextUtil.mod (SkipSpaces): Improve comments.
	(CharAvailable): Improve comments.

gcc/testsuite/ChangeLog:

	PR modula2/115057
	* gm2/isolib/run/pass/testrestline.mod: New test.
	* gm2/isolib/run/pass/testrestline2.mod: New test.
	* gm2/isolib/run/pass/testrestline3.mod: New test.

(cherry picked from commit 680af0e1e9)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-19 18:30:10 +00:00
Gaius Mulley 112d184348 [PATCH] PR modula2/115003 exporting a symbol to outer scope with a name clash causes ICE
An ICE will occur if an unknown symbol is exported and causes a name
clash.  The error mechanism attempts to find the scope of an unknown
symbol.  This patch adds a missing case clause to GetScope and returns
NulSym if the scope is an unknown symbol.

gcc/m2/ChangeLog:

	PR modula2/115003
	* gm2-compiler/SymbolTable.mod (GetScope): Add UndefinedSym
	case clause and return NulSym.

(cherry picked from commit bc5afdf14c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-11-19 15:32:02 +00:00
GCC Administrator 4d27dd15c4 Daily bump. 2024-11-19 00:22:54 +00:00
Uros Bizjak fee4616138 i386: Enable *rsqrtsf2_sse without TARGET_SSE_MATH [PR117357]
__builtin_ia32_rsqrtsf2 expander generates UNSPEC_RSQRT insn pattern
also when TARGET_SSE_MATH is not set.  Enable *rsqrtsf2_sse without
TARGET_SSE_MATH to avoid ICE with unrecognizable insn.

	PR target/117357

gcc/ChangeLog:

	* config/i386/i386.md (*rsqrtsf2_sse):
	Also enable for !TARGET_SSE_MATH.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 344356f781)
2024-11-18 22:43:10 +01:00
Georg-Johann Lay 3cb7ac6f02 AVR: target/117659 - Fix wrong code for u24 << 16.
gcc/
	PR target/117659
	* config/avr/avr.cc (avr_out_ashlpsi3) [case 16]: Use %A1 as
	input (instead of bogus %A0).

(cherry picked from commit bba27015f2)
2024-11-18 18:20:22 +01:00
Andre Vieira b51b45eaf7 fold-const: Fix BIT_INSERT_EXPR folding for BYTES_BIG_ENDIAN [PR116997]
Fix constant folding of BIT_INSER_EXPR for BYTES_BIG_ENDIAN targets.

gcc/ChangeLog:

	PR middle-end/116997
	* fold-const.cc (fold_ternary_loc): Fix BIT_INSERT_EXPR constant folding
	for BYTES_BIG_ENDIAN targets.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/pr116997.c: New test.

Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 2e30e90a0c)
2024-11-18 16:56:42 +00:00
Hu, Lin1 8b4bb54e6c i386: Zero extend 32-bit address to 64-bit with option -mx32 -maddress-mode=long. [PR 117418]
-maddress-mode=long let Pmode = DI_mode, so zero extend 32-bit address to
64-bit and uses a 64-bit register as a pointer for avoid raise an ICE.

gcc/ChangeLog:

	PR target/117418
	* config/i386/i386-expand.cc (ix86_expand_builtin): Convert
	pointer's mode according to Pmode.

gcc/testsuite/ChangeLog:

	PR target/117418
	* gcc.target/i386/pr117418-1.c: New test.

(cherry picked from commit 2272cd2508)
2024-11-18 09:46:47 +08:00
GCC Administrator a6699802d5 Daily bump. 2024-11-18 00:25:08 +00:00
GCC Administrator fe0da4dce7 Daily bump. 2024-11-17 00:32:22 +00:00
Georg-Johann Lay 74bfca7360 AVR: target/117500 - Use output_operand_lossage in avr_print_operand.
PR target/117500
gcc/
	* config/avr/avr.cc (avr_print_operand) [code = 'i']: Use
	output_operand_lossage on bad operands instead of fatal_insn.

(cherry picked from commit 02d7370966)
2024-11-16 20:05:47 +01:00
GCC Administrator 03af3c1ad6 Daily bump. 2024-11-16 00:23:28 +00:00
John David Anglin 878b335485 hppa: Fix typos in 32-bit SFmode peephole2 patterns
2024-11-15  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	PR target/117564
	* config/pa/pa.md: Fix typos in 32-bit SFmode peephole2 patterns.
2024-11-15 11:07:22 -05:00
GCC Administrator d9752ab92b Daily bump. 2024-11-15 00:23:15 +00:00
GCC Administrator 066d8b8c3b Daily bump. 2024-11-14 17:24:28 +00:00
Paul Thomas 2b93936a12 Fortran: Fix associate_69.f90 that fails on some platforms [PR115700]
2024-11-03  Paul Thomas  <pault@gcc.gnu.org>

gcc/testsuite/
	PR fortran/115700
	* gfortran.dg/associate_69.f90: Remove the test that produces a
	variable string length because the optimized count depends on
	the platform. This is tested in associate_70.f90.

(cherry picked from commit 4ed02814c2)
2024-11-14 11:09:02 +00:00
Paul Thomas 58708cc6a5 Fortran: Fix problems with substring selectors in ASSOCIATE [PR115700]
2024-11-01  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/115700
	* resolve.cc (resolve_assoc_var): Extract a substring reference
	with missing as well as non-constant start or end.

gcc/testsuite/
	PR fortran/115700
	* gfortran.dg/associate_69.f90: Activate commented out tests.
	* gfortran.dg/associate_70.f90: Test correct functioning of
	references in associate_69.f90 tests.

(cherry picked from commit 7f93910a8b)
2024-11-14 11:09:02 +00:00
Paul Thomas caa2b2038d Fortran: Fix problem with substring selectors in ASSOCIATE [PR115700]
2024-10-31  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/115700
	* resolve.cc (resolve_variable): The typespec of an expression,
	which is not a substring, can be shared with a deferred length
	associate name.
	(resolve_assoc_var): Extract a substring reference with non-
	constant start or end. Use it to flag up the need for array
	associate name to be a pointer.
	(resolve_block_construct): Change comment from past to future
	tense.

gcc/testsuite/
	PR fortran/115700
	* gfortran.dg/associate_70.f90: New test.

(cherry picked from commit 159fb20323)
2024-11-14 11:09:01 +00:00
John David Anglin 39b0fb9bbc hppa: Remove inner fix:SF/DF from fixed-point patterns
2024-11-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	PR target/117525
	* config/pa/pa.md (fix_truncsfsi2): Remove inner `fix:SF`.
	(fix_truncdfsi2, fix_truncsfdi2, fix_truncdfdi2,
	fixuns_truncsfsi2, fixuns_truncdfsi2, fixuns_truncsfdi2,
	fixuns_truncdfdi2): Likewise.
2024-11-13 09:42:30 -05:00
GCC Administrator 164768b742 Daily bump. 2024-11-13 00:23:07 +00:00
John David Anglin 2a41d31fa8 hppa: Fix decrement_and_branch_until_zero constraint
The third alternative for argument 4 needs to be an early clobber
constraint.  Noticed testing LRA.

2024-11-12  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.md (decrement_and_branch_until_zero): Fix
	constraint.
2024-11-12 14:27:36 -05:00
Eric Botcazou 4d1e1f947d ada: Fix spurious error on iterated component association with large index type
This is only for the Ada 2022 form of the iterated component association.

gcc/ada/ChangeLog:

	PR ada/117328
	* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use a type sized
	from the index type to compute the length.  Simplify and remove
	useless calls to New_Copy_Tree for this computation.
2024-11-12 18:50:19 +01:00
Eric Botcazou 89f21c18af ada: Fix bogus error for delta aggregate as expression function
The compiler correctly accepts the other forms of aggregates.

gcc/ada/ChangeLog:

	PR ada/113868
	* par-ch6.adb (P_Subprogram) <Scan_Body_Or_Expression_Function>:
	Add delta aggregate alongside the other forms of aggregates.
2024-11-12 18:46:16 +01:00
Jonathan Wakely 061d18d7bd libstdc++: Add parentheses around operand of |
libstdc++-v3/ChangeLog:

	* include/bits/unicode.h (_Utf_iterator::_M_read_utf16): Add
	parentheses.
2024-11-12 15:36:07 +00:00
Andrew Carlotti 6d5f550231 testsuite: Adjust jump threading test expectation
This test started failing on aarch64 after 0cfc9c95 in 2023 ("Phi
analyzer - Initialize with range instead of a tree.").

The only change visible in the pass dumps prior to thread2 is the upper
bounds of some ranges are reduced from +INF to 7, consistent with the
bitamsk information.  After thread2, there are changes in the control
flow, but only affecting edges that are obviously never taken (from
basic blocks 6 through 12).  These are cleaned up in the following pass,
but the final codegen remains different.

There isn't anything obviously wrong with the change in dump output, so
let's just update the test expectations (as has happened previously
here).

gcc/testsuite/ChangeLog:

	PR tree-optimization/112376
	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update expectation.
2024-11-12 15:16:10 +00:00
Jonathan Wakely 17ff72651d libstdc++: Fix typos in iterator increment for std::text_encoding [PR117520]
The intended behaviour for std::text_encoding::aliases_view's iterator
is that it incrementing or decrementing too far sets it to a
value-initialized state, or fails an assertion when those are enabled.
There were typos that used == instead of = which meant that instead of
becoming singular or aborting, an out-of-range increment just did
nothing. This meant erroneous operations were well-defined and didn't
produce any undefined behaviour, but were not diagnosed with assertions
enabled, as had been intended.

This change fixes the bugs and adds more tests to verify the intended
behaviour.

libstdc++-v3/ChangeLog:

	PR libstdc++/117520
	* include/std/text_encoding (aliases_view:_Iterator::operator+=):
	Fix typos that caused == to be used instead of =.
	(aliases_view::_Iterator): Fix friend declaration.
	* testsuite/std/text_encoding/members.cc: Adjust expected
	behaviour of invalid subscript. Add tests for other erroneous
	operations on iterators.
2024-11-12 09:33:51 +00:00
GCC Administrator 4358c5c519 Daily bump. 2024-11-12 00:23:41 +00:00
Jonathan Wakely 2f744df601 libstdc++: Do not define _Insert_base::try_emplace before C++17
This is not a reserved name in C++11 and C++14, so must not be defined.

Also use the appropriate feature test macros for the try_emplace members
of the Debug Mode maps.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Insert_base::try_emplace):
	Do not define for C++11 and C++14.
	* include/debug/map.h (try_emplace): Use feature test macro.
	* include/debug/unordered_map (try_emplace): Likewise.
	* testsuite/17_intro/names.cc: Define try_emplace before C++17.

(cherry picked from commit b66a57c0ad)
2024-11-11 18:45:52 +00:00
Haochen Jiang 4380d6f8ac i386: Add new model number for Arrow Lake
gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_intel_cpu): Add new model
	number for Arrow Lake.
2024-11-11 10:52:33 +08:00
GCC Administrator 75dbfb7e0a Daily bump. 2024-11-11 00:21:46 +00:00
GCC Administrator c273df1c35 Daily bump. 2024-11-10 00:22:20 +00:00
GCC Administrator bb21d80e3d Daily bump. 2024-11-09 16:07:50 +00:00
Torbjörn SVENSSON e277e1082a arm: Fix ICE on arm_mve.h pragma without MVE types [PR117408]
Starting with r14-435-g00d97bf3b5a, doing `#pragma arm "arm_mve.h"
false` or `#pragma arm "arm_mve.h" true` without first doing
`#pragma arm "arm_mve_types.h"` causes GCC to ICE.

gcc/ChangeLog:

	PR target/117408
	* config/arm/arm-mve-builtins.cc(handle_arm_mve_h): Detect if MVE
	types is missing and if so, return error.

gcc/testsuite/ChangeLog:

	PR target/117408
	* gcc.target/arm/mve/pr117408-1.c: New test.
	* gcc.target/arm/mve/pr117408-2.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 8b04f60f88)
2024-11-09 13:35:55 +01:00
John David Anglin 3bc7af0e2b hppa: Don't use '%' operator in base14_operand
Division is slow on hppa and mode sizes are powers of 2.  So, we
can use '&' operator to check displacement alignment.

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

gcc/ChangeLog:

	* config/pa/predicates.md (base14_operand): Use '&' operator
	instead of '%' to check displacement alignment.
2024-11-08 16:57:28 -05:00
John David Anglin 4b30972e51 hppa: Fix handling of secondary reloads involving a SUBREG
This is fairly subtle.

When handling spills for SUBREG arguments in pa_emit_move_sequence,
alter_subreg may be called.  It in turn calls adjust_address_1 and
change_address_1.  change_address_1 calls pa_legitimate_address_p
to validate the new spill address.  change_address_1 generates an
internal compiler error if the address is not valid.  We need to
allow 14-bit displacements for all modes when reload_in_progress
is true and strict is false to prevent the internal compiler error.

SUBREGs are only used with the general registers, so the spill
should result in an integer access.  14-bit displacements are okay
for integer loads and stores but not for floating-point loads and
stores.

Potentially, the change could break the handling of spills for the
floating point-registers but I believe these are handled separately
in pa_emit_move_sequence.

This change fixes the build of symmetrica-3.0.1+ds.

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

gcc/ChangeLog:

	PR target/117443
	* config/pa/pa.cc (pa_legitimate_address_p): Allow any
	14-bit displacement when reload is in progress and strict
	is false.
2024-11-08 16:36:03 -05:00
Tamar Christina 05d54bcdc5 AArch64: backport Neoverse and Cortex CPU definitions
This is a conservative backport of a few core definitions backporting only the
core definitions and mapping them to their closest cost model that exist on the
branches.

gcc/ChangeLog:

	* config/aarch64/aarch64-cores.def (cortex-a725, cortex-x925,
	neoverse-n3, neoverse-v3, neoverse-v3ae): New.
	* config/aarch64/aarch64-tune.md: Regenerate
	* doc/invoke.texi: Document them.
2024-11-08 18:12:32 +00:00
Richard Sandiford 998d05a7b6 aarch64: Fix gcc.target/aarch64/sme2/acle-asm/bfmlslb_f32.c
I missed a search-and-replace on this test, meaning that it was
duplicating bfmlalb_f32.c.

gcc/testsuite/
	* gcc.target/aarch64/sme2/acle-asm/bfmlslb_f32.c: Replace bfmla*
	with bfmls*

(cherry picked from commit 156f536d54)
2024-11-08 14:07:47 +00:00
Richard Sandiford 8681e1ed81 aarch64: Make PSEL dependent on SME rather than SME2
The svpsel_lane intrinsics were wrongly classified as SME2+ only,
rather than as base SME intrinsics.  They should always be available
in streaming mode.

gcc/
	* config/aarch64/aarch64-sve2.md (@aarch64_sve_psel<BHSD_BITS>)
	(*aarch64_sve_psel<BHSD_BITS>_plus): Require TARGET_STREAMING
	rather than TARGET_STREAMING_SME2.

gcc/testsuite/
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_b16.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_b16.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_b32.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_b32.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_b64.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_b64.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_b8.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_b8.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_c16.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_c16.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_c32.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_c32.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_c64.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_c64.c: ...here.
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_c8.c: Move to...
	* gcc.target/aarch64/sme/acle-asm/psel_lane_c8.c: ...here.

(cherry picked from commit afd3887262)
2024-11-08 14:07:47 +00:00
Richard Sandiford d228af5cbc aarch64: Restrict FCLAMP to SME2
There are two sets of patterns for FCLAMP: one set for single registers
and one set for multiple registers.  The multiple-register set was
correctly gated on SME2, but the single-register set only required SME.
This doesn't matter for ACLE usage, since the intrinsic definitions
are correctly gated.  But it does matter for automatic generation of
FCLAMP from separate minimum and maximum operations (either ACLE
intrinsics or autovectorised code).

gcc/
	* config/aarch64/aarch64-sve2.md (@aarch64_sve_fclamp<mode>)
	(*aarch64_sve_fclamp<mode>_x): Require TARGET_STREAMING_SME2
	rather than TARGET_STREAMING_SME.

gcc/testsuite/
	* gcc.target/aarch64/sme/clamp_3.c: Force sme2
	* gcc.target/aarch64/sme/clamp_4.c: Likewise.
	* gcc.target/aarch64/sme/clamp_5.c: New test.

(cherry picked from commit f5962839d6)
2024-11-08 14:07:46 +00:00
Richard Sandiford e49c265c59 aarch64: Fix folding of degenerate svwhilele case [PR117045]
The svwhilele folder mishandled the degenerate case in which
the second argument is the maximum integer.  In that case,
the result is all-true regardless of the first parameter:

  If the second scalar operand is equal to the maximum signed integer
  value then a condition which includes an equality test can never fail
  and the result will be an all-true predicate.

This is because the conceptual "increment the first operand
by 1 after each element" is done modulo the range of the operand.
The GCC code was instead treating it as infinite precision.
whilele_5.c even had a test for the incorrect behaviour.

The easiest fix seemed to be to handle that case specially before
doing constant folding.  This also copes with variable first operands.

gcc/
	PR target/116999
	PR target/117045
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svwhilelx_impl::fold): Check for WHILELTs of the minimum value
	and WHILELEs of the maximum value.  Fold them to all-false and
	all-true respectively.

gcc/testsuite/
	PR target/116999
	PR target/117045
	* gcc.target/aarch64/sve/acle/general/whilele_5.c: Fix bogus
	expected result.
	* gcc.target/aarch64/sve/acle/general/whilele_11.c: New test.
	* gcc.target/aarch64/sve/acle/general/whilele_12.c: Likewise.

(cherry picked from commit 50e7c51b0a)
2024-11-08 14:07:46 +00:00
Richard Sandiford ffe00a0117 aarch64: Fix SVE ACLE gimple folds for C++ LTO [PR116629]
The SVE ACLE code has two ways of handling overloaded functions.
One, used by C, is to define a single dummy function for each unique
overloaded name, with resolve_overloaded_builtin then resolving calls
to real non-overloaded functions.  The other, used by C++, is to
define a separate function for each individual overload.

The builtins harness assigns integer function codes programmatically.
However, LTO requires it to use the same assignment for every
translation unit, regardless of language.  This means that C++ TUs
need to create (unused) slots for the C overloads and that C TUs
need to create (unused) slots for the C++ overloads.

In many ways, it doesn't matter whether the LTO frontend itself
uses the C approach or the C++ approach to defining overloaded
functions, since the LTO frontend never has to resolve source-level
overloading.  However, the C++ approach of defining a separate
function for each overload means that C++ calls never need to
be redirected to a different function.  Calls to an overload
can appear in the LTO dump and survive until expand.  In contrast,
calls to C's dummy overload functions are resolved by the front
end and never survive to LTO (or expand).

Some optimisations work by moving between sibling functions, such as _m
to _x.  If the source function is an overload, the expected destination
function is too.  The LTO frontend needs to define C++ overloads if it
wants to do this optimisation properly for C++.

The PR is about a tree checking failure caused by trying to use a
stubbed-out C++ overload in LTO.  Dealing with that by detecting the
stub (rather than changing which overloads are defined) would have
turned this from an ice-on-valid to a missed optimisation.

In future, it would probably make sense to redirect overloads to
non-overloaded functions during gimple folding, in case that exposes
more CSE opportunities.  But it'd probably be of limited benefit, since
it should be rare for code to mix overloaded and non-overloaded uses of
the same operation.  It also wouldn't be suitable for backports.

gcc/
	PR target/116629
	* config/aarch64/aarch64-sve-builtins.cc
	(function_builder::function_builder): Use direct overloads for LTO.

gcc/testsuite/
	PR target/116629
	* gcc.target/aarch64/sve/acle/general/pr106326_2.c: New test.

(cherry picked from commit fee3adbac0)
2024-11-08 14:07:45 +00:00
Richard Sandiford 66e611619b aarch64: Rename svpext to svpext_lane [PR116371]
When implementing the SME2 ACLE, I somehow missed off the _lane
suffix on svpext.

gcc/
	PR target/116371
	* config/aarch64/aarch64-sve-builtins-sve2.h (svpext): Rename to...
	(svpext_lane): ...this.
	* config/aarch64/aarch64-sve-builtins-sve2.cc (svpext_impl): Rename
	to...
	(svpext_lane_impl): ...this and update instantiation accordingly.
	* config/aarch64/aarch64-sve-builtins-sve2.def (svpext): Rename to...
	(svpext_lane): ...this.

gcc/testsuite/
	PR target/116371
	* gcc.target/aarch64/sme2/acle-asm/pext_c16.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c16_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c32.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c32_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c64.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c64_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c8.c,
	gcc.target/aarch64/sme2/acle-asm/pext_c8_x2.c: Replace with...
	* gcc.target/aarch64/sme2/acle-asm/pext_lane_c16.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c16_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c32.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c32_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c64.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c64_x2.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c8.c,
	gcc.target/aarch64/sme2/acle-asm/pext_lane_c8_x2.c: ...these new tests,
	testing for svpext_lane instead of svpext.

(cherry picked from commit cc2d29e5f4)
2024-11-08 14:07:45 +00:00
Torbjörn SVENSSON 724446556e testsuite: arm: Use check-function-bodies in epilog-1.c test
Update test case for armv8.1-m.main that supports conditional
arithmetic.

armv7-m:
        push    {r4, lr}
        ldr     r4, .L6
        ldr     r4, [r4]
        lsls    r4, r4, #29
        it      mi
        addmi   r2, r2, #1
        bl      bar
        movs    r0, #0
        pop     {r4, pc}

armv8.1-m.main:
        push    {r3, r4, r5, lr}
        ldr     r4, .L5
        ldr     r5, [r4]
        tst     r5, #4
        csinc   r2, r2, r2, eq
        bl      bar
        movs    r0, #0
        pop     {r3, r4, r5, pc}

gcc/testsuite/ChangeLog:

	* gcc.target/arm/epilog-1.c: Use check-function-bodies.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit ec86e87439)
2024-11-08 13:03:28 +01:00
Torbjörn SVENSSON 29284becc5 testsuite: arm: Use effective-target arm_libc_fp_abi for pr68620.c test
This fixes reported regression at
https://linaro.atlassian.net/browse/GNU-1407.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr68620.c: Use effective-target
	arm_libc_fp_abi.
	* lib/target-supports.exp: Define effective-target
	arm_libc_fp_abi.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Richard Earnshaw <rearnsha@arm.com>
(cherry picked from commit dc5d559494)
2024-11-08 13:03:26 +01:00
Torbjörn SVENSSON 82191dec72 testsuite: arm: Allow vst1.32 instruction in pr40457-2.c
When building the test case with neon, the 'vst1.32' instruction is used
instead of 'strd'. Allow both variants to make the test pass.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr40457-2.c: Add vst1.32 as an allowed
	instruction.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 636b8aeacd)
2024-11-08 13:03:24 +01:00
Torbjörn SVENSSON 8cf9b26570 testsuite: arm: Use effective-target for pr84556.cc test
Using "dg-do run" with a selector overrides the default selector set by
vect.exp that picks between "dg-do run" and "dg-do compile" based on the
target's support for simd operations for Arm targets.
The actual selection of default operation is performed in
check_vect_support_and_set_flags.

gcc/testsuite/ChangeLog:

	* g++.dg/vect/pr84556.cc: Change from "dg-do run" with selector
	to instead use dg-require-effective-target with the same
	selector.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 85c3d94480)
2024-11-08 13:03:21 +01:00
Torbjörn SVENSSON ef77193384 testsuite: arm: Use effective-target for nomve_fp_1 test
Test uses MVE, so add effective-target arm_fp requirement.

gcc/testsuite/ChangeLog:

	* g++.target/arm/mve/general-c++/nomve_fp_1.c: Use
	effective-target arm_fp.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit e8886406fa)
2024-11-08 09:59:10 +01:00
Yuta Mukai 6bcd3935f0 aarch64: Add support for FUJITSU-MONAKA (-mcpu=fujitsu-monaka) CPU
This patch adds initial support for FUJITSU-MONAKA CPU.
The cost model will be corrected in the future.

2024-11-07  Yuta Mukai  <mukai.yuta@fujitsu.com>

gcc/ChangeLog:

	* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add fujitsu-monaka.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* config/aarch64/aarch64.cc: Include fujitsu-monaka tuning model.
	* doc/invoke.texi: Document -mcpu=fujitsu-monaka.
	* config/aarch64/tuning_models/fujitsu_monaka.h: New file.
2024-11-07 22:09:39 +00:00
Hu, Lin1 6a0e143a64 i386: Modify regexp of pr117304-1.c
Since the test doesn't care if the hint is correct,
modify the regexp of the hint part to avoid future
changes to the hint that would cause the test to fail.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr117304-1.c: Modify regexp.

(cherry picked from commit 4473cf8409)
2024-11-07 14:42:43 +08:00
Hu, Lin1 05fd99e3d5 i386: Add OPTION_MASK_ISA2_EVEX512 for some AVX512 instructions.
gcc/ChangeLog:

	PR target/117304
	* config/i386/i386-builtin.def: Add OPTION_MASK_ISA2_EVEX512 for some
	AVX512 512-bits instructions.

gcc/testsuite/ChangeLog:

	PR target/117304
	* gcc.target/i386/pr117304-1.c: New test.

(cherry picked from commit 8ac694ae67)
2024-11-07 10:00:04 +08:00
GCC Administrator 9572024dd1 Daily bump. 2024-11-07 00:24:55 +00:00
Tamar Christina 97640e9632 AArch64: rename the SVE2 psel intrinsics to psel_lane [PR116371]
The psel intrinsics. similar to the pext, should be name psel_lane.  This
corrects the naming.

gcc/ChangeLog:

	PR target/116371
	* config/aarch64/aarch64-sve-builtins-sve2.cc (class svpsel_impl):
	Renamed to ...
	(class svpsel_lane_impl): ... This and adjust initialization.
	* config/aarch64/aarch64-sve-builtins-sve2.def (svpsel): Renamed to ...
	(svpsel_lane): ... This.
	* config/aarch64/aarch64-sve-builtins-sve2.h (svpsel): Renamed to
	svpsel_lane.

gcc/testsuite/ChangeLog:

	PR target/116371
	* gcc.target/aarch64/sme2/acle-asm/psel_b16.c,
	gcc.target/aarch64/sme2/acle-asm/psel_b32.c,
	gcc.target/aarch64/sme2/acle-asm/psel_b64.c,
	gcc.target/aarch64/sme2/acle-asm/psel_b8.c,
	gcc.target/aarch64/sme2/acle-asm/psel_c16.c,
	gcc.target/aarch64/sme2/acle-asm/psel_c32.c,
	gcc.target/aarch64/sme2/acle-asm/psel_c64.c,
	gcc.target/aarch64/sme2/acle-asm/psel_c8.c: Renamed to....
	* gcc.target/aarch64/sme2/acle-asm/psel_lane_b16.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_b32.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_b64.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_b8.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_c16.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_c32.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_c64.c,
	gcc.target/aarch64/sme2/acle-asm/psel_lane_c8.c: ... These.

(cherry picked from commit 306834b7f7)
2024-11-06 20:14:29 +00:00
Simon Martin 951daf5417 c++: Defer -fstrong-eval-order processing to template instantiation time [PR117158]
Since r10-3793-g1a37b6d9a7e57c, we ICE upon the following valid code
with -std=c++17 and above

=== cut here ===
struct Base {
  unsigned int *intarray;
};
template <typename T> struct Sub : public Base {
  bool Get(int i) {
    return (Base::intarray[++i] == 0);
  }
};
=== cut here ===

The problem is that from c++17 on, we use -fstrong-eval-order and need
to wrap the array access expression into a SAVE_EXPR. We do so at
template declaration time, and end up calling contains_placeholder_p
with a SCOPE_REF, that it does not handle well.

This patch fixes this by deferring the wrapping into SAVE_EXPR to
instantiation time for templates, when the SCOPE_REF will have been
turned into a COMPONENT_REF.

	PR c++/117158

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_array_ref): Only wrap array expression
	into a SAVE_EXPR at template instantiation time.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/eval-order13.C: New test.
	* g++.dg/parse/crash77.C: New test.

(cherry picked from commit b1d92aeb85)
2024-11-06 06:54:57 +01:00
GCC Administrator fa7273637e Daily bump. 2024-11-06 00:24:00 +00:00
Patrick Palka 124f2f62e0 c++: reference variable as default targ [PR101463]
Here during default template argument substitution we wrongly consider
the (substituted) default arguments v and vt<int> as value-dependent
which ultimately leads to deduction failure for the calls.

The bogus value_dependent_expression_p result aside, I noticed
type_unification_real during default targ substitution keeps track of
whether all previous targs are known and non-dependent, as is the case
for these calls.  And in such cases it should be safe to avoid checking
dependence of the substituted default targ and just assume it's not.
This patch implements this optimization for GCC 14, which lets us accept
both testcases by sidestepping the value_dependent_expression_p issue
altogether.  (Note that for GCC 15 we fixed this differently, see
r15-3038-g5348e3cb9bc99d.)

	PR c++/101463

gcc/cp/ChangeLog:

	* pt.cc (type_unification_real): Avoid checking dependence of
	a substituted default template argument if we can assume it's
	non-dependent.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype6.C: New test.
	* g++.dg/cpp1z/nontype6a.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-11-05 15:18:26 -05:00
Torbjörn SVENSSON f23a894f3b testsuite: arm: Use effective-target for pr68620 and pr78041 tests
gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr68620.c: Use effective-target arm_neon.
	* gcc.target/arm/pr78041.c: Use effective-target arm_arch_v7a.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit c751889148)
2024-11-05 20:25:25 +01:00
Torbjörn SVENSSON 232d539f25 testsuite: arm: Use effective-target for pr98636.c test
The test case assumes that -mfp16-format=alternative is accepted for the
target, but not all targets support this flag. One such target is
Cortex-M85 that does support FP16, but not the alternative format.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr98636.c: Use effective-target
	arm_fp16_alternative.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 4602f628f7)
2024-11-05 19:12:10 +01:00
Jason Merrill ce25ca4da1 c++: allow array mem-init with -fpermissive [PR116634]
We've accidentally accepted this forever (at least as far back as 4.7), but
it's always been ill-formed; this was PR59465.  And we didn't accept it for
scalar types.  But rather than switch to a hard error for this code, let's
give a permerror so affected code can continue to work with -fpermissive.

	PR c++/116634

gcc/cp/ChangeLog:

	* init.cc (can_init_array_with_p): Allow PR59465 case with
	permerror.

gcc/testsuite/ChangeLog:

	* g++.dg/diagnostic/aggr-init1.C: Expect warning with -fpermissive.
	* g++.dg/init/array62.C: Adjust diagnostic.
	* g++.dg/init/array63.C: Adjust diagnostic.
	* g++.dg/init/array64.C: Adjust diagnostic.

(cherry picked from commit 3545aab001)
2024-11-05 12:31:19 -05:00
Paul Thomas c16e4ecd8f Fortran: Fix regressions with intent(out) class[PR115070, PR115348].
2024-11-05  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/115070
	PR fortran/115348
	* trans-expr.cc (gfc_trans_class_init_assign): If all the
	components of the default initializer are null for a scalar,
	build an empty statement to prevent prior declarations from
	disappearing.

gcc/testsuite/
	PR fortran/115070
	* gfortran.dg/ieee/pr115070.f90: New test.

	PR fortran/115348
	* gfortran.dg/pr115348.f90: New test.
2024-11-05 15:55:15 +00:00
GCC Administrator d0fe096766 Daily bump. 2024-11-05 00:24:42 +00:00
Andrew MacLeod e1154e294b Don't call invert on VARYING.
When all cases go to one label and resul in a VARYING value, we can't
invert that value to remove all values from the default case. Simply
check for this case and set the default to UNDEFINED.

	PR tree-optimization/117398
	gcc/
	* gimple-range-edge.cc (gimple_outgoing_range::calc_switch_ranges):
	Check for VARYING and don't call invert () on it.

	gcc/testsuite/
	* gcc.dg/pr117398.c: New.
2024-11-04 18:24:43 -05:00
Torbjörn SVENSSON 66a3827379 testsuite: arm: Use effective-target for memset-inline* tests
As these tests are set to execute and require neon hardware to do so,
add the missing dg-require-effective-target arm_neon_hw.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/memset-inline-4.c: Use effective-target
	arm_neon_hw.
	* gcc.target/arm/memset-inline-5.c: Likewise.
	* gcc.target/arm/memset-inline-6.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2024-11-04 21:36:33 +01:00
Torbjörn SVENSSON 7cc64ea496 testsuite: arm: Force hard ABI for pr51534.c test
The test case is written in a way that it should be using hard float
ABI, but the use of -mfloat-abi=hard could be overriden by
dg-add-options arm_neon. Ensure that -mfloat-abi=hard is always after.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr51534.c: Ensure -mfloat-abi=hard is used.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit e995866cff)
2024-11-04 20:22:44 +01:00
Torbjörn SVENSSON 05ffc64950 testsuite: arm: Use effective-target for data-intrinsics-assembly test
The expected assembler in the test case assumes -marm, so explicily
require it.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/acle/data-intrinsics-assembly.c: Use
	effective-target arm_arch_v6_arm.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 7b2e6e6be6)
2024-11-04 20:22:44 +01:00
Torbjörn SVENSSON 8f2cc62785 testsuite: arm: Relax cbranch tests to accept inverted branches
Similar to PR113502, but for non-aarch64 test.
The test started to fail after r14-7243-gafac1bd3365.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/vect-early-break-cbranch.c: Ignore exact
	branch.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit d56d2f3102)
2024-11-04 20:22:44 +01:00
Eric Botcazou eb929c391f ada: Fix crash on default value with nested iterated component associations
The problem is that the freeze node for the type of the element ends up in
the component list of the record type declared with the default value.

gcc/ada/ChangeLog:

	PR ada/113036
	* freeze.adb (Freeze_Expression): Deal with freezing actions coming
	from within nested internal loops present in spec expressions.
2024-11-04 17:48:11 +01:00
Eric Botcazou 3ed8c16f61 ada: Fix crash on real literal in declare expression of expression function
The problem is that the freeze node of the type to which the real literal
is resolved is placed inside the expression function instead of outside.

gcc/ada/

	* freeze.adb (Freeze_Expression): Also attach pending freeze nodes
	to the parent in the case of an internal block in a spec expression.
2024-11-04 17:48:08 +01:00
Andrew MacLeod 2a9fbe1920 Update bitwise_or op_range.
If the LHS of a bitwise OR is positive, then so are both operands when
using op1_range or op2_range.

	gcc/
	* range-op.cc (operator_bitwise_or::op1_range): If LHS is signed
	positive, so are both operands.

	gcc/testsuite
	* g++.dg/cpp23/attr-assume-opt.C (f2b): Alternate flow test.
2024-11-04 09:37:35 -05:00
Andrew MacLeod 393ee6b645 Reimplement 'assume' processing pass.
Rework the assume pass to work properly and fail conservatively when it
does.  Also move it to its own file.

	PR tree-optimization/117287
	gcc/
	* Makefile.in (IBJS): Add tree-assume.o
	* gimple-range.cc (assume_query::assume_range_p): Remove.
	(assume_query::range_of_expr): Remove.
	(assume_query::assume_query): Move to tree-assume.cc.
	(assume_query::~assume_query): Remove.
	(assume_query::calculate_op): Move to tree-assume.cc.
	(assume_query::calculate_phi): Likewise.
	(assume_query::check_taken_edge): Remove.
	(assume_query::calculate_stmt): Move to tree-assume.cc.
	(assume_query::dump): Remove.
	* gimple-range.h (class assume_query): Move to tree-assume.cc
	* tree-assume.cc: New
	* tree-vrp.cc (struct pass_data_assumptions): Move to tree-assume.cc.
	(class pass_assumptions): Likewise.
	(make_pass_assumptions): Likewise.

	gcc/testsuite/
	* g++.dg/cpp23/pr117287-attr.C: New.
2024-11-04 09:37:35 -05:00
Andrew MacLeod 08054021c8 Make fur_edge accessible.
Move the decl of fur_edge out of the source file into the header file.

	* gimple-range-fold.cc (class fur_edge): Relocate from here.
	(fur_edge::fur_edge): Also move to:
	* gimple-range-fold.h (class fur_edge): Relocate to here.
	(fur_edge::fur_edge): Likewise.
2024-11-04 09:37:34 -05:00
Jakub Jelinek 72b7bbf9d4 libstdc++: Fix up 117406.cc test [PR117406]
Christophe mentioned in bugzilla that the test FAILs on aarch64,
I'm not including <climits> and use INT_MAX.
Apparently during my testing I got it because the test preinclude
-include bits/stdc++.h
and that includes <climits>, dunno why that didn't happen on aarch64.
In any case, either I can add #include <climits>, or because the
test already has #include <limits> I've changed uses of INT_MAX
with std::numeric_limits<int>::max(), that should be the same thing.
But if you prefer
 #include <climits>
I can surely add that instead.

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

	PR libstdc++/117406
	* testsuite/26_numerics/headers/cmath/117406.cc: Use
	std::numeric_limits<int>::max() instead of INT_MAX.

(cherry picked from commit afcbf4dd27)
2024-11-04 13:17:35 +01:00
Jakub Jelinek 377f81a60b libstdc++: Fix up std::{,b}float16_t std::{ilogb,l{,l}r{ound,int}} [PR117406]
These overloads incorrectly cast the result of the float __builtin_*
to _Float or __gnu_cxx::__bfloat16_t.  For std::ilogb that changes
behavior for the INT_MAX return because that isn't representable in
either of the floating point formats, for the others it is I think
just a very inefficient hop from int/long/long long to std::{,b}float16_t
and back.  I mean for the round/rint cases, either the argument is small
and then the return value should be representable in the floating point
format too, or it is too large that the argument is already integral
and then it should just return the argument with the round trips.
Too large value is unspecified unlike ilogb.

2024-11-02  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/117406
	* include/c_global/cmath (std::ilogb(_Float16), std::llrint(_Float16),
	std::llround(_Float16), std::lrint(_Float16), std::lround(_Float16)):
	Don't cast __builtin_* return to _Float16.
	(std::ilogb(__gnu_cxx::__bfloat16_t),
	std::llrint(__gnu_cxx::__bfloat16_t),
	std::llround(__gnu_cxx::__bfloat16_t),
	std::lrint(__gnu_cxx::__bfloat16_t),
	std::lround(__gnu_cxx::__bfloat16_t)): Don't cast __builtin_* return to
	__gnu_cxx::__bfloat16_t.
	* testsuite/26_numerics/headers/cmath/117406.cc: New test.

(cherry picked from commit 36a9e2b225)
2024-11-04 13:14:39 +01:00
Jakub Jelinek 1553e40942 expand: Fix up expansion of VIEW_CONVERT_EXPR to BITINT_TYPE [PR117354]
The following testcase ICEs, because when trying to expand the
VIEW_CONVERT_EXPR operand which is SSA_NAME defined to
V32QI or V4DI MEM_REF which is aligned just to 8 bytes we force
it as unaligned into a register, but then try to call extract_bit_field
from the V32QI or V4DI register to BLKmode.  extract_bit_field doesn't
obviously support BLKmode extraction and so ICEs.

The second hunk fixes the ICE by not calling extract_bit_field when
it can't handle it, the last if will handle it properly by storing
it to memory and using BLKmode access to the copy.

The first hunk is an optimization, if mode is BLKmode, by setting
inner_reference_p argument to expand_expr_real we avoid the
expand_misaligned_mem_ref calls which load it from memory into a register.

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

	PR middle-end/117354
	* expr.cc (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Pass
	true as inner_reference_p argument to expand_expr_real if
	mode is BLKmode.  Don't call extract_bit_field if mode is BLKmode.

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

(cherry picked from commit b39f62ff73)
2024-11-04 13:13:02 +01:00
Jakub Jelinek 82285392ab function: Call do_pending_stack_adjust in assign_parms [PR117296]
Functions called by assign_parms call emit_block_move in two places,
so on some targets can be expanded as calls and can result in pending
stack adjustment.

Now, during expansion we normally call do_pending_stack_adjust at the end
of expansion of each basic block or before emitting code that will branch
and/or has labels, and when emitting labels we assert that there are no
pending stack adjustments.

assign_parms is expanded before the first basic block and if the first
basic block starts with a label and at least one of those emit_block_move
calls resulted in the need of pending stack adjustments, we ICE when
emitting that label.

The following patch fixes that by calling do_pending_stack_adjust after
after the assign_parms potential emit_block_move calls.

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

	PR target/117296
	* function.cc (assign_parms): Call do_pending_stack_adjust.

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

(cherry picked from commit fccef0c4ed)
2024-11-04 13:11:47 +01:00
Jakub Jelinek ec43369c7e libstdc++: Use if consteval rather than if (std::__is_constant_evaluated()) for {,b}float16_t nextafter [PR117321]
The nextafter_c++23.cc testcase fails to link at -O0.
The problem is that eventhough std::__is_constant_evaluated() has
always_inline attribute, that at -O0 just means that we inline the
call, but its result is still assigned to a temporary which is tested
later, nothing at -O0 propagates that false into the if and optimizes
away the if body.  And the __builtin_nextafterf16{,b} calls are meant
to be used solely for constant evaluation, the C libraries don't
define nextafterf16 these days.

As __STDCPP_FLOAT16_T__ and __STDCPP_BFLOAT16_T__ are predefined right
now only by GCC, not by clang which doesn't implement the extended floating
point types paper, and as they are predefined in C++23 and later modes only,
I think we can just use if consteval which is folded already during the FE
and the body isn't included even at -O0.  I've added a feature test for
that just in case clang implements those and implements those in some weird
way.  Note, if (__builtin_is_constant_evaluted()) would work correctly too,
that is also folded to false at gimplification time and the corresponding
if block not emitted at all.  But for -O0 it can't be wrapped into a helper
inline function.

2024-10-29  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/117321
	* include/c_global/cmath (nextafter(_Float16, _Float16)): Use
	if consteval rather than if (std::__is_constant_evaluated()) around
	the __builtin_nextafterf16 call.
	(nextafter(__gnu_cxx::__bfloat16_t, __gnu_cxx::__bfloat16_t)): Use
	if consteval rather than if (std::__is_constant_evaluated()) around
	the __builtin_nextafterf16b call.
	* testsuite/26_numerics/headers/cmath/117321.cc: New test.

(cherry picked from commit 5e247ac0c2)
2024-11-04 13:09:03 +01:00
Eric Botcazou 0bcca04f09 Add regression test
This is for the latest fix made to Selected_Length_Checks in Checks.

gcc/testsuite
	* gnat.dg/specs/array7.ads: New test.
2024-11-04 11:20:13 +01:00
Eric Botcazou 4f563063f9 ada: Fix internal error on concatenation of discriminant-dependent component
This only occurs with optimization enabled, but the expanded code is always
wrong because it reuses the formal parameter of an initialization procedure
associated with a discriminant (a discriminal in GNAT parlance) outside of
the initialization procedure.

gcc/ada/

	* checks.adb (Selected_Length_Checks.Get_E_Length): For a
	component of a record with discriminants and if the expression is
	a selected component, try to build an actual subtype from its
	prefix instead of from the discriminal.
2024-11-04 11:19:56 +01:00
GCC Administrator 09033ae194 Daily bump. 2024-11-04 00:22:56 +00:00
GCC Administrator e455f398ca Daily bump. 2024-11-03 00:22:12 +00:00
GCC Administrator 9b1f15e1e1 Daily bump. 2024-11-02 00:25:44 +00:00
Haochen Jiang 82bfb6c5ba i386: Do not allow pointer conversion for CMPccXADD intrin under -O0
The pointer conversion to wider type under macro would not consider
whether the higher bit is cleaned or not. It will lead to unexpected
cmp result.

After this change, it will throw an incompatible pointer type error just
like -O2 does currently.

gcc/ChangeLog:

	* config/i386/cmpccxaddintrin.h (_cmpccxadd_epi32): Do not do
	type conversion for pointer.
	(_cmpccxadd_epi64): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/cmpccxadd-1b.c: New test.
2024-11-02 02:19:06 +08:00
Paul Thomas 9a5ee8da09 Fortran: Fix ICE with structure constructor in data statement [PR79685]
2024-10-25  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/79685
	* decl.cc (match_data_constant): Find the symtree instead of
	the symbol so the use renamed symbols are found. Pass this and
	the derived type to gfc_match_structure_constructor.
	* match.h: Update prototype of gfc_match_structure_contructor.
	* primary.cc (gfc_match_structure_constructor): Remove call to
	gfc_get_ha_sym_tree and use caller supplied symtree instead.

gcc/testsuite/
	PR fortran/79685
	* gfortran.dg/use_rename_13.f90: New test.

(cherry picked from commit 6cb1da72ca)
2024-11-01 10:27:44 +00:00
Hongyu Wang df54290922 [APX PPX] Avoid generating unmatched pushp/popp in pro/epilogue
According to APX spec, the pushp/popp pairs should be matched,
otherwise the PPX hint cannot take effect and cause performance loss.

In the ix86_expand_epilogue, there are several optimizations that may
cause the epilogue using mov to restore the regs. Check if PPX applied
and prevent usage of mov/leave in the epilogue. Also do not use PPX
for eh_return.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_expand_prologue): Set apx_ppx_used
	flag in m.fs with TARGET_APX_PPX && !crtl->calls_eh_return.
	(ix86_emit_save_regs): Emit ppx is available only when
	TARGET_APX_PPX && !crtl->calls_eh_return.
	(ix86_expand_epilogue): Don't restore reg using mov when
	apx_ppx_used flag is true.
	* config/i386/i386.h (struct machine_frame_state):
	Add apx_ppx_used flag.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/apx-ppx-2.c: New test.
	* gcc.target/i386/apx-ppx-3.c: Likewise.

(cherry picked from commit 8e72b1bb38)
2024-11-01 08:32:38 +08:00
GCC Administrator ea1f03fc6e Daily bump. 2024-11-01 00:24:47 +00:00
Peter Bergner b4d4b86aeb rs6000: ROP - Do not disable shrink-wrapping for leaf functions [PR114759]
Only disable shrink-wrapping when using -mrop-protect when we know we
will be emitting the ROP-protect hash instructions (ie, non-leaf functions).

2024-06-17  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/114759
	* config/rs6000/rs6000.cc (rs6000_override_options_after_change): Move
	the disabling of shrink-wrapping from here....
	* config/rs6000/rs6000-logue.cc (rs6000_emit_prologue): ...to here.

gcc/testsuite/
	PR target/114759
	* gcc.target/powerpc/pr114759-1.c: New test.

(cherry picked from commit 0451bc503d)
2024-10-31 16:35:20 -05:00
Richard Sandiford 8ac2f3ce09 aarch64: Forbid F64MM permutes in streaming mode
The current code was based on an early version of the SME spec,
which allowed the .Q forms of TRN1, TRN2, UZP1, UZP2, ZIP1, and ZIP2
to be used in streaming mode.  We should now forbid them instead;
see https://developer.arm.com/documentation/ddi0602/2024-09/SVE-Instructions/TRN1--TRN2--vectors---Interleave-even-or-odd-elements-from-two-vectors-?lang=en
and the corresponding entries for the others.

gcc/
	* config/aarch64/aarch64-sve-builtins-base.def (svtrn1q, svtrn2q)
	(svuzp1q, svuzp2q, svzip1q, svzip2q): Require SM_OFF.

gcc/testsuite/
	* g++.target/aarch64/sve/aarch64-ssve.exp: Add tests for trn[12]q,
	uzp[12].c, and zip[12]q.
	* gcc.target/aarch64/sve/acle/asm/trn1q_bf16.c: Skip for
	STREAMING_COMPATIBLE.
	* gcc.target/aarch64/sve/acle/asm/trn1q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn1q_u8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_bf16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/trn2q_u8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_bf16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp1q_u8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_bf16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/uzp2q_u8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_bf16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip1q_u8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_bf16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_f16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_f32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_f64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_s16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_s32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_s64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_s8.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_u16.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_u32.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_u64.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/zip2q_u8.c: Likewise.

(cherry picked from commit e8fa15ea01439bccf15ae9b9a4d63ac92586c2c5)
2024-10-31 19:52:46 +00:00
Yangyu Chen 4e174ac8ee Fix function multiversioning dispatcher link error with LTO
We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When
building with LTO, the linker cannot find the
__init_cpu_features_resolver.lto_priv* symbol, causing the link error.

This patch gets this fixed by adding DECL_EXTERNAL to the decl. To avoid used
but never defined warning for this symbol, we also mark TREE_PUBLIC to the decl.
We should also mark the decl having hidden visibility. And fix the attribute in
the same way for __aarch64_cpu_features identifier.

Minimal steps to reproduce the bug:

echo '__attribute__((target_clones("default", "aes"))) void func1() { }' > 1.c
echo '__attribute__((target_clones("default", "aes"))) void func2() { }' > 2.c
echo 'void func1();void func2();int main(){func1();func2();return 0;}' > main.c
gcc -flto -c 1.c 2.c
gcc -flto main.c 1.o 2.o

Fixes: 0cfde688e2 ("[aarch64] Add function multiversioning support")
Signed-off-by: Yangyu Chen <cyy@cyyself.name>

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (dispatch_function_versions): Adding
	DECL_EXTERNAL, TREE_PUBLIC and hidden DECL_VISIBILITY to
	__init_cpu_features_resolver and __aarch64_cpu_features.

(cherry picked from commit 875279ff3e)
2024-10-31 19:52:45 +00:00
GCC Administrator 0e132a3b95 Daily bump. 2024-10-31 00:22:52 +00:00
David Malcolm acc0b9ff9c jit: fix leak of pending_assemble_externals_set [PR117275]
My recent r15-4580-g779c0390e3b57d fix for resetting state in
varasm.cc introduced some noise to "make selftest-valgrind" and,
presumably, a memory leak in libgccjit:

==2462086== 160 (56 direct, 104 indirect) bytes in 1 blocks are definitely lost in loss record 248 of 352
==2462086==    at 0x5270E7D: operator new(unsigned long) (vg_replace_malloc.c:342)
==2462086==    by 0x1D1EB89: init_varasm_once() (varasm.cc:6806)
==2462086==    by 0x181C845: backend_init() (toplev.cc:1826)
==2462086==    by 0x181D41A: do_compile() (toplev.cc:2193)
==2462086==    by 0x181D99C: toplev::main(int, char**) (toplev.cc:2371)
==2462086==    by 0x378391D: main (main.cc:39)

Fixed thusly.

gcc/ChangeLog:
	PR jit/117275
	* varasm.cc (process_pending_assemble_externals): Reset
	pending_assemble_externals_set to nullptr after deleting it.
	(varasm_cc_finalize): Delete pending_assemble_externals_set.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 7f41203f08)
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-30 16:11:41 -04:00
David Malcolm 70f911bf54 jit: reset state in varasm.cc [PR117275]
PR jit/117275 reports various jit test failures seen on
powerpc64le-unknown-linux-gnu due to hitting this assertion
in varasm.cc on the 2nd compilation in a process:

#2  0x00007ffff63e67d0 in assemble_external_libcall (fun=0x7ffff2a4b1d8)
    at ../../src/gcc/varasm.cc:2650
2650          gcc_assert (!pending_assemble_externals_processed);
(gdb) p pending_assemble_externals_processed
$1 = true

We're not properly resetting state in varasm.cc after a compile
for libgccjit.

Fixed thusly.

gcc/ChangeLog:
	PR jit/117275
	* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
	* varasm.cc (varasm_cc_finalize): New.
	* varasm.h (varasm_cc_finalize): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 779c0390e3)
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-30 16:11:40 -04:00
David Malcolm 771873f0a9 testsuite, jit: fix test-error-pr63969-missing-driver.c
jit.dg/test-error-pr63969-missing-driver.c tries to break PATH and
verify that an error is generated when using an external driver.

However it does this by unsetting PATH, and so the test could
accidentally find the driver if the system supplies a default and the
driver happens to be installed in that path (reported as rhbz#2318021).

Fix the test by instead setting PATH to a bogus value.

gcc/testsuite/ChangeLog:
	* jit.dg/test-error-pr63969-missing-driver.c (create_code): When
	breaking PATH, use setenv with a bogus value, rather than
	unsetenv, in case the system uses a default path that contains
	the driver binary.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit f8dcb559e6)
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-30 16:11:40 -04:00
Alex Coplan 434483ac32 aarch64: Assume alias conflict if common address reg changes [PR116783]
As the PR shows, pair fusion was tricking memory_modified_in_insn_p into
returning false when a common base register (in this case, x1) was
modified between the mem and the store insn.  This lead to wrong code as
the accesses really did alias.

To avoid this sort of problem, this patch avoids invoking RTL alias
analysis altogether (and assume an alias conflict) if the two insns to
be compared share a common address register R, and the insns see different
definitions of R (i.e. it was modified in between).

This is a backport (but not a straight cherry pick) of
r15-4518-gc0e54ce1999ccf2241f74c5188b11b92e5aedc1f.

gcc/ChangeLog:

	PR rtl-optimization/116783
	* config/aarch64/aarch64-ldp-fusion.cc
	(def_walker::cand_addr_uses): New.
	(def_walker::def_walker): Add parameter for candidate address
	uses.
	(def_walker::alias_conflict_p): Declare.
	(def_walker::addr_reg_conflict_p): New.
	(def_walker::conflict_p): New.
	(store_walker::store_walker): Add parameter for candidate
	address uses and pass to base ctor.
	(store_walker::conflict_p): Rename to ...
	(store_walker::alias_conflict_p): ... this.
	(load_walker::load_walker): Add parameter for candidate
	address uses and pass to base ctor.
	(load_walker::conflict_p): Rename to ...
	(load_walker::alias_conflict_p): ... this.
	(ldp_bb_info::try_fuse_pair): Collect address register
	uses for candidate insns and pass down to alias walkers.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/116783
	* g++.dg/torture/pr116783.C: New test.
2024-10-30 15:32:18 +00:00
liuhongt 71a0cf699b Fix ICE due to subreg:us_truncate.
Force_operand issues an ICE when input
is (subreg:DI (us_truncate:V8QI)), it's probably because it's an
invalid rtx, So refine backend patterns for that.

gcc/ChangeLog:

	PR target/117318
	* config/i386/sse.md (*avx512vl_<code>v2div2qi2_mask_store_1):
	Rename to ..
	(avx512vl_<code>v2div2qi2_mask_store_1): .. this.
	(avx512vl_<code>v2div2qi2_mask_store_2): Change to
	define_expand.
	(*avx512vl_<code><mode>v4qi2_mask_store_1): Rename to ..
	(avx512vl_<code><mode>v4qi2_mask_store_1): .. this.
	(avx512vl_<code><mode>v4qi2_mask_store_2): Change to
	define_expand.
	(*avx512vl_<code><mode>v8qi2_mask_store_1): Rename to ..
	(avx512vl_<code><mode>v8qi2_mask_store_1): .. this.
	(avx512vl_<code><mode>v8qi2_mask_store_2): Change to
	define_expand.
	(*avx512vl_<code><mode>v4hi2_mask_store_1): Rename to ..
	(avx512vl_<code><mode>v4hi2_mask_store_1): .. this.
	(avx512vl_<code><mode>v4hi2_mask_store_2): Change to
	define_expand.
	(*avx512vl_<code>v2div2hi2_mask_store_1): Rename to ..
	(avx512vl_<code>v2div2hi2_mask_store_1): .. this.
	(avx512vl_<code>v2div2hi2_mask_store_2): Change to
	define_expand.
	(*avx512vl_<code>v2div2si2_mask_store_1): Rename to ..
	(avx512vl_<code>v2div2si2_mask_store_1): .. this.
	(avx512vl_<code>v2div2si2_mask_store_2): Change to
	define_expand.
	(*avx512f_<code>v8div16qi2_mask_store_1): Rename to ..
	(avx512f_<code>v8div16qi2_mask_store_1): .. this.
	(avx512f_<code>v8div16qi2_mask_store_2): Change to
	define_expand.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit bc0eeccf27)
2024-10-30 04:58:59 -07:00
GCC Administrator f2805039e4 Daily bump. 2024-10-30 00:23:39 +00:00
Eric Botcazou 0ea3dca794 Fix miscompilation of function containing __builtin_unreachable
This is a wrong-code generation on the SPARC for a function containing
a call to __builtin_unreachable caused by the delay slot scheduling pass,
and more specifically the find_end_label function which has these lines:

  /* Otherwise, see if there is a label at the end of the function. If there
     is, it must be that RETURN insns aren't needed, so that is our return
     label and we don't have to do anything else.  */

The comment was correct 20 years ago but no longer is nowadays in the
presence of RTL epilogues and calls to __builtin_unreachable, so the
patch just removes the associated two lines of code:

  else if (LABEL_P (insn))
    *plabel = as_a <rtx_code_label *> (insn);

and otherwise contains just adjustments to the commentary.

gcc/
	PR rtl-optimization/117327
	* reorg.cc (find_end_label): Do not return a dangling label at the
	end of the function and adjust commentary.

gcc/testsuite/
	* gcc.c-torture/execute/20241029-1.c: New test.
2024-10-29 21:51:07 +01:00
Peter Bergner ab74b2d864 rs6000: Fix PTImode handling in power8 swap optimization pass [PR116415]
Our power8 swap optimization pass has some special handling for optimizing
swaps of TImode variables.  The test case reported in bugzilla uses a call
to  __atomic_compare_exchange, which introduces a variable of PTImode and
that does not get the same treatment as TImode leading to wrong code
generation.  The simple fix is to treat PTImode identically to TImode.

2024-08-23  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/116415
	* config/rs6000/rs6000.h (TI_OR_PTI_MODE): New define.
	* config/rs6000/rs6000-p8swap.cc (rs6000_analyze_swaps): Use it to
	handle PTImode identically to TImode.

gcc/testsuite/
	PR target/116415
	* gcc.target/powerpc/pr116415.c: New test.

(cherry picked from commit 6e68c3df15)
2024-10-28 20:56:24 -05:00
GCC Administrator f675f1b738 Daily bump. 2024-10-29 00:23:02 +00:00
Sam James 6247aae35f testsuite: add testcase for fixed PR107467
PR107467 ended up being fixed by the fix for PR115110, but let's
add the testcase on top.

gcc/testsuite/ChangeLog:
	PR tree-optimization/107467
	PR middle-end/115110

	* g++.dg/lto/pr107467_0.C: New test.

(cherry picked from commit 4e09ae37db)
2024-10-28 17:06:44 +00:00
Sam James ed8fb9b285 Revert "testsuite: add testcase for fixed PR107467"
This reverts commit 2f0d109bd8.
2024-10-28 17:06:37 +00:00
Sam James 2f0d109bd8 testsuite: add testcase for fixed PR107467
PR107467 ended up being fixed by the fix for PR115110, but let's
add the testcase on top.

gcc/testsuite/ChangeLog:
	PR tree-optimization/107467
	PR middle-end/115110

	* g++.dg/lto/pr107467_0.C: New test.
2024-10-28 17:06:05 +00:00
GCC Administrator c79acf623f Daily bump. 2024-10-28 00:22:21 +00:00
Torbjörn SVENSSON ec9bd14144 testsuite: Sanitize pacbti test cases for Cortex-M
Some of the test cases were scanning for "bti", but it would,
incorrectly, match the ".arch_extenssion pacbti".

gcc/testsuite/ChangeLog:

	* gcc.target/arm/bti-1.c: Check for asm instructions starting
	with a tab.
	* gcc.target/arm/bti-2.c: Likewise.
	* gcc.target/arm/pac-1.c: Likewise.
	* gcc.target/arm/pac-2.c: Likewise.
	* gcc.target/arm/pac-3.c: Likewise.
	* gcc.target/arm/pac-4.c: Likewise.
	* gcc.target/arm/pac-6.c: Likewise.
	* gcc.target/arm/pac-7.c: Likewise.
	* gcc.target/arm/pac-8.c: Likewise.
	* gcc.target/arm/pac-9.c: Likewise.
	* gcc.target/arm/pac-10.c: Likewise.
	* gcc.target/arm/pac-11.c: Likewise.
	* gcc.target/arm/pac-15.c: Likewise.
	* gcc.target/arm/pac-sibcall.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
(cherry picked from commit 6ad29a858b)
2024-10-27 13:25:38 +01:00
GCC Administrator 77bf8aa8f2 Daily bump. 2024-10-27 00:23:03 +00:00
GCC Administrator e44d4b7647 Daily bump. 2024-10-26 00:23:24 +00:00
Jakub Jelinek 7965062f9e Assorted --disable-checking fixes [PR117249]
We have currently 3 different definitions of gcc_assert macro, one used most
of the time (unless --disable-checking) which evaluates the condition at
runtime and also checks it at runtime, then one for --disable-checking GCC 4.5+
which looks like
((void)(UNLIKELY (!(EXPR)) ? __builtin_unreachable (), 0 : 0))
and a fallback one
((void)(0 && (EXPR)))
Now, the last one actually doesn't evaluate any of the side-effects in the
argument, just quiets up unused var/parameter warnings.
I've tried to replace the middle definition with
({ [[assume (EXPR)]]; (void) 0; })
for compilers which support assume attribute and statement expressions
(surprisingly quite a few spots use gcc_assert inside of comma expressions),
but ran into PR117287, so for now such a change isn't being proposed.

The following patch attempts to move important side-effects from gcc_assert
arguments.

Bootstrapped/regtested on x86_64-linux and i686-linux with normal
--enable-checking=yes,rtl,extra, plus additionally I've attempted to do
x86_64-linux bootstrap with --disable-checking and gcc_assert changed to the
((void)(0 && (EXPR)))
version when --disable-checking.  That version ran into spurious middle-end
warnings
../../gcc/../include/libiberty.h:733:36: error: argument to ‘alloca’ is too large [-Werror=alloca-larger-than=]
../../gcc/tree-ssa-reassoc.cc:5659:20: note: in expansion of macro ‘XALLOCAVEC’
  int op_num = ops.length ();
  int op_normal_num = op_num;
  gcc_assert (op_num > 0);
  int stmt_num = op_num - 1;
  gimple **stmts = XALLOCAVEC (gimple *, stmt_num);
where we have gcc_assert exactly to work-around middle-end warnings.
Guess I'd need to also disable -Werror for this experiment, which actually
isn't a problem with unmodified system.h, because even for
--disable-checking we use the __builtin_unreachable at least in
stage2/stage3 and so the warnings aren't emitted, and even if it used
[[assume ()]]; it would work too because in stage2/stage3 we could again
rely on assume and statement expression support.

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

	PR middle-end/117249
	* tree-ssa-structalias.cc (insert_vi_for_tree): Move put calls out of
	gcc_assert.
	* lto-cgraph.cc (lto_symtab_encoder_delete_node): Likewise.
	* gimple-ssa-strength-reduction.cc (get_alternative_base,
	add_cand_for_stmt): Likewise.
	* tree-eh.cc (add_stmt_to_eh_lp_fn): Likewise.
	* except.cc (duplicate_eh_regions_1): Likewise.
	* tree-ssa-reassoc.cc (insert_operand_rank): Likewise.
	* config/nvptx/nvptx.cc (nvptx_expand_call): Use == rather than = in
	gcc_assert.
	* opts-common.cc (jobserver_info::disconnect): Call close outside of
	gcc_assert and only check result in it.
	(jobserver_info::return_token): Call write outside of gcc_assert and
	only check result in it.
	* genautomata.cc (output_default_latencies): Move j++ side-effect
	outside of gcc_assert.
	* tree-ssa-loop-ivopts.cc (get_alias_ptr_type_for_ptr_address): Use
	== rather than = in gcc_assert.
	* cgraph.cc (symbol_table::create_edge): Move ++edges_max_uid
	side-effect outside of gcc_assert.

(cherry picked from commit e2a8772c93)
2024-10-25 14:50:24 +02:00
Jakub Jelinek 8bd4f104ff c++: Further fix for get_member_function_from_ptrfunc [PR117259]
The following testcase shows that the previous get_member_function_from_ptrfunc
changes weren't sufficient and we still have cases where
-fsanitize=undefined with pointers to member functions can cause wrong code
being generated and related false positive warnings.

The problem is that save_expr doesn't always create SAVE_EXPR, it can skip
some invariant arithmetics and in the end it could be really large
expressions which would be evaluated several times (and what is worse, with
-fsanitize=undefined those expressions then can have SAVE_EXPRs added to
their subparts for -fsanitize=bounds or -fsanitize=null or
-fsanitize=alignment instrumentation).  Tried to just build1 a SAVE_EXPR
+ add TREE_SIDE_EFFECTS instead of save_expr, but that doesn't work either,
because cp_fold happily optimizes those SAVE_EXPRs away when it sees
SAVE_EXPR operand is tree_invariant_p.

So, the following patch instead of using save_expr or building SAVE_EXPR
manually builds a TARGET_EXPR.  Both types are pointers, so it doesn't need
to be destroyed in any way, but TARGET_EXPR is what doesn't get optimized
away immediately.

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

	PR c++/117259
	* typeck.cc (get_member_function_from_ptrfunc): Use force_target_expr
	rather than save_expr for instance_ptr and function.  Don't call it
	for TREE_CONSTANT.

	* g++.dg/ubsan/pr117259.C: New test.

(cherry picked from commit b25d3201b6)
2024-10-25 14:49:31 +02:00
Jakub Jelinek 85221c95e3 asan: Fix up build_check_stmt gsi handling [PR117209]
gsi_safe_insert_before properly updates gsi_bb in gimple_stmt_iterator
in case it splits objects, but unfortunately build_check_stmt was in
some places (but not others) using a copy of the iterator rather than
the iterator passed from callers and so didn't propagate that to callers.
I guess it didn't matter much before when it was just using
gsi_insert_before as that really didn't change the iterator.
The !before_p case is apparently dead code, nothing is calling it with
before_p=false since around 4.9.

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

	PR sanitizer/117209
	* asan.cc (maybe_cast_to_ptrmode): Formatting fix.
	(build_check_stmt): Don't copy *iter into gsi, perform all
	the updates on iter directly.

	* gcc.dg/asan/pr117209.c: New test.

(cherry picked from commit 885143fa77)
2024-10-25 14:48:44 +02:00
Eric Botcazou 11b5128429 Add regression test
gcc/testsuite
	PR ada/116551
	* gnat.dg/specs/vfa3.ads: New test.
2024-10-25 13:18:33 +02:00
Eric Botcazou d587da2631 ada: Fix internal error on bit-packed array type with Volatile_Full_Access
The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

	PR ada/116551
	* gcc-interface/trans.cc (node_is_atomic) <N_Identifier>: Return
	false if the type of the entity is an unconstrained array type.
	(node_is_volatile_full_access) <N_Identifier>: Likewise.
2024-10-25 13:18:22 +02:00
Georg-Johann Lay ddba8434cb AVR: target/116953 - Restore recog_data after calling jump_over_one_insn_p.
The previous fix for PR116953 is incomplete because references to
recog_data are escaping avr_out_sbxx_branch() in the form of %-operands
in the returned asm code template.  This patch reverts the previous fix,
and re-extracts the operands by means of extract_constrain_insn_cached()
after the call of jump_over_one_insn_p().

	PR target/116953
gcc/
	* config/avr/avr.cc (avr_out_sbxx_branch): Revert previous fix
	for PR116953 (r15-4078).  Run extract_constrain_insn_cached
	on the current insn after calling jump_over_one_insn_p.

(cherry picked from commit ca0ab7a0ac)
2024-10-25 11:26:35 +02:00
Paul Thomas 944d585d8a Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].
2024-07-16  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/84868
	* simplify.cc (gfc_simplify_len_trim): If the argument is an
	element of a parameter array, simplify all the elements and
	build a new parameter array to hold the result, after checking
	that it doesn't already exist.
	* trans-expr.cc (gfc_get_interface_mapping_array) if a string
	length is available, use it for the typespec.
	(gfc_add_interface_mapping): Supply the se string length.

gcc/testsuite/
	PR fortran/84868
	* gfortran.dg/pr84868.f90: New test.

(cherry picked from commit 9f966b6a8f)
2024-10-25 09:55:22 +01:00
Jason Merrill 2d47645cd4 c++: remove dg-warning [PR117274]
This warning was added for GCC 15, don't expect it.

	PR c++/117274
	PR c++/117107

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/decomp10.C: Remove captured binding warning.
2024-10-24 11:14:23 -04:00
GCC Administrator 9eb9686766 Daily bump. 2024-10-24 00:24:41 +00:00
liuhongt b718f6ec16 Fix ICE due to isa mismatch for the builtins.
gcc/ChangeLog:

	PR target/117240
	* config/i386/i386-builtin.def: Add avx/avx512f to vaes
	ymm/zmm builtins.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr117240_avx.c: New test.
	* gcc.target/i386/pr117240_avx512f.c: New test.

(cherry picked from commit 403e361d5a)
2024-10-23 04:44:00 -07:00
Jakub Jelinek 20c180cf65 c-family: Fix up -Wsizeof-pointer-memaccess ICEs [PR117230]
In the following testcases, we ICE on all 4 function calls.
The problem is using TYPE_PRECISION on vector types (but guess it
would be similarly problematic on structures/unions/arrays).
The test only differentiates between suggestion what to do, whether
to supply explicit size because sizeof (*p) for
{,{,un}signed }char *p is not very likely what the user want, or
dereferencing the pointer, so I think limiting that suggestion
to integral types is ok.

2024-10-22  Jakub Jelinek  <jakub@redhat.com>

	PR c/117230
	* c-warn.cc (sizeof_pointer_memaccess_warning): Only compare
	TYPE_PRECISION of TREE_TYPE (type) to precision of char if
	TREE_TYPE (type) is integral type.

	* c-c++-common/Wsizeof-pointer-memaccess5.c: New test.

(cherry picked from commit 5fd1c0c1b6)
2024-10-23 09:28:46 +02:00
Jakub Jelinek 6603ec4d11 match.pd: Further fma negation fixes [PR116891]
On Mon, Oct 14, 2024 at 08:53:29AM +0200, Jakub Jelinek wrote:
> >     PR middle-end/116891
> >     * match.pd ((negate (IFN_FNMS@3 @0 @1 @2)) -> (IFN_FMA @0 @1 @2)):
> >     Only enable for !HONOR_SIGN_DEPENDENT_ROUNDING.
>
> Guess it would be nice to have a testcase which FAILs without the patch and
> PASSes with it, but it can be added later.

I've added such a testcase now, and additionally found the fix only fixed
one of the 4 problematic similar cases.

Here is a patch which fixes the others too and adds the testcases.
fma-pr116891.c FAILed without your patch, FAILs with your patch too (but
only due to the bar/baz/qux checks) and PASSes with the patch.

2024-10-15  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/116891
	* match.pd ((negate (fmas@3 @0 @1 @2)) -> (IFN_FNMS @0 @1 @2)):
	Only enable for !HONOR_SIGN_DEPENDENT_ROUNDING.
	((negate (IFN_FMS@3 @0 @1 @2)) -> (IFN_FNMA @0 @1 @2)): Likewise.
	((negate (IFN_FNMA@3 @0 @1 @2)) -> (IFN_FMS @0 @1 @2)): Likewise.

	* gcc.dg/pr116891.c: New test.
	* gcc.target/i386/fma-pr116891.c: New test.

(cherry picked from commit 4366f0c7e2)
2024-10-23 09:27:08 +02:00
Richard Biener ffce44e8be middle-end/116891 - fix (negate (IFN_FNMS@3 @0 @1 @2)) -> (IFN_FMA @0 @1 @2)
Transforming -fma (-a, b, -c) to fma (a, b, c) is only valid when
not rounding towards -inf or +inf as the sign of the multiplication
changes.

	PR middle-end/116891
	* match.pd ((negate (IFN_FNMS@3 @0 @1 @2)) -> (IFN_FMA @0 @1 @2)):
	Only enable for !HONOR_SIGN_DEPENDENT_ROUNDING.

(cherry picked from commit c53bd48c69)
2024-10-23 09:23:26 +02:00
GCC Administrator 608486e678 Daily bump. 2024-10-23 00:24:19 +00:00
Jason Merrill 7de78f7353 c++: non-dep structured binding decltype again [PR117107]
The patch for PR92687 handled the usual case of a decomp variable not being
in the table, but missed the case of there being nothing in the table yet.

	PR c++/117107
	PR c++/92687

gcc/cp/ChangeLog:

	* decl.cc (lookup_decomp_type): Handle null table.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/decomp10.C: New test.

(cherry picked from commit 71e13ea134)
2024-10-22 17:57:32 -04:00
Nathaniel Shead 01d3a974fe c++/modules: Fix treatment of unnamed types [PR116929]
In r14-9530 we relaxed "depending on type with no-linkage" errors for
declarations that could actually be accessed from different TUs anyway.
However, this also enabled it for unnamed types, which never work.

In a normal module interface, an unnamed type is TU-local by
[basic.link] p15.2, and so cannot be exposed or the program is
ill-formed.  We don't yet implement this checking but we should assume
that we will later; currently supporting this actually causes ICEs when
attempting to create the mangled name in some situations.

For a header unit, by [module.import] p5.3 it is unspecified whether two
TUs importing a header unit providing such a declaration are importing
the same header unit.  In this case, we would require name mangling
changes to somehow allow the (anonymous) type exported by such a header
unit to correspond across different TUs in the presence of other
anonymous declarations, so for this patch just assume that this case
would be an ODR violation instead.

	PR c++/116929

gcc/cp/ChangeLog:

	* tree.cc (no_linkage_check): Anonymous types can't be accessed
	in a different TU.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/linkage-1_a.C: Remove anonymous type test.
	* g++.dg/modules/linkage-1_b.C: Likewise.
	* g++.dg/modules/linkage-1_c.C: Likewise.
	* g++.dg/modules/linkage-2.C: Add note about anonymous types.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>

(cherry picked from commit 0173dcce92)
2024-10-22 16:23:31 -04:00
Torbjörn SVENSSON 8b1146fe46 testsuite: arm: Use check-function-bodies in fp16-aapcs-* tests
Converted the tests to use check-function-bodies in order to ensure that
the sequence is correct.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/fp16-aapcs-1.c: Use check-function-bodies.
	* gcc.target/arm/fp16-aapcs-2.c: Likewise.
	* gcc.target/arm/fp16-aapcs-3.c: Likewise.
	* gcc.target/arm/fp16-aapcs-4.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 205515da82)
2024-10-22 19:11:20 +02:00
Torbjörn SVENSSON cc1e6053c3 testsuite: arm: Relax expected asm in bitfield* and union-2 tests
Below -O2, lsls/lsrs are prefered. For -O2 and above, lsl/lsr are
prefered.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/cmse/mainline/8_1m/bitfield-4.c: Allow lsl and
	lsr instructions.
	* gcc.target/arm/cmse/mainline/8_1m/bitfield-6.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/bitfield-8.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/bitfield-and-union.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/union-2.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit a79ca49b5c)
2024-10-22 19:06:05 +02:00
Torbjörn SVENSSON 47c66c56d7 testsuite: arm: Use check-function-bodies in cmse-5 tests
Converted the tests to use check-function-bodies in order to ensure that
the sequence is correct.
This also allows both APSR_nzcvq and APSR_nzcvqg as target selector does
not work when the -march and/or -mcpu overrides the target to test.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/cmse/mainline/8m/hard-sp/cmse-5.c: Use
	check-function-bodies.
	* gcc.target/arm/cmse/mainline/8m/hard/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8m/soft/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8m/softfp-sp/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8m/softfp/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/hard-sp/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/hard/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/soft/cmse-5.c: Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/softfp-sp/cmse-5.c:
	Likewise.
	* gcc.target/arm/cmse/mainline/8_1m/softfp/cmse-5.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 835ad52fbb)
2024-10-22 19:06:02 +02:00
Richard Sandiford 1ab90810dc testsuite: Skip pr112305.c for -O[01] on simulators
gcc.dg/torture/pr112305.c contains an inner loop that executes
0x8000_0014 times and an outer loop that executes 5 times, giving about
10 billion total executions of the inner loop body.  At -O2 and above we
are able to remove the inner loop, but at -O1 we keep a no-op loop:

        dls     lr, r3
.L3:
        subs    r3, r3, #1
        le      lr, .L3

and at -O0 we of course don't optimise.

This can lead to long execution times on simulators, possibly
triggering a timeout.

gcc/testsuite
	* gcc.dg/torture/pr112305.c: Skip at -O0 and -O1 for simulators.

(cherry picked from commit 4e80432c52)
2024-10-22 12:49:35 +01:00
Patrick Palka f381a217e9 libstdc++: Implement LWG 3664 changes to ranges::distance
libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (__distance_fn::operator()):
	Adjust iterator/sentinel overloads as per LWG 3664.
	* testsuite/24_iterators/range_operations/distance.cc:
	Test LWG 3664 example.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 7c0d1e9f2a)
2024-10-21 21:38:40 -04:00
Patrick Palka 07ee687496 libstdc++/ranges: Implement various small LWG issues
This implements the following small LWG issues:

  3848. adjacent_view, adjacent_transform_view and slide_view missing base accessor
  3851. chunk_view::inner-iterator missing custom iter_move and iter_swap
  3947. Unexpected constraints on adjacent_transform_view::base()
  4001. iota_view should provide empty
  4012. common_view::begin/end are missing the simple-view check
  4013. lazy_split_view::outer-iterator::value_type should not provide default constructor
  4035. single_view should provide empty
  4053. Unary call to std::views::repeat does not decay the argument
  4054. Repeating a repeat_view should repeat the view

libstdc++-v3/ChangeLog:

	* include/std/ranges (single_view::empty): Define as per LWG 4035.
	(iota_view::empty): Define as per LWG 4001.
	(lazy_split_view::_OuterIter::value_type): Remove default
	constructor and make other constructor private as per LWG 4013.
	(common_view::begin): Disable non-const overload for simple
	views as per LWG 4012.
	(common_view::end): Likewise.
	(adjacent_view::base): Define as per LWG 3848.
	(adjacent_transform_view::base): Likewise.
	(chunk_view::_InnerIter::iter_move): Define as per LWG 3851.
	(chunk_view::_InnerIter::itep_swap): Likewise.
	(slide_view::base): Define as per LWG 3848.
	(repeat_view): Adjust deduction guide as per LWG 4053.
	(_Repeat::operator()): Adjust single-parameter overload as per
	LWG 4054.
	* testsuite/std/ranges/adaptors/adjacent/1.cc: Verify existence
	of base member function.
	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk/1.cc: Test LWG 3851 example.
	* testsuite/std/ranges/adaptors/slide/1.cc: Verify existence of
	base member function.
	* testsuite/std/ranges/iota/iota_view.cc: Test LWG 4001 example.
	* testsuite/std/ranges/repeat/1.cc: Test LWG 4053/4054 examples.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 20165d0107)
2024-10-21 21:38:40 -04:00
Patrick Palka be56fee60a libstdc++: Add some missing ranges feature-test macro tests
libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/contains/1.cc: Verify value of
	__cpp_lib_ranges_contains.
	* testsuite/25_algorithms/find_last/1.cc: Verify value of
	__cpp_lib_ranges_find_last.
	* testsuite/25_algorithms/iota/1.cc: Verify value of
	__cpp_lib_ranges_iota.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 8e0da56f18)
2024-10-21 21:38:40 -04:00
Patrick Palka 0b2f2a7e12 libstdc++: Implement P2997R1 changes to the indirect invocability concepts
This implements the changes of this C++26 paper as a DR against C++20.

In passing this patch removes the std/ranges/version_c++23.cc test which
is now mostly obsolete after the version.def FTM refactoring, and instead
expands the __cpp_lib_ranges checks in another test so that it verifies
the exact value of the FTM on a per language version basis.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (indirectly_unary_invocable):
	Relax as per P2997R1.
	(indirectly_regular_unary_invocable): Likewise.
	(indirect_unary_predicate): Likewise.
	(indirect_binary_predicate): Likewise.
	(indirect_equivalence_relation): Likewise.
	(indirect_strict_weak_order): Likewise.
	* include/bits/version.def (ranges): Update value for C++26.
	* include/bits/version.h: Regenerate.
	* testsuite/24_iterators/indirect_callable/p2997r1.cc: New test.
	* testsuite/std/ranges/version_c++23.cc: Remove.
	* testsuite/std/ranges/headers/ranges/synopsis.cc: Refine the
	__cpp_lib_ranges checks.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 620232426b)
2024-10-21 21:13:04 -04:00
Patrick Palka 3795ac860b libstdc++: Implement P2609R3 changes to the indirect invocability concepts
This implements the changes of this C++23 paper as a DR against C++20.

Note that after the later P2538R1 "ADL-proof std::projected" (which we
already implement), we can't use a simple partial specialization to match
specializations of the 'projected' alias template.  So instead we identify
such specializations using a pair of distinguishing member aliases.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__detail::__indirect_value):
	Define.
	(__indirect_value_t): Define as per P2609R3.
	(iter_common_reference_t): Adjust as per P2609R3.
	(indirectly_unary_invocable): Likewise.
	(indirectly_regular_unary_invocable): Likewise.
	(indirect_unary_predicate): Likewise.
	(indirect_binary_predicate): Likewise.
	(indirect_equivalence_relation): Likewise.
	(indirect_strict_weak_order): Likewise.
	(__detail::__projected::__type): Define member aliases
	__projected_Iter and __projected_Proj providing the
	template arguments of the current specialization.
	* include/bits/version.def (ranges): Update value.
	* include/bits/version.h: Regenerate.
	* testsuite/24_iterators/indirect_callable/p2609r3.cc: New test.
	* testsuite/std/ranges/version_c++23.cc: Update expected value
	of __cpp_lib_ranges macro.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit b552730faf)
2024-10-21 21:13:04 -04:00
GCC Administrator 04c9cbe49f Daily bump. 2024-10-22 00:26:16 +00:00
Richard Biener 44c3eba2df tree-optimization/117104 - add missed guards to max(a,b) != a simplification
For vector types we have to make sure the comparison result is a vector
type and the resulting compare operation is supported.  As the resulting
compare is never an equality compare I didn't bother to check for the
cbranch case.

	PR tree-optimization/117104
	* match.pd ((cmp:c (minmax:c @0 @1) @0) -> (out @0 @1)): Properly
	guard the vector case.

	* gcc.dg/pr117104.c: New testcase.

(cherry picked from commit f54d42e000)
2024-10-21 12:47:12 +02:00
Richard Biener 1d11536881 tree-optimization/116982 - analyze scalar loop exit early
The following makes sure to discover the scalar loop IV exit during
analysis as failure to do so (if DCE and friends are disabled this
can happen due to if-conversion doing DCE and FRE on the if-converted
loop) would ICE later.

I refrained from larger refactoring to be able to eventually backport.

	PR tree-optimization/116982
	* tree-vectorizer.h (vect_analyze_loop): Pass in .LOOP_VECTORIZED
	call.
	(vect_analyze_loop_form): Likewise.
	* tree-vect-loop.cc (vect_analyze_loop_form): Reject loops where we
	cannot determine a IV exit for the scalar loop.
	(vect_analyze_loop): Adjust.
	* tree-vectorizer.cc (try_vectorize_loop_1): Likewise.
	* tree-parloops.cc (gather_scalar_reductions): Likewise.

(cherry picked from commit 9b86efd521)
2024-10-21 12:47:11 +02:00
Richard Biener a4744558b6 tree-optimization/116907 - stale BLOCK reference from DECL_VALUE_EXPR
When we remove unused BLOCKs we fail to clean references to them
from DECL_VALUE_EXPRs of variables in other BLOCKs which in the
PR causes LTO streaming to walk into pointers to GGC freed blocks.

There's the question of whether such DECL_VALUE_EXPRs should keep
variables and blocks referenced live (it doesn't seem to do that)
and whether such DECL_VALUE_EXPRs should have survived in the
first place.

	PR tree-optimization/116907
	* tree-ssa-live.cc (clear_unused_block_pointer_in_block): New
	helper.
	(clear_unused_block_pointer): Call it.

(cherry picked from commit 7d15248d41)
2024-10-21 12:47:11 +02:00
Richard Biener 8d8b8ed783 tree-optimization/116481 - avoid building function_type[]
The following avoids building an array type with function or method
element type during diagnosing an array bound violation as this
will result in an error, rejecting a program with a not too useful
error message.  Instead build such array type manually.

	PR tree-optimization/116481
	* pointer-query.cc (build_printable_array_type):
	Build an array types with function or method element type
	manually to avoid bogus diagnostic.

	* gcc.dg/pr116481.c: New testcase.

(cherry picked from commit 1506027347)
2024-10-21 12:47:11 +02:00
Richard Biener 69934cb171 tree-optimization/116290 - fix compare-debug issue in ldist
Loop distribution does different analysis with -g0/-g due to counting
a debug stmt starting a BB against a limit which will everntually
lead to different IVOPTs choices.  I've fixed a possible IVOPTs
issue on the way even though it doesn't make a difference here.

	PR tree-optimization/116290
	* tree-loop-distribution.cc (determine_reduction_stmt_1): PHIs
	have no debug variants.  Start with first non-debug real stmt.
	* tree-ssa-loop-ivopts.cc (find_givs_in_bb): Do not analyze
	debug stmts.

	* gcc.dg/pr116290.c: New testcase.

(cherry picked from commit 566740013b)
2024-10-21 12:47:11 +02:00
Richard Biener 2ac6159f8b middle-end/115110 - Fix view_converted_memref_p
view_converted_memref_p was checking the reference type against the
pointer type of the offset operand rather than its pointed-to type
which leads to all refs being subject to view-convert treatment
in get_alias_set causing numerous testsuite fails but with its
new uses from r15-512-g9b7cad5884f21c is also a wrong-code issue.

	PR middle-end/115110
	* tree-ssa-alias.cc (view_converted_memref_p): Fix.

(cherry picked from commit a5b3721c06)
2024-10-21 12:47:11 +02:00
Jeevitha 17f1277d78 rs6000: Correct the function code for _AMO_LD_DEC_BOUNDED
Corrected the function code for the Atomic Memory Operation "Fetch and Decrement
Bounded", changing it from 0x1A to 0x1C.

2024-10-11 Jeevitha Palanisamy <jeevitha@linux.ibm.com>

gcc/

	* config/rs6000/amo.h (enum _AMO_LD): Correct the function code for
	_AMO_LD_DEC_BOUNDED.

(cherry picked from commit 1a4c5643a5)
2024-10-21 03:54:03 -05:00
liuhongt 79e7e02b7c Refine splitters related to "combine vpcmpuw + zero_extend to vpcmpuw"
r12-6103-g1a7ce8570997eb combines vpcmpuw + zero_extend to vpcmpuw
with the pre_reload splitter, but the splitter transforms the
zero_extend into a subreg which make reload think the upper part is
garbage, it's not correct.

The patch adjusts the zero_extend define_insn_and_split to
define_insn to keep zero_extend.

gcc/ChangeLog:

	PR target/117159
	* config/i386/sse.md
	(*<avx512>_cmp<V48H_AVX512VL:mode>3_zero_extend<SWI248x:mode>):
	Change from define_insn_and_split to define_insn.
	(*<avx512>_cmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>):
	Ditto.
	(*<avx512>_ucmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>):
	Ditto.
	(*<avx512>_ucmp<VI48_AVX512VL:mode>3_zero_extend<SWI248x:mode>):
	Ditto.
	(*<avx512>_cmp<V48H_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2):
	Split to the zero_extend pattern.
	(*<avx512>_cmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2):
	Ditto.
	(*<avx512>_ucmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2):
	Ditto.
	(*<avx512>_ucmp<VI48_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2):
	Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr117159.c: New test.
	* gcc.target/i386/avx512bw-pr103750-1.c: Remove xfail.
	* gcc.target/i386/avx512bw-pr103750-2.c: Remove xfail.

(cherry picked from commit 5259d3927c)
2024-10-21 10:29:14 +08:00
GCC Administrator 809a58229a Daily bump. 2024-10-21 00:23:25 +00:00
GCC Administrator 2eb68180aa Daily bump. 2024-10-20 00:23:05 +00:00
GCC Administrator e2df2ca340 Daily bump. 2024-10-19 00:24:39 +00:00
Martin Jambor f057e95873 ipa: Treat static constructors and destructors as non-local (PR 115815)
In PR 115815, IPA-SRA thought it had control over all invocations of a
(recursive) static destructor but it did not see the implied
invocation which led to the original being left behind and the
clean-up code encountering uses of SSAs that definitely should have
been dead.

Fixed by teaching cgraph_node::can_be_local_p about static
constructors and destructors.  Similar test is missing in
cgraph_node::local_p so I added the check there as well.

In addition to the commit with the fix, this backport also contains
squashed commit 1a458bdeb2 which fixes
dejagnu directives in the testcase.

gcc/ChangeLog:

2024-07-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/115815
	* cgraph.cc (cgraph_node_cannot_be_local_p_1): Also check
	DECL_STATIC_CONSTRUCTOR and DECL_STATIC_DESTRUCTOR.
	* ipa-visibility.cc (non_local_p): Likewise.
	(cgraph_node::local_p): Delete extraneous line of tabs.

gcc/testsuite/ChangeLog:

2024-07-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/115815
	* gcc.dg/lto/pr115815_0.c: New test.

(cherry picked from commit e98ad6a049)
2024-10-18 21:34:51 +02:00
Li Xu ab465ce3a9 RISC-V:Bugfix for C++ code compilation failure with rv32imafc_zve32f[pr116883]
From: xuli <xuli1@eswincomputing.com>

Example as follows:

int main()
{
  unsigned long arraya[128], arrayb[128], arrayc[128];
  for (int i = 0; i < 128; i++)
   {
      arraya[i] = arrayb[i] + arrayc[i];
   }
  return 0;
}

Compiled with -march=rv32imafc_zve32f -mabi=ilp32f, it will cause a compilation issue:

riscv_vector.h:40:25: error: ambiguating new declaration of 'vint64m4_t __riscv_vle64(vbool16_t, const long long int*, unsigned int)'
   40 | #pragma riscv intrinsic "vector"
      |                         ^~~~~~~~
riscv_vector.h:40:25: note: old declaration 'vint64m1_t __riscv_vle64(vbool64_t, const long long int*, unsigned int)'

With zvl=32b, vbool16_t is registered in init_builtins() with
type_common.precision=0x101 (nunits=2), mode_nunits[E_RVVMF16BI]=[2,2].

Normally, vbool64_t is only valid when TARGET_MIN_VLEN > 32, so vbool64_t
is not registered in init_builtins(), meaning vbool64_t=null.

In order to implement __attribute__((target("arch=+v"))), we must register
all vector types and all RVV intrinsics. Therefore, vbool64_t will be registered
by default with zvl=128b in reinit_builtins(), resulting in
type_common.precision=0x101 (nunits=2) and mode_nunits[E_RVVMF64BI]=[2,2].

We then get TYPE_VECTOR_SUBPARTS(vbool16_t) == TYPE_VECTOR_SUBPARTS(vbool64_t),
calculated using type_common.precision, resulting in 2. Since vbool16_t and
vbool64_t have the same element type (boolean_type), the compiler treats them
as the same type, leading to a re-declaration conflict.

After all types and intrinsics have been registered, processing
__attribute__((target("arch=+v"))) will update the parameters option and
init_adjust_machine_modes. Therefore, to avoid conflicts, we can choose
zvl=4096b for the null type reinit_builtins().

command option zvl=32b
  type         nunits
  vbool64_t => null
  vbool32_t=> [1,1]
  vbool16_t=> [2,2]
  vbool8_t=>  [4,4]
  vbool4_t=>  [8,8]
  vbool2_t=>  [16,16]
  vbool1_t=>  [32,32]

reinit zvl=128b
  vbool64_t => [2,2] conflict with zvl32b vbool16_t=> [2,2]
reinit zvl=256b
  vbool64_t => [4,4] conflict with zvl32b vbool8_t=>  [4,4]
reinit zvl=512b
  vbool64_t => [8,8] conflict with zvl32b vbool4_t=>  [8,8]
reinit zvl=1024b
  vbool64_t => [16,16] conflict with zvl32b vbool2_t=>  [16,16]
reinit zvl=2048b
  vbool64_t => [32,32] conflict with zvl32b vbool1_t=>  [32,32]
reinit zvl=4096b
  vbool64_t => [64,64] zvl=4096b is ok

Signed-off-by: xuli <xuli1@eswincomputing.com>

	PR target/116883

gcc/ChangeLog:

	* config/riscv/riscv-c.cc (riscv_pragma_intrinsic_flags_pollute): Choose zvl4096b
	to initialize null type.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/pr116883.C: New test.

(cherry picked from commit fd8e590ff1)
2024-10-18 08:30:21 +00:00
Patrick Palka c468a0051a c++: checking ICE w/ constexpr if and lambda as def targ [PR117054]
Here we're tripping over the assert in extract_locals_r which enforces
that an extra-args tree appearing inside another extra-args tree doesn't
actually have extra args.  This invariant doesn't always hold for lambdas
(which recently gained the extra-args mechanism) but that should be
harmless since cp_walk_subtrees doesn't walk LAMBDA_EXPR_EXTRA_ARGS and
so should be immune to the PR114303 issue for now.  So let's just disable
this assert for lambdas.

	PR c++/117054

gcc/cp/ChangeLog:

	* pt.cc (extract_locals_r): Disable tree_extra_args assert
	for LAMBDA_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ9.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit bb2bfdb204)
2024-10-17 10:39:58 -04:00
Marek Polacek 36de56d3d6 c++: ICE with -Wtautological-compare in template [PR116534]
Pre r14-4793, we'd call warn_tautological_cmp -> operand_equal_p
with operands wrapped in NON_DEPENDENT_EXPR, which works, since
o_e_p bails for codes it doesn't know.  But now we pass operands
not encapsulated in NON_DEPENDENT_EXPR, and crash, because the
template tree for &a[x] has null DECL_FIELD_OFFSET.

This patch extends r12-7797 to cover the case when DECL_FIELD_OFFSET
is null.

	PR c++/116534

gcc/ChangeLog:

	* fold-const.cc (operand_compare::operand_equal_p): If either
	field's DECL_FIELD_OFFSET is null, compare the fields with ==.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wtautological-compare4.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7ca486889b)
2024-10-17 09:43:11 -04:00
Marek Polacek 0784e8934e c++: wrong error due to std::initializer_list opt [PR116476]
Here maybe_init_list_as_array gets elttype=field, init={NON_LVALUE_EXPR <2>}
and it tries to convert the init's element type (int) to field
using implicit_conversion, which works, so overall maybe_init_list_as_array
is successful.

But it constifies init_elttype so we end up with "const int".  Later,
when we actually perform the conversion and invoke field::field(T&&),
we end up with this error:

  error: binding reference of type 'int&&' to 'const int' discards qualifiers

So I think maybe_init_list_as_array should try to perform the conversion,
like it does below with fc.

	PR c++/116476

gcc/cp/ChangeLog:

	* call.cc (maybe_init_list_as_array): Try convert_like and see if it
	worked.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-opt2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 9f79c7ddff)
2024-10-17 09:42:25 -04:00
Marek Polacek 420e17e642 c++: ICE with ()-init and TARGET_EXPR eliding [PR116424]
Here we crash on a cp_gimplify_expr/TARGET_EXPR assert:

      gcc_checking_assert (!TARGET_EXPR_ELIDING_P (*expr_p)
                           || !TREE_ADDRESSABLE (TREE_TYPE (*expr_p)));

We cannot elide the TARGET_EXPR because we're taking its address.

It is set as eliding in massage_init_elt.  I've tried to not set
TARGET_EXPR_ELIDING_P when the context is not direct-initialization.
That didn't work: even when it's not direct-initialization now, it
can become one later, for instance, after split_nonconstant_init.
One problem is that replace_placeholders_for_class_temp_r will replace
placeholders in non-eliding TARGET_EXPRs with the slot, but if we then
elide the TARGET_EXPR, we end up with a "stray" VAR_DECL and crash.
(Only some TARGET_EXPRs are handled by replace_decl.)

I thought I'd have to go back to
<https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651163.html> but
then I realized that this problem occurrs only with ()-init but not
{}-init.  With {}-init, there is no problem, because we are clearing
TARGET_EXPR_ELIDING_P in process_init_constructor_record:

       /* We can't actually elide the temporary when initializing a
          potentially-overlapping field from a function that returns by
          value.  */
       if (ce->index
           && TREE_CODE (next) == TARGET_EXPR
           && unsafe_copy_elision_p (ce->index, next))
         TARGET_EXPR_ELIDING_P (next) = false;

But that does not happen for ()-init because we have no ce->index.
()-init doesn't allow brace elision so we don't really reshape them.

But I can just move the clearing a few lines down and then it handles
both ()-init and {}-init.

	PR c++/116424

gcc/cp/ChangeLog:

	* typeck2.cc (process_init_constructor_record): Move the clearing of
	TARGET_EXPR_ELIDING_P down.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/paren-init38.C: New test.

(cherry picked from commit 15f857af29)
2024-10-17 09:41:50 -04:00
Uros Bizjak 8be94d5643 i386: Fix expand_vector_set for VEC_MERGE/VEC_DUPLICATE RTX [PR117116]
Middle end can generate SYMBOL_REF RTX as a value "val" in the call
to expand_vector_set, but SYMBOL_REF RTX is not accepted in
<sse2p4_1>_pinsr<ssemodesuffix> insn pattern, generated via
VEC_MERGE/VEC_DUPLICATE RTX path.

Force the value into a register before VEC_MERGE/VEC_DUPLICATE RTX
is generated if it doesn't satisfy nonimmediate_operand predicate.

	PR target/117116

gcc/ChangeLog:

	* config/i386/i386-expand.cc (expand_vector_set): Force "val"
	into a register before VEC_MERGE/VEC_DUPLICATE RTX is generated
	if it doesn't satisfy nonimmediate_operand predicate.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 80d7032067)
2024-10-16 16:15:40 +02:00
GCC Administrator ed664f8d76 Daily bump. 2024-10-16 11:42:29 +00:00
Jonathan Wakely 23480efbab libstdc++: Fix Python deprecation warning in printers.py
python/libstdcxx/v6/printers.py:1355: DeprecationWarning: 'count' is passed as positional argument

The Python docs say:

  Deprecated since version 3.13: Passing count and flags as positional
  arguments is deprecated. In future Python versions they will be
  keyword-only parameters.

Using a keyword argument for count only became possible with Python 3.1
so introduce a new function to do the substitution.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (strip_fundts_namespace): New.
	(StdExpAnyPrinter, StdExpOptionalPrinter): Use it.

(cherry picked from commit b9e98bb991)
2024-10-16 10:12:24 +01:00
Jonathan Wakely f1cee9d1a0 libstdc++: Increase timeouts for PSTL tests in debug mode [PR90276]
These tests compile very slowly in debug mode.

libstdc++-v3/ChangeLog:

	PR libstdc++/90276
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Increase timeout for debug mode.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/set_symmetric_difference.cc:
	Likewise.

(cherry picked from commit e65b6627a3)
2024-10-16 09:17:31 +01:00
Jonathan Wakely 4d8a55ac55 libstdc++: Implement LWG 3564 for ranges::transform_view
The _Iterator<true> type returned by begin() const uses const F& to
transform the elements, so it should use const F& to determine the
iterator's value_type and iterator_category as well.

This was accepted into the WP in July 2022.

libstdc++-v3/ChangeLog:

	* include/std/ranges (transform_view:_Iterator): Use const F&
	to determine value_type and iterator_category of
	_Iterator<true>, as per LWG 3564.
	* testsuite/std/ranges/adaptors/transform.cc: Check value_type
	and iterator_category.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit dde19c600c)
2024-10-15 21:52:04 +01:00
Jonathan Wakely f1436fde43 libstdc++: Fix localized %c formatting for <chrono> [PR117085]
When formatting a time point with %c we call std::vformat_to using the
formatting locale's D_T_FMT string, but we weren't adding the L option
to the format string. This meant we always interpreted D_T_FMT in the C
locale, instead of using the formatting locale as obviously intended
when %c is used.

libstdc++-v3/ChangeLog:

	PR libstdc++/117085
	* include/bits/chrono_io.h (__formatter_chrono::_M_c): Add L
	option to format string.
	* testsuite/std/time/format.cc: Move to...
	* testsuite/std/time/format/format.cc: ...here.
	* testsuite/std/time/format/pr117085.cc: New test.

(cherry picked from commit 4ad697bb7f)
2024-10-15 21:50:46 +01:00
Jonathan Wakely 7836113ff4 libstdc++: Tweak %c formatting for chrono types
libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono::_M_c): Add
	[[unlikely]] attribute to condition for missing %c format in
	locale. Use %T instead of %H:%M:%S in fallback.

(cherry picked from commit ce89d2f317)
2024-10-15 21:49:44 +01:00
Jonathan Wakely 8f181a2f87 libstdc++: Populate generic std::time_get's wide %c format [PR117135]
I missed out the __timepunct<wchar_t> specialization for the "generic"
implementation when defining the %c format in r15-4016-gc534e37faccf48.

libstdc++-v3/ChangeLog:

	PR libstdc++/117135
	* config/locale/generic/time_members.cc
	(__timepunct<wchar_t>::_M_initialize_timepunc): Set
	_M_date_time_format for C locale. Set %Ex formats to the same
	values as the %x formats.

(cherry picked from commit 707d84efee)
2024-10-15 21:45:51 +01:00
Jonathan Wakely cbb1814ffa libstdc++: Use std::move for iterator in ranges::fill [PR117094]
Input iterators aren't required to be copyable.

libstdc++-v3/ChangeLog:

	PR libstdc++/117094
	* include/bits/ranges_algobase.h (__fill_fn): Use std::move for
	iterator that might not be copyable.
	* testsuite/25_algorithms/fill/constrained.cc: Check
	non-copyable iterator with sized sentinel.

(cherry picked from commit 03623fa91f)
2024-10-15 21:45:51 +01:00
Victor Do Nascimento abbfe1e261 middle-end: Fix ifcvt predicate generation for masked function calls
Up until now, due to a latent bug in the code for the ifcvt pass,
irrespective of the branch taken in a conditional statement, the
original condition for the if statement was used in masking the
function call.

Thus, for code such as:

  if (a[i] > limit)
    b[i] = fixed_const;
  else
    b[i] = fn (a[i]);

we would generate the following (wrong) if-converted tree code:

  _1 = a[i_1];
  _2 = _1 > limit;
  _3 = .MASK_CALL (fn, _1, _2);
  cstore_4 = _2 ? fixed_const : _3;

as opposed to the correct expected sequence:

  _1 = a[i_1];
  _2 = _1 > limit;
  _3 = ~_2;
  _4 = .MASK_CALL (fn, _1, _3);
  cstore_5 = _2 ? fixed_const : _4;

This patch ensures that the correct predicate mask generation is
carried out such that, upon autovectorization, the correct vector
lanes are selected in the vectorized function call.

gcc/ChangeLog:

	* tree-if-conv.cc (predicate_statements): Fix handling of
	predicated function calls.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-fncall-mask.c: New.
2024-10-15 12:29:54 +01:00
Jan Hubicka f0629e3227 Fix handling of ICF_NOVOPS in ipa-modref
As shown in somewhat convoluted testcase, ipa-modref is mistreating
ECF_NOVOPS as "having no side effects".  This come from time when
modref cared only about memory accesses and thus it was possible to
shortcut on it.

This patch removes (hopefully) all those bad shortcuts.
Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

	PR ipa/109985

	* ipa-modref.cc (modref_summary::useful_p): Fix handling of ECF_NOVOPS.
	(modref_access_analysis::process_fnspec): Likevise.
	(modref_access_analysis::analyze_call): Likevise.
	(propagate_unknown_call): Likevise.
	(modref_propagate_in_scc): Likevise.
	(modref_propagate_flags_in_scc): Likewise.
	(ipa_merge_modref_summary_after_inlining): Likewise.

(cherry picked from commit efcbe7b985)
2024-10-15 01:11:47 +01:00
Richard Sandiford a9ab9b6450 aarch64: Fix caller saves of VNx2QI [PR116238]
The testcase contains a VNx2QImode pseudo that is live across a call
and that cannot be allocated a call-preserved register.  LRA quite
reasonably tried to save it before the call and restore it afterwards.
Unfortunately, the target told it to do that in SImode, even though
punning between SImode and VNx2QImode is disallowed by both
TARGET_CAN_CHANGE_MODE_CLASS and TARGET_MODES_TIEABLE_P.

The natural class to use for SImode is GENERAL_REGS, so this led
to an unsalvageable situation in which we had:

  (set (subreg:VNx2QI (reg:SI A) 0) (reg:VNx2QI B))

where A needed GENERAL_REGS and B needed FP_REGS.  We therefore ended
up in a reload loop.

The hooks above should ensure that this situation can never occur
for incoming subregs.  It only happened here because the target
explicitly forced it.

The decision to use SImode for modes smaller than 4 bytes dates
back to the beginning of the port, before 16-bit floating-point
modes existed.  I'm not sure whether promoting to SImode really
makes sense for any FPR, but that's a separate performance/QoI
discussion.  For now, this patch just disallows using SImode
when it is wrong for correctness reasons, since that should be
safer to backport.

gcc/
	PR testsuite/116238
	* config/aarch64/aarch64.cc (aarch64_hard_regno_caller_save_mode):
	Only return SImode if we can convert to and from it.

gcc/testsuite/
	PR testsuite/116238
	* gcc.target/aarch64/sve/pr116238.c: New test.

(cherry picked from commit ec9d6d4519)
2024-10-14 13:29:34 +01:00
Eric Botcazou b62c956f77 Add regression test
gcc/testsuite/
	PR ada/114593
	* gnat.dg/specs/generic_inst2-child2.ads: New test.
	* gnat.dg/specs/generic_inst2.ads: New helper.
	* gnat.dg/specs/generic_inst2-child1.ads: Likewise.
2024-10-14 12:17:38 +02:00
Steve Baird aff061f0f5 ada: Type conversion in instance incorrectly rejected.
In some cases, a legal type conversion in a generic package is correctly
accepted but the corresponding type conversion in an instance of the generic
is incorrectly rejected.

gcc/ada/
	PR ada/114593
	* sem_res.adb (Valid_Conversion): Test In_Instance instead of
	In_Instance_Body.
2024-10-14 12:17:09 +02:00
liuhongt 9b7d5ecbec Add a new tune avx256_avoid_vec_perm for SRF.
According to Intel SOM[1], For Crestmont,  most 256-bit Intel AVX2
instructions can be decomposed into two independent 128-bit
micro-operations, except for a subset of Intel AVX2 instructions,
known as cross-lane operations, can only compute the result for an
element by utilizing one or more sources belonging to other elements.

The 256-bit instructions listed below use more operand sources than
can be natively supported by a single reservation station within these
microarchitectures. They are decomposed into two μops, where the first
μop resolves a subset of operand dependencies across two cycles. The
dependent second μop executes the 256-bit operation by using a single
128-bit execution port for two consecutive cycles with a five-cycle
latency for a total latency of seven cycles.

VPERM2I128 ymm1, ymm2, ymm3/m256, imm8
VPERM2F128 ymm1, ymm2, ymm3/m256, imm8
VPERMPD ymm1, ymm2/m256, imm8
VPERMPS ymm1, ymm2, ymm3/m256
VPERMD ymm1, ymm2, ymm3/m256
VPERMQ ymm1, ymm2/m256, imm8

Instead of setting tune avx128_optimal for SRF, the patch add a new
tune avx256_avoid_vec_perm for it. so by default, vectorizer still
uses 256-bit VF if cost is profitable, but lowers to 128-bit whenever
256-bit vec_perm is needed for auto-vectorization. w/o vec_perm,
performance of 256-bit vectorization should be similar as 128-bit
ones(some benchmark results show it's even better than 128-bit
vectorization since it enables more parallelism for convert cases.)

[1] https://www.intel.com/content/www/us/en/content-details/814198/intel-64-and-ia-32-architectures-optimization-reference-manual-volume-1.html

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_vector_costs::ix86_vector_costs):
	Add new member m_num_avx256_vec_perm.
	(ix86_vector_costs::add_stmt_cost): Record 256-bit vec_perm.
	(ix86_vector_costs::finish_cost): Prevent vectorization for
	TAREGT_AVX256_AVOID_VEC_PERM when there's 256-bit vec_perm
	instruction.
	* config/i386/i386.h (TARGET_AVX256_AVOID_VEC_PERM): New
	Macro.
	* config/i386/x86-tune.def (X86_TUNE_AVX256_SPLIT_REGS): Add
	m_CORE_ATOM.
	(X86_TUNE_AVX256_AVOID_VEC_PERM): New tune.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 9eaecce3d8)
2024-10-14 13:19:32 +08:00
liuhongt fe0692f689 Add new microarchitecture tune for SRF/GRR/CWF.
For Crestmont, 4-operand vex blendv instructions come from MSROM and
is slower than 3-instructions sequence (op1 & mask) | (op2 & ~mask).
legacy blendv instruction can still be handled by the decoder.

The patch add a new tune which is enabled for all processors except
for SRF/CWF. It will use vpand + vpandn + vpor instead of
vpblendvb(similar for vblendvps/vblendvpd) for SRF/CWF.

gcc/ChangeLog:

	* config/i386/i386-expand.cc (ix86_expand_sse_movcc): Guard
	instruction blendv generation under new tune.
	* config/i386/i386.h (TARGET_SSE_MOVCC_USE_BLENDV): New Macro.
	* config/i386/x86-tune.def (X86_TUNE_SSE_MOVCC_USE_BLENDV):
	New tune.

(cherry picked from commit 9c8cea8feb)
2024-10-14 13:19:32 +08:00
GCC Administrator 20131c1cb5 Daily bump. 2024-10-14 00:22:05 +00:00
Sam James d8ac855f79 testsuite: fix PR111613 test
PR ipa/111613
	* gcc.c-torture/pr111613.c: Rename to..
	* gcc.c-torture/execute/pr111613.c: ...this.

(cherry picked from commit 5e5d7a8893)
2024-10-13 22:43:33 +01:00
Richard Biener 81fd5bfdcb tree-optimization/117041 - fix load classification of former grouped load
When we first detect a grouped load but later dis-associate it we
only set DR_GROUP_FIRST_ELEMENT to NULL, indicating it is not a
STMT_VINFO_GROUPED_ACCESS but leave DR_GROUP_NEXT_ELEMENT set.  This
causes a stray DR_GROUP_NEXT_ELEMENT access in get_group_load_store_type
to go wrong, indicating a load isn't single_element_p when it actually
is, leading to wrong classification and an ICE.

	PR tree-optimization/117041
	* tree-vect-stmts.cc (get_group_load_store_type): Only
	check DR_GROUP_NEXT_ELEMENT for STMT_VINFO_GROUPED_ACCESS.

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

(cherry picked from commit 72c83f644d)
2024-10-13 11:21:54 +02:00
Richard Biener 6638d6ed0f middle-end/117086 - fixup vec_cond simplifications
The following adds missing checks for a vector type result type
to simplifications that end up creating a vec_cond.

	PR middle-end/117086
	* match.pd ((op (vec_cond ...) ..) -> (vec_cond ...)): Add
	missing checks for VECTOR_TYPE_P (type).

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

(cherry picked from commit c64ae83772)
2024-10-13 11:21:35 +02:00
Richard Biener 50d0fda490 tree-optimization/116990 - missed control flow check in vect_analyze_loop_form
The following fixes checking for unsupported control flow in
vectorization to also cover the outer loop body.

	PR tree-optimization/116990
	* tree-vect-loop.cc (vect_analyze_loop_form): Check the current
	loop body for control flow.

(cherry picked from commit b0b7161815)
2024-10-13 11:20:14 +02:00
Richard Biener ae4b9dcff3 tree-optimization/116879 - failure to recognize non-empty latch
When we relaxed the vectorizers constraint on loop structure verifying
the emptiness of the latch became too lose as can be seen in the case
for PR116879 where the latch effectively contains two basic-blocks
which one being an unmerged forwarder that's not empty.

	PR tree-optimization/116879
	* tree-vect-loop.cc (vect_analyze_loop_form): Scan all
	blocks that form the latch.

	* gcc.dg/pr116879.c: New testcase.

(cherry picked from commit 18e905b461)
2024-10-13 11:19:45 +02:00
Richard Biener 32bc20d326 tree-optimization/116850 - corrupt post-dom info
Path isolation computes post-dominators on demand but can end up
splitting blocks after that, wrecking it.  We can delay splitting
of blocks until we no longer need the post-dom info which is what
the following patch does to solve the issue.

	PR tree-optimization/116850
	* gimple-ssa-isolate-paths.cc (bb_split_points): New global.
	(insert_trap): Delay BB splitting if post-doms are computed.
	(find_explicit_erroneous_behavior): Process delayed BB
	splitting after releasing post dominators.
	(gimple_ssa_isolate_erroneous_paths): Do not free post-dom
	info here.

	* gcc.dg/pr116850.c: New testcase.

(cherry picked from commit 64163657ba)
2024-10-13 11:19:02 +02:00
Richard Biener 18bc415ae2 tree-optimization/116768 - wrong dependence analysis
The following reverts a bogus fix done for PR101009 and instead makes
sure we get into the same_access_functions () case when computing
the distance vector for g[1] and g[1] where the constants ended up
having different types.  The generic code doesn't seem to handle
loop invariant dependences.  The special case gets us both
( 0 ) and ( 1 ) as distance vectors while formerly we got ( 1 ),
which the PR101009 fix changed to ( 0 ) with bad effects on other
cases as shown in this PR.

	PR tree-optimization/116768
	* tree-data-ref.cc (build_classic_dist_vector_1): Revert
	PR101009 change.
	* tree-chrec.cc (eq_evolutions_p): Make sure (sizetype)1
	and (int)1 compare equal.

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

(cherry picked from commit 5b5a36b122)
2024-10-13 11:18:32 +02:00
Richard Biener 987a7b58bf tree-optimization/116166 - forward jump-threading going wild
Currently the forward threader isn't limited as to the search space
it explores and with it now using path-ranger for simplifying
conditions it runs into it became pretty slow for degenerate cases
like compiling insn-emit.cc for RISC-V esp. when compiling for
a host with LOGICAL_OP_NON_SHORT_CIRCUIT disabled.

The following makes the forward threader honor the search space
limit I introduced for the backward threader.  This reduces
compile-time from minutes to seconds for the testcase in PR116166.

Note this wasn't necessary before we had ranger but with ranger
the work we do is quadatic in the length of the threading path
we build up (the same is true for the backwards threader).

	PR tree-optimization/116166
	* tree-ssa-threadedge.h (jump_threader::thread_around_empty_blocks):
	Add limit parameter.
	(jump_threader::thread_through_normal_block): Likewise.
	* tree-ssa-threadedge.cc (jump_threader::thread_around_empty_blocks):
	Honor and decrement limit parameter.
	(jump_threader::thread_through_normal_block): Likewise.
	(jump_threader::thread_across_edge): Initialize limit from
	param_max_jump_thread_paths and pass it down to workers.

(cherry picked from commit 2cf89ae832)
2024-10-13 11:17:09 +02:00
Jakub Jelinek 68316afcb5 i386: Fix up ix86_expand_int_compare with TImode comparisons of SUBREGs from V8{H,B}Fmode against zero [PR116921]
The following testcase ICEs, because the ix86_expand_int_compare
optimization to use {,v}ptest assumes there are instructions for all
16-byte vector modes.  That isn't the case, we only have one for
V16QI, V8HI, V4SI, V2DI, V1TI, V4SF and V2DF, not for
V8HF nor V8BF.

The following patch fixes that by using the V8HI instruction instead
for those 2 modes.  tmp can't be a SUBREG, because it is SUBREG_REG
of another SUBREG, so we don't need to worry about gen_lowpart
failing.

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

	PR target/116921
	* config/i386/i386-expand.cc (ix86_expand_int_compare): Add a SUBREG
	to V8HImode from V8HFmode or V8BFmode before generating a ptest.

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

(cherry picked from commit 92e9e971ce)
2024-10-13 11:11:59 +02:00
Jakub Jelinek 80f1343035 range-cache: Fix ranger ICE if number of bbs increases [PR116899]
Ranger cache during initialization reserves number of basic block slots
in the m_workback vector (in an inefficient way by doing create (0)
and safe_grow_cleared (n) and truncate (0) rather than say create (n)
or reserve (n) after create).  The problem is that some passes split bbs and/or
create new basic blocks and so when one is unlucky, the quick_push into that
vector can ICE.

The following patch replaces those 4 quick_push calls with safe_push.

I've also gathered some statistics from compiling 63 gcc sources (picked those
that dependent on gimple-range-cache.h just because I had to rebuild them once
for the instrumentation), and that showed that in 81% of cases nothing has
been pushed into the vector at all (and note, not everything was small, there
were even cases with 10000+ basic blocks), another 18.5% of cases had just 1-4
elements in the vector at most, 0.08% had 5-8 and 19 out of 305386 cases
had at most 9-11 elements, nothing more.  So, IMHO reserving number of basic
block in the vector is a waste of compile time memory and with the safe_push
calls, the patch just initializes the vector to vNULL.

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

	PR middle-end/116899
	* gimple-range-cache.cc (ranger_cache::ranger_cache): Set m_workback
	to vNULL instead of creating it, growing and then truncating.
	(ranger_cache::fill_block_cache): Use safe_push rather than quick_push
	on m_workback.
	(ranger_cache::range_from_dom): Likewise.

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

(cherry picked from commit de25f1729d)
2024-10-13 11:11:59 +02:00
Jakub Jelinek 3df53e5554 range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898]
Some passes like the bitint lowering queue some statements on edges and only
commit them at the end of the pass.  If they use ranger at the same time,
the ranger might see such SSA_NAMEs and ICE on those.  The following patch
instead just punts on them.

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

	PR middle-end/116898
	* gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME
	with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead
	of failing assertion.  Formatting fix.

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

(cherry picked from commit bdbd0607d5)
2024-10-13 11:11:58 +02:00
Jakub Jelinek 31c8b82bd7 cselib: Discard useless locs of preserved VALUEs [PR116627]
remove_useless_values iteratively discards useless locs (locs of
cselib_val which refer to non-preserved VALUEs with no locations),
which in turn can make further values useless until no further VALUEs
are made useless and then discards the useless VALUEs.

Preserved VALUEs (something done during var-tracking only I think)
live in a different hash table, cselib_preserved_hash_table rather
than cselib_hash_table.  cselib_find_slot first looks up slot in
cselib_preserved_hash_table and only if not found looks it up in
cselib_hash_table (and INSERTs only into the latter), whereas preservation
of a VALUE results in move of a cselib_val from the latter to the former
hash table.

The testcase in the PR (apparently too fragile, it only reproduces on 14
branch with various flags on a single arch, not on trunk) ICEs, because
we have a preserved VALUE (QImode with (const_int 0) as one of the locs).
In a different BB SImode r2 is looked up, a non-preserved VALUE is created
for it, and the r13-2916 added code attempts to lookup also SUBREGs of that
in narrower modes, among those QImode, so adds to that SImode r2
non-preserve VALUE a new loc of (subreg:QI (value:SI) 0).  That SImode
value is considered useless, so remove_useless_value discards it, but
nothing discarded it from the preserved VALUE's loc_list, so when looking
something up in the hash table we ICE trying to derevence CSELIB_VAL
of the discarded VALUE.

I think we need to discuard useless locs even from the preserved VALUEs.
That IMHO shouldn't create any further useless VALUEs, the preserved
VALUEs are never useless, so we don't need to iterate with it, can do it
just once, but IMHO it needs to be done because actually
discard_useless_values.

The following patch does that.

2024-09-29  Jakub Jelinek  <jakub@redhat.com>

	PR target/116627
	* cselib.cc (remove_useless_values): Discard useless locs
	even from preserved cselib_vals in cselib_preserved_hash_table
	hash table.

(cherry picked from commit 73726725ae)
2024-10-13 11:11:58 +02:00
Jakub Jelinek 11195a9e0a i386: Fix up _mm_min_ss etc. handling of zeros and NaNs [PR116738]
min/max patterns for intrinsics which on x86 result in the second
input operand if the two operands are both zeros or one or both of them
are a NaN shouldn't use SMIN/SMAX RTL, because that is similarly to
MIN_EXPR/MAX_EXPR undefined what will be the result in those cases.

The following patch adds an expander which uses either a new pattern with
UNSPEC_IEEE_M{AX,IN} or use the S{MIN,MAX} representation of the same.

2024-09-20  Uros Bizjak  <ubizjak@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR target/116738
	* config/i386/subst.md (mask_scalar_operand_arg34,
	mask_scalar_expand_op3, round_saeonly_scalar_mask_arg3): New
	subst attributes.
	* config/i386/sse.md
	(<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
	Change from define_insn to define_expand, rename the old define_insn
	to ...
	(*<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
	... this.
	(<sse>_ieee_vm<ieee_maxmin><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
	New define_insn.

	* gcc.target/i386/sse-pr116738.c: New test.

(cherry picked from commit 624d3af025)
2024-10-13 11:11:57 +02:00
Jakub Jelinek 3ae40fa0ad c++: Don't emit deprecated/unavailable attribute diagnostics when creating cdtor thunks [PR116678]
Another spot where we mark_used a function (in this case ctor or dtor)
even when it is just artificially used inside of thunks (emitted on mingw
with -Os for the testcase).

2024-09-13  Jakub Jelinek  <jakub@redhat.com>

	PR c++/116678
	* optimize.cc: Include decl.h.
	(maybe_thunk_body): Temporarily change deprecated_state to
	UNAVAILABLE_DEPRECATED_SUPPRESS.

	* g++.dg/warn/deprecated-20.C: New test.

(cherry picked from commit b7b67732e2)
2024-10-13 11:11:57 +02:00
GCC Administrator 17ec4636f2 Daily bump. 2024-10-13 00:22:13 +00:00
GCC Administrator f15b8c925a Daily bump. 2024-10-12 00:23:39 +00:00
GCC Administrator 8794e5b19c Daily bump. 2024-10-11 00:23:22 +00:00
Richard Ball 44dc46415c aarch64: Alter pr116258.c test to correct for big endian.
The test at pr116258.c fails on big endian targets,
this is because the test checks that the index of a floating
point multiply is 0, which is correct only for little endian.

gcc/testsuite/ChangeLog:

	PR tree-optimization/116258
	* gcc.target/aarch64/pr116258.c:
	Alter test to add big-endian support.

(cherry picked from commit a17a9bdcb3)
2024-10-10 19:21:09 +01:00
GCC Administrator c6c8455e59 Daily bump. 2024-10-10 00:23:39 +00:00
Martin Uecker 4123f546d7 c: fix crash when checking for compatibility of structures [PR116726]
When checking for compatibility of structure or union types in
tagged_types_tu_compatible_p, restore the old value of the pointer to
the top of the temporary cache after recursively calling comptypes_internal
when looping over the members of a structure of union.  While the next
iteration of the loop overwrites the pointer, I missed the fact that it can
be accessed again when types of function arguments are compared as part
of recursive type checking and the function is entered again.

	PR c/116726

gcc/c/ChangeLog:

	* c-typeck.cc (tagged_types_tu_compatible_p): Restore value
	of the cache after recursing into comptypes_internal.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr116726.c: New test.

(cherry picked from commit 9227a64495)
2024-10-09 09:18:59 +02:00
GCC Administrator f14b608614 Daily bump. 2024-10-09 00:23:40 +00:00
Eric Botcazou 70c46d8e45 Add regression test
gcc/testsuite/
	PR ada/116190
	* gnat.dg/aggr31.adb: New test.
2024-10-08 18:29:32 +02:00
Eric Botcazou f8e9c36aa3 ada: Fix wrong finalization of anonymous array aggregate
The issue arises when the aggregate consists only of iterated associations
because, in this case, its expansion uses a 2-pass mechanism which creates
a temporary that needs a fully-fledged initialization, thus running afoul
of the optimization that avoids building the initialization procedure in
the anonymous array case.

gcc/ada/ChangeLog:
	* exp_aggr.ads (Is_Two_Pass_Aggregate): New function declaration.
	* exp_aggr.adb (Is_Two_Pass_Aggregate): New function body.
	(Expand_Array_Aggregate): Call Is_Two_Pass_Aggregate to detect the
	aggregates that need the 2-pass expansion.
	* exp_ch3.adb (Expand_Freeze_Array_Type): In the anonymous array
	case, build the initialization procedure if the initial value in
	the object declaration is a 2-pass aggregate.
2024-10-08 18:26:56 +02:00
Eric Botcazou 4390e95fa5 Add regression test
gcc/testsuite/
	PR ada/115535
	* gnat.dg/put_image1.adb: New test
2024-10-08 18:22:46 +02:00
Eric Botcazou f45fc31bd6 ada: Fix negative value returned by 'Image for array with nonnegative component
The problem is that Exp_Put_Image.Build_Elementary_Put_Image_Call uses the
signedness of the base type but the size of the first subtype, hence the
discrepancy between them.

gcc/ada/ChangeLog:
	PR ada/115535
	* exp_put_image.adb (Build_Elementary_Put_Image_Call): Use the size
	of the underlying type to find the support type.
2024-10-08 18:22:30 +02:00
Eric Botcazou c9fe4eae41 ada: Fix internal error on elsif part of if-statement containing if-expression
The problem occurs when the compiler is trying to find a context to which
it can hoist finalization actions coming from the if-expression, because
Find_Hook_Context incorrectly returns the N_Elsif_Part node.

gcc/ada/ChangeLog:
	PR ada/114640
	* exp_util.adb (Find_Hook_Context): For a node present within a
	conditional expression, do not return an N_Elsif_Part node.
2024-10-08 18:20:48 +02:00
Eric Botcazou 932d1c3adb Add regression test
gcc/testsuite/
	PR ada/114636
	* gnat.dg/specs/generic_inst1.ads: New test.
2024-10-08 18:13:59 +02:00
Eric Botcazou 89d2007d21 ada: Fix bogus error in instantiation with formal package
The compiler reports that an actual does not match the formal when there
is a defaulted formal discrete type because Check_Formal_Package_Instance
fails to skip the implicit base type generated by the compiler.

gcc/ada/ChangeLog:
	PR ada/114636
	* sem_ch12.adb (Check_Formal_Package_Instance): For a defaulted
	formal discrete type, skip the generated implicit base type.
2024-10-08 18:13:45 +02:00
Jan Beulich 965ee6a822 x86/{,V}AES: adjust when to force EVEX encoding
Commit a79d13a01f ("i386: Fix aes/vaes patterns [PR114576]") correctly
said "..., but we need to emit {evex} prefix in the assembly if AES ISA
is not enabled". Yet it did so only for the TARGET_AES insns. Going from
the alternative chosen in the TARGET_VAES insns isn't quite right: If
AES is (also) enabled, EVEX encoding would needlessly be forced.

gcc/

	* config/i386/sse.md (vaesdec_<mode>, vaesdeclast_<mode>,
	vaesenc_<mode>, vaesenclast_<mode>): Replace which_alternative
	check by TARGET_AES one.
2024-10-08 16:07:24 +02:00
GCC Administrator 5779e04088 Daily bump. 2024-10-08 00:22:43 +00:00
GCC Administrator 4af44f2cf7 Daily bump. 2024-10-07 00:21:34 +00:00
GCC Administrator f70e2910e3 Daily bump. 2024-10-06 00:26:10 +00:00
John David Anglin 27582d4a68 hppa: Fix indirect_goto constraint
Noticed testing LRA.

2024-10-05  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.md: Fix indirect_got constraint.
2024-10-05 18:22:04 -04:00
GCC Administrator 6722ebb95f Daily bump. 2024-10-05 00:21:50 +00:00
H.J. Lu 1032b72548 x86: Disable stack protector for naked functions
Since naked functions should not enable stack protector, define
TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable stack protector
for naked functions.

gcc/

	PR target/116962
	* config/i386/i386.cc (ix86_stack_protect_runtime_enabled_p): New
	function.
	(TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): New.

gcc/testsuite/

	PR target/116962
	* gcc.target/i386/pr116962.c: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 7d2845da11)
2024-10-05 03:25:25 +08:00
Georg-Johann Lay 93a6fab364 AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.
PR target/116953
gcc/
	* config/avr/avr.cc (avr_out_sbxx_branch): Work on a copy of
	the operands rather than on operands itself, which is just
	recog_data.operand and may be clobbered by jump_over_one_insn_p.
gcc/testsuite/
	* gcc.target/avr/torture/pr116953.c: New test.

(cherry picked from commit 58b9024c99)
2024-10-04 20:34:47 +02:00
Eric Botcazou 7363d73e26 Fix crash with subunit of local package
This is a regression present on the 14 branch only: the expander gets
confused when trying to insert the finalizer of a procedure that contains
a package as a subunit.  The offending code no longer exists on the
mainline so this adds the minimal fix to address the issue.

gcc/ada
	PR ada/116430
	* exp_ch7.adb (Build_Finalizer.Create_Finalizer): For the insertion
	point of the finalizer, deal with package bodies that are subunits.
2024-10-04 11:29:31 +02:00
GCC Administrator 83bd0d9971 Daily bump. 2024-10-04 00:23:08 +00:00
Jonathan Wakely 4ef6b95d5d libstdc++: Make debug sequence members mutable [PR116369]
We need to be able to attach debug mode iterators to const containers,
so the safe iterator constructor uses const_cast to get a modifiable
pointer to the container. If the container was defined as const, that
const_cast to access its members results in undefined behaviour.  PR
116369 shows a case where it results in a segfault because the container
is in a rodata section (which shouldn't have happened, but the undefined
behaviour in the library still exists in any case).

This makes the _M_iterators and _M_const_iterators data members mutable,
so that it's safe to modify them even if the declared type of the
container is a const type.

Ideally we would not need the const_cast at all. Instead, the _M_attach
member (and everything it calls) should be const-qualified. That would
work fine now, because the members that it ends up modifying are
mutable. Making that change would require a number of new exports from
the shared library, and would require retaining the old non-const member
functions (maybe as symbol aliases) for backwards compatibility. That
might be worth changing at some point, but isn't done here.

libstdc++-v3/ChangeLog:

	PR c++/116369
	* include/debug/safe_base.h (_Safe_sequence_base::_M_iterators):
	Add mutable specifier.
	(_Safe_sequence_base::_M_const_iterators): Likewise.

(cherry picked from commit a35dd276cb)
2024-10-03 11:48:59 +01:00
Kim Gräsman ab9ab537b1 libstdc++: Fix @headername for bits/cpp_type_traits.h
There is no file ext/type_traits, point it to ext/type_traits.h instead.

libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h: Improve doxygen file docs.

(cherry picked from commit f6ed7a61a7)
2024-10-03 11:48:27 +01:00
Kim Gräsman 09f789660e libstdc++: Fix @file for target-specific opt_random.h
A few of these files self-identified as ext/random.tcc, update to use
the actual basename.

libstdc++-v3/ChangeLog:

	* config/cpu/aarch64/opt/ext/opt_random.h: Improve doxygen file
	docs.
	* config/cpu/i486/opt/ext/opt_random.h: Likewise.

(cherry picked from commit c2ad7b2d52)
2024-10-03 11:48:01 +01:00
Jonathan Wakely 1982bd34cf libstdc++: Fix autoconf check for O_NONBLOCK in <fcntl.h>
I misused the AC_CHECK_DECL macro, assuming that it behaved like
AC_CHECK_DECLS and always defined a HAVE_xxx macro if the decl was
found. Instead, the [action-if-found] shell commands are needed to
defined HAVE_O_NONBLOCK explicitly.

libstdc++-v3/ChangeLog:

	* configure.ac: Fix check for O_NONBLOCK.
	* config.h.in: Regenerate.
	* configure: Regenerate.

(cherry picked from commit b68561dd79)
2024-10-03 11:47:21 +01:00
Jonathan Wakely 1b09baab8c libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]
This function definition should not be marked as non-throwing, because
the declaration in <cxxabi.h> is potentially throwing.

Also fix whitespace.

libstdc++-v3/ChangeLog:

	PR libstdc++/116857
	* libsupc++/guard.cc (__cxa_guard_acquire): Remove
	_GLIBCXX_NOTHROW to match declaration in <cxxabi.h>.

(cherry picked from commit efdda203f5)
2024-10-03 11:45:32 +01:00
Jonathan Wakely c4253d6a17 libstdc++: Fix std::codecvt<wchar_t, char, mbstate_t> for empty dest [PR37475]
For the GNU locale model, codecvt::do_out and codecvt::do_in incorrectly
return 'ok' when the destination range is empty. That happens because
detecting incomplete output is done in the loop body, and the loop is
never even entered if to == to_end.

By restructuring the loop condition so that we check the output range
separately, we can ensure that for a non-empty source range, we always
enter the loop at least once, and detect if the destination range is too
small.

The loops also seem easier to reason about if we return immediately on
any error, instead of checking the result twice on every iteration. We
can use an RAII type to restore the locale before returning, which also
simplifies all the other member functions.

libstdc++-v3/ChangeLog:

	PR libstdc++/37475
	* config/locale/gnu/codecvt_members.cc (Guard): New RAII type.
	(do_out, do_in): Return partial if the destination is empty but
	the source is not. Use Guard to restore locale on scope exit.
	Return immediately on any conversion error.
	(do_encoding, do_max_length, do_length): Use Guard.
	* testsuite/22_locale/codecvt/in/char/37475.cc: New test.
	* testsuite/22_locale/codecvt/in/wchar_t/37475.cc: New test.
	* testsuite/22_locale/codecvt/out/char/37475.cc: New test.
	* testsuite/22_locale/codecvt/out/wchar_t/37475.cc: New test.

(cherry picked from commit 73ad57c244)
2024-10-03 11:29:36 +01:00
Jonathan Wakely c5bdd24aba libstdc++: Populate std::time_get::get's %c format for C locale
We were using the empty string "" for D_T_FMT and ERA_D_T_FMT in the C
locale, instead of "%a %b %e %T %Y" as the C standard requires. Set it
correctly for each locale implementation that defines time_members.cc.

We can also explicitly set the _M_era_xxx pointers to the same values as
the corresponding _M_xxx ones, rather than setting them to point to
identical string literals. This doesn't rely on the compiler merging
string literals, and makes it more explicit that they're the same in the
C locale.

libstdc++-v3/ChangeLog:

	* config/locale/dragonfly/time_members.cc
	(__timepunct<char>::_M_initialize_timepunc)
	(__timepunct<wchar_t>::_M_initialize_timepunc): Set
	_M_date_time_format for C locale. Set %Ex formats to the same
	values as the %x formats.
	* config/locale/generic/time_members.cc: Likewise.
	* config/locale/gnu/time_members.cc: Likewise.
	* testsuite/22_locale/time_get/get/char/5.cc: New test.
	* testsuite/22_locale/time_get/get/wchar_t/5.cc: New test.

(cherry picked from commit c534e37fac)
2024-10-03 11:26:31 +01:00
Jonathan Wakely 2f9585392d libstdc++: Add missing 'inline' to always_inline function
This fixes a -Wattributes warning for the COW std::string which was
previously suppressed due to being in a system header.

libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h (__resize_for_overwrite): Add
	inline keyword to function with always_inline attribute.

(cherry picked from commit 48e1b89f14)
2024-10-03 11:20:30 +01:00
Jonathan Wakely 61584f377c libstdc++: Work around some PSTL test failures for debug mode [PR90276]
This addresses one known failure due to a bug in the upstream tests, and
a number of timeouts due to the algorithms running much more slowly with
debug mode checks enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/90276
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
	[_GLIBCXX_DEBUG]: Add xfail-run-if for debug mode.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
	[_GLIBCXX_DEBUG]: Reduce size of test data.
	* testsuite/25_algorithms/pstl/alg_sorting/includes.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/set_util.h:
	Likewise.

(cherry picked from commit 003ce8a6c4)
2024-10-03 11:20:30 +01:00
Jonathan Wakely 98ae5227a3 libstdc++: Disable std::formatter<char8_t, C> specialization
I noticed that char8_t was missing from the list of types that were
prevented from using the std::formatter partial specialization for
integer types. That partial specialization was also matching
cv-qualified integer types, because std::integral<const int> is true.

This change simplifies the constraints by introducing a new variable
template which is only true for cv-unqualified integer types, with
explicit specializations to exclude the character types. This should be
slightly more efficient than the previous constraints that checked
std::integral<T> and (!__is_one_of<T, char, wchar_t, ...>). It also
avoids the need for a separate std::formatter specialization for 128-bit
integers, as they can be handled by the new variable template too.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::__is_formattable_integer): New
	variable template and specializations.
	(template<integral, __char> struct formatter): Replace
	constraints on first arg with __is_formattable_integer.
	* testsuite/std/format/formatter/requirements.cc: Check that
	std::formatter specializations for char8_t and const int are
	disabled.

(cherry picked from commit 0f52a92ab2)
2024-10-03 11:20:30 +01:00
Jonathan Wakely aeb54d0f3a libstdc++: Fix formatting of most negative chrono::duration [PR116755]
When formatting chrono::duration<signed-integer-type, P>::min() we were
causing undefined behaviour by trying to form the negative of the most
negative value. If we convert negative durations with integer rep to the
corresponding unsigned integer rep then we can safely represent all
values.

libstdc++-v3/ChangeLog:

	PR libstdc++/116755
	* include/bits/chrono_io.h (formatter<duration<R,P>>::format):
	Cast negative integral durations to unsigned rep.
	* testsuite/20_util/duration/io.cc: Test the most negative
	integer durations.

(cherry picked from commit 482e651f57)
2024-10-03 11:20:29 +01:00
GCC Administrator eed6e6e4db Daily bump. 2024-10-03 00:22:10 +00:00
Richard Biener e69c03971a tree-optimization/116585 - SSA corruption with split_constant_offset
split_constant_offset when looking through SSA defs can end up
picking SSA leafs that are subject to abnormal coalescing.  This
can lead to downstream consumers to insert code based on the
result (like from dataref analysis) in places that violate constraints
for abnormal coalescing.  It's best to not expand defs whose operands
are subject to abnormal coalescing - and not either do something when
a subexpression has operands like that already.

	PR tree-optimization/116585
	* tree-data-ref.cc (split_constant_offset_1): When either
	operand is subject to abnormal coalescing do no further
	processing.

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

(cherry picked from commit 1d0cb3b5fc)
2024-10-02 15:23:42 +00:00
GCC Administrator 8b1df6344e Daily bump. 2024-10-02 00:20:53 +00:00
Jason Merrill 91417c778a c++: don't advertise C++20 concepts in C++14
There have been various problems with -std=c++14 -fconcepts; let's stop
defining the feature test macro in that case.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Don't define __cpp_concepts
	before C++17.
2024-10-01 17:15:47 -04:00
Jason Merrill 47b205b4dc c++: -Wdangling-reference and empty class [PR115361]
We can't have a dangling reference to an empty class unless it's
specifically to that class or one of its bases.  This was giving a
false positive on the _ExtractKey pattern in libstdc++ hashtable.h.

This also adjusts the order of arguments to reference_related_p, which
is relevant for empty classes (unlike scalars).

Several of the classes in the testsuite needed to gain data members to
continue to warn.

	PR c++/115361

gcc/cp/ChangeLog:

	* call.cc (do_warn_dangling_reference): Check is_empty_class.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-no-dangling6.C
	* g++.dg/ext/attr-no-dangling7.C
	* g++.dg/ext/attr-no-dangling8.C
	* g++.dg/ext/attr-no-dangling9.C
	* g++.dg/warn/Wdangling-reference1.C
	* g++.dg/warn/Wdangling-reference2.C
	* g++.dg/warn/Wdangling-reference3.C: Make classes non-empty.
	* g++.dg/warn/Wdangling-reference23.C: New test.
2024-10-01 05:19:02 -04:00
Marek Polacek 7232bc1806 c++: fix -Wdangling-reference false positive [PR115987]
This fixes another false positive.  When a function is taking a
temporary of scalar type that couldn't be bound to the return type
of the function, don't warn, such a program would be ill-formed.

Thanks to Jonathan for reporting the problem.

	PR c++/115987

gcc/cp/ChangeLog:

	* call.cc (do_warn_dangling_reference): Don't consider a
	temporary with a scalar type that cannot bind to the return type.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-no-dangling6.C: Adjust.
	* g++.dg/ext/attr-no-dangling7.C: Likewise.
	* g++.dg/warn/Wdangling-reference22.C: New test.
2024-10-01 05:19:02 -04:00
GCC Administrator be06962b34 Daily bump. 2024-10-01 00:24:22 +00:00
GCC Administrator 129914854e Daily bump. 2024-09-30 00:21:54 +00:00
Uros Bizjak 4697543b76 i386: Modernize AMD processor types
Use iterative PTA definitions for members of the same AMD processor family.

Also, fix a couple of related M_CPU_TYPE/M_CPU_SUBTYPE inconsistencies.

No functional changes intended.

gcc/ChangeLog:

	* config/i386/i386.h: Add PTA_BDVER1, PTA_BDVER2, PTA_BDVER3,
	PTA_BDVER4, PTA_BTVER1 and PTA_BTVER2.
	* common/config/i386/i386-common.cc (processor_alias_table)
	<"bdver1">: Use PTA_BDVER1.
	<"bdver2">: Use PTA_BDVER2.
	<"bdver3">: Use PTA_BDVER3.
	<"bdver4">: Use PTA_BDVER4.
	<"btver1">: Use PTA_BTVER1.  Use M_CPU_TYPE (AMD_BTVER1).
	<"btver2">: Use PTA_BTVER2.
	<"shanghai>: Use M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI).
	<"istanbul>: Use M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL).

(cherry picked from commit a721089208)
2024-09-29 20:51:01 +02:00
GCC Administrator e0f131c879 Daily bump. 2024-09-29 00:22:12 +00:00
Jan Hubicka b17cb7ed70 Zen5 tuning part 4: update reassocation width
Zen5 has 6 instead of 4 ALUs and the integer multiplication can now execute in
3 of them.  FP units can do 2 additions and 2 multiplications with latency 2
and 3.  This patch updates reassociation width accordingly.  This has potential
of increasing register pressure but unlike while benchmarking znver1 tuning
I did not noticed this actually causing problem on spec, so this patch bumps
up reassociation width to 6 for everything except for integer vectors, where
there are 4 units with typical latency of 1.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_reassociation_width): Update for Znver5.
	* config/i386/x86-tune-costs.h (znver5_costs): Update reassociation
	widths.

(cherry picked from commit f0ab3de6ec)
2024-09-29 01:36:37 +02:00
Jan Hubicka 2eade72b0e Zen5 tuning part 3: fix typo in previous patch
gcc/ChangeLog:

	* config/i386/x86-tune-sched.cc (ix86_fuse_mov_alu_p): Fix
	typo.

(cherry picked from commit 910e1769a0)
2024-09-29 01:10:48 +02:00
Jan Hubicka 2c01292411 Zen5 tuning part 3: scheduler tweaks
this patch adds support for new fussion in znver5 documented in the
optimization manual:

   The Zen5 microarchitecture adds support to fuse reg-reg MOV Instructions
   with certain ALU instructions. The following conditions need to be met for
   fusion to happen:
     - The MOV should be reg-reg mov with Opcode 0x89 or 0x8B
     - The MOV is followed by an ALU instruction where the MOV and ALU destination register match.
     - The ALU instruction may source only registers or immediate data. There cannot be any memory source.
     - The ALU instruction sources either the source or dest of MOV instruction.
     - If ALU instruction has 2 reg sources, they should be different.
     - The following ALU instructions can fuse with an older qualified MOV instruction:
       ADD ADC AND XOR OP SUB SBB INC DEC NOT SAL / SHL SHR SAR
       (I assume OP is OR)

I also increased issue rate from 4 to 6.  Theoretically znver5 can do more, but
with our model we can't realy use it.
Increasing issue rate to 8 leads to infinite loop in scheduler.

Finally, I also enabled fuse_alu_and_branch since it is supported by
znver5 (I think by earlier zens too).

New fussion pattern moves quite few instructions around in common code:
@@ -2210,13 +2210,13 @@
        .cfi_offset 3, -32
        leaq    63(%rsi), %rbx
        movq    %rbx, %rbp
+       shrq    $6, %rbp
+       salq    $3, %rbp
        subq    $16, %rsp
        .cfi_def_cfa_offset 48
        movq    %rdi, %r12
-       shrq    $6, %rbp
-       movq    %rsi, 8(%rsp)
-       salq    $3, %rbp
        movq    %rbp, %rdi
+       movq    %rsi, 8(%rsp)
        call    _Znwm
        movq    8(%rsp), %rsi
        movl    $0, 8(%r12)
@@ -2224,8 +2224,8 @@
        movq    %rax, (%r12)
        movq    %rbp, 32(%r12)
        testq   %rsi, %rsi
-       movq    %rsi, %rdx
        cmovns  %rsi, %rbx
+       movq    %rsi, %rdx
        sarq    $63, %rdx
        shrq    $58, %rdx
        sarq    $6, %rbx
which should help decoder bandwidth and perhaps also cache, though I was not
able to measure off-noise effect on SPEC.

gcc/ChangeLog:

	* config/i386/i386.h (TARGET_FUSE_MOV_AND_ALU): New tune.
	* config/i386/x86-tune-sched.cc (ix86_issue_rate): Updat for znver5.
	(ix86_adjust_cost): Add TODO about znver5 memory latency.
	(ix86_fuse_mov_alu_p): New.
	(ix86_macro_fusion_pair_p): Use it.
	* config/i386/x86-tune.def (X86_TUNE_FUSE_ALU_AND_BRANCH): Add ZNVER5.
	(X86_TUNE_FUSE_MOV_AND_ALU): New tune;

(cherry picked from commit e2125a6005)
2024-09-29 01:10:33 +02:00
Jan Hubicka 3d0a91130e Zen5 tuning part 2: disable gather and scatter
We disable gathers for zen4.  It seems that gather has improved a bit compared
to zen4 and Zen5 optimization manual suggests "Avoid GATHER instructions when
the indices are known ahead of time. Vector loads followed by shuffles result
in a higher load bandwidth." however the situation seems to be more
complicated.

gather is 5-10% loss on parest benchmark as well as 30% loss on sparse dot
products in TSVC. Curiously enough breaking these out into microbenchmark
reversed the situation and it turns out that the performance depends on
how indices are distributed.  gather is loss if indices are sequential,
neutral if they are random and win for some strides (4, 8).

This seems to be similar to earlier zens, so I think (especially for
backporting znver5 support) that it makes sense to be conistent and disable
gather unless we work out a good heuristics on when to use it. Since we
typically do not know the indices in advance, I don't see how that can be done.

I opened PR116582 with some examples of wins and loses

gcc/ChangeLog:

	* config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): Disable for
	ZNVER5.
	(X86_TUNE_USE_SCATTER_2PARTS): Disable for ZNVER5.
	(X86_TUNE_USE_GATHER_4PARTS): Disable for ZNVER5.
	(X86_TUNE_USE_SCATTER_4PARTS): Disable for ZNVER5.
	(X86_TUNE_USE_GATHER_8PARTS): Disable for ZNVER5.
	(X86_TUNE_USE_SCATTER_8PARTS): Disable for ZNVER5.

(cherry picked from commit d82edbe92e)
2024-09-29 01:06:43 +02:00
Jan Hubicka fce2fe0406 Zen5 tuning part 1: avoid FMA chains
testing matrix multiplication benchmarks shows that FMA on a critical chain
is a perofrmance loss over separate multiply and add. While the latency of 4
is lower than multiply + add (3+2) the problem is that all values needs to
be ready before computation starts.

While on znver4 AVX512 code fared well with FMA, it was because of the split
registers. Znver5 benefits from avoding FMA on all widths.  This may be different
with the mobile version though.

On naive matrix multiplication benchmark the difference is 8% with -O3
only since with -Ofast loop interchange solves the problem differently.
It is 30% win, for example, on S323 from TSVC:

real_t s323(struct args_t * func_args)
{

//    recurrences
//    coupled recurrence

    initialise_arrays(__func__);
    gettimeofday(&func_args->t1, NULL);

    for (int nl = 0; nl < iterations/2; nl++) {
        for (int i = 1; i < LEN_1D; i++) {
            a[i] = b[i-1] + c[i] * d[i];
            b[i] = a[i] + c[i] * e[i];
        }
        dummy(a, b, c, d, e, aa, bb, cc, 0.);
    }

    gettimeofday(&func_args->t2, NULL);
    return calc_checksum(__func__);
}

gcc/ChangeLog:

	* config/i386/x86-tune.def (X86_TUNE_AVOID_128FMA_CHAINS): Enable for
	znver5.
	(X86_TUNE_AVOID_256FMA_CHAINS): Likewise.
	(X86_TUNE_AVOID_512FMA_CHAINS): Likewise.

(cherry picked from commit d6360b4083)
2024-09-29 00:36:23 +02:00
H.J. Lu 25cb153f93 x86: Don't use address override with segment regsiter
Address override only applies to the (reg32) part in the thread address
fs:(reg32).  Don't rewrite thread address like

(set (reg:CCZ 17 flags)
    (compare:CCZ (reg:SI 98 [ __gmpfr_emax.0_1 ])
        (mem/c:SI (plus:SI (plus:SI (unspec:SI [
                            (const_int 0 [0])
                        ] UNSPEC_TP)
                    (reg:SI 107))
                (const:SI (unspec:SI [
                            (symbol_ref:SI ("previous_emax") [flags 0x1a] <var_decl 0x7fffe9a11cf0 previous_emax>)
                        ] UNSPEC_DTPOFF))) [1 previous_emax+0 S4 A32])))

if address override is used to avoid the invalid memory operand like

	cmpl	%fs:previous_emax@dtpoff(%eax), %r12d

gcc/

	PR target/116839
	* config/i386/i386.cc (ix86_rewrite_tls_address_1): Make it
	static.  Return if TLS address is thread register plus an integer
	register.

gcc/testsuite/

	PR target/116839
	* gcc.target/i386/pr116839.c: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c79cc30862)
2024-09-28 18:48:33 +08:00
GCC Administrator cd8ba194c5 Daily bump. 2024-09-28 00:23:51 +00:00
GCC Administrator 37a302fb72 Daily bump. 2024-09-27 00:22:39 +00:00
Stefan Schulze Frielinghaus 3eb3fbc89c s390: Fix TF to FPRX2 conversion [PR115860]
Currently subregs originating from *tf_to_fprx2_0 and *tf_to_fprx2_1
survive register allocation.  This in turn leads to wrong register
renaming.  Keeping the current approach would mean we need two insns for
*tf_to_fprx2_0 and *tf_to_fprx2_1, respectively.  Something along the
lines

(define_insn "*tf_to_fprx2_0"
  [(set (subreg:DF (match_operand:FPRX2 0 "nonimmediate_operand" "=f") 0)
        (unspec:DF [(match_operand:TF 1 "general_operand" "v")]
                   UNSPEC_TF_TO_FPRX2_0))]
  "TARGET_VXE"
  "#")

(define_insn "*tf_to_fprx2_0"
  [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
        (unspec:DF [(match_operand:TF 1 "general_operand" "v")]
                   UNSPEC_TF_TO_FPRX2_0))]
  "TARGET_VXE"
  "vpdi\t%v0,%v1,%v0,1
  [(set_attr "op_type" "VRR")])

and similar for *tf_to_fprx2_1.  Note, pre register allocation operand 0
has mode FPRX2 and afterwards DF once subregs have been eliminated.

Since we always copy a whole vector register into a floating-point
register pair, another way to fix this is to merge *tf_to_fprx2_0 and
*tf_to_fprx2_1 into a single insn which means we don't have to use
subregs at all.  The downside of this is that the assembler template
contains two instructions, now.  The upside is that we don't have to
come up with some artificial insn before RA which might be more
readable/maintainable.  That is implemented by this patch.

In commit r11-4872-ge627cda5686592, the output operand specifier %V was
introduced which is used in tf_to_fprx2 only, now.  Instead of coming up
with its counterpart %F for floating-point registers, which would also
only be used in tf_to_fprx2, I print the operands directly.  This
renders %V unused which is why it is removed by this patch.

gcc/ChangeLog:

	PR target/115860
	* config/s390/s390.cc (print_operand): Remove operand specifier
	%V.
	* config/s390/s390.md (UNSPEC_TF_TO_FPRX2): New.
	* config/s390/vector.md (*tf_to_fprx2_0): Remove.
	(*tf_to_fprx2_1): Remove.
	(tf_to_fprx2): New.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/vector/long-double-asm-abi.c: Adapt
	scan-assembler directive.
	* gcc.target/s390/vector/long-double-to-i64.c: Adapt
	scan-assembler directive.
	* gcc.target/s390/pr115860-1.c: New test.

(cherry picked from commit 46c2538435)
2024-09-26 19:38:02 +02:00
Stefan Schulze Frielinghaus 1670d3259d s390: Fix AQ and AR constraints
Ensure for AQ and AR constraints that the resulting displacement after
adding any positive offset less than the size of the object being
referenced is still valid.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_mem_constraint): Check displacement
	for AQ and AR constraints.

(cherry picked from commit 1a71ff3b89)
2024-09-26 19:38:02 +02:00
GCC Administrator 54780d29c9 Daily bump. 2024-09-26 00:22:51 +00:00
GCC Administrator 10d8060e77 Daily bump. 2024-09-25 00:22:29 +00:00
GCC Administrator 335e10a88f Daily bump. 2024-09-24 00:22:27 +00:00
Jonathan Wakely 4d88724c2d libstdc++: Avoid forming T* in unique_ptr(auto_ptr<U>&&) constraints [PR116529]
PR 116529 shows that std::unique_ptr<X&, D> is currently unusable
because the constructor taking std::auto_ptr (which is a non-standard
extension since C++17) tries to form the invalid type X&* during
overload resolution. We can use the `pointer` type in the constructor
constraints, instead of trying to form an invalid type. The
std::auto_ptr constructor can never actually match for the case where
element_type is a reference, so we just need it to produce a
substitution failure instead of being ill-formed.

LWG 4144 might make std::unique_ptr<X&, D> ill-formed, which would
invalidate this new test. We would have to remove this test in that
case. Using `pointer` in the constructor from std::auto_ptr would not be
needed to support the std::unique_ptr<X&, D> case, but would not cause
any harm either.

libstdc++-v3/ChangeLog:

	PR libstdc++/116529
	* include/bits/unique_ptr.h (unique_ptr(auto_ptr<U>&&)):
	Use pointer instead of T*.
	* testsuite/20_util/unique_ptr/creation/116529.cc: New test.

(cherry picked from commit a001d51505)
2024-09-23 14:30:42 +01:00
Jonathan Wakely f4fc6d2aa8 libstdc++: Fix condition for ranges::copy to use memmove [PR116754]
libstdc++-v3/ChangeLog:

	PR libstdc++/116754
	* include/bits/ranges_algobase.h (__copy_or_move): Fix order of
	arguments to __memcpyable.

(cherry picked from commit 83c6fe130a)
2024-09-23 14:30:42 +01:00
Jonathan Wakely 74f67ba3dc libstdc++: Document missing features for old std:string ABI [PR116777]
There are several features that are not supported when using the old
std::string ABI. It's possible that PR 81967 will get fixed, but the
missing C++20 features almost certainly won't be. Document this in the
manual.

libstdc++-v3/ChangeLog:

	PR libstdc++/116777
	* doc/xml/manual/using.xml: Document features that are not
	supported for the gcc4-compatible ABI.
	* doc/html/manual/using_dual_abi.html: Regenerate.

(cherry picked from commit 8230922230)
2024-09-23 14:30:42 +01:00
Jonathan Wakely 1be3e4e438 libstdc++: Fix std::allocator_traits::construct constraints [PR108619]
Using std::is_constructible in the constraints introduces a spurious
dependency on the type being destructible, which should not be required
for constructing with an allocator. The test case shows a case where the
type has a private destructor, which can be destroyed by the allocator,
but std::is_destructible and std::is_constructible are false.

Similarly, using is_nothrow_constructible in the noexcept-specifiers
for the construct members of allocator_traits and std::allocator,
__gnu_cxx::__new_allocator, and __gnu_cxx::__malloc_allocator gives the
wrong answer if the type isn't destructible.
We need a new type trait to define those correctly, so that we only
check if the placement new-expression is nothrow after using
is_constructible to check that it would be well-formed.

On trunk all members of std::allocator_traits were rewritten in terms of
'if constexpr' using variable templates and the detection idiom. For the
release branch this backport only changes the 'construct' member.

Although we can use 'if constexpr' and variable templates in C++11 with
appropriate uses of diagnostic pragmas, we can't have constexpr
functions with multiple return statements. This means that in C++11 mode
the _S_nothrow_construct helper used for noexcept-specifiers still needs
to be a pair of overloads using enable_if.

libstdc++-v3/ChangeLog:

	PR libstdc++/108619
	* include/bits/alloc_traits.h (__allocator_traits_base): Add
	variable templates for detecting whether the allocator has a
	construct member, or if placement new can be used instead.
	(allocator_traits::__construct_helper): Remove.
	(allocator_traits::__has_construct): Remove.
	(allocator_traits::construct): Use 'if constexpr' instead of
	dispatching to overloads constrained with enable_if.
	(allocator_traits<allocator<T>>::construct): Use _Construct if
	construct_at is not supported. Use
	__is_nothrow_new_constructible for noexcept-specifier.
	(allocator_traits<allocator<void>>::construct): Use
	__is_nothrow_new_constructible for noexcept-specifier.
	* include/bits/new_allocator.h (construct): Likewise.
	* include/ext/malloc_allocator.h (construct): Likewise.
	* include/std/type_traits (__is_nothrow_new_constructible): New
	variable template.
	* testsuite/20_util/allocator/89510.cc: Adjust expected results.
	* testsuite/ext/malloc_allocator/89510.cc: Likewise.
	* testsuite/ext/new_allocator/89510.cc: Likewise.
	* testsuite/20_util/allocator_traits/members/108619.cc: New test.

(cherry picked from commit 8cf51d7516)
2024-09-23 14:30:42 +01:00
Iain Sandoe 7eba5b286e libgcc, Darwin: From macOS 11, make that the earliest supported.
For libgcc, we have (so far) supported building a DSO that supports
earlier versions of the OS than the target.  From macOS 11, there are
APIs that do not exist on earlier OS versions, so limit the libgcc
range to macOS11..current.

libgcc/ChangeLog:

	* config.host: From macOS 11, limit earliest macOS support
	to macOS 11.
	* config/t-darwin-min-11: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 43eab54939)
2024-09-23 07:40:02 +01:00
Iain Sandoe 59fa909de8 Darwin: Allow for as versions that need '-' for std in.
Recent versions of Xcode as require a dash to read from standard
input.  We can use this on all supported OS versions so make it
unconditional.  Patch from Mark Mentovai.

gcc/ChangeLog:

	* config/darwin.h (AS_NEEDS_DASH_FOR_PIPED_INPUT): New.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 33ccc1314d)
2024-09-23 07:39:34 +01:00
Iain Sandoe b292b6b9e1 Darwin: Recognise -weak_framework in the driver [PR116237].
XCode compilers recognise the weak_framework linker option in the driver
and forward it.  This patch makes GCC adopt the same behaviour.

	PR target/116237

gcc/ChangeLog:

	* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Add a spec for
	weak_framework.
	* config/darwin.opt: Handle weak_framework driver option.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 4cec7bc79d)
2024-09-23 07:38:51 +01:00
GCC Administrator 2a8f362c3e Daily bump. 2024-09-23 00:22:16 +00:00
John David Anglin cf4086628d hppa: Add peephole2 optimizations for REG+D loads and stores
The PA 1.x architecture only supports long displacements in
integer loads and stores.  Floating-point loads and stores
only support short displacements.  As a result, we have to
wait until reload is complete before generating insns with
long displacements.

The PA 2.0 architecture supports long displacements in both
integer and floating-point loads and stores.

The peephole2 optimizations added in this change are only
enabled when 14-bit long displacements aren't supported for
floating-point loads and stores.

2024-09-18  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.h (GENERAL_REGNO_P): Define.
	* config/pa/pa.md: Add SImode and SFmode peephole2
	patterns to generate loads and stores with long
	displacements.
2024-09-22 09:21:16 -04:00
GCC Administrator a0abcea3b0 Daily bump. 2024-09-22 00:23:21 +00:00
GCC Administrator 99e640b1e1 Daily bump. 2024-09-21 00:22:06 +00:00
Patrick Palka abdea396e1 c++: decltype(auto) deduction of statement-expression [PR116418]
r8-7538 for PR84968 made strip_typedefs_expr diagnose STATEMENT_LIST
so that we reject statement-expressions in noexcept-specifiers to
match our behavior in template arguments (which the parser diagnoses
directly).

Later r11-7452 made decltype(auto) deduction canonicalize the expression
(as an implementation detail) which in turn calls strip_typedefs_expr,
and so ever since we inadvertently reject decltype(auto) deduction of a
statement-expression.

This patch just removes the diagnostic in strip_typedefs_expr and instead
treats statement-expressions similar to lambda-expressions.  The function
doesn't seem like the right place for such a diagnostic and so it seems
easier to just accept rather than try to reject them in a suitable place.

	PR c++/116418

gcc/cp/ChangeLog:

	* tree.cc (strip_typedefs_expr) <case STATEMENT_LIST>: Replace
	this error path with ...
	<case STMT_EXPR>: ... this, returning the original tree.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/pr84968.C: No longer expect an ahead of time diagnostic
	for the statement-expresssion.  Instantiate the template and expect
	an incomplete type error instead.
	* g++.dg/ext/stmtexpr26.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 12bdcc3d79)
2024-09-20 18:07:41 -04:00
Patrick Palka 659f32ea9d c++: CWG 2789 and usings [PR116492]
For GCC 14, narrowly fix this PR by implementing the missing

  - if they are member functions, both are direct members of the same
    class, and

part of CWG 2789 for constructors only.

	PR c++/116492
	DR 2789

gcc/cp/ChangeLog:

	* call.cc (cand_parms_match): Return false for constructors that
	come from different classes.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-inherit-ctor12.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-20 17:37:03 -04:00
Harald Anlauf cf8f6aa2a0 Fortran: fix ICE in gfc_create_module_variable [PR100273]
gcc/fortran/ChangeLog:

	PR fortran/100273
	* trans-decl.cc (gfc_create_module_variable): Handle module
	variable also when it is needed for the result specification
	of a contained function.

gcc/testsuite/ChangeLog:

	PR fortran/100273
	* gfortran.dg/pr100273.f90: New test.

(cherry picked from commit 1f462b5072)
2024-09-20 20:28:07 +02:00
GCC Administrator 9f8f721607 Daily bump. 2024-09-20 17:41:07 +00:00
Eric Botcazou adab597af2 Fix small thinko in IPA mod/ref pass
When a memory copy operation is analyzed by analyze_ssa_name, if both the
load and store are made through the same SSA name, the store is overlooked.

gcc/
	* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always
	process both the load and the store of a memory copy operation.

gcc/testsuite/
	* gcc.dg/ipa/modref-4.c: New test.
2024-09-20 14:15:23 +02:00
Stefan Schulze Frielinghaus bff6e5667d s390: Fix strict_low_part generation
In s390_expand_insv(), if generating code for ICM et al. src is a MEM
and gen_lowpart might force src into a register such that we end up with
patterns which do not match anymore.  Use adjust_address() instead in
order to preserve a MEM.

Furthermore, it is not straight forward to enforce a subreg.  For
example, in case of a paradoxical subreg, gen_lowpart() may return a
register.  In order to compensate this, s390_gen_lowpart_subreg() emits
a reference to a pseudo which does not coincide with its definition
which is wrong.  Additionally, if dest is a paradoxical subreg, then do
not try to emit a strict_low_part since it could mean that dest was not
initialized even though this might be fixed up later by init-regs.

Splitter for insn *get_tp_64, *zero_extendhisi2_31,
*zero_extendqisi2_31, *zero_extendqihi2_31 are applied after reload.
Thus, operands[0] is a hard register and gen_lowpart (m, operands[0])
just returns the hard register for mode m which is fine to use as an
argument for strict_low_part, i.e., we do not need to enforce subregs
here since after reload subregs are supposed to be eliminated anyway.

This fixes gcc.dg/torture/pr111821.c.

gcc/ChangeLog:

	* config/s390/s390-protos.h (s390_gen_lowpart_subreg): Remove.
	* config/s390/s390.cc (s390_gen_lowpart_subreg): Remove.
	(s390_expand_insv): Use adjust_address() and emit a
	strict_low_part only in case of a natural subreg.
	* config/s390/s390.md: Use gen_lowpart() instead of
	s390_gen_lowpart_subreg().

(cherry picked from commit 9ebc9fbddd)
2024-09-20 14:06:42 +02:00
Joseph Myers 164a4a5713 Update cpplib zh_CN.po
* zh_CN.po: Update.
2024-09-19 21:10:19 +00:00
Joseph Myers 37c9b3ab17 Update gcc zh_CN.po
* zh_CN.po: Update.
2024-09-19 21:07:08 +00:00
Haochen Jiang a3efd2ff9d doc: Add more alias option and reorder Intel CPU -march documentation
This patch is backported from GCC15 with some tweaks.

Since r15-3539, there are requests coming in to add other alias option
documentation. This patch will add all ot them, including corei7, corei7-avx,
core-avx-i, core-avx2, atom, slm, gracemont and emerarldrapids.

Also in the patch, I reordered that part of documentation, currently all
the CPUs/products are just all over the place. I regrouped them by
date-to-now products (since the very first CPU to latest Panther Lake), P-core
(since the clients become hybrid cores, starting from Sapphire Rapids) and
E-core (since Bonnell to latest Clearwater Forest). In GCC14 and
eariler GCC, Xeon Phi CPUs are still there, I put them after E-core
CPUs.

And in the patch, I refined the product names in documentation.

gcc/ChangeLog:

	* doc/invoke.texi: Add corei7, corei7-avx, core-avx-i,
	core-avx2, atom, slm, gracemont and emerarldrapids. Reorder
	the -march documentation by splitting them into date-to-now
	products, P-core, E-core and Xeon Phi. Refine the product names in
	documentation.
2024-09-19 14:24:54 +08:00
GCC Administrator 646b5650a5 Daily bump. 2024-09-19 00:23:52 +00:00
Richard Biener bdc5937df6 tree-optimization/116460 - ICE with DCE in forwprop
The following avoids removing stmts with defs that might still have
uses in the IL before calling simple_dce_from_worklist which might
remove those as that will wreck debug stmt generation.  Instead first
perform use-based DCE and then remove stmts which may have uses in
code that CFG cleanup will remove.  This requires tracking stmts
in to_remove by their SSA def so we can check whether it was removed
before without running into the issue that PHIs can be ggc_free()d
upon removal.  So this adds to_remove_defs in addition to to_remove
which has to stay to track GIMPLE_NOPs we want to elide.

	PR tree-optimization/116460
	* tree-ssa-forwprop.cc (pass_forwprop::execute): First do
	simple_dce_from_worklist and then remove stmts in to_remove.
	Track defs to be removed in to_remove_defs.

	* g++.dg/torture/pr116460.C: New testcase.

(cherry picked from commit 172637cf0d)
2024-09-18 11:42:11 +02:00
Joern Rennecke a308afb455 Fix vect/pr115278.cc for targets where uint32_t is distinct from unsigned.
gcc/testsuite/
	* g++.dg/vect/pr115278.cc: Make cast's type agree with
	assignment destination WRITE.

(cherry picked from commit b844775283)
2024-09-18 11:25:24 +02:00
Richard Biener 5b264a4b95 middle-end/115426 - wrong gimplification of "rm" asm output operand
When the operand is gimplified to an extract of a register or a
register we have to disallow memory as we otherwise fail to
gimplify it properly.  Instead of

  __asm__("" : "=rm" __imag <r>);

we want

  __asm__("" : "=rm" D.2772);
  _1 = REALPART_EXPR <r>;
  r = COMPLEX_EXPR <_1, D.2772>;

otherwise SSA rewrite will fail and generate wrong code with 'r'
left bare in the asm output.

	PR middle-end/115426
	* gimplify.cc (gimplify_asm_expr): Handle "rm" output
	constraint gimplified to a register (operation).

	* gcc.dg/pr115426.c: New testcase.

(cherry picked from commit a4bbdec2be)
2024-09-18 10:18:10 +02:00
Richard Biener cacc976a71 tree-optimization/116610 - wrong SLP induction bias for mask peeling
The following fixes a mistake when applying the bias for peeling via
masking to the inital value of SLP inductions.

This resolves gcc.target/aarch64/sve/peel_ind_1.c (a scan-assembler
only unfortunately) when forcing single-lane SLP for it.

	PR tree-optimization/116610
	* tree-vect-loop.cc (vectorizable_induction): Use MINUS_EXPR
	to apply a mask peeling adjustment.

(cherry picked from commit 6a1a856ba7)
2024-09-18 10:17:39 +02:00
Andrew Pinski 12c00048d9 fold: Fix a * 1j if a has side effects [PR116454]
The problem here was a missing save_expr around arg0 since
it is used twice, once in REALPART_EXPR and once in IMAGPART_EXPR.
Thia adds the save_expr and reformats the code slightly so it is a
little easier to understand.  It excludes the case when arg0 is
a COMPLEX_EXPR since in that case we'll end up with the distinct
real and imaginary parts.  This is important to retain early
optimization in some testcases.

Bootstapped and tested on x86_64-linux-gnu with no regressions.

	PR middle-end/116454

gcc/ChangeLog:

	* fold-const.cc (fold_binary_loc): Fix `a * +-1i`
	by wrapping arg0 with save_expr when it is not COMPLEX_EXPR.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr116454-1.c: New test.
	* gcc.dg/torture/pr116454-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Co-Authored-By: Richard Biener  <rguenther@suse.de>
(cherry picked from commit b07f8a3011)
2024-09-18 10:16:16 +02:00
Richard Biener 8f8a7e1f19 tree-optimization/116380 - bogus SSA update with loop distribution
When updating LC PHIs after copying loops we have to handle defs
defined outside of the loop appropriately (by not setting them to
NULL ...).  This mimics how we handle this in the SSA updating
code of the vectorizer.

	PR tree-optimization/116380
	* tree-loop-distribution.cc (copy_loop_before): Handle
	out-of-loop defs appropriately.

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

(cherry picked from commit af0d2d95a5)
2024-09-18 10:15:43 +02:00
Richard Biener d5d4f3bae5 tree-optimization/116274 - overzealous SLP vectorization
The following tries to address that the vectorizer fails to have
precise knowledge of argument and return calling conventions and
views some accesses as loads and stores that are not.
This is mainly important when doing basic-block vectorization as
otherwise loop indexing would force such arguments to memory.

On x86 the reduction in the number of apparent loads and stores
often dominates cost analysis so the following tries to mitigate
this aggressively by adjusting only the scalar load and store
cost, reducing them to the cost of a simple scalar statement,
but not touching the vector access cost which would be much
harder to estimate.  Thereby we error on the side of not performing
basic-block vectorization.

	PR tree-optimization/116274
	* tree-vect-slp.cc (vect_bb_slp_scalar_cost): Cost scalar loads
	and stores as simple scalar stmts when they access a non-global,
	not address-taken variable that doesn't have BLKmode assigned.

	* gcc.target/i386/pr116274-2.c: New testcase.

(cherry picked from commit b8ea13ebf1)
2024-09-18 10:13:05 +02:00
Andrew Pinski 090926ba81 aarch64/testsuite: Add testcases for recently fixed PRs
The commit for PR 116258, added a x86_64 specific testcase,
I thought it would be a good idea to add an aarch64 testcase too.
And since it also fixed VLA vectors too so add a SVE testcase.

Pushed as obvious after a test for aarch64-linux-gnu.

	PR middle-end/116258
	PR middle-end/116259

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr116258.c: New test.
	* gcc.target/aarch64/sve/pr116259-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 2c6174402e)
2024-09-18 10:10:58 +02:00
Richard Biener 198b13e248 tree-optimization/116258 - fix i386 testcase
With -march=cascadelake we use vpermilps instead of shufps.

	PR tree-optimization/116258
	* gcc.target/i386/pr116258.c: Also allow vpermilps.

(cherry picked from commit 5aa4cd913e)
2024-09-18 10:10:04 +02:00
Richard Biener 05db1bea8c tree-optimization/116258 - do not lower PAREN_EXPR of vectors
The following avoids lowering of PAREN_EXPR of vectors as unsupported
to scalars.  Instead PAREN_EXPR is like a plain move or a VIEW_CONVERT.

	PR tree-optimization/116258
	* tree-vect-generic.cc (expand_vector_operations_1): Do not
	lower PAREN_EXPR.

	* gcc.target/i386/pr116258.c: New testcase.

(cherry picked from commit 5b999997d1)
2024-09-18 10:09:53 +02:00
Richard Biener 98dc0471d5 middle-end/115641 - invalid address construction
fold_truth_andor_1 via make_bit_field_ref builds an address of
a CALL_EXPR which isn't valid GENERIC and later causes an ICE.
The following simply avoids the folding for f ().a != 1 || f ().b != 2
as it is a premature optimization anyway.  The alternative would
have been to build a TARGET_EXPR around the call.  To get this far
f () has to be const as otherwise the two calls are not semantically
equivalent for the optimization.

	PR middle-end/115641
	* fold-const.cc (decode_field_reference): If the inner
	reference isn't something we can take the address of, fail.

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

(cherry picked from commit 3670c70c56)
2024-09-18 10:08:44 +02:00
GCC Administrator 0043ac2059 Daily bump. 2024-09-18 00:22:28 +00:00
Marek Polacek f1dc18250d c++: crash with anon VAR_DECL [PR116676]
r12-3495 added maybe_warn_about_constant_value which will crash if
it gets a nameless VAR_DECL, which is what happens in this PR.

We created this VAR_DECL in cp_parser_decomposition_declaration.

	PR c++/116676

gcc/cp/ChangeLog:

	* constexpr.cc (maybe_warn_about_constant_value): Check DECL_NAME.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/constexpr-116676.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit dfe0d4389a)
2024-09-17 11:30:04 -04:00
GCC Administrator bee69e5306 Daily bump. 2024-09-17 00:21:27 +00:00
GCC Administrator 122794cb52 Daily bump. 2024-09-16 00:21:15 +00:00
H.J. Lu 3f3f546bf8 x86-64: Don't use temp for argument in a TImode register
Don't use temp for a PARALLEL BLKmode argument of an EXPR_LIST expression
in a TImode register.  Otherwise, the TImode variable will be put in
the GPR save area which guarantees only 8-byte alignment.

gcc/

	PR target/116621
	* config/i386/i386.cc (ix86_gimplify_va_arg): Don't use temp for
	a PARALLEL BLKmode container of an EXPR_LIST expression in a
	TImode register.

gcc/testsuite/

	PR target/116621
	* gcc.target/i386/pr116621.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit fa7bbb065c)
2024-09-16 04:04:39 +08:00
GCC Administrator f79535a8f1 Daily bump. 2024-09-15 00:20:29 +00:00
GCC Administrator 03b4c7599e Daily bump. 2024-09-14 00:20:48 +00:00
GCC Administrator 890a26bb95 Daily bump. 2024-09-13 00:21:45 +00:00
Marek Polacek 4088319e7c c++: ICE with TTP [PR96097]
We crash when dependent_type_p gets a TEMPLATE_TYPE_PARM outside
a template.  That happens here because in

  template <template <typename T, typename T::type TT> typename X>
  void func() {}
  template <typename U, int I>
  struct Y {};
  void g() { func<Y>(); }

when performing overload resolution for func<Y>() we have to check
if U matches T and I matches TT.  So we wind up in
coerce_template_template_parm/PARM_DECL.  TREE_TYPE (arg) is int
so we try to substitute TT's type, which is T::type.  But we have
nothing to substitute T with.  And we call make_typename_type where
ctx is still T, which checks dependent_scope_p and we trip the assert.

It should work to always perform the substitution in a template context.
If the result still contains template parameters, we cannot say if they
match.

	PR c++/96097

gcc/cp/ChangeLog:

	* pt.cc (coerce_template_template_parm): Increment
	processing_template_decl before calling tsubst.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 25ac2bb57a)
2024-09-12 15:16:06 -04:00
Jakub Jelinek 5609246b56 c++: Disable deprecated/unavailable diagnostics when creating thunks for methods with such attributes [PR116636]
On the following testcase, we emit false positive warnings/errors about using
the deprecated or unavailable methods when creating thunks for them, even
when nothing (in the testcase so far) actually used those.

The following patch temporarily disables that diagnostics when creating
the thunks.

2024-09-12  Jakub Jelinek  <jakub@redhat.com>

	PR c++/116636
	* method.cc: Include decl.h.
	(use_thunk): Temporarily change deprecated_state to
	UNAVAILABLE_DEPRECATED_SUPPRESS.

	* g++.dg/warn/deprecated-19.C: New test.

(cherry picked from commit 4026d89d62)
2024-09-12 20:26:44 +02:00
Jakub Jelinek 90a9c36dc3 c++: Fix get_member_function_from_ptrfunc with -fsanitize=bounds [PR116449]
The following testcase is miscompiled, because
get_member_function_from_ptrfunc
emits something like
(((FUNCTION.__pfn & 1) != 0)
 ? ptr + FUNCTION.__delta + FUNCTION.__pfn - 1
 : FUNCTION.__pfn) (ptr + FUNCTION.__delta, ...)
or so, so FUNCTION tree is used there 5 times.  There is
if (TREE_SIDE_EFFECTS (function)) function = save_expr (function);
but in this case function doesn't have side-effects, just nested ARRAY_REFs.
Now, if all the FUNCTION trees would be shared, it would work fine,
FUNCTION is evaluated in the first operand of COND_EXPR; but unfortunately
that isn't the case, both the BIT_AND_EXPR shortening and conversion to
bool done for build_conditional_expr actually unshare_expr that first
expression, but none of the other 4 are unshared.  With -fsanitize=bounds,
.UBSAN_BOUNDS calls are added to the ARRAY_REFs and use save_expr to avoid
evaluating the argument multiple times, but because that FUNCTION tree is
first used in the second argument of COND_EXPR (i.e. conditionally), the
SAVE_EXPR initialization is done just there and then the third argument
of COND_EXPR just uses the uninitialized temporary and so does the first
argument computation as well.

The following patch fixes that by doing save_expr even if !TREE_SIDE_EFFECTS,
but to avoid doing that too often only if !nonvirtual and if the expression
isn't a simple decl.

2024-09-10  Jakub Jelinek  <jakub@redhat.com>

	PR c++/116449
	* typeck.cc (get_member_function_from_ptrfunc): Use save_expr
	on instance_ptr and function even if it doesn't have side-effects,
	as long as it isn't a decl.

	* g++.dg/ubsan/pr116449.C: New test.

(cherry picked from commit 0008050b9d)
2024-09-12 20:21:04 +02:00
Jakub Jelinek c9fd43a8df libiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section [PR116614]
cat abc.C
  #define A(n) struct T##n {} t##n;
  #define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
  #define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
  #define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9)
  #define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9)
  E(1) E(2) E(3)
  int main () { return 0; }
./xg++ -B ./ -o abc{.o,.C} -flto -flto-partition=1to1 -O2 -g -fdebug-types-section -c
./xgcc -B ./ -o abc{,.o} -flto -flto-partition=1to1 -O2
(not included in testsuite as it takes a while to compile) FAILs with
lto-wrapper: fatal error: Too many copied sections: Operation not supported
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

The following patch fixes that.  Most of the 64K+ section support for
reading and writing was already there years ago (and especially reading used
quite often already) and a further bug fixed in it in the PR104617 fix.

Yet, the fix isn't solely about removing the
  if (new_i - 1 >= SHN_LORESERVE)
    {
      *err = ENOTSUP;
      return "Too many copied sections";
    }
5 lines, the missing part was that the function only handled reading of
the .symtab_shndx section but not copying/updating of it.
If the result has less than 64K-epsilon sections, that actually wasn't
needed, but e.g. with -fdebug-types-section one can exceed that pretty
easily (reported to us on WebKitGtk build on ppc64le).
Updating the section is slightly more complicated, because it basically
needs to be done in lock step with updating the .symtab section, if one
doesn't need to use SHN_XINDEX in there, the section should (or should be
updated to) contain SHN_UNDEF entry, otherwise needs to have whatever would
be overwise stored but couldn't fit.  But repeating due to that all the
symtab decisions what to discard and how to rewrite it would be ugly.

So, the patch instead emits the .symtab_shndx section (or sections) last
and prepares the content during the .symtab processing and in a second
pass when going just through .symtab_shndx sections just uses the saved
content.

2024-09-07  Jakub Jelinek  <jakub@redhat.com>

	PR lto/116614
	* simple-object-elf.c (SHN_COMMON): Align comment with neighbouring
	comments.
	(SHN_HIRESERVE): Use uppercase hex digits instead of lowercase for
	consistency.
	(simple_object_elf_find_sections): Formatting fixes.
	(simple_object_elf_fetch_attributes): Likewise.
	(simple_object_elf_attributes_merge): Likewise.
	(simple_object_elf_start_write): Likewise.
	(simple_object_elf_write_ehdr): Likewise.
	(simple_object_elf_write_shdr): Likewise.
	(simple_object_elf_write_to_file): Likewise.
	(simple_object_elf_copy_lto_debug_section): Likewise.  Don't fail for
	new_i - 1 >= SHN_LORESERVE, instead arrange in that case to copy
	over .symtab_shndx sections, though emit those last and compute their
	section content when processing associated .symtab sections.  Handle
	simple_object_internal_read failure even in the .symtab_shndx reading
	case.

(cherry picked from commit bb8dd0980b)
2024-09-12 20:20:29 +02:00
GCC Administrator 78a08bf4a1 Daily bump. 2024-09-12 00:20:49 +00:00
Jonathan Wakely 2003f890b1 libstdc++: Only use std::ios_base_library_init() for ELF [PR116159]
The undefined std::ios_base_library_init() symbol that is referenced by
<iostream> is only supposed to be used for targets where symbol
versioning is supported.

The mingw-w64 target defaults to --enable-symvers=gnu due to using GNU
ld but doesn't actually support symbol versioning. This means it tries
to emit references to the std::ios_base_library_init() symbol, which
isn't really defined in the library. This causes problems when using lld
to link user binaries.

Disable the undefined symbol reference for non-ELF targets.

libstdc++-v3/ChangeLog:

	PR libstdc++/116159
	* include/std/iostream (ios_base_library_init): Only define for
	ELF targets.
	* src/c++98/ios_init.cc (ios_base_library_init): Likewise.

(cherry picked from commit fc7a1fb023)
2024-09-11 08:13:35 +01:00
Jonathan Wakely d5d6d3ff43 libstdc++: std::string move assignment should not use POCCA trait [PR116641]
The changes to implement LWG 2579 (r10-327-gdb33efde17932f) made
std::string::assign use the propagate_on_container_copy_assignment
(POCCA) trait, for consistency with operator=(const basic_string&).
However, this also unintentionally affected operator=(basic_string&&)
which calls assign(str) to make a deep copy when performing a move is
not possible. The fix is for the move assignment operator to call
_M_assign(str) instead of assign(str), as this just does the deep copy
and doesn't check the POCCA trait first.

The bug only affects the unlikely/useless combination of POCCA==true and
POCMA==false, but we should fix it for correctness anyway. it should
also make move assignment slightly cheaper to compile and execute,
because we skip the extra code in assign(const basic_string&).

libstdc++-v3/ChangeLog:

	PR libstdc++/116641
	* include/bits/basic_string.h (operator=(basic_string&&)): Call
	_M_assign instead of assign.
	* testsuite/21_strings/basic_string/allocator/116641.cc: New
	test.

(cherry picked from commit c07cf418fd)
2024-09-11 08:13:35 +01:00
GCC Administrator f0f00c44eb Daily bump. 2024-09-11 00:23:02 +00:00
Jonathan Wakely ab884fffe3 libstdc++: Fix std::chrono::tzdb to work with vanguard format
I found some issues in the std::chrono::tzdb parser by testing the
tzdata "vanguard" format, which uses new features that aren't enabled in
the "main" and "rearguard" data formats.

Since 2024a the keyword "minimum" is no longer valid for the FROM and TO
fields in a Rule line, which means that "m" is now a valid abbreviation
for "maximum". Previously we expected either "mi" or "ma". For backwards
compatibility, a FROM field beginning with "mi" is still supported and
is treated as 1900. The "maximum" keyword is only allowed in TO now,
because it makes no sense in FROM. To support these changes the
minmax_year and minmax_year2 classes for parsing FROM and TO are
replaced with a single years_from_to class that reads both fields.

The vanguard format makes use of %z in Zone FORMAT fields, which caused
an exception to be thrown from ZoneInfo::set_abbrev because no % or /
characters were expected when a Zone doesn't use a named Rule. The
ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace
any %z with the current offset. Although format_abbrev_str also checks
for %s and STD/DST formats, those only make sense when a named Rule is
in effect, so won't occur when ZoneInfo::to(sys_info&) is used.

Since making this change on trunk, the tzdata-2024b release started
using %z in the main format, not just vanguard. This makes a backport to
release branches necessary (see PR 116657).

This change also implements a feature that has always been missing from
time_zone::_M_get_sys_info: finding the Rule that is active before the
specified time point, so that we can correctly handle %s in the FORMAT
for the first new sys_info that gets created. This requires implementing
a poorly documented feature of zic, to get the LETTERS field from a
later transition, as described at
https://mm.icann.org/pipermail/tz/2024-April/058891.html
In order for this to work we need to be able to distinguish an empty
letters field (as used by CE%sT where the variable part is either empty
or "S") from "the letters field is not known for this transition". The
tzdata file uses "-" for an empty letters field, which libstdc++ was
previously replacing with "" when the Rule was parsed. Instead, we now
preserve the "-" in the Rule object, so that "" can be used for the case
where we don't know the letters (and so need to decide it).

libstdc++-v3/ChangeLog:

	* src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove.
	(years_from_to): New class replacing minmax_year and
	minmax_year2.
	(format_abbrev_str, select_std_or_dst_abbrev): Move earlier in
	the file. Handle "-" for letters.
	(ZoneInfo::to): Use format_abbrev_str to expand %z.
	(ZoneInfo::set_abbrev): Remove exception. Change parameter from
	reference to value.
	(operator>>(istream&, Rule&)): Do not clear letters when it
	contains "-".
	(time_zone::_M_get_sys_info): Add missing logic to find the Rule
	in effect before the time point.
	* testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using
	"GMT" as the Zone name, not as a Link to "Etc/GMT".
	* testsuite/std/time/time_zone/sys_info_abbrev.cc: New test.

(cherry picked from commit 0ca8d56f20)
2024-09-10 13:18:21 +01:00
GCC Administrator 8a0f0fca63 Daily bump. 2024-09-10 00:33:01 +00:00
Haochen Jiang 3951efed1c doc: Enhance Intel CPU documentation
This patch will add those recent aliased CPU names into documentation
for clearness.

gcc/ChangeLog:

	PR target/116617
	* doc/invoke.texi: Add meteorlake, raptorlake and lunarlake.
2024-09-09 14:56:03 +08:00
GCC Administrator 9366940793 Daily bump. 2024-09-09 00:21:22 +00:00
Patrick Palka 149d87fbe6 c++: c->B::m access resolved through current inst [PR116320]
Here when checking the access of (the injected-class-name) B in c->B::m
at parse time, we notice its context B (now the type) is a base of the
object type C<T>, so we proceed to use C<T> as the effective qualifying
type.  But this C<T> is the dependent specialization not the primary
template type, so it has empty TYPE_BINFO, which leads to a segfault later
from perform_or_defer_access_check.

The reason the DERIVED_FROM_P (B, C<T>) test guarding this code path works
despite C<T> having empty TYPE_BINFO is because of its currently_open_class
logic (added in r9-713-gd9338471b91bbe) which replaces a dependent
specialization with the primary template type if we're inside it.  So the
safest fix seems to be to call currently_open_class in the caller as well.

	PR c++/116320

gcc/cp/ChangeLog:

	* semantics.cc (check_accessibility_of_qualified_id): Try
	currently_open_class when using the object type as the
	effective qualifying type.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 484f139ccd)
2024-09-08 19:58:21 -04:00
Patrick Palka b5ed381d05 c++: inherited CTAD fixes [PR116276]
This implements the overlooked inherited vs non-inherited guide
tiebreaker from P2582R1.  This requires tracking inherited-ness of a
guide, for which it seems natural to reuse the lang_decl_fn::context
field which for a constructor tracks its inherited-ness.

This patch also works around CLASSTYPE_CONSTRUCTORS not reliably
returning all inherited constructors (due to some using-decl handling
quirks in in push_class_level_binding) by iterating over TYPE_FIELDS
instead.

This patch also makes us recognize another written form of inherited
constructor, 'using Base<T>::Base::Base' whose USING_DECL_SCOPE is a
TYPENAME_TYPE.

	PR c++/116276

gcc/cp/ChangeLog:

	* call.cc (joust): Implement P2582R1 inherited vs non-inherited
	guide tiebreaker.
	* cp-tree.h (lang_decl_fn::context): Document usage in
	deduction_guide_p FUNCTION_DECLs.
	(inherited_guide_p): Declare.
	* pt.cc (inherited_guide_p): Define.
	(set_inherited_guide_context): Define.
	(alias_ctad_tweaks): Use set_inherited_guide_context.
	(inherited_ctad_tweaks): Recognize some inherited constructors
	whose scope is a TYPENAME_TYPE.
	(ctor_deduction_guides_for): For C++23 inherited CTAD, iterate
	over TYPE_FIELDS instead of CLASSTYPE_CONSTRUCTORS to recognize
	all inherited constructors.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/class-deduction-inherited4.C: Remove an xfail.
	* g++.dg/cpp23/class-deduction-inherited5.C: New test.
	* g++.dg/cpp23/class-deduction-inherited6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 8cc67b5209)
2024-09-08 19:58:21 -04:00
Patrick Palka 140aab25a4 libstdc++: use concrete return type for std::forward_like
Inspired by https://github.com/llvm/llvm-project/issues/101614 this
inverts the relationship between forward_like and __like_t so that
forward_like is defined in terms of __like_t and with a concrete return
type.  __like_t in turn is defined via partial specializations that
pattern match on the const- and reference-ness of T.

This turns out to be more SFINAE friendly and significantly cheaper
to compile than the previous implementation.

libstdc++-v3/ChangeLog:

	* include/bits/move.h (__like_impl): New metafunction.
	(__like_t): Redefine in terms of __like_impl.
	(forward_like): Redefine in terms of __like_t.
	* testsuite/20_util/forward_like/2_neg.cc: Don't expect
	error outside the immediate context anymore.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 8256d5c009)
2024-09-08 19:58:20 -04:00
GCC Administrator 7e0649ac0f Daily bump. 2024-09-08 00:30:07 +00:00
Patrick Palka 0c80216b7b c++: template depth of lambda in default targ [PR116567]
For GCC 14, let's narrowly fix this bug by just pruning the result of
add_extra_args after the fact to get rid of any unwanted outer levels.

	PR c++/116567

gcc/cp/ChangeLog:

	* pt.cc (tsubst_lambda_expr): For a deferred-substitution lambda,
	trim the augmented template arguments to match the template depth
	of the lambda.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-07 14:10:09 -04:00
GCC Administrator 1e79541bed Daily bump. 2024-09-07 00:21:14 +00:00
Joseph Myers d4d7c4e219 Update gcc uk.po
* uk.po: Update.
2024-09-06 16:15:12 +00:00
GCC Administrator aedf6f810e Daily bump. 2024-09-06 00:22:34 +00:00
Marek Polacek fe668633f6 c++: vtable referring to "unavailable" virtual fn [PR116606]
mark_vtable_entries already has

   /* It's OK for the vtable to refer to deprecated virtual functions.  */
   warning_sentinel w(warn_deprecated_decl);

but that doesn't cover __attribute__((unavailable)).  We can use the
following override to cover both.

	PR c++/116606

gcc/cp/ChangeLog:

	* decl2.cc (mark_vtable_entries): Temporarily override deprecated_state to
	UNAVAILABLE_DEPRECATED_SUPPRESS.  Remove a warning_sentinel.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-unavailable-13.C: New test.

(cherry picked from commit d9d34f9a91)
2024-09-05 18:44:05 -04:00
H.J. Lu 6abedee0d4 ipa: Don't disable function parameter analysis for fat LTO
Update analyze_parms not to disable function parameter analysis for
-ffat-lto-objects.  Tested on x86-64, there are no differences in zstd
with "-O2 -flto=auto" -g "vs -O2 -flto=auto -g -ffat-lto-objects".

	PR ipa/116410
	* ipa-modref.cc (analyze_parms): Always analyze function parameter
	for LTO.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 2f1689ea8e)
2024-09-05 07:11:42 -07:00
Jakub Jelinek 2490951210 libsanitizer: On aarch64 use hint #34 in prologue of libsanitizer functions
When gcc is built with -mbranch-protection=standard, running sanitized
programs doesn't work properly on bti enabled kernels.

This has been fixed upstream with
https://github.com/llvm/llvm-project/pull/84061

The following patch cherry picks that from upstream.

For trunk we should eventually do a full merge from upstream, but I'm hoping
they will first fix up the _BitInt libubsan support mess.

2024-09-05  Jakub Jelinek  <jakub@redhat.com>

	* sanitizer_common/sanitizer_asm.h: Cherry-pick llvm-project revision
	1c792d24e0a228ad49cc004a1c26bbd7cd87f030.
	* interception/interception.h: Likewise.

(cherry picked from commit 2379cbb94b)
2024-09-05 12:23:50 +02:00
Jakub Jelinek 73afc3e47e lower-bitint: Fix up __builtin_{add,sub}_overflow{,_p} bitint lowering [PR116501]
The following testcase is miscompiled.  The problem is in the last_ovf step.
The second operand has signed _BitInt(513) type but has the MSB clear,
so range_to_prec returns 512 for it (i.e. it fits into unsigned
_BitInt(512)).  Because of that the last step actually doesn't need to get
the most significant bit from the second operand, but the code was deciding
what to use purely from TYPE_UNSIGNED (type1) - if unsigned, use 0,
otherwise sign-extend the last processed bit; but that in this case was set.
We don't want to treat the positive operand as if it was negative regardless
of the bit below that precision, and precN >= 0 indicates that the operand
is in the [0, inf) range.

2024-09-03  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/116501
	* gimple-lower-bitint.cc (bitint_large_huge::lower_addsub_overflow):
	In the last_ovf case, use build_zero_cst operand not just when
	TYPE_UNSIGNED (typeN), but also when precN >= 0.

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

(cherry picked from commit d4d75a8300)
2024-09-05 12:23:42 +02:00
Jakub Jelinek 6fb41c27b6 Don't call clean_symbol_name in create_tmp_var_name [PR116219]
SRA adds fancy names like offset$D94316$_M_impl$D93629$_M_start
where the numbers in there are DECL_UIDs if there are unnamed
FIELD_DECLs etc.
Because -g0 vs. -g can cause differences between the exact DECL_UID
values (add bigger gaps in between them, corresponding decls should
still be ordered the same based on DECL_UID) we make sure such
decls have DECL_NAMELESS set and depending on exact options either don't
dump such names at all or dump_fancy_name sanitizes the D123456$ parts in
there to Dxxxx$.
Unfortunately in tons of places we then use get_name to grab either user
names or these SRA created names and use that as argument to
create_tmp_var{,_name,_raw} to base other artificial temporary names based
on that.  Those are DECL_NAMELESS too, but unfortunately create_tmp_var_name
starting with
https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=725494f6e4121eace43b7db1202f8ecbf52a8276
calls clean_symbol_name which replaces the $s in there with _s and thus
dump_fancy_name doesn't sanitize it anymore.

I don't see any discussion of that commit (originally to TM branch, later
merged) on the mailing list, but from
   DECL_NAME (new_decl)
     = create_tmp_var_name (IDENTIFIER_POINTER (DECL_NAME (old_decl)));
-  SET_DECL_ASSEMBLER_NAME (new_decl, NULL_TREE);
+  SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
snippet elsewhere in that commit it seems create_tmp_var_name was used at
that point also to determine function names of clones, so presumably the
clean_symbol_name at that point was to ensure the symbol could be emitted
into assembly, maybe in case DECL_NAME is something like C++ operators or
whatever could have there undesirable characters.

Anyway, we don't do that for years anymore, already GCC 4.5 uses for such
purposes clone_function_name which starts of DECL_ASSEMBLER_NAME of the old
function and appends based on supportable symbol suffix separators the
separator and some suffix and/or number, so that part doesn't go through
create_tmp_var_name.

I don't see problems with having the $ and . etc. characters in the names
intended just to make dumps more readable, after all, we already are using
those in the SRA created names.  Those names shouldn't make it into the
assembly in any way, neither debug info nor assembly labels.

There is one theoretical case, where the gimplifier promotes automatic
vars into TREE_STATIC ones and therefore those can then appear in assembly,
just in case it would be on e.g. SRA created names and regimplified later.
Because no cases of promotion of DECL_NAMELESS vars to static was observed in
{x86_64,i686,powerpc64le}-linux bootstraps/regtests, the code simply uses
C.NNN names for DECL_NAMELESS vars like it does for !DECL_NAME vars.

Richi mentioned on IRC that the non-cleaned up names might make things
harder to feed stuff back to the GIMPLE FE, but if so, I think it should be
the dumping for GIMPLE FE purposes that cleans those up (but at that point
it should also verify if some such cleaned up names don't collide with
others and somehow deal with those).

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

	PR c++/116219
	* gimple-expr.cc (remove_suffix): Formatting fixes.
	(create_tmp_var_name): Don't call clean_symbol_name.
	* gimplify.cc (gimplify_init_constructor): When promoting automatic
	DECL_NAMELESS vars to static, don't preserve their DECL_NAME.

(cherry picked from commit 165e3e7c3b)
2024-09-05 12:23:30 +02:00
Tamar Christina 040b979a08 testsuite: remove -fwrapv from signbit-5.c
The meaning of the testcase was changed by passing it -fwrapv.  The reason for
the test failures on some platform was because the test was testing some
implementation defined behavior wrt INT_MIN in generic code.

Instead of using -fwrapv this just removes the border case from the test so
all the values now have a defined semantic.  It still relies on the handling of
shifting a negative value right, but that wasn't changed with -fwrapv anyway.

The -fwrapv case is being handled already by other testcases.

gcc/testsuite/ChangeLog:

	* gcc.dg/signbit-5.c: Remove -fwrapv and change INT_MIN to INT_MIN+1.

(cherry picked from commit 67eaf67360)
2024-09-05 11:44:25 +02:00
GCC Administrator 0c4a95e9f5 Daily bump. 2024-09-05 00:22:17 +00:00
Jonathan Wakely a054ba563b libstdc++: Fix error handling in fs::hard_link_count for Windows
The recent change to use auto_win_file_handle for
std::filesystem::hard_link_count caused a regression. The
std::error_code argument should be cleared if no error occurs, but this
no longer happens. Add a call to ec.clear() in fs::hard_link_count to
fix this.

Also change the auto_win_file_handle class to take a reference to the
std::error_code and set it if an error occurs, to slightly simplify the
control flow in the fs::equiv_files function.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_ops.cc (auto_win_file_handle): Add error_code&
	member and set it if CreateFileW or GetFileInformationByHandle
	fails.
	(fs::equiv_files) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Simplify
	control flow.
	(fs::hard_link_count) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Clear ec
	on success.
	* testsuite/27_io/filesystem/operations/hard_link_count.cc:
	Check error handling.

(cherry picked from commit 71b1639c67)
2024-09-04 21:34:36 +01:00
Jonathan Wakely 35c98149a5 libstdc++: Fix overwriting files with fs::copy_file on Windows
There are no inode numbers on Windows filesystems, so stat_type::st_ino
is always zero and the check for equivalent files in do_copy_file was
incorrectly identifying distinct files as equivalent. This caused
copy_file to incorrectly report errors when trying to overwrite existing
files.

The fs::equivalent function already does the right thing on Windows, so
factor that logic out into a new function that can be reused by
fs::copy_file.

The tests for fs::copy_file were quite inadequate, so this also adds
checks for that function's error conditions.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_ops.cc (auto_win_file_handle): Change constructor
	parameter from const path& to const wchar_t*.
	(fs::equiv_files): New function.
	(fs::equivalent): Use equiv_files.
	* src/filesystem/ops-common.h (fs::equiv_files): Declare.
	(do_copy_file): Use equiv_files.
	* src/filesystem/ops.cc (fs::equiv_files): Define.
	(fs::copy, fs::equivalent): Use equiv_files.
	* testsuite/27_io/filesystem/operations/copy.cc: Test
	overwriting directory contents recursively.
	* testsuite/27_io/filesystem/operations/copy_file.cc: Test
	overwriting existing files.

(cherry picked from commit 017e3f89b0)
2024-09-04 21:34:35 +01:00
Lennox Shou Hao Ho ec1bcd1763 libstdc++: Fix fs::hard_link_count behaviour on MinGW [PR113663]
std::filesystem::hard_link_count() always returns 1 on
mingw-w64ucrt-11.0.1-r3 on Windows 10 19045

hard_link_count() queries _wstat64() on MinGW-w64
The MSFT documentation claims _wstat64() will always return 1 *non*-NTFS volumes
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/14h5k7ff(v=vs.120)

My tests suggest that is not always true -
hard_link_count()/_wstat64() still returns 1 on NTFS.
GetFileInformationByHandle does return the correct result of 2.
Please see the PR for a minimal repro.

This patch changes the Windows implementation to always call
GetFileInformationByHandle.

	PR libstdc++/113663

libstdc++-v3/ChangeLog:

	* src/c++17/fs_ops.cc (fs::equivalent): Moved helper class
	auto_handle to anonymous namespace as auto_win_file_handle.
	(fs::hard_link_count): Changed Windows implementation to use
	information provided by GetFileInformationByHandle which is more
	reliable.
	* testsuite/27_io/filesystem/operations/hard_link_count.cc: New
	test.

Signed-off-by: "Lennox" Shou Hao Ho <lennoxhoe@gmail.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 658193658f)
2024-09-04 21:34:35 +01:00
Jonathan Wakely ee37d75026 libstdc++: Specialize std::disable_sized_sentinel_for for std::move_iterator [PR116549]
LWG 3736 added a partial specialization of this variable template for
two std::move_iterator types. This is needed for the case where the
types satisfy std::sentinel_for and are subtractable, but do not model
the semantics requirements of std::sized_sentinel_for.

libstdc++-v3/ChangeLog:

	PR libstdc++/116549
	* include/bits/stl_iterator.h (disable_sized_sentinel_for):
	Define specialization for two move_iterator types, as per LWG
	3736.
	* testsuite/24_iterators/move_iterator/lwg3736.cc: New test.

(cherry picked from commit 819deae0a5)
2024-09-04 21:34:35 +01:00
Dhruv Chawla 469602619d libstdc++: Add missing feature-test macro in various headers
version.syn#2 requires various headers to define
__cpp_lib_allocator_traits_is_always_equal. Currently, only <memory> was
defining this macro. Implement fixes for the other headers as well.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>

libstdc++-v3/ChangeLog:

	* include/std/deque: Define macro
	__glibcxx_want_allocator_traits_is_always_equal.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/scoped_allocator: Likewise.
	* include/std/set: Likewise.
	* include/std/string: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/20_util/headers/memory/version.cc: New test.
	* testsuite/20_util/scoped_allocator/version.cc: Likewise.
	* testsuite/21_strings/headers/string/version.cc: Likewise.
	* testsuite/23_containers/deque/version.cc: Likewise.
	* testsuite/23_containers/forward_list/version.cc: Likewise.
	* testsuite/23_containers/list/version.cc: Likewise.
	* testsuite/23_containers/map/version.cc: Likewise.
	* testsuite/23_containers/set/version.cc: Likewise.
	* testsuite/23_containers/unordered_map/version.cc: Likewise.
	* testsuite/23_containers/unordered_set/version.cc: Likewise.
	* testsuite/23_containers/vector/version.cc: Likewise.

(cherry picked from commit efe6efb6f3)
2024-09-04 21:34:35 +01:00
Jonathan Wakely 3b8a67b0cf libstdc++: Fix std::variant to reject array types [PR116381]
For the backport, rejecting array types is only done in strict modes.

libstdc++-v3/ChangeLog:

	PR libstdc++/116381
	* include/std/variant (variant): Fix conditions for
	static_assert to match the spec.
	* testsuite/20_util/variant/types_neg.cc: New test.

(cherry picked from commit 1e10b3b882)
2024-09-04 21:34:35 +01:00
Andrew Carlotti 9899be7d53 aarch64: Fix ls64 intrinsic availability
The availability of ls64 intrinsics and data types were determined
solely by the globally specified architecture features, which did not
reflect any changes specified in target pragmas or attributes.

This patch removes the initialisation-time guards for the intrinsics,
and replaces them with checks at use time. We also get better error
messages when ls64 is not available (matching the existing error
messages for SVE intrinsics).

The data512_t type is made always available; this is consistent with the
present behaviour for Neon fp16/bf16 types.

gcc/ChangeLog:

	PR target/112108
	* config/aarch64/aarch64-builtins.cc (handle_arm_acle_h): Remove
	feature check at initialisation.
	(aarch64_general_check_builtin_call): Check ls64 intrinsics.
	* config/aarch64/arm_acle.h: (data512_t) Make always available.

gcc/testsuite/ChangeLog:

	PR target/112108
	* gcc.target/aarch64/acle/ls64_guard-1.c: New test.
	* gcc.target/aarch64/acle/ls64_guard-2.c: New test.
	* gcc.target/aarch64/acle/ls64_guard-3.c: New test.
	* gcc.target/aarch64/acle/ls64_guard-4.c: New test.
2024-09-04 19:25:57 +01:00
Andrew Carlotti 8485606056 aarch64: Fix memtag intrinsic availability
The availability of memtag intrinsics and data types were determined
solely by the globally specified architecture features, which did not
reflect any changes specified in target pragmas or attributes.

This patch removes the initialisation-time guards for the intrinsics,
and replaces them with checks at use time. It also removes the macro
indirection from the header file - this simplifies the header, and
allows the missing extension error reporting to find the user-facing
intrinsic names.

gcc/ChangeLog:

	PR target/112108
	* config/aarch64/aarch64-builtins.cc (aarch64_init_memtag_builtins):
	Define intrinsic names directly.
	(aarch64_general_init_builtins): Move memtag intialisation...
	(handle_arm_acle_h): ...to here, and remove feature check.
	(aarch64_general_check_builtin_call): Check memtag intrinsics.
	* config/aarch64/arm_acle.h (__arm_mte_create_random_tag)
	(__arm_mte_exclude_tag, __arm_mte_ptrdiff)
	(__arm_mte_increment_tag, __arm_mte_set_tag, __arm_mte_get_tag):
	Remove.

gcc/testsuite/ChangeLog:

	PR target/112108
	* gcc.target/aarch64/acle/memtag_guard-1.c: New test.
	* gcc.target/aarch64/acle/memtag_guard-2.c: New test.
	* gcc.target/aarch64/acle/memtag_guard-3.c: New test.
	* gcc.target/aarch64/acle/memtag_guard-4.c: New test.
2024-09-04 19:25:56 +01:00
Andrew Carlotti 0a3a0d4a5e aarch64: Fix tme intrinsic availability
The availability of tme intrinsics was previously gated at both
initialisation time (using global target options) and usage time
(accounting for function-specific target options).  This patch removes
the check at initialisation time, and also moves the intrinsics out of
the header file to allow for better error messages (matching the
existing error messages for SVE intrinsics).

gcc/ChangeLog:

	PR target/112108
	* config/aarch64/aarch64-builtins.cc (aarch64_init_tme_builtins):
	Define intrinsic names directly.
	(aarch64_general_init_builtins): Move tme initialisation...
	(handle_arm_acle_h): ...to here, and remove feature check.
	(aarch64_general_check_builtin_call): Check tme intrinsics.
	* config/aarch64/arm_acle.h (__tstart, __tcommit, __tcancel)
	(__ttest): Remove.
	(_TMFAILURE_*): Define unconditionally.

gcc/testsuite/ChangeLog:

	PR target/112108
	* gcc.target/aarch64/acle/tme_guard-1.c: New test.
	* gcc.target/aarch64/acle/tme_guard-2.c: New test.
	* gcc.target/aarch64/acle/tme_guard-3.c: New test.
	* gcc.target/aarch64/acle/tme_guard-4.c: New test.
2024-09-04 19:25:56 +01:00
Andrew Carlotti 422c3f1965 aarch64: Move check_required_extensions
Move SVE extension checking functionality to aarch64-builtins.cc, so
that it can be shared by non-SVE intrinsics.

gcc/ChangeLog:

	* config/aarch64/aarch64-sve-builtins.cc (check_builtin_call)
	(expand_builtin): Update calls to the below.
	(report_missing_extension, report_missing_registers)
	(check_required_extensions): Move out of aarch64_sve namespace,
	rename, and move into...
	* config/aarch64/aarch64-builtins.cc (aarch64_report_missing_extension)
	(aarch64_report_missing_registers)
	(aarch64_check_required_extensions) ...here.
	* config/aarch64/aarch64-protos.h (aarch64_check_required_extensions):
	Add prototype.
2024-09-04 19:25:56 +01:00
Andrew Carlotti c6e04d1f92 aarch64: Refactor check_required_extensions
Replace TARGET_GENERAL_REGS_ONLY check with an explicit check that
aarch64_isa_flags enables all required extensions.  This will be more
flexible when repurposing this function for non-SVE intrinsics.

gcc/ChangeLog:

	* config/aarch64/aarch64-sve-builtins.cc
	(check_required_registers): Remove target check and rename to...
	(report_missing_registers): ...this.
	(check_required_extensions): Refactor.
2024-09-04 19:25:55 +01:00
H.J. Lu 0562522e12 lto: Don't check obj.found for offload section
obj.found is the number of LTO symbols.  We should include the offload
section when it is used by linker even if there are no LTO symbols.

	PR lto/116361
	* lto-plugin.c (claim_file_handler_v2): Don't check obj.found
	for the offload section.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit cb51e0b236)
2024-09-04 04:51:02 -07:00
H.J. Lu 66eb7b752a Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook
This hook allows the BFD linker plugin to distinguish calls to
claim_file_handler that know the object is being used by the linker
(from ldmain.c:add_archive_element), from calls that don't know it's
being used by the linker (from elf_link_is_defined_archive_symbol); in
the latter case, the plugin should avoid including the unused LTO archive
members in link output.  To get the proper support for archives with LTO
common symbols, the linker fix

commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Aug 14 20:50:02 2024 -0700

    lto: Don't include unused LTO archive members in output

is required.

	PR lto/116361
	* lto-plugin.c (claim_file_handler_v2): Rename claimed to
	can_be_claimed.  Include the LTO object only if it is known to
	be included in link output.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit a98dd536b1)
2024-09-04 04:50:54 -07:00
GCC Administrator 5c1955f563 Daily bump. 2024-09-04 00:27:51 +00:00
Haochen Jiang 59157c038d i386: Fix vfpclassph non-optimizied intrin
The intrin for non-optimized got a typo in mask type, which will cause
the high bits of __mmask32 being unexpectedly zeroed.

The test does not fail under O0 with current 1b since the testcase is
wrong. We need to include avx512-mask-type.h after SIZE is defined, or
it will always be __mmask8. I will write a seperate patch to fix that
on trunk ONLY.

gcc/ChangeLog:

	* config/i386/avx512fp16intrin.h
	(_mm512_mask_fpclass_ph_mask): Correct mask type to __mmask32.
	(_mm512_fpclass_ph_mask): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-vfpclassph-1c.c: New test.
2024-09-03 16:51:25 +08:00
GCC Administrator 2ac3806d54 Daily bump. 2024-09-03 00:32:49 +00:00
liuhongt ba9a3f105e Check avx upper register for parallel.
For function arguments/return, when it's BLK mode, it's put in a
parallel with an expr_list, and the expr_list contains the real mode
and registers.
Current ix86_check_avx_upper_register only checked for SSE_REG_P, and
failed to handle that. The patch extend the handle to each subrtx.

gcc/ChangeLog:

	PR target/116512
	* config/i386/i386.cc (ix86_check_avx_upper_register): Iterate
	subrtx to scan for avx upper register.
	(ix86_check_avx_upper_stores): Inline old
	ix86_check_avx_upper_register.
	(ix86_avx_u128_mode_needed): Ditto, and replace
	FOR_EACH_SUBRTX with call to new
	ix86_check_avx_upper_register.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit ab214ef734)
2024-09-02 09:37:15 +08:00
GCC Administrator db4d81090b Daily bump. 2024-09-02 00:25:48 +00:00
GCC Administrator a2e32a8856 Daily bump. 2024-09-01 00:36:10 +00:00
GCC Administrator 657bf4a01b Daily bump. 2024-08-31 00:22:43 +00:00
Harald Anlauf 5999dd8a61 Fortran: fix ICE with use with rename of namelist member [PR116530]
gcc/fortran/ChangeLog:

	PR fortran/116530
	* trans-io.cc (transfer_namelist_element): Prevent NULL pointer
	dereference.

gcc/testsuite/ChangeLog:

	PR fortran/116530
	* gfortran.dg/use_rename_12.f90: New test.

(cherry picked from commit 6bfeba12c8)
2024-08-30 10:58:23 +02:00
GCC Administrator 552c7c12e3 Daily bump. 2024-08-30 00:30:04 +00:00
GCC Administrator d3c14d4086 Daily bump. 2024-08-29 00:25:52 +00:00
Joseph Myers 4d6c0c0a0b Add gcc ka.po
* ka.po: New file.
2024-08-28 16:32:11 +00:00
Xi Ruoyao f5b3dae221 i386: testsuite: Adapt fentryname3.c for r14-811 change [PR70150]
After r14-811 "call *nop@GOTPCREL(%rip)" is only generated with
-mno-direct-extern-access even if --enable-default-pie.  So the r13-1614
change to this file is not valid anymore.

gcc/testsuite/ChangeLog:

	PR testsuite/70150
	* gcc.target/i386/fentryname3.c (dg-final): Revert r13-1614
	change.

(cherry picked from commit 8035619b73)
2024-08-28 16:22:19 +08:00
Xi Ruoyao 377c3e9a8b i386: testsuite: Add -no-pie for pr113689-1.c [PR70150]
For a --enable-default-pie build, using -fno-pic (for compiler) but
not -no-pie (for linker) triggers some linker warnings counted as
excess errors:

    /usr/bin/ld: /tmp/cc8MgxiR.o: warning: relocation in read-only
    section `.text.startup'
    /usr/bin/ld: warning: creating DT_TEXTREL in a PIE

gcc/testsuite/ChangeLog:

	PR testsuite/70150
	* gcc.target/i386/pr113689-1.c (dg-options): Add -no-pie.

(cherry picked from commit 331f7d8a39)
2024-08-28 16:22:09 +08:00
GCC Administrator 87aea23f9d Daily bump. 2024-08-28 00:24:02 +00:00
Joseph Myers 90b123253d Update gcc zh_CN.po
* zh_CN.po: Update.
2024-08-27 21:21:58 +00:00
YunQiang Su 75892d9797 MIPS: Include missing mips16.S in libgcc/lib1funcs.S
mips16.S was missing since
commit 29b7454553
Date:   Thu Jun 1 10:14:24 2023 +0800

    MIPS: Add speculation_barrier support

Without mips16.S included, some symbols will miss for mips16, and
so some software will fail to build.

libgcc/ChangeLog:

	* config/mips/lib1funcs.S: Includes mips16.S.

(cherry picked from commit 9522fc8bb7)
2024-08-27 08:22:13 +08:00
GCC Administrator ef9c53b6e6 Daily bump. 2024-08-26 00:23:14 +00:00
GCC Administrator b414466d1c Daily bump. 2024-08-25 00:23:36 +00:00
GCC Administrator 5b75e1c15f Daily bump. 2024-08-24 00:22:38 +00:00
GCC Administrator 8de3153a65 Daily bump. 2024-08-23 00:21:22 +00:00
liuhongt 27dc1533b6 Align ix86_{move_max,store_max} with vectorizer.
When none of mprefer-vector-width, avx256_optimal/avx128_optimal,
avx256_store_by_pieces/avx512_store_by_pieces is specified, GCC will
set ix86_{move_max,store_max} as max available vector length except
for AVX part.

	      if (TARGET_AVX512F_P (opts->x_ix86_isa_flags)
		  && TARGET_EVEX512_P (opts->x_ix86_isa_flags2))
		opts->x_ix86_move_max = PVW_AVX512;
	      else
		opts->x_ix86_move_max = PVW_AVX128;

So for -mavx2, vectorizer will choose 256-bit for vectorization, but
128-bit is used for struct copy, there could be a potential STLF issue
due to this "misalign".

The patch fixes that.

gcc/ChangeLog:

	* config/i386/i386-options.cc (ix86_option_override_internal):
	set ix86_{move_max,store_max} to PVW_AVX256 when TARGET_AVX
	instead of PVW_AVX128.

gcc/testsuite/ChangeLog:
	* gcc.target/i386/pieces-memcpy-10.c: Add -mprefer-vector-width=128.
	* gcc.target/i386/pieces-memcpy-6.c: Ditto.
	* gcc.target/i386/pieces-memset-38.c: Ditto.
	* gcc.target/i386/pieces-memset-40.c: Ditto.
	* gcc.target/i386/pieces-memset-41.c: Ditto.
	* gcc.target/i386/pieces-memset-42.c: Ditto.
	* gcc.target/i386/pieces-memset-43.c: Ditto.
	* gcc.target/i386/pieces-strcpy-2.c: Ditto.
	* gcc.target/i386/pieces-memcpy-22.c: New test.
	* gcc.target/i386/pieces-memset-51.c: New test.
	* gcc.target/i386/pieces-strcpy-3.c: New test.

(cherry picked from commit 6ea25c0419)
2024-08-22 10:31:42 +08:00
GCC Administrator ffd458d815 Daily bump. 2024-08-22 00:22:57 +00:00
GCC Administrator 5146af5ede Daily bump. 2024-08-21 00:24:10 +00:00
Alexandre OlivaandRichard Earnshaw 25812d8b78 [testsuite] [arm] [vect] adjust mve-vshr test [PR113281]
The test was too optimistic, alas.  We used to vectorize shifts by
clamping the shift counts below the bit width of the types (e.g. at 15
for 16-bit vector elements), but (uint16_t)32768 >> (uint16_t)16 is
well defined (because of promotion to 32-bit int) and must yield 0,
not 1 (as before the fix).

Unfortunately, in the gimple model of vector units, such large shift
counts wouldn't be well-defined, so we won't vectorize such shifts any
more, unless we can tell they're in range or undefined.

So the test that expected the vectorization we no longer performed
needs to be adjusted.  Instead of nobbling the test, Richard Earnshaw
suggested annotating the test with the expected ranges so as to enable
the optimization, and Christophe Lyon suggested a further
simplification.

Co-Authored-By: Richard Earnshaw <Richard.Earnshaw@arm.com>

for  gcc/testsuite/ChangeLog

	PR tree-optimization/113281
	* gcc.target/arm/simd/mve-vshr.c: Add expected ranges.

(cherry picked from commit 54d2339c9f)
2024-08-20 16:11:48 +01:00
GCC Administrator 76ac16766a Daily bump. 2024-08-20 00:23:37 +00:00
Marek Polacek 52da8588fd c++: fix ICE in convert_nontype_argument [PR116384]
Here we ICE since r14-8291 in C++11/C++14 modes.  Fortunately
this is an easy one.

The important bit of r14-8291 is this:

@@ -20056,9 +20071,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
        RETURN (retval);
      }
    if (IMPLICIT_CONV_EXPR_NONTYPE_ARG (t))
-     /* We'll pass this to convert_nontype_argument again, we don't need
-        to actually perform any conversion here.  */
-     RETURN (expr);
+     {
+       tree r = convert_nontype_argument (type, expr, complain);
+       if (r == NULL_TREE)
+         r = error_mark_node;
+       RETURN (r);
+     }

which obviously means that instead of returning right away we go
to convert_nontype_argument.  When type is error_mark_node and we're
in C++17, in convert_nontype_argument we go down this path:

      else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
               || cxx_dialect >= cxx17)
        {
          expr = build_converted_constant_expr (type, expr, complain);
          if (expr == error_mark_node)
            return (complain & tf_error) ? NULL_TREE : error_mark_node;
	  // ...
	}

but pre-C++17, we take a different route and end up crashing on
gcc_unreachable.

It would of course also work to check for error_mark_node early in
build_converted_constant_expr.

	PR c++/116384

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr) <case IMPLICIT_CONV_EXPR>: Bail if tsubst
	returns error_mark_node.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/vt-116384.C: New test.

(cherry picked from commit 8191f15022)
2024-08-19 13:36:06 -04:00
Torbjörn SVENSSON af97b5eb02 testsuite: Prune warning about size of enums
This fixes reported regression at
https://linaro.atlassian.net/browse/GNU-1315.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/pr33738-2.C: dg-prune arm linker messages about
	size of enums.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 6d8b9b772e)
2024-08-19 10:50:27 +02:00
GCC Administrator 1fad6adae9 Daily bump. 2024-08-19 00:21:54 +00:00
Georg-Johann Lay c725748663 AVR: ad target/116407 - Fix linker error "relocation truncated to fit".
PR target/116407
gcc/
	* config/avr/avr.md (*dec-and-branchhi!=-1.l.clobber):
	Increase the additional jump offset to 2 words.

(cherry picked from commit 22acd3c4d1)
2024-08-18 18:42:13 +02:00
Georg-Johann Lay 919c42bf44 AVR: target/116407 - Fix linker error "relocation truncated to fit".
Some text peepholes output extra instructions prior to a branch
instruction and that increase the jump offset of backward branches.

	PR target/116407
gcc/
	* config/avr/avr-protos.h (avr_jump_mode): Add an int argument.
	* config/avr/avr.cc (avr_jump_mode): Add an int argument to increase
	the computed jump offset of backwards branches.
	* config/avr/avr.md (*dec-and-branchhi!=-1, *dec-and-branchsi!=-1):
	Increase the jump offset used by avr_jump_mode() as needed.
gcc/testsuite/
	* gcc.target/avr/torture/pr116407-2.c: New test.
	* gcc.target/avr/torture/pr116407-4.c: New test.

(cherry picked from commit dfb2e8caa8)
2024-08-18 15:45:35 +02:00
GCC Administrator f4ce0980da Daily bump. 2024-08-18 00:21:22 +00:00
Georg-Johann Lay f3d9c120a1 AVR: target/116390 - Fix an avrtiny asm out template.
PR target/116390
gcc/
	* config/avr/avr.cc (avr_out_movsi_mr_r_reg_disp_tiny): Fix
	output templates for the reg_base == reg_src and
	reg_src == reg_base - 2 cases.
gcc/testsuite/
	* gcc.target/avr/torture/pr116390.c: New test.

(cherry picked from commit 4065d16315)
2024-08-17 13:35:32 +02:00
GCC Administrator 02960011cb Daily bump. 2024-08-17 00:21:45 +00:00
Georg-Johann Lay 507b4e1475 AVR: target/85624 - Use HImode for clrmemqi alignment.
gcc/
	PR target/85624
	* config/avr/avr.md (*clrmemqi*): Use HImode for alignment operand.

gcc/testsuite/
	* gcc.target/avr/torture/pr85624.c: New test.
2024-08-16 18:16:37 +02:00
Torbjörn SVENSSON edf95a4910 testsuite: Verify -fshort-enums and -fno-short-enums in pr33738.C
For some targets, like Cortex-M on arm-none-eabi, the -fshort-enums is
enabled by default. For these targets, the test case fails as
sizeof(Alpha) < sizeof(int).
To make the test case behave identical for targets that does enable
-fshort-enums and those that does not, add -fno-short-enums in the test
case and verify that the warning is not emitted. Then also create a copy
and run the test with -fshort-enums and verify that the warning is
emitted.

Regtested on x86_64-pc-linux-gnu and arm-none-eabi.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/pr33738.C: Added -fno-short-enums.
	* g++.dg/warn/pr33738-2.C: Duplicate g++.dg/warn/pr33738.C with
	-fshort-enums and removed xfail.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 479dab62b8)
2024-08-16 16:52:06 +02:00
Torbjörn SVENSSON 5c1f687288 testsuite: Add -fno-short-enums to pr97315-1.C
The test case assumes that sizeof(tree_code) >= 2. On some targets, like
Cortex-M on arm-none-eabi, -fshort-enums is enabled by default and in
that case, sizeof(tree_code) will be 1 and the following warning is
emitted:

.../pr97315-1.C:8:13: warning: width of 'tree_base::code' exceeds its type

Avoid the warning by forcing -fno-short-enums.

gcc/testsuite/ChangeLog:

	* g++.dg/opt/pr97315-1.C: Add -fno-short-enums.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 10bf035775)
2024-08-16 16:43:27 +02:00
Torbjörn SVENSSON 345d1452dc testsuite: Add -fwrapv to signbit-5.c
On Cortex-M55 with MVE, the test case fails due to -INT_MAX being
undefined. Adding -fwrapv solves the issues.

Regtested on x86_64-pc-linux-gnu and arm-none-eabi for
Cortex-M0/M3/M4/M7/M33/M55/M85/A7.

gcc/testsuite/ChangeLog:

	* gcc.dg/signbit-5.c: Add -fwrapv and remove x86 exception.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
(cherry picked from commit 5a3387938d)
2024-08-16 16:23:56 +02:00
Lingling Kong 45a771d22e i386: Fix some vex insns that prohibit egpr
Although these vex insn have evex counterpart, but when it
uses the displayed vex prefix should not support APX EGPR.
Like TARGET_AVXVNNI, TARGET_IFMA and TARGET_AVXNECONVERT.
TARGET_AVXVNNIINT8 and TARGET_AVXVNNITINT16 also are vex
insn should not support egpr.

gcc/ChangeLog:

	* config/i386/sse.md (vpmadd52<vpmadd52type><mode>):
	Prohibit egpr for vex version.
	(vpdpbusd_<mode>): Ditto.
	(vpdpbusds_<mode>): Ditto.
	(vpdpwssd_<mode>): Ditto.
	(vpdpwssds_<mode>): Ditto.
	(*vcvtneps2bf16_v4sf): Ditto.
	(*vcvtneps2bf16_v8sf): Ditto.
	(vpdp<vpdotprodtype>_<mode>): Ditto.
	(vbcstnebf162ps_<mode>): Ditto.
	(vbcstnesh2ps_<mode>): Ditto.
	(vcvtnee<bf16_ph>2ps_<mode>): Ditto.
	(vcvtneo<bf16_ph>2ps_<mode>): Ditto.
	(vpdp<vpdpwprodtype>_<mode>): Ditto.
2024-08-16 16:37:24 +08:00
Richard Sandiford 86dacfb06b aarch64: Add another use of force_subreg [PR115464]
This patch includes the testcase from r15-1399 plus a miminal
fix for it, without the other proactive uses of force_subreg.
We can backport other force_subreg calls later if they're shown
to be needed.

gcc/
	PR target/115464
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svset_neonq_impl::expand): Use force_subreg instead of
	lowpart_subreg.

gcc/testsuite/
	PR target/115464
	* gcc.target/aarch64/sve/acle/general/pr115464_2.c: New test.
2024-08-16 07:53:02 +01:00
Richard Sandiford 32b21292ad aarch64: Fix invalid nested subregs [PR115464]
The testcase extracts one arm_neon.h vector from a pair (one subreg)
and then reinterprets the result as an SVE vector (another subreg).
Each subreg makes sense individually, but we can't fold them together
into a single subreg: it's 32 bytes -> 16 bytes -> 16*N bytes,
but the interpretation of 32 bytes -> 16*N bytes depends on
whether N==1 or N>1.

Since the second subreg makes sense individually, simplify_subreg
should bail out rather than ICE on it.  simplify_gen_subreg will
then do the same (because it already checks validate_subreg).
This leaves simplify_gen_subreg returning null, requiring the
caller to take appropriate action.

I think this is relatively likely to occur elsewhere, so the patch
adds a helper for forcing a subreg, allowing a temporary pseudo to
be created where necessary.

I'll follow up by using force_subreg in more places.  This patch
is intended to be a minimal backportable fix for the PR.

gcc/
	PR target/115464
	* simplify-rtx.cc (simplify_context::simplify_subreg): Don't try
	to fold two subregs together if their relationship isn't known
	at compile time.
	* explow.h (force_subreg): Declare.
	* explow.cc (force_subreg): New function.
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svset_neonq_impl::expand): Use it instead of simplify_gen_subreg.

gcc/testsuite/
	PR target/115464
	* gcc.target/aarch64/sve/acle/general/pr115464.c: New test.

(cherry picked from commit 0970ff46ba)
2024-08-16 07:53:01 +01:00
liuhongt 4e7735a8d8 Move ix86_align_loops into a separate pass and insert the pass after pass_endbr_and_patchable_area.
gcc/ChangeLog:

	PR target/116174
	* config/i386/i386.cc (ix86_align_loops): Move this to ..
	* config/i386/i386-features.cc (ix86_align_loops): .. here.
	(class pass_align_tight_loops): New class.
	(make_pass_align_tight_loops): New function.
	* config/i386/i386-passes.def: Insert pass_align_tight_loops
	after pass_insert_endbr_and_patchable_area.
	* config/i386/i386-protos.h (make_pass_align_tight_loops): New
	declare.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit c3c83d22d2)
2024-08-16 11:14:02 +08:00
GCC Administrator ccca8dfba8 Daily bump. 2024-08-16 00:22:18 +00:00
Patrick Palka 63c51e09d1 c++/coroutines: fix passing *this to promise type, again [PR116327]
In r15-2210 we got rid of the unnecessary cast to lvalue reference when
passing *this to the promise type ctor, and as a drive-by change we also
simplified the code to use cp_build_fold_indirect_ref.

But it turns out cp_build_fold_indirect_ref does too much here, namely
it has a shortcut for returning current_class_ref if the operand is
current_class_ptr.  The problem with that shortcut is current_class_ref
might have gotten clobbered earlier if it appeared in the function body,
since rewrite_param_uses walks and rewrites in-place all local variable
uses to their corresponding frame copy.

So later cp_build_fold_indirect_ref for *this will instead return the
clobbered current_class_ref i.e. *frame_ptr->this, which doesn't make
sense here since we're in the ramp function and not the actor function
where frame_ptr is in scope.

This patch fixes this by using the build_fold_indirect_ref instead of
cp_build_fold_indirect_ref.

	PR c++/116327
	PR c++/104981
	PR c++/115550

gcc/cp/ChangeLog:

	* coroutines.cc (morph_fn_to_coro): Use build_fold_indirect_ref
	instead of cp_build_fold_indirect_ref.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr104981-preview-this.C: Improve coverage by
	adding a non-static data member use within the coroutine member
	function.
	* g++.dg/coroutines/pr116327-preview-this.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 303bed670a)
2024-08-15 10:21:04 -04:00
Craig Blackmore d9bd361d89 [PATCH] RISC-V: Fix unresolved mcpu-[67].c tests
These tests check the sched2 dump, so skip them for optimization levels
that do not enable sched2.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/mcpu-6.c: Skip for -O0, -O1, -Og.
	* gcc.target/riscv/mcpu-7.c: Likewise.

(cherry picked from commit 77f3b3419d)
2024-08-15 14:19:06 +08:00
Pan Li 8c98f0601f RISC-V: Make full-vec-move1.c test robust for optimization
During investigate the support of early break autovec, we notice
the test full-vec-move1.c will be optimized to 'return 0;' in main
function body.  Because somehow the value of V type is compiler
time constant,  and then the second loop will be considered as
assert (true).

Thus,  the ccp4 pass will eliminate these stmt and just return 0.

typedef int16_t V __attribute__((vector_size (128)));

int main ()
{
  V v;
  for (int i = 0; i < sizeof (v) / sizeof (v[0]); i++)
    (v)[i] = i;

  V res = v;
  for (int i = 0; i < sizeof (v) / sizeof (v[0]); i++)
    assert (res[i] == i); // will be optimized to assert (true)
}

This patch would like to introduce a extern function to use the res[i]
that get rid of the ccp4 optimization.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls-vlmax/full-vec-move1.c:
	Introduce extern func use to get rid of ccp4 optimization.

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit b1520d2260)
2024-08-15 14:18:58 +08:00
GCC Administrator 726898510b Daily bump. 2024-08-15 00:26:05 +00:00
Stefan Schulze Frielinghaus e903ada5e8 s390: Fix high-level builtins vec_gfmsum{,_accum}_128
Starting with r14-9449-g9f2b16ce1efef0 builtins were streamlined with
those in LLVM.  In particular s390_vgfm{,a}g have been changed from
UV16QI to UINT128 in order to match those in LLVM.  However, these
low-level builtins are directly used by the high-level builtins
vec_gfmsum{,_accum}_128 which expect UV16QI instead.  Therefore,
introduce new low-level builtins s390_vgfm{,a}g_128 and make use of
them, respectively.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def (BT_FN_UV16QI_UV2DI_UV2DI):
	New.
	(BT_FN_UV16QI_UV2DI_UV2DI_UV16QI): New.
	* config/s390/s390-builtins.def (s390_vgfmg_128): New.
	(s390_vgfmag_128): New.
	* config/s390/vecintrin.h (vec_gfmsum_128): Use s390_vgfmg_128.
	(vec_gfmsum_accum_128): Use s390_vgfmag_128.

(cherry picked from commit e8a7142a69)
2024-08-14 20:12:35 +02:00
GCC Administrator 5a63e19fd4 Daily bump. 2024-08-14 00:22:22 +00:00
Michael Meissner 7d9bb37174 Add -mcpu=power11 support.
This patch adds the power11 option to the -mcpu= and -mtune= switches.

This patch treats the power11 like a power10 in terms of costs and reassociation
width.

This patch issues a ".machine power11" to the assembly file if you use
-mcpu=power11.

This patch defines _ARCH_PWR11 if the user uses -mcpu=power11.

This patch allows GCC to be configured with the --with-cpu=power11 and
--with-tune=power11 options.

This patch passes -mpwr11 to the assembler if the user uses -mcpu=power11.

This patch adds support for using "power11" in the __builtin_cpu_is built-in
function.

Backported from master: 2024-07-22

2024-08-13  Michael Meissner  <meissner@linux.ibm.com>

gcc/

	* config.gcc (powerpc*-*-*): Add support for power11.
	* config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for -mcpu=power11.
	* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
	* config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
	* config/rs6000/driver-rs6000.cc (asm_names): Likewise.
	* config/rs6000/ppc-auxv.h (PPC_PLATFORM_POWER11): New define.
	* config/rs6000/rs6000-builtin.cc (cpu_is_info): Add power11.
	* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
	_ARCH_PWR11 if -mcpu=power11.
	* config/rs6000/rs6000-cpus.def (POWER11_MASKS_SERVER): New define.
	(POWERPC_MASKS): Add power11.
	(power11 cpu): Add power11 definition.
	* config/rs6000/rs6000-opts.h (PROCESSOR_POWER11): Add power11 processor.
	* config/rs6000/rs6000-string.cc (expand_compare_loop): Likewise.
	* config/rs6000/rs6000-tables.opt: Regenerate.
	* config/rs6000/rs6000.cc (rs6000_option_override_internal): Add power11
	support.
	(rs6000_machine_from_flags): Likewise.
	(rs6000_reassociation_width): Likewise.
	(rs6000_adjust_cost): Likewise.
	(rs6000_issue_rate): Likewise.
	(rs6000_sched_reorder): Likewise.
	(rs6000_sched_reorder2): Likewise.
	(rs6000_register_move_cost): Likewise.
	(rs6000_opt_masks): Likewise.
	* config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
	* config/rs6000/rs6000.md (cpu attribute): Add power11.
	* config/rs6000/rs6000.opt (-mpower11): Add internal power11 flag.
	* doc/invoke.texi (RS/6000 and PowerPC Options): Document -mcpu=power11.
	* config/rs6000/power10.md (all reservations): Add power11 support.

gcc/testsuite/

	* gcc.target/powerpc/power11-1.c: New test.
	* gcc.target/powerpc/power11-2.c: Likewise.
	* gcc.target/powerpc/power11-3.c: Likewise.
2024-08-13 17:24:20 -04:00
GCC Administrator f688431db9 Daily bump. 2024-08-13 00:22:33 +00:00
GCC Administrator 6bfd78c595 Daily bump. 2024-08-12 00:22:44 +00:00
GCC Administrator 534ffe70e9 Daily bump. 2024-08-11 00:22:27 +00:00
GCC Administrator 6f1e687d23 Daily bump. 2024-08-10 00:22:40 +00:00
Jakub Jelinek b0dd13efca i386: Fix up __builtin_ia32_b{extr{,i}_u{32,64},zhi_{s,d}i} folding [PR116287]
The GENERIC folding of these builtins have cases where it folds to a
constant regardless of the value of the first operand.  If so, we need
to use omit_one_operand to avoid throwing away side-effects in the first
operand if any.  The cases which verify the first argument is INTEGER_CST
don't need that, INTEGER_CST doesn't have side-effects.

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

	PR target/116287
	* config/i386/i386.cc (ix86_fold_builtin) <case IX86_BUILTIN_BEXTR32>:
	When folding into zero without checking whether first argument is
	constant, use omit_one_operand.
	(ix86_fold_builtin) <case IX86_BUILTIN_BZHI32>: Likewise.

	* gcc.target/i386/bmi-pr116287.c: New test.
	* gcc.target/i386/bmi2-pr116287.c: New test.
	* gcc.target/i386/tbm-pr116287.c: New test.

(cherry picked from commit 6e7088dbe3)
2024-08-09 14:58:52 +02:00
GCC Administrator 897cd794d3 Daily bump. 2024-08-09 00:22:36 +00:00
Georg-Johann Lay 9ca1d7a36a AVR: target/116295 - Fix unrecognizable insn with __flash read.
Some loads from non-generic address-spaces are performed by
libgcc calls, and they don't have a POST_INC form.  Don't consider
such insns when running -mfuse-add.

	PR target/116295
gcc/
	* config/avr/avr.cc (Mem_Insn::Mem_Insn): Don't consider MEMs
	that are avr_mem_memx_p or avr_load_libgcc_p.

gcc/testsuite/
	* gcc.target/avr/torture/pr116295.c: New test.

(cherry picked from commit c4d3dba253)
2024-08-08 19:11:21 +02:00
GCC Administrator a9255df9c8 Daily bump. 2024-08-08 00:23:29 +00:00
GCC Administrator 49e8eeeb38 Daily bump. 2024-08-07 00:21:46 +00:00
Jason Merrill b1102f7c47 c++: alias and non-type template parm [PR116223]
My r14-8291 for PR112632 introduced IMPLICIT_CONV_EXPR_FORCED to express
conversions to the type of an alias template parameter.  In this example,
that broke deduction of X in the call to foo, so let's teach deduction to
look through it.

	PR c++/116223
	PR c++/112632

gcc/cp/ChangeLog:

	* pt.cc (deducible_expression): Also look through
	IMPLICIT_CONV_EXPR_FORCED.
	(unify): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype-auto25.C: New test.

(cherry picked from commit 4add6cd341)
2024-08-06 17:47:08 -04:00
Jason Merrill 987fc81740 c++: parse error with -std=c++14 -fconcepts [PR116071]
cp_parser_simple_type_specifier tries a variety of different things that
might qualify as a user-defined type: an actual type-name, a constrained
auto, a CTAD placeholder.  In a context where a type-specifier is optional,
this is all tentative.  With -std=c++14 -fconcepts, we try type-name and
constrained auto in sub-tentative parses, and when we run out of things to
try we haven't found anything but also haven't failed the outer tentative
parse, so parse_definitely succeeds, discarding the nested-name-specifier.

Fixed by failing if we didn't find anything.

I said in r14-3203 that we should disable this combination of flags if
further problems arise, but this seems like a more general problem that only
happened to occur with just this combination of flags.  So it lives on.

	PR c++/116071

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_simple_type_specifier): Call
	cp_parser_simulate_error if nothing worked.

gcc/testsuite/ChangeLog:

	* g++.dg/parse/pr116071.C: New test.

(cherry picked from commit 8c71830b51)
2024-08-06 17:47:08 -04:00
John David Anglin ba26c471cf hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
The constant C must be an integral multiple of the shift value in
the above optimization.  Non integral values can occur evaluating
IMAGPART_EXPR when the shadd constant is 8 and we have SFmode.

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

gcc/ChangeLog:

	PR target/113384
	* config/pa/pa.cc (hppa_legitimize_address): Add check to
	ensure constant is an integral multiple of shift the value.
2024-08-06 13:42:42 -04:00
Jakub Jelinek f2b5ca6be8 wide-int: Fix up mul_internal overflow checking [PR116224]
The following testcase is miscompiled, because wi::mul for (_BitInt(65))-15
times (_BitInt(65))-15 computes the right value (_BitInt(65))225, but
sets *overflow to wi::OVF_UNKNOWN as that it overflowed when it didn't.

Even signed operands are unpacked as unsigned but because they are
implicitly sign-extended from the represented value (the operands
obviously have len==1), we get
0xfffffff1, 0xffffffff, 0x1, 0x0
in both u and v (0x1 because that is exactly 65 bits).
We then multiply these.  Next step is because both the high and
overflow handling expects the high half to start at a limb boundary
the bits of the result starting with bit 65 are shifted up by 63 such
that the bits relevant for high/need_overflow start at the half of the
4th half wide int limb.
Because both operands are negative that part is then adjusted.

The reason mul_internal says there is overflow is because of the unspecified
garbage in the most significant bits of the result which the adjusting
doesn't clean up.  65 bit multiplication needs 65 bits of result and 65 bits
of the high part, can't produce more, so the following patch fixes it by
checking for the overflow only in those first 65 bits of the high part, not
anything beyond that.  If it was a highpart multiply, we'd have ignored that
as well (canonicalized).

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

	PR tree-optimization/116224
	* wide-int.cc (wi::mul_internal): If prec isn't multiple of
	HOST_BITS_PER_WIDE_INT, for need_overflow checking only look at
	the least significant prec bits starting with r[half_blocks_needed].

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

(cherry picked from commit 69093fd8aa)
2024-08-06 11:13:24 +02:00
Jakub Jelinek 3fe5720430 libquadmath: Fix up libquadmath/math/sqrtq.c compilation in some powerpc* configurations [PR116007]
My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation.
Unfortunately, that seems to fail building in some powerpc* configurations, where
TFmode isn't available.
quad.h has:
 #ifndef TFtype
 typedef float TFtype __attribute__ ((mode (TF)));
 #endif
and uses TFtype.  quad.h has:
 /* Define the complex type corresponding to __float128
    ("_Complex __float128" is not allowed) */
 #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
 typedef _Complex float __attribute__((mode(TC))) __complex128;
 #else
 typedef _Complex float __attribute__((mode(KC))) __complex128;
 #endif
with the conditional and KCmode use added during porting of libquadmath
to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__
isn't defined; I could define it to float __attribute__ ((mode (KF))) but it
seemed easier to just define it to __float128 which should do the same thing.

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

	PR target/116007
	* math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__
	define to __float128 before including soft-fp.h and quad.h.

(cherry picked from commit 3ac02e6750)
2024-08-06 11:13:10 +02:00
Jakub Jelinek cad2693096 fortran: Fix up pasto in gfc_get_array_descr_info
A static analyzer found a pasto in gfc_get_array_descr_info.
The code does
      t = base_decl;
      if (!integer_zerop (dtype_off))
        t = fold_build_pointer_plus (t, dtype_off);
      dtype = TYPE_MAIN_VARIANT (get_dtype_type_node ());
      field = gfc_advance_chain (TYPE_FIELDS (dtype), GFC_DTYPE_RANK);
      rank_off = byte_position (field);
      if (!integer_zerop (dtype_off))
        t = fold_build_pointer_plus (t, rank_off);
i.e. uses the same !integer_zerop check between both, while it should
be checking rank_off in the latter case.
This actually doesn't change anything on the generated code, because
both the dtype_off and rank_off aren't zero,
typedef struct dtype_type
{
  size_t elem_len;
  int version;
  signed char rank;
  signed char type;
  signed short attribute;
}
dtype_type;
struct {
  type *base_addr;
  size_t offset;
  dtype_type dtype;
  index_type span;
  descriptor_dimension dim[];
};
dtype_off is 16 on 64-bit arches and 8 on 32-bit ones and rank_off is
12 on 64-bit arches and 8 on 32-bit arches, so this patch is just to
pacify those static analyzers or be prepared if the ABI changes in the
future.  Because in the current ABI both of those are actually non-zero,
doing
if (!integer_zerop (something)) t = fold_build_pointer_plus (t, something);
actually isn't an optimization, it will consume more compile time.  If
the ABI changes and we forget to readd it, nothing bad happens,
fold_build_pointer_plus handles 0 addends fine, just takes some compile
time to handle that.
I've kept this if (!integer_zerop (data_off)) guard earlier because
data_off is 0 in the current ABI, so it is an optimization there.

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

	* trans-types.cc (gfc_get_array_descr_info): Don't test if
	!integer_zerop (dtype_off), use fold_build_pointer_plus
	unconditionally.

(cherry picked from commit 90fe402a89)
2024-08-06 11:12:54 +02:00
Andrew Pinski ba45573c80 sh: Don't call make_insn_raw in sh_recog_treg_set_expr [PR116189]
This was an interesting compare debug failure to debug. The first symptom
was in gcse which would produce different order of creating psedu-registers. This
was caused by a different order of a hashtable walk, due to the hash table having different
number of entries. Which in turn was due to the number of max insn being different between
the 2 runs. The place max insn uid comes from was in sh_recog_treg_set_expr which is called
via rtx_costs and fwprop would cause rtx_costs in some cases for debug insn related stuff.

Build and tested for sh4-linux-gnu.

	PR target/116189

gcc/ChangeLog:

	* config/sh/sh.cc (sh_recog_treg_set_expr): Don't call make_insn_raw,
	make the insn with a fake uid.

gcc/testsuite/ChangeLog:

	* c-c++-common/torture/pr116189-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 0355c943b9)
2024-08-05 19:39:10 -07:00
GCC Administrator c5ef3b94e4 Daily bump. 2024-08-06 00:22:27 +00:00
Ian Lance Taylor de738988ff compiler: panic arguments are empty interface type
After CL 536643 passing NULL as the expected type permitted an untyped
constant expression to remain untyped. Change to passing the empty
interface type.

The panic and print/println functions are the only builtin functions
that turn an untyped constant expression into a regular function call,
and we already handled print/println specially.

The test case is https://go.dev/cl/603096.

Fixes golang/go#68734

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/603215
2024-08-05 16:07:12 -07:00
Paul Thomas 2405d29086 libgomp: Remove bogus warnings from privatized-ref-2.f90.
2024-07-19  Paul Thomas  <pault@gcc.gnu.org>

libgomp/ChangeLog

	* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Cut
	dg-note about 'a' and remove bogus warnings about its array
	descriptor components being used uninitialized.

(cherry picked from commit 8d6994f33a)
2024-08-05 17:44:02 +01:00
Paul Thomas 9906a9863d Fortran: Suppress bogus used uninitialized warnings [PR108889].
2024-07-18  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/108889
	* gfortran.h: Add bit field 'allocated_in_scope' to gfc_symbol.
	* trans-array.cc (gfc_array_allocate): Set 'allocated_in_scope'
	after allocation if not a component reference.
	(gfc_alloc_allocatable_for_assignment): If 'allocated_in_scope'
	not set, not a component ref and not allocated, set the array
	bounds and offset to give zero length in all dimensions. Then
	set allocated_in_scope.

gcc/testsuite/
	PR fortran/108889
	* gfortran.dg/pr108889.f90: New test.

(cherry picked from commit c3aa339ea5)
2024-08-05 17:37:31 +01:00
Joseph Myers daced7625e Update gcc fr.po
* fr.po: Update.
2024-08-05 16:34:13 +00:00
Christoph Müllner eccf707e5c RISC-V: xtheadmemidx: Fix mode test for pre/post-modify addressing
auto_inc_dec (-O3) performs optimizations like the following
if RVV and XTheadMemIdx is enabled.

(insn 23 20 27 3 (set (mem:V4QI (reg:DI 136 [ ivtmp.13 ]) [0 MEM <vector(4) char> [(char *)_39]+0 S4 A32])
        (reg:V4QI 168)) "gcc/testsuite/gcc.target/riscv/pr116033.c":12:27 3183 {*movv4qi}
     (nil))
(insn 40 39 41 3 (set (reg:DI 136 [ ivtmp.13 ])
        (plus:DI (reg:DI 136 [ ivtmp.13 ])
            (const_int 20 [0x14]))) 5 {adddi3}
     (nil))
====>
(insn 23 20 27 3 (set (mem:V4QI (post_modify:DI (reg:DI 136 [ ivtmp.13 ])
                (plus:DI (reg:DI 136 [ ivtmp.13 ])
                    (const_int 20 [0x14]))) [0 MEM <vector(4) char> [(char *)_39]+0 S4 A32])
        (reg:V4QI 168)) "gcc/testsuite/gcc.target/riscv/pr116033.c":12:27 3183 {*movv4qi}
     (expr_list:REG_INC (reg:DI 136 [ ivtmp.13 ])
        (nil)))

The reason why the pass believes that this is legal is,
that the mode test in th_memidx_classify_address_modify()
requires INTEGRAL_MODE_P (mode), which includes vector modes.

Let's restrict the mode test such, that only MODE_INT is allowed.

	PR target/116033

gcc/ChangeLog:

	* config/riscv/thead.cc (th_memidx_classify_address_modify):
	Fix mode test.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr116033.c: New test.

(cherry picked from commit a86c0cb937)
Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-08-05 13:21:10 +02:00
GCC Administrator 5103ee7469 Daily bump. 2024-08-05 00:20:59 +00:00
GCC Administrator 80a64e6c57 Daily bump. 2024-08-04 00:20:46 +00:00
Jonathan Wakely c3866651a2 libstdc++: Fix __cpp_lib_chrono for old std::string ABI
The <chrono> header is incomplete for the old std::string ABI, because
std::chrono::tzdb is only defined for the new ABI. The feature test
macro advertising full C++20 support should not be defined for the old
ABI.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (chrono): Add cxx11abi = yes.
	* include/bits/version.h: Regenerate.
	* testsuite/std/time/syn_c++20.cc: Adjust expected value for
	the feature test macro.

(cherry picked from commit f906b10763)
2024-08-03 22:29:29 +01:00
GCC Administrator 99eb84fd36 Daily bump. 2024-08-03 00:22:11 +00:00
Joseph Myers 21e2d27fd4 Update gcc .po files
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
	ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
	zh_TW.po: Update.
2024-08-02 21:13:59 +00:00
Andrew Pinski 14fa2b2ae7 forwprop: Don't add uses to dce list if debug statement [PR116156]
The problem here is that when forwprop does a copy prop, into a statement,
we mark the uses of that statement as possibly need to be removed. But it just
happened that statement was a debug statement, there will be a difference when
compiling with debuging info turned on vs off; this is not expected.
So the fix is not to add the old use to dce list to process if it was a debug
statement.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR tree-optimization/116156

gcc/ChangeLog:

	* tree-ssa-forwprop.cc (pass_forwprop::execute): Don't add
	uses if the statement was a debug statement.

gcc/testsuite/ChangeLog:

	* c-c++-common/torture/pr116156-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-02 03:05:03 -07:00
liuhongt a295076bee Refine constraint "Bk" to define_special_memory_constraint.
For below pattern, RA may still allocate r162 as v/k register, try to
reload for address with leaq __libc_tsd_CTYPE_B@gottpoff(%rip), %rsi
which result a linker error.

(set (reg:DI 162)
     (mem/u/c:DI
       (const:DI (unspec:DI
		 [(symbol_ref:DI ("a") [flags 0x60]  <var_decl 0x7f621f6e1c60 a>)]
		 UNSPEC_GOTNTPOFF))

Quote from H.J for why linker issue an error.
>What do these do:
>
>        leaq    __libc_tsd_CTYPE_B@gottpoff(%rip), %rax
>        vmovq   (%rax), %xmm0
>
>From x86-64 TLS psABI:
>
>The assembler generates for the x@gottpoff(%rip) expressions a R X86
>64 GOTTPOFF relocation for the symbol x which requests the linker to
>generate a GOT entry with a R X86 64 TPOFF64 relocation. The offset of
>the GOT entry relative to the end of the instruction is then used in
>the instruction. The R X86 64 TPOFF64 relocation is pro- cessed at
>program startup time by the dynamic linker by looking up the symbol x
>in the modules loaded at that point. The offset is written in the GOT
>entry and later loaded by the addq instruction.
>
>The above code sequence looks wrong to me.

gcc/ChangeLog:

	PR target/116043
	* config/i386/constraints.md (Bk): Refine to
	define_special_memory_constraint.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit bc1fda00d5)
2024-08-02 16:02:47 +08:00
Haochen Jiang 30f4fa3f53 i386: Add non-optimize prefetchi intrins
Under -O0, with the "newly" introduced intrins, the variable will be
transformed as mem instead of the origin symbol_ref. The compiler will
then treat the operand as invalid and turn the operation into nop, which
is not expected. Use macro for non-optimize to keep the variable as
symbol_ref just as how prefetch intrin does.

gcc/ChangeLog:

	* config/i386/prfchiintrin.h
	(_m_prefetchit0): Add macro for non-optimized option.
	(_m_prefetchit1): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/prefetchi-1b.c: New test.
2024-08-02 10:48:43 +08:00
Yang Yujie 79d32baea4 LoongArch: Remove gawk extension from a generator script.
gcc/ChangeLog:

	* config/loongarch/genopts/gen-evolution.awk: Do not use
	"length()" to compute the size of an array.

(cherry picked from commit c48f38288f)
2024-08-02 10:42:29 +08:00
Patrick Palka 81db685768 c++: generic lambda in default template argument [PR88313]
Here we're rejecting the generic lambda inside the default template
argument ultimately because auto_is_implicit_function_template_parm_p
doesn't get set during parsing of the lambda's parameter list, due
to the !processing_template_parmlist restriction.  But when parsing a
lambda parameter list we should always set that flag regardless of where
the lambda appears.  This patch makes sure of this via a local lambda_p
flag.

	PR c++/88313

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_lambda_declarator_opt): Pass
	lambda_p=true to cp_parser_parameter_declaration_clause.
	(cp_parser_direct_declarator): Pass lambda_p=false to
	to cp_parser_parameter_declaration_clause.
	(cp_parser_parameter_declaration_clause): Add bool lambda_p
	parameter.  Consider lambda_p instead of current_class_type
	when setting parser->auto_is_implicit_function_template_parm_p.
	Don't consider processing_template_parmlist.
	(cp_parser_requirement_parameter_list): Pass lambda_p=false
	to cp_parser_parameter_declaration_clause.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 72a7ab891a)
2024-08-01 20:33:24 -04:00
Patrick Palka 37e54ffd2a c++: alias of alias tmpl with dependent attrs [PR115897]
As a follow-up to r15-2047-g7954bb4fcb6fa8, we also need to consider
dependent attributes when recursing into a non-template alias that names
a dependent alias template specialization (and so STF_STRIP_DEPENDENT
is set), otherwise in the first testcase below we undesirably strip B
all the way to T instead of to A<T>.

We also need to move the typedef recursion case of strip_typedefs up to
get checked before the compound type recursion cases.  Otherwise for C
below (which ultimately aliases T*) we end up stripping it to T* instead
of to A<T*> because the POINTER_TYPE recursion dominates the typedef
recursion.  It also means we issue an unexpected extra error in the
third testcase below.

Ideally we would also want to consider dependent attributes on
non-template aliases, so that we accept the second testcase below, but
making that work correctly would require broader changes to e.g.
structural_comptypes.

	PR c++/115897

gcc/cp/ChangeLog:

	* tree.cc (strip_typedefs): Move up the typedef recursion case.
	Never strip a dependent alias template-id that has dependent
	attributes.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-78.C: New test.
	* g++.dg/cpp0x/alias-decl-79.C: New test.
	* g++.dg/cpp0x/alias-decl-pr92206-1a.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 9bcad23883)
2024-08-01 20:33:24 -04:00
Patrick Palka 59e3934346 libstdc++: fix uses of explicit object parameter [PR116038]
The type of an implicit object parameter is always the current class.
For an explicit object parameter however, its deduced type can be a
derived class of the current class.  So when combining multiple
implicit-object overloads into a single explicit-object overload we need
to account for this possibility.  For example when accessing a member of
the current class through an explicit object parameter, it may now be a
derived class from which the member is not accessible, as in the below
testcases.

This pitfall is discussed[1] in the deducing this paper.  The general
solution is to cast the explicit object parameter to (a reference to)
the current class rather than e.g. using std::forward which preserves
the deduced type.

This patch corrects the existing problematic uses of explicit object
parameters in the library, all of which forward the parameter via
std::forward, to instead cast the parameter to the current class via
our __like_t alias template.  Note that unlike the paper's like_t,
ours always returns a reference so we can just write

  __like_t<Self, B>(self)

instead of

  (_like_t<Self, B>&&)self

as the paper does.

[1]: https://wg21.link/P0847#name-lookup-within-member-functions (and the
section after that)

	PR libstdc++/116038

libstdc++-v3/ChangeLog:

	* include/std/functional (_Bind_front::operator()): Use __like_t
	instead of std::forward when forwarding __self.
	(_Bind_back::operator()): Likewise.
	* include/std/ranges (_Partial::operator()): Likewise.
	(_Pipe::operator()): Likewise.
	* testsuite/20_util/function_objects/bind_back/116038.cc: New test.
	* testsuite/20_util/function_objects/bind_front/116038.cc: New test.
	* testsuite/std/ranges/adaptors/116038.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 1066a95aa3)
2024-08-01 20:33:24 -04:00
Patrick Palka 241f710c85 c++: normalizing ttp constraints [PR115656]
Here we normalize the constraint same_as<T, bool> for the first
time during ttp coercion of B / UU, specifically constraint subsumption
checking.  During this normalization the set of in-scope template
parameters i.e. current_template_parms is empty, which we rely on
during normalization of the ttp constraints since we pass in_decl=NULL_TREE
to norm_info.  And this tricks the satisfaction cache into thinking that
the satisfaction value of same_as<T, bool> is independent of its template
parameters, and we incorrectly conflate the satisfaction value with
T = bool vs T = long and accept the specialization A<long, B>.

Since is_compatible_template_arg rewrites the ttp's constraints to
be in terms of the argument template's parameters, and since it's
the only caller of weakly_subsumes, the latter funcion can instead
pass in_decl=tmpl to avoid relying on current_template_parms.  This
patch implements this, and in turns renames weakly_subsumes to
ttp_subsumes to reflect that this predicate is now hardcoded for this
one caller.

	PR c++/115656

gcc/cp/ChangeLog:

	* constraint.cc (weakly_subsumes): Pass in_decl=tmpl to
	get_normalized_constraints_from_info.  Rename to ...
	(ttp_subsumes): ... this.
	* cp-tree.h (weakly_subsumes): Rename to ...
	(ttp_subsumes): ... this.
	* pt.cc (is_compatible_template_arg): Adjust after renaming.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-ttp7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 2861eb34e3)
2024-08-01 20:33:23 -04:00
Patrick Palka e548a881a4 c++: missing SFINAE during alias CTAD [PR115296]
During the alias CTAD transformation, if substitution failed for some
guide we should just silently discard the guide.  We currently do
discard the guide, but not silently, as in the below testcase which
we diagnose forming a too-large array type when transforming the
user-defined deduction guides.

This patch fixes this by using complain=tf_none instead of
tf_warning_or_error throughout alias_ctad_tweaks.

	PR c++/115296

gcc/cp/ChangeLog:

	* pt.cc (alias_ctad_tweaks): Use complain=tf_none instead of
	tf_warning_or_error.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-alias23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit f70281222d)
2024-08-01 20:33:23 -04:00
Patrick Palka 1287b4abc6 c++: prev declared hidden tmpl friend inst [PR112288]
When partially instantiating a previously declared hidden template
friend definition (at class template scope) such as slot_allocated in
the first testcase below, tsubst_friend_function needs to go through
all existing specializations thereof and make them point to the new
definition.

But when the previous declaration was also at class template scope,
old_decl is not the most general template, instead it's the partial
instantiation, and since instantiations are relative to the most general
template, old_decl's DECL_TEMPLATE_INSTANTIATIONS is empty.  So we
to consistently use the most general template here.  And when adjusting
DECL_TI_ARGS to match, only the innermost template arguments should be
preserved; the outer ones should correspond to the new definition.

Otherwise we fail a checking-only sanity check in instantiate_decl in
the first testcase, and in the second/third we end up emitting multiple
definitions of the template friend instantiation, resulting in a link
failure.

	PR c++/112288

gcc/cp/ChangeLog:

	* pt.cc (tsubst_friend_function): When adjusting existing
	specializations after defining a previously declared template
	friend, consider the most general template and correct
	DECL_TI_ARGS adjustment.

gcc/testsuite/ChangeLog:

	* g++.dg/template/friend80.C: New test.
	* g++.dg/template/friend81.C: New test.
	* g++.dg/template/friend81a.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 30dd420a06)
2024-08-01 20:33:23 -04:00
GCC Administrator fb8da40121 Daily bump. 2024-08-02 00:23:49 +00:00
Jonathan Wakely c6372417e5 libstdc++: Add [[nodiscard]] to some std::locale functions
libstdc++-v3/ChangeLog:

	* include/bits/locale_classes.h (locale::combine)
	(locale::name, locale::operator==, locale::operator!=)
	(locale::operator(), locale::classic): Add nodiscard
	attribute.
	* include/bits/locale_classes.tcc (has_facet, use_facet):
	Likewise.
	* testsuite/22_locale/locale/cons/12438.cc: Add dg-warning for
	nodiscard diagnostic.
	* testsuite/22_locale/locale/cons/2.cc: Cast use_facet
	expression to void, to suppress diagnostic.
	* testsuite/22_locale/locale/cons/unicode.cc: Likewise.
	* testsuite/22_locale/locale/operations/2.cc: Add dg-warning.

(cherry picked from commit fd1a674ff5)
2024-08-01 18:54:19 +01:00
Deev Patel c79e73e7ed libstdc++: Add missing constexpr to __atomic_impl::__clear_padding
This is called from the std::atomic<floating-point-type> constructor,
which needs to be usable in constant expressions.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (__atomic_impl::__clear_padding):
	Add missing constexpr specifier.
	* testsuite/29_atomics/atomic_float/constinit.cc: New test.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit ae91b5dd14)
2024-08-01 18:54:19 +01:00
Jonathan Wakely 8d52ae39b9 libstdc++: Initialize base in test allocator's constructor
This fixes a warning from one of the test allocators:
warning: base class 'class std::allocator<__gnu_test::copy_tracker>' should be explicitly initialized in the copy constructor [-Wextra]

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_allocator.h (tracker_allocator):
	Initialize base class in copy constructor.

(cherry picked from commit e2fb245b07)
2024-08-01 18:54:19 +01:00
Jonathan Wakely d8e564539f libstdc++: Fix std::tr2::dynamic_bitset shift operations [PR115399]
The shift operations for dynamic_bitset fail to zero out words where the
non-zero bits were shifted to a completely different word.

For a right shift we don't need to sanitize the unused bits in the high
word, because we know they were already clear and a right shift doesn't
change that.

libstdc++-v3/ChangeLog:

	PR libstdc++/115399
	* include/tr2/dynamic_bitset (operator>>=): Remove redundant
	call to _M_do_sanitize.
	* include/tr2/dynamic_bitset.tcc (_M_do_left_shift): Zero out
	low bits in words that should no longer be populated.
	(_M_do_right_shift): Likewise for high bits.
	* testsuite/tr2/dynamic_bitset/pr115399.cc: New test.

(cherry picked from commit bd3a312728)
2024-08-01 18:54:19 +01:00
Jonathan Wakely a78480c4e9 libstdc++: Remove std::basic_format_args default constructor (LWG 4106)
There's no valid use case for default constructing this type, so the
committee approved removing the default constructor.

libstdc++-v3/ChangeLog:

	* include/std/format (basic_format_args): Remove default
	constructor, as per LWG 4106.
	* testsuite/std/format/arguments/args.cc: Check it isn't default
	constructible.

(cherry picked from commit 5be55447e2)
2024-08-01 18:54:19 +01:00
Jonathan Wakely 85d07df7be libstdc++: Make std::basic_format_context non-copyable [PR114387]
Users are not supposed to create objects of this type, and there's no
reason it needs to be copyable. LWG 4061 makes it non-copyable and
non-default constructible.

libstdc++-v3/ChangeLog:

	PR libstdc++/114387
	* include/std/format (basic_format_context): Define copy
	operations as deleted, as per LWG 4061.
	* testsuite/std/format/context.cc: New test.

(cherry picked from commit d8cd852118)
2024-08-01 18:54:18 +01:00
Jonathan Wakely 7d269e34a3 libstdc++: Make std::any_cast<void> ill-formed (LWG 3305)
LWG 3305 was approved earlier this year in Tokyo. We need to give an
error if using std::any_cast<void>, but std::any_cast<void()> is valid
(but always returns null).

libstdc++-v3/ChangeLog:

	* include/std/any (any_cast(any*), any_cast(const any*)): Add
	static assertion to reject void types, as per LWG 3305.
	* testsuite/20_util/any/misc/lwg3305.cc: New test.

(cherry picked from commit 466ee78e3e)
2024-08-01 18:54:18 +01:00
Jonathan Wakely 095be59fd7 libstdc++: Define __cpp_lib_ranges in <algorithm>
The __cpp_lib_ranges macro is missing from <algorithm>.

libstdc++-v3/ChangeLog:

	* include/std/algorithm: Define __glibcxx_want_ranges.
	* testsuite/25_algorithms/headers/algorithm/synopsis.cc: Check
	feature test macro in C++20 mode.

(cherry picked from commit 77e84dc4e4)
2024-08-01 18:54:18 +01:00
Jonathan Wakely 11b5ad5ba7 libstdc++: Use direct-initialization for std::vector<bool>'s allocator [PR115854]
The consensus in the standard committee is that this change shouldn't be
necessary, and the Allocator requirements should require conversions
between rebound allocators to be implicit. But we can make it work for
now anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/115854
	* include/bits/stl_bvector.h (_Bvector_base): Convert allocator
	to rebound type explicitly.
	* testsuite/23_containers/vector/allocator/115854.cc: New test.
	* testsuite/23_containers/vector/bool/allocator/115854.cc: New test.

(cherry picked from commit c5efc6eca8)
2024-08-01 18:54:18 +01:00
Jonathan Wakely 5fcdb36fed libstdc++: Use __glibcxx_ranges_as_const to guard P2278R4 changes
The P2278R4 additions for C++23 are currently guarded by a check for
__cplusplus > 202002L but can use __glibcxx_ranges_as_const instead.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (const_iterator_t): Change
	preprocessor condition to use __glibcxx_ranges_as_const.
	(const_sentinel_t, range_const_reference_t): Likewise.
	(__access::__possibly_const_range, cbegin, cend, crbegin)
	(crend, cdata): Likewise.
	* include/bits/stl_iterator.h (iter_const_reference_t)
	(basic_const_iterator, const_iterator, const_sentinel)
	(make_const_iterator): Likewise.

(cherry picked from commit 0755b2304b)
2024-08-01 18:54:18 +01:00
Jonathan Wakely a1e166516f libstdc++: Use reserved form of [[__likely__]] in <variant>
We should not use [[unlikely]] before C++20, so use [[__unlikely__]]
instead.

libstdc++-v3/ChangeLog:

	* include/std/variant (_Variant_storage::_M_reset): Use
	__unlikely__ form of attribute instead of unlikely.

(cherry picked from commit 9f1cd51766)
2024-08-01 18:54:18 +01:00
Jonathan Wakely 9ba75a628e libstdc++: Fix <ostream> and <istream> for -std=gnu++14 -fconcepts [PR116070]
This questionable combination of flags causes a number of errors. The
ones in the rvalue stream overloads need to be fixed in the gcc-14
branch so I'm committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

	PR libstdc++/116070
	* include/std/istream: Check feature test macro before using
	is_class_v and is_same_v.
	* include/std/ostream: Likewise.

(cherry picked from commit 6c22fe418c)
2024-08-01 18:54:17 +01:00
Jonathan Wakely ce84abae49 libstdc++: Fix std::vector<bool> for -std=gnu++14 -fconcepts [PR116070]
This questionable combination of flags causes a number of errors. This
one in std::vector<bool> needs to be fixed in the gcc-13 branch so I'm
committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

	PR libstdc++/116070
	* include/bits/stl_bvector.h: Check feature test macro before
	using is_default_constructible_v.

(cherry picked from commit 5fc9c40fea)
2024-08-01 18:54:17 +01:00
Jakub Jelinek 973097d801 i386: Fix up *<extract_type>_vinsert<shuffletype><extract_suf>_0 [PR115981]
The r14-537 change started canonicalizing VEC_MERGE operands based on
swap_commutative_operands_p or if they have the same precedence least
significant bit of the third operand.
The *<extract_type>_vinsert<shuffletype><extract_suf>_0 pattern was
added for combine matching and no longer triggers after that change,
as it used the reg_or_0_operand as the first operand and VEC_DUPLICATE
as the second.
Now, reg_or_0_operand could be a REG, SUBREG of object or CONST_VECTOR.
REG has commutative_operand_precedence -1 or -2, SUBREG of object -3,
CONST_VECTOR -4, while VEC_DUPLICATE has 0, so VEC_DUPLICATE will always
go first and REG, SUBREG or CONST_VECTOR second.

This patch swaps the operands so that it matches again.

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

	PR target/115981
	* config/i386/sse.md
	(*<extract_type>_vinsert<shuffletype><extract_suf>_0): Swap the
	first two VEC_MERGE operands, renumber match_operands and test
	for 0xF or 0x3 rather than 0xFFF0 or 0xFC immediate.

	* gcc.target/i386/avx512dq-pr90991-1.c: Add tests for no separate
	zero extension instructions.
	* gcc.target/i386/avx512dq-pr90991-2.c: Likewise.

(cherry picked from commit df2b444a23)
2024-08-01 12:02:05 +02:00
Jakub Jelinek fb2f72db27 Bump BASE-VER.
2024-08-01  Jakub Jelinek  <jakub@redhat.com>

	* BASE-VER: Set to 14.2.1.
2024-08-01 11:17:40 +02:00
Jakub Jelinek 04696df096 Update ChangeLog and version files for release 2024-08-01 08:18:20 +00:00
GCC Administrator 0f4eb65785 Daily bump. 2024-08-01 00:23:56 +00:00
GCC Administrator 10323e2cca Daily bump. 2024-07-31 00:23:47 +00:00
Lingling Kong ee6c5afec3 x86: Don't enable APX_F in 32-bit mode
gcc/ChangeLog:

	PR target/115978
	* config/i386/driver-i386.cc (host_detect_local_cpu):  Enable
	APX_F only for 64-bit codegen.
	* config/i386/i386-options.cc (DEF_PTA):  Skip PTA_APX_F if
	not in 64-bit mode.

gcc/testsuite/ChangeLog:

	PR target/115978
	* gcc.target/i386/pr115978-1.c: New test.
	* gcc.target/i386/pr115978-2.c: Ditto.
2024-07-30 16:13:10 +08:00
GCC Administrator 7c688e026a Daily bump. 2024-07-30 00:22:56 +00:00
Marek Polacek da7f0be91e c++: wrong error initializing empty class [PR115900]
In r14-409, we started handling empty bases first in cxx_fold_indirect_ref_1
so that we don't need to recurse and waste time.

This caused a bogus "modifying a const object" error.  I'm appending my
analysis from the PR, but basically, cxx_fold_indirect_ref now returns
a different object than before, and we mark the wrong thing as const,
but since we're initializing an empty object, we should avoid setting
the object constness.

~~
Pre-r14-409: we're evaluating the call to C::C(), which is in the body of
B::B(), which is the body of D::D(&d):

  C::C ((struct C *) this, NON_LVALUE_EXPR <0>)

It's a ctor so we get here:

 3118   /* Remember the object we are constructing or destructing.  */
 3119   tree new_obj = NULL_TREE;
 3120   if (DECL_CONSTRUCTOR_P (fun) || DECL_DESTRUCTOR_P (fun))
 3121     {
 3122       /* In a cdtor, it should be the first `this' argument.
 3123          At this point it has already been evaluated in the call
 3124          to cxx_bind_parameters_in_call.  */
 3125       new_obj = TREE_VEC_ELT (new_call.bindings, 0);

new_obj=(struct C *) &d.D.2656

 3126       new_obj = cxx_fold_indirect_ref (ctx, loc, DECL_CONTEXT (fun), new_obj);

new_obj=d.D.2656.D.2597

We proceed to evaluate the call, then we get here:

 3317           /* At this point, the object's constructor will have run, so
 3318              the object is no longer under construction, and its possible
 3319              'const' semantics now apply.  Make a note of this fact by
 3320              marking the CONSTRUCTOR TREE_READONLY.  */
 3321           if (new_obj && DECL_CONSTRUCTOR_P (fun))
 3322             cxx_set_object_constness (ctx, new_obj, /*readonly_p=*/true,
 3323                                       non_constant_p, overflow_p);

new_obj is still d.D.2656.D.2597, its type is "C", cxx_set_object_constness
doesn't set anything as const.  This is fine.

After r14-409: on line 3125, new_obj is (struct C *) &d.D.2656 as before,
but we go to cxx_fold_indirect_ref_1:

 5739       if (is_empty_class (type)
 5740           && CLASS_TYPE_P (optype)
 5741           && lookup_base (optype, type, ba_any, NULL, tf_none, off))
 5742         {
 5743           if (empty_base)
 5744             *empty_base = true;
 5745           return op;

type is C, which is an empty class; optype is "const D", and C is a base of D.
So we return the VAR_DECL 'd'.  Then we get to cxx_set_object_constness with
object=d, which is const, so we mark the constructor READONLY.

Then we're evaluating A::A() which has

  ((A*)this)->data = 0;

we evaluate the LHS to d.D.2656.a, for which the initializer is
{.D.2656={.a={.data=}}} which is TREE_READONLY and 'd' is const, so we think
we're modifying a const object and fail the constexpr evaluation.

	PR c++/115900

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Set new_obj to NULL_TREE
	if cxx_fold_indirect_ref set empty_base to true.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-init23.C: New test.

(cherry picked from commit d890b04197)
2024-07-29 09:43:41 -04:00
Richard Biener a7f1b00ed6 tree-optimization/116057 - wrong code with CCP and vector CTORs
The following fixes an issue with CCPs likely_value when faced with
a vector CTOR containing undef SSA names and constants.  This should
be classified as CONSTANT and not UNDEFINED.

	PR tree-optimization/116057
	* tree-ssa-ccp.cc (likely_value): Also walk CTORs in stmt
	operands to look for constants.

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

(cherry picked from commit 1ea551514b)
2024-07-29 15:39:16 +02:00
Jakub Jelinek 61cb0c889e testsuite: Fix up consteval-prop21.C for 32-bit targets [PR115986]
The test fails on 32-bit targets (which don't support __int128 type).
Using unsigned long long instead still ICEs before the fix and passes
after it on those targets.

2024-07-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/115986
	* g++.dg/cpp2a/consteval-prop21.C (operator "" _c): Use
	unsigned long long rather than __uint128_t for return type if int128
	is unsupported.

(cherry picked from commit 331f23540e)
2024-07-29 09:15:18 -04:00
Jason Merrill 9662299593 c++: if consteval and consteval propagation [PR115583]
During speculative constant folding of an if consteval, we take the false
branch, but the true branch is an immediate function context, so we don't
want to to cp_fold_immediate it.  So we could check IF_STMT_CONSTEVAL_P
here.  But beyond that, we don't want to do this inside a call, only when
first parsing a function.

	PR c++/115583

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_conditional_expression): Don't
	cp_fold_immediate for if consteval.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/consteval-if13.C: New test.

(cherry picked from commit d5f1948640)
2024-07-29 09:13:36 -04:00
Jason Merrill 56d5f8a605 c++: consteval propagation and templates [PR115986]
Here the call to e() makes us decide to check d() for escalation at EOF, but
while checking it we try to fold_immediate 0_c, and get confused by the
template trees.  Let's not mess with escalation for function templates.

	PR c++/115986

gcc/cp/ChangeLog:

	* cp-gimplify.cc (remember_escalating_expr): Skip function
	templates.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/consteval-prop21.C: New test.

(cherry picked from commit a9e9f772c7)
2024-07-29 09:13:36 -04:00
Jason Merrill f30caf1bda c++: ICE with concept, local class, and lambda [PR115561]
Here when we want to synthesize methods for foo()::B maybe_push_to_top_level
calls push_function_context, which sets cfun to a dummy value; later
finish_call_expr tries to set something in
cp_function_chain (i.e. cfun->language), which isn't set.  Many places in
the compiler check cfun && cp_function_chain to avoid this problem; here we
also want to check !cp_unevaluated_operand, like set_flags_from_callee does.

	PR c++/115561

gcc/cp/ChangeLog:

	* semantics.cc (finish_call_expr): Check cp_unevaluated_operand.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-lambda21.C: New test.

(cherry picked from commit 3129a2ed6a)
2024-07-29 09:13:36 -04:00
Jan Hubicka 98baaa1756 Fix ICE with -fdump-tree-moref
gcc/ChangeLog:

	PR ipa/116055
	* ipa-modref.cc (analyze_function): Do not ICE when flags regress.
2024-07-29 10:48:34 +02:00
Haochen Jiang affb2e8f87 i386: Fix AVX512 intrin macro typo
There are several typo in AVX512 intrins macro define. Correct them to solve
errors when compiled with -O0.

gcc/ChangeLog:

	* config/i386/avx512dqintrin.h
	(_mm_mask_fpclass_ss_mask): Correct operand order.
	(_mm_mask_fpclass_sd_mask): Ditto.
	(_mm256_maskz_reduce_round_ss): Use __builtin_ia32_reducess_mask_round
	instead of __builtin_ia32_reducesd_mask_round.
	(_mm_reduce_round_sd): Use -1 as mask since it is non-mask.
	(_mm_reduce_round_ss): Ditto.
	* config/i386/avx512vlbwintrin.h
	(_mm256_mask_alignr_epi8): Correct operand usage.
	(_mm_mask_alignr_epi8): Ditto.
	* config/i386/avx512vlintrin.h (_mm_mask_alignr_epi64): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512bw-vpalignr-1b.c: New test.
	* gcc.target/i386/avx512dq-vfpclasssd-1b.c: Ditto.
	* gcc.target/i386/avx512dq-vfpclassss-1b.c: Ditto.
	* gcc.target/i386/avx512dq-vreducesd-1b.c: Ditto.
	* gcc.target/i386/avx512dq-vreducess-1b.c: Ditto.
	* gcc.target/i386/avx512vl-valignq-1b.c: Ditto.
2024-07-29 16:42:55 +08:00
GCC Administrator b858a511eb Daily bump. 2024-07-29 00:23:54 +00:00
GCC Administrator c3eef3d446 Daily bump. 2024-07-28 00:22:44 +00:00
GCC Administrator 8eae5b065d Daily bump. 2024-07-27 00:22:35 +00:00
GCC Administrator 92eb0ee705 Daily bump. 2024-07-26 00:22:36 +00:00
Joseph Myers a32aff11db Regenerate gcc.pot
* gcc.pot: Regenerate.
2024-07-25 16:24:37 +00:00
GCC Administrator a7f07e5d48 Daily bump. 2024-07-25 00:24:39 +00:00
Jakub Jelinek 181f40f5cf testsuite: Fix up pr116034.c test for big/pdp endian [PR116061]
Didn't notice the memmove is into an int variable, so the test
was still failing on big endian.

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

	PR tree-optimization/116034
	PR testsuite/116061
	* gcc.dg/pr116034.c (g): Change type from int to unsigned short.
	(foo): Guard memmove call on __SIZEOF_SHORT__ == 2.

(cherry picked from commit 69e69847e2)
2024-07-24 18:40:09 +02:00
Christoph Müllner ab0386679f RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled
It is possible that the Zba optimization pattern zero_extendsidi2_bitmanip
matches for a XTheadMemIdx INSN with the effect of emitting an invalid
instruction as reported in PR116035.

The pattern above is used to emit a zext.w instruction to zero-extend
SI mode registers to DI mode.  A similar functionality can be achieved
by XTheadBb's th.extu instruction.  And indeed, we have the equivalent
pattern in thead.md (zero_extendsidi2_th_extu).  However, that pattern
depends on !TARGET_XTHEADMEMIDX.  To compensate for that, there are
specific patterns that ensure that zero-extension instruction can still
be emitted (th_memidx_bb_zero_extendsidi2 and friends).

While we could implement something similar (th_memidx_zba_zero_extendsidi2)
it would only make sense, if there existed real HW that does implement Zba
and XTheadMemIdx, but not XTheadBb.  Unless such a machine exists, let's
simply disable zero_extendsidi2_bitmanip if XTheadMemIdx is available.

	PR target/116035

gcc/ChangeLog:

	* config/riscv/bitmanip.md: Disable zero_extendsidi2_bitmanip
	for XTheadMemIdx.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr116035-1.c: New test.
	* gcc.target/riscv/pr116035-2.c: New test.

(cherry picked from commit 9817d29cd6)
Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-24 12:31:38 +02:00
GCC Administrator ae2909a057 Daily bump. 2024-07-24 00:23:48 +00:00
Torbjörn SVENSSON a544898f6d testsuite: Disable finite math only for test [PR115826]
As the test case requires +-Inf and NaN to work and -ffast-math is added
by default for arm-none-eabi, re-enable non-finite math.

gcc/testsuite/ChangeLog:

	PR testsuite/115826
	* gcc.dg/vect/tsvc/vect-tsvc-s1281.c: Use -fno-finite-math-only.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 7793f5b419)
2024-07-23 12:05:20 +02:00
Jonathan Wakely b41487a883 libstdc++: Use [[maybe_unused]] attribute in src/c++23/print.cc
This avoids some warnings when the preprocessor conditions are not met.

libstdc++-v3/ChangeLog:

	* src/c++23/print.cc (__open_terminal): Use [[maybe_unused]] on
	parameter.

(cherry picked from commit b40156d691)
2024-07-23 10:50:03 +01:00
Detlef Vollmann 5fad887430 libstdc++: Do not use isatty on avr [PR115482]
avrlibc has an incomplete unistd.h that doesn't have isatty.
So building libstdc++ fails when compiling c++23/print.cc.
As a workaround I added a check for AVR.

libstdc++-v3/ChangeLog:

	PR libstdc++/115482
	* src/c++23/print.cc (__open_terminal) [__AVR__]: Do not use
	isatty.

(cherry picked from commit 8439405e38)
2024-07-23 10:50:02 +01:00
Jakub Jelinek 084768c865 ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]
The folding into REALPART_EXPR is correct, used only when the mem_offset
is zero, but for IMAGPART_EXPR it didn't check the exact offset value (just
that it is not 0).
The following patch fixes that by using IMAGPART_EXPR only if the offset
is right and using BITFIELD_REF or whatever else otherwise.

2024-07-23  Jakub Jelinek  <jakub@redhat.com>
	    Andrew Pinski  <quic_apinski@quicinc.com>

	PR tree-optimization/116034
	* tree-ssa.cc (maybe_rewrite_mem_ref_base): Only use IMAGPART_EXPR
	if MEM_REF offset is equal to element type size.

	* gcc.dg/pr116034.c: New test.

(cherry picked from commit b9cefd67a2)
2024-07-23 10:54:09 +02:00
Haochen Jiang 81f356f9f7 i386: Change prefetchi output template
For prefetchi instructions, RIP-relative address is explicitly mentioned
for operand and assembler obeys that rule strictly. This makes
instruction like:

	prefetchit0	bar

got illegal for assembler, which should be a broad usage for prefetchi.

Change to %a to explicitly add (%rip) after function label to make it
legal in assembler so that it could pass to linker to get the real address.

gcc/ChangeLog:

	* config/i386/i386.md (prefetchi): Change to %a.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/prefetchi-1.c: Check (%rip).
2024-07-23 13:51:07 +08:00
Alexandre Oliva 109b389a0b [powerpc] [testsuite] reorder dg directives [PR106069]
The dg-do directive appears after dg-require-effective-target in
g++.target/powerpc/pr106069.C.  That doesn't work the way that was
presumably intended.  Both of these directives set dg-do-what, but
dg-do does so fully and unconditionally, overriding any decisions
recorded there by earlier directives.  Reorder the directives more
canonically, so that both take effect.


for  gcc/testsuite/ChangeLog

	PR target/106069
	* g++.target/powerpc/pr106069.C: Reorder dg directives.

(cherry picked from commit ad65caa332)
2024-07-23 00:44:05 -03:00
Patrick Palka 066c7893ea c++/coroutines: correct passing *this to promise type [PR104981]
When passing *this to the promise type ctor (or to its operator new)
(as per [dcl.fct.def.coroutine]/4), we add an explicit cast to lvalue
reference.  But this is unnecessary since *this is already always an
lvalue.  And doing so means we need to call convert_from_reference
afterward to lower the reference expression to an implicit dereference,
which we're currently neglecting to do and which causes overload
resolution to get confused when computing argument conversions.

So this patch removes this unneeded reference cast when passing *this
to the promise ctor, and removes both the cast and implicit deref when
passing *this to operator new, for consistency.  While we're here, use
cp_build_fold_indirect_ref instead of directly building INDIRECT_REF.

	PR c++/104981
	PR c++/115550

gcc/cp/ChangeLog:

	* coroutines.cc (morph_fn_to_coro): Remove unneeded calls
	to convert_to_reference and convert_from_reference when
	passing *this.  Use cp_build_fold_indirect_ref instead
	of directly building INDIRECT_REF.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr104981-preview-this.C: New test.
	* g++.dg/coroutines/pr115550-preview-this.C: New test.

Reviewed-by: Iain Sandoe <iain@sandoe.co.uk>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7c5a9bf1d2)
2024-07-22 21:32:07 -04:00
Patrick Palka 50ff112d17 c++: xobj fn call without obj [PR115783]
The code path for rejecting an object-less call to a non-static member
function should also consider xobj member functions (so that we correctly
reject the below calls with a "cannot call member function without object"
diagnostic).

	PR c++/115783

gcc/cp/ChangeLog:

	* call.cc (build_new_method_call): Generalize METHOD_TYPE
	check to DECL_OBJECT_MEMBER_FUNCTION_P.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 2ee70c9f83)
2024-07-22 21:32:04 -04:00
GCC Administrator dfae324da5 Daily bump. 2024-07-23 00:22:52 +00:00
Jan Hubicka 9ddd5f88e6 Fix modref's iteraction with store merging
Hi,
this patch fixes wrong code in case store-merging introduces load of function
parameter that was previously write-only (which happens for bitfields).
Without this, the whole store-merged area is consdered to be killed.

	PR ipa/111613

gcc/ChangeLog:

	* ipa-modref.cc (analyze_parms): Do not preserve EAF_NO_DIRECT_READ and
	EAF_NO_INDIRECT_READ from past flags.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/pr111613.c: New test.

(cherry picked from commit 1407477335)
2024-07-22 22:56:08 +02:00
Peter Bergner bd535b46aa rs6000: Catch unsupported ABI errors when using -mrop-protect [PR114759,PR115988]
2024-07-18  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/
	PR target/114759
	PR target/115988
	* gcc.target/powerpc/pr114759-3.c: Catch unsupported ABI errors.

(cherry picked from commit b2f47a5c1d)
2024-07-22 13:26:05 -05:00
Peter Bergner 35e5c2d2e4 rs6000: Error on CPUs and ABIs that don't support the ROP protection insns [PR114759]
We currently silently ignore the -mrop-protect option for old CPUs we don't
support with the ROP hash insns, but we throw an error for unsupported ABIs.
This patch treats unsupported CPUs and ABIs similarly by throwing an error
both both.  This matches clang behavior and allows us to simplify our tests
in the code that generates our prologue and epilogue code.

2024-06-26  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/114759
	* config/rs6000/rs6000.cc (rs6000_option_override_internal): Disallow
	CPUs and ABIs that do no support the ROP protection insns.
	* config/rs6000/rs6000-logue.cc (rs6000_stack_info): Remove now
	unneeded tests.
	(rs6000_emit_prologue): Likewise.
	Remove unneeded gcc_assert.
	(rs6000_emit_epilogue): Likewise.
	* config/rs6000/rs6000.md: Likewise.

gcc/testsuite/
	PR target/114759
	* gcc.target/powerpc/pr114759-3.c: New test.

(cherry picked from commit 6f2bab9b5d)
2024-07-22 13:25:54 -05:00
Peter Bergner e2d746e5ab rs6000: ROP - Emit hashst and hashchk insns on Power8 and later [PR114759]
We currently only emit the ROP-protect hash* insns for Power10, where the
insns were added to the architecture.  We want to emit them for earlier
cpus (where they operate as NOPs), so that if those older binaries are
ever executed on a Power10, then they'll be protected from ROP attacks.
Binutils accepts hashst and hashchk back to Power8, so change GCC to emit
them for Power8 and later.  This matches clang's behavior.

2024-06-19  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/114759
	* config/rs6000/rs6000-logue.cc (rs6000_stack_info): Use TARGET_POWER8.
	(rs6000_emit_prologue): Likewise.
	* config/rs6000/rs6000.md (hashchk): Likewise.
	(hashst): Likewise.
	Fix whitespace.

gcc/testsuite/
	PR target/114759
	* gcc.target/powerpc/pr114759-2.c: New test.
	* lib/target-supports.exp (rop_ok): Use
	check_effective_target_has_arch_pwr8.

(cherry picked from commit a05c3d23d1)
2024-07-22 13:25:41 -05:00
Peter Bergner 33ebeb2435 rs6000: Compute rop_hash_save_offset for non-Altivec compiles [PR115389]
We currently only compute the offset for the ROP hash save location in
the stack frame for Altivec compiles.  For non-Altivec compiles when we
emit ROP mitigation instructions, we use a default offset of zero which
corresponds to the backchain save location which will get clobbered on
any call.  The fix is to compute the ROP hash save location for all
compiles.

2024-06-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/115389
	* config/rs6000/rs6000-logue.cc (rs6000_stack_info): Compute
	rop_hash_save_offset for non-Altivec compiles.

gcc/testsuite
	PR target/115389
	* gcc.target/powerpc/pr115389.c: New test.

(cherry picked from commit c70eea0dba)
2024-07-22 13:25:31 -05:00
Peter Bergner c33532c597 rs6000: Update ELFv2 stack frame comment showing the correct ROP save location
The ELFv2 stack frame layout comment in rs6000-logue.cc shows the ROP
hash save slot in the wrong location.  Update the comment to show the
correct ROP hash save location in the frame.

2024-06-07  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-logue.cc (rs6000_stack_info): Update comment.

(cherry picked from commit e91cf26a95)
2024-07-22 13:25:19 -05:00
Jan Hubicka 27ef3a0779 Fix modref_eaf_analysis::analyze_ssa_name handling of values dereferenced to function call parameters
modref_eaf_analysis::analyze_ssa_name misinterprets EAF flags.  If dereferenced
parameter is passed (to map_iterator in the testcase) it can be returned
indirectly which in turn makes it to escape into the next function call.

	PR ipa/115033

gcc/ChangeLog:

	* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Fix checking of
	EAF flags when analysing values dereferenced as function parameters.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/pr115033.c: New test.

(cherry picked from commit cf8ffc58aa)
2024-07-22 18:09:41 +02:00
Jan Hubicka f2e9808479 Fix accounting of offsets in unadjusted_ptr_and_unit_offset
unadjusted_ptr_and_unit_offset accidentally throws away the offset computed by
get_addr_base_and_unit_offset. Instead of passing extra_offset it passes offset.

	PR ipa/114207

gcc/ChangeLog:

	* ipa-prop.cc (unadjusted_ptr_and_unit_offset): Fix accounting of offsets in ADDR_EXPR.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/pr114207.c: New test.

(cherry picked from commit 391f46f10b)
2024-07-22 18:09:30 +02:00
Jan Hubicka c5397d343f Compare loop bounds in ipa-icf
Hi,
this testcase shows another poblem with missing comparators for metadata
in ICF. With value ranges available to loop optimizations during early
opts we can estimate number of iterations based on guarding condition that
can be split away by the fnsplit pass. This patch disables ICF when
number of iteraitons does not match.

Bootstrapped/regtesed x86_64-linux, will commit it shortly

gcc/ChangeLog:

	PR ipa/115277
	* ipa-icf-gimple.cc (func_checker::compare_loops): compare loop
	bounds.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/compile/pr115277.c: New test.

(cherry picked from commit 0d19fbc7b0)
2024-07-22 18:09:19 +02:00
Jan Hubicka 9a7d668fc5 Reduce recursive inlining of always_inline functions
this patch tames down inliner on (mutiply) self-recursive always_inline functions.
While we already have caps on recursive inlning, the testcase combines early inliner
and late inliner to get very wide recursive inlining tree.  The basic idea is to
ignore DISREGARD_INLINE_LIMITS when deciding on inlining self recursive functions
(so we cut on function being large) and clear the flag once it is detected.

I did not include the testcase since it still produces a lot of code and would
slow down testing.  It also outputs many inlining failed messages that is not
very nice, but it is hard to detect self recursin cycles in full generality
when indirect calls and other tricks may happen.

gcc/ChangeLog:

	PR ipa/113291

	* ipa-inline.cc (enum can_inline_edge_by_limits_flags): New enum.
	(can_inline_edge_by_limits_p): Take flags instead of multiple bools; add flag
	for forcing inlinie limits.
	(can_early_inline_edge_p): Update.
	(want_inline_self_recursive_call_p): Update; use FORCE_LIMITS mode.
	(check_callers): Update.
	(update_caller_keys): Update.
	(update_callee_keys): Update.
	(recursive_inlining): Update.
	(add_new_edges_to_heap): Update.
	(speculation_useful_p): Update.
	(inline_small_functions): Clear DECL_DISREGARD_INLINE_LIMITS on self recursion.
	(flatten_function): Update.
	(inline_to_all_callers_1): Update.

(cherry picked from commit 1ec4989725)
2024-07-22 17:34:11 +02:00
Maciej W. Rozycki 323d010fa5 [PR115565] cse: Don't use a valid regno for non-register in comparison_qty
Use INT_MIN rather than -1 in `comparison_qty' where a comparison is not
with a register, because the value of -1 is actually a valid reference
to register 0 in the case where it has not been assigned a quantity.

Using -1 makes `REG_QTY (REGNO (folded_arg1)) == ent->comparison_qty'
comparison in `fold_rtx' to incorrectly trigger in rare circumstances
and return true for a memory reference, making CSE consider a comparison
operation to evaluate to a constant expression and consequently make the
resulting code incorrectly execute or fail to execute conditional
blocks.

This has caused a miscompilation of rwlock.c from LinuxThreads for the
`alpha-linux-gnu' target, where `rwlock->__rw_writer != thread_self ()'
expression (where `thread_self' returns the thread pointer via a PALcode
call) has been decided to be always true (with `ent->comparison_qty'
using -1 for a reference to to `rwlock->__rw_writer', while register 0
holding the thread pointer retrieved by `thread_self') and code for the
false case has been optimized away where it mustn't have, causing
program lockups.

The issue has been observed as a regression from commit 08a692679f
("Undefined cse.c behaviour causes 3.4 regression on HPUX"),
<https://gcc.gnu.org/ml/gcc-patches/2004-10/msg02027.html>, and up to
commit 932ad4d9b5 ("Make CSE path following use the CFG"),
<https://gcc.gnu.org/ml/gcc-patches/2006-12/msg00431.html>, where CSE
has been restructured sufficiently for the issue not to trigger with the
original reproducer anymore.  However the original bug remains and can
trigger, because `comparison_qty' will still be assigned -1 for a memory
reference and the `reg_qty' member of a `cse_reg_info_table' entry will
still be assigned -1 for register 0 where the entry has not been
assigned a quantity, e.g. at initialization.

Use INT_MIN then as noted above, so that the value remains negative, for
consistency with the REGNO_QTY_VALID_P macro (even though not used on
`comparison_qty'), and then so that it should not ever match a valid
negated register number, fixing the regression with commit 08a692679f.

	gcc/
	PR rtl-optimization/115565
	* cse.cc (record_jump_cond): Use INT_MIN rather than -1 for
	`comparison_qty' if !REG_P.

(cherry picked from commit 69bc5fb97d)
2024-07-22 10:08:46 +01:00
GCC Administrator 91a6faf8b3 Daily bump. 2024-07-22 00:22:26 +00:00
GCC Administrator 043f3adc9c Daily bump. 2024-07-21 00:22:34 +00:00
Stefan Schulze Frielinghaus bb34b7eda1 s390: Fix unresolved iterators bhfgq and xdee
Code attribute bhfgq is missing a mapping for TF.  This results in
unresolved iterators in assembler templates for *bswaptf.

With the TF mapping added the base mnemonics vlbr and vstbr are not
"used" anymore but only the extended mnemonics (vlbr<bhfgq> was
interpreted as vlbr; likewise for vstbr).  Therefore, remove the base
mnemonics from the scheduling description, otherwise, genattrtab would
error about unknown mnemonics.

Likewise, for movtf_vr only the extended mnemonics for vrepi are used,
now, which means the base mnemonic is "unused" and has to be removed
from the scheduling description.

Similarly, we end up with unresolved iterators in assembler templates
for mulfprx23 since code attribute xdee is missing a mapping for FPRX2.

Note, this is basically a cherry pick of commit r15-2060-ga4abda934aa426
with the addition that vrepi is removed from the scheduling description,
too.

gcc/ChangeLog:

	* config/s390/3931.md (vlbr, vstbr, vrepi): Remove.
	* config/s390/s390.md (xdee): Add FPRX2 mapping.
	* config/s390/vector.md (bhfgq): Add TF mapping.
2024-07-20 16:03:33 +02:00
Siddhesh Poyarekar 2eca8a9548 Avoid undefined behaviour in build_option_suggestions
The inner loop in build_option_suggestions uses OPTION to take the
address of OPTB and use it across iterations, which is undefined
behaviour since OPTB is defined within the loop.  Pull it outside the
loop to make this defined.

gcc/ChangeLog:

	* opt-suggestions.cc
	(option_proposer::build_option_suggestions): Pull OPTB
	definition out of the innermost loop.

(cherry picked from commit e0d997e913)
2024-07-20 07:54:21 -04:00
Paul Thomas 94e4661fee Revert "Fortran: Auto array allocation with function dependencies [PR59104]"
This reverts commit 5034af8223.
2024-07-20 10:42:40 +01:00
GCC Administrator 6b6a056891 Daily bump. 2024-07-20 00:22:33 +00:00
Paul Thomas d15664f71c Fortran: Fix wrong code in unlimited polymorphic assignment [PR113363]
2024-05-13  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/113363
	* trans-array.cc (gfc_array_init_size): Use the expr3 dtype so
	that the correct element size is used.
	* trans-expr.cc (gfc_conv_procedure_call): Remove restriction
	that ss and ss->loop be present for the finalization of class
	array function results.
	(trans_class_assignment): Use free and malloc, rather than
	realloc, for character expressions assigned to unlimited poly
	entities.
	* trans-stmt.cc (gfc_trans_allocate): Build a correct rhs for
	the assignment of an unlimited polymorphic 'source'.

gcc/testsuite/
	PR fortran/113363
	* gfortran.dg/pr113363.f90: New test.

(cherry picked from commit 2d0eeb529d)
2024-07-19 22:00:50 +01:00
Paul Thomas 5034af8223 Fortran: Auto array allocation with function dependencies [PR59104]
2024-06-20  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/59104
	* dependency.cc (dependency_fcn, gfc_function_dependency): New
	functions to detect dependency in array bounds and character
	lengths on old style function results.
	* dependency.h : Add prototype for gfc_function_dependency.
	* error.cc (error_print): Remove trailing space.
	* gfortran.h : Remove dummy_order and add fn_result_spec.
	* symbol.cc : Remove declaration of next_dummy_order..
	(gfc_set_sym_referenced): remove setting of symbol dummy order.
	* trans-array.cc (gfc_trans_auto_array_allocation): Detect
	non-dummy symbols with function dependencies and put the
	allocation at the end of the initialization code.
	* trans-decl.cc : Include dependency.h.
	(decl_order): New function that determines uses the location
	field of the symbol 'declared_at' to determine the order of two
	declarations.
	(gfc_defer_symbol_init): Call gfc_function_dependency to put
	dependent symbols in the right part of the tlink chain. Use
	the location field of the symbol declared_at to determine the
	order of declarations.
	(gfc_trans_auto_character_variable): Put character length
	initialization of dependent symbols at the end of the chain.
	* trans.cc (gfc_add_init_cleanup): Add boolean argument with
	default false that determines whther an expression is placed at
	the back or the front of the initialization chain.
	* trans.h : Update the prototype for gfc_add_init_cleanup.

gcc/testsuite/
	PR fortran/59104
	* gfortran.dg/dependent_decls_2.f90: New test.

(cherry picked from commit ccaa39a268)
2024-07-19 21:59:05 +01:00
René Rebe 1205104bbe rs6000: Fix .machine cpu selection w/ altivec [PR97367]
There are various non-IBM CPUs with altivec, so we cannot use that
flag to determine which .machine cpu to use, so ignore it.
Emit an additional ".machine altivec" if Altivec is enabled so
that the assembler doesn't require an explicit -maltivec option
to assemble any Altivec instructions for those targets where
the ".machine cpu" is insufficient to enable Altivec.  For example,
-mcpu=G5 emits a ".machine power4".

2024-07-18  René Rebe  <rene@exactcode.de>
	    Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/97367
	* config/rs6000/rs6000.cc (rs6000_machine_from_flags): Do not consider
	OPTION_MASK_ALTIVEC.
	(emit_asm_machine): For Altivec compiles, emit a ".machine altivec".

gcc/testsuite/
	PR target/97367
	* gcc.target/powerpc/pr97367.c: New test.

Signed-off-by: René Rebe <rene@exactcode.de>
(cherry picked from commit 6962835bca)
2024-07-19 15:07:10 -05:00
Harald Anlauf ca0fa18add Fortran: character array constructor with >= 4 constant elements [PR103115]
gcc/fortran/ChangeLog:

	PR fortran/103115
	* trans-array.cc (gfc_trans_array_constructor_value): If the first
	element of an array constructor is deferred-length character and
	therefore does not have an element size known at compile time, do
	not try to collect subsequent constant elements into a constructor
	for optimization.

gcc/testsuite/ChangeLog:

	PR fortran/103115
	* gfortran.dg/string_array_constructor_4.f90: New test.

(cherry picked from commit c93be1606e)
2024-07-19 20:27:49 +02:00
Daniel Bertalan 187eec8a2f Fix Xcode 16 build break with NULL != nullptr
As of Xcode 16 beta 2 with the macOS 15 SDK, each re-inclusion of the
stddef.h header causes the NULL macro in C++ to be re-defined to an
integral constant (__null). This makes the workaround in d59a576b8
("Redefine NULL to nullptr") ineffective, as other headers that are
typically included after system.h (such as obstack.h) do include
stddef.h too.

This can be seen by running the sample below through `clang++ -E`

    #include <stddef.h>
    #define NULL nullptr
    #include <stddef.h>
    NULL

The relevant libc++ change is here:
https://github.com/llvm/llvm-project/commit/2950283dddab03c183c1be2d7de9d4999cc86131

Filed as FB14261859 to Apple and added a comment about it on LLVM PR
86843.

This fixes the cases in --enable-languages=c,c++,objc,obj-c++,rust build
where NULL being an integral constant instead of a null pointer literal
(therefore no longer implicitly converting to a pointer when used as a
template function's argument) caused issues.

    gcc/value-pointer-equiv.cc:65:43: error: no viable conversion from `pair<typename __unwrap_ref_decay<long>::type, typename __unwrap_ref_decay<long>::type>' to 'const pair<tree, tree>'

    65 |   const std::pair <tree, tree> m_marker = std::make_pair (NULL, NULL);
       |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~

As noted in the previous commit though, the proper solution would be to
phase out the usages of NULL in GCC's C++ source code.

gcc/analyzer/ChangeLog:

	* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
	Change NULL to nullptr.
	(struct null_assignment_sm_context): Likewise.
	* infinite-loop.cc: Likewise.
	* infinite-recursion.cc: Likewise.
	* varargs.cc (va_list_state_machine::on_leak): Likewise.

gcc/rust/ChangeLog:

	* metadata/rust-imports.cc (Import::try_package_in_directory):
	Change NULL to nullptr.

gcc/ChangeLog:

	* value-pointer-equiv.cc: Change NULL to nullptr.

Signed-off-by: Daniel Bertalan <dani@danielbertalan.dev>
(cherry picked from commit 08776bef53)
2024-07-19 14:54:26 +01:00
Robin Dapp 0abce4116a RISC-V: Split vwadd.wx and vwsub.wx and add helpers.
vwadd.wx and vwsub.wx have the same problem vfwadd.wf had.  This patch
splits the insn pattern in the same way vfwadd.wf was split.

It also adds two patterns to recognize extended scalars.  In practice
those do not provide a lot of improvement over what we already have but
in some instances we can get rid of redundant extensions.

gcc/ChangeLog:

	* config/riscv/vector.md: Split vwadd.wx/vwsub.wx pattern and
	add extended_scalar patterns.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr115068.c: Add vwadd.wx/vwsub.wx
	tests.
	* gcc.target/riscv/rvv/base/pr115068-run.c: Include pr115068.c.
	* gcc.target/riscv/rvv/base/vwaddsub-1.c: New test.

(cherry picked from commit 9781885a62)
2024-07-19 13:55:50 +08:00
Robin Dapp 937713a523 RISC-V: Do not allow v0 as dest when merging [PR115068].
This patch splits the vfw...wf pattern so we do not emit e.g. vfwadd.wf
v0,v8,fa5,v0.t anymore.

gcc/ChangeLog:

	PR target/115068

	* config/riscv/vector.md:  Split vfw<insn>.wf pattern.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr115068-run.c: New test.
	* gcc.target/riscv/rvv/base/pr115068.c: New test.

(cherry picked from commit a2fd0812a5)
2024-07-19 13:55:50 +08:00
Fangrui Song 3a7e796b48 RISC-V: Add -X to link spec
--discard-locals (-X) instructs the linker to remove local .L* symbols,
which occur a lot due to label differences for linker relaxation. The
arm port has a similar need and passes -X to ld.

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

gcc/ChangeLog:

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

(cherry picked from commit 50c218e3ff)
2024-07-19 13:55:50 +08:00
Christoph Müllner 92003fad99 RISC-V: Fix parsing of Zic* extensions
The extension parsing table entries for a range of Zic* extensions
does not match the mask definition in riscv.opt.
This results in broken TARGET_ZIC* macros, because the values of
riscv_zi_subext and riscv_zicmo_subext are set wrong.

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

gcc/ChangeLog:

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

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
(cherry picked from commit 285300eb92)
2024-07-19 13:55:49 +08:00
Pan Li 68ef0c321a RISC-V: Bugfix ICE for RVV intrinisc vfw on _Float16 scalar
For the vfw vx format RVV intrinsic, the scalar type _Float16 also
requires the zvfh extension.  Unfortunately,  we only check the
vector tree type and miss the scalar _Float16 type checking.  For
example:

vfloat32mf2_t test_vfwsub_wf_f32mf2(vfloat32mf2_t vs2, _Float16 rs1, size_t vl)
{
  return __riscv_vfwsub_wf_f32mf2(vs2, rs1, vl);
}

It should report some error message like zvfh extension is required
instead of ICE for unreg insn.

This patch would like to make up such kind of validation for _Float16
in the RVV intrinsic API.  It will report some error like below when
there is no zvfh enabled.

error: built-in function '__riscv_vfwsub_wf_f32mf2(vs2,  rs1,  vl)'
  requires the zvfhmin or zvfh ISA extension

Passed the rv64gcv fully regression tests, included c/c++/fortran.

	PR target/114988

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins.cc
	(validate_instance_type_required_extensions): New func impl to
	validate the intrinisc func type ops.
	(expand_builtin): Validate instance type before expand.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit 41b3cf262e)
2024-07-19 13:55:49 +08:00
Liao Shihua c38dbfc1ce RISC-V: Fix missing boolean_expression in zmmul extension
Update v1->v2
    Add testcase for this patch.

Missing boolean_expression TARGET_ZMMUL in riscv_rtx_costs() cause different instructions when
multiplying an integer with a constant. ( https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1482 )

int foo(int *ib) {
    *ib = *ib * 33938;
    return 0;
}

rv64im:
        lw      a4,0(a1)
        li      a5,32768
        addiw   a5,a5,1170
        mulw    a5,a5,a4
        sw      a5,0(a1)
        ret

rv64i_zmmul:
        lw      a4,0(a1)
        slliw   a5,a4,5
        addw    a5,a5,a4
        slliw   a5,a5,3
        addw    a5,a5,a4
        slliw   a5,a5,3
        addw    a5,a5,a4
        slliw   a5,a5,3
        addw    a5,a5,a4
        slliw   a5,a5,1
        sw      a5,0(a1)
        ret

Fixed.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_rtx_costs): Add TARGET_ZMMUL.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zmmul-3.c: New test.

(cherry picked from commit 06bb125521)
2024-07-19 13:55:49 +08:00
Pan Li 4db38759dc RISC-V: Bugfix vec_extract v mode iterator restriction mismatch
We have vec_extract pattern which takes ZVFHMIN as the mode
iterator of the V mode.  Aka VF_ZVFHMIN iterator.  But it will
expand to pred_extract_first pattern which takes the ZVFH as the mode
iterator of the V mode.  AKa VF.  The mismatch will result in one ICE
similar as below:

insn 30 29 31 2 (set (reg:HF 156 [ _2 ])
        (unspec:HF [
                (vec_select:HF (reg:RVVMF2HF 134 [ _1 ])
                    (parallel [
                            (const_int 0 [0])
                        ]))
                (reg:SI 67 vtype)
            ] UNSPEC_VPREDICATE)) "compress_run-2.c":22:3 -1
     (nil))
during RTL pass: vregs
compress_run-2.c:25:1: internal compiler error: in extract_insn, at
recog.cc:2812
0xb3bc47 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ../../../gcc/gcc/rtl-error.cc:108
0xb3bc69 _fatal_insn_not_found(rtx_def const*, char const*, int, char
const*)
        ../../../gcc/gcc/rtl-error.cc:116
0xb3a545 extract_insn(rtx_insn*)
        ../../../gcc/gcc/recog.cc:2812
0x1010e9e instantiate_virtual_regs_in_insn
        ../../../gcc/gcc/function.cc:1612
0x1010e9e instantiate_virtual_regs
        ../../../gcc/gcc/function.cc:1995
0x1010e9e execute
        ../../../gcc/gcc/function.cc:2042

The below test suites are passed for this patch.
1. The rv64gcv fully regression test.
2. The rv64gcv build with glibc.

There may be other similar issue(s) for the mismatch,  we will take care
of them by test cases one by one.

	PR target/115456

gcc/ChangeLog:

	* config/riscv/vector-iterators.md: Leverage V_ZVFH instead of V
	which contains the VF_ZVFHMIN for alignment.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit c2c61d8902)
2024-07-19 13:55:49 +08:00
Pan Li 87346ed74c RISC-V: Bugfix vec_extract vls mode iterator restriction mismatch
We have vec_extract pattern which takes ZVFHMIN as the mode
iterator of the VLS mode.  Aka V_VLS.  But it will expand to
pred_extract_first pattern which takes the ZVFH as the mode
iterator of the VLS mode.  AKa V_VLSF.  The mismatch will
result in one ICE similar as below:

error: unrecognizable insn:
   27 | }
      | ^
(insn 19 18 20 2 (set (reg:HF 150 [ _13 ])
        (unspec:HF [
                (vec_select:HF (reg:V4HF 134 [ _1 ])
                    (parallel [
                            (const_int 0 [0])
                        ]))
                (reg:SI 67 vtype)
            ] UNSPEC_VPREDICATE)) "compress_run-2.c":24:5 -1
     (nil))
during RTL pass: vregs
compress_run-2.c:27:1: internal compiler error: in extract_insn, at
recog.cc:2812
0x1a627ef _fatal_insn(char const*, rtx_def const*, char const*, int,
char const*)
        ../../../gcc/gcc/rtl-error.cc:108
0x1a62834 _fatal_insn_not_found(rtx_def const*, char const*, int, char
const*)
        ../../../gcc/gcc/rtl-error.cc:116
0x1a0f356 extract_insn(rtx_insn*)
        ../../../gcc/gcc/recog.cc:2812
0x159ee61 instantiate_virtual_regs_in_insn
        ../../../gcc/gcc/function.cc:1612
0x15a04aa instantiate_virtual_regs
        ../../../gcc/gcc/function.cc:1995
0x15a058e execute
        ../../../gcc/gcc/function.cc:2042

This patch would like to fix this issue by align the mode
iterator restriction to ZVFH.

The below test suites are passed for this patch.
1. The rv64gcv fully regression test.
2. The rv64gcv build with glibc.

	PR target/115456

gcc/ChangeLog:

	* config/riscv/autovec.md: Take ZVFH mode iterator instead of
	the ZVFHMIN for the alignment.
	* config/riscv/vector-iterators.md: Add 2 new iterator
	V_VLS_ZVFH and VLS_ZVFH.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr115456-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit 3dac1049c1)
2024-07-19 13:55:49 +08:00
Artemiy Volkov c32995c445 [PATCH] RISC-V: Fix unrecognizable pattern in riscv_expand_conditional_move()
Presently, the code fragment:

int x[5];

void
d(int a, int b, int c) {
  for (int i = 0; i < 5; i++)
    x[i] = (a != b) ? c : a;
}

causes an ICE when compiled with -O2 -march=rv32i_zicond:

test.c: In function 'd':
test.c: error: unrecognizable insn:
   11 | }
      | ^
(insn 8 5 9 2 (set (reg:SI 139 [ iftmp.0_2 ])
        (if_then_else:SI (ne:SI (reg/v:SI 136 [ a ])
                (reg/v:SI 137 [ b ]))
            (reg/v:SI 136 [ a ])
            (reg/v:SI 138 [ c ]))) -1
     (nil))
during RTL pass: vregs

This happens because, as part of one of the optimizations in
riscv_expand_conditional_move(), an if_then_else is generated with both
comparands being register operands, resulting in an unmatchable insn since
Zicond patterns require constant 0 as the second comparand.  Fix this by adding
a extra check before performing this optimization.

The code snippet mentioned above is also included in this patch as a new Zicond
testcase.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_expand_conditional_move): Add a
	CONST0_RTX check.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zicond-ice-5.c: New test.

(cherry picked from commit eb647daa87)
2024-07-19 13:55:49 +08:00
Robin Dapp 2d7dda8473 RISC-V: Use tu policy for first-element vec_set [PR115725].
This patch changes the tail policy for vmv.s.x from ta to tu.
By default the bug does not show up with qemu because qemu's
current vmv.s.x implementation always uses the tail-undisturbed
policy.  With a local qemu version that overwrites the tail
with ones when the tail-agnostic policy is specified, the bug
shows.

gcc/ChangeLog:

	* config/riscv/autovec.md: Add TU policy.
	* config/riscv/riscv-protos.h (enum insn_type): Define
	SCALAR_MOVE_MERGED_OP_TU.

gcc/testsuite/ChangeLog:

	PR target/115725

	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-1.c: Adjust
	test expectation.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-4.c: Ditto.

(cherry picked from commit acc3b703c0)
2024-07-19 13:55:49 +08:00
Fei Gao b218c42532 [RISC-V] add implied extension repeatly until stable
Call handle_implied_ext repeatly until there's no
new subset added into the subset list.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_subset_list::riscv_subset_list):
	init m_subset_num to 0.
	(riscv_subset_list::add): increase m_subset_num once a subset added.
	(riscv_subset_list::finalize): call handle_implied_ext repeatly
	until no change in m_subset_num.
	* config/riscv/riscv-subset.h: add m_subset_num member.

Signed-off-by: Fei Gao <gaofei@eswincomputing.com>
(cherry picked from commit 682731d11f)
2024-07-19 13:55:49 +08:00
GCC Administrator a2a2916755 Daily bump. 2024-07-19 00:25:13 +00:00
Marek Polacek 493035c878 eh: ICE with std::initializer_list and ASan [PR115865]
Here we ICE with -fsanitize=address on

  std::initializer_list x = { 1, 2, 3 };

since r14-8681, which removed .ASAN_MARK calls on TREE_STATIC variables.
That means that lower_try_finally now instead of

  try
    {
      .ASAN_MARK (UNPOISON, &C.0, 12);
      x = {};
      x._M_len = 3;
      x._M_array = &C.0;
    }
  finally
    {
      .ASAN_MARK (POISON, &C.0, 12);
    }

gets:

  try
    {
      x = {};
      x._M_len = 3;
      x._M_array = &C.0;
    }
  finally
    {

    }

and we ICE on the empty finally in lower_try_finally_onedest while
getting get_eh_else.

	PR c++/115865

gcc/ChangeLog:

	* tree-eh.cc (get_eh_else): Check that the result of
	gimple_seq_first_stmt is non-null.

gcc/testsuite/ChangeLog:

	* g++.dg/asan/initlist2.C: New test.

Co-authored-by: Jakub Jelinek  <jakub@redhat.com>
(cherry picked from commit 1e60a6abfe)
2024-07-18 11:49:54 -04:00
LIU Hao 747c4b5857 Do not use caller-saved registers for COMDAT functions
A reference to a COMDAT function may be resolved to another definition
outside the current translation unit, so it's not eligible for `-fipa-ra`.

In `decl_binds_to_current_def_p()` there is already a check for weak
symbols. This commit checks for COMDAT functions that are not implemented
as weak symbols, for example, on *-*-mingw32.

gcc/ChangeLog:

	PR rtl-optimization/115049
	* varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT
	declarations too, like weak ones.

(cherry picked from commit 5080840d8f)
2024-07-18 13:22:28 +00:00
Marek Polacek c314867fc0 c++: ICE with __has_unique_object_representations [PR115476]
Here we started to ICE with r13-25: in check_trait_type, for "X[]" we
return true here:

  if (kind == 1 && TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type))
    return true; // Array of unknown bound. Don't care about completeness.

and then end up crashing in record_has_unique_obj_representations:

4836	  if (cur != wi::to_offset (sz))

because sz is null.

https://eel.is/c++draft/type.traits#tab:meta.unary.prop-row-47-column-3-sentence-1
says that the preconditions for __has_unique_object_representations are:
"T shall be a complete type, cv void, or an array of unknown bound" and
that "For an array type T, the same result as
has_unique_object_representations_v<remove_all_extents_t<T>>" so T[]
should be treated as T.  So we should use kind==2 for the trait.

	PR c++/115476

gcc/cp/ChangeLog:

	* semantics.cc (finish_trait_expr)
	<case CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS>: Move below to call
	check_trait_type with kind==2.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/has-unique-obj-representations4.C: New test.

(cherry picked from commit fc382a373e)
2024-07-18 13:50:42 +02:00
Roger Sayle a4c9ade728 i386: PR target/115351: RTX costs for *concatditi3 and *insvti_highpart.
This patch addresses PR target/115351, which is a code quality regression
on x86 when passing floating point complex numbers.  The ABI considers
these arguments to have TImode, requiring interunit moves to place the
FP values (which are actually passed in SSE registers) into the upper
and lower parts of a TImode pseudo, and then similar moves back again
before they can be used.

The cause of the regression is that changes in how TImode initialization
is represented in RTL now prevents the RTL optimizers from eliminating
these redundant moves.  The specific cause is that the *concatditi3
pattern, (zext(hi)<<64)|zext(lo), has an inappropriately high (default)
rtx_cost, preventing fwprop1 from propagating it.  This pattern just
sets the hipart and lopart of a double-word register, typically two
instructions (less if reload can allocate things appropriately) but
the current ix86_rtx_costs actually returns INSN_COSTS(13), i.e. 52.

propagating insn 5 into insn 6, replacing:
(set (reg:TI 110)
    (ior:TI (and:TI (reg:TI 110)
            (const_wide_int 0x0ffffffffffffffff))
        (ashift:TI (zero_extend:TI (subreg:DI (reg:DF 112 [ zD.2796+8 ]) 0))
            (const_int 64 [0x40]))))
successfully matched this instruction to *concatditi3_3:
(set (reg:TI 110)
    (ior:TI (ashift:TI (zero_extend:TI (subreg:DI (reg:DF 112 [ zD.2796+8 ]) 0))
            (const_int 64 [0x40]))
        (zero_extend:TI (subreg:DI (reg:DF 111 [ zD.2796 ]) 0))))
change not profitable (cost 50 -> cost 52)

This issue is resolved by having ix86_rtx_costs return more reasonable
values for these (place-holder) patterns.

2024-06-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR target/115351
	* config/i386/i386.cc (ix86_rtx_costs): Provide estimates for
	the *concatditi3 and *insvti_highpart patterns, about two insns.

gcc/testsuite/ChangeLog
	PR target/115351
	* g++.target/i386/pr115351.C: New test case.

(cherry picked from commit fb3e4c549d)
2024-07-18 13:50:42 +02:00
David Malcolm b0452ed2fd analyzer: fix ICE seen with -fsanitize=undefined [PR114899]
gcc/analyzer/ChangeLog:
	PR analyzer/114899
	* access-diagram.cc
	(written_svalue_spatial_item::get_label_string): Bulletproof
	against SSA_NAME_VAR being null.

gcc/testsuite/ChangeLog:
	PR analyzer/114899
	* c-c++-common/analyzer/out-of-bounds-diagram-pr114899.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
(cherry picked from commit 1779e22150)
2024-07-18 13:50:42 +02:00
Jan Hubicka 0b7ec50ae2 Fix points_to_local_or_readonly_memory_p wrt TARGET_MEM_REF
TARGET_MEM_REF can be used to offset constant base into a memory object (to
produce lea instruction).  This confuses points_to_local_or_readonly_memory_p
which treats the constant address as a base of the access.

Bootstrapped/regtsted x86_64-linux, comitted.
Honza

gcc/ChangeLog:

	PR ipa/113787
	* ipa-fnsummary.cc (points_to_local_or_readonly_memory_p): Do not
	look into TARGET_MEM_REFS with constant opreand 0.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/pr113787.c: New test.

(cherry picked from commit 96d53252ae)
2024-07-18 13:50:42 +02:00
Roger Sayle 0f593e4cd8 PR tree-optimization/113673: Avoid load merging when potentially trapping.
This patch fixes PR tree-optimization/113673, a P2 ice-on-valid regression
caused by load merging of (ptr[0]<<8)+ptr[1] when -ftrapv has been
specified.  When the operator is | or ^ this is safe, but for addition
of signed integer types, a trap may be generated/required, so merging this
idiom into a single non-trapping instruction is inappropriate, confusing
the compiler by transforming a basic block with an exception edge into one
without.

This revision implements Richard Biener's feedback to add an early check
for stmt_can_throw_internal (cfun, stmt) to prevent transforming in the
presence of any statement that could trap, not just overflow on addition.
The one other tweak included in this patch is to mark the local function
find_bswap_or_nop_load as static ensuring that it isn't called from outside
this file, and guaranteeing that it is dominated by stmt_can_throw_internal
checking.

2024-06-24  Roger Sayle  <roger@nextmovesoftware.com>
	    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
	PR tree-optimization/113673
	* gimple-ssa-store-merging.cc (find_bswap_or_nop_load): Make static.
	(find_bswap_or_nop_1): Avoid transformations (load merging) when
	stmt_can_throw_internal indicates that a statement can trap.

gcc/testsuite/ChangeLog
	PR tree-optimization/113673
	* g++.dg/pr113673.C: New test case.

(cherry picked from commit d8b05aef77)
2024-07-18 13:50:41 +02:00
Jakub Jelinek 0fbad21b07 testsuite: Fix up builtin-clear-padding-3.c for -funsigned-char
As reported on gcc-regression, this test FAILs on aarch64, but my
r15-2090 change didn't change anything on the generated assembly,
just added the forgotten dg-do run directive to the test, so the
test has been failing forever, just we didn't know it.

I can actually reproduce it on x86_64 with -funsigned-char too,
s2.b.a has int type and -1 is stored to it, so we should compare
it against -1 rather than (char) -1; the latter is appropriate for
testing char fields into which we've stored -1.

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

	* c-c++-common/torture/builtin-clear-padding-3.c (main): Compare
	s2.b.a against -1 rather than (char) -1.

(cherry picked from commit 958ee13874)
2024-07-18 09:37:04 +02:00
Nathaniel Shead f0c3a1c16a c++/modules: Conditionally start timer during lazy load [PR115165]
While lazy loading, instantiation of pendings can sometimes recursively
perform name lookup and begin further lazy loading.  When using the
'-ftime-report' functionality this causes ICEs as we could start an
already-running timer for the importing.

This patch fixes the issue by using the 'timevar_cond*' API instead to
support such recursive calls.

	PR c++/115165

gcc/cp/ChangeLog:

	* module.cc (lazy_load_binding): Use 'timevar_cond*' APIs.
	(lazy_load_pendings): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/timevar-1_a.H: New test.
	* g++.dg/modules/timevar-1_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-07-18 13:08:29 +10:00
GCC Administrator 4871b0f74c Daily bump. 2024-07-18 00:24:42 +00:00
Patrick Palka 1bbfe788d1 c++: constrained partial spec type context [PR111890]
maybe_new_partial_specialization wasn't propagating TYPE_CONTEXT when
creating a new class type corresponding to a constrained partial spec,
which do_friend relies on via template_class_depth to distinguish a
template friend from a non-template friend, and so in the below testcase
we were incorrectly instantiating the non-template operator+ as if it
were a template leading to an ICE.

	PR c++/111890

gcc/cp/ChangeLog:

	* pt.cc (maybe_new_partial_specialization): Propagate TYPE_CONTEXT
	to the newly created partial specialization.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-partial-spec15.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 247335823f)
2024-07-17 15:02:25 -04:00
Patrick Palka 2249c63488 c++: alias template with dependent attributes [PR115897]
Here we're prematurely stripping the dependent alias template-id A<T> to
its defining-type-id T when used as a template argument, which in turn
causes us to essentially ignore A's vector_size attribute in the outer
template-id.

This has always been a problem for class template-ids it seems, and after
r14-2170 variable template-ids are affected as well.

This patch marks alias templates that have a dependent attribute as
complex (as with e.g. constrained alias templates) so that we don't look
through them prematurely.

	PR c++/115897

gcc/cp/ChangeLog:

	* pt.cc (complex_alias_template_p): Return true for an alias
	template with attributes.
	(get_underlying_template): Don't look through an alias template
	with attributes.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-77.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7954bb4fcb)
2024-07-17 15:02:24 -04:00
Patrick Palka 79c5a09f95 c++: bad 'this' conversion for nullary memfn [PR106760]
Here we notice the 'this' conversion for the call f<void>() is bad, so
we correctly defer deduction for the template candidate, but we end up
never adding it to 'bad_cands' since missing_conversion_p for it returns
false (its only argument is 'this' which has already been determined to
be bad).  This is not a huge deal, but it causes us to longer accept the
call with -fpermissive in release builds, and a tree check ICE in checking
builds.

So if we have a non-strictly viable template candidate that has not been
instantiated, then we need to add it to 'bad_cands' even if no argument
conversion is missing.

	PR c++/106760

gcc/cp/ChangeLog:

	* call.cc (add_candidates): Relax test for adding a candidate
	to 'bad_cands' to also accept an uninstantiated template candidate
	that has no missing conversions.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/conv3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 50073ffae0)
2024-07-17 15:02:24 -04:00
Uros Bizjak 3a963d441a alpha: Fix duplicate !tlsgd!62 assemble error [PR115526]
Add missing "cannot_copy" attribute to instructions that have to
stay in 1-1 correspondence with another insn.

	PR target/115526

gcc/ChangeLog:

	* config/alpha/alpha.md (movdi_er_high_g): Add cannot_copy attribute.
	(movdi_er_tlsgd): Ditto.
	(movdi_er_tlsldm): Ditto.
	(call_value_osf_<tls>): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/alpha/pr115526.c: New test.

(cherry picked from commit 0841fd4c42)
2024-07-17 18:13:41 +02:00
Jakub Jelinek 01dfc5b4ad bitint: Use gsi_insert_on_edge rather than gsi_insert_on_edge_immediate [PR115887]
The following testcase ICEs on x86_64-linux, because we try to
gsi_insert_on_edge_immediate a statement on an edge which already has
statements queued with gsi_insert_on_edge, and the deferral has been
intentional so that we don't need to deal with cfg changes in between.

The following patch uses the delayed insertion as well.

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

	PR middle-end/115887
	* gimple-lower-bitint.cc (gimple_lower_bitint): Use gsi_insert_on_edge
	instead of gsi_insert_on_edge_immediate and set edge_insertions to
	true.

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

(cherry picked from commit 5104fe4c78)
2024-07-17 17:43:04 +02:00
Jakub Jelinek d668f87598 gimple-fold: Fix up __builtin_clear_padding lowering [PR115527]
The builtin-clear-padding-6.c testcase fails as clear_padding_type
doesn't correctly recompute the buf->size and buf->off members after
expanding clearing of an array using a runtime loop.
buf->size should be in that case the offset after which it should continue
with next members or padding before them modulo UNITS_PER_WORD and
buf->off that offset minus buf->size.  That is what the code was doing,
but with off being the start of the loop cleared array, not its end.
So, the last hunk in gimple-fold.cc fixes that.
When adding the testcase, I've noticed that the
c-c++-common/torture/builtin-clear-padding-* tests, although clearly
written as runtime tests to test the builtins at runtime, didn't have
{ dg-do run } directive and were just compile tests because of that.
When adding that to the tests, builtin-clear-padding-1.c was already
failing without that clear_padding_type hunk too, but
builtin-clear-padding-5.c was still failing even after the change.
That is due to a bug in clear_padding_flush which the patch fixes as
well - when clear_padding_flush is called with full=true (that happens
at the end of the whole __builtin_clear_padding or on those array
padding clears done by a runtime loop), it wants to flush all the pending
padding clearings rather than just some.  If it is at the end of the whole
object, it decreases wordsize when needed to make sure the code never writes
including RMW cycles to something outside of the object:
      if ((unsigned HOST_WIDE_INT) (buf->off + i + wordsize)
          > (unsigned HOST_WIDE_INT) buf->sz)
        {
          gcc_assert (wordsize > 1);
          wordsize /= 2;
          i -= wordsize;
          continue;
        }
but if it is full==true flush in the middle, this doesn't happen, but we
still process just the buffer bytes before the current end.  If that end
is not on a wordsize boundary, e.g. on the builtin-clear-padding-5.c test
the last chunk is 2 bytes, '\0', '\xff', i is 16 and end is 18,
nonzero_last might be equal to the end - i, i.e. 2 here, but still all_ones
might be true, so in some spots we just didn't emit any clearing in that
last chunk.

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

	PR middle-end/115527
	* gimple-fold.cc (clear_padding_flush): Introduce endsize
	variable and use it instead of wordsize when comparing it against
	nonzero_last.
	(clear_padding_type): Increment off by sz.

	* c-c++-common/torture/builtin-clear-padding-1.c: Add dg-do run
	directive.
	* c-c++-common/torture/builtin-clear-padding-2.c: Likewise.
	* c-c++-common/torture/builtin-clear-padding-3.c: Likewise.
	* c-c++-common/torture/builtin-clear-padding-4.c: Likewise.
	* c-c++-common/torture/builtin-clear-padding-5.c: Likewise.
	* c-c++-common/torture/builtin-clear-padding-6.c: New test.

(cherry picked from commit 8b5919bae1)
2024-07-17 17:40:47 +02:00
Jakub Jelinek 297ea7e5bb c++: Fix ICE on constexpr placement new [PR115754]
C++26 is making in P2747R2 paper placement new constexpr.
While working on a patch for that, I've noticed we ICE starting with
GCC 14 on the following testcase.
The problem is that e.g. for the void * to sometype * casts checks,
we really assume the casts have their operand constant evaluated
as prvalue, but on the testcase the cast itself is evaluated with
vc_discard and that means op can end up e.g. a VAR_DECL which the
later code doesn't like and asserts on.
If the result type is void, we don't really need the cast operand
for anything, so can use vc_discard for the recursive call,
VIEW_CONVERT_EXPR can appear on the lhs, so we need to honor the
lval but otherwise the patch uses vc_prvalue.
I'd like to get this patch in before the rest of P2747R2 implementation,
so that it can be backported to 14.2 later on.

2024-07-02  Jakub Jelinek  <jakub@redhat.com>
	    Jason Merrill  <jason@redhat.com>

	PR c++/115754
	* constexpr.cc (cxx_eval_constant_expression) <case CONVERT_EXPR>:
	For conversions to void, pass vc_discard to the recursive call
	and otherwise for tcode other than VIEW_CONVERT_EXPR pass vc_prvalue.

	* g++.dg/cpp26/pr115754.C: New test.

(cherry picked from commit 1250540a98)
2024-07-17 17:38:04 +02:00
Robin Dapp bf64404280 vect: Merge loop mask and cond_op mask in fold-left reduction [PR115382].
Currently we discard the cond-op mask when the loop is fully masked
which causes wrong code in
gcc.dg/vect/vect-cond-reduc-in-order-2-signed-zero.c
when compiled with
-O3 -march=cascadelake --param vect-partial-vector-usage=2.

This patch ANDs both masks.

gcc/ChangeLog:

	PR tree-optimization/115382

	* tree-vect-loop.cc (vectorize_fold_left_reduction): Use
	prepare_vec_mask.
	* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
	Remove static of prepare_vec_mask.
	* tree-vectorizer.h (prepare_vec_mask): Export.

(cherry picked from commit 2b438a0d2a)
2024-07-17 08:18:21 +02:00
Richard Biener c58bede01c tree-optimization/115868 - ICE with .MASK_CALL in simdclone
The following adjusts mask recording which didn't take into account
that we can merge call arguments from two vectors like

  _50 = {vect_d_1.253_41, vect_d_1.254_43};
  _51 = VIEW_CONVERT_EXPR<unsigned char>(mask__19.257_49);
  _52 = (unsigned int) _51;
  _53 = _Z3bazd.simdclone.7 (_50, _52);
  _54 = BIT_FIELD_REF <_53, 256, 0>;
  _55 = BIT_FIELD_REF <_53, 256, 256>;

The testcase g++.dg/vect/pr68762-2.cc exercises this on x86_64 with
partial vector usage enabled and AVX512 support.

	PR tree-optimization/115868
	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Correctly
	compute the number of mask copies required for vect_record_loop_mask.

(cherry picked from commit abf3964711)
2024-07-17 08:14:27 +02:00
Nathaniel Shead 5fad0b552c c++/modules: Propagate BINDING_VECTOR_*_DUPS_P on realloc [PR99242]
When importing modules, when a binding vector for a name runs out of
slots it gets reallocated with a larger size, and existing bindings are
copied across.  However, the flags to indicate whether deduping needs to
occur did not: this causes ICEs, as it allows a duplicate binding to be
added which then violates assumptions later on.

	PR c++/99242

gcc/cp/ChangeLog:

	* name-lookup.cc (append_imported_binding_slot): Propagate dups
	flags.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr99242_a.H: New test.
	* g++.dg/modules/pr99242_b.H: New test.
	* g++.dg/modules/pr99242_c.H: New test.
	* g++.dg/modules/pr99242_d.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit 1aa0f16278)
2024-07-17 11:23:23 +10:00
GCC Administrator 4039c7473a Daily bump. 2024-07-17 00:24:45 +00:00
Richard Biener 59ed01d5e3 tree-optimization/115841 - reduction epilogue placement issue
When emitting the compensation to the vectorized main loop for
a vector reduction value to be re-used in the vectorized epilogue
we fail to place it in the correct block when the main loop is
known to be entered (no loop_vinfo->main_loop_edge) but the
epilogue is not (a loop_vinfo->skip_this_loop_edge).  The code
currently disregards this situation.

With the recent znver4 cost fix I couldn't trigger this situation
with the testcase but I adjusted it so it could eventually trigger
on other targets.

	PR tree-optimization/115841
	* tree-vect-loop.cc (vect_transform_cycle_phi): Correctly
	place the partial vector reduction for the accumulator
	re-use when the main loop cannot be skipped but the
	epilogue can.

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

(cherry picked from commit 016c947b02)
2024-07-16 16:22:35 +02:00
Richard Biener 06829e593d tree-optimization/115843 - fix wrong-code with fully-masked loop and peeling
When AVX512 uses a fully masked loop and peeling we fail to create the
correct initial loop mask when the mask is composed of multiple
components in some cases.  The following fixes this by properly applying
the bias for the component to the shift amount.

	PR tree-optimization/115843
	* tree-vect-loop-manip.cc
	(vect_set_loop_condition_partial_vectors_avx512): Properly
	bias the shift of the initial mask for alignment peeling.

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

(cherry picked from commit a177be05f6)
2024-07-16 16:22:24 +02:00
Richard Biener e01012c459 tree-optimization/115701 - fix maybe_duplicate_ssa_info_at_copy
The following restricts copying of points-to info from defs that
might be in regions invoking UB and are never executed.

	PR tree-optimization/115701
	* tree-ssanames.cc (maybe_duplicate_ssa_info_at_copy):
	Only copy info from within the same BB.

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

(cherry picked from commit b77f17c5fe)
2024-07-16 16:22:05 +02:00
Richard Biener 6f74a5f5dc tree-optimization/115701 - factor out maybe_duplicate_ssa_info_at_copy
The following factors out the code that preserves SSA info of the LHS
of a SSA copy LHS = RHS when LHS is about to be eliminated to RHS.

	PR tree-optimization/115701
	* tree-ssanames.h (maybe_duplicate_ssa_info_at_copy): Declare.
	* tree-ssanames.cc (maybe_duplicate_ssa_info_at_copy): New
	function, split out from ...
	* tree-ssa-copy.cc (fini_copy_prop): ... here.
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): ...
	and here.

(cherry picked from commit b5c64b413f)
2024-07-16 16:22:05 +02:00
Richard Biener ca275b68ef tree-optimization/115867 - ICE with simdcall vectorization in masked loop
When only a loop mask is to be supplied for the inbranch arg to a
simd function we fail to handle integer mode masks correctly.  We
need to guess the number of elements represented by it.  This assumes
that excess arguments are all for masks, I wasn't able to create
a simdclone with more than one integer mode mask argument.

The gcc.dg/vect/vect-simd-clone-20.c exercises this with -mavx512vl

	PR tree-optimization/115867
	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Properly
	guess the number of mask elements for integer mode masks.

(cherry picked from commit 4f4478f0f3)
2024-07-16 16:22:05 +02:00
Richard Biener 4a04110ec8 Fixup unaligned load/store cost for znver5
Currently unaligned YMM and ZMM load and store costs are cheaper than
aligned which causes the vectorizer to purposely mis-align accesses
by adding an alignment prologue.  It looks like the unaligned costs
were simply copied from the bogus znver4 costs.  The following makes
the unaligned costs equal to the aligned costs like in the fixed znver4
version.

	* config/i386/x86-tune-costs.h (znver5_cost): Update unaligned
	load and store cost from the aligned costs.

(cherry picked from commit 896393791e)
2024-07-16 16:22:05 +02:00
Richard Biener d702a95775 Fixup unaligned load/store cost for znver4
Currently unaligned YMM and ZMM load and store costs are cheaper than
aligned which causes the vectorizer to purposely mis-align accesses
by adding an alignment prologue.  It looks like the unaligned costs
were simply left untouched from znver3 where they equate the aligned
costs when tweaking aligned costs for znver4.  The following makes
the unaligned costs equal to the aligned costs.

This avoids the miscompile seen in PR115843 but it's of course not
a real fix for the issue uncovered there.  But it makes it qualify
as a regression fix.

	PR tree-optimization/115843
	* config/i386/x86-tune-costs.h (znver4_cost): Update unaligned
	load and store cost from the aligned costs.

(cherry picked from commit 1e3aa9c927)
2024-07-16 16:22:05 +02:00
Alexandre Oliva c8fdef7fc2 [alpha] adjust MEM alignment for block move [PR115459]
Before issuing loads or stores for a block move, adjust the MEM
alignments if analysis of the addresses enabled the inference of
stricter alignment.  This ensures that the MEMs are sufficiently
aligned for the corresponding insns, which avoids trouble in case of
e.g. substitutions into SUBREGs.


for  gcc/ChangeLog

	PR target/115459
	* config/alpha/alpha.cc (alpha_expand_block_move): Adjust
	MEMs to match inferred alignment.

(cherry picked from commit ccfe715180)
2024-07-16 08:54:20 -03:00
Christoph Müllner b3cff8357e RISC-V: Allow adding enabled extension via target arch attributes
The set of enabled extensions can be extended via target arch function
attributes by listing each extension with a '+' prefix and a comma as
list separator.  E.g.:
  __attribute__((target("arch=+zba,+zbb"))) void foo();

The programmer intends to ensure that one or more extensions
are enabled when building the code.  This is independent of the arch
string that is passed at build time via the -march= option.

Therefore, it is reasonable to allow enabling extensions via target arch
attributes, which have already been enabled via the -march= string.

The subset list code already supports such duplication for implied
extensions.  This patch adds an interface so the subset list
parser can be switched into a mode where duplication is allowed.

This commit fixes the following regressed test cases:
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-39.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-42.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-43.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-44.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-45.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-46.c

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_subset_list::add):
	Allow adding enabled extension if m_allow_adding_dup is set.
	* config/riscv/riscv-subset.h: Add m_allow_adding_dup and setter.
	* config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::parse_arch):
	Allow adding enabled extensions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr115554.c: Change expected fail to expected pass.
	* gcc.target/riscv/target-attr-16.c: New test.

(cherry picked from commit 61c21a719e)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-16 13:02:16 +02:00
Christoph Müllner 0e1f599d63 RISC-V: Rewrite target attribute handling
The target-arch attribute handling in RISC-V is only a few months old,
but already saw a rewrite (9941f0295a), which addressed an important
issue.  This rewrite introduced a hash table in the backend, which is
used to keep track of target-arch attributes of all functions.
The index of this hash table is the pointer to the function declaration
object (fndecl).  However, objects like these don't have the lifetime
that is assumed here, which resulted in observing two fndecl objects
with the same address for different objects (triggering the assertion
in riscv_func_target_put() -- see also PR115562).

This patch removes the hash table approach in favor of storing target
specific options using the DECL_FUNCTION_SPECIFIC_TARGET() macro, which
is also used by other backends and is specifically designed for this
purpose (https://gcc.gnu.org/onlinedocs/gccint/Function-Properties.html).

To have an accessible field in the target options, we need to
adjust riscv.opt and introduce the field riscv_arch_string
(for the already existing option '-march=').

Using this macro allows to remove much code from riscv-common.cc, which
controls access to the objects 'func_target_table' and 'current_subset_list'.

One thing to mention is, that we had two subset lists:
current_subset_list and cmdline_subset_list, with the latter being
introduced recently for target attribute handling.
This patch reduces them back to one (cmdline_subset_list) which
contains the list of extensions that have been enabled by the command
line arguments.

Note that the patch keeps the existing behavior of rejecting
duplications of extensions when added via the '+' operator in a function
target attribute.  E.g. "-march=rv64gc_zbb" and "arch=+zbb" will trigger
an error (see pr115554.c).  However, at the same time this patch breaks
the acceptance of adding implied extensions, which causes the following
six regressions (with the error "extension 'EXT' appear more than one time"):
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-39.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-42.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-43.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-44.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-45.c
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-46.c

New tests were added to document the behavior and to ensure it won't
regress.  This patch did not show any regressions for rv32/rv64
and fixes the ICEs from PR115554 and PR115562.

	PR target/115554
	PR target/115562

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (struct riscv_func_target_info):
	Remove.
	(struct riscv_func_target_hasher): Likewise.
	(riscv_func_decl_hash): Likewise.
	(riscv_func_target_hasher::hash): Likewise.
	(riscv_func_target_hasher::equal): Likewise.
	(riscv_current_subset_list): Likewise.
	(riscv_cmdline_subset_list): Remove obsolete space.
	(riscv_func_target_table_lazy_init): Remove.
	(riscv_func_target_get): Likewise.
	(riscv_func_target_put): Likewise.
	(riscv_func_target_remove_and_destory): Likewise.
	(riscv_arch_str): Generate from cmdline_subset_list.
	(riscv_set_arch_by_subset_list): Don't set current_subset_list.
	(riscv_parse_arch_string): Remove current_subset_list.
	* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins):
	Get subset list via riscv_cmdline_subset_list().
	* config/riscv/riscv-subset.h (riscv_current_subset_list):
	Remove prototype.
	(riscv_func_target_get): Likewise.
	(riscv_func_target_put): Likewise.
	(riscv_func_target_remove_and_destory): Likewise.
	* config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::parse_arch):
	Build base arch string from existing target options, if any.
	(riscv_target_attr_parser::update_settings): Store new arch
	string in target options.
	(riscv_process_one_target_attr): Whitespace fix.
	(riscv_process_target_attr): Drop opts argument.
	(riscv_option_valid_attribute_p): Properly save, change and restore
	target options.
	* config/riscv/riscv.cc (get_arch_str): New function.
	(riscv_declare_function_name): Get arch string for option-arch
	directive from function's target options.
	* config/riscv/riscv.opt: Add riscv_arch_string variable to
	march option.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/target-attr-01.c: Add test for option-arch directive.
	* gcc.target/riscv/target-attr-02.c: Likewise.
	* gcc.target/riscv/target-attr-03.c: Likewise.
	* gcc.target/riscv/target-attr-04.c: Likewise.
	* gcc.target/riscv/target-attr-05.c: Fix formatting.
	* gcc.target/riscv/target-attr-06.c: Likewise.
	* gcc.target/riscv/target-attr-07.c: Likewise.
	* gcc.target/riscv/pr115554.c: New test.
	* gcc.target/riscv/pr115562.c: New test.
	* gcc.target/riscv/target-attr-08.c: New test.
	* gcc.target/riscv/target-attr-09.c: New test.
	* gcc.target/riscv/target-attr-10.c: New test.
	* gcc.target/riscv/target-attr-11.c: New test.
	* gcc.target/riscv/target-attr-12.c: New test.
	* gcc.target/riscv/target-attr-13.c: New test.
	* gcc.target/riscv/target-attr-14.c: New test.
	* gcc.target/riscv/target-attr-15.c: New test.

(cherry picked from commit aa8e2de78c)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-16 13:02:16 +02:00
Christoph Müllner b604d59b23 RISC-V: Fix comment/naming in attribute parsing code
Function target attributes have to be separated by semi-colons.
Let's fix the comment and variable naming to better explain what
the code does.

gcc/ChangeLog:

	* config/riscv/riscv-target-attr.cc (riscv_process_target_attr):
	Fix comments and variable names.

(cherry picked from commit 5ef0b7d204)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-16 13:02:16 +02:00
Christoph Müllner 20fb450d17 RISC-V: Deduplicate arch subset list processing
We have a code duplication in riscv_set_arch_by_subset_list() and
riscv_parse_arch_string(), where the latter function parses an ISA string
into a subset_list before doing the same as the former function.

riscv_parse_arch_string() is used to process command line options and
riscv_set_arch_by_subset_list() processes target attributes.
So, it is obvious that both functions should do the same.
Let's deduplicate the code to enforce this.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_set_arch_by_subset_list):
	Fix overlong line.
	(riscv_parse_arch_string): Replace duplicated code by a call to
	riscv_set_arch_by_subset_list.

(cherry picked from commit 85fa334fbc)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-16 13:02:16 +02:00
Christoph Müllner ea5907d6d4 RISC-V: testsuite: Properly gate LTO tests
There are two test cases with the following skip directive:
  dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" }
This reads as: skip if both '-flto' and '-fno-fat-lto-objects'
are present.  This is not the case if only '-flto' is present.

Since both tests depend on instruction sequences (one does
check-function-bodies the other tests for an assembler error
message), they won't work reliably with fat LTO objects.

Let's change the skip line to gate the test on '-flto'
to avoid failing tests like this:

FAIL: gcc.target/riscv/interrupt-misaligned.c   -O2 -flto   check-function-bodies interrupt
FAIL: gcc.target/riscv/interrupt-misaligned.c   -O2 -flto -flto-partition=none   check-function-bodies interrupt
FAIL: gcc.target/riscv/pr93202.c   -O2 -flto   (test for errors, line 10)
FAIL: gcc.target/riscv/pr93202.c   -O2 -flto   (test for errors, line 9)
FAIL: gcc.target/riscv/pr93202.c   -O2 -flto -flto-partition=none   (test for errors, line 10)
FAIL: gcc.target/riscv/pr93202.c   -O2 -flto -flto-partition=none   (test for errors, line 9)

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/interrupt-misaligned.c: Remove
	"-fno-fat-lto-objects" from skip condition.
	* gcc.target/riscv/pr93202.c: Likewise.

(cherry picked from commit 0717d50fc4)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-07-16 13:02:16 +02:00
Alexandre Oliva 7bc63f1c70 [i386] adjust flag_omit_frame_pointer in a single function [PR113719]
The first two patches for PR113719 have each regressed
gcc.dg/ipa/iinline-attr.c on a different target.  The reason for this
instability is that there are competing flag_omit_frame_pointer
overriders on x86:

- ix86_recompute_optlev_based_flags computes and sets a
  -f[no-]omit-frame-pointer default depending on
  USE_IX86_FRAME_POINTER and, in 32-bit mode, optimize_size

- ix86_option_override_internal enables flag_omit_frame_pointer for
  -momit-leaf-frame-pointer to take effect

ix86_option_override[_internal] calls
ix86_recompute_optlev_based_flags before setting
flag_omit_frame_pointer.  It is called during global process_options.

But ix86_recompute_optlev_based_flags is also called by
parse_optimize_options, during attribute processing, and at that
point, ix86_option_override is not called, so the final overrider for
global options is not applied to the optimize attributes.  If they
differ, the testcase fails.

In order to fix this, we need to process all overriders of this option
whenever we process any of them.  Since this setting is affected by
optimization options, it makes sense to compute it in
parse_optimize_options, rather than in process_options.


for  gcc/ChangeLog

	PR target/113719
	* config/i386/i386-options.cc (ix86_option_override_internal):
	Move flag_omit_frame_pointer final overrider...
	(ix86_recompute_optlev_based_flags): ... here.

(cherry picked from commit bf8e80f9d1)
2024-07-16 06:37:13 -03:00
Alexandre Oliva 102bcf1478 [i386] restore recompute to override opts after change [PR113719]
The first patch for PR113719 regressed gcc.dg/ipa/iinline-attr.c on
toolchains configured to --enable-frame-pointer, because the
optimization node created within handle_optimize_attribute had
flag_omit_frame_pointer incorrectly set, whereas
default_optimization_node didn't.  With this difference,
can_inline_edge_by_limits_p flagged an optimization mismatch and we
refused to inline the function that had a redundant optimization flag
into one that didn't, which is exactly what is tested for there.

This patch restores the calls to ix86_default_align and
ix86_recompute_optlev_based_flags that used to be, and ought to be,
issued during TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE, but preserves the
intent of the original change, of having those functions called at
different spots within ix86_option_override_internal.  To that end,
the remaining bits were refactored into a separate function, that was
in turn adjusted to operate on explicitly-passed opts and opts_set,
rather than going for their global counterparts.


for  gcc/ChangeLog

	PR target/113719
	* config/i386/i386-options.cc
	(ix86_override_options_after_change_1): Add opts and opts_set
	parms, operate on them, after factoring out of...
	(ix86_override_options_after_change): ... this.  Restore calls
	of ix86_default_align and ix86_recompute_optlev_based_flags.
	(ix86_option_override_internal): Call the factored-out bits.

(cherry picked from commit bf2fc0a27b)
2024-07-16 06:27:06 -03:00
H.J. Lu 1fff665a51 x86: Update branch hint for Redwood Cove.
According to Intel® 64 and IA-32 Architectures Optimization Reference
Manual[1], Branch Hint is updated for Redwood Cove.

--------cut from [1]-------------------------
Starting with the Redwood Cove microarchitecture, if the predictor has
no stored information about a branch, the branch has the Intel® SSE2
branch taken hint (i.e., instruction prefix 3EH), When the codec
decodes the branch, it flips the branch’s prediction from not-taken to
taken. It then flushes the pipeline in front of it and steers this
pipeline to fetch the taken path of the branch.
--------cut end -----------------------------

Split tune branch_prediction_hints into branch_prediction_hints_taken
and branch_prediction_hints_not_taken, always generate branch hint for
conditional branches, both tunes are disabled by default.

[1] https://www.intel.com/content/www/us/en/content-details/821612/intel-64-and-ia-32-architectures-optimization-reference-manual-volume-1.html

gcc/

	* config/i386/i386.cc (ix86_print_operand): Always generate
	branch hint for conditional branches.
	* config/i386/i386.h (TARGET_BRANCH_PREDICTION_HINTS): Split
	into ..
	(TARGET_BRANCH_PREDICTION_HINTS_TAKEN): .. this, and ..
	(TARGET_BRANCH_PREDICTION_HINTS_NOT_TAKEN): .. this.
	* config/i386/x86-tune.def (X86_TUNE_BRANCH_PREDICTION_HINTS):
	Split into ..
	(X86_TUNE_BRANCH_PREDICTION_HINTS_TAKEN): .. this, and ..
	(X86_TUNE_BRANCH_PREDICTION_HINTS_NOT_TAKEN): .. this.

(cherry picked from commit a910c30c7c)
2024-07-16 09:28:08 +08:00
GCC Administrator 0fcadb3d51 Daily bump. 2024-07-16 00:26:23 +00:00
Harald Anlauf 71ec9ed7a7 Fortran: improve attribute conflict checking [PR93635]
gcc/fortran/ChangeLog:

	PR fortran/93635
	* symbol.cc (conflict_std): Helper function for reporting attribute
	conflicts depending on the Fortran standard version.
	(conf_std): Helper macro for checking standard-dependent conflicts.
	(gfc_check_conflict): Use it.

gcc/testsuite/ChangeLog:

	PR fortran/93635
	* gfortran.dg/c-interop/c1255-2.f90: Adjust pattern.
	* gfortran.dg/pr87907.f90: Likewise.
	* gfortran.dg/pr93635.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 9561cf550a)
2024-07-15 20:41:43 +02:00
liuhongt 13bfc385b0 Fix SSA_NAME leak due to def_stmt is removed before use_stmt.
-  _5 = __atomic_fetch_or_8 (&set_work_pending_p, 1, 0);
-  # DEBUG old => (long int) _5
+  _6 = .ATOMIC_BIT_TEST_AND_SET (&set_work_pending_p, 0, 1, 0, __atomic_fetch_or_8);
+  # DEBUG old => NULL
   # DEBUG BEGIN_STMT
-  # DEBUG D#2 => _5 & 1
+  # DEBUG D#2 => NULL
...
-  _10 = ~_5;
-  _8 = (_Bool) _10;
-  # DEBUG ret => _8
+  _8 = _6 == 0;
+  # DEBUG ret => (_Bool) _10

confirmed.  convert_atomic_bit_not does this, it checks for single_use
and removes the def, failing to release the name (which would fix this up
IIRC).

Note the function removes stmts in "wrong" order (before uses of LHS
are removed), so it requires larger surgery.  And it leaks SSA names.

gcc/ChangeLog:

	PR target/115872
	* tree-ssa-ccp.cc (convert_atomic_bit_not): Remove use_stmt after use_nop_stmt is removed.
	(optimize_atomic_bit_test_and): Ditto.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit a8209237dc46dc4db7d9d8e3807e6c93734c64b5)
2024-07-15 14:19:57 +08:00
GCC Administrator 53dd1ced62 Daily bump. 2024-07-15 00:24:06 +00:00
Mikael Morin c80a746023 fortran: Assume there is no cyclic reference with submodule symbols [PR99798]
This prevents a premature release of memory with procedure symbols from
submodules, causing random compiler crashes.

The problem is a fragile detection of cyclic references, which can match
with procedures host-associated from a module in submodules, in cases where it
shouldn't.  The formal namespace is released, and with it the dummy arguments
symbols of the procedure.  But there is no cyclic reference, so the procedure
symbol itself is not released and remains, with pointers to its dummy arguments
now dangling.

The fix adds a condition to avoid the case, and refactors to a new predicate
by the way.  Part of the original condition is also removed, for lack of a
reason to keep it.

	PR fortran/99798

gcc/fortran/ChangeLog:

	* symbol.cc (gfc_release_symbol): Move the condition guarding
	the handling cyclic references...
	(cyclic_reference_break_needed): ... here as a new predicate.
	Remove superfluous parts.  Add a condition preventing any premature
	release with submodule symbols.

gcc/testsuite/ChangeLog:

	* gfortran.dg/submodule_33.f08: New test.

(cherry picked from commit 38d1761c0c)
2024-07-14 20:31:20 +02:00
Mikael Morin 55988c48ea fortran: Correctly evaluate scalar MASK arguments of MINLOC/MAXLOC
Add the preliminary code that the generated expression for MASK may depend
on when generating the inline code to evaluate MINLOC or MAXLOC with a
scalar MASK.

The generated code was only keeping the generated expression but not the
preliminary code, which was sufficient for simple cases such as data
references or simple (scalar) function calls, but was bogus with more
complicated ones.

gcc/fortran/ChangeLog:

	* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Add the
	preliminary code generated for MASK to the preliminary code of
	MINLOC/MAXLOC.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit d211100903)
2024-07-14 19:30:33 +02:00
GCC Administrator 81972649bd Daily bump. 2024-07-14 00:24:37 +00:00
Lulu Cheng 89f9342980 LoongArch: TFmode is not allowed to be stored in the float register.
PR target/115752

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_hard_regno_mode_ok_uncached): Replace
	UNITS_PER_FPVALUE with UNITS_PER_HWFPVALUE.
	* config/loongarch/loongarch.h (UNITS_PER_FPVALUE): Delete.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/pr115752.c: New test.

(cherry picked from commit abeb6c8a62)
2024-07-13 14:06:13 +08:00
Stefan Schulze Frielinghaus 5ade7afdef s390: Fix output template for movv1qi
Although for instructions MVI and MVIY it does not make a difference
whether the immediate is interpreted as signed or unsigned, GAS expects
unsigned immediates for instruction format SI_URD.

gcc/ChangeLog:

	* config/s390/vector.md (mov<mode>): Fix output template for
	movv1qi.

(cherry picked from commit e6680d3f39)
2024-07-13 08:01:59 +02:00
Stefan Schulze Frielinghaus cd11413ff7 s390: Align *cjump_64 and *icjump_64
During machine reorg we optimize backward jumps and transform insns as
e.g.

(jump_insn 118 117 119 (set (pc)
        (if_then_else (ne (reg:CCRAW 33 %cc)
                (const_int 8 [0x8]))
            (label_ref 134)
            (pc))) "dec_math_1.f90":204:8 discrim 1 2161 {*cjump_64}
     (expr_list:REG_DEAD (reg:CCRAW 33 %cc)
        (int_list:REG_BR_PROB 719407028 (nil)))
 -> 134)

into

(jump_insn 118 117 432 (set (pc)
        (if_then_else (ne (reg:CCRAW 33 %cc)
                (const_int 8 [0x8]))
            (pc)
            (label_ref 433))) "dec_math_1.f90":204:8 discrim 1 -1
     (expr_list:REG_DEAD (reg:CCRAW 33 %cc)
        (int_list:REG_BR_PROB 719407028 (nil)))
 -> 433)

The latter is not recognized anymore since *icjump_64 only matches
CC_REGNUM against zero.  Fixed by aligning *cjump_64 and *icjump_64.

gcc/ChangeLog:

	* config/s390/s390.md (*icjump_64): Allow raw CC comparisons,
	i.e., any constant integer between 0 and 15 for CC comparisons.

(cherry picked from commit 56de68aba6)
2024-07-13 08:01:51 +02:00
GCC Administrator 3cba6fb80e Daily bump. 2024-07-13 00:23:54 +00:00
Jonathan Wakely d920658cbb libstdc++: Fix unwanted #pragma messages from PSTL headers [PR113376]
When we rebased the PSTL on upstream, in r14-2109-g3162ca09dbdc2e, a
change to how _PSTL_USAGE_WARNINGS is set was missed out, but the change
to how it's tested was included. This means that the macro is always
defined, so testing it with #ifdef (instead of using #if to test its
value) doesn't work as intended.

Revert the test to use #if again, since that part of the upstream change
was unnecessary in the first place (the macro is always defined, so
there's no need to use #ifdef to avoid -Wundef warnings).

libstdc++-v3/ChangeLog:

	PR libstdc++/113376
	* include/pstl/pstl_config.h: Use #if instead of #ifdef to test
	the _PSTL_USAGE_WARNINGS macro.

(cherry picked from commit 99a1fe6c12)
2024-07-12 11:12:27 +01:00
Jonathan Wakely 21c8708ba6 libstdc++: Fix std::to_array for trivial-ish types [PR115522]
Due to PR c++/85723 the std::is_trivial trait is true for types with a
deleted default constructor, so the use of std::is_trivial in
std::to_array is not sufficient to ensure the type can be trivially
default constructed then filled using memcpy.

I also forgot that a type with a deleted assignment operator can still
be trivial, so we also need to check that it's assignable because the
is_constant_evaluated() path can't use memcpy.

Replace the uses of std::is_trivial with std::is_trivially_copyable
(needed for memcpy), std::is_trivially_default_constructible (needed so
that the default construction is valid and does no work) and
std::is_copy_assignable (needed for the constant evaluation case).

libstdc++-v3/ChangeLog:

	PR libstdc++/115522
	* include/std/array (to_array): Workaround the fact that
	std::is_trivial is not sufficient to check that a type is
	trivially default constructible and assignable.
	* testsuite/23_containers/array/creation/115522.cc: New test.

(cherry picked from commit 510ce5eed6)
2024-07-12 11:12:27 +01:00
YunQiang Su cff270707f RISC-V: NO_WARNING preferred else value for RVV
PR target/115840.

In riscv_preferred_else_value, we create an uninitialized tmp var
for else value, instead of the 0 (as default_preferred_else_value)
or the pre-exists VAR (as aarch64 does), so that we can use agnostic
policy.

The problem is that `warn_uninit` will emit a warning:
  '({anonymous})' may be used uninitialized

Let's mark this tmp var as NO_WARNING.

This problem is found when I try to build glibc with V extension.

gcc

	PR target/115840
	* config/riscv/riscv.cc(riscv_preferred_else_value): Mark
	tmp_var as NO_WARNING.

gcc/testsuite
	* gcc.dg/vect/pr115840.c: New testcase.

(cherry picked from commit c6f38e5e6d)
2024-07-12 17:31:18 +08:00
Paul Thomas 29b2e1cdb6 Fortran: Fix ICEs due to comp calls in initialization exprs [PR103312]
2024-05-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/103312
	* dependency.cc (gfc_dep_compare_expr): Handle component call
	expressions. Return -2 as default and return 0 if compared with
	a function expression that is from an interface body and has
	the same name.
	* expr.cc (gfc_reduce_init_expr): If the expression is a comp
	call do not attempt to reduce, defer to resolution and return
	false.
	* trans-types.cc (gfc_get_dtype_rank_type,
	gfc_get_nodesc_array_type): Fix whitespace.

gcc/testsuite/
	PR fortran/103312
	* gfortran.dg/pr103312.f90: New test.

(cherry picked from commit 2ce90517ed)
2024-07-12 07:34:16 +01:00
GCC Administrator d096ff3715 Daily bump. 2024-07-12 00:26:24 +00:00
Andre Vieira b7a16ad1df mve: Fix vsetq_lane for 64-bit elements with lane 1 [PR 115611]
This patch fixes the backend pattern that was printing the wrong input
scalar register pair when inserting into lane 1.

Added a new test to force float-abi=hard so we can use scan-assembler to check
correct codegen.

gcc/ChangeLog:

	PR target/115611
	* config/arm/mve.md (mve_vec_setv2di_internal): Fix printing of input
	scalar register pair when lane = 1.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/intrinsics/vsetq_lane_su64.c: New test.

(cherry picked from commit 7c11fdd2cc)
2024-07-11 18:02:30 +01:00
Nathaniel Shead 08c2abffe0 c++/modules: Keep entity mapping info across duplicate_decls [PR99241]
When duplicate_decls finds a match with an existing imported
declaration, it clears DECL_LANG_SPECIFIC of the olddecl and replaces it
with the contents of newdecl; this clears DECL_MODULE_ENTITY_P causing
an ICE if the same declaration is imported again later.

This fixes the issue by ensuring that the flag is transferred to newdecl
before clearing so that it ends up on olddecl again.

For future-proofing we also do the same with DECL_MODULE_KEYED_DECLS_P,
though because we don't yet support textual redefinition merging we
can't yet test this works as intended.  I don't expect it's possible for
a new declaration already to have extra keyed decls mismatching that of
the old declaration though, so I don't do anything with 'keyed_map' at
this time.

	PR c++/99241

gcc/cp/ChangeLog:

	* decl.cc (duplicate_decls): Merge module entity information.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr99241_a.H: New test.
	* g++.dg/modules/pr99241_b.H: New test.
	* g++.dg/modules/pr99241_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit f04f9714fc)
2024-07-11 21:11:30 +10:00
GCC Administrator ddea107322 Daily bump. 2024-07-11 00:23:02 +00:00
Torbjörn SVENSSON e7d81cf551 testsuite: Align testcase with implementation [PR105090]
Since r13-1006-g2005b9b888eeac, the test case copysign_softfloat_1.c
no longer contains any lsr istruction, so drop the check as per
comment 9 in PR105090.

gcc/testsuite/ChangeLog:

	PR target/105090
	* gcc.target/arm/copysign_softfloat_1.c: Drop check for lsr

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 4865a92b35)
2024-07-10 18:56:23 +02:00
Uros Bizjak 47a8b464d2 middle-end: Fix stalled swapped condition code value [PR115836]
emit_store_flag_1 calculates scode (swapped condition code) at the
beginning of the function from the value of code variable.  However,
code variable may change before scode usage site, resulting in
invalid stalled scode value.

Move calculation of scode value just before its only usage site to
avoid stalled scode value.

	PR middle-end/115836

gcc/ChangeLog:

	* expmed.cc (emit_store_flag_1): Move calculation of
	scode just before its only usage site.

(cherry picked from commit 44933fdeb3)
2024-07-10 15:13:26 +02:00
Fei Gao efa30f6193 RISC-V: backport fix zcmp popretz [PR113715]
Root cause:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b27d323a368033f0b37e93c57a57a35fd9997864
Commit above tries in targetm.gen_epilogue () to detect if
there's li a0,0 insn at the end of insn chain, if so, cm.popret
is replaced by cm.popretz and li a0,0 insn is deleted.

Insertion of the generated epilogue sequence
into the insn chain doesn't happen at this moment.
If later shrink-wrap decides NOT to insert the epilogue sequence at the end
of insn chain, then the li a0,0 insn has already been mistakeny removed.

Fix this issue by removing generation of cm.popretz in epilogue,
leaving the assignment to a0 and use insn with cm.popret.

That's likely going to result in some kind of code size regression,
but not a correctness regression.

Optimization can be done in future.

Signed-off-by: Fei Gao <gaofei@eswincomputing.com>

gcc/ChangeLog:
	PR target/113715

	* config/riscv/riscv.cc (riscv_zcmp_can_use_popretz): Removed.
	(riscv_gen_multi_pop_insn): Remove generation of cm.popretz.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rv32e_zcmp.c: Adapt TC.
	* gcc.target/riscv/rv32i_zcmp.c: Likewise.
2024-07-10 02:08:54 +00:00
GCC Administrator 76b4721734 Daily bump. 2024-07-10 00:23:33 +00:00
Jonathan Wakely c94c8ff5f5 libstdc++: Fix _Atomic(T) macro in <stdatomic.h> [PR115807]
The definition of the _Atomic(T) macro needs to refer to ::std::atomic,
not some other std::atomic relative to the current namespace.

libstdc++-v3/ChangeLog:

	PR libstdc++/115807
	* include/c_compatibility/stdatomic.h (_Atomic): Ensure it
	refers to std::atomic in the global namespace.
	* testsuite/29_atomics/headers/stdatomic.h/115807.cc: New test.

(cherry picked from commit 40d234dd64)
2024-07-09 19:59:21 +01:00
Jonathan Wakely 85a39a8aaf libstdc++: Define __glibcxx_assert_fail for non-verbose build [PR115585]
When the library is configured with --disable-libstdcxx-verbose the
assertions just abort instead of calling __glibcxx_assert_fail, and so I
didn't export that function for the non-verbose build. However, that
option is documented to not change the library ABI, so we still need to
export the symbol from the library. It could be needed by programs
compiled against the headers from a verbose build.

The non-verbose definition can just call abort so that it doesn't pull
in I/O symbols, which are unwanted in a non-verbose build.

libstdc++-v3/ChangeLog:

	PR libstdc++/115585
	* src/c++11/assert_fail.cc (__glibcxx_assert_fail): Add
	definition for non-verbose builds.

(cherry picked from commit 52370c839e)
2024-07-09 19:59:21 +01:00
Alfie Richards 72753ec820 Aarch64, bugfix: Fix NEON bigendian addp intrinsic [PR114890]
This change removes code that switches the operands in bigendian mode erroneously.
This fixes the related test also.

gcc/ChangeLog:

	PR target/114890
	* config/aarch64/aarch64-simd.md: Remove bigendian operand swap.

gcc/testsuite/ChangeLog:

	PR target/114890
	* gcc.target/aarch64/vector_intrinsics_asm.c: Remove xfail.

(cherry picked from commit 11049cdf20)
2024-07-09 12:39:39 +01:00
Wilco Dijkstra 83332e3f80 Arm: Fix ldrd offset range [PR115153]
The valid offset range of LDRD in arm_legitimate_index_p is increased to
-1024..1020 if NEON is enabled since VALID_NEON_DREG_MODE includes DImode.
Fix this by moving the LDRD check earlier.

gcc:
	PR target/115153
	* config/arm/arm.cc (arm_legitimate_index_p): Move LDRD case before
	NEON.
	(thumb2_legitimate_index_p): Update comments.
	(output_move_neon): Use DFmode for vldr/vstr and non-checking
	adjust_address.

gcc/testsuite:
	PR target/115153
	* gcc.target/arm/pr115153.c: Add new test.
	* lib/target-supports.exp: Add arm_arch_v7ve_neon target support.

(cherry picked from commit 44e5ecfd26)
2024-07-09 12:39:02 +01:00
Haochen Jiang 74c15cb93b i386: Correct AVX10 CPUID emulation
AVX10 Documentaion has specified ecx value as 0 for AVX10 version and
vector size under 0x24 subleaf. Although for ecx=1, the bits are all
reserved for now, we still need to specify ecx as 0 to avoid dirty
value in ecx.

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_available_features): Correct
	AVX10 CPUID emulation to specify ecx value.
2024-07-09 16:51:42 +08:00
Pan Li 505382ceee RISC-V: Bugfix vfmv insn honor zvfhmin for FP16 SEW [PR115763]
According to the ISA,  the zvfhmin sub extension should only contain
convertion insn.  Thus,  the vfmv insn acts on FP16 should not be
present when only the zvfhmin option is given.

This patch would like to fix it by split the pred_broadcast define_insn
into zvfhmin and zvfh part.  Given below example:

void test (_Float16 *dest, _Float16 bias) {
  dest[0] = bias;
  dest[1] = bias;
}

when compile with -march=rv64gcv_zfh_zvfhmin

Before this patch:
test:
  vsetivli        zero,2,e16,mf4,ta,ma
  vfmv.v.f        v1,fa0 // should not leverage vfmv for zvfhmin
  vse16.v v1,0(a0)
  ret

After this patch:
test:
  addi     sp,sp,-16
  fsh      fa0,14(sp)
  addi     a5,sp,14
  vsetivli zero,2,e16,mf4,ta,ma
  vlse16.v v1,0(a5),zero
  vse16.v  v1,0(a0)
  addi     sp,sp,16
  jr       ra

	PR target/115763

gcc/ChangeLog:

	* config/riscv/vector.md (*pred_broadcast<mode>): Split into
	zvfh and zvfhmin part.
	(*pred_broadcast<mode>_zvfh): New define_insn for zvfh part.
	(*pred_broadcast<mode>_zvfhmin): Ditto but for zvfhmin.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/scalar_move-5.c: Adjust asm check.
	* gcc.target/riscv/rvv/base/scalar_move-6.c: Ditto.
	* gcc.target/riscv/rvv/base/scalar_move-7.c: Ditto.
	* gcc.target/riscv/rvv/base/scalar_move-8.c: Ditto.
	* gcc.target/riscv/rvv/base/pr115763-1.c: New test.
	* gcc.target/riscv/rvv/base/pr115763-2.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit de9254e224)
2024-07-09 13:31:32 +08:00
GCC Administrator 9d47a436f8 Daily bump. 2024-07-09 00:23:42 +00:00
Richard Biener 64a6c0d594 tree-optimization/115723 - ICE with .COND_ADD reduction
The following fixes an ICE with a .COND_ADD discovered as reduction
even though its else value isn't the reduction chain link but a
constant.  This would be wrong-code with --disable-checking I think.

	PR tree-optimization/115723
	* tree-vect-loop.cc (check_reduction_path): For a .COND_ADD
	verify the else value also refers to the reduction chain op.

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

(cherry picked from commit 286cda3461)
2024-07-08 10:52:07 +02:00
Richard Biener cde411950e tree-optimization/115694 - ICE with complex store rewrite
The following adds a missed check when forwprop attempts to rewrite
a complex store.

	PR tree-optimization/115694
	* tree-ssa-forwprop.cc (pass_forwprop::execute): Check the
	store is complex before rewriting it.

	* g++.dg/torture/pr115694.C: New testcase.

(cherry picked from commit 543a5b9da9)
2024-07-08 10:51:27 +02:00
Richard Biener 03844a2a15 tree-optimization/115669 - fix SLP reduction association
The following avoids associating a reduction path as that might
get STMT_VINFO_REDUC_IDX out-of-sync with the SLP operand order.
This is a latent issue with SLP reductions but now easily exposed
as we're doing single-lane SLP reductions.

When we achieved SLP only we can move and update this meta-data.

	PR tree-optimization/115669
	* tree-vect-slp.cc (vect_build_slp_tree_2): Do not reassociate
	chains that participate in a reduction.

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

(cherry picked from commit 7886830bb4)
2024-07-08 10:51:05 +02:00
Richard Biener 078cdccc84 tree-optimization/115646 - ICE with pow shrink-wrapping from bitfield
The following makes analysis and transform agree on constraints.

	PR tree-optimization/115646
	* tree-call-cdce.cc (check_pow): Check for bit_sz values
	as allowed by transform.

	* gcc.dg/pr115646.c: New testcase.

(cherry picked from commit 453b1d291d)
2024-07-08 10:50:45 +02:00
Paul Thomas c36acfea1a Fortran: Unlimited polymorphic intrinsic function arguments [PR84006]
2024-05-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/84006
	PR fortran/100027
	PR fortran/98534
	* iresolve.cc (gfc_resolve_transfer): Emit a TODO error for
	unlimited polymorphic mold.
	* trans-expr.cc (gfc_resize_class_size_with_len): Use the fold
	even if a block is not available in which to fix the result.
	(trans_class_assignment): Enable correct assignment of
	character expressions to unlimited polymorphic variables using
	lhs _len field and rse string_length.
	* trans-intrinsic.cc (gfc_conv_intrinsic_storage_size): Extract
	the class expression so that the unlimited polymorphic class
	expression can be used in gfc_resize_class_size_with_len to
	obtain the storage size for character payloads. Guard the use
	of GFC_DECL_SAVED_DESCRIPTOR by testing for DECL_LANG_SPECIFIC
	to prevent the ICE. Also, invert the order to use the class
	expression extracted from the argument.
	(gfc_conv_intrinsic_transfer): In same way as 'storage_size',
	use the _len field to obtaining the correct length for arg 1.
	Add a branch for the element size in bytes of class expressions
	with provision to make use of the unlimited polymorphic _len
	field. Again, the class references are explicitly identified.
	'mold_expr' was already declared. Use it instead of 'arg'. Do
	not fix 'dest_word_len' for deferred character sources because
	reallocation on assign makes use of it before it is assigned.

gcc/testsuite/
	PR fortran/84006
	PR fortran/100027
	* gfortran.dg/storage_size_7.f90: New test.

	PR fortran/98534
	* gfortran.dg/transfer_class_4.f90: New test.

(cherry picked from commit b9294757f8)
2024-07-08 06:56:09 +01:00
Pali Rohár a8617b5ec3 Fix MinGW option -mcrtdll=
Add missing msvcr40* and msvcrtd* cases to CPP_SPEC and
document missing _UCRT macro and msvcr71* case.

Fixes commit 453cb585f0.

gcc/
	* config/i386/mingw-w64.h (CPP_SPEC): Add missing -mcrtdll=
	cases: msvcr40*, msvcrtd*.
	* config/i386/mingw32.h (CPP_SPEC): Add missing -mcrtdll=
	cases: msvcr40*, msvcrtd*.
	* doc/invoke.texi: Add missing -mcrtdll= cases: msvcr40*,
	msvcrtd*, msvcr71*. Express wildcards with *. Document _UCRT.

(cherry picked from commit 0de0476e47)
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2024-07-08 02:45:54 +00:00
GCC Administrator a927d33557 Daily bump. 2024-07-08 00:22:29 +00:00
Harald Anlauf 36ca07f0a9 Fortran: fix associate with assumed-length character array [PR115700]
gcc/fortran/ChangeLog:

	PR fortran/115700
	* trans-stmt.cc (trans_associate_var): When the associate target
	is an array-valued character variable, the length is known at entry
	of the associate block.  Move setting of string length of the
	selector to the initialization part of the block.

gcc/testsuite/ChangeLog:

	PR fortran/115700
	* gfortran.dg/associate_69.f90: New test.

(cherry picked from commit 7b7f203472)
2024-07-07 20:33:03 +02:00
GCC Administrator 3ab45a16c8 Daily bump. 2024-07-07 00:22:21 +00:00
Eric Botcazou 6c5ef4944e RISC-V: fix internal error on global variable-length array
This is an ICE in the RISC-V back-end calling tree_to_uhwi on the DECL_SIZE
of a global variable-length array.

gcc/
	PR target/115591
	* config/riscv/riscv.cc (riscv_valid_lo_sum_p): Add missing test on
	tree_fits_uhwi_p before calling tree_to_uhwi.

gcc/testsuite/
	* gnat.dg/array41.ads, gnat.dg/array41.adb: New test.
2024-07-06 17:19:02 +02:00
GCC Administrator 7124ad8642 Daily bump. 2024-07-06 00:22:54 +00:00
Wilco Dijkstra 100d353e54 Arm: Fix disassembly error in Thumb-1 relaxed load/store [PR115188]
A Thumb-1 memory operand allows single-register LDMIA/STMIA. This doesn't get
printed as LDR/STR with writeback in unified syntax, resulting in strange
assembler errors if writeback is selected.  To work around this, use the 'Uw'
constraint that blocks writeback.  Also use a new 'mem_and_no_t1_wback_op'
which is a general memory operand that disallows writeback in Thumb-1.
A few other patterns were using 'm' for Thumb-1 in a similar way, update these
to also use 'mem_and_no_t1_wback_op' and 'Uw'.

gcc:
	PR target/115188
	* config/arm/arm.md (unaligned_loadsi): Use 'Uw' constraint and
	'mem_and_no_t1_wback_op'.
	(unaligned_loadhiu): Likewise.
	(unaligned_storesi): Likewise.
	(unaligned_storehi): Likewise.
	* config/arm/predicates.md (mem_and_no_t1_wback_op): Add new predicate.
	* config/arm/sync.md (arm_atomic_load<mode>): Use 'Uw' constraint.
	(arm_atomic_store<mode>): Likewise.

gcc/testsuite:
	PR target/115188
	* gcc.target/arm/pr115188.c: Add new test.

(cherry picked from commit d04c5537f5)
2024-07-05 13:03:35 +01:00
Georg-Johann Lay 9f5620aed3 AVR: target/87376 - Use nop_general_operand for DImode inputs.
The avr-dimode.md expanders have code like  emit_move_insn(acc_a, operands[1])
where acc_a is a hard register and operands[1] might be a non-generic
address-space memory reference.  Such loads may clobber hard regs since
some of them are implemented as libgcc calls /and/ 64-moves are
expanded as eight byte-moves, so that acc_a or acc_b might be clobbered
by such a load.

This patch simply denies non-generic address-space references by using
nop_general_operand for all avr-dimode.md input predicates.
With the patch, all memory loads that require library calls are issued
before the expander codes from avr-dimode.md are run.

	PR target/87376
gcc/
	* config/avr/avr-dimode.md: Use "nop_general_operand" instead
	of "general_operand" as predicate for all input operands.

gcc/testsuite/
	* gcc.target/avr/torture/pr87376.c: New test.

(cherry picked from commit 23a0935262)
2024-07-05 13:38:44 +02:00
GCC Administrator a633e41364 Daily bump. 2024-07-05 00:22:58 +00:00
Kyrylo Tkachov dc63b5dbe6 aarch64: PR target/115475 Implement missing __ARM_FEATURE_SVE_BF16 macro
The ACLE requires __ARM_FEATURE_SVE_BF16 to be enabled when SVE and BF16
and the associated intrinsics are available.
GCC does support the required intrinsics for TARGET_SVE_BF16 so define
this macro too.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/

	PR target/115475
	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
	Define __ARM_FEATURE_SVE_BF16 for TARGET_SVE_BF16.

gcc/testsuite/

	PR target/115475
	* gcc.target/aarch64/acle/bf16_sve_feature.c: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
(cherry picked from commit 6492c7130d)
2024-07-04 16:56:03 +05:30
Kyrylo Tkachov 1a97c8ed42 aarch64: PR target/115457 Implement missing __ARM_FEATURE_BF16 macro
The ACLE asks the user to test for __ARM_FEATURE_BF16 before using the
<arm_bf16.h> header but GCC doesn't set this up.
LLVM does, so this is an inconsistency between the compilers.

This patch enables that macro for TARGET_BF16_FP.
Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/

	PR target/115457
	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
	Define __ARM_FEATURE_BF16 for TARGET_BF16_FP.

gcc/testsuite/

	PR target/115457
	* gcc.target/aarch64/acle/bf16_feature.c: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
(cherry picked from commit c10942134f)
2024-07-04 16:56:03 +05:30
Tamar Christina 1742b699c3 c++ frontend: check for missing condition for novector [PR115623]
It looks like I forgot to check in the C++ frontend if a condition exist for the
loop being adorned with novector.  This causes a segfault because cond isn't
expected to be null.

This fixes it by issuing ignoring the pragma when there's no loop condition
the same way we do in the C frontend.

gcc/cp/ChangeLog:

	PR c++/115623
	* semantics.cc (finish_for_cond): Add check for C++ cond.

gcc/testsuite/ChangeLog:

	PR c++/115623
	* g++.dg/vect/vect-novector-pragma_2.cc: New test.

(cherry picked from commit 84acbfbecb)
2024-07-04 11:03:52 +01:00
GCC Administrator 0f71e52717 Daily bump. 2024-07-04 00:24:34 +00:00
John David Anglin 6e1fb1f9db Revert "Delete MALLOC_ABI_ALIGNMENT define from pa32-linux.h"
This reverts commit 0ee3266b3d.
2024-07-03 14:36:26 -04:00
John David Anglin acde9f81da hppa: Fix ICE caused by mismatched predicate and constraint in xmpyu patterns
2024-06-30  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	PR target/115691
	* config/pa/pa.md: Remove incorrect xmpyu patterns.
2024-07-03 14:30:39 -04:00
Lewis Hyatt 3389a23fd4 preprocessor: Create the parser before handling command-line includes [PR115312]
Since r14-2893, we create a parser object in preprocess-only mode for the
purpose of parsing #pragma while preprocessing. The parser object was
formerly created after calling c_finish_options(), which leads to problems
on platforms that don't use stdc-predef.h (such as MinGW, as reported in
the PR). On such platforms, the call to c_finish_options() will process
the first command-line-specified include file. If that includes a PCH, then
c-ppoutput.cc will encounter a state it did not anticipate. Fix it by
creating the parser prior to calling c_finish_options().

gcc/c-family/ChangeLog:

	PR pch/115312
	* c-opts.cc (c_common_init): Call c_init_preprocess() before
	c_finish_options() so that a parser is available to process any
	includes specified on the command line.

gcc/testsuite/ChangeLog:

	PR pch/115312
	* g++.dg/pch/pr115312.C: New test.
	* g++.dg/pch/pr115312.Hs: New test.
2024-07-03 07:12:04 -04:00
Georg-Johann Lay 55744507ab AVR: target/98762 - Handle partial clobber in movqi output.
PR target/98762
gcc/
	* config/avr/avr.cc (avr_out_movqi_r_mr_reg_disp_tiny): Properly
	restore the base register when it is partially clobbered.
gcc/testsuite/
	* gcc.target/avr/torture/pr98762.c: New test.

(cherry picked from commit e9fb6efa1c)
2024-07-03 10:35:37 +02:00
Kewen LinandXionghu Luo 052f78d010 rs6000: Fix wrong RTL patterns for vector merge high/low short on LE
Commit r12-4496 changes some define_expands and define_insns
for vector merge high/low short, which are altivec_vmrg[hl]h.
These defines are mainly for built-in function vec_merge{h,l}
and some internal gen function needs.  These functions should
consider endianness, taking vec_mergeh as example, as PVIPR
defines, vec_mergeh "Merges the first halves (in element order)
of two vectors", it does note it's in element order.  So it's
mapped into vmrghh on BE while vmrglh on LE respectively.
Although the mapped insns are different, as the discussion in
PR106069, the RTL pattern should be still the same, it is
conformed before commit r12-4496, but gets changed into
different patterns on BE and LE starting from commit r12-4496.
Similar to 32-bit element case in commit log of r15-1504, this
16-bit element pattern on LE doesn't actually match what the
underlying insn is intended to represent, once some optimization
like combine does some changes basing on it, it would cause
the unexpected consequence.  The newly constructed test case
pr106069-2.c is a typical example for this issue on element type
short.

So this patch is to fix the wrong RTL pattern, ensure the
associated RTL patterns become the same as before which can
have the same semantic as their mapped insns.  With the
proposed patch, the expanders like altivec_vmrghh expands
into altivec_vmrghh_direct_be or altivec_vmrglh_direct_le
depending on endianness, "direct" can easily show which
insn would be generated, _be and _le are mainly for the
different RTL patterns as endianness.

Co-authored-by: Xionghu Luo <xionghuluo@tencent.com>

	PR target/106069
	PR target/115355

gcc/ChangeLog:

	* config/rs6000/altivec.md (altivec_vmrghh_direct): Rename to ...
	(altivec_vmrghh_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrghh_direct_le): New define_insn.
	(altivec_vmrglh_direct): Rename to ...
	(altivec_vmrglh_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrglh_direct_le): New define_insn.
	(altivec_vmrghh): Adjust by calling gen_altivec_vmrghh_direct_be
	for BE and gen_altivec_vmrglh_direct_le for LE.
	(altivec_vmrglh): Adjust by calling gen_altivec_vmrglh_direct_be
	for BE and gen_altivec_vmrghh_direct_le for LE.
	(vec_widen_umult_hi_v16qi): Adjust the call to
	gen_altivec_vmrghh_direct by gen_altivec_vmrghh for BE
	and by gen_altivec_vmrglh for LE.
	(vec_widen_smult_hi_v16qi): Likewise.
	(vec_widen_umult_lo_v16qi): Adjust the call to
	gen_altivec_vmrglh_direct by gen_altivec_vmrglh for BE
	and by gen_altivec_vmrghh for LE.
	(vec_widen_smult_lo_v16qi): Likewise.
	* config/rs6000/rs6000.cc (altivec_expand_vec_perm_const): Replace
	CODE_FOR_altivec_vmrghh_direct by
	CODE_FOR_altivec_vmrghh_direct_be for BE and
	CODE_FOR_altivec_vmrghh_direct_le for LE.  And replace
	CODE_FOR_altivec_vmrglh_direct by
	CODE_FOR_altivec_vmrglh_direct_be for BE and
	CODE_FOR_altivec_vmrglh_direct_le for LE.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106069-2.c: New test.

(cherry picked from commit 812c70bf49)
2024-07-02 20:58:15 -05:00
Kewen LinandXionghu Luo 0e495e8e3f rs6000: Fix wrong RTL patterns for vector merge high/low char on LE
Commit r12-4496 changes some define_expands and define_insns
for vector merge high/low char, which are altivec_vmrg[hl]b.
These defines are mainly for built-in function vec_merge{h,l}
and some internal gen function needs.  These functions should
consider endianness, taking vec_mergeh as example, as PVIPR
defines, vec_mergeh "Merges the first halves (in element order)
of two vectors", it does note it's in element order.  So it's
mapped into vmrghb on BE while vmrglb on LE respectively.
Although the mapped insns are different, as the discussion in
PR106069, the RTL pattern should be still the same, it is
conformed before commit r12-4496, but gets changed into
different patterns on BE and LE starting from commit r12-4496.
Similar to 32-bit element case in commit log of r15-1504, this
8-bit element pattern on LE doesn't actually match what the
underlying insn is intended to represent, once some optimization
like combine does some changes basing on it, it would cause
the unexpected consequence.  The newly constructed test case
pr106069-1.c is a typical example for this issue.

So this patch is to fix the wrong RTL pattern, ensure the
associated RTL patterns become the same as before which can
have the same semantic as their mapped insns.  With the
proposed patch, the expanders like altivec_vmrghb expands
into altivec_vmrghb_direct_be or altivec_vmrglb_direct_le
depending on endianness, "direct" can easily show which
insn would be generated, _be and _le are mainly for the
different RTL patterns as endianness.

Co-authored-by: Xionghu Luo <xionghuluo@tencent.com>

	PR target/106069
	PR target/115355

gcc/ChangeLog:

	* config/rs6000/altivec.md (altivec_vmrghb_direct): Rename to ...
	(altivec_vmrghb_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrghb_direct_le): New define_insn.
	(altivec_vmrglb_direct): Rename to ...
	(altivec_vmrglb_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrglb_direct_le): New define_insn.
	(altivec_vmrghb): Adjust by calling gen_altivec_vmrghb_direct_be
	for BE and gen_altivec_vmrglb_direct_le for LE.
	(altivec_vmrglb): Adjust by calling gen_altivec_vmrglb_direct_be
	for BE and gen_altivec_vmrghb_direct_le for LE.
	* config/rs6000/rs6000.cc (altivec_expand_vec_perm_const): Replace
	CODE_FOR_altivec_vmrghb_direct by
	CODE_FOR_altivec_vmrghb_direct_be for BE and
	CODE_FOR_altivec_vmrghb_direct_le for LE.  And replace
	CODE_FOR_altivec_vmrglb_direct by
	CODE_FOR_altivec_vmrglb_direct_be for BE and
	CODE_FOR_altivec_vmrglb_direct_le for LE.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106069-1.c: New test.

(cherry picked from commit 62520e4e9f)
2024-07-02 20:57:47 -05:00
GCC Administrator 88bfbab8fb Daily bump. 2024-07-03 00:25:28 +00:00
Alex Coplan 8eb469546f aarch64: Fix typo in aarch64-ldp-fusion.cc:combine_reg_notes [PR114936]
This fixes a typo in combine_reg_notes in the load/store pair fusion
pass.  As it stands, the calls to filter_notes store any
REG_FRAME_RELATED_EXPR to fr_expr with the following association:

 - i2 -> fr_expr[0]
 - i1 -> fr_expr[1]

but then the checks inside the following if statement expect the
opposite (more natural) association, i.e.:

 - i2 -> fr_expr[1]
 - i1 -> fr_expr[0]

this patch fixes the oversight by swapping the fr_expr indices in the
calls to filter_notes.

In hindsight it would probably have been less confusing / error-prone to
have combine_reg_notes take an array of two insns, then we wouldn't have
to mix 1-based and 0-based indexing as well as remembering to call
filter_notes in reverse program order.  This however is a minimal fix
for backporting purposes.

gcc/ChangeLog:

	PR target/114936
	* config/aarch64/aarch64-ldp-fusion.cc (combine_reg_notes):
	Ensure insn iN has its REG_FRAME_RELATED_EXPR (if any) stored in
	FR_EXPR[N-1], thus matching the correspondence expected by the
	copy_rtx calls.

(cherry picked from commit 73c8e24b69)
2024-07-02 19:38:54 +01:00
GCC Administrator 5db1392e8e Daily bump. 2024-07-02 00:23:08 +00:00
Georg-Johann Lay 7249b3cdc1 AVR: target/88236, target/115726 - Fix __memx code generation.
PR target/88236
	PR target/115726
gcc/
	* config/avr/avr.md (mov<mode>) [avr_mem_memx_p]: Expand in such a
	way that the destination does not overlap with any hard register
	clobbered / used by xload8qi_A resp. xload<mode>_A.
	* config/avr/avr.cc (avr_out_xload): Avoid early-clobber
	situation for Z by executing just one load when the output register
	overlaps with Z.
gcc/testsuite/
	* gcc.target/avr/torture/pr88236-pr115726.c: New test.

(cherry picked from commit 3d23abd3dd)
2024-07-01 13:30:03 +02:00
Jakub Jelinek 37bbd2c166 c: Fix ICE related to incomplete structures in C23 [PR114930]
Here is a version of the c_update_type_canonical fixes which passed
bootstrap/regtest.
The non-trivial part is the handling of the case when
build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x))
returns a type with NULL TYPE_CANONICAL.  That should happen only
if TYPE_CANONICAL (t) == t, because otherwise c_update_type_canonical should
have been already called on the other type.  c, the returned type, is usually x
and in that case it should have TYPE_CANONICAL set to itself, or worst
for whatever reason x is not the right canonical type (say it has attributes
or whatever disqualifies it from check_qualified_type).  In that case
either it finds some pre-existing type from the variant chain of t which
is later in the chain and we haven't processed it yet (but then
get_qualified_type moves it right after t in:
        /* Put the found variant at the head of the variant list so
           frequently searched variants get found faster.  The C++ FE
           benefits greatly from this.  */
        tree t = *tp;
        *tp = TYPE_NEXT_VARIANT (t);
        TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (mv);
        TYPE_NEXT_VARIANT (mv) = t;
        return t;
optimization), or creates a fresh new type using build_variant_type_copy,
which again places the new type right after t:
  /* Add the new type to the chain of variants of TYPE.  */
  TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
  TYPE_NEXT_VARIANT (m) = t;
  TYPE_MAIN_VARIANT (t) = m;
At this point we want to make c its own canonical type (i.e. TYPE_CANONICAL
(c) = c;), but also need to process pointers to it and only then return back
to processing x.  Processing the whole chain from c again could be costly,
we could have hundreds of types in the chain already processed, and while
the loop would just quickly skip them
  for (tree x = t, l = NULL_TREE; x; l = x, x = TYPE_NEXT_VARIANT (x))
    {
      if (x != t && TYPE_STRUCTURAL_EQUALITY_P (x))
...
      else if (x != t)
        continue;
it feels costly.  So, this patch instead moves c from right after t
to right before x in the chain (that shouldn't change anything, because
clearly build_qualified_type didn't find any matches in the chain before
x) and continues processing the c at that position, so should handle the
x that encountered this in the next iteration.

We could avoid some of the moving in the chain if we processed the chain
twice, once deal only with x != t && TYPE_STRUCTURAL_EQUALITY_P (x)
&& TYPE_CANONICAL (t) == t && check_qualified_type (t, x, TYPE_QUALS (x))
types (in that case set TYPE_CANONICAL (x) = x) and once the rest.  There
is still the theoretical case where build_qualified_type would return
a new type and in that case we are back to the moving the type around and
needing to handle it though.

2024-06-25  Jakub Jelinek  <jakub@redhat.com>
	    Martin Uecker  <uecker@tugraz.at>

	PR c/114930
	PR c/115502
gcc/c/
	* c-decl.cc (c_update_type_canonical): Assert t is main variant
	with 0 TYPE_QUALS.  Simplify and don't use check_qualified_type.
	Deal with the case where build_qualified_type returns
	TYPE_STRUCTURAL_EQUALITY_P type.
gcc/testsuite/
	* gcc.dg/pr114574-1.c: Require lto effective target.
	* gcc.dg/pr114574-2.c: Likewise.
	* gcc.dg/pr114930.c: New test.
	* gcc.dg/pr115502.c: New test.

(cherry picked from commit 777cc6a01d)
2024-07-01 09:38:15 +02:00
GCC Administrator 78bd4b1c23 Daily bump. 2024-07-01 00:24:05 +00:00
Harald Anlauf 603b344c07 Fortran: fix ALLOCATE with SOURCE of deferred character length [PR114019]
gcc/fortran/ChangeLog:

	PR fortran/114019
	* trans-stmt.cc (gfc_trans_allocate): Fix handling of case of
	scalar character expression being used for SOURCE.

gcc/testsuite/ChangeLog:

	PR fortran/114019
	* gfortran.dg/allocate_with_source_33.f90: New test.

(cherry picked from commit 7682d11540)
2024-06-30 20:20:26 +02:00
Harald Anlauf 9f147487de Fortran: fix passing of optional dummy as actual to optional argument [PR55978]
gcc/fortran/ChangeLog:

	PR fortran/55978
	* trans-array.cc (gfc_conv_array_parameter): Do not dereference
	data component of a missing allocatable dummy array argument for
	passing as actual to optional dummy.  Harden logic of presence
	check for optional pointer dummy by using TRUTH_ANDIF_EXPR instead
	of TRUTH_AND_EXPR.

gcc/testsuite/ChangeLog:

	PR fortran/55978
	* gfortran.dg/optional_absent_12.f90: New test.

(cherry picked from commit f02c70dafd)
2024-06-30 20:20:26 +02:00
Harald Anlauf b31e1900fa Fortran: fix for CHARACTER(len=*) dummies with bind(C) [PR115390]
gcc/fortran/ChangeLog:

	PR fortran/115390
	* trans-decl.cc (gfc_conv_cfi_to_gfc): Move derivation of type sizes
	for character via gfc_trans_vla_type_sizes to after character length
	has been set.

gcc/testsuite/ChangeLog:

	PR fortran/115390
	* gfortran.dg/bind_c_char_11.f90: New test.

(cherry picked from commit 954f9011c4)
2024-06-30 20:20:26 +02:00
GCC Administrator 4fe3fff904 Daily bump. 2024-06-30 00:22:56 +00:00
GCC Administrator 47cbc76568 Daily bump. 2024-06-29 00:22:50 +00:00
Patrick Palka e6b115be1c c++: decltype of capture proxy of ref [PR115504]
The finish_decltype_type capture proxy handling added in r14-5330 was
incorrectly stripping references in the type of the captured variable.

	PR c++/115504

gcc/cp/ChangeLog:

	* semantics.cc (finish_decltype_type): Don't strip the reference
	type (if any) of a capture proxy's captured variable.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/decltype-auto8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 737449e5f2)
2024-06-28 15:43:52 -04:00
Patrick Palka a00a8d46ea c++: alias CTAD and copy deduction guide [PR115198]
Here we're neglecting to update DECL_NAME during the alias CTAD guide
transformation, which causes copy_guide_p to return false for the
transformed copy deduction guide since DECL_NAME is still __dguide_C
with TREE_TYPE C<B, T> but it should be __dguide_A with TREE_TYPE A<T>
(i.e. C<false, T>).  This ultimately results in ambiguity during
overload resolution between the copy deduction guide vs copy ctor guide.

This patch makes us update DECL_NAME of a transformed guide accordingly
during alias/inherited CTAD.

	PR c++/115198

gcc/cp/ChangeLog:

	* pt.cc (alias_ctad_tweaks): Update DECL_NAME of the transformed
	guides.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-alias22.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 06ebb7c6f3)
2024-06-28 15:43:52 -04:00
Patrick Palka 33a9c4dd5f c++: using non-dep array var of unknown bound [PR115358]
For a non-dependent array variable of unknown bound, it seems we need to
try instantiating its definition upon use in a template context for sake
of proper checking and typing of the overall expression, like we do for
function specializations with deduced return type.

	PR c++/115358

gcc/cp/ChangeLog:

	* decl2.cc (mark_used): Call maybe_instantiate_decl for an array
	variable with unknown bound.
	* semantics.cc (finish_decltype_type): Remove now redundant
	handling of array variables with unknown bound.
	* typeck.cc (cxx_sizeof_expr): Likewise.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit e3915c1ad5)
2024-06-28 15:43:52 -04:00
Jonathan Wakely d5e352addf libstdc++: Fix std::format for chrono::duration with unsigned rep [PR115668]
Using std::chrono::abs is only valid if numeric_limits<rep>::is_signed
is true, so using it unconditionally made it ill-formed to format a
duration with an unsigned rep.

The duration formatter might as well negate the duration itself instead
of using chrono::abs, because it already needs to check for a negative
value.

libstdc++-v3/ChangeLog:

	PR libstdc++/115668
	* include/bits/chrono_io.h (formatter<duration<R,P, C>::format):
	Do not use chrono::abs.
	* testsuite/20_util/duration/io.cc: Check formatting a duration
	with unsigned rep.

(cherry picked from commit dafa750c8a)
2024-06-28 10:44:00 +01:00
Kewen LinandXionghu Luo ef8b60dd48 rs6000: Fix wrong RTL patterns for vector merge high/low word on LE
Commit r12-4496 changes some define_expands and define_insns
for vector merge high/low word, which are altivec_vmrg[hl]w,
vsx_xxmrg[hl]w_<VSX_W:mode>.  These defines are mainly for
built-in function vec_merge{h,l}, __builtin_vsx_xxmrghw,
__builtin_vsx_xxmrghw_4si and some internal gen function
needs.  These functions should consider endianness, taking
vec_mergeh as example, as PVIPR defines, vec_mergeh "Merges
the first halves (in element order) of two vectors", it does
note it's in element order.  So it's mapped into vmrghw on
BE while vmrglw on LE respectively.  Although the mapped
insns are different, as the discussion in PR106069, the RTL
pattern should be still the same, it is conformed before
commit r12-4496, define_expand altivec_vmrghw got expanded
into:

  (vec_select:VSX_W
     (vec_concat:<VS_double>
        (match_operand:VSX_W 1 "register_operand" "wa,v")
        (match_operand:VSX_W 2 "register_operand" "wa,v"))
        (parallel [(const_int 0) (const_int 4)
                   (const_int 1) (const_int 5)])))]

on both BE and LE then.  But commit r12-4496 changed it to
expand into:

  (vec_select:VSX_W
     (vec_concat:<VS_double>
        (match_operand:VSX_W 1 "register_operand" "wa,v")
        (match_operand:VSX_W 2 "register_operand" "wa,v"))
        (parallel [(const_int 0) (const_int 4)
                   (const_int 1) (const_int 5)])))]

on BE, and

  (vec_select:VSX_W
     (vec_concat:<VS_double>
        (match_operand:VSX_W 1 "register_operand" "wa,v")
        (match_operand:VSX_W 2 "register_operand" "wa,v"))
        (parallel [(const_int 2) (const_int 6)
                   (const_int 3) (const_int 7)])))]

on LE, although the mapped insn are still vmrghw on BE and
vmrglw on LE, the associated RTL pattern is completely
wrong and inconsistent with the mapped insn.  If optimization
passes leave this pattern alone, even if its pattern doesn't
represent its mapped insn, it's still fine, that's why simple
testing on bif doesn't expose this issue.  But once some
optimization pass such as combine does some changes basing
on this wrong pattern, because the pattern doesn't match the
semantics that the expanded insn is intended to represent,
it would cause the unexpected result.

So this patch is to fix the wrong RTL pattern, ensure the
associated RTL patterns become the same as before which can
have the same semantic as their mapped insns.  With the
proposed patch, the expanders like altivec_vmrghw expands
into altivec_vmrghb_direct_be or altivec_vmrglb_direct_le
depending on endianness, "direct" can easily show which
insn would be generated, _be and _le are mainly for the
different RTL patterns as endianness.

Co-authored-by: Xionghu Luo <xionghuluo@tencent.com>

	PR target/106069
	PR target/115355

gcc/ChangeLog:

	* config/rs6000/altivec.md (altivec_vmrghw_direct_<VSX_W:mode>): Rename
	to ...
	(altivec_vmrghw_direct_<VSX_W:mode>_be): ... this.  Add the condition
	BYTES_BIG_ENDIAN.
	(altivec_vmrghw_direct_<VSX_W:mode>_le): New define_insn.
	(altivec_vmrglw_direct_<VSX_W:mode>): Rename to ...
	(altivec_vmrglw_direct_<VSX_W:mode>_be): ... this.  Add the condition
	BYTES_BIG_ENDIAN.
	(altivec_vmrglw_direct_<VSX_W:mode>_le): New define_insn.
	(altivec_vmrghw): Adjust by calling gen_altivec_vmrghw_direct_v4si_be
	for BE and gen_altivec_vmrglw_direct_v4si_le for LE.
	(altivec_vmrglw): Adjust by calling gen_altivec_vmrglw_direct_v4si_be
	for BE and gen_altivec_vmrghw_direct_v4si_le for LE.
	(vec_widen_umult_hi_v8hi): Adjust the call to
	gen_altivec_vmrghw_direct_v4si by gen_altivec_vmrghw for BE
	and by gen_altivec_vmrglw for LE.
	(vec_widen_smult_hi_v8hi): Likewise.
	(vec_widen_umult_lo_v8hi): Adjust the call to
	gen_altivec_vmrglw_direct_v4si by gen_altivec_vmrglw for BE
	and by gen_altivec_vmrghw for LE
	(vec_widen_smult_lo_v8hi): Likewise.
	* config/rs6000/rs6000.cc (altivec_expand_vec_perm_const): Replace
	CODE_FOR_altivec_vmrghw_direct_v4si by
	CODE_FOR_altivec_vmrghw_direct_v4si_be for BE and
	CODE_FOR_altivec_vmrghw_direct_v4si_le for LE.  And replace
	CODE_FOR_altivec_vmrglw_direct_v4si by
	CODE_FOR_altivec_vmrglw_direct_v4si_be for BE and
	CODE_FOR_altivec_vmrglw_direct_v4si_le for LE.
	* config/rs6000/vsx.md (vsx_xxmrghw_<VSX_W:mode>): Adjust by calling
	gen_altivec_vmrghw_direct_v4si_be for BE and
	gen_altivec_vmrglw_direct_v4si_le for LE.
	(vsx_xxmrglw_<VSX_W:mode>): Adjust by calling
	gen_altivec_vmrglw_direct_v4si_be for BE and
	gen_altivec_vmrghw_direct_v4si_le for LE.

gcc/testsuite/ChangeLog:

	* g++.target/powerpc/pr106069.C: New test.
	* gcc.target/powerpc/pr115355.c: New test.

(cherry picked from commit 52c112800d)
2024-06-27 20:15:02 -05:00
GCC Administrator 15d304de84 Daily bump. 2024-06-28 00:23:15 +00:00
Jonathan Wakely a8b77a6963 libstdc++: Replace viewcvs links in docs with cgit links
For this backport to the release branch, the links to the git repo refer
to the branch.

libstdc++-v3/ChangeLog:

	* doc/xml/faq.xml: Replace viewcvs links with cgit links.
	* doc/xml/manual/allocator.xml: Likewise.
	* doc/xml/manual/mt_allocator.xml: Likewise.
	* doc/html/*: Regenerate.

(cherry picked from commit 9d8021d187)
2024-06-27 23:46:21 +01:00
Alexandre Oliva b70af0bd2e [libstdc++] [testsuite] defer to check_vect_support* [PR115454]
The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

	PR libstdc++/115454
	* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
	to check_vect_support_and_set_flags's default dg-do action.

(cherry picked from commit 95faa1bea7)
2024-06-27 08:14:34 -03:00
Kyrylo Tkachov c2878a9a17 aarch64: Add support for -mcpu=grace
This adds support for the NVIDIA Grace CPU to aarch64.
We reuse the tuning decisions for the Neoverse V2 core, but include a
number of architecture features that are not enabled by default in
-mcpu=neoverse-v2.

This allows Grace users to more simply target the CPU with -mcpu=grace
rather than remembering what extensions to tag on top of
-mcpu=neoverse-v2.

Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/

	* config/aarch64/aarch64-cores.def (grace): New entry.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* doc/invoke.texi (AArch64 Options): Document the above.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
2024-06-27 09:47:56 +02:00
Jiawei 6e6f10c3ad tree-ssa-pre.c/115214(ICE in find_or_generate_expression, at tree-ssa-pre.c:2780): Return NULL_TREE when deal special cases.
Return NULL_TREE when genop3 equal EXACT_DIV_EXPR.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652641.html

version log v3: remove additional POLY_INT_CST check.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652795.html

gcc/ChangeLog:

	* tree-ssa-pre.cc (create_component_ref_by_pieces_1): New conditions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/pr115214.c: New test.
2024-06-27 13:08:46 +08:00
GCC Administrator f9cc628d16 Daily bump. 2024-06-27 00:22:50 +00:00
GCC Administrator 532357bc27 Daily bump. 2024-06-26 00:23:48 +00:00
Jonathan Wakely f91d9b3e91 libstdc++: Remove confusing text from status tables for release branch
When I tried to make the release branch versions of these docs refer to
the release branch instead of "mainline GCC", for some reason I left the
text "not any particular release" there. That's just confusing, because
the docs are for a particular release, the latest on that branch. Remove
that confusing text in several places.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx1998.xml: Remove confusing "not in
	any particular release" text.
	* doc/xml/manual/status_cxx2011.xml: Likewise.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise.
	* doc/xml/manual/status_cxx2020.xml: Likewise.
	* doc/xml/manual/status_cxx2023.xml: Likewise.
	* doc/xml/manual/status_cxxtr1.xml: Likewise.
	* doc/xml/manual/status_cxxtr24733.xml: Likewise.
	* doc/html/manual/status.html: Regenerate.
2024-06-25 23:35:45 +01:00
Sandra Loosemore b383719aeb Fix PR c/115587, uninitialized variable in c_parser_omp_loop_nest
This function had a reference to an uninitialized variable on the
error path.  The problem was diagnosed by clang but not gcc.  It seems
the cleanest solution is to initialize all the loop-clause variables
at the point of declaration rather than at different places in the
code.

The C++ front end didn't have this problem, but I've made similar
changes there to keep the code in sync.

gcc/c/ChangeLog:

	PR c/115587
	* c-parser.cc (c_parser_omp_loop_nest): Move initializations to
	point of declaration.

gcc/cp/ChangeLog:

	PR c/115587
	* parser.cc (cp_parser_omp_loop_nest): Move initializations to
	point of declaration.

(cherry picked from commit 21f1073d38)
2024-06-25 14:53:05 +00:00
Eric Botcazou 4bf93fc3d3 SPARC: fix internal error with -mv8plus on 64-bit Linux
This passes -m32 when -mv8plus is specified on Linux (like on Solaris).

gcc/
	PR target/115608
	* config/sparc/linux64.h (CC1_SPEC): Pass -m32 for -mv8plus.
2024-06-25 11:50:46 +02:00
Andrew Pinski b7157f3930 c-family: Add Warning property to Wnrvo option [PR115624]
This was missing when Wnrvo was added in
r14-1594-g2ae5384d457b9c67586de012816dfc71a6943164 .

Pushed after a bootstrap/test on x86_64-linux-gnu.

gcc/c-family/ChangeLog:

	PR c++/115624
	* c.opt (Wnrvo): Add Warning property.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit f774721094)
2024-06-24 21:57:57 -07:00
GCC Administrator faf5994e65 Daily bump. 2024-06-25 00:24:11 +00:00
Kewen Lin 2b5e8f918e rs6000: Don't clobber return value when eh_return called [PR114846]
As the associated test case in PR114846 shows, currently
with eh_return involved some register restoring for EH
RETURN DATA in epilogue can clobber the one which holding
the return value.  Referring to the existing handlings in
some other targets, this patch makes eh_return expander
call one new define_insn_and_split eh_return_internal which
directly calls rs6000_emit_epilogue with epilogue_type
EPILOGUE_TYPE_EH_RETURN instead of the previous treating
normal return with crtl->calls_eh_return specially.

	PR target/114846

gcc/ChangeLog:

	* config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): As
	EPILOGUE_TYPE_EH_RETURN would be passed as epilogue_type directly
	now, adjust the relevant handlings on it.
	* config/rs6000/rs6000.md (eh_return expander): Append by calling
	gen_eh_return_internal and emit_barrier.
	(eh_return_internal): New define_insn_and_split, call function
	rs6000_emit_epilogue with epilogue type EPILOGUE_TYPE_EH_RETURN.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr114846.c: New test.

(cherry picked from commit e5fc5d42d2)
2024-06-23 20:42:45 -05:00
GCC Administrator 1a2329d007 Daily bump. 2024-06-24 00:24:03 +00:00
GCC Administrator 1735b862ad Daily bump. 2024-06-23 00:22:43 +00:00
GCC Administrator 70d9d929ce Daily bump. 2024-06-22 00:24:39 +00:00
Wilco Dijkstra 9421f02916 AArch64: Fix cpu features initialization [PR115342]
The CPU features initialization code uses CPUID registers (rather than
HWCAP).  The equality comparisons it uses are incorrect: for example FEAT_SVE
is not set if SVE2 is available.  Using HWCAPs for these is both simpler and
correct.  The initialization must also be done atomically to avoid multiple
threads causing corruption due to non-atomic RMW accesses to the global.

libgcc:
	PR target/115342
	* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
	Use HWCAP where possible.  Use atomic write for initialization.
	Fix FEAT_PREDRES comparison.
	(__init_cpu_features_resolver): Use atomic load for correct
	initialization.
	(__init_cpu_features): Likewise.
(cherry picked from commit d7cbcfe7c3)
2024-06-21 17:15:45 +01:00
Matthias Kretz a851931bc0 libstdc++: Fix test on x86_64 and non-simd targets
* Running a test compiled with AVX512 instructions requires
avx512f_runtime not just avx512f.

* The 'reduce2' test violated an invariant of fixed_size_simd_mask and
thus failed on all targets without 16-Byte vector builtins enabled (in
bits/simd.h).

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115575
	* testsuite/experimental/simd/pr115454_find_last_set.cc: Require
	avx512f_runtime. Don't memcpy fixed_size masks.

(cherry picked from commit 77f321435b)
2024-06-21 18:07:30 +02:00
YunQiang Su a16f47f5f3 Build: Set gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel
We check gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel
only, while gcc_cv_as_mips_explicit_relocs is used by later code.

gcc
	* configure.ac: Set gcc_cv_as_mips_explicit_relocs if
	gcc_cv_as_mips_explicit_relocs_pcrel.
	* configure: Regenerate.

(cherry picked from commit 573f11ec34)
2024-06-21 21:55:12 +08:00
Richard Biener 272e8c90af tree-optimization/115278 - fix DSE in if-conversion wrt volatiles
The following adds the missing guard for volatile stores to the
embedded DSE in the loop if-conversion pass.

	PR tree-optimization/115278
	* tree-if-conv.cc (ifcvt_local_dce): Do not DSE volatile stores.

	* g++.dg/vect/pr115278.cc: New testcase.

(cherry picked from commit 65dbe0ab7c)
2024-06-21 11:42:49 +02:00
Richard Biener 65e25860f4 tree-optimization/115508 - fix ICE with SLP scheduling and extern vector
When there's a permute after an extern vector we can run into a case
that didn't consider the scheduled node being a permute which lacks
a representative.

	PR tree-optimization/115508
	* tree-vect-slp.cc (vect_schedule_slp_node): Guard check on
	representative.

	* gcc.target/i386/pr115508.c: New testcase.

(cherry picked from commit 65e72b95c6)
2024-06-21 11:42:48 +02:00
Richard Biener 85d32e6f75 Avoid SLP_REPRESENTATIVE access for VEC_PERM in SLP scheduling
SLP permute nodes can end up without a SLP_REPRESENTATIVE now,
the following avoids touching it in this case in vect_schedule_slp_node.

	* tree-vect-slp.cc (vect_schedule_slp_node): Avoid looking
	at SLP_REPRESENTATIVE for VEC_PERM nodes.

(cherry picked from commit 31e9bae0ea)
2024-06-21 11:42:48 +02:00
GCC Administrator 30fca2ce1d Daily bump. 2024-06-21 00:26:37 +00:00
Matthias Kretz e77f314ccd libstdc++: Fix find_last_set(simd_mask) to ignore padding bits
With the change to the AVX512 find_last_set implementation, the change
to AVX512 operator!= is unnecessary. However, the latter was not
producing optimal code and unnecessarily set the padding bits. In
theory, the compiler could determine that with the new !=
implementation, the bit operation for clearing the padding bits is a
no-op and can be elided.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115454
	* include/experimental/bits/simd_x86.h (_S_not_equal_to): Use
	neq comparison instead of bitwise negation after eq.
	(_S_find_last_set): Clear unused high bits before computing
	bit_width.
	* testsuite/experimental/simd/pr115454_find_last_set.cc: New
	test.

(cherry picked from commit 1340ddea01)
2024-06-20 13:28:06 +02:00
Andreas Krebbel d26fa1c73b vshuf-mem.C: Make -march=z14 depend on s390_vxe
gcc/testsuite/ChangeLog:

	* g++.dg/torture/vshuf-mem.C: Use -march=z14 only, if the we are
	on a machine which can actually run it.

(cherry picked from commit 7e59f0c05d)
2024-06-20 13:05:17 +02:00
Jakub Jelinek b4e4997b1f testsuite: Add -Wno-psabi to vshuf-mem.C test
The newly added test FAILs on i686-linux.
On x86_64-linux
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m64,-m32/-msse2,-m32/-mno-sse/-mno-mmx\} dg-torture.exp=vshuf-mem.C'
shows that as well.

The problem is that without SSE2/MMX the vector is passed differently
than normally and so GCC warns about that.
-Wno-psabi is the usual way to shut it up.

Also wonder about the
// { dg-additional-options "-march=z14" { target s390*-*-* } }
line, doesn't that mean the test will FAIL on all pre-z14 HW?
Shouldn't it use some z14_runtime or similar effective target, or
check in main (in that case copied over to g++.target/s390) whether
z14 instructions can be actually used at runtime?

2024-06-14  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/torture/vshuf-mem.C: Add -Wno-psabi to dg-options.

(cherry picked from commit 1bb2535c7c)
2024-06-20 13:04:56 +02:00
Andreas Krebbel 166c9f99a2 IBM Z: Fix ICE in expand_perm_as_replicate
The current implementation assumes to always be invoked with register
operands. For memory operands we even have an instruction
though (vlrep). With the patch we try this first and only if it fails
force the input into a register and continue.

vec_splats generation fails for single element 128bit types which are
allowed for vec_splat. This is something to sort out with another
patch I guess.

gcc/ChangeLog:

	* config/s390/s390.cc (expand_perm_as_replicate): Handle memory
	operands.
	* config/s390/vx-builtins.md (vec_splats<mode>): Turn into parameterized expander.
	(@vec_splats<mode>): New expander.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/vshuf-mem.C: New test.

(cherry picked from commit 21fd8c67ad)
2024-06-20 13:04:31 +02:00
Jakub Jelinek f79e909a11 bitint: Fix up lowering of COMPLEX_EXPR [PR115544]
We don't really support _Complex _BitInt(N), the only place we use
bitint complex types is for the .{ADD,SUB,MUL}_OVERFLOW internal function
results and COMPLEX_EXPR in the usual case should be either not present
yet because the ifns weren't folded and will be lowered, or optimized
into something simpler, because normally the complex bitint should be
used just for extracting the 2 subparts from it.
Still, with disabled optimizations it can occassionally happen that it
appears in the IL and that is why there is support for lowering those,
but it doesn't handle optimizing those too much, so if it uses SSA_NAME,
it relies on them having a backing VAR_DECL during the lowering.
This is normally achieves through the
                      && ((is_gimple_assign (use_stmt)
                           && (gimple_assign_rhs_code (use_stmt)
                               != COMPLEX_EXPR))
                          || gimple_code (use_stmt) == GIMPLE_COND)
hunk in gimple_lower_bitint, but as the following testcase shows, there
is one thing I've missed, the load optimization isn't guarded by the
above stuff.  So, either we'd need to add support for loads to
lower_complexexpr_stmt, or because they should be really rare, this
patch just disables the load optimization if at least one load use is
a COMPLEX_EXPR (like we do already for PHIs, calls, asm).

2024-06-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/115544
	* gimple-lower-bitint.cc (gimple_lower_bitint): Disable optimizing
	loads used by COMPLEX_EXPR operands.

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

(cherry picked from commit 25860fd2a6)
2024-06-20 10:24:13 +02:00
Jakub Jelinek 74a58c39c7 diagnostics: Fix add_misspelling_candidates [PR115440]
The option_map array for most entries contains just non-NULL opt0
    { "-Wno-", NULL, "-W", false, true },
    { "-fno-", NULL, "-f", false, true },
    { "-gno-", NULL, "-g", false, true },
    { "-mno-", NULL, "-m", false, true },
    { "--debug=", NULL, "-g", false, false },
    { "--machine-", NULL, "-m", true, false },
    { "--machine-no-", NULL, "-m", false, true },
    { "--machine=", NULL, "-m", false, false },
    { "--machine=no-", NULL, "-m", false, true },
    { "--machine", "", "-m", false, false },
    { "--machine", "no-", "-m", false, true },
    { "--optimize=", NULL, "-O", false, false },
    { "--std=", NULL, "-std=", false, false },
    { "--std", "", "-std=", false, false },
    { "--warn-", NULL, "-W", true, false },
    { "--warn-no-", NULL, "-W", false, true },
    { "--", NULL, "-f", true, false },
    { "--no-", NULL, "-f", false, true }
and so add_misspelling_candidates works correctly for it, but 3 out of
these,
    { "--machine", "", "-m", false, false },
    { "--machine", "no-", "-m", false, true },
and
    { "--std", "", "-std=", false, false },
use non-NULL opt1.  That says that
--machine foo
should map to
-mfoo
and
--machine no-foo
should map to
-mno-foo
and
--std c++17
should map to
-std=c++17
add_misspelling_canidates was not handling this, so it hapilly
registered say
--stdc++17
or
--machineavx512
(twice) as spelling alternatives, when those options aren't recognized.
Instead we support
--std c++17
or
--machine avx512
--machine no-avx512

The following patch fixes that.  On this particular testcase, we no longer
suggest anything, even when among the suggestion is say that
--std c++17
or
-std=c++17
etc.

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

	PR driver/115440
	* opts-common.cc (add_misspelling_candidates): If opt1 is non-NULL,
	add a space and opt1 to the alternative suggestion text.

	* g++.dg/cpp1z/pr115440.C: New test.

(cherry picked from commit 96db57948b)
2024-06-20 10:19:56 +02:00
GCC Administrator 946f26e35f Daily bump. 2024-06-20 00:22:19 +00:00
GCC Administrator 6f6103ccc5 Daily bump. 2024-06-19 00:23:00 +00:00
GCC Administrator 789f05536d Daily bump. 2024-06-18 00:22:42 +00:00
Jakub Jelinek 922648759b c-family: Fix -Warray-compare warning ICE [PR115290]
The warning code uses %D to print the ARRAY_REF first operands.
That works in the most common case where those operands are decls, but
as can be seen on the following testcase, they can be other expressions
with array type.
Just changing %D to %E isn't enough, because then the diagnostics can
suggest something like
note: use '&(x) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0] == &(y) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0]' to compare the addresses
which is a bad suggestion, the %E printing doesn't know that the
warning code will want to add & before it and [0] after it.
So, the following patch adds ()s around the operand as well, but does
that only for non-decls, for decls keeps it as &arr[0] like before.

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

	PR c/115290
	* c-warn.cc (do_warn_array_compare): Use %E rather than %D for
	printing op0 and op1; if those operands aren't decls, also print
	parens around them.

	* c-c++-common/Warray-compare-3.c: New test.

(cherry picked from commit b63c7d9201)
2024-06-17 19:25:43 +02:00
Jakub Jelinek 5be6d9d2a9 c++: Fix up floating point conversion rank comparison for _Float32 and float if float/double are same size [PR115511]
On AVR and SH with some options sizeof (float) == sizeof (double) and
the 2 types have the same set of values.
http://eel.is/c++draft/conv.rank#2.2 for this says that double still
has bigger rank than float and http://eel.is/c++draft/conv.rank#2.2
says that extended type with the same set of values as more than one
standard floating point type shall have the same rank as double.
I've implemented the latter rule as
   if (cnt > 1 && mv2 == long_double_type_node)
     return -2;
with the _Float64/double/long double case having same mode case (various
targets with -mlong-double-64) in mind.
But never thought there are actually targets where float and double
are the same, that needs handling too, if cnt > 1 (that is the extended
type mv1 has same set of values as 2 or 3 of float/double/long double)
and mv2 is float, we need to return 2, because mv1 in that case should
have same rank as double and double has bigger rank than float.

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

	PR target/111343
	PR c++/115511
	* typeck.cc (cp_compare_floating_point_conversion_ranks): If an
	extended floating point type mv1 has same set of values as more
	than one standard floating point type and mv2 is float, return 2.

	* g++.dg/cpp23/ext-floating18.C: New test.

(cherry picked from commit 8584c98f37)
2024-06-17 19:17:06 +02:00
Patrick Palka 20cda2e85c c++: undeclared identifier in requires-clause [PR99678]
Since the terms of a requires-clause are grammatically primary-expressions
and not e.g. postfix-expressions, it seems we need to explicitly handle
and diagnose the case where a term parses to a bare unresolved identifier,
like cp_parser_postfix_expression does, since cp_parser_primary_expression
leaves that up to its callers.  Otherwise we incorrectly accept the first
three requires-clauses below.

Note that the only occurrences of primary-expression in the grammar are
postfix-expression and constraint-logical-and-expression, so it's not too
surprising that we need this special handling here.

	PR c++/99678

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_constraint_primary_expression): Diagnose
	a bare unresolved unqualified-id.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires38.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit d387ecb2b2)
2024-06-17 10:14:44 -04:00
Patrick Palka 4df8640299 c++: ICE w/ ambig and non-strictly-viable cands [PR115239]
Here during overload resolution we have two strictly viable ambiguous
candidates #1 and #2, and two non-strictly viable candidates #3 and #4
which we hold on to ever since r14-6522.  These latter candidates have
an empty second arg conversion since the first arg conversion was deemed
bad, and this trips up joust when called on #3 and #4 which assumes all
arg conversions are there.

We can fix this by making joust robust to empty arg conversions, but in
this situation we shouldn't need to compare #3 and #4 at all given that
we have a strictly viable candidate.  To that end, this patch makes
tourney shortcut considering non-strictly viable candidates upon
encountering ambiguity between two strictly viable candidates (taking
advantage of the fact that the candidates list is sorted according to
viability via splice_viable).

	PR c++/115239

gcc/cp/ChangeLog:

	* call.cc (tourney): Don't consider a non-strictly viable
	candidate as the champ if there was ambiguity between two
	strictly viable candidates.

gcc/testsuite/ChangeLog:

	* g++.dg/overload/error7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7fed7e9bbc)
2024-06-17 10:14:43 -04:00
Patrick Palka 9583f781e1 c++: visibility wrt concept-id as targ [PR115283]
Like with alias templates, it seems we don't maintain visibility flags
for concepts either, so min_vis_expr_r should ignore them for now.
Otherwise after r14-6789 we may incorrectly give a function template that
uses a concept-id in its signature internal linkage.

	PR c++/115283

gcc/cp/ChangeLog:

	* decl2.cc (min_vis_expr_r) <case TEMPLATE_DECL>: Ignore
	concepts.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit b1fe718cbe)
2024-06-17 10:14:43 -04:00
Stefan Schulze Frielinghaus 0ed63e3791 s390: testsuite: Fix ifcvt-one-insn-bool.c
With the change of r15-787-g57e04879389f9c I forgot to also update this
test.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/ifcvt-one-insn-bool.c: Fix loc.

(cherry picked from commit ac66736bf2)
2024-06-17 08:52:28 +02:00
Stefan Schulze Frielinghaus 8f124e6b79 s390: Implement TARGET_NOCE_CONVERSION_PROFITABLE_P [PR109549]
Consider a NOCE conversion as profitable if there is at least one
conditional move.

gcc/ChangeLog:

	PR target/109549
	* config/s390/s390.cc (TARGET_NOCE_CONVERSION_PROFITABLE_P):
	Define.
	(s390_noce_conversion_profitable_p): Implement.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/ccor.c: Order of loads are reversed, now, as a
	consequence the condition has to be reversed.

(cherry picked from commit 57e0487938)
2024-06-17 08:52:20 +02:00
GCC Administrator 13a09f32df Daily bump. 2024-06-17 00:21:57 +00:00
GCC Administrator a4f8e9ec38 Daily bump. 2024-06-16 00:21:54 +00:00
Christoph Müllner 3fe255fd3f riscv: Allocate enough space to strcpy() string
I triggered an ICE on Ubuntu 24.04 when compiling code that uses
function attributes. Looking into the sources shows that we have
a systematic issue in the attribute handling code:
* we determine the length with strlen() (excluding the terminating null)
* we allocate a buffer with this length
* we copy the original string using strcpy() (incl. the terminating null)

To quote the man page of strcpy():
"The programmer is responsible for allocating a  destination  buffer
large  enough,  that  is, strlen(src)  + 1."

The ICE looks like this:

*** buffer overflow detected ***: terminated
xtheadmempair_bench.c:14:1: internal compiler error: Aborted
   14 | {
      | ^
0xaf3b99 crash_signal
        /home/ubuntu/src/gcc/scaleff/gcc/toplev.cc:319
0xe5b957 strcpy
        /usr/include/riscv64-linux-gnu/bits/string_fortified.h:79
0xe5b957 riscv_process_target_attr
        /home/ubuntu/src/gcc/scaleff/gcc/config/riscv/riscv-target-attr.cc:339
0xe5baaf riscv_process_target_attr
        /home/ubuntu/src/gcc/scaleff/gcc/config/riscv/riscv-target-attr.cc:314
0xe5bc5f riscv_option_valid_attribute_p(tree_node*, tree_node*, tree_node*, int)
        /home/ubuntu/src/gcc/scaleff/gcc/config/riscv/riscv-target-attr.cc:389
0x6a31e5 handle_target_attribute
        /home/ubuntu/src/gcc/scaleff/gcc/c-family/c-attribs.cc:5915
0x5d3a07 decl_attributes(tree_node**, tree_node*, int, tree_node*)
        /home/ubuntu/src/gcc/scaleff/gcc/attribs.cc:900
0x5db403 c_decl_attributes
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-decl.cc:5501
0x5e8965 start_function(c_declspecs*, c_declarator*, tree_node*)
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-decl.cc:10562
0x6318ed c_parser_declaration_or_fndef
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-parser.cc:2914
0x63a8ad c_parser_external_declaration
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-parser.cc:2048
0x63b219 c_parser_translation_unit
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-parser.cc:1902
0x63b219 c_parse_file()
        /home/ubuntu/src/gcc/scaleff/gcc/c/c-parser.cc:27277
0x68fec5 c_common_parse_file()
        /home/ubuntu/src/gcc/scaleff/gcc/c-family/c-opts.cc:1311
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

gcc/ChangeLog:

	* config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::parse_arch):
	Fix allocation size of buffer.
	(riscv_process_one_target_attr): Likewise.
	(riscv_process_target_attr): Likewise.

(cherry picked from commit 6762d5738b)
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2024-06-15 12:12:00 +02:00
GCC Administrator 6b2fc15d22 Daily bump. 2024-06-15 00:22:06 +00:00
Jonathan Wakely 75251f5091 libstdc++: Fix declaration of posix_memalign for freestanding
Thanks to Jérôme Duval for noticing this.

libstdc++-v3/ChangeLog:

	* libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Fix declaration of
	posix_memalign.

(cherry picked from commit 161efd6774)
2024-06-14 15:39:27 +01:00
GCC Administrator b740c091a3 Daily bump. 2024-06-14 00:22:20 +00:00
GCC Administrator 8bd6e4038a Daily bump. 2024-06-13 00:21:50 +00:00
Andre Vieira 7593dae69b arm: Add .type and .size to __gnu_cmse_nonsecure_call [PR115360]
This patch adds missing assembly directives to the CMSE library wrapper to call
functions with attribute cmse_nonsecure_call.  Without the .type directive the
linker will fail to produce the correct veneer if a call to this wrapper
function is to far from the wrapper itself.  The .size was added for
completeness, though we don't necessarily have a usecase for it.

libgcc/ChangeLog:

	PR target/115360
	* config/arm/cmse_nonsecure_call.S: Add .type and .size directives.

(cherry picked from commit c559353af4)
2024-06-12 15:08:55 +01:00
Torbjörn SVENSSON 9100e78ba2 testsuite: Fix expand-return CMSE test for Armv8.1-M [PR115253]
For Armv8.1-M, the clearing of the registers is handled differently than
for Armv8-M, so update the test case accordingly.

gcc/testsuite/ChangeLog:

	PR target/115253
	* gcc.target/arm/cmse/extend-return.c: Update test case
	condition for Armv8.1-M.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
(cherry picked from commit cf5f9171ba)
2024-06-12 10:12:07 +02:00
Torbjörn SVENSSON a657148995 arm: Zero/Sign extends for CMSE security on Armv8-M.baseline [PR115253]
Properly handle zero and sign extension for Armv8-M.baseline as
Cortex-M23 can have the security extension active.
Currently, there is an internal compiler error on Cortex-M23 for the
epilog processing of sign extension.

This patch addresses the following CVE-2024-0151 for Armv8-M.baseline.

gcc/ChangeLog:

	PR target/115253
	* config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
	Sign extend for Thumb1.
	(thumb1_expand_prologue): Add zero/sign extend.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
(cherry picked from commit 65bd0655ec)
2024-06-12 10:12:06 +02:00
GCC Administrator dfc5c98cbc Daily bump. 2024-06-12 00:24:10 +00:00
Andrew Pinski e6b1c08205 Fix building JIT with musl libc [PR115442]
Just like r13-6662-g0e6f87835ccabf but this time for jit/jit-recording.cc.

Pushed as obvious after a quick build to make sure jit still builds.

gcc/jit/ChangeLog:

	PR jit/115442
	* jit-recording.cc: Define INCLUDE_SSTREAM before including
	system.h and don't directly incldue sstream.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit e4244b88d7)
2024-06-11 12:45:59 -07:00
Richard Sandiford 7d64bc0990 ira: Fix go_through_subreg offset calculation [PR115281]
go_through_subreg used:

  else if (!can_div_trunc_p (SUBREG_BYTE (x),
			     REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))

to calculate the register offset for a pseudo subreg x.  In the blessed
days before poly-int, this was:

    *offset = (SUBREG_BYTE (x) / REGMODE_NATURAL_SIZE (GET_MODE (x)));

But I think this is testing the wrong natural size.  If we exclude
paradoxical subregs (which will get an offset of zero regardless),
it's the inner register that is being split, so it should be the
inner register's natural size that we use.

This matters in the testcase because we have an SFmode lowpart
subreg into the last of three variable-sized vectors.  The
SUBREG_BYTE is therefore equal to the size of two variable-sized
vectors.  Dividing by the vector size gives a register offset of 2,
as expected, but dividing by the size of a scalar FPR would give
a variable offset.

I think something similar could happen for fixed-size targets if
REGMODE_NATURAL_SIZE is different for vectors and integers (say),
although that case would trade an ICE for an incorrect offset.

gcc/
	PR rtl-optimization/115281
	* ira-conflicts.cc (go_through_subreg): Use the natural size of
	the inner mode rather than the outer mode.

gcc/testsuite/
	PR rtl-optimization/115281
	* gfortran.dg/pr115281.f90: New test.

(cherry picked from commit 46d931b3dd)
2024-06-11 09:58:48 +01:00
GCC Administrator 60e4cc3625 Daily bump. 2024-06-11 00:23:34 +00:00
Patrick Palka ff8105b491 c++: lambda in pack expansion [PR115378]
Here find_parameter_packs_r is incorrectly treating the 'auto' return
type of a lambda as a parameter pack due to Concepts-TS specific logic
added in r6-4517, leading to confusion later when expanding the pattern.

Since we intend on removing Concepts TS support soon anyway, this patch
fixes this by restricting the problematic logic with flag_concepts_ts.
Doing so revealed that add_capture was relying on this logic to set
TEMPLATE_TYPE_PARAMETER_PACK for the 'auto' type of an pack expansion
init-capture, which we now need to do explicitly.

	PR c++/115378

gcc/cp/ChangeLog:

	* lambda.cc (lambda_capture_field_type): Set
	TEMPLATE_TYPE_PARAMETER_PACK on the auto type of an init-capture
	pack expansion.
	* pt.cc (find_parameter_packs_r) <case TEMPLATE_TYPE_PARM>:
	Restrict TEMPLATE_TYPE_PARAMETER_PACK promotion with
	flag_concepts_ts.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/decltype-auto-103497.C: Adjust expected diagnostic.
	* g++.dg/template/pr95672.C: Likewise.
	* g++.dg/cpp2a/lambda-targ5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 5c76139540)
2024-06-10 10:15:31 -04:00
Eric Botcazou b5ad4431f9 Fix crash on access-to-incomplete type
This just adds the missing guard.

gcc/ada/
	PR ada/114708
	* exp_util.adb (Finalize_Address): Add guard for incomplete types.

gcc/testsuite/
	* gnat.dg/incomplete8.adb: New test.
2024-06-10 12:22:32 +02:00
Eric Botcazou 72a59a1b8d Add testcase for PR ada/114398
gcc/testsuite/
	PR ada/114398
	* gnat.dg/access11.adb: New test.
2024-06-10 11:51:26 +02:00
Javier Miranda a1bec0455f ada: Storage_Error in indirect call to function returning limited type
At runtime the code generated by the compiler reports the
exception Storage_Error in an indirect call through an
access-to-subprogram variable that references a function
returning a limited tagged type object.

gcc/ada/

	* sem_ch6.adb (Might_Need_BIP_Task_Actuals): Add support
	for access-to-subprogram parameter types.
	* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call):
	Add dummy BIP parameters to access-to-subprogram types
	that may reference a function that has BIP parameters.
2024-06-10 11:50:40 +02:00
Jan Beulich 6bd8a3a7a8 libgcc/aarch64: also provide AT_HWCAP2 fallback
Much like AT_HWCAP is already provided in case the platform headers
don't have the value (yet).

libgcc/

	* config/aarch64/cpuinfo.c: Provide AT_HWCAP2.
2024-06-10 08:59:46 +02:00
Matthias Kretz 489b58b797 libstdc++: Fix simd<char> conversion for -fno-signed-char for Clang
The special case for Clang in the trait producing a signed integer type
lead to the trait returning 'char' where it should have been 'signed
char'. This workaround was introduced because on Clang the return type
of vector compares was not convertible to '_SimdWrapper<
__int_for_sizeof_t<...' unless '__int_for_sizeof_t<char>' was an alias
for 'char'. In order to not rewrite the complete mask type code (there
is code scattered around the implementation assuming signed integers),
this needs to be 'signed char'; so the special case for Clang needs to
be removed.
The conversion issue is now solved in _SimdWrapper, which now
additionally allows conversion from vector types with compatible
integral type.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115308
	* include/experimental/bits/simd.h (__int_for_sizeof): Remove
	special cases for __clang__.
	(_SimdWrapper): Change constructor overload set to allow
	conversion from vector types with integral conversions via bit
	reinterpretation.

(cherry picked from commit 8e36cf4c5c)
2024-06-10 07:58:09 +02:00
Matthias Kretz 237f060033 libstdc++: Avoid MMX return types from __builtin_shufflevector
This resolves a regression on i686 that was introduced with
r15-429-gfb1649f8b4ad50.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115247
	* include/experimental/bits/simd.h (__as_vector): Don't use
	vector_size(8) on __i386__.
	(__vec_shuffle): Never return MMX vectors, widen to 16 bytes
	instead.
	(concat): Fix padding calculation to pick up widening logic from
	__as_vector.

(cherry picked from commit 241a6cc88d)
2024-06-10 07:58:09 +02:00
Matthias Kretz ff4646793f libstdc++: Use __builtin_shufflevector for simd split and concat
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/114958
	* include/experimental/bits/simd.h (__as_vector): Return scalar
	simd as one-element vector. Return vector from single-vector
	fixed_size simd.
	(__vec_shuffle): New.
	(__extract_part): Adjust return type signature.
	(split): Use __extract_part for any split into non-fixed_size
	simds.
	(concat): If the return type stores a single vector, use
	__vec_shuffle (which calls __builtin_shufflevector) to produce
	the return value.
	* include/experimental/bits/simd_builtin.h
	(__shift_elements_right): Removed.
	(__extract_part): Return single elements directly. Use
	__vec_shuffle (which calls __builtin_shufflevector) to for all
	non-trivial cases.
	* include/experimental/bits/simd_fixed_size.h (__extract_part):
	Return single elements directly.
	* testsuite/experimental/simd/pr114958.cc: New test.

(cherry picked from commit fb1649f8b4)
2024-06-10 07:58:08 +02:00
GCC Administrator affb4f3ed6 Daily bump. 2024-06-10 00:22:13 +00:00
GCC Administrator 2ceab8827c Daily bump. 2024-06-09 00:22:27 +00:00
Harald Anlauf c3e16edcf2 Fortran: fix ALLOCATE with SOURCE=, zero-length character [PR83865]
gcc/fortran/ChangeLog:

	PR fortran/83865
	* trans-stmt.cc (gfc_trans_allocate): Restrict special case for
	source-expression with zero-length character to rank 0, so that
	the array shape is not discarded.

gcc/testsuite/ChangeLog:

	PR fortran/83865
	* gfortran.dg/allocate_with_source_32.f90: New test.

(cherry picked from commit 7f21aee0d4)
2024-06-08 19:53:00 +02:00
GCC Administrator 96f9b06822 Daily bump. 2024-06-08 00:24:02 +00:00
Richard Ball ca1924947b arm: Fix CASE_VECTOR_SHORTEN_MODE for thumb2.
The CASE_VECTOR_SHORTEN_MODE query is missing some equals signs
which causes suboptimal codegen due to missed optimisation
opportunities. This patch also adds a test for thumb2
switch statements as none exist currently.

gcc/ChangeLog:
	PR target/115353
	* config/arm/arm.h (enum arm_auto_incmodes):
	Correct CASE_VECTOR_SHORTEN_MODE query.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/thumb2-switchstatement.c: New test.

(cherry picked from commit 2963c76e8e)
2024-06-07 15:16:15 +01:00
Jakub Jelinek 0f616e75f3 bitint: Fix up lower_addsub_overflow [PR115352]
The following testcase is miscompiled because of a flawed optimization.
If one changes the 65 in the testcase to e.g. 66, one gets:
...
  _25 = .USUBC (0, _24, _14);
  _12 = IMAGPART_EXPR <_25>;
  _26 = REALPART_EXPR <_25>;
  if (_23 >= 1)
    goto <bb 8>; [80.00%]
  else
    goto <bb 11>; [20.00%]

  <bb 8> :
  if (_23 != 1)
    goto <bb 10>; [80.00%]
  else
    goto <bb 9>; [20.00%]

  <bb 9> :
  _27 = (signed long) _26;
  _28 = _27 >> 1;
  _29 = (unsigned long) _28;
  _31 = _29 + 1;
  _30 = _31 > 1;
  goto <bb 11>; [100.00%]

  <bb 10> :
  _32 = _26 != _18;
  _33 = _22 | _32;

  <bb 11> :
  # _17 = PHI <_30(9), _22(7), _33(10)>
  # _19 = PHI <_29(9), _18(7), _18(10)>
...
so there is one path for limbs below the boundary (in this case there are
actually no limbs there, maybe we could consider optimizing that further,
say with simply folding that _23 >= 1 condition to 1 == 1 and letting
cfg cleanup handle it), another case where it is exactly the limb on the
boundary (that is the bb 9 handling where it extracts the interesting
bits (the first 3 statements) and then checks if it is zero or all ones and
finally the case of limbs above that where it compares the current result
limb against the previously recorded 0 or all ones and ors differences into
accumulated result.

Now, the optimization which the first hunk removes was based on the idea
that for that case the extraction of the interesting bits from the limb
don't need anything special, so the _27/_28/_29 statements above aren't
needed, the whole limb is interesting bits, so it handled the >= 1
case like the bb 9 above without the first 3 statements and bb 10 wasn't
there at all.  There are 2 problems with that, for the higher limbs it
only checks if the the result limb bits are all zeros or all ones, but
doesn't check if they are the same as the other extension bits, and
it forgets the previous flag whether there was an overflow.
First I wanted to fix it just by adding the _33 = _22 | _30; statement
to the end of bb 9 above, which fixed the originally filed huge testcase
and the first 2 foo calls in the testcase included in the patch, it no
longer forgets about previously checked differences from 0/1.
But as the last 2 foo calls show, it still didn't check whether each
even (or each odd depending on the exact position) result limb is
equal to the first one, so every second limb it could choose some other
0 vs. all ones value and as long as it repeated in another limb above it
it would be ok.

So, the optimization just can't work properly and the following patch
removes it.

2024-06-07  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/115352
	* gimple-lower-bitint.cc (lower_addsub_overflow): Don't disable
	single_comparison if cmp_code is GE_EXPR.

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

(cherry picked from commit a47b1aaa7a)
2024-06-07 10:34:53 +02:00
GCC Administrator 7d40974268 Daily bump. 2024-06-07 00:22:48 +00:00
Jakub Jelinek 56c73729c3 c: Fix up pointer types to may_alias structures [PR114493]
The following testcase ICEs in ipa-free-lang, because the
fld_incomplete_type_of
          gcc_assert (TYPE_CANONICAL (t2) != t2
                      && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
assertion doesn't hold.
This is because t is a struct S * type which was created while struct S
was still incomplete and without the may_alias attribute (and TYPE_CANONICAL
of a pointer type is a type created with can_alias_all = false argument),
while later on on the struct definition may_alias attribute was used.
fld_incomplete_type_of then creates an incomplete distinct copy of the
structure (but with the original attributes) but pointers created for it
are because of the "may_alias" attribute TYPE_REF_CAN_ALIAS_ALL, including
their TYPE_CANONICAL, because while that is created with !can_alias_all
argument, we later set it because of the "may_alias" attribute on the
to_type.

This doesn't ICE with C++ since PR70512 fix because the C++ FE sets
TYPE_REF_CAN_ALIAS_ALL on all pointer types to the class type (and its
variants) when the may_alias is added.

The following patch does that in the C FE as well.

2024-06-06  Jakub Jelinek  <jakub@redhat.com>

	PR c/114493
	* c-decl.cc (c_fixup_may_alias): New function.
	(finish_struct): Call it if "may_alias" attribute is
	specified.

	* gcc.dg/pr114493-1.c: New test.
	* gcc.dg/pr114493-2.c: New test.

(cherry picked from commit d5a3c6d43a)
2024-06-06 22:18:54 +02:00
Richard Ball 35ed54f136 aarch64: Add missing ACLE macro for NEON-SVE Bridge
__ARM_NEON_SVE_BRIDGE was missed in the original patch and is
added by this patch.

gcc/ChangeLog:

	* config/aarch64/aarch64-c.cc (aarch64_define_unconditional_macros):
	Add missing __ARM_NEON_SVE_BRIDGE.

(cherry picked from commit 43530bc40b)
2024-06-06 16:33:30 +01:00
GCC Administrator d5760344db Daily bump. 2024-06-06 00:22:30 +00:00
Rainer Orth e11a42b8c7 testsuite: i386: Require ifunc support in gcc.target/i386/avx10_1-25.c etc.
Two new AVX10.1 tests FAIL on Solaris/x86:

FAIL: gcc.target/i386/avx10_1-25.c (test for excess errors)
FAIL: gcc.target/i386/avx10_1-26.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.target/i386/avx10_1-25.c:6:9: error: the call requires 'ifunc', which is not supported by this target

Fixed by requiring ifunc support.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

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

	gcc/testsuite:
	* gcc.target/i386/avx10_1-25.c: Require ifunc support.
	* gcc.target/i386/avx10_1-26.c: Likewise.
2024-06-05 10:16:51 +08:00
GCC Administrator 7f0f88e282 Daily bump. 2024-06-05 00:22:26 +00:00
Jonathan Wakely c6e6258ea4 libstdc++: Only define std::span::at for C++26 [PR115335]
In r14-5689-g1fa85dcf656e2f I added std::span::at and made the correct
changes to the __cpp_lib_span macro (with tests for the correct value in
C++20/23/26). But I didn't make the declaration of std::span::at
actually depend on the macro, so it was defined for C++20 and C++23, not
only for C++26. This fixes that oversight.

libstdc++-v3/ChangeLog:

	PR libstdc++/115335
	* include/std/span (span::at): Guard with feature test macro.

(cherry picked from commit 2197814011)
2024-06-04 15:29:28 +01:00
Jakub Jelinek a88e13bd7e fold-const: Fix up CLZ handling in tree_call_nonnegative_warnv_p [PR115337]
The function currently incorrectly assumes all the __builtin_clz* and .CLZ
calls have non-negative result.  That is the case of the former which is UB
on zero and has [0, prec-1] return value otherwise, and is the case of the
single argument .CLZ as well (again, UB on zero), but for two argument
.CLZ is the case only if the second argument is also nonnegative (or if we
know the argument can't be zero, but let's do that just in the ranger IMHO).

The following patch does that.

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

	PR tree-optimization/115337
	* fold-const.cc (tree_call_nonnegative_warnv_p) <CASE_CFN_CLZ>:
	If arg1 is non-NULL, RECURSE on it, otherwise return true.

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

(cherry picked from commit b82a816000)
2024-06-04 16:20:25 +02:00
Jakub Jelinek f9af4a05e0 builtins: Force SAVE_EXPR for __builtin_{add,sub,mul}_overflow and __builtin{add,sub}c [PR108789]
The following testcase is miscompiled, because we use save_expr
on the .{ADD,SUB,MUL}_OVERFLOW call we are creating, but if the first
two operands are not INTEGER_CSTs (in that case we just fold it right away)
but are TREE_READONLY/!TREE_SIDE_EFFECTS, save_expr doesn't actually
create a SAVE_EXPR at all and so we lower it to
*arg2 = REALPART_EXPR (.ADD_OVERFLOW (arg0, arg1)), \
IMAGPART_EXPR (.ADD_OVERFLOW (arg0, arg1))
which evaluates the ifn twice and just hope it will be CSEd back.
As *arg2 aliases *arg0, that is not the case.
The builtins are really never const/pure as they store into what
the third arguments points to, so after handling the INTEGER_CST+INTEGER_CST
case, I think we should just always use SAVE_EXPR.  Just building SAVE_EXPR
by hand and setting TREE_SIDE_EFFECTS on it doesn't work, because
c_fully_fold optimizes it away again, so the following patch marks the
ifn calls as TREE_SIDE_EFFECTS (but doesn't do it for the
__builtin_{add,sub,mul}_overflow_p case which were designed for use
especially in constant expressions and don't really evaluate the
realpart side, so we don't really need a SAVE_EXPR in that case).

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

	PR middle-end/108789
	* builtins.cc (fold_builtin_arith_overflow): For ovf_only,
	don't call save_expr and don't build REALPART_EXPR, otherwise
	set TREE_SIDE_EFFECTS on call before calling save_expr.
	(fold_builtin_addc_subc): Set TREE_SIDE_EFFECTS on call before
	calling save_expr.

	* gcc.c-torture/execute/pr108789.c: New test.

(cherry picked from commit b8e28381cb)
2024-06-04 16:19:42 +02:00
Jakub Jelinek 1c1bc2553f invoke.texi: Clarify -march=lujiazui
I was recently searching which exact CPUs are affected by the PR114576
wrong-code issue and went from the PTA_* bitmasks in GCC, so arrived
at the goldmont, goldmont-plus, tremont and lujiazui CPUs (as -march=
cases which do enable -maes and don't enable -mavx).
But when double-checking that against the invoke.texi documentation,
that was true for the first 3, but lujiazui said it supported AVX.
I was really confused by that, until I found the
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604407.html
explanation.  So, seems the CPUs do have AVX and F16C but -march=lujiazui
doesn't enable those and even activelly attempts to filter those out from
the announced CPUID features, in glibc as well as e.g. in libgcc.

Thus, I think we should document what actually happens, otherwise
users could assume that
gcc -march=lujiazui predefines __AVX__ and __F16C__, which it doesn't.

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

	* doc/invoke.texi (lujiazui): Clarify that while the CPUs do support
	AVX and F16C, -march=lujiazui actually doesn't enable those.

(cherry picked from commit 09b4ab5315)
2024-06-04 16:19:18 +02:00
Jakub Jelinek a7dd44c02e rs6000: Fix up PCH in --enable-host-pie builds [PR115324]
PCH doesn't work properly in --enable-host-pie configurations on
powerpc*-linux*.
The problem is that the rs6000_builtin_info and rs6000_instance_info
arrays mix pointers to .rodata/.data (bifname and attr_string point
to string literals in .rodata section, and the next member is either NULL
or &rs6000_instance_info[XXX]) and GC member (tree fntype).
Now, for normal GC this works just fine, we emit
  {
    &rs6000_instance_info[0].fntype,
    1 * (RS6000_INST_MAX),
    sizeof (rs6000_instance_info[0]),
    &gt_ggc_mx_tree_node,
    &gt_pch_nx_tree_node
  },
  {
    &rs6000_builtin_info[0].fntype,
    1 * (RS6000_BIF_MAX),
    sizeof (rs6000_builtin_info[0]),
    &gt_ggc_mx_tree_node,
    &gt_pch_nx_tree_node
  },
GC roots which are strided and thus cover only the fntype members of all
the elements of the two arrays.
For PCH though it actually results in saving those huge arrays (one is
130832 bytes, another 81568 bytes) into the .gch files and loading them back
in full.  While the bifname and attr_string and next pointers are marked as
GTY((skip)), they are actually saved to point to the .rodata and .data
sections of the process which writes the PCH, but because cc1/cc1plus etc.
are position independent executables with --enable-host-pie, when it is
loaded from the PCH file, it can point in a completely different addresses
where nothing is mapped at all or some random different thing appears at.
While gengtype supports the callback option, that one is meant for
relocatable function pointers and doesn't work in the case of GTY arrays
inside of .data section anyway.

So, either we'd need to add some further GTY extensions, or the following
patch instead reworks it such that the fntype members which were the only
reason for PCH in those arrays are moved to separate arrays.

Size-wise in .data sections it is (in bytes):

                             vanilla    patched
rs6000_builtin_info          130832     110704
rs6000_instance_info          81568      40784
rs6000_overload_info           7392       7392
rs6000_builtin_info_fntype        0      10064
rs6000_instance_info_fntype       0      20392
sum                          219792     189336

where previously we saved/restored for PCH those 130832+81568 bytes, now we
save/restore just 10064+20392 bytes, so this change is beneficial for the
data section size.

Unfortunately, it grows the size of the rs6000_init_generated_builtins
function, vanilla had 218328 bytes, patched has 228668.

When I applied
 void
 rs6000_init_generated_builtins ()
 {
+  bifdata *rs6000_builtin_info_p;
+  tree *rs6000_builtin_info_fntype_p;
+  ovlddata *rs6000_instance_info_p;
+  tree *rs6000_instance_info_fntype_p;
+  ovldrecord *rs6000_overload_info_p;
+  __asm ("" : "=r" (rs6000_builtin_info_p) : "0" (rs6000_builtin_info));
+  __asm ("" : "=r" (rs6000_builtin_info_fntype_p) : "0" (rs6000_builtin_info_fntype));
+  __asm ("" : "=r" (rs6000_instance_info_p) : "0" (rs6000_instance_info));
+  __asm ("" : "=r" (rs6000_instance_info_fntype_p) : "0" (rs6000_instance_info_fntype));
+  __asm ("" : "=r" (rs6000_overload_info_p) : "0" (rs6000_overload_info));
+  #define rs6000_builtin_info rs6000_builtin_info_p
+  #define rs6000_builtin_info_fntype rs6000_builtin_info_fntype_p
+  #define rs6000_instance_info rs6000_instance_info_p
+  #define rs6000_instance_info_fntype rs6000_instance_info_fntype_p
+  #define rs6000_overload_info rs6000_overload_info_p
+
hack by hand, the size of the function is 209700 though, so if really
wanted, we could add __attribute__((__noipa__)) to the function when
building with recent enough GCC and pass pointers to the first elements
of the 5 arrays to the function as arguments.  If you want such a change,
could that be done incrementally?

2024-06-03  Jakub Jelinek  <jakub@redhat.com>

	PR target/115324
	* config/rs6000/rs6000-gen-builtins.cc (write_decls): Remove
	GTY markup from struct bifdata and struct ovlddata and remove their
	fntype members.  Change next member in struct ovlddata and
	first_instance member of struct ovldrecord to have int type rather
	than struct ovlddata *.  Remove GTY markup from rs6000_builtin_info
	and rs6000_instance_info arrays, declare new
	rs6000_builtin_info_fntype and rs6000_instance_info_fntype arrays,
	which have GTY markup.
	(write_bif_static_init): Adjust for the above changes.
	(write_ovld_static_init): Likewise.
	(write_init_bif_table): Likewise.
	(write_init_ovld_table): Likewise.
	* config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Likewise.
	* config/rs6000/rs6000-c.cc (find_instance): Likewise.  Make static.
	(altivec_resolve_overloaded_builtin): Adjust for the above changes.

(cherry picked from commit 4cf2de9b52)
2024-06-04 16:19:12 +02:00
Jakub Jelinek 14a7296d04 combine: Fix up simplify_compare_const [PR115092]
The following testcases are miscompiled (with tons of GIMPLE
optimization disabled) because combine sees GE comparison of
1-bit sign_extract (i.e. something with [-1, 0] value range)
with (const_int -1) (which is always true) and optimizes it into
NE comparison of 1-bit zero_extract ([0, 1] value range) against
(const_int 0).
The reason is that simplify_compare_const first (correctly)
simplifies the comparison to
GE (ashift:SI something (const_int 31)) (const_int -2147483648)
and then an optimization for when the second operand is power of 2
triggers.  That optimization is fine for power of 2s which aren't
the signed minimum of the mode, or if it is NE, EQ, GEU or LTU
against the signed minimum of the mode, but for GE or LT optimizing
it into NE (or EQ) against const0_rtx is wrong, those cases
are always true or always false (but the function doesn't have
a standardized way to tell callers the comparison is now unconditional).

The following patch just disables the optimization in that case.

2024-05-15  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/114902
	PR rtl-optimization/115092
	* combine.cc (simplify_compare_const): Don't optimize
	GE op0 SIGNED_MIN or LT op0 SIGNED_MIN into NE op0 const0_rtx or
	EQ op0 const0_rtx.

	* gcc.dg/pr114902.c: New test.
	* gcc.dg/pr115092.c: New test.

(cherry picked from commit 0b93a0ae15)
2024-06-04 16:18:14 +02:00
Rainer Orth e80523288c testsuite: gm2: Remove timeout overrides [PR114886]
A large number of gm2 tests are timing out even on current Solaris/SPARC
systems.  As detailed in the PR, the problem is that the gm2 testsuite
artificially lowers many timeouts way below the DejaGnu default of 300
seconds, often as short as 10 seconds.  The problem lies both in the
values (they may be appropriate for some targets, but too low for
others, especially under high load) and the fact that it uses absolute
values, overriding e.g. settings from a build-wide site.exp.

Therefore this patch removes all those overrides, restoring the
defaults.

Tested on sparc-sun-solaris2.11 (where all the previous timeouts are
gone) and i386-pc-solaris2.11.

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

	gcc/testsuite:
	PR modula2/114886
	* lib/gm2.exp: Don't load timeout-dg.exp.
	Don't set gm2_previous_timeout.
	Don't call dg-timeout.
	(gm2_push_timeout, gm2_pop_timeout): Remove.
	(gm2_init): Don't call dg-timeout.
	* lib/gm2-torture.exp: Don't load timeout-dg.exp.
	Don't set gm2_previous_timeout.
	Don't call dg-timeout.
	(gm2_push_timeout, gm2_pop_timeout): Remove.

	* gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp: Don't
	load timeout-dg.exp.
	Don't call gm2_push_timeout, gm2_pop_timeout.
	* gm2/examples/map/pass/examples-map-pass.exp: Don't call
	gm2_push_timeout, gm2_pop_timeout.
	* gm2/iso/run/pass/iso-run-pass.exp: Don't load timeout-dg.exp.
	Don't call gm2_push_timeout, gm2_pop_timeout.
	* gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp: Don't load
	timeout-dg.exp.
	Don't call gm2_push_timeout, gm2_pop_timeout.
	* gm2/projects/iso/run/pass/halma/projects-iso-run-pass-halma.exp:
	Don't call gm2_push_timeout, gm2_pop_timeout.
	* gm2/switches/whole-program/pass/run/switches-whole-program-pass-run.exp:
	Don't load timeout-dg.exp.
	Don't call gm2_push_timeout, gm2_pop_timeout.

(cherry picked from commit aff63ac110)
2024-06-04 09:12:28 +02:00
Rainer Orth d92b508dd1 libstdc++: Build libbacktrace and 19_diagnostics/stacktrace with -funwind-tables [PR111641]
Several of the 19_diagnostics/stacktrace tests FAIL on Solaris/SPARC (32
and 64-bit), Solaris/x86 (32-bit only), and several other targets:

FAIL: 19_diagnostics/stacktrace/current.cc  -std=gnu++23 execution test
FAIL: 19_diagnostics/stacktrace/current.cc  -std=gnu++26 execution test
FAIL: 19_diagnostics/stacktrace/entry.cc  -std=gnu++23 execution test
FAIL: 19_diagnostics/stacktrace/entry.cc  -std=gnu++26 execution test
FAIL: 19_diagnostics/stacktrace/output.cc  -std=gnu++23 execution test
FAIL: 19_diagnostics/stacktrace/output.cc  -std=gnu++26 execution test
FAIL: 19_diagnostics/stacktrace/stacktrace.cc  -std=gnu++23 execution test
FAIL: 19_diagnostics/stacktrace/stacktrace.cc  -std=gnu++26 execution test

As it turns out, both the copy of libbacktrace in libstdc++ and the
testcases proper need to compiled with -funwind-tables, as is done for
libbacktrace itself.

This isn't an issue on Linux/x86_64 and Solaris/amd64 since 64-bit x86
always defaults to -funwind-tables.  32-bit x86 does, too, when
-fomit-frame-pointer is enabled as on Linux/i686, but unlike
Solaris/i386.

So this patch always enables the option both for the libbacktrace copy
and the testcases.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2024-05-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	PR libstdc++/111641
	* src/libbacktrace/Makefile.am (AM_CFLAGS): Add -funwind-tables.
	* src/libbacktrace/Makefile.in: Regenerate.

	* testsuite/19_diagnostics/stacktrace/current.cc (dg-options): Add
	-funwind-tables.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/hash.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/output.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.

(cherry picked from commit a99ebb88f8)
2024-06-04 09:10:24 +02:00
GCC Administrator b2bbf9890e Daily bump. 2024-06-04 00:23:13 +00:00
François Dumont 955202eb2c libstdc++: Fix -Wstringop-overflow warning coming from std::vector [PR109849]
libstdc++-v3/ChangeLog:

	PR libstdc++/109849
	* include/bits/vector.tcc
	(std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt,
	forward_iterator_tag))[__cplusplus < 201103L]: Add __builtin_unreachable
	expression to tell the compiler that the allocated buffer is large enough to
	receive current elements plus the elements of the range to insert.

(cherry picked from commit 0426be4544)
2024-06-03 21:52:58 +02:00
Haochen Jiang 97474ba207 Add AVX10.1 target_clones support
Since AVX10 is the first major ISA introduced after AVX-512, we propose
to add target_clones support for it.

Although AVX10.1-256 won't cover 512-bit part of AVX512F, but since
it is only for priority but not for implication, it won't be an issue.

gcc/ChangeLog:

	* common/config/i386/i386-common.cc: Change Granite Rapids
	series CPU type to P_PROC_AVX10_1_512.
	* common/config/i386/i386-cpuinfo.h (enum feature_priority):
	Revise comment part. Add P_AVX10_1_256, P_AVX10_1_512,
	P_PROC_AVX10_1_512.
	* common/config/i386/i386-isas.h: Link to avx10.1-256, avx10.1-512.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx10_1-25.c: New test.
	* gcc.target/i386/avx10_1-26.c: Ditto.
2024-06-03 14:53:58 +08:00
GCC Administrator 1dbf796579 Daily bump. 2024-06-03 00:22:58 +00:00
GCC Administrator a31676a5d0 Daily bump. 2024-06-02 00:22:52 +00:00
Georg-Johann Lay d7f42794d9 AVR: target/115317 - Make isinf(-Inf) return -1.
PR target/115317
libgcc/config/avr/libf7/
	* libf7-asm.sx (__isinf): Map -Inf to -1.

gcc/testsuite/
	* gcc.target/avr/torture/pr115317-isinf.c: New test.

(cherry picked from commit f12454278d)
2024-06-01 12:52:26 +02:00
Jonathan Wakely 2f097c0b3f libstdc++: Replace link to gcc-4.3.2 docs in manual [PR115269]
Link to the docs for GCC trunk instead. For the release branches, the
link should be to the docs for appropriate release branch.

Also replace the incomplete/outdated list of explicit -std options with
a single entry for the -std option.

libstdc++-v3/ChangeLog:

	PR libstdc++/115269
	* doc/xml/manual/using.xml: Replace link to gcc-4.3.2 docs.
	Replace list of -std=... options with a single entry for -std.
	* doc/html/manual/using.html: Regenerate.

(cherry picked from commit b460ede64f)
2024-06-01 11:01:37 +01:00
Georg-Johann Lay 9d08c55f7c AVR: tree-optimization/115307 - Work around isinf bloat from early passes.
PR tree-optimization/115307
gcc/
	* config/avr/avr.md (SFDF): New mode iterator.
	(isinf<mode>2) [sf, df]: New expanders.

gcc/testsuite/
	* gcc.target/avr/torture/pr115307-isinf.c: New test.

(cherry picked from commit fabb545026)
2024-06-01 10:55:49 +02:00
GCC Administrator 5ca4e161b6 Daily bump. 2024-06-01 00:22:30 +00:00
Uros Bizjak ec92744de5 alpha: Fix invalid RTX in divmodsi insn patterns [PR115297]
any_divmod instructions are modelled with invalid RTX:

  [(set (match_operand:DI 0 "register_operand" "=c")
        (sign_extend:DI (match_operator:SI 3 "divmod_operator"
                        [(match_operand:DI 1 "register_operand" "a")
                         (match_operand:DI 2 "register_operand" "b")])))
   (clobber (reg:DI 23))
   (clobber (reg:DI 28))]

where SImode divmod_operator (div,mod,udiv,umod) has DImode operands.

Wrap input operand with truncate:SI to make machine modes consistent.

	PR target/115297

gcc/ChangeLog:

	* config/alpha/alpha.md (<any_divmod:code>si3): Wrap DImode
	operands 3 and 4 with truncate:SI RTX.
	(*divmodsi_internal_er): Ditto for operands 1 and 2.
	(*divmodsi_internal_er_1): Ditto.
	(*divmodsi_internal): Ditto.
	* config/alpha/constraints.md ("b"): Correct register
	number in the description.

gcc/testsuite/ChangeLog:

	* gcc.target/alpha/pr115297.c: New test.

(cherry picked from commit 0ac802064c)
2024-05-31 15:53:15 +02:00
Richard Sandiford 36575f5fe4 vect: Fix access size alignment assumption [PR115192]
create_intersect_range_checks checks whether two access ranges
a and b are alias-free using something equivalent to:

  end_a <= start_b || end_b <= start_a

It has two ways of doing this: a "vanilla" way that calculates
the exact exclusive end pointers, and another way that uses the
last inclusive aligned pointers (and changes the comparisons
accordingly).  The comment for the latter is:

      /* Calculate the minimum alignment shared by all four pointers,
	 then arrange for this alignment to be subtracted from the
	 exclusive maximum values to get inclusive maximum values.
	 This "- min_align" is cumulative with a "+ access_size"
	 in the calculation of the maximum values.  In the best
	 (and common) case, the two cancel each other out, leaving
	 us with an inclusive bound based only on seg_len.  In the
	 worst case we're simply adding a smaller number than before.

The problem is that the associated code implicitly assumed that the
access size was a multiple of the pointer alignment, and so the
alignment could be carried over to the exclusive end pointer.

The testcase started failing after g:9fa5b473b5b8e289b6542
because that commit improved the alignment information for
the accesses.

gcc/
	PR tree-optimization/115192
	* tree-data-ref.cc (create_intersect_range_checks): Take the
	alignment of the access sizes into account.

gcc/testsuite/
	PR tree-optimization/115192
	* gcc.dg/vect/pr115192.c: New test.

(cherry picked from commit a0fe4fb1c8)
2024-05-31 08:22:55 +01:00
Hongyu Wang cd161b335c i386: Fix ix86_option override after change [PR 113719]
In ix86_override_options_after_change, calls to ix86_default_align
and ix86_recompute_optlev_based_flags will cause mismatched target
opt_set when doing cl_optimization_restore. Move them back to
ix86_option_override_internal to solve the issue.

gcc/ChangeLog:

	PR target/113719
	* config/i386/i386-options.cc (ix86_override_options_after_change):
	Remove call to ix86_default_align and
	ix86_recompute_optlev_based_flags.
	(ix86_option_override_internal): Call ix86_default_align and
	ix86_recompute_optlev_based_flags.

(cherry picked from commit 499d00127d)
2024-05-31 11:09:40 +08:00
GCC Administrator 06333a181d Daily bump. 2024-05-31 00:23:20 +00:00
YunQiang Su 201cfa7255 MIPS16: Mark $2/$3 as clobbered if GP is used
PR Target/84790.
The gp init sequence
        li      $2,%hi(_gp_disp)
        addiu   $3,$pc,%lo(_gp_disp)
        sll     $2,16
        addu    $2,$3
is generated directly in `mips_output_function_prologue`, and does
not appear in the RTL.

So the IRA/IPA passes are not aware that $2/$3 have been clobbered,
so they may be used for cross (local) function call.

Let's mark $2/$3 clobber both:
  - Just after the UNSPEC_GP RTL of a function;
  - Just after a function call.

Reported-by: Matthias Schiffer <mschiffer@universe-factory.net>
Origin-Patch-by: Felix Fietkau <nbd@nbd.name>.

gcc
	* config/mips/mips.cc(mips16_gp_pseudo_reg): Mark
	MIPS16_PIC_TEMP and MIPS_PROLOGUE_TEMP clobbered.
	(mips_emit_call_insn): Mark MIPS16_PIC_TEMP and
	MIPS_PROLOGUE_TEMP clobbered if MIPS16 and CALL_CLOBBERED_GP.

(cherry picked from commit 915440eed2)
2024-05-30 09:48:08 +08:00
GCC Administrator 8f6c56cda5 Daily bump. 2024-05-30 00:23:02 +00:00
Eric Botcazou fba2843b9b Fix link failure of GNAT tools on 32-bit SPARC/Linux
There is an incorrect binding to the 64-bit compare-and-exchange builtin.

gcc/ada/
	PR ada/115270
	* Makefile.rtl (PowerPC/Linux): Use libgnat/s-atopri__32.ads for
	the 32-bit library.
	(SPARC/Linux): Likewise.
2024-05-29 12:11:22 +02:00
Richard Biener 90a447677a tree-optimization/115149 - VOP live and missing PHIs
The following fixes a bug in vop-live get_live_in which was using
NULL to indicate the first processed edge but at the same time
using it for the case the live-in virtual operand cannot be computed.
The following fixes this, avoiding sinking a load to a place where
we'd have to insert virtual PHIs to make the virtual operand SSA
web OK.

	PR tree-optimization/115149
	* tree-ssa-live.cc (virtual_operand_live::get_live_in):
	Explicitly track the first processed edge.

	* gcc.dg/pr115149.c: New testcase.

(cherry picked from commit ec9b8bafe2)
2024-05-29 08:29:25 +02:00
Richard Biener 2a1fdd5fd0 tree-optimization/115197 - fix ICE w/ constant in LC PHI and loop distribution
Forgot a check for an SSA name before trying to replace a PHI arg with
its current definition.

	PR tree-optimization/115197
	* tree-loop-distribution.cc (copy_loop_before): Constant PHI
	args remain the same.

	* gcc.dg/pr115197.c: New testcase.

(cherry picked from commit 2b2476d4d1)
2024-05-29 08:29:25 +02:00
Richard Biener 9e971c671d tree-optimization/114921 - _Float16 -> __bf16 isn't noop fixup
The following further strengthens the check which convert expressions
we allow to vectorize as simple copy by resorting to
tree_nop_conversion_p on the vector components.

	PR tree-optimization/114921
	* tree-vect-stmts.cc (vectorizable_assignment): Use
	tree_nop_conversion_p to identify converts we can vectorize
	with a simple assignment.

(cherry picked from commit d0d6dcc019)
2024-05-29 08:29:25 +02:00
liuhongt b4d4ece044 Align tight&hot loop without considering max skipping bytes.
When hot loop is small enough to fix into one cacheline, we should align
the loop with ceil_log2 (loop_size) without considering maximum
skipp bytes. It will help code prefetch.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_avoid_jump_mispredicts): Change
	gen_pad to gen_max_skip_align.
	(ix86_align_loops): New function.
	(ix86_reorg): Call ix86_align_loops.
	* config/i386/i386.md (pad): Rename to ..
	(max_skip_align): .. this, and accept 2 operands for align and
	skip.
2024-05-29 11:12:51 +08:00
Haochen Jiang 80600352d1 Adjust generic loop alignment from 16:11:8 to 16 for Intel processors
Previously, we use 16:11:8 in generic tune for Intel processors, which
lead to cross cache line issue and result in some random performance
penalty in benchmarks with small loops commit to commit.

After changing to always aligning to 16 bytes, it will somehow solve
the issue.

gcc/ChangeLog:

	* config/i386/x86-tune-costs.h (generic_cost): Change from
	16:11:8 to 16.
2024-05-29 11:12:37 +08:00
GCC Administrator e2b66da9bd Daily bump. 2024-05-29 00:23:15 +00:00
Tobias Burnus dbeb3d127d Fortran: Fix SHAPE for zero-size arrays
PR fortran/115150

gcc/fortran/ChangeLog:

	* trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
	for zero-size arrays

gcc/testsuite/ChangeLog:

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

(cherry picked from commit b701306a9b)
2024-05-28 12:59:46 +02:00
Jonathan Wakely 89dff1488e libstdc++: Guard use of sized deallocation [PR114940]
Clang does not enable -fsized-deallocation by default, which means it
can't compile our <stacktrace> and <generator> headers.

Make the __cpp_lib_generator macro depend on the compiler-defined
__cpp_sized_deallocation macro, and change <stacktrace> to use unsized
deallocation when __cpp_sized_deallocation isn't defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/114940
	* include/bits/version.def (generator): Depend on
	__cpp_sized_deallocation.
	* include/bits/version.h: Regenerate.
	* include/std/stacktrace (_GLIBCXX_SIZED_DELETE): New macro.
	(basic_stacktrace::_Impl::_M_deallocate): Use it.

(cherry picked from commit b2fdd508d7)
2024-05-28 10:19:44 +01:00
Xi Ruoyao e78980fdd5 LoongArch: Guard REGNO with REG_P in loongarch_expand_conditional_move [PR115169]
gcc/ChangeLog:

	PR target/115169
	* config/loongarch/loongarch.cc
	(loongarch_expand_conditional_move): Guard REGNO with REG_P.

(cherry picked from commit ded91d8577)
2024-05-28 09:34:32 +08:00
GCC Administrator 133da68a4c Daily bump. 2024-05-28 00:21:29 +00:00
Richard Biener 4790076933 tree-optimization/115232 - demangle failure during -Waccess
For the following testcase we fail to demangle
_ZZN5OuterIvE6methodIvEEvvQ3cstITL0__EEN5InnernwEm and
_ZZN5OuterIvE6methodIvEEvvQ3cstITL0__EEN5InnerdlEPv and in turn end
up building NULL references.  The following puts in a safeguard for
faile demangling into -Waccess.

	PR tree-optimization/115232
	* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
	failure to demangle gracefully.

	* g++.dg/pr115232.C: New testcase.

(cherry picked from commit 311d7f5c17)
2024-05-27 11:24:48 +02:00
GCC Administrator 0cae44a288 Daily bump. 2024-05-27 00:21:39 +00:00
GCC Administrator 2e0f832cf7 Daily bump. 2024-05-26 00:22:08 +00:00
Harald Anlauf b0b21d5bdf Fortran: fix bounds check for assignment, class component [PR86100]
gcc/fortran/ChangeLog:

	PR fortran/86100
	* trans-array.cc (gfc_conv_ss_startstride): Use abridged_ref_name
	to generate a more user-friendly name for bounds-check messages.
	* trans-expr.cc (gfc_copy_class_to_class): Fix bounds check for
	rank>1 by looping over the dimensions.

gcc/testsuite/ChangeLog:

	PR fortran/86100
	* gfortran.dg/bounds_check_25.f90: New test.

(cherry picked from commit 9376573681)
2024-05-25 20:07:45 +02:00
GCC Administrator cab894172d Daily bump. 2024-05-25 00:22:08 +00:00
Jason Merrill 9031c02782 c++: deleting array temporary [PR115187]
Decaying the array temporary to a pointer and then deleting that crashes in
verify_gimple_stmt, because the TARGET_EXPR is first evaluated inside the
TRY_FINALLY_EXPR, but the cleanup point is outside.  Fixed by using
get_target_expr instead of save_expr.

I also adjust the stabilize_expr comment to prevent me from again thinking
it's a suitable replacement.

	PR c++/115187

gcc/cp/ChangeLog:

	* init.cc (build_delete): Use get_target_expr instead of save_expr.
	* tree.cc (stabilize_expr): Update comment.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/array-prvalue3.C: New test.
2024-05-24 11:15:13 -04:00
Nathaniel Shead 782ad2033e c++: Propagate using decls from partitions [PR114868]
The modules code currently neglects to set OVL_USING_P on the dependency
created for a using-decl, which causes it not to remember that the
OVL_EXPORT_P flag had been set on it when emitted from the primary
interface unit. This patch ensures that it occurs.

	PR c++/114868

gcc/cp/ChangeLog:

	* module.cc (depset::hash::add_binding_entity): Propagate
	OVL_USING_P for using-declarations.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/using-15_a.C: New test.
	* g++.dg/modules/using-15_b.C: New test.
	* g++.dg/modules/using-15_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit 0d0215b10d)
2024-05-25 00:32:35 +10:00
Nathaniel Shead fd6fd88b1a c++: Fix instantiation of imported temploid friends [PR114275]
This patch fixes a number of issues with the handling of temploid friend
declarations.

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

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

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

(cherry-picked from commits b5f6a56940 and
ec2365e075)

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

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-05-25 00:16:59 +10:00
Nathaniel Shead 557cddcc71 c++: Standardise errors for module_may_redeclare
Currently different places calling 'module_may_redeclare' all emit very
similar but slightly different error messages, and handle different
kinds of declarations differently.  This patch makes the function
perform its own error messages so that they're all in one place, and
prepares it for use with temploid friends.

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 2faf040335)
2024-05-25 00:16:59 +10:00
GCC Administrator 5429e6a646 Daily bump. 2024-05-24 00:22:34 +00:00
Martin Jambor 1a6c1c85b7 sra: Do not leave work for DSE (that it can sometimes not perform)
When looking again at the g++.dg/tree-ssa/pr109849.C testcase we
discovered that it generates terrible store-to-load forwarding stalls
because SRA was leaving behind aggregate loads but all the stores were
by scalar parts and DSE failed to remove the useless load.  SRA has
all the knowledge to remove the statement even now, so this small
patch makes it do so.

With this patch, the g++.dg/tree-ssa/pr109849.C micro-benchmark runs 9
times faster (on an AMD EPYC 75F3 machine).

gcc/ChangeLog:

2024-04-18  Martin Jambor  <mjambor@suse.cz>

	* tree-sra.cc (sra_modify_assign): Remove the original statement
	also when dealing with a store to a fully covered aggregate from a
	non-candidate.

gcc/testsuite/ChangeLog:

2024-04-23  Martin Jambor  <mjambor@suse.cz>

	* g++.dg/tree-ssa/pr109849.C: Also check that the aggeegate store
	to cur disappears.
	* gcc.dg/tree-ssa/ssa-dse-26.c: Instead of relying on DSE,
	check that the unwanted stores were removed at early SRA time.

(cherry picked from commit f6743695b4)
2024-05-23 18:42:01 +02:00
GCC Administrator 137e7a86a4 Daily bump. 2024-05-23 00:22:09 +00:00
Marek Polacek c27d6c7fd0 c++: failure to suppress -Wsizeof-array-div in template [PR114983]
-Wsizeof-array-div offers a way to suppress the warning by wrapping
the second operand of the division in parens:

  sizeof (samplesBuffer) / (sizeof(unsigned char))

but this doesn't work in a template, because we fail to propagate
the suppression bits.  Do it, then.

The finish_parenthesized_expr hunk is not needed because suppress_warning
isn't very fine-grained.  But I think it makes sense to be explicit and
not rely on OPT_Wparentheses also suppressing OPT_Wsizeof_array_div.

	PR c++/114983

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr) <case SIZEOF_EXPR>: Use copy_warning.
	* semantics.cc (finish_parenthesized_expr): Also suppress
	-Wsizeof-array-div.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wsizeof-array-div3.C: New test.

(cherry picked from commit 646db3d30b)
2024-05-22 18:19:55 -04:00
Torbjörn SVENSSON da3a6b0dda testsuite: Verify r0-r3 are extended with CMSE
Add regression test to the existing zero/sign extend tests for CMSE to
verify that r0, r1, r2 and r3 are properly extended, not just r0.

boolCharShortEnumSecureFunc test is done using -O0 to ensure the
instructions are in a predictable order.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/cmse/extend-param.c: Add regression test. Add
	-fshort-enums.
	* gcc.target/arm/cmse/extend-return.c: Add -fshort-enums option.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>

(cherry picked from commit 9ddad76e98)
2024-05-22 21:38:50 +02:00
Eric Botcazou 2f0e086240 Fix internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
The problem directly comes from the -ffold-mem-offsets pass messing up with
the prologue and the frame-related instructions, which is a no-no with SEH,
so the fix simply disconnects the pass in these circumstances.

gcc/
	PR rtl-optimization/115038
	* fold-mem-offsets.cc (fold_offsets): Return 0 if the defining
	instruction of the register is frame related.

gcc/testsuite/
	* g++.dg/opt/fmo1.C: New test.
2024-05-22 20:54:11 +02:00
Jonathan Wakely 4896bb3199 libstdc++: Implement std::formatter<std::thread::id> without <sstream> [PR115099]
The std::thread::id formatter uses std::basic_ostringstream without
including <sstream>, which went unnoticed because the test for it uses
a stringstream to check the output is correct.

The fix implemented here is to stop using basic_ostringstream for
formatting thread::id and just use std::format instead.

As a drive-by fix, the formatter specialization is constrained to
require that the thread::id::native_handle_type can be formatted, to
avoid making the formatter ill-formed if the pthread_t type is not a
pointer or integer. Since non-void pointers can't be formatted, ensure
that we convert pointers to const void* for formatting. Make a similar
change to the existing operator<< overload so that in the unlikely case
that pthread_t is a typedef for char* we don't treat it as a
null-terminated string when inserting into a stream.

libstdc++-v3/ChangeLog:

	PR libstdc++/115099
	* include/bits/std_thread.h: Declare formatter as friend of
	thread::id.
	* include/std/thread (operator<<): Convert non-void pointers to
	void pointers for output.
	(formatter): Add constraint that thread::native_handle_type is a
	pointer or integer.
	(formatter::format): Reimplement without basic_ostringstream.
	* testsuite/30_threads/thread/id/output.cc: Check output
	compiles before <sstream> has been included.

(cherry picked from commit 1a5e4dd837)
2024-05-22 10:06:52 +01:00
Jakub Jelinek fc9fb69ad6 strlen: Fix up !si->full_string_p handling in count_nonzero_bytes_addr [PR115152]
The following testcase is miscompiled because
strlen_pass::count_nonzero_bytes_addr doesn't handle correctly
the !si->full_string_p case.
If si->full_string_p, it correctly computes minlen and maxlen as
minimum and maximum length of the '\0' terminated stgring and
clears *nulterm (ie. makes sure !full_string_p in the ultimate
caller) if minlen is equal or larger than nbytes and so
'\0' isn't guaranteed to be among those bytes.
But in the !si->full_string_p case, all we know is that there
are [minlen,maxlen] non-zero bytes followed by unknown bytes,
so effectively the maxlen is infinite (but caller cares about only
the first nbytes bytes) and furthermore, we never know if there is
any '\0' char among those, so *nulterm needs to be always cleared.

2024-05-22  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/115152
	* tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes_addr): If
	!si->full_string_p, clear *nulterm and set maxlen to nbytes.

	* gcc.dg/pr115152.c: New test.

(cherry picked from commit dbc9b45a3c)
2024-05-22 09:19:01 +02:00
Jakub Jelinek d224c7d8d8 ubsan: Use right address space for MEM_REF created for bool/enum sanitization [PR115172]
The following testcase is miscompiled, because -fsanitize=bool,enum
creates a MEM_REF without propagating there address space qualifiers,
so what should be normally loaded using say %gs:/%fs: segment prefix
isn't.  Together with asan it then causes that load to be sanitized.

2024-05-22  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/115172
	* ubsan.cc (instrument_bool_enum_load): If rhs is not in generic
	address space, use qualified version of utype with the right
	address space.  Formatting fix.

	* gcc.dg/asan/pr115172.c: New test.

(cherry picked from commit d3c506eff5)
2024-05-22 09:19:00 +02:00
Haochen Jiang 1ad5c9d524 i386: Disable ix86_expand_vecop_qihi2 when !TARGET_AVX512BW
Since vpermq is really slow, we should avoid using it for permutation
when vpmovwb is not available (needs AVX512BW) for ix86_expand_vecop_qihi2
and fall back to ix86_expand_vecop_qihi.

gcc/ChangeLog:

	PR target/115069
	* config/i386/i386-expand.cc (ix86_expand_vecop_qihi2):
	Do not enable the optimization when AVX512BW is not enabled.

gcc/testsuite/ChangeLog:

	PR target/115069
	* gcc.target/i386/pr115069.c: New.
2024-05-22 10:26:42 +08:00
GCC Administrator d2f4279516 Daily bump. 2024-05-22 00:22:39 +00:00
Jonathan Wakely 5b96d547ce c++: Fix std dialect hint for std::to_address [PR107800]
The correct dialect for std::to_address is cxx20 not cxx11.

gcc/cp/ChangeLog:

	PR libstdc++/107800
	* cxxapi-data.csv <to_address>: Change dialect to cxx20.
	* std-name-hint.gperf: Regenerate.
	* std-name-hint.h: Regenerate.

(cherry picked from commit 826a7d3d19)
2024-05-21 22:02:57 +01:00
Patrick Palka caf43cc9e5 c++: folding non-dep enumerator from current inst [PR115139]
After the tsubst_copy removal r14-4796-g3e3d73ed5e85e7 GCC 14 ICEs during
fold_non_dependent_expr for 'e1 | e2' below ultimately because we no
longer exit early when substituting the CONST_DECLs for e1 and e2 with
args=NULL_TREE and instead proceed to substitute the class context A<Ts...>
(also with args=NULL_TREE) which ends up ICEing from tsubst_pack_expansion
(due to processing_template_decl being cleared).

Incidentally, the ICE went away on trunk ever since the tsubst_aggr_type
removal r15-123-gf04dc89a991ddc since it changed the CONST_DECL case of
tsubst_expr to use tsubst to substitute the context, which short circuits
for empty args and so avoids the ICE.

This patch fixes this ICE for GCC 14 by narrowly restoring the early exit
for empty args that would've happened in tsubst_copy when substituting an
enumerator CONST_DECL.  We might as well apply this to trunk too, as a
small optimization.

	PR c++/115139

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr) <case CONST_DECL>: Exit early if args
	is empty.

gcc/testsuite/ChangeLog:

	* g++.dg/template/non-dependent33.C: New test.

Reviewed-by: Marek Polacek <mpolacek@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit f0c0bced62)
2024-05-21 15:55:26 -04:00
Harald Anlauf edde60a53c Fortran: fix dependency checks for inquiry refs [PR115039]
gcc/fortran/ChangeLog:

	PR fortran/115039
	* expr.cc (gfc_traverse_expr): An inquiry ref does not constitute
	a dependency and cannot collide with a symbol.

gcc/testsuite/ChangeLog:

	PR fortran/115039
	* gfortran.dg/statement_function_5.f90: New test.

(cherry picked from commit d4974fd227)
2024-05-21 21:01:40 +02:00
Andrew Pinski b2bb49d6a7 match: Disable (type)zero_one_valuep*CST for 1bit signed types [PR115154]
The problem here is the pattern added in r13-1162-g9991d84d2a8435
assumes that it is well defined to multiply zero_one_valuep by the truncated
converted integer constant. It is well defined for all types except for signed 1bit types.
Where `a * -1` is produced which is undefined/
So disable this pattern for 1bit signed types.

Note the pattern added in r14-3432-gddd64a6ec3b38e is able to workaround the undefinedness except when
`-fsanitize=undefined` is turned on, this is why I added a testcase for that.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR tree-optimization/115154

gcc/ChangeLog:

	* match.pd (convert (mult zero_one_valued_p@1 INTEGER_CST@2)): Disable
	for 1bit signed types.

gcc/testsuite/ChangeLog:

	* c-c++-common/ubsan/signed1bitfield-1.c: New test.
	* gcc.c-torture/execute/signed1bitfield-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 49c87d2253)
2024-05-21 07:25:30 -07:00
GCC Administrator 786597185d Daily bump. 2024-05-21 01:18:26 +00:00
Andrew Pinski 89ab128656 PHIOPT: Don't transform minmax if middle bb contains a phi [PR115143]
The problem here is even if last_and_only_stmt returns a statement,
the bb might still contain a phi node which defines a ssa name
which is used in that statement so we need to add a check to make sure
that the phi nodes are empty for the middle bbs in both the
`CMP?MINMAX:MINMAX` case and the `CMP?MINMAX:B` cases.

Bootstrapped and tested on x86_64_linux-gnu with no regressions.

	PR tree-optimization/115143

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (minmax_replacement): Check for empty
	phi nodes for middle bbs for the case where middle bb is not empty.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/compile/pr115143-1.c: New test.
	* gcc.c-torture/compile/pr115143-2.c: New test.
	* gcc.c-torture/compile/pr115143-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 9ff8f04133)
2024-05-20 14:56:11 -07:00
Patrick Palka a983793420 c++: aggregate CTAD w/ paren init and bases [PR115114]
During aggregate CTAD with paren init, we're accidentally overlooking
base classes since TYPE_FIELDS of a template type doesn't contain
corresponding base fields.  So we need to consider them separately.

	PR c++/115114

gcc/cp/ChangeLog:

	* pt.cc (maybe_aggr_guide): Consider bases in the paren init case.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-aggr15.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 5aaf47cb19)
2024-05-20 09:51:24 -04:00
Patrick Palka b3399b445b c++: lvalueness of non-dependent assignment expr [PR114994]
r14-4111-g6e92a6a2a72d3b made us check non-dependent simple assignment
expressions ahead of time and give them a type, as was already done for
compound assignments.  Unlike for compound assignments however, if a
simple assignment resolves to an operator overload we represent it as a
(typed) MODOP_EXPR instead of a CALL_EXPR to the selected overload.
(I reckoned this was at worst a pessimization -- we'll just have to repeat
overload resolution at instantiatiation time.)

But this turns out to break the below testcase ultimately because
MODOP_EXPR (of non-reference type) is always treated as an lvalue
according to lvalue_kind, which is incorrect for the MODOP_EXPR
representing x=42.

We can fix this by representing such class assignment expressions as
CALL_EXPRs as well, but this turns out to require some tweaking of our
-Wparentheses warning logic and may introduce other fallout making it
unsuitable for backporting.

So this patch instead fixes lvalue_kind to consider the type of a
MODOP_EXPR representing a class assignment.

	PR c++/114994

gcc/cp/ChangeLog:

	* tree.cc (lvalue_kind) <case MODOP_EXPR>: For a class
	assignment, consider the result type.

gcc/testsuite/ChangeLog:

	* g++.dg/template/non-dependent32.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit c6cc6d4741)
2024-05-20 09:51:23 -04:00
GCC Administrator 2502ac4b2e Daily bump. 2024-05-20 01:10:46 +00:00
GCC Administrator a7240b0bde Daily bump. 2024-05-19 19:09:01 +00:00
Wolfgang Hospital 3b88dade7f AVR: target/115065 - Tweak __clzhi2.
The libgcc implementation of __clzhi2 can be tweaked by
one cycle in some situations by re-arranging the instructions.
It also reduces the WCET by 1 cycle.

libgcc/
	PR target/115065
	* config/avr/lib1funcs.S (__clzhi2): Tweak.

(cherry picked from commit 988838da72)
2024-05-18 15:14:58 +02:00
Paul Thomas c887341432 Fortran: Fix select type regression due to r14-9489 [PR114874]
2024-05-17  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/114874
	* gfortran.h: Add 'assoc_name_inferred' to gfc_namespace.
	* match.cc (gfc_match_select_type): Set 'assoc_name_inferred'
	in select type namespace if the selector has inferred type.
	* primary.cc (gfc_match_varspec): If a select type temporary
	is apparently scalar and a left parenthesis has been detected,
	check the current namespace has 'assoc_name_inferred' set. If
	so, set inferred_type.
	* resolve.cc (resolve_variable): If the namespace of a select
	type temporary is marked with 'assoc_name_inferred' call
	gfc_fixup_inferred_type_refs to ensure references are OK.
	(gfc_fixup_inferred_type_refs): Catch invalid array refs..

gcc/testsuite/
	PR fortran/114874
	* gfortran.dg/pr114874_1.f90: New test for valid code.
	* gfortran.dg/pr114874_2.f90: New test for invalid code.

(cherry picked from commit 5f5074fe7a)
2024-05-17 15:22:57 +01:00
Jonathan Wakely e909d360df libstdc++: Fix typo in _Grapheme_cluster_view::_Iterator [PR115119]
libstdc++-v3/ChangeLog:

	PR libstdc++/115119
	* include/bits/unicode.h (_Iterator::operator++(int)): Fix typo
	in increment expression.
	* testsuite/ext/unicode/grapheme_view.cc: Check post-increment
	on view's iterator.

(cherry picked from commit c9e05b03c1)
2024-05-17 13:48:43 +01:00
Richard Biener 1e9ae50d4d tree-optimization/114998 - use-after-free with loop distribution
When loop distribution releases a PHI node of the original IL it
can end up clobbering memory that's re-used when it upon releasing
its RDG resets all stmt UIDs back to -1, even those that got released.

The fix is to avoid resetting UIDs based on stmts in the RDG but
instead reset only those still present in the loop.

	PR tree-optimization/114998
	* tree-loop-distribution.cc (free_rdg): Take loop argument.
	Reset UIDs of stmts still in the IL rather than all stmts
	referenced from the RDG.
	(loop_distribution::build_rdg): Pass loop to free_rdg.
	(loop_distribution::distribute_loop): Likewise.
	(loop_distribution::transform_reduction_loop): Likewise.

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

(cherry picked from commit 34d15a4d63)
2024-05-17 11:26:40 +02:00
Joseph Myers 81c627d47c Update gcc sv.po
* sv.po: Update.
2024-05-16 21:21:48 +00:00
GCC Administrator 82e4bdc5c3 Daily bump. 2024-05-16 00:22:15 +00:00
Richard Biener 1d89cb4394 middle-end/114931 - type_hash_canon and structual equality types
TYPE_STRUCTURAL_EQUALITY_P is part of our type system so we have
to make sure to include that into the type unification done via
type_hash_canon.  This requires the flag to be set before querying
the hash which is the biggest part of the patch.

	PR middle-end/114931
gcc/
	* tree.cc (type_hash_canon_hash): Hash TYPE_STRUCTURAL_EQUALITY_P.
	(type_cache_hasher::equal): Compare TYPE_STRUCTURAL_EQUALITY_P.
	(build_array_type_1): Set TYPE_STRUCTURAL_EQUALITY_P before
	probing with type_hash_canon.
	(build_function_type): Likewise.
	(build_method_type_directly): Likewise.
	(build_offset_type): Likewise.
	(build_complex_type): Likewise.
	* attribs.cc (build_type_attribute_qual_variant): Likewise.

gcc/c-family/
	* c-common.cc (complete_array_type): Set TYPE_STRUCTURAL_EQUALITY_P
	before probing with type_hash_canon.

gcc/testsuite/
	* gcc.dg/pr114931.c: New testcase.

(cherry picked from commit b09c2e9560)
2024-05-15 13:40:20 +02:00
Richard Biener 573e1df0ec Avoid changing type in the type_hash_canon hash
When building a type and type_hash_canon returns an existing type
avoid changing it, in particular its TYPE_CANONICAL.

	PR middle-end/114931
	* tree.cc (build_array_type_1): Return early when type_hash_canon
	returned an older existing type.
	(build_function_type): Likewise.
	(build_method_type_directly): Likewise.
	(build_offset_type): Likewise.

(cherry picked from commit 7a212ac678)
2024-05-15 13:40:13 +02:00
GCC Administrator 7c49e45fbf Daily bump. 2024-05-15 00:22:45 +00:00
Jonathan Wakely eefa4c0648 libstdc++: Guard dynamic_cast use in src/c++23/print.cc [PR115015]
Do not use dynamic_cast unconditionally, in case libstdc++ is built with
-fno-rtti.

libstdc++-v3/ChangeLog:

	PR libstdc++/115015
	* src/c++23/print.cc (__open_terminal(streambuf*)) [!__cpp_rtti]:
	Do not use dynamic_cast.
2024-05-14 15:06:56 +01:00
Jonathan Wakely c60205cd4a libstdc++: Fix typo in std::stacktrace::max_size [PR115063]
libstdc++-v3/ChangeLog:

	PR libstdc++/115063
	* include/std/stacktrace (basic_stacktrace::max_size): Fix typo
	in reference to _M_alloc member.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Check
	max_size() compiles.

(cherry picked from commit dd9677f3343ca2a4b4aab9428b8129774accac29)
2024-05-14 10:50:20 +01:00
Jonathan Wakely 4d3b358fd7 libstdc++: Guard uses of is_pointer_interconvertible_v [PR114891]
This type trait isn't supported by Clang 18. It's only used in static
assertions, so they can just be omitted if the trait isn't available.

libstdc++-v3/ChangeLog:

	PR libstdc++/114891
	* include/std/generator: Check feature test macro before using
	is_pointer_interconvertible_v.

(cherry picked from commit 1fbe1a50d8)
2024-05-14 10:50:19 +01:00
Jonathan Wakely 788ccd269e libstdc++: Update ABI test to disallow adding to released symbol versions
If we update the list of "active" symbols versions now, rather than when
adding a new symbol version, we will notice if new symbols get added to
the wrong version (as in PR 114692).

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_abi.cc: Update latest versions to
	new versions that should be used in future.

(cherry picked from commit 6e25ca387f)
2024-05-14 10:50:19 +01:00
Jonathan Wakely b0f022f93a libstdc++: Fix handling of incomplete UTF-8 sequences in _Unicode_view
Eddie Nolan reported to me that _Unicode_view was not correctly
implementing the substitution of ill-formed subsequences with U+FFFD,
due to failing to increment the counter when the iterator reaches the
end of the sequence before a multibyte sequence is complete.  As a
result, the incomplete sequence was not completely consumed, and then
the remaining character was treated as another ill-formed sequence,
giving two U+FFFD characters instead of one.

To avoid similar mistakes in future, this change introduces a lambda
that increments the iterator and the counter together. This ensures the
counter is always incremented when the iterator is incremented, so that
we always know how many characters have been consumed.

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h (_Unicode_view::_M_read_utf8): Ensure
	count of characters consumed is correct when the end of the
	input is reached unexpectedly.
	* testsuite/ext/unicode/view.cc: Test incomplete UTF-8
	sequences.

(cherry picked from commit 3f04f3939e)
2024-05-14 10:50:19 +01:00
Jonathan Wakely 95055199ee libstdc++: Fix <memory> for -std=c++23 -ffreestanding [PR114866]
std::shared_ptr isn't declared for freestanding, so guard uses of it
with #if _GLIBCXX_HOSTED in <bits/out_ptr.h>.

libstdc++-v3/ChangeLog:

	PR libstdc++/114866
	* include/bits/out_ptr.h [!_GLIBCXX_HOSTED]: Don't refer to
	shared_ptr, __shared_ptr or __is_shred_ptr.
	* testsuite/20_util/headers/memory/114866.cc: New test.

(cherry picked from commit 9927059bb8)
2024-05-14 10:50:19 +01:00
GCC Administrator 679fa4dd81 Daily bump. 2024-05-14 00:21:46 +00:00
Patrick Palka 57cd8665fe c++: nested aggregate/alias CTAD fixes [PR114974, PR114901, PR114903]
During maybe_aggr_guide with a nested class template and paren init,
like with list init we need to consider the generic template type rather
than the partially instantiated type since partial instantiations don't
have (partially instantiated) TYPE_FIELDS.  In turn we need to partially
substitute PARMs in the paren init case as well.  As a drive-by improvement
it seems better to use outer_template_args instead of DECL_TI_ARGS during
this partial substitution so that we lower instead of substitute the
innermost template parameters, which is generally more robust.

And during alias_ctad_tweaks with a nested class template, even though
the guides may be already partially instantiated we still need to
substitute the outermost arguments into its constraints.

	PR c++/114974
	PR c++/114901
	PR c++/114903

gcc/cp/ChangeLog:

	* pt.cc (maybe_aggr_guide): Fix obtaining TYPE_FIELDS in
	the paren init case.  Hoist out partial substitution logic
	to apply to the paren init case as well.
	(alias_ctad_tweaks): Substitute outer template arguments into
	a guide's constraints.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-aggr14.C: New test.
	* g++.dg/cpp2a/class-deduction-alias20.C: New test.
	* g++.dg/cpp2a/class-deduction-alias21.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6d31a370e2)
2024-05-13 09:54:53 -04:00
Joseph Myers 0b5642e17a Update gcc .po files
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
	ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
	zh_TW.po: Update.
2024-05-13 13:46:48 +00:00
GCC Administrator 8fcc4e7870 Daily bump. 2024-05-13 08:56:24 +00:00
Gerald Pfeifer 80ccc90be4 doc: Describe limitations re Ada, D, and Go on FreeBSD
gcc:
	PR target/69374
	PR target/112959
	* doc/install.texi (Specific) <*-*-freebsd*>: The Ada and D
	run-time libraries are broken on i386 which also can affect
	64-bit builds. Go is broken.

(cherry picked from commit ff98aab108)
2024-05-12 15:31:33 +02:00
Gerald Pfeifer 609f9699cd doc: FreeBSD no longer has a GNU toolchain in base
gcc:
	PR target/69374
	PR target/112959
	* doc/install.texi (Specific) <*-*-freebsd*>: No longer refer
	to GCC or binutils in base. Recommend bootstrap using binutils.

(cherry picked from commit 0695aba3e9)
2024-05-12 15:30:18 +02:00
Gerald Pfeifer 7939f8823e doc: Remove old details on libunwind for ia64-*-hpux*
gcc:
	PR target/69374
	* doc/install.texi (Specific) <ia64-*-hpux*>: Remove details
	on libunwind for GCC 3.4 and earlier.

(cherry picked from commit 81f7965e63)
2024-05-12 15:28:27 +02:00
Gerald Pfeifer cf43da54f8 doc: Remove references to FreeBSD 7 and older
FreeBSD 7 has been end of life for years and current GCC most likely
would not build there anymore anyways.

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

(cherry picked from commit 507f3ce34c)
2024-05-12 15:26:34 +02:00
Georg-Johann Lay fcdd723779 AVR: target/114981 - Tweak __builtin_powif / __powisf2
Implement __powisf2 in assembly.

	PR target/114981
libgcc/
	* config/avr/t-avr (LIB2FUNCS_EXCLUDE): Add _powisf2.
	(LIB1ASMFUNCS) [!avrtiny]: Add _powif.
	* config/avr/lib1funcs.S (mov4): New .macro.
	(L_powif, __powisf2) [!avrtiny]: New module and function.

gcc/testsuite/
	* gcc.target/avr/pr114981-powif.c: New test.

(cherry picked from commit af64af69c3)
2024-05-10 12:02:14 +02:00
Jakub Jelinek a805de33f7 c++, mingw: Fix up types of dtor hooks to __cxa_{,thread_}atexit/__cxa_throw on mingw ia32 [PR114968]
__cxa_atexit/__cxa_thread_atexit/__cxa_throw functions accept function
pointers to usually directly destructors rather than wrappers around
them.
Now, mingw ia32 uses implicitly __attribute__((thiscall)) calling
conventions for METHOD_TYPE (where the this pointer is passed in %ecx
register, the rest on the stack), so these functions use:
in config/os/mingw32/os_defines.h:
 #if defined (__i386__)
 #define _GLIBCXX_CDTOR_CALLABI __thiscall
 #endif
in libsupc++/cxxabi.h
__cxa_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void*) _GLIBCXX_NOTHROW;
__cxa_thread_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void *) _GLIBCXX_NOTHROW;
__cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *))
__attribute__((__noreturn__));

Now, mingw for some weird reason uses
 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
so it never actually uses __cxa_atexit, but does use __cxa_thread_atexit
and __cxa_throw.  Recent changes for modules result in more detailed
__cxa_*atexit/__cxa_throw prototypes precreated by the compiler, and if
that happens and one also includes <cxxabi.h>, the compiler complains about
mismatches in the prototypes.

One thing is the missing thiscall attribute on the FUNCTION_TYPE, the
other problem is that all of atexit/__cxa_atexit/__cxa_thread_atexit
get function pointer types created by a single function,
get_atexit_fn_ptr_type (), which creates it depending on if atexit
or __cxa_atexit will be used as either void(*)(void) or void(*)(void *),
but when using atexit and __cxa_thread_atexit it uses the wrong function
type for __cxa_thread_atexit.

The following patch adds a target hook to add the thiscall attribute to the
function pointers, and splits the get_atexit_fn_ptr_type () function into
get_atexit_fn_ptr_type () and get_cxa_atexit_fn_ptr_type (), the former always
creates shared void(*)(void) type, the latter creates either
void(*)(void*) (on most targets) or void(__attribute__((thiscall))*)(void*)
(on mingw ia32).  So that we don't waiste another GTY global tree for it,
because cleanup_type used for the same purpose for __cxa_throw should be
the same, the code changes it to use that type too.

In register_dtor_fn then based on the decision whether to use atexit,
__cxa_atexit or __cxa_thread_atexit it picks the right function pointer
type, and also if it decides to emit a __tcf_* wrapper for the cleanup,
uses that type for that wrapper so that it agrees on calling convention.

2024-05-10  Jakub Jelinek  <jakub@redhat.com>

	PR target/114968
gcc/
	* target.def (use_atexit_for_cxa_atexit): Remove spurious space
	from comment.
	(adjust_cdtor_callabi_fntype): New cxx target hook.
	* targhooks.h (default_cxx_adjust_cdtor_callabi_fntype): Declare.
	* targhooks.cc (default_cxx_adjust_cdtor_callabi_fntype): New
	function.
	* doc/tm.texi.in (TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE): Add.
	* doc/tm.texi: Regenerate.
	* config/i386/i386.cc (ix86_cxx_adjust_cdtor_callabi_fntype): New
	function.
	(TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE): Redefine.
gcc/cp/
	* cp-tree.h (atexit_fn_ptr_type_node, cleanup_type): Adjust macro
	comments.
	(get_cxa_atexit_fn_ptr_type): Declare.
	* decl.cc (get_atexit_fn_ptr_type): Adjust function comment, only
	build type for atexit argument.
	(get_cxa_atexit_fn_ptr_type): New function.
	(get_atexit_node): Call get_cxa_atexit_fn_ptr_type rather than
	get_atexit_fn_ptr_type when using __cxa_atexit.
	(get_thread_atexit_node): Call get_cxa_atexit_fn_ptr_type
	rather than get_atexit_fn_ptr_type.
	(start_cleanup_fn): Add ob_parm argument, call
	get_cxa_atexit_fn_ptr_type or get_atexit_fn_ptr_type depending
	on it and create PARM_DECL also based on that argument.
	(register_dtor_fn): Adjust start_cleanup_fn caller, use
	get_cxa_atexit_fn_ptr_type rather than get_atexit_fn_ptr_type
	for use_dtor casts.
	* except.cc (build_throw): Use get_cxa_atexit_fn_ptr_type ().

(cherry picked from commit e5d8fd9ce0)
2024-05-10 11:07:59 +02:00
Xi Ruoyao 21051de4be driver: Move -fdiagnostics-urls= early like -fdiagnostics-color= [PR114980]
In GCC 14 we started to emit URLs for "command-line option <option> is
valid for <language> but not <another language>" and "-Werror= argument
'-Werror=<option>' is not valid for <language>" warnings.  So we should
have moved -fdiagnostics-urls= early like -fdiagnostics-color=, or
-fdiagnostics-urls= wouldn't be able to control URLs in these warnings.

No test cases are added because with TERM=xterm-256colors PR114980
already triggers some test failures.

gcc/ChangeLog:

	PR driver/114980
	* opts-common.cc (prune_options): Move -fdiagnostics-urls=
	early like -fdiagnostics-color=.

(cherry picked from commit f75806ec63)
2024-05-10 11:21:08 +08:00
Harald Anlauf a504623550 Fortran: fix issues with class(*) assignment [PR114827]
gcc/fortran/ChangeLog:

	PR fortran/114827
	* trans-array.cc (gfc_alloc_allocatable_for_assignment): Take into
	account _len of unlimited polymorphic entities when calculating
	the effective element size for allocation size and array span.
	Set _len of lhs to _len of rhs.
	* trans-expr.cc (trans_class_assignment): Take into account _len
	of unlimited polymorphic entities for allocation size.

gcc/testsuite/ChangeLog:

	PR fortran/114827
	* gfortran.dg/asan/unlimited_polymorphic_34.f90: New test.

(cherry picked from commit 21e7aa5f3e)
2024-05-09 20:22:49 +02:00
GCC Administrator 93793ed35d Daily bump. 2024-05-09 11:03:31 +00:00
Jakub Jelinek 726e7a64ed testsuite: Fix up vector-subaccess-1.C test for ia32 [PR89224]
The test FAILs on i686-linux due to
.../gcc/testsuite/g++.dg/torture/vector-subaccess-1.C:16:6: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]
excess warnings.

This fixes it by adding -Wno-psabi, like commonly done in other tests.

2024-05-09  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89224
	* g++.dg/torture/vector-subaccess-1.C: Add -Wno-psabi as additional
	options.

(cherry picked from commit 8fb65ec816)
2024-05-09 11:22:41 +02:00
Georg-Johann Lay bbb76ac0a0 AVR: target/114975 - Add combine-pattern for __parityqi2.
PR target/114975
gcc/
	* config/avr/avr.md: Add combine pattern for
	8-bit parity detection.

gcc/testsuite/
	* gcc.target/avr/pr114975-parity.c: New test.

(cherry picked from commit 41bc359c32)
2024-05-09 10:37:59 +02:00
Georg-Johann Lay 4ef09dd8ce AVR: target/114975 - Add combine-pattern for __popcountqi2.
PR target/114975
gcc/
	* config/avr/avr.md: Add combine pattern for
	8-bit popcount detection.

gcc/testsuite/
	* gcc.target/avr/pr114975-popcount.c: New test.

(cherry picked from commit c8f4bbb824)
2024-05-09 10:37:26 +02:00
Georg-Johann Lay a9e313ed38 AVR: target/114981 - Support __builtin_powi[l] / __powidf2.
This supports __powidf2 by means of a double wrapper for already
existing f7_powi (renamed to __f7_powi by f7-renames.h).
It tweaks the implementation so that it does not perform trivial
multiplications with 1.0 any more, but instead uses a move.
It also fixes the last statement of f7_powi, which was wrong.
Notice that f7_powi was unused until now.

	PR target/114981
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add D_powi
	* libf7-asm.sx (F7MOD_D_powi_, __powidf2): New module and function.
	* libf7.c (f7_powi): Fix last (wrong) statement.
	Tweak trivial multiplications with 1.0.

gcc/testsuite/
	* gcc.target/avr/pr114981-powil.c: New test.

(cherry picked from commit de4eea7d7e)
2024-05-09 10:13:54 +02:00
Iain Sandoe 7e8fae89f3 Objective-C, NeXT, v2: Correct a regression in code-gen.
There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

	* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
	(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
	to determine this ABI change.
	(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 9b5c0be59d)
2024-05-08 10:18:54 +01:00
Jakub Jelinek d54151df3b reassoc: Fix up optimize_range_tests_to_bit_test [PR114965]
The optimize_range_tests_to_bit_test optimization normally emits a range
test first:
          if (entry_test_needed)
            {
              tem = build_range_check (loc, optype, unshare_expr (exp),
                                       false, lowi, high);
              if (tem == NULL_TREE || is_gimple_val (tem))
                continue;
            }
so during the bit test we already know that exp is in the [lowi, high]
range, but skips it if we have range info which tells us this isn't
necessary.
Also, normally it emits shifts by exp - lowi counter, but has an
optimization to use just exp counter if the mask isn't a more expensive
constant in that case and lowi is > 0 and high is smaller than prec.

The following testcase is miscompiled because the two abnormal cases
are triggered.  The range of exp is [43, 43][48, 48][95, 95], so we on
64-bit arch decide we don't need the entry test, because 95 - 43 < 64.
And we also decide to use just exp as counter, because the range test
tests just for exp == 43 || exp == 48, so high is smaller than 64 too.
Because 95 is in the exp range, we can't do that, we'd either need to
do a range test first, i.e.
if (exp - 43U <= 48U - 43U) if ((1UL << exp) & mask1))
or need to subtract lowi from the shift counter, i.e.
if ((1UL << (exp - 43)) & mask2)
but can't do both unless r.upper_bound () is < prec.

The following patch ensures that.

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

	PR tree-optimization/114965
	* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): Don't try to
	optimize away exp - lowi subtraction from shift count unless entry
	test is emitted or unless r.upper_bound () is smaller than prec.

	* gcc.c-torture/execute/pr114965.c: New test.

(cherry picked from commit 9adec2d91e)
2024-05-08 10:19:01 +02:00
Andrew Pinski cacc48014c c++/c-common: Fix convert_vector_to_array_for_subscript for qualified vector types [PR89224]
After r7-987-gf17a223de829cb, the access for the elements of a vector type would lose the qualifiers.
So if we had `constvector[0]`, the type of the element of the array would not have const on it.
This was due to a missing build_qualified_type for the inner type of the vector when building the array type.
We need to add back the call to build_qualified_type and now the access has the correct qualifiers. So the
overloads and even if it is a lvalue or rvalue is correctly done.

Note we correctly now reject the testcase gcc.dg/pr83415.c which was incorrectly accepted after r7-987-gf17a223de829cb.

Built and tested for aarch64-linux-gnu.

	PR c++/89224

gcc/c-family/ChangeLog:

	* c-common.cc (convert_vector_to_array_for_subscript): Call build_qualified_type
	for the inner type.

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_array_reference): Compare main variants
	for the vector/array types instead of the types directly.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/vector-subaccess-1.C: New test.
	* gcc.dg/pr83415.c: Change warning to error.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 4421d35167)
2024-05-07 16:50:09 -07:00
Nathaniel Shead 61a095b05c c++/modules: Stream unmergeable temporaries by value again [PR114856]
In r14-9266-g2823b4d96d9ec4 I gave all temporary vars a DECL_CONTEXT,
including those at namespace or global scope, so that they could be
properly merged across importers.  However, not all of these temporary
vars are actually supposed to be mergeable.

For instance, in the attached testcase we have an unnamed temporary var
used in the NSDMI of a class member, which cannot properly merged -- but
it also doesn't need to be, as it'll be thrown away when the class type
itself is merged anyway.

This patch reverts the change made above and instead makes a weaker
adjustment that only causes temporary vars with linkage have a
DECL_CONTEXT to merge from.  This way these unnamed, "unmergeable"
temporaries are properly streamed by value again.

	PR c++/114856

gcc/cp/ChangeLog:

	* call.cc (make_temporary_var_for_ref_to_temp): Set context for
	temporaries with linkage.
	* init.cc (create_temporary_var): Revert to only set context
	when in a function decl.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr114856.h: New test.
	* g++.dg/modules/pr114856_a.H: New test.
	* g++.dg/modules/pr114856_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit e60032b382)
2024-05-08 09:21:08 +10:00
Jakub Jelinek f43f346f19 expansion: Use __trunchfbf2 calls rather than __extendhfbf2 [PR114907]
The HF and BF modes have the same size/precision and neither is
a subset nor superset of the other.
So, using either __extendhfbf2 or __trunchfbf2 is weird.
The expansion apparently emits __extendhfbf2, but on the libgcc side
we apparently have __trunchfbf2 implemented.

I think it is easier to switch to using what is available rather than
adding new entrypoints to libgcc, even alias, because this is backportable.

2024-05-07  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/114907
	* expr.cc (convert_mode_scalar): Use trunc_optab rather than
	sext_optab for HF->BF conversions.
	* optabs-libfuncs.cc (gen_trunc_conv_libfunc): Likewise.

	* gcc.dg/pr114907.c: New test.

(cherry picked from commit 28ee13db2e)
2024-05-07 21:31:40 +02:00
Jakub Jelinek aca573ea64 tree-inline: Remove .ASAN_MARK calls when inlining functions into no_sanitize callers [PR114956]
In r9-5742 we've started allowing to inline always_inline functions into
functions which have disabled e.g. address sanitization even when the
always_inline function is implicitly from command line options sanitized.

This mostly works fine because most of the asan instrumentation is done only
late after ipa, but as the following testcase the .ASAN_MARK ifn calls
gimplifier adds can result in ICEs.

Fixed by dropping those during inlining, similarly to how we drop
.TSAN_FUNC_EXIT calls.

2024-05-07  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/114956
	* tree-inline.cc: Include asan.h.
	(copy_bb): Remove also .ASAN_MARK calls if id->dst_fn has asan/hwasan
	sanitization disabled.

	* gcc.dg/asan/pr114956.c: New test.

(cherry picked from commit d4e25cf4f7)
2024-05-07 21:31:25 +02:00
Gaius Mulley 07dab3f6b5 [PR modula2/113768][PR modula2/114133] bugfix constants must be cast prior to vararg call
This bug fix corrects the test codes below by converting the constant
literals to the type required by C.  In the testcases below the values, 1
etc were converted into the INTEGER type before being passed to a C
vararg function.  By default in modula2 constant literal ordinals are
represented as the ZTYPE (the largest GCC integer type node).

gcc/testsuite/ChangeLog:

	PR modula2/113768
	PR modula2/114133
	* gm2/extensions/run/pass/callingc10.mod: Convert constant literal
	numbers into INTEGER.
	* gm2/extensions/run/pass/callingc11.mod: Ditto.
	* gm2/extensions/run/pass/vararg2.mod: Ditto.
	* gm2/iso/run/pass/packed.mod: Emit a printf as a runtime
	diagnostic.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-07 19:51:08 +01:00
Jakub Jelinek 23cf010768 libgomp: Add gfx90c, 1036 and 1103 declare variant tests
Recently -march=gfx{90c,1036,1103} support has been added, but corresponding
changes weren't done in the testsuite.

The following patch adds that.

Tested on x86_64-linux (with fiji and gfx1103 devices; had to use
OMP_DEFAULT_DEVICE=1 there, fiji doesn't really work due to LLVM dropping
support, but we still list those as offloading devices).

2024-05-02  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/libgomp.c/declare-variant-4.h (gfx90c, gfx1036, gfx1103):
	New functions.
	(f): Add #pragma omp declare variant directives for those.
	* testsuite/libgomp.c/declare-variant-4-gfx90c.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1036.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1103.c: New test.

(cherry picked from commit 5eb25d1561)
2024-05-07 18:05:18 +02:00
Jakub Jelinek a1c8ae15d9 gimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument [PR114876]
Seems when Martin S. implemented this, he coded there strict reading
of the standard, which said that %lc with (wint_t) 0 argument is handled
as wchar_t[2] temp = { arg, 0 }; %ls with temp arg and so shouldn't print
any values.  But, most of the libc implementations actually handled that
case like %c with '\0' argument, adding a single NUL character, the only
known exception is musl.
Recently, C23 changed this in response to GB-141 and POSIX in
https://austingroupbugs.net/view.php?id=1647
so that it should have the same behavior as %c with '\0'.

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

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

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

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

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

(cherry picked from commit 6c6b70f072)
2024-05-07 18:04:50 +02:00
Patrick Palka 390bd23fd9 c++/modules: imported spec befriending class tmpl [PR114889]
When adding to CLASSTYPE_BEFRIENDING_CLASSES as part of installing an
imported class definition, we need to look through TEMPLATE_DECL like
make_friend_class does.

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

	PR c++/114889

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 22b20ac6c6)
2024-05-07 10:24:55 -04:00
Georg-Johann Lay c6141ad24f AVR: ipa/92606 - Don't optimize PROGMEM data against non-PROGMEM.
ipa/92606: Inter-procedural analysis optimizes data across
address-spaces and PROGMEM.  As of v14, the PROGMEM part is
still not fixed (and there is still no target hook as proposed
in PR92932).  Just disable respective bogus optimization.

	PR ipa/92606
gcc/
	* config/avr/avr.cc (avr_option_override): Set
	flag_ipa_icf_variables = 0.
gcc/testsuite/
	* gcc.target/avr/torture/pr92606.c: New test.

(cherry picked from commit 08e752e723)
2024-05-07 11:31:19 +02:00
Richard Biener 43b730b913 Bump BASE-VER
* BASE-VER: Set to 14.1.1.
2024-05-07 09:23:01 +02:00
Jakub Jelinek cd0059a197 Update ChangeLog and version files for release 2024-05-07 06:52:35 +00:00
Jakub Jelinek 4f12e06d2d Update gennews for GCC 14.
2024-05-07  Jakub Jelinek  <jakub@redhat.com>

	* gennews (files): Add files for GCC 14.

(cherry picked from commit 7ee3f76952)
2024-05-07 08:49:50 +02:00
GCC Administrator 308a39c1cd Daily bump. 2024-05-07 00:24:56 +00:00
Rainer Orth c7b4305f9c testsuite: c++: Skip g++.dg/analyzer on Solaris [PR111475]
Almost 1400 C++ analyzer tests FAIL on Solaris.  The patch is too risky
to apply so close to the GCC 14.1.0 release, so disable the tests on
Solaris instead to reduce the noise.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

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

	gcc/testsuite:
	PR analyzer/111475
	* g++.dg/analyzer/analyzer.exp: Disable on *-*-solaris2.*.
2024-05-06 10:54:27 +02:00
GCC Administrator 765ddffdbd Daily bump. 2024-05-06 00:24:07 +00:00
GCC Administrator 43b7e2f88c Daily bump. 2024-05-05 00:23:49 +00:00
GCC Administrator 532d775fc1 Daily bump. 2024-05-04 00:23:25 +00:00
Gaius Mulley d811080341 [PATCH] PR modula2/114929 for loop fails to iterate down to zero
There is a bug in the for loop control code which is exposed when an
unsigned type is used in the iterator variable.  See
gm2/pim/run/pass/testforloopzero[234].mod.  The bug is in the
calculation of the last iterator value.  The bug fix is to avoid using
negative expressions when calculating the last iterator value with a
negative step value.  This patch detects if e1, e2, step value are all
constant, in which case the ztype is used internally and there is no
overflow.  If the last iterator value is held in a variable then it
uses a different method to calculate the last iterator depending upon
the sign of the step value.

gcc/m2/ChangeLog:

	PR modula2/114929
	* gm2-compiler/M2Quads.mod (ForLoopLastIteratorVariable): New
	procedure.
	(ForLoopLastIteratorConstant): Ditto.
	(ForLoopLastIterator): Ditto.
	(BuildForToByDo): Remove LastIterator calculation and call
	ForLoopLastIterator instead.
	(FinalValue): Replace with ...
	(LastIterator): ... this.

gcc/testsuite/ChangeLog:

	PR modula2/114929
	* gm2/pim/run/pass/testforloopzero.mod: New test.
	* gm2/pim/run/pass/testforloopzero2.mod: New test.
	* gm2/pim/run/pass/testforloopzero3.mod: New test.
	* gm2/pim/run/pass/testforloopzero4.mod: New test.

(cherry picked from commit a561dc0f6c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-03 22:58:11 +01:00
Jason Merrill 3b4d6b6ecd c++: initializer_list<string> and EH [PR114935]
When we initialize an array of a type with a non-trivial destructor, such as
the backing array for the initializer_list, we have a cleanup to destroy any
constructed elements if a later constructor throws.  When the array being
created is a variable, the end of that EH region naturally coincides with
the beginning of the EH region for the cleanup for the variable as a whole.

But if the array is a temporary, or a subobject of one, the array cleanup
region lasts for the rest of the full-expression, along with the normal
cleanup for the TARGET_EXPR.  As a result, when tata throws we clean it up
twice.  Before r14-1705 we avoided this by disabling the array cleanup in
split_nonconstant_init, but after that we don't go through
split_nonconstant_init, so let's handle it in cp_genericize_target_expr.

	PR c++/114935

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_genericize_init): Add flags parm.
	(cp_genericize_init_expr): Pass nullptr.
	(cp_genericize_target_expr): Handle cleanup flags.
	* typeck2.cc (build_disable_temp_cleanup): Factor out of...
	(split_nonconstant_init): ...here.
	* cp-tree.h (build_disable_temp_cleanup): Declare.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-eh1.C: New test.

(cherry picked from commit 8f3afb83c8)
2024-05-03 16:01:21 -04:00
Richard Biener db447ec808 Revert "tree-optimization/114921 - _Float16 -> __bf16 isn't noop"
This reverts commit fa7e05d90b.
2024-05-03 16:03:14 +02:00
Andreas Schwab d7c06a80b5 libstdc++: Update powerpc-linux-gnu baseline_symbols
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt: Update.
2024-05-03 15:39:00 +02:00
Patrick O'Neill 796319476e RISC-V: Add testcase for pr114734
gcc/testsuite/ChangeLog:

	PR middle-end/114734

	* gcc.target/riscv/rvv/autovec/pr114734.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
(cherry picked from commit ff4dc8b10a)
2024-05-03 14:51:17 +02:00
Richard Biener 5c42872b2a middle-end/114734 - wrong code with expand_call_mem_ref
When expand_call_mem_ref looks at the definition of the address
argument to eventually expand a &TARGET_MEM_REF argument together
with a masked load it fails to honor constraints imposed by SSA
coalescing decisions.  The following fixes this.

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

(cherry picked from commit 4d3a5618de)
2024-05-03 14:51:17 +02:00
Alex Coplan 242fbc0df6 cfgrtl: Fix MEM_EXPR update in duplicate_insn_chain [PR114924]
The PR shows that when cfgrtl.cc:duplicate_insn_chain attempts to
update the MR_DEPENDENCE_CLIQUE information for a MEM_EXPR we can end up
accidentally dropping (e.g.) an ARRAY_REF from the MEM_EXPR and end up
replacing it with the underlying MEM_REF.  This leads to an
inconsistency in the MEM_EXPR information, and could lead to wrong code.

While the walk down to the MEM_REF is necessary to update
MR_DEPENDENCE_CLIQUE, we should use the outer tree expression for the
MEM_EXPR.  This patch does that.

gcc/ChangeLog:

	PR rtl-optimization/114924
	* cfgrtl.cc (duplicate_insn_chain): When updating MEM_EXPRs,
	don't strip (e.g.) ARRAY_REFs from the final MEM_EXPR.

(cherry picked from commit fe40d52561)
2024-05-03 13:47:55 +01:00
Richard Biener fa7e05d90b tree-optimization/114921 - _Float16 -> __bf16 isn't noop
The vectorizer handles a _Float16 to __bf16 conversion through
vectorizable_assignment, thinking it's a noop.  The following
fixes this by requiring the same vector component mode when
checking for CONVERT_EXPR_CODE_P, being stricter than for
VIEW_CONVERT_EXPR.

	PR tree-optimization/114921
	* tree-vect-stmts.cc (vectorizable_assignment): Require
	same vector component modes for input and output for
	CONVERT_EXPR_CODE_P.

(cherry picked from commit 87e35da16d)
2024-05-03 09:26:51 +02:00
GCC Administrator f86f1970e0 Daily bump. 2024-05-03 00:23:24 +00:00
Joseph Myers 8e39d4f2c6 Regenerate gcc.pot
* gcc.pot: Regenerate.
2024-05-02 19:46:01 +00:00
GCC Administrator 590a065c76 Daily bump. 2024-05-02 00:22:48 +00:00
GCC Administrator 9ccb16d032 Daily bump. 2024-05-01 00:22:29 +00:00
Jonathan Wakely 7a00c459cb libstdc++: Do not apply localized formatting to NaN and inf [PR114863]
We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.

libstdc++-v3/ChangeLog:

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

(cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)
2024-04-30 09:36:44 +01:00
Paul Thomas e976bef157 Fortran: Fix regression caused by r14-9752 [PR114959]
2024-04-29  Paul Thomas  <pault@gcc.gnu.org>

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

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

(cherry picked from commit bca41a8d55)
2024-04-30 10:17:47 +02:00
Jakub Jelinek a795a7b670 vect: Adjust vect_transform_reduction assertion [PR114883]
The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are
commutative conditional binary operations like ADD/MUL/AND/IOR/XOR,
and can be handled just fine.
In particular, we emit
        vminpd  %zmm3, %zmm5, %zmm0{%k2}
        vminpd  %zmm0, %zmm3, %zmm5{%k1}
and
        vmaxpd  %zmm3, %zmm5, %zmm0{%k2}
        vmaxpd  %zmm0, %zmm3, %zmm5{%k1}
in the vectorized loops of the first and second subroutine.

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

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

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

(cherry picked from commit 04ef92a62a)
2024-04-30 10:16:03 +02:00
Jakub Jelinek af925ba8e2 libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd
On Mon, Apr 29, 2024 at 01:44:24PM +0000, Joseph Myers wrote:
> > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> > dummy shared library with just some symbol versions for compatibility, but
> > all the pthread_* APIs are in libc.so.6).
>
> I suspect this has caused link failures in the glibc testsuite for Hurd,
> which still has separate libpthread.
>
> https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

So like this then?

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

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

(cherry picked from commit 3146a92a77)
2024-04-30 09:07:30 +02:00
Jakub Jelinek 501fed8078 Set DEV-PHASE to prerelease.
2024-04-26  Jakub Jelinek  <jakub@redhat.com>

	* DEV-PHASE: Set to prerelease.
2024-04-30 09:06:49 +02:00
Patrick Palka 3c925ac349 c++: ICE with templated sizeof(E1) / sizeof(E2) [PR114888]
In the sizeof / sizeof operator expression handling we're missing
a dependence check for the second operand.

	PR c++/114888

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 3900e944b0)
2024-04-29 21:15:42 -04:00
GCC Administrator 0062f8310d Daily bump. 2024-04-30 00:22:01 +00:00
Rainer Orth 330c04dc53 libstdc++: Update Solaris baselines for GCC 14.0
This patch updates the Solaris baselines for the GLIBCXX_3.4.33 version
added in GCC 14.0.

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

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

	libstdc++-v3:
	* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
	* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
	Likewise.
	* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
	* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
	Likewise.
2024-04-29 14:33:46 +02:00
Rainer Orth c3e9b863f2 libstdc++: Update Solaris baselines for GCC 13.2
This patch updates the Solaris baselines for the GLIBCXX_3.4.32 version
added in GCC 13.2.

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

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

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

(cherry picked from commit 3e1ca51284)
2024-04-29 14:32:08 +02:00
Pan Li d40073be96 RISC-V: Fix ICE for legitimize move on subreg const_poly_int [PR114885]
When we build with isl, there will be a ICE for graphite in both
the c/c++ and fortran.  The legitimize move cannot take care of
below rtl.

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

Then we will have ice similar to below:

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

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

The below test cases are fixed by this PATCH.

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

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

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

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

	PR target/114885

gcc/ChangeLog:

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

Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit 25213c4c11aa96aff1beda2aa4471cdff29e8953)
2024-04-29 16:30:52 +08:00
GCC Administrator 41d7a8ceaa Daily bump. 2024-04-29 00:23:01 +00:00
GCC Administrator 8cec90c7cc Daily bump. 2024-04-28 00:22:15 +00:00
Xi Ruoyao 3e04b6f6ba LoongArch: Add constraints for bit string operation define_insn_and_split's [PR114861]
Without the constrants, the compiler attempts to use a stack slot as the
target, causing an ICE building the kernel with -Os:

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

Add these constrants to fix the issue.

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 140124ad54)
2024-04-27 12:01:37 +08:00
GCC Administrator 457e907c86 Daily bump. 2024-04-27 00:21:59 +00:00
Patrick Palka c014cfd885 c++: fix source printing for "required from here" message
It seems the diagnostic machinery's source line printing respects
the pretty printer prefix, but this is undesirable for the call to
diagnostic_show_locus in print_instantiation_partial_context_line
(added in r14-4388-g1c45319b66edc9) since the prefix may have been
set when issuing an earlier, unrelated diagnostic and we just want
to print an unprefixed source line.

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

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

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

and afterward we print

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

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 7d5479a2ec)
2024-04-26 07:54:38 -04:00
Jonathan Wakely 5e5f33a067 libstdc++: Update status tables to refer to GCC 14 not mainline
libstdc++-v3/ChangeLog:

	* doc/html/manual/status.html: Regenerate.
	* doc/xml/manual/status_cxx1998.xml: Replace references to
	mainline GCC.
	* doc/xml/manual/status_cxx2011.xml: Likewise.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise.
	* doc/xml/manual/status_cxx2020.xml: Likewise.
	* doc/xml/manual/status_cxx2023.xml: Likewise.
	* doc/xml/manual/status_cxxtr1.xml: Likewise.
	* doc/xml/manual/status_cxxtr24733.xml: Likewise.
2024-04-26 11:59:21 +01:00
2750 changed files with 375305 additions and 218773 deletions
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-16 Thomas Schwinge <tschwinge@baylibre.com>
* configure.ac (have_cargo): Force to "no" in Canadian cross
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2023-06-22 Marek Polacek <polacek@redhat.com>
* configure.ac (--enable-host-bind-now): New check.
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-16 Thomas Schwinge <tschwinge@baylibre.com>
* acx.m4 (ACX_PROG_CARGO): Use 'AC_CHECK_PROGS'.
+19
View File
@@ -1,3 +1,22 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-05-07 Jakub Jelinek <jakub@redhat.com>
* gennews (files): Add files for GCC 14.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-18 Sandra Loosemore <sloosemore@baylibre.com>
* config-list.mk (LIST): --enable-obsolete for nios2*-*-*.
+1
View File
@@ -23,6 +23,7 @@
website=http://gcc.gnu.org/
files="
gcc-14/index.html gcc-14/changes.html
gcc-13/index.html gcc-13/changes.html
gcc-12/index.html gcc-12/changes.html
gcc-11/index.html gcc-11/changes.html
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2022-08-31 Martin Liska <mliska@suse.cz>
* README: Remove deprecated ports.
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2023-05-18 Jonathan Wakely <jwakely@redhat.com>
PR bootstrap/105831
+12
View File
@@ -1,3 +1,15 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2023-11-23 Hans-Peter Nilsson <hp@axis.com>
* btest-gcc.sh (--handle-xpass-as-fail): New option.
+21
View File
@@ -1,3 +1,24 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2025-05-01 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Backported from master:
2024-06-27 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* fixincl.x: Regenerate.
* inclhack.def (apple_local_stdio_fn_deprecation): Also apply to
_stdio.h.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2023-11-22 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* configure: Regenerated.
+3 -3
View File
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
* It has been AutoGen-ed August 17, 2023 at 10:16:38 AM by AutoGen 5.18.12
* It has been AutoGen-ed April 1, 2025 at 03:28:07 PM by AutoGen 5.18.16
* From the definitions inclhack.def
* and the template file fixincl
*/
/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Aug 17 10:16:38 CEST 2023
/* DO NOT SVN-MERGE THIS FILE, EITHER Tue Apr 1 15:28:07 BST 2025
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -2619,7 +2619,7 @@ tSCC zApple_Local_Stdio_Fn_DeprecationName[] =
* File name selection pattern
*/
tSCC zApple_Local_Stdio_Fn_DeprecationList[] =
"stdio.h\0";
"stdio.h\0_stdio.h\0";
/*
* Machine/OS name selection pattern
*/
+1
View File
@@ -1273,6 +1273,7 @@ fix = {
hackname = apple_local_stdio_fn_deprecation;
mach = "*-*-*darwin2*";
files = stdio.h;
files = _stdio.h;
select = "__deprecated_msg([^\n]*)$";
c_fix = format;
c_fix_arg = "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n"
+1 -1
View File
@@ -1 +1 @@
14.0.1
14.3.0
+5483
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
20240426
20250523
-1
View File
@@ -1 +0,0 @@
experimental
+1
View File
@@ -1697,6 +1697,7 @@ OBJS = \
ubsan.o \
sanopt.o \
sancov.o \
tree-assume.o \
tree-call-cdce.o \
tree-cfg.o \
tree-cfgcleanup.o \
+188
View File
@@ -1,3 +1,191 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2025-04-30 Eric Botcazou <ebotcazou@adacore.com>
PR ada/112958
* Makefile.rtl (LIBGNAT_TARGET_PAIRS) [x86 FreeBSD]: Add specific
version of s-dorepr.adb.
* libgnat/s-dorepr__freebsd.adb: New file.
2025-04-04 Eric Botcazou <ebotcazou@adacore.com>
* libgnat/a-ngcoar.adb (Eigensystem): Adjust notation and fix the
layout of the real symmetric matrix in the main comment. Adjust
the layout of the associated code accordingly and correctly turn
the 2Nx1 real vectors into Nx1 complex ones.
(Eigenvalues): Minor similar tweaks.
* libgnat/a-ngrear.adb (Jacobi): Minor tweaks in the main comment.
Adjust notation and corresponding parameter names of functions.
Fix call to Unit_Matrix routine. Adjust the comment describing
the various kinds of iterations to match the implementation.
2025-03-19 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
the may_alias attribute if a specific GCC type is built.
2025-03-19 Eric Botcazou <ebotcazou@adacore.com>
* gen_il-gen-gen_nodes.adb (N_Formal_Package_Declaration): Use
N_Declaration instead of Node_Kind as ancestor.
* sem_ch12.adb (Get_Formal_Entity): Remove obsolete alternative.
(Instantiate_Formal_Package): Take into account the abbreviated
instances in the main loop running over the actuals of the local
package created for the formal package.
2025-02-01 Eric Botcazou <ebotcazou@adacore.com>
PR ada/118712
* sem_warn.adb (Check_References): Deal with small adjustments of
references.
2025-01-06 Eric Botcazou <ebotcazou@adacore.com>
* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use the base type of
the index type to find the type used to compute the length.
2025-01-05 Estevan Castilho (Tevo) <estevan.cps@gmail.com>
* libgnarl/s-taprop__dummy.adb: Remove use clause for
System.Parameters.
(Unlock): Remove Global_Lock formal parameter.
(Write_Lock): Likewise.
2024-12-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.cc (get_atomic_access): Deal specifically with
nodes that are both Atomic and Volatile_Full_Access in Ada 2012.
2024-12-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/117996
* libgnat/a-ngrear.adb (Jacobi): Remove default value for
Compute_Vectors formal parameter.
(Sort_Eigensystem): Add Compute_Vectors formal parameter. Do not
modify the Vectors if Compute_Vectors is False.
(Eigensystem): Pass True as Compute_Vectors to Sort_Eigensystem.
(Eigenvalues): Pass False as Compute_Vectors to Sort_Eigensystem.
2024-11-26 Arsen Arsenović <arsen@aarsen.me>
Backported from master:
2024-08-19 Arsen Arsenović <arsen@aarsen.me>
PR ada/115917
* gnatvsn.ads: Add note about the duplication of this value in
version.c.
* version.c (VER_LEN_MAX): Define to the same value as
Gnatvsn.Ver_Len_Max.
(gnat_version_string): Use VER_LEN_MAX as bound.
2024-11-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/117328
* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use a type sized
from the index type to compute the length. Simplify and remove
useless calls to New_Copy_Tree for this computation.
2024-11-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/113868
* par-ch6.adb (P_Subprogram) <Scan_Body_Or_Expression_Function>:
Add delta aggregate alongside the other forms of aggregates.
2024-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR ada/113036
* freeze.adb (Freeze_Expression): Deal with freezing actions coming
from within nested internal loops present in spec expressions.
2024-11-04 Eric Botcazou <ebotcazou@adacore.com>
* freeze.adb (Freeze_Expression): Also attach pending freeze nodes
to the parent in the case of an internal block in a spec expression.
2024-11-04 Eric Botcazou <ebotcazou@adacore.com>
* checks.adb (Selected_Length_Checks.Get_E_Length): For a
component of a record with discriminants and if the expression is
a selected component, try to build an actual subtype from its
prefix instead of from the discriminal.
2024-10-25 Eric Botcazou <ebotcazou@adacore.com>
PR ada/116551
* gcc-interface/trans.cc (node_is_atomic) <N_Identifier>: Return
false if the type of the entity is an unconstrained array type.
(node_is_volatile_full_access) <N_Identifier>: Likewise.
2024-10-14 Steve Baird <baird@adacore.com>
PR ada/114593
* sem_res.adb (Valid_Conversion): Test In_Instance instead of
In_Instance_Body.
2024-10-08 Eric Botcazou <ebotcazou@adacore.com>
* exp_aggr.ads (Is_Two_Pass_Aggregate): New function declaration.
* exp_aggr.adb (Is_Two_Pass_Aggregate): New function body.
(Expand_Array_Aggregate): Call Is_Two_Pass_Aggregate to detect the
aggregates that need the 2-pass expansion.
* exp_ch3.adb (Expand_Freeze_Array_Type): In the anonymous array
case, build the initialization procedure if the initial value in
the object declaration is a 2-pass aggregate.
2024-10-08 Eric Botcazou <ebotcazou@adacore.com>
PR ada/115535
* exp_put_image.adb (Build_Elementary_Put_Image_Call): Use the size
of the underlying type to find the support type.
2024-10-08 Eric Botcazou <ebotcazou@adacore.com>
PR ada/114640
* exp_util.adb (Find_Hook_Context): For a node present within a
conditional expression, do not return an N_Elsif_Part node.
2024-10-08 Eric Botcazou <ebotcazou@adacore.com>
PR ada/114636
* sem_ch12.adb (Check_Formal_Package_Instance): For a defaulted
formal discrete type, skip the generated implicit base type.
2024-10-04 Eric Botcazou <ebotcazou@adacore.com>
PR ada/116430
* exp_ch7.adb (Build_Finalizer.Create_Finalizer): For the insertion
point of the finalizer, deal with package bodies that are subunits.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-06-10 Eric Botcazou <ebotcazou@adacore.com>
PR ada/114708
* exp_util.adb (Finalize_Address): Add guard for incomplete types.
2024-06-10 Javier Miranda <miranda@adacore.com>
* sem_ch6.adb (Might_Need_BIP_Task_Actuals): Add support
for access-to-subprogram parameter types.
* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call):
Add dummy BIP parameters to access-to-subprogram types
that may reference a function that has BIP parameters.
2024-05-29 Eric Botcazou <ebotcazou@adacore.com>
PR ada/115270
* Makefile.rtl (PowerPC/Linux): Use libgnat/s-atopri__32.ads for
the 32-bit library.
(SPARC/Linux): Likewise.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-15 Piotr Trojanek <trojanek@adacore.com>
* doc/gnat_rm/implementation_defined_aspects.rst
+11 -3
View File
@@ -1730,6 +1730,7 @@ ifeq ($(strip $(filter-out %86 freebsd%,$(target_cpu) $(target_os))),)
$(TRASYM_DWARF_UNIX_PAIRS) \
$(ATOMICS_TARGET_PAIRS) \
$(X86_TARGET_PAIRS) \
s-dorepr.adb<libgnat/s-dorepr__freebsd.adb \
system.ads<libgnat/system-freebsd.ads
GNATLIB_SHARED = gnatlib-shared-dual
@@ -2238,15 +2239,18 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),)
system.ads<libgnat/system-linux-ppc.ads
ifeq ($(strip $(filter-out powerpc64%,$(target_cpu))),)
ifneq ($(strip $(MULTISUBDIR)),/32)
ifeq ($(strip $(MULTISUBDIR)),/32)
LIBGNAT_TARGET_PAIRS += s-atopri.ads<libgnat/s-atopri__32.ads
else
LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
endif
else
LIBGNAT_TARGET_PAIRS += s-atopri.ads<libgnat/s-atopri__32.ads
ifeq ($(strip $(MULTISUBDIR)),/64)
LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
else
LIBGNAT_TARGET_PAIRS += s-atopri.ads<libgnat/s-atopri__32.ads
endif
endif
@@ -2355,7 +2359,9 @@ ifeq ($(strip $(filter-out sparc% linux%,$(target_cpu) $(target_os))),)
system.ads<libgnat/system-linux-sparc.ads
ifeq ($(strip $(filter-out sparc64 sparcv9,$(target_cpu))),)
ifneq ($(strip $(MULTISUBDIR)),/32)
ifeq ($(strip $(MULTISUBDIR)),/32)
LIBGNAT_TARGET_PAIRS += s-atopri.ads<libgnat/s-atopri__32.ads
else
LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
endif
@@ -2363,6 +2369,8 @@ ifeq ($(strip $(filter-out sparc% linux%,$(target_cpu) $(target_os))),)
ifeq ($(strip $(MULTISUBDIR)),/64)
LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
else
LIBGNAT_TARGET_PAIRS += s-atopri.ads<libgnat/s-atopri__32.ads
endif
endif
+9 -1
View File
@@ -9800,7 +9800,15 @@ package body Checks is
if Ekind (Scope (E)) = E_Record_Type
and then Has_Discriminants (Scope (E))
then
N := Build_Discriminal_Subtype_Of_Component (E);
-- If the expression is a selected component, in other words,
-- has a prefix, then build an actual subtype from the prefix.
-- Otherwise, build an actual subtype from the discriminal.
if Nkind (Expr) = N_Selected_Component then
N := Build_Actual_Subtype_Of_Component (E, Expr);
else
N := Build_Discriminal_Subtype_Of_Component (E);
end if;
if Present (N) then
Insert_Action (Expr, N);
+36 -18
View File
@@ -5704,7 +5704,11 @@ package body Exp_Aggr is
Comp_Type : constant Entity_Id := Etype (N);
Index_Id : constant Entity_Id := Make_Temporary (Loc, 'I', N);
Index_Type : constant Entity_Id := Etype (First_Index (Etype (N)));
Index_Base : constant Entity_Id := Base_Type (Index_Type);
Size_Id : constant Entity_Id := Make_Temporary (Loc, 'I', N);
Size_Type : constant Entity_Id :=
Integer_Type_For
(Esize (Index_Base), Is_Unsigned_Type (Index_Base));
TmpE : constant Entity_Id := Make_Temporary (Loc, 'A', N);
Assoc : Node_Id := First (Component_Associations (N));
@@ -5720,7 +5724,7 @@ package body Exp_Aggr is
Size_Expr_Code := New_List (
Make_Object_Declaration (Loc,
Defining_Identifier => Size_Id,
Object_Definition => New_Occurrence_Of (Standard_Integer, Loc),
Object_Definition => New_Occurrence_Of (Size_Type, Loc),
Expression => Make_Integer_Literal (Loc, 0)));
-- First pass: execute the iterators to count the number of elements
@@ -5747,32 +5751,35 @@ package body Exp_Aggr is
Insert_Actions (N, Size_Expr_Code);
-- Build a constrained subtype with the calculated length
-- and declare the proper bounded aggregate object.
-- Build a constrained subtype with the bounds deduced from
-- the size computed above and declare the aggregate object.
-- The index type is some discrete type, so the bounds of the
-- constructed array are computed as T'Val (T'Pos (ineger bound));
-- constrained subtype are computed as T'Val (integer bounds).
declare
-- Pos_Lo := Index_Type'Pos (Index_Type'First)
Pos_Lo : constant Node_Id :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Index_Type, Loc),
Prefix => New_Occurrence_Of (Index_Type, Loc),
Attribute_Name => Name_Pos,
Expressions => New_List (
Expressions => New_List (
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Index_Type, Loc),
Attribute_Name => Name_First)));
-- Corresponding index value, i.e. Index_Type'First
Aggr_Lo : constant Node_Id :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Index_Type, Loc),
Attribute_Name => Name_Val,
Expressions => New_List (New_Copy_Tree (Pos_Lo)));
Prefix => New_Occurrence_Of (Index_Type, Loc),
Attribute_Name => Name_First);
-- Hi = Index_type'Pos (Lo + Size -1).
-- Pos_Hi := Pos_Lo + Size - 1
Pos_Hi : constant Node_Id :=
Make_Op_Add (Loc,
Left_Opnd => New_Copy_Tree (Pos_Lo),
Left_Opnd => Pos_Lo,
Right_Opnd =>
Make_Op_Subtract (Loc,
Left_Opnd => New_Occurrence_Of (Size_Id, Loc),
@@ -5784,7 +5791,7 @@ package body Exp_Aggr is
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Index_Type, Loc),
Attribute_Name => Name_Val,
Expressions => New_List (New_Copy_Tree (Pos_Hi)));
Expressions => New_List (Pos_Hi));
SubE : constant Entity_Id := Make_Temporary (Loc, 'T');
SubD : constant Node_Id :=
@@ -5807,6 +5814,7 @@ package body Exp_Aggr is
Make_Object_Declaration (Loc,
Defining_Identifier => TmpE,
Object_Definition => New_Occurrence_Of (SubE, Loc));
begin
Insert_Actions (N, New_List (SubD, TmpD));
end;
@@ -5908,12 +5916,7 @@ package body Exp_Aggr is
then
return;
elsif Present (Component_Associations (N))
and then Nkind (First (Component_Associations (N))) =
N_Iterated_Component_Association
and then
Present (Iterator_Specification (First (Component_Associations (N))))
then
elsif Is_Two_Pass_Aggregate (N) then
Two_Pass_Aggregate_Expansion (N);
return;
@@ -8710,6 +8713,21 @@ package body Exp_Aggr is
and then C in Uint_1 | Uint_2 | Uint_4; -- False if No_Uint
end Is_Two_Dim_Packed_Array;
---------------------------
-- Is_Two_Pass_Aggregate --
---------------------------
function Is_Two_Pass_Aggregate (N : Node_Id) return Boolean is
begin
return Nkind (N) = N_Aggregate
and then Present (Component_Associations (N))
and then Nkind (First (Component_Associations (N))) =
N_Iterated_Component_Association
and then
Present
(Iterator_Specification (First (Component_Associations (N))));
end Is_Two_Pass_Aggregate;
--------------------
-- Late_Expansion --
--------------------
+4
View File
@@ -35,6 +35,10 @@ package Exp_Aggr is
-- Returns True if N is an aggregate of some kind whose Expansion_Delayed
-- flag is set (see sinfo for meaning of flag).
function Is_Two_Pass_Aggregate (N : Node_Id) return Boolean;
-- Return True if N is an aggregate that is to be expanded in two passes.
-- This is the case if it consists only of iterated associations.
procedure Convert_Aggr_In_Object_Decl (N : Node_Id);
-- N is a N_Object_Declaration with an expression which must be an
-- N_Aggregate or N_Extension_Aggregate with Expansion_Delayed.
+10 -5
View File
@@ -4889,17 +4889,22 @@ package body Exp_Ch3 is
if No (Init_Proc (Base)) then
-- If this is an anonymous array created for a declaration with
-- an initial value, its init_proc will never be called. The
-- If this is an anonymous array built for an object declaration
-- with an initial value, its Init_Proc will never be called. The
-- initial value itself may have been expanded into assignments,
-- in which case the object declaration is carries the
-- No_Initialization flag.
-- in which case the declaration has the No_Initialization flag.
-- The exception is when the initial value is a 2-pass aggregate,
-- because the special expansion used for it creates a temporary
-- that needs a fully-fledged initialization.
if Is_Itype (Base)
and then Nkind (Associated_Node_For_Itype (Base)) =
N_Object_Declaration
and then
(Present (Expression (Associated_Node_For_Itype (Base)))
((Present (Expression (Associated_Node_For_Itype (Base)))
and then not
Is_Two_Pass_Aggregate
(Expression (Associated_Node_For_Itype (Base))))
or else No_Initialization (Associated_Node_For_Itype (Base)))
then
null;
+8 -3
View File
@@ -646,15 +646,20 @@ package body Exp_Ch6 is
Master_Formal : Node_Id;
begin
pragma Assert (Ekind (Function_Id) in E_Function
| E_Subprogram_Type);
-- No such extra parameters are needed if there are no tasks
if not Needs_BIP_Task_Actuals (Function_Id) then
-- However we must add dummy extra actuals if the function is
-- a dispatching operation that inherited these extra formals.
-- a dispatching operation that inherited these extra formals
-- or an access-to-subprogram type that requires these extra
-- actuals.
if Is_Dispatching_Operation (Function_Id)
and then Has_BIP_Extra_Formal (Function_Id, BIP_Task_Master)
if Has_BIP_Extra_Formal (Function_Id, BIP_Task_Master,
Must_Be_Frozen => False)
then
Master_Formal :=
Build_In_Place_Formal (Function_Id, BIP_Task_Master);
+6
View File
@@ -2051,6 +2051,12 @@ package body Exp_Ch7 is
and then List_Containing (Finalizer_Insert_Nod) = Stmts)
then
Finalizer_Insert_Nod := Last_Top_Level_Ctrl_Construct;
if Nkind (Finalizer_Insert_Nod) = N_Package_Body
and then Nkind (Parent (Finalizer_Insert_Nod)) = N_Subunit
then
Finalizer_Insert_Nod :=
Corresponding_Stub (Parent (Finalizer_Insert_Nod));
end if;
end if;
Insert_After (Finalizer_Insert_Nod, Fin_Body);
+1 -2
View File
@@ -293,10 +293,9 @@ package body Exp_Put_Image is
Loc : constant Source_Ptr := Sloc (N);
P_Type : constant Entity_Id := Entity (Prefix (N));
U_Type : constant Entity_Id := Underlying_Type (P_Type);
FST : constant Entity_Id := First_Subtype (U_Type);
Sink : constant Node_Id := First (Expressions (N));
Item : constant Node_Id := Next (Sink);
P_Size : constant Uint := Esize (FST);
P_Size : constant Uint := Esize (U_Type);
Lib_RE : RE_Id;
begin
+7
View File
@@ -6076,6 +6076,12 @@ package body Exp_Util is
Utyp := Underlying_Type (Base_Type (Utyp));
-- Handle incomplete types
if No (Utyp) then
return Empty;
end if;
-- Deal with untagged derivation of private views. If the parent is
-- now known to be protected, the finalization routine is the one
-- defined on the corresponding record of the ancestor (corresponding
@@ -6549,6 +6555,7 @@ package body Exp_Util is
| N_Aggregate
| N_Delta_Aggregate
| N_Extension_Aggregate
| N_Elsif_Part
and then Nkind (Parent (Par)) not in N_Function_Call
| N_Procedure_Call_Statement
| N_Entry_Call_Statement
+17 -9
View File
@@ -8684,8 +8684,9 @@ package body Freeze is
or else Ekind (Current_Scope) = E_Void
then
declare
Freeze_Nodes : List_Id := No_List;
Pos : Int := Scope_Stack.Last;
Freeze_Nodes : List_Id := No_List;
Pos : Int := Scope_Stack.Last;
Scop : Entity_Id := Current_Scope;
begin
if Present (Desig_Typ) then
@@ -8701,7 +8702,8 @@ package body Freeze is
end if;
-- The current scope may be that of a constrained component of
-- an enclosing record declaration, or of a loop of an enclosing
-- an enclosing record declaration, or a block of an enclosing
-- declare expression in Ada 2022, or of a loop of an enclosing
-- quantified expression or aggregate with an iterated component
-- in Ada 2022, which is above the current scope in the scope
-- stack. Indeed in the context of a quantified expression or
@@ -8711,12 +8713,18 @@ package body Freeze is
-- If the expression is within a top-level pragma, as for a pre-
-- condition on a library-level subprogram, nothing to do.
if not Is_Compilation_Unit (Current_Scope)
and then (Is_Record_Type (Scope (Current_Scope))
or else (Ekind (Current_Scope) = E_Loop
and then Is_Internal (Current_Scope)))
then
Pos := Pos - 1;
if not Is_Compilation_Unit (Scop) then
if Is_Record_Type (Scope (Scop)) then
Pos := Pos - 1;
else
while Ekind (Scop) in E_Block | E_Loop
and then Is_Internal (Scop)
loop
Pos := Pos - 1;
Scop := Scope (Scop);
end loop;
end if;
end if;
if Is_Non_Empty_List (Freeze_Nodes) then
+8
View File
@@ -3564,6 +3564,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type);
TYPE_REVERSE_STORAGE_ORDER (gnu_type)
= Reverse_Storage_Order (gnat_entity);
/* Do the same for subtypes as for the base type, since pointers
to them may symmetrically also point to the latter. */
prepend_one_attribute
(&attr_list, ATTR_MACHINE_ATTRIBUTE,
get_identifier ("may_alias"), NULL_TREE,
gnat_entity);
process_attributes (&gnu_type, &attr_list, true, gnat_entity);
/* Set the size, alignment and alias set of the type to match
+12 -4
View File
@@ -4230,7 +4230,10 @@ node_is_atomic (Node_Id gnat_node)
if (!Is_Object (gnat_entity))
break;
return Is_Atomic (gnat_entity)
/* Disregard the flag on unconstrained arrays or simple constants
since we cannot or need not generate an atomic access. */
|| (Is_Atomic (Etype (gnat_entity))
&& Ekind (Etype (gnat_entity)) != E_Array_Type
&& !simple_constant_p (gnat_entity));
case N_Selected_Component:
@@ -4270,7 +4273,10 @@ node_is_volatile_full_access (Node_Id gnat_node)
if (!Is_Object (gnat_entity))
break;
return Is_Volatile_Full_Access (gnat_entity)
/* Disregard the flag on unconstrained arrays or simple constants
since we cannot or need not generate a full access. */
|| (Is_Volatile_Full_Access (Etype (gnat_entity))
&& Ekind (Etype (gnat_entity)) != E_Array_Type
&& !simple_constant_p (gnat_entity));
case N_Selected_Component:
@@ -4358,9 +4364,9 @@ get_atomic_access (Node_Id gnat_node, atomic_acces_t *type, bool *sync)
gnat_node = Expression (gnat_node);
/* Up to Ada 2012, for Atomic itself, only reads and updates of the object as
a whole require atomic access (RM C.6(15)). But, starting with Ada 2022,
reads of or writes to a nonatomic subcomponent of the object also require
atomic access (RM C.6(19)). */
a whole require atomic access (RM C.6(15)), unless the object is also VFA.
But, starting with Ada 2022, reads of or writes to nonatomic subcomponents
of the object also require atomic access (RM C.6(19)). */
if (node_is_atomic (gnat_node))
{
bool as_a_whole = true;
@@ -4369,7 +4375,9 @@ get_atomic_access (Node_Id gnat_node, atomic_acces_t *type, bool *sync)
for (gnat_temp = gnat_node, gnat_parent = Parent (gnat_temp);
node_is_component (gnat_parent) && Prefix (gnat_parent) == gnat_temp;
gnat_temp = gnat_parent, gnat_parent = Parent (gnat_temp))
if (Ada_Version < Ada_2022 || node_is_atomic (gnat_parent))
if (Ada_Version < Ada_2022
? !node_is_volatile_full_access (gnat_node)
: node_is_atomic (gnat_parent))
goto not_atomic;
else
as_a_whole = false;
+1 -1
View File
@@ -1441,7 +1441,7 @@ begin -- Gen_IL.Gen.Gen_Nodes
Cc (N_Formal_Ordinary_Fixed_Point_Definition, Node_Kind);
Cc (N_Formal_Package_Declaration, Node_Kind,
Cc (N_Formal_Package_Declaration, N_Declaration,
(Sy (Defining_Identifier, Node_Id),
Sy (Name, Node_Id, Default_Empty),
Sy (Generic_Associations, List_Id, Default_No_List),
+2 -1
View File
@@ -83,7 +83,8 @@ package Gnatvsn is
-- space to store any possible version string value for checks. This
-- value should never be decreased in the future, but it would be
-- OK to increase it if absolutely necessary. If it is increased,
-- be sure to increase GNAT.Compiler.Version.Ver_Len_Max as well.
-- be sure to increase GNAT.Compiler.Version.Ver_Len_Max, and to update
-- the VER_LEN_MAX define in version.c as well.
Ver_Prefix : constant String := "GNAT Version: ";
-- Prefix generated by binder. If it is changed, be sure to change
+2 -9
View File
@@ -37,7 +37,6 @@
package body System.Task_Primitives.Operations is
use System.Tasking;
use System.Parameters;
pragma Warnings (Off);
-- Turn off warnings since so many unreferenced parameters
@@ -480,10 +479,7 @@ package body System.Task_Primitives.Operations is
null;
end Unlock;
procedure Unlock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
is
procedure Unlock (L : not null access RTS_Lock) is
begin
null;
end Unlock;
@@ -522,10 +518,7 @@ package body System.Task_Primitives.Operations is
Ceiling_Violation := False;
end Write_Lock;
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
is
procedure Write_Lock (L : not null access RTS_Lock) is
begin
null;
end Write_Lock;
+20 -22
View File
@@ -1058,19 +1058,21 @@ package body Ada.Numerics.Generic_Complex_Arrays is
is
N : constant Natural := Length (A);
-- For a Hermitian matrix C, we convert the eigenvalue problem to a
-- real symmetric one: if C = A + i * B, then the (N, N) complex
-- For a Hermitian matrix A, we convert the eigenvalue problem to a
-- real symmetric one: if A = X + i * Y, then the (N, N) complex
-- eigenvalue problem:
-- (A + i * B) * (u + i * v) = Lambda * (u + i * v)
--
-- (X + i * Y) * (u + i * v) = Lambda * (u + i * v)
--
-- is equivalent to the (2 * N, 2 * N) real eigenvalue problem:
-- [ A, B ] [ u ] = Lambda * [ u ]
-- [ -B, A ] [ v ] [ v ]
--
-- Note that the (2 * N, 2 * N) matrix above is symmetric, as
-- Transpose (A) = A and Transpose (B) = -B if C is Hermitian.
-- [ X, -Y ] [ u ] = Lambda * [ u ]
-- [ Y, X ] [ v ] [ v ]
--
-- Note that the (2 * N, 2 * N) matrix M above is symmetric, because
-- Transpose (X) = X and Transpose (Y) = -Y as A is Hermitian.
-- We solve this eigensystem using the real-valued algorithms. The final
-- We solve this eigensystem using the real-valued algorithm. The final
-- result will have every eigenvalue twice, so in the sorted output we
-- just pick every second value, with associated eigenvector u + i * v.
@@ -1085,10 +1087,8 @@ package body Ada.Numerics.Generic_Complex_Arrays is
C : constant Complex :=
(A (A'First (1) + (J - 1), A'First (2) + (K - 1)));
begin
M (J, K) := Re (C);
M (J + N, K + N) := Re (C);
M (J + N, K) := Im (C);
M (J, K + N) := -Im (C);
M (J, K) := Re (C); M (J, K + N) := -Im (C);
M (J + N, K) := Im (C); M (J + N, K + N) := Re (C);
end;
end loop;
end loop;
@@ -1103,10 +1103,9 @@ package body Ada.Numerics.Generic_Complex_Arrays is
for K in 1 .. N loop
declare
Row : constant Integer := Vectors'First (2) + (K - 1);
Row : constant Integer := Vectors'First (1) + (K - 1);
begin
Vectors (Row, Col)
:= (Vecs (J * 2, Col), Vecs (J * 2, Col + N));
Vectors (Row, Col) := (Vecs (K, 2 * J), Vecs (K + N, 2 * J));
end;
end loop;
end;
@@ -1118,13 +1117,14 @@ package body Ada.Numerics.Generic_Complex_Arrays is
-----------------
function Eigenvalues (A : Complex_Matrix) return Real_Vector is
N : constant Natural := Length (A);
-- See Eigensystem for a description of the algorithm
N : constant Natural := Length (A);
R : Real_Vector (A'Range (1));
M : Real_Matrix (1 .. 2 * N, 1 .. 2 * N);
R : Real_Vector (A'Range (1));
Vals : Real_Vector (1 .. 2 * N);
begin
for J in 1 .. N loop
for K in 1 .. N loop
@@ -1132,10 +1132,8 @@ package body Ada.Numerics.Generic_Complex_Arrays is
C : constant Complex :=
(A (A'First (1) + (J - 1), A'First (2) + (K - 1)));
begin
M (J, K) := Re (C);
M (J + N, K + N) := Re (C);
M (J + N, K) := Im (C);
M (J, K + N) := -Im (C);
M (J, K) := Re (C); M (J, K + N) := -Im (C);
M (J + N, K) := Im (C); M (J + N, K + N) := Re (C);
end;
end loop;
end loop;
+60 -49
View File
@@ -85,7 +85,7 @@ package body Ada.Numerics.Generic_Real_Arrays is
function Is_Symmetric (A : Real_Matrix) return Boolean is
(Transpose (A) = A);
-- Return True iff A is symmetric, see RM G.3.1 (90).
-- Return True iff A is symmetric, see RM G.3.1 (90)
function Is_Tiny (Value, Compared_To : Real) return Boolean is
(abs Compared_To + 100.0 * abs (Value) = abs Compared_To);
@@ -96,7 +96,7 @@ package body Ada.Numerics.Generic_Real_Arrays is
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
Compute_Vectors : Boolean := True);
Compute_Vectors : Boolean);
-- Perform Jacobi's eigensystem algorithm on real symmetric matrix A
function Length is new Square_Matrix_Length (Real'Base, Real_Matrix);
@@ -104,11 +104,12 @@ package body Ada.Numerics.Generic_Real_Arrays is
-- not a square matrix, and otherwise returns its length.
procedure Rotate (X, Y : in out Real; Sin, Tau : Real);
-- Perform a Givens rotation
-- Perform a Givens rotation of angle Theta given by sin and sin/(1 + cos)
procedure Sort_Eigensystem
(Values : in out Real_Vector;
Vectors : in out Real_Matrix);
(Values : in out Real_Vector;
Vectors : in out Real_Matrix;
Compute_Vectors : Boolean);
-- Sort Values and associated Vectors by decreasing absolute value
procedure Swap (Left, Right : in out Real);
@@ -486,7 +487,7 @@ package body Ada.Numerics.Generic_Real_Arrays is
is
begin
Jacobi (A, Values, Vectors, Compute_Vectors => True);
Sort_Eigensystem (Values, Vectors);
Sort_Eigensystem (Values, Vectors, Compute_Vectors => True);
end Eigensystem;
-----------------
@@ -500,7 +501,7 @@ package body Ada.Numerics.Generic_Real_Arrays is
Vectors : Real_Matrix (1 .. 0, 1 .. 0);
begin
Jacobi (A, Values, Vectors, Compute_Vectors => False);
Sort_Eigensystem (Values, Vectors);
Sort_Eigensystem (Values, Vectors, Compute_Vectors => False);
end;
end return;
end Eigenvalues;
@@ -522,15 +523,15 @@ package body Ada.Numerics.Generic_Real_Arrays is
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
Compute_Vectors : Boolean := True)
Compute_Vectors : Boolean)
is
-- This subprogram uses Carl Gustav Jacob Jacobi's iterative method
-- for computing eigenvalues and eigenvectors and is based on
-- This subprogram uses Carl Gustav Jacob Jacobi's cyclic iterative
-- method for computing eigenvalues and eigenvectors and is based on
-- Rutishauser's implementation.
-- The given real symmetric matrix is transformed iteratively to
-- diagonal form through a sequence of appropriately chosen elementary
-- orthogonal transformations, called Jacobi rotations here.
-- orthogonal transformations, called Jacobi rotations.
-- The Jacobi method produces a systematic decrease of the sum of the
-- squares of off-diagonal elements. Convergence to zero is quadratic,
@@ -541,41 +542,44 @@ package body Ada.Numerics.Generic_Real_Arrays is
-- best choice here, even though for large matrices other methods will
-- be significantly more efficient in both time and space.
-- While the eigensystem computations are absolutely foolproof for all
-- While the eigensystem computation is absolutely foolproof for all
-- real symmetric matrices, in presence of invalid values, or similar
-- exceptional situations it might not. In such cases the results cannot
-- be trusted and Constraint_Error is raised.
-- exceptional situations, it may not be. In such cases, the results
-- cannot be trusted and Constraint_Error is raised.
-- Note: this implementation needs temporary storage for 2 * N + N**2
-- values of type Real.
Max_Iterations : constant := 50;
N : constant Natural := Length (A);
Max_Iterations : constant := 50;
N : constant Natural := Length (A);
subtype Square_Matrix is Real_Matrix (1 .. N, 1 .. N);
-- In order to annihilate the M (Row, Col) element, the
-- rotation parameters Cos and Sin are computed as
-- follows:
-- In order to annihilate the M (Row, Col) element, the rotation angle
-- Theta is chosen as follows:
-- Theta = Cot (2.0 * Phi)
-- = (Diag (Col) - Diag (Row)) / (2.0 * M (Row, Col))
-- Cot (2.0 * Theta) = (Diag (Col) - Diag (Row)) / (2.0 * M (Row, Col))
-- Then Tan (Phi) as the smaller root (in modulus) of
-- If C = Cot (2.0 * Theta), then Tan (Theta) is computed as the smaller
-- root (in modulus) of:
-- T**2 + 2 * T * Theta = 1 (or 0.5 / Theta, if Theta is large)
-- X**2 + 2 * C * X - 1 = 0
function Compute_Tan (Theta : Real) return Real is
(Real'Copy_Sign (1.0 / (abs Theta + Sqrt (1.0 + Theta**2)), Theta));
-- or else as 0.5 / C, if C is large.
function Compute_Tan (C : Real) return Real is
(Real'Copy_Sign (1.0 / (abs C + Sqrt (1.0 + C**2)), C));
function Compute_Tan (P, H : Real) return Real is
(if Is_Tiny (P, Compared_To => H) then P / H
else Compute_Tan (Theta => H / (2.0 * P)));
(if Is_Tiny (P, Compared_To => H)
then P / H
else Compute_Tan (C => H / (2.0 * P)));
pragma Annotate
(CodePeer, False_Positive, "divide by zero", "H, P /= 0");
function Sum_Strict_Upper (M : Square_Matrix) return Real;
-- Return the sum of all elements in the strict upper triangle of M
-- Return the sum of the absolute value of all the elements in the
-- strict upper triangle of M.
----------------------
-- Sum_Strict_Upper --
@@ -594,11 +598,13 @@ package body Ada.Numerics.Generic_Real_Arrays is
return Sum;
end Sum_Strict_Upper;
-- Local variables
M : Square_Matrix := A; -- Work space for solving eigensystem
Threshold : Real;
Sum : Real;
Diag : Real_Vector (1 .. N);
Diag_Adj : Real_Vector (1 .. N);
Sum : Real;
Threshold : Real;
-- The vector Diag_Adj indicates the amount of change in each value,
-- while Diag tracks the value itself and Values holds the values as
@@ -620,22 +626,24 @@ package body Ada.Numerics.Generic_Real_Arrays is
raise Constraint_Error with "matrix not symmetric";
end if;
Values := Diagonal (M);
-- Note: Only the locally declared matrix M and vectors (Diag, Diag_Adj)
-- have lower bound equal to 1. The Vectors matrix may have
-- different bounds, so take care indexing elements. Assignment
-- as a whole is fine as sliding is automatic in that case.
Vectors := (if not Compute_Vectors then [1 .. 0 => [1 .. 0 => 0.0]]
else Unit_Matrix (Vectors'Length (1), Vectors'Length (2)));
Values := Diagonal (M);
Vectors := (if Compute_Vectors
then Unit_Matrix (N)
else [1 .. 0 => [1 .. 0 => 0.0]]);
Sweep : for Iteration in 1 .. Max_Iterations loop
-- The first three iterations, perform rotation for any non-zero
-- element. After this, rotate only for those that are not much
-- smaller than the average off-diagnal element. After the fifth
-- iteration, additionally zero out off-diagonal elements that are
-- very small compared to elements on the diagonal with the same
-- During the first three iterations, perform the rotation only for
-- elements that are not much smaller than the average off-diagonal
-- element. After this, rotate for any non-zero elements. After the
-- fifth iteration, additionally zero out off-diagonal elements that
-- are very small compared to elements on the diagonal with the same
-- column or row index.
Sum := Sum_Strict_Upper (M);
@@ -644,8 +652,8 @@ package body Ada.Numerics.Generic_Real_Arrays is
Threshold := (if Iteration < 4 then 0.2 * Sum / Real (N**2) else 0.0);
-- Iterate over all off-diagonal elements, rotating any that have
-- an absolute value that exceeds the threshold.
-- Iterate over all off-diagonal elements, rotating any that have an
-- absolute value that exceeds the threshold.
Diag := Values;
Diag_Adj := [others => 0.0]; -- Accumulates adjustments to Diag
@@ -653,11 +661,11 @@ package body Ada.Numerics.Generic_Real_Arrays is
for Row in 1 .. N - 1 loop
for Col in Row + 1 .. N loop
-- If, before the rotation M (Row, Col) is tiny compared to
-- If, before the rotation, M (Row, Col) is tiny compared to
-- Diag (Row) and Diag (Col), rotation is skipped. This is
-- meaningful, as it produces no larger error than would be
-- produced anyhow if the rotation had been performed.
-- Suppress this optimization in the first four sweeps, so
-- Suppress this optimization in the first four iterations, so
-- that this procedure can be used for computing eigenvectors
-- of perturbed diagonal matrices.
@@ -669,8 +677,8 @@ package body Ada.Numerics.Generic_Real_Arrays is
elsif abs M (Row, Col) > Threshold then
Perform_Rotation : declare
Tan : constant Real := Compute_Tan (M (Row, Col),
Diag (Col) - Diag (Row));
Tan : constant Real :=
Compute_Tan (M (Row, Col), Diag (Col) - Diag (Row));
Cos : constant Real := 1.0 / Sqrt (1.0 + Tan**2);
Sin : constant Real := Tan * Cos;
Tau : constant Real := Sin / (1.0 + Cos);
@@ -709,7 +717,7 @@ package body Ada.Numerics.Generic_Real_Arrays is
Values := Values + Diag_Adj;
end loop Sweep;
-- All normal matrices with valid values should converge perfectly.
-- All normal matrices with valid values should converge perfectly
if Sum /= 0.0 then
raise Constraint_Error with "eigensystem solution does not converge";
@@ -731,8 +739,9 @@ package body Ada.Numerics.Generic_Real_Arrays is
----------------------
procedure Sort_Eigensystem
(Values : in out Real_Vector;
Vectors : in out Real_Matrix)
(Values : in out Real_Vector;
Vectors : in out Real_Matrix;
Compute_Vectors : Boolean)
is
procedure Swap (Left, Right : Integer);
-- Swap Values (Left) with Values (Right), and also swap the
@@ -748,8 +757,10 @@ package body Ada.Numerics.Generic_Real_Arrays is
procedure Swap (Left, Right : Integer) is
begin
Swap (Values (Left), Values (Right));
Swap_Column (Vectors, Left - Values'First + Vectors'First (2),
Right - Values'First + Vectors'First (2));
if Compute_Vectors then
Swap_Column (Vectors, Left - Values'First + Vectors'First (2),
Right - Values'First + Vectors'First (2));
end if;
end Swap;
begin
+172
View File
@@ -0,0 +1,172 @@
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . D O U B L E _ R E A L . P R O D U C T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2021-2025, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the x86/FreeBSD version of the separate package body
with Interfaces; use Interfaces;
separate (System.Double_Real)
package body Product is
procedure Split (N : Num; Hi : out Num; Lo : out Num);
-- Compute high part and low part of N
-----------
-- Split --
-----------
-- We use a bit manipulation algorithm instead of Veltkamp's splitting
-- because it is faster and has the property that the magnitude of the
-- high part is never larger than that of the input number, which will
-- avoid spurious overflows in the Two_Prod algorithm.
-- See the recent paper by Claude-Pierre Jeannerod, Jean-Michel Muller
-- and Paul Zimmermann: On various ways to split a floating-point number
-- ARITH 2018 - 25th IEEE Symposium on Computer Arithmetic, Jun 2018,
-- Amherst (MA), United States, pages 53-60.
procedure Split (N : Num; Hi : out Num; Lo : out Num) is
X : Num;
begin
-- Spill the input into the appropriate (maybe larger) bit container,
-- mask out the low bits and reload the modified value.
case Num'Machine_Mantissa is
when 24 =>
declare
Rep32 : aliased Interfaces.Unsigned_32;
Temp : Num := N with Address => Rep32'Address;
pragma Annotate (CodePeer, Modified, Rep32);
begin
-- Mask out the low 12 bits
Rep32 := Rep32 and 16#FFFFF000#;
X := Temp;
end;
when 53 =>
declare
Rep64 : aliased array (1 .. 2) of Interfaces.Unsigned_64;
Temp : Num := N with Address => Rep64'Address;
pragma Annotate (CodePeer, Modified, Rep64);
begin
-- Mask out the low 27 bits
Rep64 (1) := Rep64 (1) and 16#FFFFFFFFF8000000#;
X := Temp;
end;
when 64 =>
declare
Rep80 : aliased array (1 .. 2) of Interfaces.Unsigned_64;
Temp : Num := N with Address => Rep80'Address;
pragma Annotate (CodePeer, Modified, Rep80);
begin
-- Mask out the low 32 bits
if System.Default_Bit_Order = High_Order_First then
Rep80 (1) := Rep80 (1) and 16#FFFFFFFFFFFF0000#;
Rep80 (2) := Rep80 (2) and 16#0000FFFFFFFFFFFF#;
else
Rep80 (1) := Rep80 (1) and 16#FFFFFFFF00000000#;
end if;
X := Temp;
end;
when others =>
raise Program_Error;
end case;
-- Deal with denormalized numbers
if X = 0.0 then
Hi := N;
Lo := 0.0;
else
Hi := X;
Lo := N - X;
end if;
end Split;
--------------
-- Two_Prod --
--------------
function Two_Prod (A, B : Num) return Double_T is
P : constant Num := A * B;
Ahi, Alo, Bhi, Blo, E : Num;
begin
if Is_Infinity (P) or else Is_Zero (P) then
return (P, 0.0);
else
Split (A, Ahi, Alo);
Split (B, Bhi, Blo);
E := ((Ahi * Bhi - P) + Ahi * Blo + Alo * Bhi) + Alo * Blo;
return (P, E);
end if;
end Two_Prod;
-------------
-- Two_Sqr --
-------------
function Two_Sqr (A : Num) return Double_T is
Q : constant Num := A * A;
Hi, Lo, E : Num;
begin
if Is_Infinity (Q) or else Is_Zero (Q) then
return (Q, 0.0);
else
Split (A, Hi, Lo);
E := ((Hi * Hi - Q) + 2.0 * Hi * Lo) + Lo * Lo;
return (Q, E);
end if;
end Two_Sqr;
end Product;
+1
View File
@@ -884,6 +884,7 @@ package body Ch6 is
if not (Paren_Count (Expr) /= 0
or else Nkind (Expr) in N_Aggregate
| N_Delta_Aggregate
| N_Extension_Aggregate
| N_Quantified_Expression)
then
+31 -6
View File
@@ -6696,8 +6696,12 @@ package body Sem_Ch12 is
then
-- If the formal is a tagged type the corresponding class-wide
-- type has been generated as well, and it must be skipped.
-- Likewise, for a formal discrete type, the base type has been
-- generated as well (see Analyze_Formal_Discrete_Type).
if Is_Type (E2) and then Is_Tagged_Type (E2) then
if Is_Type (E2)
and then (Is_Tagged_Type (E2) or else Is_Enumeration_Type (E2))
then
Next_Entity (E2);
end if;
@@ -10673,6 +10677,7 @@ package body Sem_Ch12 is
function Get_Formal_Entity (N : Node_Id) return Entity_Id is
Kind : constant Node_Kind := Nkind (Original_Node (N));
begin
case Kind is
when N_Formal_Object_Declaration =>
@@ -10687,9 +10692,6 @@ package body Sem_Ch12 is
when N_Formal_Package_Declaration =>
return Defining_Identifier (Original_Node (N));
when N_Generic_Package_Declaration =>
return Defining_Identifier (Original_Node (N));
-- All other declarations are introduced by semantic analysis and
-- have no match in the actual.
@@ -10928,6 +10930,26 @@ package body Sem_Ch12 is
end if;
Next_Non_Pragma (Formal_Node);
-- If the actual of the local package created for the formal
-- is itself an instantiated formal package, then it could
-- have given rise to additional declarations, see the code
-- dealing with conformance checking below.
if Nkind (Actual_Of_Formal) = N_Package_Renaming_Declaration
and then Requires_Conformance_Checking
(Declaration_Node
(Associated_Formal_Package
(Defining_Entity (Actual_Of_Formal))))
then
Next (Actual_Of_Formal);
pragma Assert
(Nkind (Actual_Of_Formal) = N_Package_Declaration);
Next (Actual_Of_Formal);
pragma Assert
(Nkind (Actual_Of_Formal) = N_Package_Instantiation);
end if;
Next (Actual_Of_Formal);
-- A formal subprogram may be overloaded, so advance in
@@ -10983,11 +11005,14 @@ package body Sem_Ch12 is
-- checking, because it contains formal declarations for those
-- defaulted parameters, and those should not reach the back-end.
-- This processing needs to be synchronized with the pattern matching
-- done in the main loop of the above block that starts with the test
-- on Requires_Conformance_Checking.
if Requires_Conformance_Checking (Formal) then
declare
I_Pack : constant Entity_Id := Make_Temporary (Loc, 'P');
I_Nam : Node_Id;
I_Nam : Node_Id;
begin
Set_Is_Internal (I_Pack);
+7 -5
View File
@@ -8660,9 +8660,12 @@ package body Sem_Ch6 is
-- Determines if E has its extra formals
function Might_Need_BIP_Task_Actuals (E : Entity_Id) return Boolean;
-- Determines if E is a dispatching primitive returning a limited tagged
-- type object since some descendant might return an object with tasks
-- (and therefore need the BIP task extra actuals).
-- Determines if E is a function or an access to a function returning a
-- limited tagged type object. On dispatching primitives this predicate
-- is used to determine if some descendant of the function might return
-- an object with tasks (and therefore need the BIP task extra actuals).
-- On access-to-subprogram types it is used to determine if the target
-- function might return an object with tasks.
function Needs_Accessibility_Check_Extra
(E : Entity_Id;
@@ -8783,9 +8786,8 @@ package body Sem_Ch6 is
Func_Typ := Root_Type (Underlying_Type (Etype (Subp_Id)));
return Ekind (Subp_Id) = E_Function
return Ekind (Subp_Id) in E_Function | E_Subprogram_Type
and then not Has_Foreign_Convention (Func_Typ)
and then Is_Dispatching_Operation (Subp_Id)
and then Is_Tagged_Type (Func_Typ)
and then Is_Limited_Type (Func_Typ)
and then not Has_Aspect (Func_Typ, Aspect_No_Task_Parts);
+1 -1
View File
@@ -14621,7 +14621,7 @@ package body Sem_Res is
-- If it was legal in the generic, it's legal in the instance
elsif In_Instance_Body then
elsif In_Instance then
return True;
-- If both are tagged types, check legality of view conversions
+4
View File
@@ -1229,6 +1229,10 @@ package body Sem_Warn is
UR := Unset_Reference (E1);
end if;
-- Protect again small adjustments of reference
UR := Unqual_Conv (UR);
-- Special processing for access types
if Present (UR) and then Is_Access_Type (E1T) then
+4 -1
View File
@@ -31,4 +31,7 @@
#include "version.h"
char gnat_version_string[] = version_string;
/* Logically a reference to Gnatvsn.Ver_Len_Max. Please keep in sync. */
#define VER_LEN_MAX 256
char gnat_version_string[VER_LEN_MAX] = version_string;
+77
View File
@@ -1,3 +1,80 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2024-11-20 David Malcolm <dmalcolm@redhat.com>
Backported from master:
2024-07-04 David Malcolm <dmalcolm@redhat.com>
PR analyzer/115724
* kf.cc (register_known_functions): Add __error_alias and
__error_at_line_alias.
2024-11-20 David Malcolm <dmalcolm@redhat.com>
Backported from master:
2024-05-03 David Malcolm <dmalcolm@redhat.com>
PR analyzer/111475
* analyzer.cc (is_special_named_call_p): Add "look_in_std" param.
(is_std_function_p): Make non-static.
* analyzer.h (is_special_named_call_p): Add optional "look_in_std"
param.
(is_std_function_p): New decl.
* engine.cc (stmt_requires_new_enode_p): Look for both "signal"
and "std::signal".
* kf.cc (register_known_functions): Add various "std::" copies
of the known functions.
* known-function-manager.cc
(known_function_manager::~known_function_manager): Clean up
m_std_ns_map_id_to_kf.
(known_function_manager::add_std_ns): New.
(known_function_manager::get_match): Also look for known "std::"
functions.
(known_function_manager::get_by_identifier_in_std_ns): New.
* known-function-manager.h
(known_function_manager::add_std_ns): New decl.
(known_function_manager::get_by_identifier_in_std_ns): New decl.
(known_function_manager::m_std_ns_map_id_to_kf): New field.
* sm-file.cc (register_known_file_functions): Add various "std::"
copies of the known functions.
* sm-malloc.cc (malloc_state_machine::on_stmt): Handle
"std::realloc".
* sm-signal.cc (signal_unsafe_p): Consider "std::" copies of the
functions as also being async-signal-unsafe.
(signal_state_machine::on_stmt): Consider "std::signal".
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-07-19 Daniel Bertalan <dani@danielbertalan.dev>
Backported from master:
2024-07-12 Daniel Bertalan <dani@danielbertalan.dev>
* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
Change NULL to nullptr.
(struct null_assignment_sm_context): Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* varargs.cc (va_list_state_machine::on_leak): Likewise.
2024-07-18 David Malcolm <dmalcolm@redhat.com>
Backported from master:
2024-05-15 David Malcolm <dmalcolm@redhat.com>
PR analyzer/114899
* access-diagram.cc
(written_svalue_spatial_item::get_label_string): Bulletproof
against SSA_NAME_VAR being null.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-12 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* region-model.cc (region_model::check_region_size): Bail out
+2 -1
View File
@@ -1632,7 +1632,8 @@ protected:
if (rep_tree)
{
if (TREE_CODE (rep_tree) == SSA_NAME)
rep_tree = SSA_NAME_VAR (rep_tree);
if (tree var = SSA_NAME_VAR (rep_tree))
rep_tree = var;
switch (TREE_CODE (rep_tree))
{
default:
+11 -4
View File
@@ -293,11 +293,13 @@ get_ssa_default_def (const function &fun, tree var)
is_named_call_p should be used instead, using a fndecl from
get_fndecl_for_call; this function should only be used for special cases
where it's not practical to get at the region model, or for special
analyzer functions such as __analyzer_dump. */
analyzer functions such as __analyzer_dump.
If LOOK_IN_STD is true, then also look for within std:: for the name. */
bool
is_special_named_call_p (const gcall *call, const char *funcname,
unsigned int num_args)
unsigned int num_args, bool look_in_std)
{
gcc_assert (funcname);
@@ -305,7 +307,12 @@ is_special_named_call_p (const gcall *call, const char *funcname,
if (!fndecl)
return false;
return is_named_call_p (fndecl, funcname, call, num_args);
if (is_named_call_p (fndecl, funcname, call, num_args))
return true;
if (look_in_std)
if (is_std_named_call_p (fndecl, funcname, call, num_args))
return true;
return false;
}
/* Helper function for checkers. Is FNDECL an extern fndecl at file scope
@@ -344,7 +351,7 @@ is_named_call_p (const_tree fndecl, const char *funcname)
Compare with cp/typeck.cc: decl_in_std_namespace_p, but this doesn't
rely on being the C++ FE (or handle inline namespaces inside of std). */
static inline bool
bool
is_std_function_p (const_tree fndecl)
{
tree name_decl = DECL_NAME (fndecl);
+3 -1
View File
@@ -448,10 +448,12 @@ extern tree remove_ssa_names (tree expr);
} // namespace ana
extern bool is_special_named_call_p (const gcall *call, const char *funcname,
unsigned int num_args);
unsigned int num_args,
bool look_in_std = false);
extern bool is_named_call_p (const_tree fndecl, const char *funcname);
extern bool is_named_call_p (const_tree fndecl, const char *funcname,
const gcall *call, unsigned int num_args);
extern bool is_std_function_p (const_tree fndecl);
extern bool is_std_named_call_p (const_tree fndecl, const char *funcname);
extern bool is_std_named_call_p (const_tree fndecl, const char *funcname,
const gcall *call, unsigned int num_args);
+9 -9
View File
@@ -678,12 +678,12 @@ saved_diagnostic::saved_diagnostic (const state_machine *sm,
m_stmt (ploc.m_stmt),
/* stmt_finder could be on-stack; we want our own copy that can
outlive that. */
m_stmt_finder (ploc.m_finder ? ploc.m_finder->clone () : NULL),
m_stmt_finder (ploc.m_finder ? ploc.m_finder->clone () : nullptr),
m_loc (ploc.m_loc),
m_var (var), m_sval (sval), m_state (state),
m_d (std::move (d)), m_trailing_eedge (NULL),
m_d (std::move (d)), m_trailing_eedge (nullptr),
m_idx (idx),
m_best_epath (NULL), m_problem (NULL),
m_best_epath (nullptr), m_problem (nullptr),
m_notes ()
{
/* We must have an enode in order to be able to look for paths
@@ -1790,10 +1790,10 @@ public:
stmt,
stack_depth,
sm,
NULL,
nullptr,
src_sm_val,
dst_sm_val,
NULL,
nullptr,
dst_state,
src_node));
return false;
@@ -1983,9 +1983,9 @@ struct null_assignment_sm_context : public sm_context
m_sm,
var_new_sval,
from, to,
NULL,
nullptr,
*m_new_state,
NULL));
nullptr));
}
void set_next_state (const gimple *stmt,
@@ -2009,9 +2009,9 @@ struct null_assignment_sm_context : public sm_context
m_sm,
sval,
from, to,
NULL,
nullptr,
*m_new_state,
NULL));
nullptr));
}
void warn (const supernode *, const gimple *,
+1 -1
View File
@@ -3768,7 +3768,7 @@ stmt_requires_new_enode_p (const gimple *stmt,
regular next state, which defeats the "detect state change" logic
in process_node. Work around this via special-casing, to ensure
we split the enode immediately before any "signal" call. */
if (is_special_named_call_p (call, "signal", 2))
if (is_special_named_call_p (call, "signal", 2, true))
return true;
}
+1 -1
View File
@@ -225,7 +225,7 @@ public:
enode->get_function ()->decl,
enode->get_stack_depth ()),
enode,
NULL, NULL, NULL));
nullptr, nullptr, nullptr));
logger *logger = emission_path->get_logger ();
+1 -1
View File
@@ -195,7 +195,7 @@ public:
m_callee_fndecl,
m_new_entry_enode->get_stack_depth ()),
enode,
NULL, NULL, NULL));
nullptr, nullptr, nullptr));
}
/* Reject paths in which conjured svalues have affected control flow
+26
View File
@@ -2324,6 +2324,10 @@ register_known_functions (known_function_manager &kfm,
kfm.add ("__errno_location", make_unique<kf_errno_location> ());
kfm.add ("error", make_unique<kf_error> (3));
kfm.add ("error_at_line", make_unique<kf_error> (5));
/* Variants of "error" and "error_at_line" seen by the
analyzer at -O0 (PR analyzer/115724). */
kfm.add ("__error_alias", make_unique<kf_error> (3));
kfm.add ("__error_at_line_alias", make_unique<kf_error> (5));
}
/* Other implementations of C standard library. */
@@ -2344,6 +2348,28 @@ register_known_functions (known_function_manager &kfm,
/* Language-specific support functions. */
register_known_functions_lang_cp (kfm);
/* Some C++ implementations use the std:: copies of these functions
from <cstdlib> etc for the C spellings of these headers (e.g. <stdlib.h>),
so we must match against these too. */
{
kfm.add_std_ns ("malloc", make_unique<kf_malloc> ());
kfm.add_std_ns ("free", make_unique<kf_free> ());
kfm.add_std_ns ("realloc", make_unique<kf_realloc> ());
kfm.add_std_ns ("calloc", make_unique<kf_calloc> ());
kfm.add_std_ns
("memcpy",
make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY));
kfm.add_std_ns
("memmove",
make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE));
kfm.add_std_ns ("memset", make_unique<kf_memset> (false));
kfm.add_std_ns ("strcat", make_unique<kf_strcat> (2, false));
kfm.add_std_ns ("strcpy", make_unique<kf_strcpy> (2, false));
kfm.add_std_ns ("strlen", make_unique<kf_strlen> ());
kfm.add_std_ns ("strncpy", make_unique<kf_strncpy> ());
kfm.add_std_ns ("strtok", make_unique<kf_strtok> (rmm));
}
}
} // namespace ana
+37 -1
View File
@@ -50,6 +50,8 @@ known_function_manager::~known_function_manager ()
/* Delete all owned kfs. */
for (auto iter : m_map_id_to_kf)
delete iter.second;
for (auto iter : m_std_ns_map_id_to_kf)
delete iter.second;
for (auto iter : m_combined_fns_arr)
delete iter;
}
@@ -63,6 +65,15 @@ known_function_manager::add (const char *name,
m_map_id_to_kf.put (id, kf.release ());
}
void
known_function_manager::add_std_ns (const char *name,
std::unique_ptr<known_function> kf)
{
LOG_FUNC_1 (get_logger (), "registering std::%s", name);
tree id = get_identifier (name);
m_std_ns_map_id_to_kf.put (id, kf.release ());
}
void
known_function_manager::add (enum built_in_function name,
std::unique_ptr<known_function> kf)
@@ -104,7 +115,16 @@ known_function_manager::get_match (tree fndecl, const call_details &cd) const
/* Look for a match by name. */
/* Reject fndecls that aren't in the root namespace. */
if (is_std_function_p (fndecl))
{
if (tree identifier = DECL_NAME (fndecl))
if (const known_function *candidate
= get_by_identifier_in_std_ns (identifier))
if (candidate->matches_call_types_p (cd))
return candidate;
return nullptr;
}
if (DECL_CONTEXT (fndecl)
&& TREE_CODE (DECL_CONTEXT (fndecl)) != TRANSLATION_UNIT_DECL)
return NULL;
@@ -158,6 +178,22 @@ known_function_manager::get_by_identifier (tree identifier) const
return NULL;
}
/* Get any known_function in C++ std:: namespace matching IDENTIFIER, without
type-checking.
Return nullptr if there isn't one. */
const known_function *
known_function_manager::get_by_identifier_in_std_ns (tree identifier) const
{
known_function_manager *mut_this = const_cast<known_function_manager *>(this);
known_function **slot = mut_this->m_std_ns_map_id_to_kf.get (identifier);
if (slot)
return *slot;
else
return nullptr;
}
} // namespace ana
#endif /* #if ENABLE_ANALYZER */
+5
View File
@@ -44,6 +44,7 @@ public:
~known_function_manager ();
void add (const char *name, std::unique_ptr<known_function> kf);
void add_std_ns (const char *name, std::unique_ptr<known_function> kf);
void add (enum built_in_function name, std::unique_ptr<known_function> kf);
void add (enum internal_fn ifn, std::unique_ptr<known_function> kf);
@@ -57,11 +58,15 @@ private:
const known_function *
get_normal_builtin (const builtin_known_function *builtin_kf) const;
const known_function *get_by_identifier (tree identifier) const;
const known_function *get_by_identifier_in_std_ns (tree identifier) const;
/* Map from identifier to known_function instance.
Has ownership of the latter. */
hash_map<tree, known_function *> m_map_id_to_kf;
/* Likewise for C++'s std:: namespace. */
hash_map<tree, known_function *> m_std_ns_map_id_to_kf;
/* Array of known builtins. */
known_function *m_combined_fns_arr[CFN_LAST];
};
+8
View File
@@ -648,6 +648,14 @@ register_known_file_functions (known_function_manager &kfm)
kfm.add ("fread", make_unique<kf_fread> ());
kfm.add ("getc", make_unique<kf_getc> ());
kfm.add ("getchar", make_unique<kf_getchar> ());
/* Some C++ implementations use the std:: copies of these functions
from <cstdio> for <stdio.h>, so we must match against these too. */
kfm.add_std_ns ("ferror", make_unique<kf_ferror> ());
kfm.add_std_ns ("fgets", make_unique<kf_fgets> ());
kfm.add_std_ns ("fread", make_unique<kf_fread> ());
kfm.add_std_ns ("getc", make_unique<kf_getc> ());
kfm.add_std_ns ("getchar", make_unique<kf_getchar> ());
}
#if CHECKING_P
+1
View File
@@ -1983,6 +1983,7 @@ malloc_state_machine::on_stmt (sm_context *sm_ctxt,
}
if (is_named_call_p (callee_fndecl, "realloc", call, 2)
|| is_std_named_call_p (callee_fndecl, "realloc", call, 2)
|| is_named_call_p (callee_fndecl, "__builtin_realloc", call, 2))
{
on_realloc_call (sm_ctxt, node, call);
+9 -2
View File
@@ -320,7 +320,13 @@ static bool
signal_unsafe_p (tree fndecl)
{
function_set fs = get_async_signal_unsafe_fns ();
return fs.contains_decl_p (fndecl);
if (fs.contains_decl_p (fndecl))
return true;
if (is_std_function_p (fndecl)
&& fs.contains_name_p (IDENTIFIER_POINTER (DECL_NAME (fndecl))))
return true;
return false;
}
/* Implementation of state_machine::on_stmt vfunc for signal_state_machine. */
@@ -335,7 +341,8 @@ signal_state_machine::on_stmt (sm_context *sm_ctxt,
{
if (const gcall *call = dyn_cast <const gcall *> (stmt))
if (tree callee_fndecl = sm_ctxt->get_fndecl_for_call (call))
if (is_named_call_p (callee_fndecl, "signal", call, 2))
if (is_named_call_p (callee_fndecl, "signal", call, 2)
|| is_std_named_call_p (callee_fndecl, "signal", call, 2))
{
tree handler = gimple_call_arg (call, 1);
if (TREE_CODE (handler) == ADDR_EXPR
+1 -1
View File
@@ -630,7 +630,7 @@ va_list_state_machine::on_va_end (sm_context *sm_ctxt,
std::unique_ptr<pending_diagnostic>
va_list_state_machine::on_leak (tree var) const
{
return make_unique<va_list_leak> (*this, NULL, var);
return make_unique<va_list_leak> (*this, nullptr, var);
}
} // anonymous namespace
+23 -28
View File
@@ -2100,28 +2100,13 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
mem = adjust_address (mem, VOIDmode, base_align_bias);
emit_move_insn (mem, gen_int_mode (ASAN_STACK_RETIRED_MAGIC, ptr_mode));
unsigned HOST_WIDE_INT sz = asan_frame_size >> ASAN_SHADOW_SHIFT;
bool asan_stack_free_emitted_p = false;
if (use_after_return_class < 5
&& can_store_by_pieces (sz, builtin_memset_read_str, &c,
BITS_PER_UNIT, true))
{
/* Emit:
memset(ShadowBase, kAsanStackAfterReturnMagic, ShadowSize);
**SavedFlagPtr(FakeStack, class_id) = 0
*/
store_by_pieces (shadow_mem, sz, builtin_memset_read_str, &c,
BITS_PER_UNIT, true, RETURN_BEGIN);
unsigned HOST_WIDE_INT offset
= (1 << (use_after_return_class + 6));
offset -= GET_MODE_SIZE (ptr_mode);
mem = gen_rtx_MEM (ptr_mode, base);
mem = adjust_address (mem, ptr_mode, offset);
rtx addr = gen_reg_rtx (ptr_mode);
emit_move_insn (addr, mem);
addr = convert_memory_address (Pmode, addr);
mem = gen_rtx_MEM (QImode, addr);
emit_move_insn (mem, const0_rtx);
}
/* Emit memset (ShadowBase, kAsanStackAfterReturnMagic, ShadowSize). */
store_by_pieces (shadow_mem, sz, builtin_memset_read_str, &c,
BITS_PER_UNIT, true, RETURN_BEGIN);
else if (use_after_return_class >= 5
|| !set_storage_via_setmem (shadow_mem,
GEN_INT (sz),
@@ -2138,6 +2123,20 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
GEN_INT (asan_frame_size + base_align_bias),
TYPE_MODE (pointer_sized_int_node),
orig_addr, ptr_mode);
asan_stack_free_emitted_p = true;
}
if (!asan_stack_free_emitted_p)
{
/* Emit **SavedFlagPtr (FakeStack, class_id) = 0. */
unsigned HOST_WIDE_INT offset = (1 << (use_after_return_class + 6));
offset -= GET_MODE_SIZE (ptr_mode);
mem = gen_rtx_MEM (ptr_mode, base);
mem = adjust_address (mem, ptr_mode, offset);
rtx addr = gen_reg_rtx (ptr_mode);
emit_move_insn (addr, mem);
addr = convert_memory_address (Pmode, addr);
mem = gen_rtx_MEM (QImode, addr);
emit_move_insn (mem, const0_rtx);
}
lab = gen_label_rtx ();
emit_jump (lab);
@@ -2610,7 +2609,7 @@ maybe_cast_to_ptrmode (location_t loc, tree len, gimple_stmt_iterator *iter,
if (ptrofftype_p (len))
return len;
gimple *g = gimple_build_assign (make_ssa_name (pointer_sized_int_node),
NOP_EXPR, len);
NOP_EXPR, len);
gimple_set_location (g, loc);
if (before_p)
gsi_safe_insert_before (iter, g);
@@ -2644,16 +2643,13 @@ build_check_stmt (location_t loc, tree base, tree len,
bool is_non_zero_len, bool before_p, bool is_store,
bool is_scalar_access, unsigned int align = 0)
{
gimple_stmt_iterator gsi = *iter;
gimple *g;
gcc_assert (!(size_in_bytes > 0 && !is_non_zero_len));
gcc_assert (size_in_bytes == -1 || size_in_bytes >= 1);
gsi = *iter;
base = unshare_expr (base);
base = maybe_create_ssa_name (loc, base, &gsi, before_p);
base = maybe_create_ssa_name (loc, base, iter, before_p);
if (len)
{
@@ -2704,12 +2700,11 @@ build_check_stmt (location_t loc, tree base, tree len,
align / BITS_PER_UNIT));
gimple_set_location (g, loc);
if (before_p)
gsi_safe_insert_before (&gsi, g);
gsi_safe_insert_before (iter, g);
else
{
gsi_insert_after (&gsi, g, GSI_NEW_STMT);
gsi_next (&gsi);
*iter = gsi;
gsi_insert_after (iter, g, GSI_NEW_STMT);
gsi_next (iter);
}
}
+10 -10
View File
@@ -1336,6 +1336,16 @@ build_type_attribute_qual_variant (tree otype, tree attribute, int quals)
tree dtype = ntype = build_distinct_type_copy (ttype);
TYPE_ATTRIBUTES (ntype) = attribute;
/* If the target-dependent attributes make NTYPE different from
its canonical type, we will need to use structural equality
checks for this type.
We shouldn't get here for stripping attributes from a type;
the no-attribute type might not need structural comparison. But
we can if was discarded from type_hash_table. */
if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
|| !comp_type_attributes (ntype, ttype))
SET_TYPE_STRUCTURAL_EQUALITY (ntype);
hashval_t hash = type_hash_canon_hash (ntype);
ntype = type_hash_canon (hash, ntype);
@@ -1343,16 +1353,6 @@ build_type_attribute_qual_variant (tree otype, tree attribute, int quals)
if (ntype != dtype)
/* This variant was already in the hash table, don't mess with
TYPE_CANONICAL. */;
else if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
|| !comp_type_attributes (ntype, ttype))
/* If the target-dependent attributes make NTYPE different from
its canonical type, we will need to use structural equality
checks for this type.
We shouldn't get here for stripping attributes from a type;
the no-attribute type might not need structural comparison. But
we can if was discarded from type_hash_table. */
SET_TYPE_STRUCTURAL_EQUALITY (ntype);
else if (TYPE_CANONICAL (ntype) == ntype)
TYPE_CANONICAL (ntype) = TYPE_CANONICAL (ttype);
+2 -2
View File
@@ -1538,8 +1538,6 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
if (s == NULL)
return;
cgraph_node::get (current_function_decl)->count
= profile_count::from_gcov_type (s->head_count ()).afdo ();
ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
= profile_count::from_gcov_type (s->head_count ()).afdo ();
EXIT_BLOCK_PTR_FOR_FN (cfun)->count = profile_count::zero ().afdo ();
@@ -1578,6 +1576,8 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
/* Calculate, propagate count and probability information on CFG. */
afdo_calculate_branch_prob (&annotated_bb);
}
cgraph_node::get(current_function_decl)->count
= ENTRY_BLOCK_PTR_FOR_FN(cfun)->count;
update_max_bb_count ();
profile_status_for_fn (cfun) = PROFILE_READ;
if (flag_value_profile_transformations)
+63 -32
View File
@@ -176,8 +176,8 @@ static tree fold_builtin_iseqsig (location_t, tree, tree);
static tree fold_builtin_varargs (location_t, tree, tree*, int);
static tree fold_builtin_strpbrk (location_t, tree, tree, tree, tree);
static tree fold_builtin_strspn (location_t, tree, tree, tree);
static tree fold_builtin_strcspn (location_t, tree, tree, tree);
static tree fold_builtin_strspn (location_t, tree, tree, tree, tree);
static tree fold_builtin_strcspn (location_t, tree, tree, tree, tree);
static rtx expand_builtin_object_size (tree);
static rtx expand_builtin_memory_chk (tree, rtx, machine_mode,
@@ -9441,14 +9441,16 @@ fold_builtin_frexp (location_t loc, tree arg0, tree arg1, tree rettype)
switch (value->cl)
{
case rvc_zero:
case rvc_nan:
case rvc_inf:
/* For +-0, return (*exp = 0, +-0). */
/* For +-NaN or +-Inf, *exp is unspecified, but something should
be stored there so that it isn't read from uninitialized object.
As glibc and newlib store *exp = 0 for +-Inf/NaN, storing
0 here as well is easiest. */
exp = integer_zero_node;
frac = arg0;
break;
case rvc_nan:
case rvc_inf:
/* For +-NaN or +-Inf, *exp is unspecified, return arg0. */
return omit_one_operand_loc (loc, rettype, arg0, arg1);
case rvc_normal:
{
/* Since the frexp function always expects base 2, and in
@@ -9576,7 +9578,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg)
arg = fold_build1_loc (loc, NOP_EXPR, type, arg);
}
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
real_from_string (&r, buf);
real_from_string3 (&r, buf, mode);
result = build_call_expr (isgr_fn, 2,
fold_build1_loc (loc, ABS_EXPR, type, arg),
build_real (type, r));
@@ -9600,7 +9602,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg)
arg = fold_build1_loc (loc, NOP_EXPR, type, arg);
}
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
real_from_string (&r, buf);
real_from_string3 (&r, buf, mode);
result = build_call_expr (isle_fn, 2,
fold_build1_loc (loc, ABS_EXPR, type, arg),
build_real (type, r));
@@ -9639,9 +9641,12 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg)
arg = fold_build1_loc (loc, ABS_EXPR, type, arg);
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
real_from_string (&rmax, buf);
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
real_from_string (&rmin, buf);
real_from_string3 (&rmax, buf, mode);
if (DECIMAL_FLOAT_MODE_P (mode))
sprintf (buf, "1E%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
else
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
real_from_string3 (&rmin, buf, orig_mode);
max_exp = build_real (type, rmax);
min_exp = build_real (type, rmin);
@@ -9830,28 +9835,33 @@ fold_builtin_fpclassify (location_t loc, tree *args, int nargs)
(x == 0 ? FP_ZERO : FP_SUBNORMAL))). */
tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
build_real (type, dconst0));
build_real (type, dconst0));
res = fold_build3_loc (loc, COND_EXPR, integer_type_node,
tmp, fp_zero, fp_subnormal);
tmp, fp_zero, fp_subnormal);
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
real_from_string (&r, buf);
if (DECIMAL_FLOAT_MODE_P (mode))
sprintf (buf, "1E%d", REAL_MODE_FORMAT (mode)->emin - 1);
else
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
real_from_string3 (&r, buf, mode);
tmp = fold_build2_loc (loc, GE_EXPR, integer_type_node,
arg, build_real (type, r));
res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, fp_normal, res);
arg, build_real (type, r));
res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
fp_normal, res);
if (tree_expr_maybe_infinite_p (arg))
{
tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
build_real (type, dconstinf));
build_real (type, dconstinf));
res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
fp_infinite, res);
fp_infinite, res);
}
if (tree_expr_maybe_nan_p (arg))
{
tmp = fold_build2_loc (loc, ORDERED_EXPR, integer_type_node, arg, arg);
res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, res, fp_nan);
res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
res, fp_nan);
}
return res;
@@ -9933,9 +9943,11 @@ fold_builtin_iseqsig (location_t loc, tree arg0, tree arg1)
/* Choose the wider of two real types. */
cmp_type = TYPE_PRECISION (type0) >= TYPE_PRECISION (type1)
? type0 : type1;
else if (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
else if (code0 == REAL_TYPE
&& (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
cmp_type = type0;
else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
&& code1 == REAL_TYPE)
cmp_type = type1;
arg0 = builtin_save_expr (fold_convert_loc (loc, cmp_type, arg0));
@@ -10042,7 +10054,21 @@ fold_builtin_arith_overflow (location_t loc, enum built_in_function fcode,
tree ctype = build_complex_type (type);
tree call = build_call_expr_internal_loc (loc, ifn, ctype, 2,
arg0, arg1);
tree tgt = save_expr (call);
tree tgt;
if (ovf_only)
{
tgt = call;
intres = NULL_TREE;
}
else
{
/* Force SAVE_EXPR even for calls which satisfy tree_invariant_p_1,
as while the call itself is const, the REALPART_EXPR store is
certainly not. And in any case, we want just one call,
not multiple and trying to CSE them later. */
TREE_SIDE_EFFECTS (call) = 1;
tgt = save_expr (call);
}
intres = build1_loc (loc, REALPART_EXPR, type, tgt);
ovfres = build1_loc (loc, IMAGPART_EXPR, type, tgt);
ovfres = fold_convert_loc (loc, boolean_type_node, ovfres);
@@ -10354,11 +10380,17 @@ fold_builtin_addc_subc (location_t loc, enum built_in_function fcode,
tree ctype = build_complex_type (type);
tree call = build_call_expr_internal_loc (loc, ifn, ctype, 2,
args[0], args[1]);
/* Force SAVE_EXPR even for calls which satisfy tree_invariant_p_1,
as while the call itself is const, the REALPART_EXPR store is
certainly not. And in any case, we want just one call,
not multiple and trying to CSE them later. */
TREE_SIDE_EFFECTS (call) = 1;
tree tgt = save_expr (call);
tree intres = build1_loc (loc, REALPART_EXPR, type, tgt);
tree ovfres = build1_loc (loc, IMAGPART_EXPR, type, tgt);
call = build_call_expr_internal_loc (loc, ifn, ctype, 2,
intres, args[2]);
TREE_SIDE_EFFECTS (call) = 1;
tgt = save_expr (call);
intres = build1_loc (loc, REALPART_EXPR, type, tgt);
tree ovfres2 = build1_loc (loc, IMAGPART_EXPR, type, tgt);
@@ -10624,10 +10656,10 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
return fold_builtin_modf (loc, arg0, arg1, type);
case BUILT_IN_STRSPN:
return fold_builtin_strspn (loc, expr, arg0, arg1);
return fold_builtin_strspn (loc, expr, arg0, arg1, type);
case BUILT_IN_STRCSPN:
return fold_builtin_strcspn (loc, expr, arg0, arg1);
return fold_builtin_strcspn (loc, expr, arg0, arg1, type);
case BUILT_IN_STRPBRK:
return fold_builtin_strpbrk (loc, expr, arg0, arg1, type);
@@ -11128,7 +11160,7 @@ fold_builtin_strpbrk (location_t loc, tree, tree s1, tree s2, tree type)
form of the builtin function call. */
static tree
fold_builtin_strspn (location_t loc, tree expr, tree s1, tree s2)
fold_builtin_strspn (location_t loc, tree expr, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11144,8 +11176,7 @@ fold_builtin_strspn (location_t loc, tree expr, tree s1, tree s2)
if ((p1 && *p1 == '\0') || (p2 && *p2 == '\0'))
/* Evaluate and ignore both arguments in case either one has
side-effects. */
return omit_two_operands_loc (loc, size_type_node, size_zero_node,
s1, s2);
return omit_two_operands_loc (loc, type, size_zero_node, s1, s2);
return NULL_TREE;
}
@@ -11168,7 +11199,7 @@ fold_builtin_strspn (location_t loc, tree expr, tree s1, tree s2)
form of the builtin function call. */
static tree
fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2)
fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11184,8 +11215,7 @@ fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2)
{
/* Evaluate and ignore argument s2 in case it has
side-effects. */
return omit_one_operand_loc (loc, size_type_node,
size_zero_node, s2);
return omit_one_operand_loc (loc, type, size_zero_node, s2);
}
/* If the second argument is "", return __builtin_strlen(s1). */
@@ -11199,7 +11229,8 @@ fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2)
if (!fn)
return NULL_TREE;
return build_call_expr_loc (loc, fn, 1, s1);
return fold_convert_loc (loc, type,
build_call_expr_loc (loc, fn, 1, s1));
}
return NULL_TREE;
}
+153
View File
@@ -1,3 +1,156 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2025-05-15 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2025-02-13 Jakub Jelinek <jakub@redhat.com>
PR c++/118822
* c-common.h (WHILE_COND_CLEANUP): Change description in comment.
(FOR_COND_CLEANUP): Likewise.
* c-gimplify.cc (genericize_c_loop): Adjust for COND_CLEANUP
being CLEANUP_STMT/TRY_FINALLY_EXPR trailing nesting depth
instead of actual cleanup.
2025-05-15 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2025-02-07 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
PR c++/86769
* c-common.def (FOR_STMT): Add 2 operands and document them.
(WHILE_STMT): Likewise.
* c-common.h (WHILE_COND_PREP, WHILE_COND_CLEANUP): Define.
(FOR_COND_PREP, FOR_COND_CLEANUP): Define.
* c-gimplify.cc (genericize_c_loop): Add COND_PREP and COND_CLEANUP
arguments, handle them if they are non-NULL.
(genericize_for_stmt, genericize_while_stmt, genericize_do_stmt):
Adjust callers.
2025-03-22 Martin Uecker <uecker@tugraz.at>
Backported from master:
2024-10-31 Martin Uecker <uecker@tugraz.at>
PR c/117145
PR c/117245
PR c/100420
* c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
Detect arrays of unspecified size.
2025-03-13 Eric Botcazou <ebotcazou@adacore.com>
PR ada/119265
* c-ada-spec.cc (dump_ada_node) <INTEGER_TYPE>: Deal with typedefs
of unsigned __int128.
2025-03-05 Marek Polacek <polacek@redhat.com>
Backported from master:
2025-03-05 Marek Polacek <polacek@redhat.com>
PR c++/115580
* c-common.cc (check_function_arguments): Return early if
c_inhibit_evaluation_warnings.
2025-01-09 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-11-26 Jakub Jelinek <jakub@redhat.com>
PR middle-end/43374
* c-cppbuiltin.cc (builtin_define_decimal_float_constants): Use
get_max_float.
2025-01-09 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-11-22 Jakub Jelinek <jakub@redhat.com>
PR c/117641
* c-common.cc (sync_resolve_size): For size 16 with _BitInt
on targets where TImode isn't supported, use goto incompatible if
!fetch.
2025-01-09 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-11-19 Jakub Jelinek <jakub@redhat.com>
PR c/117641
* c-common.cc (sync_resolve_size): For size == 16 fetch of
BITINT_TYPE if TImode isn't supported scalar mode diagnose
and return 0 if orig_format instead of returning 16.
2024-10-23 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-10-22 Jakub Jelinek <jakub@redhat.com>
PR c/117230
* c-warn.cc (sizeof_pointer_memaccess_warning): Only compare
TYPE_PRECISION of TREE_TYPE (type) to precision of char if
TREE_TYPE (type) is integral type.
2024-10-01 Jason Merrill <jason@redhat.com>
* c-cppbuiltin.cc (c_cpp_builtins): Don't define __cpp_concepts
before C++17.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-07-03 Lewis Hyatt <lhyatt@gmail.com>
PR pch/115312
* c-opts.cc (c_common_init): Call c_init_preprocess() before
c_finish_options() so that a parser is available to process any
includes specified on the command line.
2024-06-25 Andrew Pinski <quic_apinski@quicinc.com>
Backported from master:
2024-06-25 Andrew Pinski <quic_apinski@quicinc.com>
PR c++/115624
* c.opt (Wnrvo): Add Warning property.
2024-06-17 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-06-17 Jakub Jelinek <jakub@redhat.com>
PR c/115290
* c-warn.cc (do_warn_array_compare): Use %E rather than %D for
printing op0 and op1; if those operands aren't decls, also print
parens around them.
2024-05-15 Richard Biener <rguenther@suse.de>
Backported from master:
2024-05-07 Richard Biener <rguenther@suse.de>
PR middle-end/114931
* c-common.cc (complete_array_type): Set TYPE_STRUCTURAL_EQUALITY_P
before probing with type_hash_canon.
2024-05-07 Andrew Pinski <quic_apinski@quicinc.com>
Backported from master:
2024-05-07 Andrew Pinski <quic_apinski@quicinc.com>
PR c++/89224
* c-common.cc (convert_vector_to_array_for_subscript): Call build_qualified_type
for the inner type.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-23 Jakub Jelinek <jakub@redhat.com>
* c-attribs.cc (handle_objc_nullability_attribute): Spelling fix:
+2 -2
View File
@@ -2193,8 +2193,8 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
case BOOLEAN_TYPE:
if (TYPE_NAME (node)
&& !(TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
&& !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
"__int128")))
&& !strncmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
"__int128", 8)))
{
if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
pp_ada_tree_identifier (buffer, TYPE_NAME (node), node,
+22 -7
View File
@@ -6160,6 +6160,9 @@ check_function_arguments (location_t loc, const_tree fndecl, const_tree fntype,
{
bool warned_p = false;
if (c_inhibit_evaluation_warnings)
return warned_p;
/* Check for null being passed in a pointer argument that must be
non-null. In C++, this includes the this pointer. We also need
to do this if format checking is enabled. */
@@ -7115,6 +7118,13 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
TYPE_TYPELESS_STORAGE (main_type) = TYPE_TYPELESS_STORAGE (type);
layout_type (main_type);
/* Set TYPE_STRUCTURAL_EQUALITY_P early. */
if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type))
|| TYPE_STRUCTURAL_EQUALITY_P (TYPE_DOMAIN (main_type)))
SET_TYPE_STRUCTURAL_EQUALITY (main_type);
else
TYPE_CANONICAL (main_type) = main_type;
/* Make sure we have the canonical MAIN_TYPE. */
hashval_t hashcode = type_hash_canon_hash (main_type);
main_type = type_hash_canon (hashcode, main_type);
@@ -7122,7 +7132,7 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
/* Fix the canonical type. */
if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type))
|| TYPE_STRUCTURAL_EQUALITY_P (TYPE_DOMAIN (main_type)))
SET_TYPE_STRUCTURAL_EQUALITY (main_type);
gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (main_type));
else if (TYPE_CANONICAL (TREE_TYPE (main_type)) != TREE_TYPE (main_type)
|| (TYPE_CANONICAL (TYPE_DOMAIN (main_type))
!= TYPE_DOMAIN (main_type)))
@@ -7130,8 +7140,6 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
= build_array_type (TYPE_CANONICAL (TREE_TYPE (main_type)),
TYPE_CANONICAL (TYPE_DOMAIN (main_type)),
TYPE_TYPELESS_STORAGE (main_type));
else
TYPE_CANONICAL (main_type) = main_type;
if (quals == 0)
type = main_type;
@@ -7378,11 +7386,13 @@ sync_resolve_size (tree function, vec<tree, va_gc> *params, bool fetch,
size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
if (size == 16
&& fetch
&& !orig_format
&& TREE_CODE (type) == BITINT_TYPE
&& !targetm.scalar_mode_supported_p (TImode))
return -1;
{
if (fetch && !orig_format)
return -1;
goto incompatible;
}
if (size == 1 || size == 2 || size == 4 || size == 8 || size == 16)
return size;
@@ -8959,6 +8969,7 @@ convert_vector_to_array_for_subscript (location_t loc,
if (gnu_vector_type_p (TREE_TYPE (*vecp)))
{
tree type = TREE_TYPE (*vecp);
tree newitype;
ret = !lvalue_p (*vecp);
@@ -8973,8 +8984,12 @@ convert_vector_to_array_for_subscript (location_t loc,
for function parameters. */
c_common_mark_addressable_vec (*vecp);
/* Make sure qualifiers are copied from the vector type to the new element
of the array type. */
newitype = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
*vecp = build1 (VIEW_CONVERT_EXPR,
build_array_type_nelts (TREE_TYPE (type),
build_array_type_nelts (newitype,
TYPE_VECTOR_SUBPARTS (type)),
*vecp);
}
+7 -6
View File
@@ -58,13 +58,14 @@ DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_expression, 1)
DEFTREECODE (PAREN_SIZEOF_EXPR, "paren_sizeof_expr", tcc_expression, 1)
/* Used to represent a `for' statement. The operands are
FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, and FOR_SCOPE,
respectively. */
DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5)
FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE,
FOR_COND_PREP and FOR_COND_CLEANUP, respectively. */
DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 7)
/* Used to represent a 'while' statement. The operands are WHILE_COND
and WHILE_BODY, respectively. */
DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 2)
/* Used to represent a 'while' statement. The operands are WHILE_COND,
WHILE_BODY, WHILE_COND_PREP and WHILE_COND_CLEANUP,
respectively. */
DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 4)
/* Used to represent a 'do' statement. The operands are DO_COND and
DO_BODY, respectively. */
+10 -3
View File
@@ -1490,24 +1490,31 @@ extern tree build_userdef_literal (tree suffix_id, tree value,
tree num_string);
/* WHILE_STMT accessors. These give access to the condition of the
while statement and the body of the while statement, respectively. */
/* WHILE_STMT accessors. These give access to the condition of the
while statement and the body of the while statement, and
condition preparation statements and number of its nested cleanups,
respectively. */
#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
#define WHILE_COND_PREP(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 2)
#define WHILE_COND_CLEANUP(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 3)
/* DO_STMT accessors. These give access to the condition of the do
statement and the body of the do statement, respectively. */
#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0)
#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1)
/* FOR_STMT accessors. These give access to the init statement,
/* FOR_STMT accessors. These give access to the init statement,
condition, update expression, and body of the for statement,
and condition preparation statements and number of its nested cleanups,
respectively. */
#define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
#define FOR_SCOPE(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
#define FOR_COND_PREP(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 5)
#define FOR_COND_CLEANUP(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 6)
#define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
#define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
+5 -14
View File
@@ -357,17 +357,8 @@ builtin_define_decimal_float_constants (const char *name_prefix,
/* Compute the maximum representable value. */
sprintf (name, "__%s_MAX__", name_prefix);
p = buf;
for (digits = fmt->p; digits; digits--)
{
*p++ = '9';
if (digits == fmt->p)
*p++ = '.';
}
*p = 0;
/* fmt->p plus 1, to account for the decimal point and fmt->emax
minus 1 because the digits are nines, not 1.0. */
sprintf (&buf[fmt->p + 1], "E%d%s", fmt->emax - 1, suffix);
get_max_float (fmt, buf, sizeof (buf) - strlen (suffix), false);
strcat (buf, suffix);
builtin_define_with_value (name, buf, 0);
/* Compute epsilon (the difference between 1 and least value greater
@@ -1093,10 +1084,10 @@ c_cpp_builtins (cpp_reader *pfile)
}
if (flag_concepts)
{
if (cxx_dialect >= cxx20 || !flag_concepts_ts)
cpp_define (pfile, "__cpp_concepts=202002L");
else
if (flag_concepts_ts && cxx_dialect < cxx20)
cpp_define (pfile, "__cpp_concepts=201507L");
else if (cxx_dialect > cxx14)
cpp_define (pfile, "__cpp_concepts=202002L");
}
if (flag_contracts)
{
+73 -12
View File
@@ -225,21 +225,30 @@ expr_loc_or_loc (const_tree expr, location_t or_loc)
controlled by the loop. INCR is the increment expression of a for-loop,
or NULL_TREE. COND_IS_FIRST indicates whether the condition is
evaluated before the loop body as in while and for loops, or after the
loop body as in do-while loops. */
loop body as in do-while loops. COND_PREP and COND_CLEANUP are used
for C++ for/while loops with variable declaration as condition. COND_PREP
is a BIND_EXPR with the declaration and initialization of the condition
variable, into which COND, BODY, continue label if needed and INCR if
non-NULL should be appended, and COND_CLEANUP is number of nested
CLEANUP_STMT -> TRY_FINALLY_EXPR statements at the end. If non-NULL,
COND, BODY, continue label if needed and INCR if non-NULL should be
appended to the body of the COND_CLEANUP's nested TRY_FINALLY_EXPR. */
static void
genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
tree incr, bool cond_is_first, int *walk_subtrees,
void *data, walk_tree_fn func, walk_tree_lh lh)
tree incr, tree cond_prep, tree cond_cleanup,
bool cond_is_first, int *walk_subtrees, void *data,
walk_tree_fn func, walk_tree_lh lh)
{
tree blab, clab;
tree entry = NULL, exit = NULL, t;
tree stmt_list = NULL;
tree stmt_list = NULL, outer_stmt_list = NULL_TREE, *stmt_list_p = NULL;
location_t cond_locus = expr_loc_or_loc (cond, start_locus);
location_t incr_locus = expr_loc_or_loc (incr, start_locus);
protected_set_expr_location_if_unset (incr, start_locus);
walk_tree_1 (&cond_prep, func, data, NULL, lh);
walk_tree_1 (&cond, func, data, NULL, lh);
walk_tree_1 (&incr, func, data, NULL, lh);
@@ -249,9 +258,54 @@ genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
walk_tree_1 (&body, func, data, NULL, lh);
*walk_subtrees = 0;
/* If condition is zero don't generate a loop construct. */
if (cond && integer_zerop (cond))
if (cond_prep)
{
/* The C++ cases of
while (A x = 42) body;
for (; A x = 42; expr) body;
This should be expanded into:
top:
COND_PREP
with either
if (COND); else break;
BODY;
cont:
EXPR;
goto top;
appended into COND_PREP body or body of some TRY_FINALLY_EXPRs
at the end of COND_PREP. */
gcc_assert (cond_is_first && TREE_CODE (cond_prep) == BIND_EXPR);
tree top = build1 (LABEL_EXPR, void_type_node,
create_artificial_label (start_locus));
exit = build1 (GOTO_EXPR, void_type_node, LABEL_EXPR_LABEL (top));
append_to_statement_list (top, &outer_stmt_list);
append_to_statement_list (cond_prep, &outer_stmt_list);
stmt_list_p = &BIND_EXPR_BODY (cond_prep);
if (cond_cleanup)
for (unsigned depth = tree_to_uhwi (cond_cleanup); depth; --depth)
{
t = tsi_stmt (tsi_last (*stmt_list_p));
gcc_assert (TREE_CODE (t) == TRY_FINALLY_EXPR);
stmt_list_p = &TREE_OPERAND (t, 0);
}
stmt_list = *stmt_list_p;
*stmt_list_p = NULL_TREE;
tree after_cond = create_artificial_label (cond_locus);
tree goto_after_cond = build1 (GOTO_EXPR, void_type_node, after_cond);
t = build1 (GOTO_EXPR, void_type_node, get_bc_label (bc_break));
t = fold_build3_loc (cond_locus, COND_EXPR, void_type_node, cond,
goto_after_cond, t);
append_to_statement_list (t, &stmt_list);
t = build1 (LABEL_EXPR, void_type_node, after_cond);
append_to_statement_list (t, &stmt_list);
}
else if (cond && integer_zerop (cond))
{
/* If condition is zero don't generate a loop construct. */
if (cond_is_first)
{
t = build1_loc (start_locus, GOTO_EXPR, void_type_node,
@@ -348,6 +402,11 @@ genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
append_to_statement_list (d, &stmt_list);
}
append_to_statement_list (exit, &stmt_list);
if (stmt_list_p)
{
*stmt_list_p = stmt_list;
stmt_list = outer_stmt_list;
}
finish_bc_block (&stmt_list, bc_break, blab);
if (!stmt_list)
stmt_list = build_empty_stmt (start_locus);
@@ -373,8 +432,9 @@ genericize_for_stmt (tree *stmt_p, int *walk_subtrees, void *data,
}
genericize_c_loop (&loop, EXPR_LOCATION (stmt), FOR_COND (stmt),
FOR_BODY (stmt), FOR_EXPR (stmt), 1, walk_subtrees,
data, func, lh);
FOR_BODY (stmt), FOR_EXPR (stmt),
FOR_COND_PREP (stmt), FOR_COND_CLEANUP (stmt), 1,
walk_subtrees, data, func, lh);
append_to_statement_list (loop, &expr);
if (expr == NULL_TREE)
expr = loop;
@@ -389,8 +449,9 @@ genericize_while_stmt (tree *stmt_p, int *walk_subtrees, void *data,
{
tree stmt = *stmt_p;
genericize_c_loop (stmt_p, EXPR_LOCATION (stmt), WHILE_COND (stmt),
WHILE_BODY (stmt), NULL_TREE, 1, walk_subtrees,
data, func, lh);
WHILE_BODY (stmt), NULL_TREE,
WHILE_COND_PREP (stmt), WHILE_COND_CLEANUP (stmt), 1,
walk_subtrees, data, func, lh);
}
/* Genericize a DO_STMT node *STMT_P. */
@@ -401,8 +462,8 @@ genericize_do_stmt (tree *stmt_p, int *walk_subtrees, void *data,
{
tree stmt = *stmt_p;
genericize_c_loop (stmt_p, EXPR_LOCATION (stmt), DO_COND (stmt),
DO_BODY (stmt), NULL_TREE, 0, walk_subtrees,
data, func, lh);
DO_BODY (stmt), NULL_TREE,
NULL_TREE, NULL_TREE, 0, walk_subtrees, data, func, lh);
}
/* Genericize a SWITCH_STMT node *STMT_P by turning it into a SWITCH_EXPR. */
+1 -1
View File
@@ -1285,8 +1285,8 @@ c_common_init (void)
if (flag_preprocess_only)
{
c_finish_options ();
c_init_preprocess ();
c_finish_options ();
preprocess_file (parse_in);
return false;
}
+5 -1
View File
@@ -688,7 +688,11 @@ c_pretty_printer::direct_abstract_declarator (tree t)
maxval = TREE_OPERAND (maxval, 0);
}
expression (maxval);
/* This covers unspecified bounds. */
if (TREE_CODE (maxval) == COMPOUND_EXPR)
pp_string (this, "*");
else
expression (maxval);
}
}
else if (TYPE_SIZE (t))
+21 -12
View File
@@ -944,8 +944,9 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
"argument to %<sizeof%> in %qD call is the same "
"expression as the destination; did you mean to "
"remove the addressof?", callee);
else if ((TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node))
else if ((INTEGRAL_TYPE_P (TREE_TYPE (type))
&& (TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node)))
|| strop)
warning_at (loc, OPT_Wsizeof_pointer_memaccess,
"argument to %<sizeof%> in %qD call is the same "
@@ -984,8 +985,9 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
"argument to %<sizeof%> in %qD call is the same "
"expression as the source; did you mean to "
"remove the addressof?", callee);
else if ((TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node))
else if ((INTEGRAL_TYPE_P (TREE_TYPE (type))
&& (TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node)))
|| strop)
warning_at (loc, OPT_Wsizeof_pointer_memaccess,
"argument to %<sizeof%> in %qD call is the same "
@@ -1024,8 +1026,9 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
"argument to %<sizeof%> in %qD call is the same "
"expression as the first source; did you mean to "
"remove the addressof?", callee);
else if ((TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node))
else if ((INTEGRAL_TYPE_P (TREE_TYPE (type))
&& (TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node)))
|| strop)
warning_at (loc, OPT_Wsizeof_pointer_memaccess,
"argument to %<sizeof%> in %qD call is the same "
@@ -1064,8 +1067,9 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
"argument to %<sizeof%> in %qD call is the same "
"expression as the second source; did you mean to "
"remove the addressof?", callee);
else if ((TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node))
else if ((INTEGRAL_TYPE_P (TREE_TYPE (type))
&& (TYPE_PRECISION (TREE_TYPE (type))
== TYPE_PRECISION (char_type_node)))
|| strop)
warning_at (loc, OPT_Wsizeof_pointer_memaccess,
"argument to %<sizeof%> in %qD call is the same "
@@ -3830,11 +3834,16 @@ do_warn_array_compare (location_t location, tree_code code, tree op0, tree op1)
/* C doesn't allow +arr. */
if (c_dialect_cxx ())
inform (location, "use unary %<+%> which decays operands to pointers "
"or %<&%D[0] %s &%D[0]%> to compare the addresses",
op0, op_symbol_code (code), op1);
"or %<&%s%E%s[0] %s &%s%E%s[0]%> to compare the addresses",
DECL_P (op0) ? "" : "(", op0, DECL_P (op0) ? "" : ")",
op_symbol_code (code),
DECL_P (op1) ? "" : "(", op1, DECL_P (op1) ? "" : ")");
else
inform (location, "use %<&%D[0] %s &%D[0]%> to compare the addresses",
op0, op_symbol_code (code), op1);
inform (location,
"use %<&%s%E%s[0] %s &%s%E%s[0]%> to compare the addresses",
DECL_P (op0) ? "" : "(", op0, DECL_P (op0) ? "" : ")",
op_symbol_code (code),
DECL_P (op1) ? "" : "(", op1, DECL_P (op1) ? "" : ")");
}
}
+1 -1
View File
@@ -1133,7 +1133,7 @@ C ObjC Var(warn_override_init_side_effects) Init(1) Warning
Warn about overriding initializers with side effects.
Wnrvo
C++ ObjC++ Var(warn_nrvo)
C++ ObjC++ Var(warn_nrvo) Warning
Warn if the named return value optimization is not performed although it is allowed.
Wpacked-bitfield-compat
+172
View File
@@ -1,3 +1,175 @@
2025-05-23 Release Manager
* GCC 14.3.0 released.
2025-05-15 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2025-02-07 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
PR c++/86769
* c-parser.cc (c_parser_while_statement): Add 2 further NULL_TREE
operands to build_stmt.
(c_parser_for_statement): Likewise.
2025-05-14 Joseph Myers <josmyers@redhat.com>
Backported from master:
2024-11-18 Joseph Myers <josmyers@redhat.com>
PR c/112556
* c-typeck.cc (convert_for_assignment): Allow conversion of
ENUMERAL_TYPE and BOOLEAN_TYPE null pointer constants to pointers.
2025-04-19 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2025-04-02 Jakub Jelinek <jakub@redhat.com>
PR c/119582
* c-typeck.cc (pointer_diff, build_binary_op): Call c_fully_fold on
__sanitizer_ptr_sub or __sanitizer_ptr_cmp arguments.
2025-03-27 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2025-02-25 Jakub Jelinek <jakub@redhat.com>
PR c/119000
* c-parser.cc (c_parser_omp_atomic): For omp write call
default_function_array_read_conversion on the rhs expression.
Merge the two adjacent if (code == NOP_EXPR) blocks.
2025-03-22 Martin Uecker <uecker@tugraz.at>
Backported from master:
2024-11-30 Martin Uecker <uecker@tugraz.at>
PR c/117806
* c-typeck.cc (composite_type_internal): Call decl_attributes.
2025-03-22 Martin Uecker <uecker@tugraz.at>
Backported from master:
2024-11-09 Martin Uecker <uecker@tugraz.at>
PR c/116284
PR c/117391
* c-tree.h (c_type_unspecified_p): New inline function.
* c-typeck.cc (c_build_array_type_unspecified): New function.
(comptypes_interal): Remove useless code.
(composite_type_internal): Update.
* c-decl.cc (grokdeclarator): Revise.
2025-03-22 Martin Uecker <uecker@tugraz.at>
Backported from master:
2024-10-31 Martin Uecker <uecker@tugraz.at>
PR c/117145
PR c/117245
PR c/100420
* c-decl.cc (c_build_pointer_type): Move to c-typeck.cc
(grokdeclarator): Simplify logic.
(match_builtin_function_types): Adapt.
(push_decl): Adapt.
(implicitly_declare): Adapt.
(c_update_type_canonical): Adapt.
(c_make_fname_decl): Adapt.
(start_function): Adapt.
* c-objc-common.h: Add LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE.
* c-tree.h: Add prototypes.
* c-typeck.cc (c_verify_type): New function.
(c_set_type_bits). New function.
(c_build_pointer_type): Moved from c-decl.cc.
(c_build_pointer_type_for_mode): New function.
(c_build_function_type): New function.
(c_build_array_type): New function.
(c_build_type_attribute_variant): New function.
(c_reconstruct_complex_type): New function.
(c_build_functype_attribute_variant): Renamed.
(array_to_pointer_conversion): Simplify logic.
(composite_type_internal): Simplify logic..
(build_unary_op): Simplify logic..
(comptypes_verify): Add checking assertions.
(c_build_qualified_type): Add checking assertions.
(c_build_function_call_vec): Adapt.
(qualify_type): Adapt.
(build_functype_attribute_variant): Adapt.
(common_pointer_type): Adapt.
(c_common_type): Adapt.
(convert_for_assignment): Adapt.
(type_or_builtin_type): Adapt.
(build_access_with_size_for_counted_by): Adapt.
(build_conditional_expr): Adapt.
(build_modify_expr): Adapt.
(build_binary_op): Adapt.
(build_omp_array_section): Adapt.
(handle_omp_array_sections): Adapt.
(c_finish_omp_clauses): Adapt.
* c-parser.cc (c_parser_typeof_specifier): Adapt.
(c_parser_generic_selection): Adapt.
2025-01-09 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-11-27 Jakub Jelinek <jakub@redhat.com>
PR c/117745
* c-parser.cc (c_parser_sizeof_expression): If type_name is NULL,
just expr.set_error () and goto sizeof_expr instead of doing error
recovery manually.
2024-10-09 Martin Uecker <uecker@tugraz.at>
Backported from master:
2024-09-20 Martin Uecker <uecker@tugraz.at>
PR c/116726
* c-typeck.cc (tagged_types_tu_compatible_p): Restore value
of the cache after recursing into comptypes_internal.
2024-08-01 Release Manager
* GCC 14.2.0 released.
2024-07-01 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-06-25 Jakub Jelinek <jakub@redhat.com>
Martin Uecker <uecker@tugraz.at>
PR c/114930
PR c/115502
* c-decl.cc (c_update_type_canonical): Assert t is main variant
with 0 TYPE_QUALS. Simplify and don't use check_qualified_type.
Deal with the case where build_qualified_type returns
TYPE_STRUCTURAL_EQUALITY_P type.
2024-06-25 Sandra Loosemore <sloosemore@baylibre.com>
Backported from master:
2024-06-25 Sandra Loosemore <sloosemore@baylibre.com>
PR c/115587
* c-parser.cc (c_parser_omp_loop_nest): Move initializations to
point of declaration.
2024-06-06 Jakub Jelinek <jakub@redhat.com>
Backported from master:
2024-06-06 Jakub Jelinek <jakub@redhat.com>
PR c/114493
* c-decl.cc (c_fixup_may_alias): New function.
(finish_struct): Call it if "may_alias" attribute is
specified.
2024-05-07 Release Manager
* GCC 14.1.0 released.
2024-04-19 Martin Uecker <uecker@tugraz.at>
Jakub Jelinek <jakub@redhat.com>
+81 -93
View File
@@ -705,22 +705,9 @@ add_stmt (tree t)
return t;
}
/* Build a pointer type using the default pointer mode. */
static tree
c_build_pointer_type (tree to_type)
{
addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC
: TYPE_ADDR_SPACE (to_type);
machine_mode pointer_mode;
if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
pointer_mode = targetm.addr_space.pointer_mode (as);
else
pointer_mode = c_default_pointer_mode;
return build_pointer_type_for_mode (to_type, pointer_mode, false);
}
/* Return true if we will want to say something if a goto statement
@@ -1912,7 +1899,7 @@ match_builtin_function_types (tree newtype, tree oldtype,
newargs = TREE_CHAIN (newargs);
}
tree trytype = build_function_type (newrettype, tryargs);
tree trytype = c_build_function_type (newrettype, tryargs);
/* Allow declaration to change transaction_safe attribute. */
tree oldattrs = TYPE_ATTRIBUTES (oldtype);
@@ -1925,7 +1912,7 @@ match_builtin_function_types (tree newtype, tree oldtype,
oldattrs = tree_cons (get_identifier ("transaction_safe"),
NULL_TREE, oldattrs);
return build_type_attribute_variant (trytype, oldattrs);
return c_build_type_attribute_variant (trytype, oldattrs);
}
/* Subroutine of diagnose_mismatched_decls. Check for function type
@@ -3386,9 +3373,9 @@ pushdecl (tree x)
if (TREE_CODE (b_use->decl) == FUNCTION_DECL
&& fndecl_built_in_p (b_use->decl))
thistype
= build_type_attribute_variant (thistype,
TYPE_ATTRIBUTES
(b_use->u.type));
= c_build_type_attribute_variant (thistype,
TYPE_ATTRIBUTES
(b_use->u.type));
TREE_TYPE (b_use->decl) = thistype;
}
return b_use->decl;
@@ -3486,8 +3473,8 @@ pushdecl (tree x)
b->u.type = TREE_TYPE (b->decl);
/* Propagate the type attributes to the decl. */
thistype
= build_type_attribute_variant (thistype,
TYPE_ATTRIBUTES (b->u.type));
= c_build_type_attribute_variant (thistype,
TYPE_ATTRIBUTES (b->u.type));
TREE_TYPE (b->decl) = thistype;
bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
locus);
@@ -3885,9 +3872,9 @@ implicitly_declare (location_t loc, tree functionid)
}
if (fndecl_built_in_p (decl))
{
newtype = build_type_attribute_variant (newtype,
TYPE_ATTRIBUTES
(TREE_TYPE (decl)));
newtype = c_build_type_attribute_variant (newtype,
TYPE_ATTRIBUTES
(TREE_TYPE (decl)));
if (!comptypes (newtype, TREE_TYPE (decl)))
{
auto_diagnostic_group d;
@@ -4790,8 +4777,8 @@ c_make_fname_decl (location_t loc, tree id, int type_dep)
tree decl, type, init;
size_t length = strlen (name);
type = build_array_type (char_type_node,
build_index_type (size_int (length)));
type = c_build_array_type (char_type_node,
build_index_type (size_int (length)));
type = c_build_qualified_type (type, TYPE_QUAL_CONST);
decl = build_decl (loc, VAR_DECL, id, type);
@@ -7157,8 +7144,6 @@ grokdeclarator (const struct c_declarator *declarator,
array_parm_static = false;
}
bool varmod = C_TYPE_VARIABLY_MODIFIED (type);
switch (declarator->kind)
{
case cdk_attrs:
@@ -7440,31 +7425,16 @@ grokdeclarator (const struct c_declarator *declarator,
/* ISO C99 Flexible array members are effectively
identical to GCC's zero-length array extension. */
if (flexible_array_member || array_parm_vla_unspec_p)
itype = build_range_type (sizetype, size_zero_node,
NULL_TREE);
if (flexible_array_member)
itype = build_index_type (NULL_TREE);
}
else if (decl_context == PARM)
if (array_parm_vla_unspec_p)
{
if (array_parm_vla_unspec_p)
{
itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
size_varies = true;
}
}
else if (decl_context == TYPENAME)
{
if (array_parm_vla_unspec_p)
{
/* C99 6.7.5.2p4 */
warning (0, "%<[*]%> not in a declaration");
/* We use this to avoid messing up with incomplete
array types of the same type, that would
otherwise be modified below. */
itype = build_range_type (sizetype, size_zero_node,
NULL_TREE);
size_varies = true;
}
/* C99 6.7.5.2p4 */
if (decl_context == TYPENAME)
warning (0, "%<[*]%> not in a declaration");
size_varies = true;
}
/* Complain about arrays of incomplete types. */
@@ -7497,26 +7467,16 @@ grokdeclarator (const struct c_declarator *declarator,
{
addr_space_t as = DECODE_QUAL_ADDR_SPACE (type_quals);
if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type))
type = build_qualified_type (type,
ENCODE_QUAL_ADDR_SPACE (as));
type = build_array_type (type, itype);
type = c_build_qualified_type (type,
ENCODE_QUAL_ADDR_SPACE (as));
if (array_parm_vla_unspec_p)
type = c_build_array_type_unspecified (type);
else
type = c_build_array_type (type, itype);
}
if (type != error_mark_node)
{
if (size_varies)
{
/* It is ok to modify type here even if itype is
NULL: if size_varies, we're in a
multi-dimensional array and the inner type has
variable size, so the enclosing shared array type
must too. */
if (size && TREE_CODE (size) == INTEGER_CST)
type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
C_TYPE_VARIABLE_SIZE (type) = 1;
}
/* The GCC extension for zero-length arrays differs from
ISO flexible array members in that sizeof yields
zero. */
@@ -7528,15 +7488,6 @@ grokdeclarator (const struct c_declarator *declarator,
TYPE_SIZE_UNIT (type) = size_zero_node;
SET_TYPE_STRUCTURAL_EQUALITY (type);
}
if (array_parm_vla_unspec_p)
{
gcc_assert (itype);
/* The type is complete. C99 6.7.5.2p4 */
type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
TYPE_SIZE (type) = bitsize_zero_node;
TYPE_SIZE_UNIT (type) = size_zero_node;
SET_TYPE_STRUCTURAL_EQUALITY (type);
}
if (!valid_array_size_p (loc, type, name))
type = error_mark_node;
@@ -7659,8 +7610,8 @@ grokdeclarator (const struct c_declarator *declarator,
}
type_quals = TYPE_UNQUALIFIED;
type = build_function_type (type, arg_types,
arg_info->no_named_args_stdarg_p);
type = c_build_function_type (type, arg_types,
arg_info->no_named_args_stdarg_p);
declarator = declarator->declarator;
/* Set the TYPE_CONTEXTs for each tagged type which is local to
@@ -7725,8 +7676,6 @@ grokdeclarator (const struct c_declarator *declarator,
default:
gcc_unreachable ();
}
if (type != error_mark_node)
C_TYPE_VARIABLY_MODIFIED (type) = varmod || size_varies;
}
*decl_attrs = chainon (returned_attrs, *decl_attrs);
*decl_attrs = chainon (decl_id_attrs, *decl_attrs);
@@ -8049,7 +7998,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (TREE_CODE (type) == FUNCTION_TYPE)
{
error_at (loc, "field %qE declared as a function", name);
type = build_pointer_type (type);
type = c_build_pointer_type (type);
}
else if (TREE_CODE (type) != ERROR_MARK
&& !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
@@ -9363,18 +9312,42 @@ is_flexible_array_member_p (bool is_last_field,
static void
c_update_type_canonical (tree t)
{
for (tree x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
gcc_checking_assert (TYPE_MAIN_VARIANT (t) == t && !TYPE_QUALS (t));
for (tree x = t, l = NULL_TREE; x; l = x, x = TYPE_NEXT_VARIANT (x))
{
if (x != t && TYPE_STRUCTURAL_EQUALITY_P (x))
{
if (TYPE_QUALS (x) == TYPE_QUALS (t))
if (!TYPE_QUALS (x))
TYPE_CANONICAL (x) = TYPE_CANONICAL (t);
else if (TYPE_CANONICAL (t) != t
|| check_qualified_type (x, t, TYPE_QUALS (x)))
TYPE_CANONICAL (x)
= build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
else
TYPE_CANONICAL (x) = x;
{
tree
c = c_build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
if (TYPE_STRUCTURAL_EQUALITY_P (c))
{
gcc_checking_assert (TYPE_CANONICAL (t) == t);
if (c == x)
TYPE_CANONICAL (x) = x;
else
{
/* build_qualified_type for this function unhelpfully
moved c from some later spot in TYPE_MAIN_VARIANT (t)
chain to right after t (or created it there). Move
it right before x and process c and then x. */
gcc_checking_assert (TYPE_NEXT_VARIANT (t) == c);
if (l != t)
{
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (c);
TYPE_NEXT_VARIANT (l) = c;
TYPE_NEXT_VARIANT (c) = x;
}
TYPE_CANONICAL (c) = c;
x = c;
}
}
else
TYPE_CANONICAL (x) = TYPE_CANONICAL (c);
}
}
else if (x != t)
continue;
@@ -9384,8 +9357,8 @@ c_update_type_canonical (tree t)
continue;
if (TYPE_CANONICAL (x) != x || TYPE_REF_CAN_ALIAS_ALL (p))
TYPE_CANONICAL (p)
= build_pointer_type_for_mode (TYPE_CANONICAL (x), TYPE_MODE (p),
false);
= c_build_pointer_type_for_mode (TYPE_CANONICAL (x), TYPE_MODE (p),
false);
else
TYPE_CANONICAL (p) = p;
c_update_type_canonical (p);
@@ -9393,6 +9366,17 @@ c_update_type_canonical (tree t)
}
}
/* TYPE is a struct or union that we're applying may_alias to after the body is
parsed. Fixup any POINTER_TO types. */
static void
c_fixup_may_alias (tree type)
{
for (tree t = TYPE_POINTER_TO (type); t; t = TYPE_NEXT_PTR_TO (t))
for (tree v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
TYPE_REF_CAN_ALIAS_ALL (v) = true;
}
/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
FIELDLIST is a chain of FIELD_DECL nodes for the fields.
@@ -9737,6 +9721,10 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
C_TYPE_BEING_DEFINED (t) = 0;
if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (t)))
for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
c_fixup_may_alias (x);
/* Set type canonical based on equivalence class. */
if (flag_isoc23)
{
@@ -10507,9 +10495,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
error_at (loc, "return type is an incomplete type");
/* Make it return void instead. */
TREE_TYPE (decl1)
= build_function_type (void_type_node,
TYPE_ARG_TYPES (TREE_TYPE (decl1)),
TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl1)));
= c_build_function_type (void_type_node,
TYPE_ARG_TYPES (TREE_TYPE (decl1)),
TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (decl1)));
}
if (warn_about_return_type)
+2
View File
@@ -74,6 +74,8 @@ extern void c_register_features ();
#define LANG_HOOKS_EMITS_BEGIN_STMT true
#undef LANG_HOOKS_FINALIZE_EARLY_DEBUG
#define LANG_HOOKS_FINALIZE_EARLY_DEBUG c_common_finalize_early_debug
#undef LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE
#define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE c_reconstruct_complex_type
static const scoped_attribute_specs *const c_objc_attribute_table[] =
{
+20 -25
View File
@@ -4399,7 +4399,7 @@ c_parser_typeof_specifier (c_parser *parser)
else if (FUNCTION_POINTER_TYPE_P (ret.spec)
&& TYPE_QUALS (TREE_TYPE (ret.spec)) != TYPE_UNQUALIFIED)
ret.spec
= build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (ret.spec)));
= c_build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (ret.spec)));
}
}
return ret;
@@ -8149,7 +8149,8 @@ c_parser_while_statement (c_parser *parser, bool ivdep, unsigned short unroll,
location_t loc_after_labels;
bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
add_stmt (build_stmt (loc, WHILE_STMT, cond, body));
add_stmt (build_stmt (loc, WHILE_STMT, cond, body, NULL_TREE,
NULL_TREE));
add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_parser_maybe_reclassify_token (parser);
@@ -8507,7 +8508,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll,
objc_foreach_continue_label);
else
add_stmt (build_stmt (for_loc, FOR_STMT, NULL_TREE, cond, incr,
body, NULL_TREE));
body, NULL_TREE, NULL_TREE, NULL_TREE));
add_stmt (c_end_compound_stmt (for_loc, block,
flag_isoc99 || c_dialect_objc ()));
c_parser_maybe_reclassify_token (parser);
@@ -9891,13 +9892,11 @@ c_parser_sizeof_expression (c_parser *parser)
finish = parser->tokens_buf[0].location;
if (type_name == NULL)
{
struct c_expr ret;
c_inhibit_evaluation_warnings--;
in_sizeof--;
ret.set_error ();
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
/* Let c_expr_sizeof_expr call pop_maybe_used and fill in c_expr
for parsing error; the parsing of the expression could have
called record_maybe_used_decl. */
expr.set_error ();
goto sizeof_expr;
}
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
{
@@ -21194,9 +21193,16 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc)
goto saw_error;
if (code == NOP_EXPR)
{
lhs = c_parser_expression (parser).value;
lhs = c_fully_fold (lhs, false, NULL);
if (lhs == error_mark_node)
eloc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
expr = default_function_array_read_conversion (eloc, expr);
/* atomic write is represented by OMP_ATOMIC with NOP_EXPR
opcode. */
code = OMP_ATOMIC;
lhs = v;
v = NULL_TREE;
rhs = c_fully_fold (expr.value, false, NULL);
if (rhs == error_mark_node)
goto saw_error;
}
else
@@ -21209,15 +21215,6 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc)
if (non_lvalue_p)
lhs = non_lvalue (lhs);
}
if (code == NOP_EXPR)
{
/* atomic write is represented by OMP_ATOMIC with NOP_EXPR
opcode. */
code = OMP_ATOMIC;
rhs = lhs;
lhs = v;
v = NULL_TREE;
}
goto done;
case OMP_ATOMIC_CAPTURE_NEW:
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
@@ -22240,7 +22237,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
static tree
c_parser_omp_loop_nest (c_parser *parser, bool *if_p)
{
tree decl, cond, incr, init;
tree decl = NULL_TREE, cond = NULL_TREE, incr = NULL_TREE, init = NULL_TREE;
tree body = NULL_TREE;
matching_parens parens;
bool moreloops;
@@ -22330,7 +22327,6 @@ c_parser_omp_loop_nest (c_parser *parser, bool *if_p)
}
/* Parse the loop condition. */
cond = NULL_TREE;
if (c_parser_next_token_is_not (parser, CPP_SEMICOLON))
{
location_t cond_loc = c_parser_peek_token (parser)->location;
@@ -22363,7 +22359,6 @@ c_parser_omp_loop_nest (c_parser *parser, bool *if_p)
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
/* Parse the increment expression. */
incr = NULL_TREE;
if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN))
{
location_t incr_loc = c_parser_peek_token (parser)->location;
+19 -2
View File
@@ -748,12 +748,22 @@ extern struct c_switch *c_switch_stack;
extern bool null_pointer_constant_p (const_tree);
inline
bool c_type_variably_modified_p (tree t)
inline bool
c_type_variably_modified_p (tree t)
{
return error_mark_node != t && C_TYPE_VARIABLY_MODIFIED (t);
}
inline bool
c_type_unspecified_p (tree t)
{
return error_mark_node != t
&& C_TYPE_VARIABLE_SIZE (t) && TREE_CODE (t) == ARRAY_TYPE
&& TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t))
&& TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == COMPOUND_EXPR
&& integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
&& integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 1));
}
extern bool char_type_p (tree);
extern tree c_objc_common_truthvalue_conversion (location_t, tree,
@@ -848,6 +858,13 @@ extern tree c_build_function_call_vec (location_t, const vec<location_t>&,
tree, vec<tree, va_gc> *,
vec<tree, va_gc> *);
extern tree c_omp_clause_copy_ctor (tree, tree, tree);
extern tree c_reconstruct_complex_type (tree, tree);
extern tree c_build_type_attribute_variant (tree ntype, tree attrs);
extern tree c_build_pointer_type (tree type);
extern tree c_build_array_type (tree type, tree domain);
extern tree c_build_array_type_unspecified (tree type);
extern tree c_build_function_type (tree type, tree args, bool no = false);
extern tree c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m);
/* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */
+319 -71
View File
@@ -356,6 +356,202 @@ qualify_type (tree type, tree like)
| ENCODE_QUAL_ADDR_SPACE (as_common));
}
/* Check consistency of type TYPE. For derived types, we test that
C_TYPE_VARIABLE_SIZE and C_TYPE_VARIABLY_MODIFIED are consistent with
the requirements of the base type. We also check that arrays with a
non-constant length are marked with C_TYPE_VARIABLE_SIZE. If any
inconsistency is detected false is returned and true otherwise. */
static bool
c_verify_type (tree type)
{
switch (TREE_CODE (type))
{
case POINTER_TYPE:
case FUNCTION_TYPE:
/* Pointer and funcions can not have variable size. */
if (C_TYPE_VARIABLE_SIZE (type))
return false;
/* Pointer and funcions are variably modified if and only if the
return / target type is variably modified. */
if (C_TYPE_VARIABLY_MODIFIED (type)
!= C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type)))
return false;
break;
case ARRAY_TYPE:
/* An array has variable size if and only if it has a non-constant
dimensions or its element type has variable size. */
if ((C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
|| (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
&& TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
!= INTEGER_CST))
!= C_TYPE_VARIABLE_SIZE (type))
return false;
/* If the element type or the array has variable size, then the
array has variable size and is variably modified. */
if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
|| C_TYPE_VARIABLE_SIZE (type))
{
if (!C_TYPE_VARIABLE_SIZE (type))
return false;
if (!C_TYPE_VARIABLY_MODIFIED (type))
return false;
}
/* If the element type is variably modified, then also the array. */
if (C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type))
&& !C_TYPE_VARIABLY_MODIFIED (type))
return false;
break;
default:
break;
}
return true;
}
/* Propagate C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
from a base type to a newly built derived or qualified type. */
static tree
c_set_type_bits (tree new_type, tree old_type)
{
gcc_checking_assert (c_verify_type (old_type));
if (C_TYPE_VARIABLY_MODIFIED (old_type))
C_TYPE_VARIABLY_MODIFIED (new_type) = true;
if (TREE_CODE (new_type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (old_type))
{
C_TYPE_VARIABLY_MODIFIED (new_type) = true;
C_TYPE_VARIABLE_SIZE (new_type) = true;
}
return new_type;
}
/* Build a pointer type using the default pointer mode. */
tree
c_build_pointer_type (tree to_type)
{
addr_space_t as = to_type == error_mark_node ? ADDR_SPACE_GENERIC
: TYPE_ADDR_SPACE (to_type);
machine_mode pointer_mode;
if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
pointer_mode = targetm.addr_space.pointer_mode (as);
else
pointer_mode = c_default_pointer_mode;
return c_build_pointer_type_for_mode (to_type, pointer_mode, false);
}
/* Build a pointer type using the given mode. */
tree
c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m)
{
tree ret = build_pointer_type_for_mode (type, mode, m);
return c_set_type_bits (ret, type);
}
/* Build a function type. */
tree
c_build_function_type (tree type, tree args, bool no)
{
tree ret = build_function_type (type, args, no);
return c_set_type_bits (ret, type);
}
/* Build an array type. This sets typeless storage as required
by C2Y and C_TYPE_VARIABLY_MODIFIED and C_TYPE_VARIABLE_SIZE
based on the element type and domain. */
tree
c_build_array_type (tree type, tree domain)
{
int type_quals = TYPE_QUALS (type);
/* Identify typeless storage as introduced in C2Y
and supported also in earlier language modes. */
bool typeless = (char_type_p (type) && !(type_quals & TYPE_QUAL_ATOMIC))
|| (AGGREGATE_TYPE_P (type) && TYPE_TYPELESS_STORAGE (type));
tree ret = build_array_type (type, domain, typeless);
if (domain && TYPE_MAX_VALUE (domain)
&& TREE_CODE (TYPE_MAX_VALUE (domain)) != INTEGER_CST)
{
C_TYPE_VARIABLE_SIZE (ret) = 1;
C_TYPE_VARIABLY_MODIFIED (ret) = 1;
}
return c_set_type_bits (ret, type);
}
/* Build an array type of unspecified size. */
tree
c_build_array_type_unspecified (tree type)
{
tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node),
integer_zero_node, size_zero_node);
return c_build_array_type (type, build_index_type (upper));
}
tree
c_build_type_attribute_qual_variant (tree type, tree attrs, int quals)
{
tree ret = build_type_attribute_qual_variant (type, attrs, quals);
return c_set_type_bits (ret, type);
}
tree
c_build_type_attribute_variant (tree type, tree attrs)
{
return c_build_type_attribute_qual_variant (type, attrs, TYPE_QUALS (type));
}
/* Reconstruct a complex derived type. This is used to re-construct types
with the vector attribute. It is called via a langhook. */
tree
c_reconstruct_complex_type (tree type, tree bottom)
{
tree inner, outer;
if (TREE_CODE (type) == POINTER_TYPE)
{
inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
outer = c_build_pointer_type_for_mode (inner, TYPE_MODE (type),
TYPE_REF_CAN_ALIAS_ALL (type));
}
else if (TREE_CODE (type) == ARRAY_TYPE)
{
inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
outer = c_build_array_type (inner, TYPE_DOMAIN (type));
gcc_checking_assert (C_TYPE_VARIABLE_SIZE (type)
== C_TYPE_VARIABLE_SIZE (outer));
gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (outer)
== C_TYPE_VARIABLY_MODIFIED (type));
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
outer = c_build_function_type (inner, TYPE_ARG_TYPES (type),
TYPE_NO_NAMED_ARGS_STDARG_P (type));
}
else if (TREE_CODE (type) == REFERENCE_TYPE
|| TREE_CODE (type) == OFFSET_TYPE)
gcc_unreachable ();
else
return bottom;
return c_build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
TYPE_QUALS (type));
}
/* If NTYPE is a type of a non-variadic function with a prototype
and OTYPE is a type of a function without a prototype and ATTRS
@@ -364,7 +560,7 @@ qualify_type (tree type, tree like)
the (possibly) modified ATTRS. */
static tree
build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
{
if (!prototype_p (otype)
&& prototype_p (ntype)
@@ -375,9 +571,11 @@ build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
"does not take variable arguments", "format");
attrs = remove_attribute ("format", attrs);
}
return build_type_attribute_variant (ntype, attrs);
return c_build_type_attribute_variant (ntype, attrs);
}
/* Return the composite type of two compatible types.
We assume that comptypes has already been done and returned
@@ -439,8 +637,8 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
tree pointed_to_2 = TREE_TYPE (t2);
tree target = composite_type_internal (pointed_to_1,
pointed_to_2, cache);
t1 = build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
t1 = build_type_attribute_variant (t1, attributes);
t1 = c_build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
t1 = c_build_type_attribute_variant (t1, attributes);
return qualify_type (t1, t2);
}
@@ -472,21 +670,29 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
d2_variable = (!d2_zero
&& (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
|| TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
d1_variable = d1_variable || (d1_zero && C_TYPE_VARIABLE_SIZE (t1));
d2_variable = d2_variable || (d2_zero && C_TYPE_VARIABLE_SIZE (t2));
bool use1 = TYPE_DOMAIN (t1)
&& (d2_variable || d2_zero || !d1_variable);
bool use2 = TYPE_DOMAIN (t2)
&& (d1_variable || d1_zero || !d2_variable);
/* If the first is an unspecified size pick the other one. */
if (d2_variable && c_type_unspecified_p (t1))
{
gcc_assert (use1 && use2);
use1 = false;
}
/* Save space: see if the result is identical to one of the args. */
if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1)
&& (d2_variable || d2_zero || !d1_variable))
return build_type_attribute_variant (t1, attributes);
if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2)
&& (d1_variable || d1_zero || !d2_variable))
return build_type_attribute_variant (t2, attributes);
if (elt == TREE_TYPE (t1) && use1)
return c_build_type_attribute_variant (t1, attributes);
if (elt == TREE_TYPE (t2) && use2)
return c_build_type_attribute_variant (t2, attributes);
if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
return build_type_attribute_variant (t1, attributes);
return c_build_type_attribute_variant (t1, attributes);
if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
return build_type_attribute_variant (t2, attributes);
return c_build_type_attribute_variant (t2, attributes);
/* Merge the element types, and have a size if either arg has
one. We may have qualifiers on the element types. To set
@@ -495,13 +701,15 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
back at the end. */
quals = TYPE_QUALS (strip_array_types (elt));
unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
t1 = build_array_type (unqual_elt,
TYPE_DOMAIN ((TYPE_DOMAIN (t1)
&& (d2_variable
|| d2_zero
|| !d1_variable))
? t1
: t2));
t1 = c_build_array_type (unqual_elt, TYPE_DOMAIN (use1 ? t1 : t2));
/* Check that a type which has a varying outermost dimension
got marked has having a variable size. */
bool varsize = (d1_variable && d2_variable)
|| (d1_variable && !t2_complete)
|| (d2_variable && !t1_complete);
gcc_checking_assert (!varsize || C_TYPE_VARIABLE_SIZE (t1));
/* Ensure a composite type involving a zero-length array type
is a zero-length type not an incomplete type. */
if (d1_zero && d2_zero
@@ -512,7 +720,7 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
TYPE_SIZE_UNIT (t1) = size_zero_node;
}
t1 = c_build_qualified_type (t1, quals);
return build_type_attribute_variant (t1, attributes);
return c_build_type_attribute_variant (t1, attributes);
}
case RECORD_TYPE:
@@ -565,6 +773,8 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
decl_attributes (&f, DECL_ATTRIBUTES (f), 0);
finish_decl (f, input_location, NULL, NULL, NULL);
if (DECL_C_BIT_FIELD (a))
@@ -611,7 +821,7 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
return t2;
}
return build_type_attribute_variant (t1, attributes);
return c_build_type_attribute_variant (t1, attributes);
case FUNCTION_TYPE:
/* Function types: prefer the one that specified arg types.
@@ -627,23 +837,23 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
/* Save space: see if the result is identical to one of the args. */
if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
return build_functype_attribute_variant (t1, t2, attributes);
return c_build_functype_attribute_variant (t1, t2, attributes);
if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
return build_functype_attribute_variant (t2, t1, attributes);
return c_build_functype_attribute_variant (t2, t1, attributes);
/* Simple way if one arg fails to specify argument types. */
if (TYPE_ARG_TYPES (t1) == NULL_TREE)
{
t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2),
TYPE_NO_NAMED_ARGS_STDARG_P (t2));
t1 = build_type_attribute_variant (t1, attributes);
t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t2),
TYPE_NO_NAMED_ARGS_STDARG_P (t2));
t1 = c_build_type_attribute_variant (t1, attributes);
return qualify_type (t1, t2);
}
if (TYPE_ARG_TYPES (t2) == NULL_TREE)
{
t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1),
TYPE_NO_NAMED_ARGS_STDARG_P (t1));
t1 = build_type_attribute_variant (t1, attributes);
t1 = c_build_function_type (valtype, TYPE_ARG_TYPES (t1),
TYPE_NO_NAMED_ARGS_STDARG_P (t1));
t1 = c_build_type_attribute_variant (t1, attributes);
return qualify_type (t1, t2);
}
@@ -738,13 +948,13 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
parm_done: ;
}
t1 = build_function_type (valtype, newargs);
t1 = c_build_function_type (valtype, newargs);
t1 = qualify_type (t1, t2);
}
/* FALLTHRU */
default:
return build_type_attribute_variant (t1, attributes);
return c_build_type_attribute_variant (t1, attributes);
}
}
@@ -821,8 +1031,8 @@ common_pointer_type (tree t1, tree t2)
target_quals |= ENCODE_QUAL_ADDR_SPACE (as_common);
t1 = build_pointer_type (c_build_qualified_type (target, target_quals));
return build_type_attribute_variant (t1, attributes);
t1 = c_build_pointer_type (c_build_qualified_type (target, target_quals));
return c_build_type_attribute_variant (t1, attributes);
}
/* Return the common type for two arithmetic types under the usual
@@ -854,13 +1064,13 @@ c_common_type (tree t1, tree t2)
if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
{
tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
t1 = build_type_attribute_variant (t1, attrs);
t1 = c_build_type_attribute_variant (t1, attrs);
}
if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
{
tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
t2 = build_type_attribute_variant (t2, attrs);
t2 = c_build_type_attribute_variant (t2, attrs);
}
/* Save time if the two types are the same. */
@@ -1167,6 +1377,35 @@ common_type (tree t1, tree t2)
return c_common_type (t1, t2);
}
/* Helper function for comptypes. For two compatible types, return 1
if they pass consistency checks. In particular we test that
TYPE_CANONICAL is set correctly, i.e. the two types can alias. */
static bool
comptypes_verify (tree type1, tree type2)
{
if (type1 == type2 || !type1 || !type2
|| TREE_CODE (type1) == ERROR_MARK || TREE_CODE (type2) == ERROR_MARK)
return true;
gcc_checking_assert (c_verify_type (type1));
gcc_checking_assert (c_verify_type (type2));
if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
&& !TYPE_STRUCTURAL_EQUALITY_P (type1)
&& !TYPE_STRUCTURAL_EQUALITY_P (type2))
{
/* FIXME: check other types. */
if (RECORD_OR_UNION_TYPE_P (type1)
|| TREE_CODE (type1) == ENUMERAL_TYPE
|| TREE_CODE (type2) == ENUMERAL_TYPE)
return false;
}
return true;
}
struct comptypes_data {
bool enum_and_int_p;
bool different_types_p;
@@ -1391,8 +1630,6 @@ comptypes_internal (const_tree type1, const_tree type2,
d2_variable = (!d2_zero
&& (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
|| TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
d1_variable = d1_variable || (d1_zero && C_TYPE_VARIABLE_SIZE (t1));
d2_variable = d2_variable || (d2_zero && C_TYPE_VARIABLE_SIZE (t2));
if (d1_variable != d2_variable)
data->different_types_p = true;
@@ -1611,8 +1848,11 @@ tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
data->anon_field = !DECL_NAME (s1);
const struct tagged_tu_seen_cache *cache = data->cache;
data->cache = &entry;
if (!comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2), data))
bool ret = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2), data);
data->cache = cache;
if (!ret)
return false;
tree st1 = TYPE_SIZE (TREE_TYPE (s1));
@@ -1891,7 +2131,7 @@ array_to_pointer_conversion (location_t loc, tree exp)
copy_warning (exp, orig_exp);
ptrtype = build_pointer_type (restype);
ptrtype = c_build_pointer_type (restype);
if (INDIRECT_REF_P (exp))
return convert (ptrtype, TREE_OPERAND (exp, 0));
@@ -2961,7 +3201,7 @@ build_omp_array_section (location_t loc, tree array, tree index, tree length)
gcc_assert (!error_operand_p (idxtype));
sectype = build_array_type (eltype, idxtype);
sectype = c_build_array_type (eltype, idxtype);
}
return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
@@ -4223,8 +4463,8 @@ pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
if (current_function_decl != NULL_TREE
&& sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
{
op0 = save_expr (op0);
op1 = save_expr (op1);
op0 = save_expr (c_fully_fold (op0, false, NULL));
op1 = save_expr (c_fully_fold (op1, false, NULL));
tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
*instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
@@ -5113,7 +5353,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg,
gcc_assert (TREE_CODE (arg) != COMPONENT_REF
|| !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
argtype = build_pointer_type (argtype);
argtype = c_build_pointer_type (argtype);
/* ??? Cope with user tricks that amount to offsetof. Delete this
when we have proper support for integer constant expressions. */
@@ -5389,7 +5629,7 @@ type_or_builtin_type (tree expr, tree *bltin = NULL)
return type;
if ((*bltin = builtin_decl_implicit (code)))
type = build_pointer_type (TREE_TYPE (*bltin));
type = c_build_pointer_type (TREE_TYPE (*bltin));
return type;
}
@@ -5674,7 +5914,7 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
/* for array, use qualifiers of element type */
if (flag_isoc23)
t2 = t2_stripped;
result_type = build_pointer_type (qualify_type (t1, t2));
result_type = c_build_pointer_type (qualify_type (t1, t2));
}
/* Objective-C pointer comparisons are a bit more lenient. */
else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
@@ -5697,8 +5937,8 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
inform (op1_loc, "first expression has type %qT", type1);
inform (op2_loc, "second expression has type %qT", type2);
}
result_type = build_pointer_type
(build_qualified_type (void_type_node, qual));
result_type = c_build_pointer_type
(c_build_qualified_type (void_type_node, qual));
}
}
else if (code1 == POINTER_TYPE
@@ -6649,8 +6889,8 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
}
/* Remove qualifiers. */
lhstype = build_qualified_type (lhstype, TYPE_UNQUALIFIED);
olhstype = build_qualified_type (olhstype, TYPE_UNQUALIFIED);
lhstype = c_build_qualified_type (lhstype, TYPE_UNQUALIFIED);
olhstype = c_build_qualified_type (olhstype, TYPE_UNQUALIFIED);
/* Convert new value to destination type. Fold it first, then
restore any excess precision information, for the sake of
@@ -7293,11 +7533,11 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
}
if (!c_mark_addressable (rhs))
return error_mark_node;
rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
rhs = build1 (ADDR_EXPR, c_build_pointer_type (TREE_TYPE (rhs)), rhs);
SET_EXPR_LOCATION (rhs, location);
rhs = convert_for_assignment (location, expr_loc,
build_pointer_type (TREE_TYPE (type)),
c_build_pointer_type (TREE_TYPE (type)),
rhs, origtype, errtype,
null_pointer_constant, fundecl, function,
parmnum, warnopt);
@@ -7911,6 +8151,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
}
else if (codel == POINTER_TYPE
&& (coder == INTEGER_TYPE
|| coder == ENUMERAL_TYPE
|| coder == BOOLEAN_TYPE
|| coder == NULLPTR_TYPE
|| coder == BITINT_TYPE))
{
@@ -12990,8 +13232,8 @@ build_binary_op (location_t location, enum tree_code code,
if (result_type == NULL_TREE)
{
int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
result_type = build_pointer_type
(build_qualified_type (void_type_node, qual));
result_type = c_build_pointer_type
(c_build_qualified_type (void_type_node, qual));
}
}
else if (code0 == POINTER_TYPE
@@ -13023,10 +13265,10 @@ build_binary_op (location_t location, enum tree_code code,
create a pointer type from its type. */
else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
result_type = (INTEGRAL_TYPE_P (type1)
? build_pointer_type (type1) : type1);
? c_build_pointer_type (type1) : type1);
else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
result_type = (INTEGRAL_TYPE_P (type0)
? build_pointer_type (type0) : type0);
? c_build_pointer_type (type0) : type0);
if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
|| truth_value_p (TREE_CODE (orig_op0)))
^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
@@ -13124,8 +13366,8 @@ build_binary_op (location_t location, enum tree_code code,
else
{
int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
result_type = build_pointer_type
(build_qualified_type (void_type_node, qual));
result_type = c_build_pointer_type
(c_build_qualified_type (void_type_node, qual));
pedwarn (location, OPT_Wcompare_distinct_pointer_types,
"comparison of distinct pointer types lacks a cast");
}
@@ -13167,8 +13409,8 @@ build_binary_op (location_t location, enum tree_code code,
&& current_function_decl != NULL_TREE
&& sanitize_flags_p (SANITIZE_POINTER_COMPARE))
{
op0 = save_expr (op0);
op1 = save_expr (op1);
op0 = save_expr (c_fully_fold (op0, false, NULL));
op1 = save_expr (c_fully_fold (op1, false, NULL));
tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
@@ -14390,8 +14632,8 @@ handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
tree eltype = TREE_TYPE (first);
while (TREE_CODE (eltype) == ARRAY_TYPE)
eltype = TREE_TYPE (eltype);
tree type = build_array_type (eltype, index_type);
tree ptype = build_pointer_type (eltype);
tree type = c_build_array_type (eltype, index_type);
tree ptype = c_build_pointer_type (eltype);
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
t = build_fold_addr_expr (t);
tree t2 = build_fold_addr_expr (first);
@@ -14857,10 +15099,10 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
size = size_binop (MINUS_EXPR, size, size_one_node);
size = save_expr (size);
tree index_type = build_index_type (size);
tree atype = build_array_type (TYPE_MAIN_VARIANT (type),
index_type);
tree atype = c_build_array_type (TYPE_MAIN_VARIANT (type),
index_type);
atype = c_build_qualified_type (atype, TYPE_QUALS (type));
tree ptype = build_pointer_type (type);
tree ptype = c_build_pointer_type (type);
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
t = build_fold_addr_expr (t);
t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
@@ -16478,17 +16720,17 @@ c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
|| (domain && TYPE_CANONICAL (domain) != domain))
{
tree unqualified_canon
= build_array_type (TYPE_CANONICAL (element_type),
domain? TYPE_CANONICAL (domain)
: NULL_TREE);
= c_build_array_type (TYPE_CANONICAL (element_type),
domain ? TYPE_CANONICAL (domain)
: NULL_TREE);
if (TYPE_REVERSE_STORAGE_ORDER (type))
{
unqualified_canon
= build_distinct_type_copy (unqualified_canon);
= build_distinct_type_copy (unqualified_canon);
TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
}
TYPE_CANONICAL (t)
= c_build_qualified_type (unqualified_canon, type_quals);
= c_build_qualified_type (unqualified_canon, type_quals);
}
else
TYPE_CANONICAL (t) = t;
@@ -16510,6 +16752,12 @@ c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
tree var_type = (orig_qual_type && orig_qual_indirect == 0
? orig_qual_type
: build_qualified_type (type, type_quals));
gcc_checking_assert (C_TYPE_VARIABLE_SIZE (var_type)
== C_TYPE_VARIABLE_SIZE (type));
gcc_checking_assert (C_TYPE_VARIABLY_MODIFIED (var_type)
== C_TYPE_VARIABLY_MODIFIED (type));
/* A variant type does not inherit the list of incomplete vars from the
type main variant. */
if ((RECORD_OR_UNION_TYPE_P (var_type)
+6 -1
View File
@@ -4039,8 +4039,13 @@ expand_gimple_stmt_1 (gimple *stmt)
else
{
temp = force_operand (temp, target);
if (temp != target)
if (temp == target)
;
else if (GET_MODE (target) != BLKmode)
emit_move_insn (target, temp);
else
emit_block_move (target, temp, expr_size (lhs),
BLOCK_OP_NORMAL);
}
}
}
+2 -1
View File
@@ -4432,12 +4432,13 @@ duplicate_insn_chain (rtx_insn *from, rtx_insn *to,
since MEM_EXPR is shared so make a copy and
walk to the subtree again. */
tree new_expr = unshare_expr (MEM_EXPR (*iter));
tree orig_new_expr = new_expr;
if (TREE_CODE (new_expr) == WITH_SIZE_EXPR)
new_expr = TREE_OPERAND (new_expr, 0);
while (handled_component_p (new_expr))
new_expr = TREE_OPERAND (new_expr, 0);
MR_DEPENDENCE_CLIQUE (new_expr) = newc;
set_mem_expr (const_cast <rtx> (*iter), new_expr);
set_mem_expr (const_cast <rtx> (*iter), orig_new_expr);
}
}
}
+10 -4
View File
@@ -894,7 +894,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
edge->m_summary_id = -1;
edges_count++;
gcc_assert (++edges_max_uid != 0);
++edges_max_uid;
gcc_assert (edges_max_uid != 0);
edge->m_uid = edges_max_uid;
edge->aux = NULL;
edge->caller = caller;
@@ -1709,12 +1710,15 @@ cgraph_update_edges_for_call_stmt (gimple *old_stmt, tree old_decl,
cgraph_node *node;
gcc_checking_assert (orig);
gcc_assert (!orig->thunk);
cgraph_update_edges_for_call_stmt_node (orig, old_stmt, old_decl, new_stmt);
if (orig->clones)
for (node = orig->clones; node != orig;)
{
cgraph_update_edges_for_call_stmt_node (node, old_stmt, old_decl,
new_stmt);
/* Do not attempt to adjust bodies of yet unexpanded thunks. */
if (!node->thunk)
cgraph_update_edges_for_call_stmt_node (node, old_stmt, old_decl,
new_stmt);
if (node->clones)
node = node->clones;
else if (node->next_sibling_clone)
@@ -2434,7 +2438,9 @@ cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
&& !node->forced_by_abi
&& !node->used_from_object_file_p ()
&& !node->same_comdat_group)
|| !node->externally_visible));
|| !node->externally_visible)
&& !DECL_STATIC_CONSTRUCTOR (node->decl)
&& !DECL_STATIC_DESTRUCTOR (node->decl));
}
/* Return true if cgraph_node can be made local for API change.
+9 -1
View File
@@ -307,12 +307,20 @@ cgraph_node::expand_all_artificial_thunks ()
e = e->next_caller;
}
/* Dump information about creation of a call graph node clone to the dump file
created by the -fdump-ipa-clones option. ORIGINAL is the function being
cloned, CLONE is the new clone. SUFFIX is a string that helps identify the
reason for cloning, often it is the suffix used by a particular IPA pass to
create unique function names. SUFFIX can be NULL and in that case the
dumping will not take place, which must be the case only for helper clones
which will never be emitted to the output. */
void
dump_callgraph_transformation (const cgraph_node *original,
const cgraph_node *clone,
const char *suffix)
{
if (symtab->ipa_clones_dump_file)
if (suffix && symtab->ipa_clones_dump_file)
{
fprintf (symtab->ipa_clones_dump_file,
"Callgraph clone;%s;%d;%s;%d;%d;%s;%d;%s;%d;%d;%s\n",
+27 -17
View File
@@ -3904,6 +3904,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
copy. This saves at least one insn, more if register allocation can
eliminate the copy.
We cannot do this if the involved modes have more than one elements,
like for vector or complex modes.
We cannot do this if the destination of the first assignment is a
condition code register. We eliminate this case by making sure
the SET_DEST and SET_SRC have the same mode.
@@ -3919,6 +3922,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
&& GET_CODE (SET_SRC (XVECEXP (newpat, 0, 0))) == SIGN_EXTEND
&& (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0)))
== GET_MODE (SET_SRC (XVECEXP (newpat, 0, 0))))
&& ! VECTOR_MODE_P (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0))))
&& ! COMPLEX_MODE_P (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0))))
&& GET_CODE (XVECEXP (newpat, 0, 1)) == SET
&& rtx_equal_p (SET_SRC (XVECEXP (newpat, 0, 1)),
XEXP (SET_SRC (XVECEXP (newpat, 0, 0)), 0))
@@ -4000,18 +4005,19 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
rtx set1 = XVECEXP (newpat, 0, 1);
/* Normally, it doesn't matter which of the two is done first, but
one which uses any regs/memory set in between i2 and i3 can't
be first. The PARALLEL might also have been pre-existing in i3,
so we need to make sure that we won't wrongly hoist a SET to i2
that would conflict with a death note present in there, or would
have its dest modified between i2 and i3. */
one which uses any regs/memory set or used in between i2 and i3
can't be first. The PARALLEL might also have been pre-existing
in i3, so we need to make sure that we won't wrongly hoist a SET
to i2 that would conflict with a death note present in there, or
would have its dest modified or used between i2 and i3. */
if (!modified_between_p (SET_SRC (set1), i2, i3)
&& !(REG_P (SET_DEST (set1))
&& find_reg_note (i2, REG_DEAD, SET_DEST (set1)))
&& !(GET_CODE (SET_DEST (set1)) == SUBREG
&& find_reg_note (i2, REG_DEAD,
SUBREG_REG (SET_DEST (set1))))
&& !modified_between_p (SET_DEST (set1), i2, i3)
&& SET_DEST (set1) != pc_rtx
&& !reg_used_between_p (SET_DEST (set1), i2, i3)
/* If I3 is a jump, ensure that set0 is a jump so that
we do not create invalid RTL. */
&& (!JUMP_P (i3) || SET_DEST (set0) == pc_rtx)
@@ -4026,7 +4032,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
&& !(GET_CODE (SET_DEST (set0)) == SUBREG
&& find_reg_note (i2, REG_DEAD,
SUBREG_REG (SET_DEST (set0))))
&& !modified_between_p (SET_DEST (set0), i2, i3)
&& SET_DEST (set0) != pc_rtx
&& !reg_used_between_p (SET_DEST (set0), i2, i3)
/* If I3 is a jump, ensure that set1 is a jump so that
we do not create invalid RTL. */
&& (!JUMP_P (i3) || SET_DEST (set1) == pc_rtx)
@@ -7588,7 +7595,7 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
least significant (LEN - C) bits of X, giving an rtx
whose mode is MODE, then multiply it by 2^C. */
const HOST_WIDE_INT shift_amt = exact_log2 (INTVAL (XEXP (inner, 1)));
if (IN_RANGE (shift_amt, 1, len - 1))
if (len > 1 && IN_RANGE (shift_amt, 1, len - 1))
{
new_rtx = make_extraction (mode, XEXP (inner, 0),
0, 0, len - shift_amt,
@@ -11841,8 +11848,10 @@ simplify_compare_const (enum rtx_code code, machine_mode mode,
`and'ed with that bit), we can replace this with a comparison
with zero. */
if (const_op
&& (code == EQ || code == NE || code == GE || code == GEU
|| code == LT || code == LTU)
&& (code == EQ || code == NE || code == GEU || code == LTU
/* This optimization is incorrect for signed >= INT_MIN or
< INT_MIN, those are always true or always false. */
|| ((code == GE || code == LT) && const_op > 0))
&& is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT
&& pow2p_hwi (const_op & GET_MODE_MASK (int_mode))
@@ -14478,14 +14487,15 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2,
/* Otherwise, if this register is used by I3, then this register
now dies here, so we must put a REG_DEAD note here unless there
is one already. */
else if (reg_referenced_p (XEXP (note, 0), PATTERN (i3))
&& ! (REG_P (XEXP (note, 0))
? find_regno_note (i3, REG_DEAD,
REGNO (XEXP (note, 0)))
: find_reg_note (i3, REG_DEAD, XEXP (note, 0))))
else if (reg_referenced_p (XEXP (note, 0), PATTERN (i3)))
{
PUT_REG_NOTE_KIND (note, REG_DEAD);
place = i3;
if (! (REG_P (XEXP (note, 0))
? find_regno_note (i3, REG_DEAD, REGNO (XEXP (note, 0)))
: find_reg_note (i3, REG_DEAD, XEXP (note, 0))))
{
PUT_REG_NOTE_KIND (note, REG_DEAD);
place = i3;
}
}
/* A SET or CLOBBER of the REG_UNUSED reg has been removed,
+3 -2
View File
@@ -606,6 +606,7 @@ get_intel_cpu (struct __processor_model *cpu_model,
CHECK___builtin_cpu_is ("grandridge");
cpu_model->__cpu_type = INTEL_GRANDRIDGE;
break;
case 0xb5:
case 0xc5:
/* Arrow Lake. */
cpu = "arrowlake";
@@ -1014,10 +1015,10 @@ get_available_features (struct __processor_model *cpu_model,
}
}
/* Get Advanced Features at level 0x24 (eax = 0x24). */
/* Get Advanced Features at level 0x24 (eax = 0x24, ecx = 0). */
if (avx10_set && max_cpuid_level >= 0x24)
{
__cpuid (0x24, eax, ebx, ecx, edx);
__cpuid_count (0x24, 0, eax, ebx, ecx, edx);
version = ebx & 0xff;
if (ebx & bit_AVX10_256)
switch (version)
+22 -45
View File
@@ -239,7 +239,7 @@ along with GCC; see the file COPYING3. If not see
(OPTION_MASK_ISA2_AVXIFMA_UNSET | OPTION_MASK_ISA2_AVXVNNI_UNSET \
| OPTION_MASK_ISA2_AVXVNNIINT8_UNSET | OPTION_MASK_ISA2_AVXNECONVERT_UNSET \
| OPTION_MASK_ISA2_AVXVNNIINT16_UNSET | OPTION_MASK_ISA2_AVX512F_UNSET \
| OPTION_MASK_ISA2_AVX10_1_256_UNSET)
| OPTION_MASK_ISA2_AVX10_1_UNSET)
#define OPTION_MASK_ISA_AVX512F_UNSET \
(OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_AVX512CD_UNSET \
| OPTION_MASK_ISA_AVX512PF_UNSET | OPTION_MASK_ISA_AVX512ER_UNSET \
@@ -319,9 +319,8 @@ along with GCC; see the file COPYING3. If not see
#define OPTION_MASK_ISA2_APX_F_UNSET OPTION_MASK_ISA2_APX_F
#define OPTION_MASK_ISA2_EVEX512_UNSET OPTION_MASK_ISA2_EVEX512
#define OPTION_MASK_ISA2_USER_MSR_UNSET OPTION_MASK_ISA2_USER_MSR
#define OPTION_MASK_ISA2_AVX10_1_256_UNSET \
(OPTION_MASK_ISA2_AVX10_1_256 | OPTION_MASK_ISA2_AVX10_1_512_UNSET)
#define OPTION_MASK_ISA2_AVX10_1_512_UNSET OPTION_MASK_ISA2_AVX10_1_512
#define OPTION_MASK_ISA2_AVX10_1_UNSET \
(OPTION_MASK_ISA2_AVX10_1_256 | OPTION_MASK_ISA2_AVX10_1_512)
/* SSE4 includes both SSE4.1 and SSE4.2. -mno-sse4 should the same
as -mno-sse4.1. */
@@ -1419,8 +1418,8 @@ ix86_handle_option (struct gcc_options *opts,
}
else
{
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10_1_256_UNSET;
opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10_1_256_UNSET;
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10_1_UNSET;
opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10_1_UNSET;
opts->x_ix86_no_avx10_1_explicit = 1;
}
return true;
@@ -1435,8 +1434,8 @@ ix86_handle_option (struct gcc_options *opts,
}
else
{
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10_1_512_UNSET;
opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10_1_512_UNSET;
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10_1_UNSET;
opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10_1_UNSET;
opts->x_ix86_no_avx10_1_explicit = 1;
}
return true;
@@ -1468,11 +1467,13 @@ ix86_handle_option (struct gcc_options *opts,
return true;
case OPT_msse4:
gcc_assert (value != 0);
opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4_SET;
opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_SET;
return true;
case OPT_mno_sse4:
gcc_assert (value != 0);
opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_UNSET;
opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_UNSET;
opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_UNSET;
@@ -2273,10 +2274,10 @@ const pta processor_alias_table[] =
{"meteorlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE,
M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2},
{"graniterapids", PROCESSOR_GRANITERAPIDS, CPU_HASWELL, PTA_GRANITERAPIDS,
M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS), P_PROC_AVX512F},
M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS), P_PROC_AVX10_1_512},
{"graniterapids-d", PROCESSOR_GRANITERAPIDS_D, CPU_HASWELL,
PTA_GRANITERAPIDS_D, M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS_D),
P_PROC_AVX512F},
P_PROC_AVX10_1_512},
{"arrowlake", PROCESSOR_ARROWLAKE, CPU_HASWELL, PTA_ARROWLAKE,
M_CPU_SUBTYPE (INTEL_COREI7_ARROWLAKE), P_PROC_AVX2},
{"arrowlake-s", PROCESSOR_ARROWLAKE_S, CPU_HASWELL, PTA_ARROWLAKE_S,
@@ -2395,34 +2396,16 @@ const pta processor_alias_table[] =
| PTA_SSE3 | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_PRFCHW | PTA_FXSR,
M_CPU_SUBTYPE (AMDFAM10H_BARCELONA), P_PROC_DYNAMIC},
{"bdver1", PROCESSOR_BDVER1, CPU_BDVER1,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1
| PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4
| PTA_XOP | PTA_LWP | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE,
M_CPU_TYPE (AMDFAM15H_BDVER1), P_PROC_XOP},
PTA_BDVER1,
M_CPU_SUBTYPE (AMDFAM15H_BDVER1), P_PROC_XOP},
{"bdver2", PROCESSOR_BDVER2, CPU_BDVER2,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1
| PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4
| PTA_XOP | PTA_LWP | PTA_BMI | PTA_TBM | PTA_F16C
| PTA_FMA | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE,
M_CPU_TYPE (AMDFAM15H_BDVER2), P_PROC_FMA},
PTA_BDVER2,
M_CPU_SUBTYPE (AMDFAM15H_BDVER2), P_PROC_FMA},
{"bdver3", PROCESSOR_BDVER3, CPU_BDVER3,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1
| PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4
| PTA_XOP | PTA_LWP | PTA_BMI | PTA_TBM | PTA_F16C
| PTA_FMA | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE
| PTA_XSAVEOPT | PTA_FSGSBASE,
PTA_BDVER3,
M_CPU_SUBTYPE (AMDFAM15H_BDVER3), P_PROC_FMA},
{"bdver4", PROCESSOR_BDVER4, CPU_BDVER4,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1
| PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_AVX2
| PTA_FMA4 | PTA_XOP | PTA_LWP | PTA_BMI | PTA_BMI2
| PTA_TBM | PTA_F16C | PTA_FMA | PTA_PRFCHW | PTA_FXSR
| PTA_XSAVE | PTA_XSAVEOPT | PTA_FSGSBASE | PTA_RDRND
| PTA_MOVBE | PTA_MWAITX,
PTA_BDVER4,
M_CPU_SUBTYPE (AMDFAM15H_BDVER4), P_PROC_AVX2},
{"znver1", PROCESSOR_ZNVER1, CPU_ZNVER1,
PTA_ZNVER1,
@@ -2440,16 +2423,10 @@ const pta processor_alias_table[] =
PTA_ZNVER5,
M_CPU_SUBTYPE (AMDFAM1AH_ZNVER5), P_PROC_AVX512F},
{"btver1", PROCESSOR_BTVER1, CPU_GENERIC,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_PRFCHW
| PTA_FXSR | PTA_XSAVE,
M_CPU_SUBTYPE (AMDFAM15H_BDVER1), P_PROC_SSE4_A},
PTA_BTVER1,
M_CPU_TYPE (AMD_BTVER1), P_PROC_SSE4_A},
{"btver2", PROCESSOR_BTVER2, CPU_BTVER2,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_SSE4_1
| PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX
| PTA_BMI | PTA_F16C | PTA_MOVBE | PTA_PRFCHW
| PTA_FXSR | PTA_XSAVE | PTA_XSAVEOPT,
PTA_BTVER2,
M_CPU_TYPE (AMD_BTVER2), P_PROC_BMI},
{"generic", PROCESSOR_GENERIC, CPU_GENERIC,
@@ -2468,9 +2445,9 @@ const pta processor_alias_table[] =
{"amdfam19h", PROCESSOR_GENERIC, CPU_GENERIC, 0,
M_CPU_TYPE (AMDFAM19H), P_NONE},
{"shanghai", PROCESSOR_GENERIC, CPU_GENERIC, 0,
M_CPU_TYPE (AMDFAM10H_SHANGHAI), P_NONE},
M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI), P_NONE},
{"istanbul", PROCESSOR_GENERIC, CPU_GENERIC, 0,
M_CPU_TYPE (AMDFAM10H_ISTANBUL), P_NONE},
M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL), P_NONE},
};
/* NB: processor_alias_table stops at the "generic" entry. */
+4 -1
View File
@@ -112,7 +112,7 @@ enum processor_subtypes
/* Priority of i386 features, greater value is higher priority. This is
used to decide the order in which function dispatch must happen. For
instance, a version specialized for SSE4.2 should be checked for dispatch
before a version for SSE3, as SSE4.2 implies SSE3. */
before a version for SSE3. */
enum feature_priority
{
P_NONE = 0,
@@ -148,6 +148,9 @@ enum feature_priority
P_AVX512F,
P_PROC_AVX512F,
P_X86_64_V4,
P_AVX10_1_256,
P_AVX10_1_512,
P_PROC_AVX10_1_512,
P_PROC_DYNAMIC
};
+3 -3
View File
@@ -193,7 +193,7 @@ ISA_NAMES_TABLE_START
ISA_NAMES_TABLE_ENTRY("sm4", FEATURE_SM4, P_NONE, "-msm4")
ISA_NAMES_TABLE_ENTRY("apxf", FEATURE_APX_F, P_NONE, "-mapxf")
ISA_NAMES_TABLE_ENTRY("usermsr", FEATURE_USER_MSR, P_NONE, "-musermsr")
ISA_NAMES_TABLE_ENTRY("avx10.1", FEATURE_AVX10_1_256, P_NONE, "-mavx10.1")
ISA_NAMES_TABLE_ENTRY("avx10.1-256", FEATURE_AVX10_1_256, P_NONE, "-mavx10.1-256")
ISA_NAMES_TABLE_ENTRY("avx10.1-512", FEATURE_AVX10_1_512, P_NONE, "-mavx10.1-512")
ISA_NAMES_TABLE_ENTRY("avx10.1-256", FEATURE_AVX10_1_256, P_AVX10_1_256, "-mavx10.1-256")
ISA_NAMES_TABLE_ENTRY("avx10.1-512", FEATURE_AVX10_1_512, P_AVX10_1_512, "-mavx10.1-512")
ISA_NAMES_TABLE_ENTRY("avx10.1", FEATURE_AVX10_1_512, P_AVX10_1_512, "-mavx10.1")
ISA_NAMES_TABLE_END
+182 -152
View File
@@ -79,6 +79,13 @@ static const riscv_implied_info_t riscv_implied_info[] =
{"f", "zicsr"},
{"d", "zicsr"},
{"a", "zaamo"},
{"a", "zalrsc"},
{"zabha", "zaamo"},
{"zcmop", "zca"},
{"zdinx", "zfinx"},
{"zfinx", "zicsr"},
{"zdinx", "zicsr"},
@@ -155,12 +162,15 @@ static const riscv_implied_info_t riscv_implied_info[] =
{"zvksed", "zve32x"},
{"zvksh", "zve32x"},
{"zfbfmin", "zfhmin"},
{"zfh", "zfhmin"},
{"zfhmin", "f"},
{"zfa", "f"},
{"zvfbfmin", "zve32f"},
{"zvfbfwma", "zvfbfmin"},
{"zvfbfwma", "zfbfmin"},
{"zvfhmin", "zve32f"},
{"zvfh", "zve32f"},
{"zvfh", "zfhmin"},
@@ -205,6 +215,12 @@ struct riscv_ext_version
int minor_version;
};
struct riscv_profiles
{
const char *profile_name;
const char *profile_string;
};
/* All standard extensions defined in all supported ISA spec. */
static const struct riscv_ext_version riscv_ext_version_table[] =
{
@@ -252,6 +268,9 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
{"za64rs", ISA_SPEC_CLASS_NONE, 1, 0},
{"za128rs", ISA_SPEC_CLASS_NONE, 1, 0},
{"zawrs", ISA_SPEC_CLASS_NONE, 1, 0},
{"zaamo", ISA_SPEC_CLASS_NONE, 1, 0},
{"zalrsc", ISA_SPEC_CLASS_NONE, 1, 0},
{"zabha", ISA_SPEC_CLASS_NONE, 1, 0},
{"zba", ISA_SPEC_CLASS_NONE, 1, 0},
{"zbb", ISA_SPEC_CLASS_NONE, 1, 0},
@@ -286,6 +305,9 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
{"zicclsm", ISA_SPEC_CLASS_NONE, 1, 0},
{"ziccrse", ISA_SPEC_CLASS_NONE, 1, 0},
{"zimop", ISA_SPEC_CLASS_NONE, 1, 0},
{"zcmop", ISA_SPEC_CLASS_NONE, 1, 0},
{"zicntr", ISA_SPEC_CLASS_NONE, 2, 0},
{"zihpm", ISA_SPEC_CLASS_NONE, 2, 0},
@@ -331,9 +353,11 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
{"zvl32768b", ISA_SPEC_CLASS_NONE, 1, 0},
{"zvl65536b", ISA_SPEC_CLASS_NONE, 1, 0},
{"zfbfmin", ISA_SPEC_CLASS_NONE, 1, 0},
{"zfh", ISA_SPEC_CLASS_NONE, 1, 0},
{"zfhmin", ISA_SPEC_CLASS_NONE, 1, 0},
{"zvfbfmin", ISA_SPEC_CLASS_NONE, 1, 0},
{"zvfbfwma", ISA_SPEC_CLASS_NONE, 1, 0},
{"zvfhmin", ISA_SPEC_CLASS_NONE, 1, 0},
{"zvfh", ISA_SPEC_CLASS_NONE, 1, 0},
@@ -391,6 +415,7 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
/* Combine extensions defined in this table */
static const struct riscv_ext_version riscv_combine_info[] =
{
{"a", ISA_SPEC_CLASS_20191213, 2, 1},
{"zk", ISA_SPEC_CLASS_NONE, 1, 0},
{"zkn", ISA_SPEC_CLASS_NONE, 1, 0},
{"zks", ISA_SPEC_CLASS_NONE, 1, 0},
@@ -404,6 +429,47 @@ static const struct riscv_ext_version riscv_combine_info[] =
{NULL, ISA_SPEC_CLASS_NONE, 0, 0}
};
/* This table records the mapping form RISC-V Profiles into march string. */
static const riscv_profiles riscv_profiles_table[] =
{
/* RVI20U only contains the base extension 'i' as mandatory extension. */
{"rvi20u64", "rv64i"},
{"rvi20u32", "rv32i"},
/* RVA20U contains the 'i,m,a,f,d,c,zicsr,zicntr,ziccif,ziccrse,ziccamoa,
zicclsm,za128rs' as mandatory extensions. */
{"rva20u64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
"_zicclsm_za128rs"},
/* RVA22U contains the 'i,m,a,f,d,c,zicsr,zihintpause,zba,zbb,zbs,zicntr,
zihpm,ziccif,ziccrse,ziccamoa, zicclsm,zic64b,za64rs,zicbom,zicbop,zicboz,
zfhmin,zkt' as mandatory extensions. */
{"rva22u64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
"_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
"_zicboz_zfhmin_zkt"},
/* RVA23 contains all mandatory base ISA for RVA22U64 and the new extension
'v,zihintntl,zvfhmin,zvbb,zvkt,zicond,zimop,zcmop,zfa,zawrs' as mandatory
extensions. */
{"rva23u64", "rv64imafdcv_zicsr_zicntr_zihpm_ziccif_ziccrse_ziccamoa"
"_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
"_zicboz_zfhmin_zkt_zvfhmin_zvbb_zvkt_zihintntl_zicond_zimop_zcmop_zcb"
"_zfa_zawrs"},
/* RVB23 contains all mandatory base ISA for RVA22U64 and the new extension
'zihintntl,zicond,zimop,zcmop,zfa,zawrs' as mandatory
extensions. */
{"rvb23u64", "rv64imafdc_zicsr_zicntr_zihpm_ziccif_ziccrse_ziccamoa"
"_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
"_zicboz_zfhmin_zkt_zihintntl_zicond_zimop_zcmop_zcb"
"_zfa_zawrs"},
/* Currently we do not define S/M mode Profiles in gcc part. */
/* Terminate the list. */
{NULL, NULL}
};
static const riscv_cpu_info riscv_cpu_tables[] =
{
#define RISCV_CORE(CORE_NAME, ARCH, TUNE) \
@@ -424,110 +490,13 @@ static const char *riscv_supported_std_ext (void);
bool riscv_subset_list::parse_failed = false;
static riscv_subset_list *current_subset_list = NULL;
static riscv_subset_list *cmdline_subset_list = NULL;
struct riscv_func_target_info
{
tree fn_decl;
std::string fn_target_name;
riscv_func_target_info (const tree &decl, const std::string &target_name)
: fn_decl (decl), fn_target_name (target_name)
{
}
};
struct riscv_func_target_hasher : nofree_ptr_hash<struct riscv_func_target_info>
{
typedef tree compare_type;
static hashval_t hash (value_type);
static bool equal (value_type, const compare_type &);
};
static hash_table<riscv_func_target_hasher> *func_target_table = NULL;
static inline hashval_t riscv_func_decl_hash (tree fn_decl)
{
inchash::hash h;
h.add_ptr (fn_decl);
return h.end ();
}
inline hashval_t
riscv_func_target_hasher::hash (value_type value)
{
return riscv_func_decl_hash (value->fn_decl);
}
inline bool
riscv_func_target_hasher::equal (value_type value, const compare_type &key)
{
return value->fn_decl == key;
}
const riscv_subset_list *riscv_current_subset_list ()
{
return current_subset_list;
}
const riscv_subset_list * riscv_cmdline_subset_list ()
const riscv_subset_list *riscv_cmdline_subset_list ()
{
return cmdline_subset_list;
}
static inline void riscv_func_target_table_lazy_init ()
{
if (func_target_table != NULL)
return;
func_target_table = new hash_table<riscv_func_target_hasher> (1023);
}
std::string * riscv_func_target_get (tree fn_decl)
{
riscv_func_target_table_lazy_init ();
hashval_t hash = riscv_func_decl_hash (fn_decl);
struct riscv_func_target_info *info
= func_target_table->find_with_hash (fn_decl, hash);
return info == NULL ? NULL : &info->fn_target_name;
}
void riscv_func_target_put (tree fn_decl, std::string fn_target_name)
{
riscv_func_target_table_lazy_init ();
hashval_t hash = riscv_func_decl_hash (fn_decl);
struct riscv_func_target_info **target_info_slot
= func_target_table->find_slot_with_hash (fn_decl, hash, INSERT);
gcc_assert (!*target_info_slot);
struct riscv_func_target_info *info
= new riscv_func_target_info (fn_decl, fn_target_name);
*target_info_slot = info;
}
void riscv_func_target_remove_and_destory (tree fn_decl)
{
hashval_t hash = riscv_func_decl_hash (fn_decl);
struct riscv_func_target_info *info
= func_target_table->find_with_hash (fn_decl, hash);
if (info)
{
func_target_table->remove_elt_with_hash (fn_decl, hash);
delete info;
}
}
/* struct for recording multi-lib info. */
struct riscv_multi_lib_info_t {
std::string path;
@@ -555,7 +524,8 @@ riscv_subset_t::riscv_subset_t ()
}
riscv_subset_list::riscv_subset_list (const char *arch, location_t loc)
: m_arch (arch), m_loc (loc), m_head (NULL), m_tail (NULL), m_xlen (0)
: m_arch (arch), m_loc (loc), m_head (NULL), m_tail (NULL), m_xlen (0),
m_subset_num (0)
{
}
@@ -760,12 +730,17 @@ riscv_subset_list::add (const char *subset, int major_version,
ext->minor_version = minor_version;
}
else
error_at (
m_loc,
"%<-march=%s%>: extension %qs appear more than one time",
m_arch,
subset);
{
/* The extension is already in the list. */
if (!m_allow_adding_dup
|| ext->major_version != major_version
|| ext->minor_version != minor_version)
error_at (
m_loc,
"%<-march=%s%>: extension %qs appear more than one time",
m_arch,
subset);
}
return;
}
else if (strlen (subset) == 1 && !standard_extensions_p (subset))
@@ -801,6 +776,7 @@ riscv_subset_list::add (const char *subset, int major_version,
return;
}
m_subset_num++;
riscv_subset_t *s = new riscv_subset_t ();
riscv_subset_t *itr;
@@ -906,6 +882,8 @@ riscv_subset_list::to_string (bool version_p) const
riscv_subset_t *subset;
bool skip_zifencei = false;
bool skip_zaamo_zalrsc = false;
bool skip_zabha = false;
bool skip_zicsr = false;
bool i2p0 = false;
@@ -933,6 +911,14 @@ riscv_subset_list::to_string (bool version_p) const
a mistake in that binutils 2.35 supports zicsr but not zifencei. */
skip_zifencei = true;
#endif
#ifndef HAVE_AS_MARCH_ZAAMO_ZALRSC
/* Skip since binutils 2.42 and earlier don't recognize zaamo/zalrsc. */
skip_zaamo_zalrsc = true;
#endif
#ifndef HAVE_AS_MARCH_ZABHA
/* Skip since binutils 2.42 and earlier don't recognize zabha. */
skip_zabha = true;
#endif
for (subset = m_head; subset != NULL; subset = subset->next)
{
@@ -944,6 +930,15 @@ riscv_subset_list::to_string (bool version_p) const
subset->name == "zicsr")
continue;
if (skip_zaamo_zalrsc && subset->name == "zaamo")
continue;
if (skip_zaamo_zalrsc && subset->name == "zalrsc")
continue;
if (skip_zabha && subset->name == "zabha")
continue;
/* For !version_p, we only separate extension with underline for
multi-letter extension. */
if (!first &&
@@ -1080,6 +1075,52 @@ riscv_subset_list::parsing_subset_version (const char *ext,
return p;
}
/* Parsing RISC-V Profiles in -march string.
Return string with mandatory extensions of Profiles. */
std::string
riscv_subset_list::parse_profiles (const char *arch)
{
/* Checking if input string contains a Profiles.
There are two cases use Profiles in -march option:
1. Only use Profiles in '-march' as input
2. Mixed Profiles with other extensions
Use '_' to split Profiles and other extension. */
std::string p(arch);
const size_t p_len = p.size();
for (int i = 0; riscv_profiles_table[i].profile_name != nullptr; ++i)
{
const std::string& p_name = riscv_profiles_table[i].profile_name;
const std::string& p_str = riscv_profiles_table[i].profile_string;
size_t pos = p.find(p_name);
/* Find profile at the begin. */
if (pos == 0 && pos + p_name.size() <= p_len)
{
size_t after_pos = pos + p_name.size();
std::string after_part = p.substr(after_pos);
/* If there're only profile, return the profile_string directly. */
if (after_part[0] == '\0')
return p_str;
/* If isn't '_' after profile, need to add it and mention the user. */
if (after_part[0] != '_')
{
warning_at (m_loc, 0, "Should use \"%c\" to contact Profiles with other "
"extensions", '_');
return p_str + "_" + after_part;
}
/* Return 'profiles_additional' extensions. */
return p_str + after_part;
}
}
/* Not found profile, return directly. */
return p;
}
/* Parsing function for base extensions, rv[32|64][i|e|g]
Return Value:
@@ -1106,8 +1147,8 @@ riscv_subset_list::parse_base_ext (const char *p)
}
else
{
error_at (m_loc, "%<-march=%s%>: ISA string must begin with rv32 or rv64",
m_arch);
error_at (m_loc, "%<-march=%s%>: ISA string must begin with rv32, rv64 "
"or Profiles", m_arch);
return NULL;
}
@@ -1498,8 +1539,10 @@ riscv_subset_list::parse (const char *arch, location_t loc)
return NULL;
riscv_subset_list *subset_list = new riscv_subset_list (arch, loc);
const char *p = arch;
p = subset_list->parse_base_ext (p);
std::string a = subset_list->parse_profiles(p);
p = subset_list->parse_base_ext (a.c_str());
if (p == NULL)
goto fail;
@@ -1564,9 +1607,15 @@ void
riscv_subset_list::finalize ()
{
riscv_subset_t *subset;
unsigned pre_subset_num;
for (subset = m_head; subset != NULL; subset = subset->next)
handle_implied_ext (subset->name.c_str ());
do
{
pre_subset_num = m_subset_num;
for (subset = m_head; subset != NULL; subset = subset->next)
handle_implied_ext (subset->name.c_str ());
}
while (pre_subset_num != m_subset_num);
gcc_assert (check_implied_ext ());
@@ -1579,8 +1628,8 @@ riscv_subset_list::finalize ()
std::string
riscv_arch_str (bool version_p)
{
if (current_subset_list)
return current_subset_list->to_string (version_p);
if (cmdline_subset_list)
return cmdline_subset_list->to_string (version_p);
else
return std::string();
}
@@ -1611,9 +1660,12 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{"zifencei", &gcc_options::x_riscv_zi_subext, MASK_ZIFENCEI},
{"zicond", &gcc_options::x_riscv_zi_subext, MASK_ZICOND},
{"za64rs", &gcc_options::x_riscv_za_subext, MASK_ZA64RS},
{"za64rs", &gcc_options::x_riscv_za_subext, MASK_ZA64RS},
{"za128rs", &gcc_options::x_riscv_za_subext, MASK_ZA128RS},
{"zawrs", &gcc_options::x_riscv_za_subext, MASK_ZAWRS},
{"zawrs", &gcc_options::x_riscv_za_subext, MASK_ZAWRS},
{"zaamo", &gcc_options::x_riscv_za_subext, MASK_ZAAMO},
{"zalrsc", &gcc_options::x_riscv_za_subext, MASK_ZALRSC},
{"zabha", &gcc_options::x_riscv_za_subext, MASK_ZABHA},
{"zba", &gcc_options::x_riscv_zb_subext, MASK_ZBA},
{"zbb", &gcc_options::x_riscv_zb_subext, MASK_ZBB},
@@ -1638,15 +1690,18 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL},
{"zihintpause", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTPAUSE},
{"ziccamoa", &gcc_options::x_riscv_zi_subext, MASK_ZICCAMOA},
{"ziccif", &gcc_options::x_riscv_zi_subext, MASK_ZICCIF},
{"zicclsm", &gcc_options::x_riscv_zi_subext, MASK_ZICCLSM},
{"ziccrse", &gcc_options::x_riscv_zi_subext, MASK_ZICCRSE},
{"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ},
{"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM},
{"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP},
{"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B},
{"ziccamoa", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCAMOA},
{"ziccif", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCIF},
{"zicclsm", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCLSM},
{"ziccrse", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCRSE},
{"zimop", &gcc_options::x_riscv_mop_subext, MASK_ZIMOP},
{"zcmop", &gcc_options::x_riscv_mop_subext, MASK_ZCMOP},
{"zve32x", &gcc_options::x_target_flags, MASK_VECTOR},
{"zve32f", &gcc_options::x_target_flags, MASK_VECTOR},
@@ -1665,6 +1720,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{"zve64f", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_32},
{"zve64d", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_64},
{"zvfbfmin", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_BF_16},
{"zvfbfwma", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_BF_16},
{"zvfhmin", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_16},
{"zvfh", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_16},
@@ -1698,9 +1754,11 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{"zvl32768b", &gcc_options::x_riscv_zvl_flags, MASK_ZVL32768B},
{"zvl65536b", &gcc_options::x_riscv_zvl_flags, MASK_ZVL65536B},
{"zfbfmin", &gcc_options::x_riscv_zf_subext, MASK_ZFBFMIN},
{"zfhmin", &gcc_options::x_riscv_zf_subext, MASK_ZFHMIN},
{"zfh", &gcc_options::x_riscv_zf_subext, MASK_ZFH},
{"zvfbfmin", &gcc_options::x_riscv_zf_subext, MASK_ZVFBFMIN},
{"zvfbfwma", &gcc_options::x_riscv_zf_subext, MASK_ZVFBFWMA},
{"zvfhmin", &gcc_options::x_riscv_zf_subext, MASK_ZVFHMIN},
{"zvfh", &gcc_options::x_riscv_zf_subext, MASK_ZVFH},
@@ -1759,8 +1817,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{NULL, NULL, 0}
};
/* Apply SUBSET_LIST to OPTS if OPTS is not null, also set CURRENT_SUBSET_LIST
to SUBSET_LIST, just note this WON'T delete old CURRENT_SUBSET_LIST. */
/* Apply SUBSET_LIST to OPTS if OPTS is not null. */
void
riscv_set_arch_by_subset_list (riscv_subset_list *subset_list,
@@ -1779,15 +1836,14 @@ riscv_set_arch_by_subset_list (riscv_subset_list *subset_list,
else if (subset_list->xlen () == 64)
opts->x_target_flags |= MASK_64BIT;
for (arch_ext_flag_tab = &riscv_ext_flag_table[0]; arch_ext_flag_tab->ext;
for (arch_ext_flag_tab = &riscv_ext_flag_table[0];
arch_ext_flag_tab->ext;
++arch_ext_flag_tab)
{
if (subset_list->lookup (arch_ext_flag_tab->ext))
opts->*arch_ext_flag_tab->var_ref |= arch_ext_flag_tab->mask;
}
}
current_subset_list = subset_list;
}
/* Parse a RISC-V ISA string into an option mask. Must clear or set all arch
@@ -1803,38 +1859,12 @@ riscv_parse_arch_string (const char *isa,
if (!subset_list)
return;
if (opts)
{
const riscv_ext_flag_table_t *arch_ext_flag_tab;
/* Clean up target flags before we set. */
for (arch_ext_flag_tab = &riscv_ext_flag_table[0];
arch_ext_flag_tab->ext;
++arch_ext_flag_tab)
opts->*arch_ext_flag_tab->var_ref &= ~arch_ext_flag_tab->mask;
if (subset_list->xlen () == 32)
opts->x_target_flags &= ~MASK_64BIT;
else if (subset_list->xlen () == 64)
opts->x_target_flags |= MASK_64BIT;
for (arch_ext_flag_tab = &riscv_ext_flag_table[0];
arch_ext_flag_tab->ext;
++arch_ext_flag_tab)
{
if (subset_list->lookup (arch_ext_flag_tab->ext))
opts->*arch_ext_flag_tab->var_ref |= arch_ext_flag_tab->mask;
}
}
/* Avoid double delete if current_subset_list equals cmdline_subset_list. */
if (current_subset_list && current_subset_list != cmdline_subset_list)
delete current_subset_list;
if (cmdline_subset_list)
delete cmdline_subset_list;
current_subset_list = cmdline_subset_list = subset_list;
cmdline_subset_list = subset_list;
riscv_set_arch_by_subset_list (subset_list, opts);
}
/* Return the riscv_cpu_info entry for CPU, NULL if not found. */
+2 -2
View File
@@ -534,7 +534,7 @@ powerpc*-*-*)
extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h si2vmx.h"
extra_headers="${extra_headers} amo.h"
case x$with_cpu in
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower10|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
cpu_is_64bit=yes
;;
esac
@@ -5601,7 +5601,7 @@ case "${target}" in
eval "with_$which=405"
;;
"" | common | native \
| power[3456789] | power10 | power5+ | power6x \
| power[3456789] | power1[01] | power5+ | power6x \
| powerpc | powerpc64 | powerpc64le \
| rs64 \
| 401 | 403 | 405 | 405fp | 440 | 440fp | 464 | 464fp \
+25
View File
@@ -629,6 +629,18 @@
#endif
/* Define if the assembler understands -march=rv*_zaamo_zalrsc. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MARCH_ZAAMO_ZALRSC
#endif
/* Define if the assembler understands -march=rv*_zabha. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MARCH_ZABHA
#endif
/* Define if the assembler understands -march=rv*_zifencei. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MARCH_ZIFENCEI
@@ -2259,6 +2271,13 @@
#endif
/* Define if personality and ADDR_NO_RANDOMIZE are declared in
sys/personality.h. */
#ifndef USED_FOR_TARGET
#undef HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE
#endif
/* Define which stat syscall is able to handle 64bit indodes. */
#ifndef USED_FOR_TARGET
#undef HOST_STAT_FOR_64BIT_INODES
@@ -2289,6 +2308,12 @@
#endif
/* Define to 1 if ld64 supports '-macos_version_min'. */
#ifndef USED_FOR_TARGET
#undef LD64_HAS_MACOS_VERSION_MIN
#endif
/* Define to 1 if ld64 supports '-platform_version'. */
#ifndef USED_FOR_TARGET
#undef LD64_HAS_PLATFORM_VERSION
+154 -36
View File
@@ -1709,21 +1709,17 @@ aarch64_init_tme_builtins (void)
= build_function_type_list (void_type_node, uint64_type_node, NULL);
aarch64_builtin_decls[AARCH64_TME_BUILTIN_TSTART]
= aarch64_general_add_builtin ("__builtin_aarch64_tstart",
ftype_uint64_void,
AARCH64_TME_BUILTIN_TSTART);
= aarch64_general_simulate_builtin ("__tstart", ftype_uint64_void,
AARCH64_TME_BUILTIN_TSTART);
aarch64_builtin_decls[AARCH64_TME_BUILTIN_TTEST]
= aarch64_general_add_builtin ("__builtin_aarch64_ttest",
ftype_uint64_void,
AARCH64_TME_BUILTIN_TTEST);
= aarch64_general_simulate_builtin ("__ttest", ftype_uint64_void,
AARCH64_TME_BUILTIN_TTEST);
aarch64_builtin_decls[AARCH64_TME_BUILTIN_TCOMMIT]
= aarch64_general_add_builtin ("__builtin_aarch64_tcommit",
ftype_void_void,
AARCH64_TME_BUILTIN_TCOMMIT);
= aarch64_general_simulate_builtin ("__tcommit", ftype_void_void,
AARCH64_TME_BUILTIN_TCOMMIT);
aarch64_builtin_decls[AARCH64_TME_BUILTIN_TCANCEL]
= aarch64_general_add_builtin ("__builtin_aarch64_tcancel",
ftype_void_uint64,
AARCH64_TME_BUILTIN_TCANCEL);
= aarch64_general_simulate_builtin ("__tcancel", ftype_void_uint64,
AARCH64_TME_BUILTIN_TCANCEL);
}
/* Add builtins for Random Number instructions. */
@@ -1854,27 +1850,27 @@ aarch64_init_memtag_builtins (void)
#define AARCH64_INIT_MEMTAG_BUILTINS_DECL(F, N, I, T) \
aarch64_builtin_decls[AARCH64_MEMTAG_BUILTIN_##F] \
= aarch64_general_add_builtin ("__builtin_aarch64_memtag_"#N, \
T, AARCH64_MEMTAG_BUILTIN_##F); \
= aarch64_general_simulate_builtin ("__arm_mte_"#N, T, \
AARCH64_MEMTAG_BUILTIN_##F); \
aarch64_memtag_builtin_data[AARCH64_MEMTAG_BUILTIN_##F - \
AARCH64_MEMTAG_BUILTIN_START - 1] = \
{T, CODE_FOR_##I};
fntype = build_function_type_list (ptr_type_node, ptr_type_node,
uint64_type_node, NULL);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (IRG, irg, irg, fntype);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (IRG, create_random_tag, irg, fntype);
fntype = build_function_type_list (uint64_type_node, ptr_type_node,
uint64_type_node, NULL);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (GMI, gmi, gmi, fntype);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (GMI, exclude_tag, gmi, fntype);
fntype = build_function_type_list (ptrdiff_type_node, ptr_type_node,
ptr_type_node, NULL);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (SUBP, subp, subp, fntype);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (SUBP, ptrdiff, subp, fntype);
fntype = build_function_type_list (ptr_type_node, ptr_type_node,
unsigned_type_node, NULL);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (INC_TAG, inc_tag, addg, fntype);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (INC_TAG, increment_tag, addg, fntype);
fntype = build_function_type_list (void_type_node, ptr_type_node, NULL);
AARCH64_INIT_MEMTAG_BUILTINS_DECL (SET_TAG, set_tag, stg, fntype);
@@ -1984,8 +1980,9 @@ aarch64_init_data_intrinsics (void)
void
handle_arm_acle_h (void)
{
if (TARGET_LS64)
aarch64_init_ls64_builtins ();
aarch64_init_ls64_builtins ();
aarch64_init_tme_builtins ();
aarch64_init_memtag_builtins ();
}
/* Initialize fpsr fpcr getters and setters. */
@@ -2078,12 +2075,6 @@ aarch64_general_init_builtins (void)
if (!TARGET_ILP32)
aarch64_init_pauth_hint_builtins ();
if (TARGET_TME)
aarch64_init_tme_builtins ();
if (TARGET_MEMTAG)
aarch64_init_memtag_builtins ();
if (in_lto_p)
handle_arm_acle_h ();
}
@@ -2098,11 +2089,112 @@ aarch64_general_builtin_decl (unsigned code, bool)
return aarch64_builtin_decls[code];
}
/* True if we've already complained about attempts to use functions
when the required extension is disabled. */
static bool reported_missing_extension_p;
/* True if we've already complained about attempts to use functions
which require registers that are missing. */
static bool reported_missing_registers_p;
/* Report an error against LOCATION that the user has tried to use
function FNDECL when extension EXTENSION is disabled. */
static void
aarch64_report_missing_extension (location_t location, tree fndecl,
const char *extension)
{
/* Avoid reporting a slew of messages for a single oversight. */
if (reported_missing_extension_p)
return;
error_at (location, "ACLE function %qD requires ISA extension %qs",
fndecl, extension);
inform (location, "you can enable %qs using the command-line"
" option %<-march%>, or by using the %<target%>"
" attribute or pragma", extension);
reported_missing_extension_p = true;
}
/* Report an error against LOCATION that the user has tried to use
function FNDECL when non-general registers are disabled. */
static void
aarch64_report_missing_registers (location_t location, tree fndecl)
{
/* Avoid reporting a slew of messages for a single oversight. */
if (reported_missing_registers_p)
return;
error_at (location,
"ACLE function %qD is incompatible with the use of %qs",
fndecl, "-mgeneral-regs-only");
reported_missing_registers_p = true;
}
/* Check whether all the AARCH64_FL_* values in REQUIRED_EXTENSIONS are
enabled, given that those extensions are required for function FNDECL.
Report an error against LOCATION if not. */
bool
aarch64_check_required_extensions (location_t location, tree fndecl,
aarch64_feature_flags required_extensions)
{
if ((required_extensions & ~aarch64_isa_flags) == 0)
return true;
auto missing_extensions = required_extensions & ~aarch64_asm_isa_flags;
if (missing_extensions == 0)
{
/* All required extensions are enabled in aarch64_asm_isa_flags, so the
error must be the use of general-regs-only. */
aarch64_report_missing_registers (location, fndecl);
return false;
}
if (missing_extensions & AARCH64_FL_SM_OFF)
{
error_at (location, "ACLE function %qD cannot be called when"
" SME streaming mode is enabled", fndecl);
return false;
}
if (missing_extensions & AARCH64_FL_SM_ON)
{
error_at (location, "ACLE function %qD can only be called when"
" SME streaming mode is enabled", fndecl);
return false;
}
if (missing_extensions & AARCH64_FL_ZA_ON)
{
error_at (location, "ACLE function %qD can only be called from"
" a function that has %qs state", fndecl, "za");
return false;
}
static const struct {
aarch64_feature_flags flag;
const char *name;
} extensions[] = {
#define AARCH64_OPT_EXTENSION(EXT_NAME, IDENT, C, D, E, F) \
{ AARCH64_FL_##IDENT, EXT_NAME },
#include "aarch64-option-extensions.def"
};
for (unsigned int i = 0; i < ARRAY_SIZE (extensions); ++i)
if (missing_extensions & extensions[i].flag)
{
aarch64_report_missing_extension (location, fndecl, extensions[i].name);
return false;
}
gcc_unreachable ();
}
bool
aarch64_general_check_builtin_call (location_t location, vec<location_t>,
unsigned int code, tree fndecl,
unsigned int nargs ATTRIBUTE_UNUSED, tree *args)
{
tree decl = aarch64_builtin_decls[code];
switch (code)
{
case AARCH64_RSR:
@@ -2115,17 +2207,43 @@ aarch64_general_check_builtin_call (location_t location, vec<location_t>,
case AARCH64_WSR64:
case AARCH64_WSRF:
case AARCH64_WSRF64:
tree addr = STRIP_NOPS (args[0]);
if (TREE_CODE (TREE_TYPE (addr)) != POINTER_TYPE
|| TREE_CODE (addr) != ADDR_EXPR
|| TREE_CODE (TREE_OPERAND (addr, 0)) != STRING_CST)
{
error_at (location, "first argument to %qD must be a string literal",
fndecl);
return false;
}
{
tree addr = STRIP_NOPS (args[0]);
if (TREE_CODE (TREE_TYPE (addr)) != POINTER_TYPE
|| TREE_CODE (addr) != ADDR_EXPR
|| TREE_CODE (TREE_OPERAND (addr, 0)) != STRING_CST)
{
error_at (location,
"first argument to %qD must be a string literal",
fndecl);
return false;
}
break;
}
case AARCH64_TME_BUILTIN_TSTART:
case AARCH64_TME_BUILTIN_TCOMMIT:
case AARCH64_TME_BUILTIN_TTEST:
case AARCH64_TME_BUILTIN_TCANCEL:
return aarch64_check_required_extensions (location, decl,
AARCH64_FL_TME);
case AARCH64_LS64_BUILTIN_LD64B:
case AARCH64_LS64_BUILTIN_ST64B:
case AARCH64_LS64_BUILTIN_ST64BV:
case AARCH64_LS64_BUILTIN_ST64BV0:
return aarch64_check_required_extensions (location, decl,
AARCH64_FL_LS64);
default:
break;
}
/* Default behavior. */
if (code >= AARCH64_MEMTAG_BUILTIN_START
&& code <= AARCH64_MEMTAG_BUILTIN_END)
return aarch64_check_required_extensions (location, decl,
AARCH64_FL_MEMTAG);
return true;
}
+6
View File
@@ -75,6 +75,7 @@ aarch64_define_unconditional_macros (cpp_reader *pfile)
builtin_define ("__ARM_STATE_ZA");
builtin_define ("__ARM_STATE_ZT0");
builtin_define ("__ARM_NEON_SVE_BRIDGE");
/* Define keyword attributes like __arm_streaming as macros that expand
to the associated [[...]] attribute. Use __extension__ in the attribute
@@ -251,6 +252,11 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile);
aarch64_def_or_undef (TARGET_BF16_FP,
"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", pfile);
aarch64_def_or_undef (TARGET_BF16_FP,
"__ARM_FEATURE_BF16", pfile);
aarch64_def_or_undef (TARGET_SVE_BF16,
"__ARM_FEATURE_SVE_BF16", pfile);
aarch64_def_or_undef (TARGET_LS64,
"__ARM_FEATURE_LS64", pfile);
aarch64_def_or_undef (AARCH64_ISA_RCPC, "__ARM_FEATURE_RCPC", pfile);
+10 -1
View File
@@ -132,6 +132,7 @@ AARCH64_CORE("octeontx2f95mm", octeontx2f95mm, cortexa57, V8_2A, (CRYPTO, PROFI
/* Fujitsu ('F') cores. */
AARCH64_CORE("a64fx", a64fx, a64fx, V8_2A, (F16, SVE), a64fx, 0x46, 0x001, -1)
AARCH64_CORE("fujitsu-monaka", fujitsu_monaka, cortexa57, V9_3A, (F16, LS64, RNG, CRYPTO, SVE2_AES, SVE2_BITPERM, SVE2_SHA3, SVE2_SM4), fujitsu_monaka, 0x46, 0x003, -1)
/* HiSilicon ('H') cores. */
AARCH64_CORE("tsv110", tsv110, tsv110, V8_2A, (CRYPTO, F16), tsv110, 0x48, 0xd01, -1)
@@ -178,17 +179,25 @@ AARCH64_CORE("cortex-a710", cortexa710, cortexa57, V9A, (SVE2_BITPERM, MEMTAG,
AARCH64_CORE("cortex-a715", cortexa715, cortexa57, V9A, (SVE2_BITPERM, MEMTAG, I8MM, BF16), neoversen2, 0x41, 0xd4d, -1)
AARCH64_CORE("cortex-a720", cortexa720, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd81, -1)
AARCH64_CORE("cortex-a725", cortexa725, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd87, -1)
AARCH64_CORE("cortex-x2", cortexx2, cortexa57, V9A, (SVE2_BITPERM, MEMTAG, I8MM, BF16), neoversen2, 0x41, 0xd48, -1)
AARCH64_CORE("cortex-x3", cortexx3, cortexa57, V9A, (SVE2_BITPERM, MEMTAG, I8MM, BF16), neoversen2, 0x41, 0xd4e, -1)
AARCH64_CORE("cortex-x4", cortexx4, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd81, -1)
AARCH64_CORE("cortex-x4", cortexx4, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd82, -1)
AARCH64_CORE("cortex-x925", cortexx925, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd85, -1)
AARCH64_CORE("neoverse-n2", neoversen2, cortexa57, V9A, (I8MM, BF16, SVE2_BITPERM, RNG, MEMTAG, PROFILE), neoversen2, 0x41, 0xd49, -1)
AARCH64_CORE("cobalt-100", cobalt100, cortexa57, V9A, (I8MM, BF16, SVE2_BITPERM, RNG, MEMTAG, PROFILE), neoversen2, 0x6d, 0xd49, -1)
AARCH64_CORE("neoverse-n3", neoversen3, cortexa57, V9_2A, (SVE2_BITPERM, RNG, MEMTAG, PROFILE), neoversen2, 0x41, 0xd8e, -1)
AARCH64_CORE("neoverse-v2", neoversev2, cortexa57, V9A, (I8MM, BF16, SVE2_BITPERM, RNG, MEMTAG, PROFILE), neoversev2, 0x41, 0xd4f, -1)
AARCH64_CORE("grace", grace, cortexa57, V9A, (I8MM, BF16, SVE2_BITPERM, SVE2_AES, SVE2_SHA3, SVE2_SM4, PROFILE), neoversev2, 0x41, 0xd4f, -1)
AARCH64_CORE("neoverse-v3", neoversev3, cortexa57, V9_2A, (SVE2_BITPERM, RNG, LS64, MEMTAG, PROFILE), neoversev2, 0x41, 0xd84, -1)
AARCH64_CORE("neoverse-v3ae", neoversev3ae, cortexa57, V9_2A, (SVE2_BITPERM, RNG, LS64, MEMTAG, PROFILE), neoversev2, 0x41, 0xd83, -1)
AARCH64_CORE("demeter", demeter, cortexa57, V9A, (I8MM, BF16, SVE2_BITPERM, RNG, MEMTAG, PROFILE), neoversev2, 0x41, 0xd4f, -1)
/* Generic Architecture Processors. */
+56 -1
View File
@@ -1933,6 +1933,43 @@ early_ra::record_artificial_refs (unsigned int flags)
m_current_point += 1;
}
// Return true if:
//
// - X is a SUBREG, in which case it is a SUBREG of some REG Y
//
// - one 64-bit word of Y can be modified while preserving all other words
//
// - X refers to no more than one 64-bit word of Y
//
// - assigning FPRs to Y would put more than one 64-bit word in each FPR
//
// For example, this is true of:
//
// - (subreg:DI (reg:TI R) 0) and
// - (subreg:DI (reg:TI R) 8)
//
// but is not true of:
//
// - (subreg:V2SI (reg:V2x2SI R) 0) or
// - (subreg:V2SI (reg:V2x2SI R) 8).
static bool
allocno_assignment_is_rmw (rtx x)
{
if (partial_subreg_p (x))
{
auto outer_mode = GET_MODE (x);
auto inner_mode = GET_MODE (SUBREG_REG (x));
if (known_eq (REGMODE_NATURAL_SIZE (inner_mode), 0U + UNITS_PER_WORD)
&& known_lt (GET_MODE_SIZE (outer_mode), UNITS_PER_VREG))
{
auto nregs = targetm.hard_regno_nregs (V0_REGNUM, inner_mode);
if (maybe_ne (nregs * UNITS_PER_WORD, GET_MODE_SIZE (inner_mode)))
return true;
}
}
return false;
}
// Model the register references in INSN as part of a backwards walk.
void
early_ra::record_insn_refs (rtx_insn *insn)
@@ -1945,9 +1982,21 @@ early_ra::record_insn_refs (rtx_insn *insn)
record_fpr_def (DF_REF_REGNO (ref));
else
{
auto range = get_allocno_subgroup (DF_REF_REG (ref));
rtx reg = DF_REF_REG (ref);
auto range = get_allocno_subgroup (reg);
for (auto &allocno : range.allocnos ())
{
// Make sure that assigning to the DF_REF_REG clobbers the
// whole of this allocno, not just some of it.
if (allocno_assignment_is_rmw (reg))
{
m_allocation_successful = false;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "read-modify-write of allocno %d",
allocno.id);
break;
}
// If the destination is unused, record a momentary blip
// in its live range.
if (!bitmap_bit_p (m_live_allocnos, allocno.id))
@@ -3388,6 +3437,12 @@ early_ra::is_dead_insn (rtx_insn *insn)
if (side_effects_p (set))
return false;
/* If we can't delete dead exceptions and the insn throws,
then the instruction is not dead. */
if (!cfun->can_delete_dead_exceptions
&& !insn_nothrow_p (insn))
return false;
return true;
}
+1
View File
@@ -35,6 +35,7 @@
#undef FBSD_TARGET_LINK_SPEC
#define FBSD_TARGET_LINK_SPEC " \
%{p:%nconsider using `-pg' instead of `-p' with gprof (1)} \
" FBSD_LINK_PG_NOTE " \
%{v:-V} \
%{assert*} %{R*} %{rpath*} %{defsym*} \
%{shared:-Bshareable %{h*} %{soname*}} \
+138 -24
View File
@@ -1093,9 +1093,9 @@ combine_reg_notes (insn_info *i1, insn_info *i2, bool load_p)
bool found_eh_region = false;
rtx result = NULL_RTX;
result = filter_notes (REG_NOTES (i2->rtl ()), result,
&found_eh_region, fr_expr);
result = filter_notes (REG_NOTES (i1->rtl ()), result,
&found_eh_region, fr_expr + 1);
result = filter_notes (REG_NOTES (i1->rtl ()), result,
&found_eh_region, fr_expr);
if (!load_p)
{
@@ -1784,6 +1784,24 @@ ldp_bb_info::fuse_pair (bool load_p,
input_uses[i] = remove_note_accesses (attempt, input_uses[i]);
}
// Get the uses that the pair instruction would have, and punt if
// the unpaired instructions use different definitions of the same
// register. That would normally be caught as a side-effect of
// hazard detection below, but this check also deals with cases
// in which one use is undefined and the other isn't.
auto new_uses = merge_access_arrays (attempt,
drop_memory_access (input_uses[0]),
drop_memory_access (input_uses[1]));
if (!new_uses.is_valid ())
{
if (dump_file)
fprintf (dump_file,
" rejecting pair: i%d and i%d use different definiitions of"
" the same register\n",
insns[0]->uid (), insns[1]->uid ());
return false;
}
// Edge case: if the first insn is a writeback load and the
// second insn is a non-writeback load which transfers into the base
// register, then we should drop the writeback altogether as the
@@ -1911,10 +1929,7 @@ ldp_bb_info::fuse_pair (bool load_p,
input_defs[1]);
gcc_assert (pair_change->new_defs.is_valid ());
pair_change->new_uses
= merge_access_arrays (attempt,
drop_memory_access (input_uses[0]),
drop_memory_access (input_uses[1]));
pair_change->new_uses = new_uses;
gcc_assert (pair_change->new_uses.is_valid ());
set_pair_pat (pair_change);
}
@@ -1936,9 +1951,7 @@ ldp_bb_info::fuse_pair (bool load_p,
case Action::CHANGE:
{
set_pair_pat (change);
change->new_uses = merge_access_arrays (attempt,
input_uses[0],
input_uses[1]);
change->new_uses = new_uses;
auto d1 = drop_memory_access (input_defs[0]);
auto d2 = drop_memory_access (input_defs[1]);
change->new_defs = merge_access_arrays (attempt, d1, d2);
@@ -1970,9 +1983,7 @@ ldp_bb_info::fuse_pair (bool load_p,
auto new_insn = crtl->ssa->create_insn (attempt, INSN, pair_pat);
change = make_change (new_insn);
change->move_range = move_range;
change->new_uses = merge_access_arrays (attempt,
input_uses[0],
input_uses[1]);
change->new_uses = new_uses;
gcc_assert (change->new_uses.is_valid ());
auto d1 = drop_memory_access (input_defs[0]);
@@ -2173,11 +2184,80 @@ protected:
def_iter_t def_iter;
insn_info *limit;
def_walker (def_info *def, insn_info *limit) :
def_iter (def), limit (limit) {}
// Array of register uses from the candidate insn which occur in MEMs.
use_array cand_addr_uses;
def_walker (def_info *def, insn_info *limit, use_array addr_uses) :
def_iter (def), limit (limit), cand_addr_uses (addr_uses) {}
virtual bool iter_valid () const { return *def_iter; }
// Implemented in {load,store}_walker.
virtual bool alias_conflict_p (int &budget) const = 0;
// Return true if the current (walking) INSN () uses a register R inside a
// MEM, where R is also used inside a MEM by the (static) candidate insn, and
// those uses see different definitions of that register. In this case we
// can't rely on RTL alias analysis, and for now we conservatively assume that
// there is an alias conflict. See PR116783.
bool addr_reg_conflict_p () const
{
use_array curr_insn_uses = insn ()->uses ();
auto cand_use_iter = cand_addr_uses.begin ();
auto insn_use_iter = curr_insn_uses.begin ();
while (cand_use_iter != cand_addr_uses.end ()
&& insn_use_iter != curr_insn_uses.end ())
{
auto insn_use = *insn_use_iter;
auto cand_use = *cand_use_iter;
if (insn_use->regno () > cand_use->regno ())
cand_use_iter++;
else if (insn_use->regno () < cand_use->regno ())
insn_use_iter++;
else
{
// As it stands I believe the alias code (memory_modified_in_insn_p)
// doesn't look at insn notes such as REG_EQU{IV,AL}, so it should
// be safe to skip over uses that only occur in notes.
if (insn_use->includes_address_uses ()
&& !insn_use->only_occurs_in_notes ()
&& insn_use->def () != cand_use->def ())
{
if (dump_file)
{
fprintf (dump_file,
"assuming aliasing of cand i%d and i%d:\n"
"-> insns see different defs of common addr reg r%u\n"
"-> ",
cand_use->insn ()->uid (), insn_use->insn ()->uid (),
insn_use->regno ());
// Note that while the following sequence could be made more
// concise by eliding pp_string calls into the pp_printf
// calls, doing so triggers -Wformat-diag.
pretty_printer pp;
pp_string (&pp, "[");
pp_access (&pp, cand_use, 0);
pp_string (&pp, "] in ");
pp_printf (&pp, "i%d", cand_use->insn ()->uid ());
pp_string (&pp, " vs [");
pp_access (&pp, insn_use, 0);
pp_string (&pp, "] in ");
pp_printf (&pp, "i%d", insn_use->insn ()->uid ());
fprintf (dump_file, "%s\n", pp_formatted_text (&pp));
}
return true;
}
cand_use_iter++;
insn_use_iter++;
}
}
return false;
}
public:
insn_info *insn () const override { return (*def_iter)->insn (); }
void advance () override { def_iter++; }
@@ -2191,6 +2271,14 @@ public:
else
return *(insn ()) < *limit;
}
bool conflict_p (int &budget) const override final
{
if (addr_reg_conflict_p ())
return true;
return alias_conflict_p (budget);
}
};
// alias_walker that iterates over stores.
@@ -2201,12 +2289,14 @@ class store_walker : public def_walker<reverse>
InsnPredicate tombstone_p;
public:
store_walker (def_info *mem_def, rtx mem, insn_info *limit_insn,
store_walker (def_info *mem_def, rtx mem,
use_array addr_uses,
insn_info *limit_insn,
InsnPredicate tombstone_fn) :
def_walker<reverse> (mem_def, limit_insn),
def_walker<reverse> (mem_def, limit_insn, addr_uses),
cand_mem (mem), tombstone_p (tombstone_fn) {}
bool conflict_p (int &budget) const override final
bool alias_conflict_p (int &budget) const override final
{
if (tombstone_p (this->insn ()))
return false;
@@ -2243,13 +2333,14 @@ public:
return (*use_iter)->insn ();
}
bool conflict_p (int &budget) const override final
bool alias_conflict_p (int &budget) const override final
{
return load_modified_by_store_p (insn (), cand_store, budget);
}
load_walker (def_info *def, insn_info *store, insn_info *limit_insn)
: Base (def, limit_insn),
load_walker (def_info *def, insn_info *store, use_array addr_uses,
insn_info *limit_insn)
: Base (def, limit_insn, addr_uses),
use_iter (Base::start_use_chain (this->def_iter)),
cand_store (store) {}
};
@@ -2628,11 +2719,32 @@ ldp_bb_info::try_fuse_pair (bool load_p, unsigned access_size,
&& bitmap_bit_p (&m_tombstone_bitmap, insn->uid ());
};
auto_vec<access_info *, 2> addr_use_vec[2];
use_array addr_uses[2];
// Collect the lists of register uses that occur in the candidate MEMs.
for (int i = 0; i < 2; i++)
{
// N.B. it's safe for us to ignore uses that only occur in notes
// here (e.g. in a REG_EQUIV expression) since we only pass the
// MEM down to the alias machinery, so it can't see any insn-level
// notes.
for (auto use : insns[i]->uses ())
if (use->is_reg ()
&& use->includes_address_uses ()
&& !use->only_occurs_in_notes ())
addr_use_vec[i].safe_push (use);
addr_uses[i] = use_array (addr_use_vec[i]);
}
store_walker<false, decltype(tombstone_p)>
forward_store_walker (mem_defs[0], cand_mems[0], insns[1], tombstone_p);
forward_store_walker (mem_defs[0], cand_mems[0], addr_uses[0], insns[1],
tombstone_p);
store_walker<true, decltype(tombstone_p)>
backward_store_walker (mem_defs[1], cand_mems[1], insns[0], tombstone_p);
backward_store_walker (mem_defs[1], cand_mems[1], addr_uses[1], insns[0],
tombstone_p);
alias_walker *walkers[4] = {};
if (mem_defs[0])
@@ -2646,8 +2758,10 @@ ldp_bb_info::try_fuse_pair (bool load_p, unsigned access_size,
{
// We want to find any loads hanging off the first store.
mem_defs[0] = memory_access (insns[0]->defs ());
load_walker<false> forward_load_walker (mem_defs[0], insns[0], insns[1]);
load_walker<true> backward_load_walker (mem_defs[1], insns[1], insns[0]);
load_walker<false> forward_load_walker (mem_defs[0], insns[0],
addr_uses[0], insns[1]);
load_walker<true> backward_load_walker (mem_defs[1], insns[1],
addr_uses[1], insns[0]);
walkers[2] = &forward_load_walker;
walkers[3] = &backward_load_walker;
do_alias_analysis (alias_hazards, walkers, load_p);
+2
View File
@@ -1008,6 +1008,8 @@ tree aarch64_general_builtin_rsqrt (unsigned int);
void handle_arm_acle_h (void);
void handle_arm_neon_h (void);
bool aarch64_check_required_extensions (location_t, tree,
aarch64_feature_flags);
bool aarch64_general_check_builtin_call (location_t, vec<location_t>,
unsigned int, tree, unsigned int,
tree *);
+1 -3
View File
@@ -7363,8 +7363,6 @@
nunits /= 2;
rtx par_even = aarch64_gen_stepped_int_parallel (nunits, 0, 2);
rtx par_odd = aarch64_gen_stepped_int_parallel (nunits, 1, 2);
if (BYTES_BIG_ENDIAN)
std::swap (operands[1], operands[2]);
emit_insn (gen_aarch64_addp<mode>_insn (operands[0], operands[1],
operands[2], par_even, par_odd));
DONE;
@@ -8496,7 +8494,7 @@
UNSPEC_CONCAT))]
"TARGET_SIMD"
"#"
"&& reload_completed"
"&& 1"
[(const_int 0)]
{
aarch64_split_combinev16qi (operands);
@@ -1174,7 +1174,7 @@ public:
Advanced SIMD argument as an SVE vector. */
if (!BYTES_BIG_ENDIAN
&& is_undef (CALL_EXPR_ARG (e.call_expr, 0)))
return simplify_gen_subreg (mode, e.args[1], GET_MODE (e.args[1]), 0);
return force_subreg (mode, e.args[1], GET_MODE (e.args[1]), 0);
rtx_vector_builder builder (VNx16BImode, 16, 2);
for (unsigned int i = 0; i < 16; i++)
@@ -1185,7 +1185,9 @@ public:
if (BYTES_BIG_ENDIAN)
return e.use_exact_insn (code_for_aarch64_sve_set_neonq (mode));
insn_code icode = code_for_vcond_mask (mode, mode);
e.args[1] = lowpart_subreg (mode, e.args[1], GET_MODE (e.args[1]));
e.args[1] = force_subreg (mode, e.args[1], GET_MODE (e.args[1]),
subreg_lowpart_offset (mode,
GET_MODE (e.args[1])));
e.add_output_operand (icode);
e.add_input_operand (icode, e.args[1]);
e.add_input_operand (icode, e.args[0]);
@@ -2855,7 +2857,9 @@ public:
: while_comparison (unspec_for_sint, unspec_for_uint), m_eq_p (eq_p)
{}
/* Try to fold a call by treating its arguments as constants of type T. */
/* Try to fold a call by treating its arguments as constants of type T.
We have already filtered out the degenerate cases of X .LT. MIN
and X .LE. MAX. */
template<typename T>
gimple *
fold_type (gimple_folder &f) const
@@ -2911,6 +2915,13 @@ public:
if (f.vectors_per_tuple () > 1)
return nullptr;
/* Filter out cases where the condition is always true or always false. */
tree arg1 = gimple_call_arg (f.call, 1);
if (!m_eq_p && operand_equal_p (arg1, TYPE_MIN_VALUE (TREE_TYPE (arg1))))
return f.fold_to_pfalse ();
if (m_eq_p && operand_equal_p (arg1, TYPE_MAX_VALUE (TREE_TYPE (arg1))))
return f.fold_to_ptrue ();
if (f.type_suffix (1).unsigned_p)
return fold_type<poly_uint64> (f);
else
@@ -364,7 +364,11 @@ DEF_SVE_FUNCTION (svusmmla, ternary_uintq_intq, s_signed, none)
DEF_SVE_FUNCTION (svmmla, mmla, s_float, none)
#undef REQUIRED_EXTENSIONS
#define REQUIRED_EXTENSIONS AARCH64_FL_SVE | AARCH64_FL_F64MM
#define REQUIRED_EXTENSIONS (AARCH64_FL_SVE \
| AARCH64_FL_F64MM \
| AARCH64_FL_SM_OFF)
DEF_SVE_FUNCTION (svld1ro, load_replicate, all_data, implicit)
DEF_SVE_FUNCTION (svmmla, mmla, d_float, none)
DEF_SVE_FUNCTION (svtrn1q, binary, all_data, none)
DEF_SVE_FUNCTION (svtrn2q, binary, all_data, none)
DEF_SVE_FUNCTION (svuzp1q, binary, all_data, none)
@@ -372,10 +376,3 @@ DEF_SVE_FUNCTION (svuzp2q, binary, all_data, none)
DEF_SVE_FUNCTION (svzip1q, binary, all_data, none)
DEF_SVE_FUNCTION (svzip2q, binary, all_data, none)
#undef REQUIRED_EXTENSIONS
#define REQUIRED_EXTENSIONS (AARCH64_FL_SVE \
| AARCH64_FL_F64MM \
| AARCH64_FL_SM_OFF)
DEF_SVE_FUNCTION (svld1ro, load_replicate, all_data, implicit)
DEF_SVE_FUNCTION (svmmla, mmla, d_float, none)
#undef REQUIRED_EXTENSIONS
@@ -221,7 +221,7 @@ public:
}
};
class svpext_impl : public function_base
class svpext_lane_impl : public function_base
{
public:
rtx
@@ -234,7 +234,7 @@ public:
}
};
class svpsel_impl : public function_base
class svpsel_lane_impl : public function_base
{
public:
rtx
@@ -619,13 +619,13 @@ FUNCTION (svmullt_lane, unspec_based_lane_function, (UNSPEC_SMULLT,
UNSPEC_UMULLT, -1))
FUNCTION (svnbsl, CODE_FOR_MODE0 (aarch64_sve2_nbsl),)
FUNCTION (svnmatch, svmatch_svnmatch_impl, (UNSPEC_NMATCH))
FUNCTION (svpext, svpext_impl,)
FUNCTION (svpext_lane, svpext_lane_impl,)
FUNCTION (svpmul, CODE_FOR_MODE0 (aarch64_sve2_pmul),)
FUNCTION (svpmullb, unspec_based_function, (-1, UNSPEC_PMULLB, -1))
FUNCTION (svpmullb_pair, unspec_based_function, (-1, UNSPEC_PMULLB_PAIR, -1))
FUNCTION (svpmullt, unspec_based_function, (-1, UNSPEC_PMULLT, -1))
FUNCTION (svpmullt_pair, unspec_based_function, (-1, UNSPEC_PMULLT_PAIR, -1))
FUNCTION (svpsel, svpsel_impl,)
FUNCTION (svpsel_lane, svpsel_lane_impl,)
FUNCTION (svqabs, rtx_code_function, (SS_ABS, UNKNOWN, UNKNOWN))
FUNCTION (svqcadd, svqcadd_impl,)
FUNCTION (svqcvt, integer_conversion, (UNSPEC_SQCVT, UNSPEC_SQCVTU,

Some files were not shown because too many files have changed in this diff Show More