]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 months agoDaily bump.
GCC Administrator [Tue, 11 Mar 2025 00:22:48 +0000 (00:22 +0000)] 
Daily bump.

4 months agolibphobos: Default to libc closefrom in spawnProcessPosix [PR119112]
Iain Buclaw [Mon, 10 Mar 2025 19:52:49 +0000 (20:52 +0100)] 
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

5 months agoFortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
Paul Thomas [Mon, 27 Jan 2025 09:55:26 +0000 (09:55 +0000)] 
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 3600b1ff14a459e84bb40bdfea7cd8d2ffd73d8d)

5 months agoDaily bump.
GCC Administrator [Mon, 10 Mar 2025 00:21:35 +0000 (00:21 +0000)] 
Daily bump.

5 months agoFortran: Fix segmentation fault in defined assignment [PR109066]
Paul Thomas [Sat, 16 Nov 2024 15:56:10 +0000 (15:56 +0000)] 
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 27ff8049bbdb0a001ba46835cd6a334c4ac76573)

5 months agoFortran: Fix ICE in resolve.cc with -pedantic
Jerry DeLisle [Sat, 8 Mar 2025 02:33:29 +0000 (18:33 -0800)] 
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 3014f8787196d7c0d15d24195c8f07167968ff55)

5 months agoFortran: Fix gimplification error on assignment to pointer [PR103391]
Andre Vehreschild [Tue, 4 Mar 2025 11:56:20 +0000 (12:56 +0100)] 
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 04909c7ecc023874c3444b85f88c60b7b7cc7778)

5 months agoDaily bump.
GCC Administrator [Sun, 9 Mar 2025 00:21:44 +0000 (00:21 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sat, 8 Mar 2025 00:22:25 +0000 (00:22 +0000)] 
Daily bump.

5 months agoarm: Handle fixed PIC register in require_pic_register (PR target/115485)
Christophe Lyon [Mon, 3 Mar 2025 11:12:18 +0000 (11:12 +0000)] 
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 b1d0ac28de643e7c810e407a0668737131cdcc00)

5 months agoDaily bump.
GCC Administrator [Fri, 7 Mar 2025 00:22:10 +0000 (00:22 +0000)] 
Daily bump.

5 months agoLoongArch: Fix incorrect reorder of __lsx_vldx and __lasx_xvldx [PR119084]
Xi Ruoyao [Sun, 2 Mar 2025 11:02:50 +0000 (19:02 +0800)] 
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 4856292f7a680ec478e7607f1b71781996d7d542)

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.

5 months agoDaily bump.
GCC Administrator [Thu, 6 Mar 2025 00:24:11 +0000 (00:24 +0000)] 
Daily bump.

5 months agoc++: disable -Wnonnull in unevaluated context [PR115580]
Marek Polacek [Tue, 4 Mar 2025 18:07:27 +0000 (13:07 -0500)] 
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 459c8a55567b06522e4b9cc0a4ef62f9d3024526)

5 months agoaarch64: Check for invalid use arrays in ldp_fusion [PR118320]
Richard Sandiford [Wed, 5 Mar 2025 12:18:20 +0000 (12:18 +0000)] 
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>
5 months agoarm: Fix signedness of vld1q intrinsic parms [PR118942]
Hannes Braun [Thu, 20 Feb 2025 14:09:41 +0000 (15:09 +0100)] 
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 4d0a333ef13e2da140cd44c4941b20f48a80dc0f)

5 months agolibstdc++: Fix subrange conversion to pair-like [PR119121]
Tomasz Kamiński [Wed, 5 Mar 2025 10:11:55 +0000 (11:11 +0100)] 
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 95b2f8d8fb3131165b1b38645dacf10a5dd2bc15)

5 months agoDaily bump.
GCC Administrator [Wed, 5 Mar 2025 00:25:17 +0000 (00:25 +0000)] 
Daily bump.

5 months agoc++: generic lambda, implicit 'this' capture, xobj memfn [PR119038]
Patrick Palka [Fri, 28 Feb 2025 15:56:49 +0000 (10:56 -0500)] 
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 1a150f1f688486b12cd975bdc4cd1bd52a7e0110)

5 months agoaarch64: Add missing simd requirements for INS [PR118531]
Richard Sandiford [Tue, 4 Mar 2025 17:49:31 +0000 (17:49 +0000)] 
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 1b8820421488d220a95f651b51175d618063c48c)

5 months agoFix folding of BIT_NOT_EXPR for POLY_INT_CST [PR118976]
Richard Sandiford [Tue, 4 Mar 2025 17:49:30 +0000 (17:49 +0000)] 
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 78380fd7f743e23dfdf013d68a2f0347e1511550)

5 months agoarm: xfail gcc.target/arm/unsigned-extend-1.c for thumb1
Richard Earnshaw [Mon, 3 Mar 2025 15:30:58 +0000 (15:30 +0000)] 
arm: xfail gcc.target/arm/unsigned-extend-1.c for thumb1

Partial backport of 2a502f9e4c5c6a8e908ef1b0b5c03fb2e4bd4390.

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>
5 months agotestsuite: arm: Use effective-target for pr68674.c test
Torbjörn SVENSSON [Fri, 8 Nov 2024 17:39:32 +0000 (18:39 +0100)] 
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 879fd9c822633ecf2c62471d1a7f9b9619e296b7)

5 months agotestsuite: Add tests for already fixed PR [PR119071]
Jakub Jelinek [Tue, 4 Mar 2025 08:52:22 +0000 (09:52 +0100)] 
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 ccf9db9a6fa4b5bc7aad5e9603e2ac71984142a0)

5 months agocombine: Discard REG_UNUSED note in i2 when register is also referenced in i3 [PR118739]
Uros Bizjak [Wed, 12 Feb 2025 10:19:57 +0000 (11:19 +0100)] 
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 a92dc3fe31c95d56019b2fb95a58414bca06241f)

5 months agoipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243)
Martin Jambor [Tue, 4 Mar 2025 13:53:41 +0000 (14:53 +0100)] 
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 0bffcd469e68d68ba9c724f515651deff8494b82)

5 months agoDaily bump.
GCC Administrator [Tue, 4 Mar 2025 00:22:48 +0000 (00:22 +0000)] 
Daily bump.

5 months agogimple: sccopy: Prune removed statements from SCCs [PR117919]
Filip Kastl [Sun, 2 Mar 2025 05:39:17 +0000 (06:39 +0100)] 
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 5349aa2accdf34a7bf9cabd1447878aaadfc0e87)

5 months agoDaily bump.
GCC Administrator [Mon, 3 Mar 2025 00:24:30 +0000 (00:24 +0000)] 
Daily bump.

5 months ago[PR target/116720] Fix test for valid mempair operands
Jeff Law [Sun, 29 Dec 2024 15:27:30 +0000 (08:27 -0700)] 
[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 0b06abe027a78681d29a5e91daa74bf8dba39826)

5 months agod: Fix comparing uninitialized memory in dstruct.d [PR116961]
Iain Buclaw [Fri, 28 Feb 2025 18:22:36 +0000 (19:22 +0100)] 
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 f7bc17ebc9ef89700672ed7125da719f3558f3b7)

5 months agoDaily bump.
GCC Administrator [Sun, 2 Mar 2025 00:24:16 +0000 (00:24 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sat, 1 Mar 2025 13:10:14 +0000 (13:10 +0000)] 
Daily bump.

5 months agolibstdc++: Use init_priority attribute for tzdb globals [PR118811]
Jonathan Wakely [Wed, 12 Feb 2025 17:29:59 +0000 (17:29 +0000)] 
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 99f57446e63b8ebeaeeae8dc48981cd5f1dfb831)

5 months agolibstdc++: Hide std::tuple internals from Doxygen docs
Jonathan Wakely [Fri, 23 Aug 2024 21:06:43 +0000 (22:06 +0100)] 
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 5cfee9360c90da8171e9f6bb71568bdc4c296e6e)

5 months agolibstdc++: Fix outdated comment in <stacktrace>
Jonathan Wakely [Thu, 27 Feb 2025 21:58:09 +0000 (21:58 +0000)] 
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 e8302282cdb53ae1d347c12d7a50c4209fbab4f7)

5 months agolibstdc++: Reuse temporary buffer utils in <stacktrace>
Jonathan Wakely [Sat, 1 Jun 2024 09:45:55 +0000 (10:45 +0100)] 
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 2a83084ce5536353ceb8554e906f87273a59c4fd)

5 months agolibstdc++: Optimize std::basic_string_view::starts_with
Jonathan Wakely [Thu, 30 May 2024 19:36:42 +0000 (20:36 +0100)] 
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 482f97e79fc29ea2d61f1425b32564a668b51e1c)

5 months agolibstdc++: Do not use C++11 alignof in C++98 mode [PR104395]
Jonathan Wakely [Wed, 26 Jun 2024 13:09:07 +0000 (14:09 +0100)] 
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 03d3aeb0e0fa7dec9bd702cabf57ef73cdc32704)

5 months agolibstdc++: Fix warning regressions in <bits/stl_tempbuf.h>
Jonathan Wakely [Tue, 18 Jun 2024 19:53:53 +0000 (20:53 +0100)] 
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 8c52adcf5f9812ef66aeef357590fb2f148302f7)

5 months agolibstdc++: Handle extended alignment in std::get_temporary_buffer [PR105258]
Jonathan Wakely [Wed, 13 Apr 2022 12:03:44 +0000 (13:03 +0100)] 
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 b0efdcbf58a76af3b8fff75f1d53d334fb5b46ee)

5 months agolibstdc++: fix a dangling reference crash in ranges::is_permutation [PR118160]
Giuseppe D'Angelo [Thu, 6 Feb 2025 14:24:17 +0000 (14:24 +0000)] 
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 2a2bd96d0d2109384a0eedde843ba811d2e18738)

5 months agolibstdc++: Qualify calls in <bits/stl_uninitialized.h> to prevent ADL
Jonathan Wakely [Thu, 20 Jun 2024 23:25:32 +0000 (00:25 +0100)] 
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 09ca26cd24778e0820525edfac1cce07262f7e6c)

5 months agolibstdc++: Add missing character to __to_wstring_numeric map
Jonathan Wakely [Mon, 16 Dec 2024 09:45:40 +0000 (09:45 +0000)] 
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 e1937cf33abded5c6ebbe4938a4a3e8cb3365176)

5 months agolibstdc++: Add missing equality comparison in new tests [PR117921]
Jonathan Wakely [Mon, 9 Dec 2024 09:36:15 +0000 (09:36 +0000)] 
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 5cdd78b39725fb1d82cb6bd68e8f56bf4f5d51cd)

5 months agolibstdc++: Use ADL swap for containers' function objects [PR117921]
Jonathan Wakely [Thu, 5 Dec 2024 12:46:26 +0000 (12:46 +0000)] 
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 0368c42507328774cadbea589509b95aaf3cb826)

5 months agolibstdc++: Add debug assertions to std::list and std::forward_list
Jonathan Wakely [Fri, 15 Nov 2024 22:03:20 +0000 (22:03 +0000)] 
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 e7aa614d7372b5d3cbcd2400838c80ef905ba381)

5 months agolibstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]
Jonathan Wakely [Mon, 30 Dec 2024 13:08:41 +0000 (13:08 +0000)] 
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 301a961ffd0567eece55ece42e80a7ba9e855ba0)

5 months agoDaily bump.
GCC Administrator [Fri, 28 Feb 2025 00:23:33 +0000 (00:23 +0000)] 
Daily bump.

5 months agotestsuite: limit concepts-pr67774.C to C++20
Jason Merrill [Sat, 15 Feb 2025 23:17:30 +0000 (00:17 +0100)] 
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.

5 months agoc++: NRVO, constexpr, lambda [PR118053]
Jason Merrill [Sat, 15 Feb 2025 09:48:17 +0000 (10:48 +0100)] 
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 de66529f2e7bb24fb2b61b82e6a953f3f6c12902)

5 months agoc++: disable initializer_list transformation
Jason Merrill [Tue, 28 Jan 2025 22:39:41 +0000 (17:39 -0500)] 
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.

5 months agoc++: Update const_decl handling after r15-7259 [PR118673].
Iain Sandoe [Thu, 30 Jan 2025 08:19:21 +0000 (08:19 +0000)] 
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>
5 months agoc++: init-list opt and lvalue initializers [PR118673]
Jason Merrill [Mon, 27 Jan 2025 23:30:18 +0000 (18:30 -0500)] 
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.

5 months agoc++: constexpr VEC_INIT_EXPR [PR118285]
Jason Merrill [Tue, 28 Jan 2025 18:11:50 +0000 (13:11 -0500)] 
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.

5 months agoi386: Treat Granite Rapids/Granite Rapids-D similar as Sapphire Rapids in x86-tune.def
Haochen Jiang [Wed, 26 Feb 2025 03:28:45 +0000 (11:28 +0800)] 
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.

5 months agoDaily bump.
GCC Administrator [Thu, 27 Feb 2025 00:23:41 +0000 (00:23 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Wed, 26 Feb 2025 00:23:33 +0000 (00:23 +0000)] 
Daily bump.

5 months agos390: Fix s390_valid_shift_count() for TI mode [PR118835]
Stefan Schulze Frielinghaus [Thu, 13 Feb 2025 08:13:06 +0000 (09:13 +0100)] 
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 ac9806dae30d07ab082ac341fe5646987753adcb)

5 months agojit/118780 - make sure to include dlfcn.h when plugin support is disabled
Richard Biener [Fri, 7 Feb 2025 13:42:23 +0000 (14:42 +0100)] 
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 e22962538f64bb6e5ac87977ec8a5d86f4ef21cb)

5 months agoDaily bump.
GCC Administrator [Tue, 25 Feb 2025 00:22:55 +0000 (00:22 +0000)] 
Daily bump.

5 months agotree-optimization/118717 - store commoning vs. abnormals
Richard Biener [Mon, 3 Feb 2025 08:55:50 +0000 (09:55 +0100)] 
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 fbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5)

5 months agotree-optimization/118653 - ICE in vectorizable_live_operation
Richard Biener [Mon, 27 Jan 2025 11:53:21 +0000 (12:53 +0100)] 
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 6a510dea7f3b047d0650a48e558a4911973930eb)

5 months agotree-optimization/117979 - failed irreducible loop update from DCE
Richard Biener [Wed, 8 Jan 2025 08:25:52 +0000 (09:25 +0100)] 
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 eca04660a2c9546c8ecefc5288395eb8a9fdc168)

5 months agotree-optimization/117119 - ICE with int128 IV in dataref analysis
Richard Biener [Mon, 13 Jan 2025 08:12:23 +0000 (09:12 +0100)] 
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 d3904a3ad9d7b4c8e5e536e5166b89548510fd48)

5 months agotree-optimization/117113 - ICE with unroll-and-jam
Richard Biener [Mon, 3 Feb 2025 14:12:52 +0000 (15:12 +0100)] 
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 0675eb17480bada678bf2769d39732027abcd6d0)

5 months agolto/113207 - fix free_lang_data_in_type
Richard Biener [Mon, 3 Feb 2025 13:27:01 +0000 (14:27 +0100)] 
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 a55e14b239181381204c615335929b3316d75370)

5 months agortl-optimization/118662 - wrong combination of vector sign-extends
Richard Biener [Mon, 27 Jan 2025 09:49:51 +0000 (10:49 +0100)] 
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 343e1083eb9f57e05c0caba195f118ef2e95cc40)

5 months agotree-optimization/117424 - invalid LIM of trapping ref
Richard Biener [Tue, 28 Jan 2025 11:28:14 +0000 (12:28 +0100)] 
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 f1e776ce58ae4a6ae67886adb4ae806598e2c7ef)

5 months agotree-optimization/116906 - unsafe PRE with never executed edges
Richard Biener [Tue, 1 Oct 2024 08:37:16 +0000 (10:37 +0200)] 
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 3e1bd6470e4deba1a3ad14621037098311ad1350)

5 months agotree-optimization/115494 - PRE PHI translation and ranges
Richard Biener [Wed, 15 Jan 2025 13:31:57 +0000 (14:31 +0100)] 
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 ea1deefe54ea1c5182bfa179abf36469c9ec6974)

5 months agotree-optimization/114052 - consider infinite sub-loops when lowering iter bound
Richard Biener [Wed, 29 Jan 2025 12:25:14 +0000 (13:25 +0100)] 
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.

5 months agotree-optimization/112859 - add comment
Richard Biener [Tue, 28 Jan 2025 14:01:25 +0000 (15:01 +0100)] 
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 3ccbc8c9d182c380e396631b2b5a683de4fddba9)

5 months agotree-optimization/112859 - bogus loop distribution
Richard Biener [Thu, 23 Jan 2025 12:10:17 +0000 (13:10 +0100)] 
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 04ba1300407f106a6dd10d346f58a51d87e6d43e)

5 months agoDaily bump.
GCC Administrator [Mon, 24 Feb 2025 00:23:13 +0000 (00:23 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sun, 23 Feb 2025 00:22:25 +0000 (00:22 +0000)] 
Daily bump.

5 months agoFortran: passing of derived type to VALUE,OPTIONAL dummy argument [PR118080]
Harald Anlauf [Sat, 15 Feb 2025 19:36:15 +0000 (20:36 +0100)] 
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 8859dce9037bcb242819305f02e16edbea38923c)

5 months agoDaily bump.
GCC Administrator [Sat, 22 Feb 2025 00:22:48 +0000 (00:22 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Fri, 21 Feb 2025 00:22:41 +0000 (00:22 +0000)] 
Daily bump.

5 months agoLoongArch: Fix the issue of function jump out of range caused by crtbeginS.o [PR118844].
Lulu Cheng [Wed, 12 Feb 2025 06:29:58 +0000 (14:29 +0800)] 
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 ae14d7d04da8c6cb542269722638071f999f94d8)

5 months agoDaily bump.
GCC Administrator [Thu, 20 Feb 2025 00:21:46 +0000 (00:21 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Wed, 19 Feb 2025 00:22:07 +0000 (00:22 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Tue, 18 Feb 2025 00:22:39 +0000 (00:22 +0000)] 
Daily bump.

5 months agoFreeBSD: Stop linking _p libs for -pg as of FreeBSD 14
Andreas Tobler [Sun, 9 Jun 2024 21:18:04 +0000 (23:18 +0200)] 
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.

5 months agoLoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843].
Lulu Cheng [Wed, 12 Feb 2025 03:50:50 +0000 (11:50 +0800)] 
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 ee579b7c257468b9032ab4583ec455fa871d4428)

5 months agoi386: Deprecate -m[no-]avx10.1 and make -mno-avx10.1-512 to disable the whole AVX10.1
Haochen Jiang [Tue, 11 Feb 2025 03:29:34 +0000 (11:29 +0800)] 
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.

5 months agoi386: Do not check vector size conflict when AVX512 is not explicitly set [PR 118815]
Haochen Jiang [Mon, 10 Feb 2025 08:53:27 +0000 (16:53 +0800)] 
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.

5 months agoDaily bump.
GCC Administrator [Mon, 17 Feb 2025 00:26:29 +0000 (00:26 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sun, 16 Feb 2025 00:26:05 +0000 (00:26 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sat, 15 Feb 2025 00:26:41 +0000 (00:26 +0000)] 
Daily bump.

5 months ago[PATCH] PR modula2/118761: gm2 driver doesnt behave as gcc for -fhelp=BLA
Gaius Mulley [Fri, 14 Feb 2025 19:17:02 +0000 (19:17 +0000)] 
[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 3c5422e719d1fbabccaa9b63605171ea8bdfe57e)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoFortran: fix initialization of allocatable non-deferred character [PR59252]
Harald Anlauf [Fri, 7 Feb 2025 20:21:10 +0000 (21:21 +0100)] 
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 818c36a85e3faec5442eb26799bfa3bba7764b36)

5 months agoDaily bump.
GCC Administrator [Fri, 14 Feb 2025 00:22:20 +0000 (00:22 +0000)] 
Daily bump.

5 months agodriver: -fhardened and -z lazy/-z norelro [PR117739]
Marek Polacek [Tue, 26 Nov 2024 19:37:21 +0000 (14:37 -0500)] 
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 a134dcd8a010744a0097d190f73a4efc2e381531)

5 months ago[PATCH] PR modula2/115112 Incorrect line debugging information occurs during INC...
Gaius Mulley [Thu, 13 Feb 2025 18:17:17 +0000 (18:17 +0000)] 
[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 4d0faaaaf917528d1c59bfad5401274c5be71b7b)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoc++: Constrain visibility for CNTTPs with internal types [PR118849]
Nathaniel Shead [Wed, 12 Feb 2025 12:07:43 +0000 (23:07 +1100)] 
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>
5 months agoDaily bump.
GCC Administrator [Thu, 13 Feb 2025 00:22:19 +0000 (00:22 +0000)] 
Daily bump.

5 months ago[PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr
Gaius Mulley [Wed, 12 Feb 2025 21:26:04 +0000 (21:26 +0000)] 
[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 e2d32c81a993a27f3e9b5408f5d20580fe58feca)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoDaily bump.
GCC Administrator [Wed, 12 Feb 2025 00:22:40 +0000 (00:22 +0000)] 
Daily bump.

5 months agox86: Correct ASM_OUTPUT_SYMBOL_REF
H.J. Lu [Tue, 11 Feb 2025 05:47:54 +0000 (13:47 +0800)] 
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 7317fc0b03380a83ad03a5fc4fabef5f38c44c9d)