gcc.git
7 hours agoDaily bump. releases/gcc-12
GCC Administrator [Sat, 10 May 2025 00:20:10 +0000 (00:20 +0000)]
Daily bump.

31 hours agoDaily bump.
GCC Administrator [Fri, 9 May 2025 00:20:55 +0000 (00:20 +0000)]
Daily bump.

2 days agoDaily bump.
GCC Administrator [Thu, 8 May 2025 00:19:37 +0000 (00:19 +0000)]
Daily bump.

3 days agoDaily bump.
GCC Administrator [Wed, 7 May 2025 00:20:59 +0000 (00:20 +0000)]
Daily bump.

4 days agoDaily bump.
GCC Administrator [Tue, 6 May 2025 00:20:32 +0000 (00:20 +0000)]
Daily bump.

4 days agoEnable generation of GNU stack notes on Linux
John David Anglin [Mon, 6 Nov 2023 20:33:15 +0000 (20:33 +0000)]
Enable generation of GNU stack notes on Linux

2023-11-06  John David Anglin  <danglin@gcc.gnu.org>

* config/pa/pa-linux.h (NEED_INDICATE_EXEC_STACK): Define to 1.

5 days agoDaily bump.
GCC Administrator [Mon, 5 May 2025 00:19:56 +0000 (00:19 +0000)]
Daily bump.

6 days agoDaily bump.
GCC Administrator [Sun, 4 May 2025 00:18:57 +0000 (00:18 +0000)]
Daily bump.

7 days agoDaily bump.
GCC Administrator [Sat, 3 May 2025 00:20:59 +0000 (00:20 +0000)]
Daily bump.

8 days agoDaily bump.
GCC Administrator [Fri, 2 May 2025 00:21:21 +0000 (00:21 +0000)]
Daily bump.

8 days agodf: Treat partial defs as uses in df_simulate_defs [PR116564]
Alex Coplan [Mon, 10 Mar 2025 16:44:15 +0000 (16:44 +0000)]
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 758e617bcf224dc9d4a7e26dd858d43c1e63b916)

9 days agoDaily bump.
GCC Administrator [Thu, 1 May 2025 00:22:46 +0000 (00:22 +0000)]
Daily bump.

9 days agoAdd test-case for PR118924
Martin Jambor [Tue, 29 Apr 2025 16:24:29 +0000 (18:24 +0200)]
Add test-case for PR118924

Because the testcase for the issue in master is in a commit I do not
plan to backport to GCC 12 but the issue is avoided by my previous one
nevertheless, I am backporting the testcase in this one.

gcc/testsuite/ChangeLog:

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

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

9 days agosra: Clear grp_same_access_path of acesses created by total scalarization (PR118924)
Martin Jambor [Mon, 7 Apr 2025 11:32:10 +0000 (13:32 +0200)]
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 40445711b8af113ef423d8bcac1a7ce1c47f62d7)

9 days agoFix GNAT build failure for x86/FreeBSD
Eric Botcazou [Wed, 30 Apr 2025 10:41:36 +0000 (12:41 +0200)]
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.

10 days agoAVR: target/119989 - Add missing clobbers to xload_<mode>_libgcc.
Georg-Johann Lay [Wed, 30 Apr 2025 06:43:51 +0000 (08:43 +0200)]
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.

      Backport from 2025-04-30 r14-11703
      PR target/119989
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.

(cherry picked from commit 1ca1c1fc3b58ae5e1d3db4f5a2014132fe69f82a)

10 days agoDaily bump.
GCC Administrator [Wed, 30 Apr 2025 00:20:58 +0000 (00:20 +0000)]
Daily bump.

10 days agos390: Accept only Pmode for registers AP/FP/RA [PR119235]
Stefan Schulze Frielinghaus [Fri, 21 Mar 2025 09:29:19 +0000 (10:29 +0100)]
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 2b383ae2a6e5fc0530bfd8b86ad0e6b27e760bd2)

11 days agoDaily bump.
GCC Administrator [Tue, 29 Apr 2025 00:22:02 +0000 (00:22 +0000)]
Daily bump.

12 days agoDaily bump.
GCC Administrator [Mon, 28 Apr 2025 00:20:51 +0000 (00:20 +0000)]
Daily bump.

13 days agoDaily bump.
GCC Administrator [Sun, 27 Apr 2025 00:20:36 +0000 (00:20 +0000)]
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sat, 26 Apr 2025 00:21:26 +0000 (00:21 +0000)]
Daily bump.

2 weeks agoAvoid using POINTER_DIFF_EXPR for overlap checks [PR119399]
Richard Sandiford [Fri, 25 Apr 2025 11:04:47 +0000 (12:04 +0100)]
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 4c8c373495d7d863dfb7102726ac3b4b41685df4)

2 weeks agovect: Enforce dr_with_seg_len::align precondition [PR116125]
Richard Sandiford [Fri, 25 Apr 2025 11:04:46 +0000 (12:04 +0100)]
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 e8651b80aeb86da935035e218747a6b41b611497)

2 weeks agoDaily bump.
GCC Administrator [Fri, 25 Apr 2025 00:19:43 +0000 (00:19 +0000)]
Daily bump.

2 weeks agoc++: templates, attributes, #pragma target [PR114772]
Jason Merrill [Wed, 16 Apr 2025 16:02:58 +0000 (12:02 -0400)]
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 5fdb0145fb9499f5db9e27f775895ce4a39215e4)

2 weeks agoDaily bump.
GCC Administrator [Wed, 23 Apr 2025 00:19:29 +0000 (00:19 +0000)]
Daily bump.

2 weeks agoFortran: fix issue with impure elemental subroutine and interface [PR119656]
Harald Anlauf [Tue, 8 Apr 2025 20:30:15 +0000 (22:30 +0200)]
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 334545194d9023fb9b2f72ee0dcde8af94930f25)

2 weeks agoDaily bump.
GCC Administrator [Tue, 22 Apr 2025 00:21:04 +0000 (00:21 +0000)]
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Mon, 21 Apr 2025 00:19:36 +0000 (00:19 +0000)]
Daily bump.

2 weeks agoFix compilation of server.cc on hpux.
John David Anglin [Mon, 9 Jan 2023 15:41:51 +0000 (15:41 +0000)]
Fix compilation of server.cc on hpux.

Select and FD_ISSET are declared in sys/time.h on most versions
of hpux.  As a result, HAVE_PSELECT and HAVE_SELECT can be 0.

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

c++tools/ChangeLog:

PR other/107616
* server.cc (server): Don't call FD_ISSET when HAVE_PSELECT
and HAVE_SELECT are zero.

2 weeks agod: Fix ICE in dwarf2out_imported_module_or_decl, at dwarf2out.cc:27676 [PR119817]
Iain Buclaw [Tue, 15 Apr 2025 12:49:34 +0000 (14:49 +0200)]
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 f5ed7d19c965de9ccb158d77e929b17459bf65b5)

2 weeks agoDaily bump.
GCC Administrator [Sun, 20 Apr 2025 00:21:12 +0000 (00:21 +0000)]
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Sat, 19 Apr 2025 00:21:01 +0000 (00:21 +0000)]
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Fri, 18 Apr 2025 00:20:19 +0000 (00:20 +0000)]
Daily bump.

3 weeks agolibstdc++: Qualify calls to debug mode helpers
Jonathan Wakely [Fri, 23 Jun 2023 12:50:01 +0000 (13:50 +0100)]
libstdc++: Qualify calls to debug mode helpers

These functions should be qualified to disable unwanted ADL.

The overload of __check_singular_aux for safe iterators was previously
being found by ADL, because it wasn't declared before __check_singular.
Add a declaration so that it can be found by qualified lookup.

libstdc++-v3/ChangeLog:

* include/debug/helper_functions.h (__get_distance)
(__check_singular, __valid_range_aux, __valid_range): Qualify
calls to disable ADL.
(__check_singular_aux(const _Safe_iterator_base*)): Declare
overload that was previously found via ADL.

(cherry picked from commit fa98bc4270dcb4ec78b5b1c0f4c067094c84bae6)

3 weeks agolibstdc++: Fix infinite loop in std::istream::ignore(n, delim) [PR93672]
Jonathan Wakely [Thu, 4 Apr 2024 09:33:33 +0000 (10:33 +0100)]
libstdc++: Fix infinite loop in std::istream::ignore(n, delim) [PR93672]

A negative delim value passed to std::istream::ignore can never match
any character in the stream, because the comparison is done using
traits_type::eq_int_type(sb->sgetc(), delim) and sgetc() never returns
negative values (except at EOF). The optimized version of ignore for the
std::istream specialization uses traits_type::find to locate the delim
character in the streambuf, which _can_ match a negative delim on
platforms where char is signed, but then we do another comparison using
eq_int_type which fails. The code then keeps looping forever, with
traits_type::find locating the character and traits_type::eq_int_type
saying it's not a match, so traits_type::find is used again and finds
the same character again.

A possible fix would be to check with eq_int_type after a successful
find, to see whether we really have a match. However, that would be
suboptimal since we know that a negative delimiter will never match
using eq_int_type. So a better fix is to adjust the check at the top of
the function that handles delim==eof(), so that we treat all negative
delim values as equivalent to EOF. That way we don't bother using find
to search for something that will never match with eq_int_type.

The version of ignore in the primary template doesn't need a change,
because it doesn't use traits_type::find, instead characters are
extracted one-by-one and always matched using eq_int_type. That avoids
the inconsistency between find and eq_int_type. The specialization for
std::wistream does use traits_type::find, but traits_type::to_int_type
is equivalent to an implicit conversion from wchar_t to wint_t, so
passing a wchar_t directly to ignore without using to_int_type works.

libstdc++-v3/ChangeLog:

PR libstdc++/93672
* src/c++98/istream.cc (istream::ignore(streamsize, int_type)):
Treat all negative delimiter values as eof().
* testsuite/27_io/basic_istream/ignore/char/93672.cc: New test.
* testsuite/27_io/basic_istream/ignore/wchar_t/93672.cc: New
test.

(cherry picked from commit 2d694414ada8e3b58f504c1b175d31088529632e)

3 weeks agolibstdc++: Fix bogus -Wstringop-overflow in std::vector::insert [PR117983]
Jonathan Wakely [Fri, 28 Mar 2025 22:00:38 +0000 (22:00 +0000)]
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 878812b6f6905774ab37cb78903e3e11bf1c508c)

3 weeks agolibstdc++: Fix std::deque::insert(pos, first, last) undefined behaviour [PR118035]
Jonathan Wakely [Mon, 16 Dec 2024 17:42:24 +0000 (17:42 +0000)]
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 b273e25e11c842a5729d0e03c85088cf5ba8e06c)

3 weeks agoDaily bump.
GCC Administrator [Thu, 17 Apr 2025 00:20:34 +0000 (00:20 +0000)]
Daily bump.

3 weeks agotestcase: Add testcase for already fixed PR [PR118476]
Andrew Pinski [Mon, 14 Apr 2025 15:40:24 +0000 (08:40 -0700)]
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 d45a6502d1ec87d43f1a39f87cca58f1e28369c8)

3 weeks agomatch: Reject non-ssa name/min invariants in gimple_extract [PR116412]
Andrew Pinski [Mon, 19 Aug 2024 15:06:36 +0000 (08:06 -0700)]
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.

GCC13: the function is in gimple-match-head.cc rather than gimple-match-exports.cc.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116412

gcc/ChangeLog:

* gimple-match-head.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 c7b76a076cb2c6ded7ae208464019b04cb0531a2)

3 weeks agophiopt: Fix value_replacement for middle bb having phi nodes [PR118922]
Andrew Pinski [Sun, 9 Mar 2025 06:43:54 +0000 (22:43 -0800)]
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 7232c005afb5002cdfd0a2dbd0e8b8f2d80250ce)

3 weeks agovec-lowering: Fix ABSU lowering [PR111285]
Andrew Pinski [Sun, 27 Oct 2024 20:16:22 +0000 (13:16 -0700)]
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 ad0084337e901ddaedd48c14e7a5dad9fc2a093e)

3 weeks agobackprop: Fix deleting of a phi node [PR116922]
Andrew Pinski [Tue, 1 Oct 2024 21:48:19 +0000 (14:48 -0700)]
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 cea87c84eacdb422caeada734ba5138c994d7022)

3 weeks agophiopt: Reset the number of iterations information of a loop when changing an exit...
Andrew Pinski [Mon, 2 Dec 2024 16:35:23 +0000 (08:35 -0800)]
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 b7c69cc072ef0da36439ebc55c513b48e68391b7)

3 weeks agolibstdc++: Add dg-options "-std=gnu++20" to backported tests
Jonathan Wakely [Wed, 16 Apr 2025 17:38:03 +0000 (18:38 +0100)]
libstdc++: Add dg-options "-std=gnu++20" to backported tests

These tests were backported from gcc-14 where the testsuite
automatically adds -std=gnu++20 as needed. That doesn't happen on the
older release branches, so an explicit dg-options directive is needed to
ensure the tests are run by default. Otherwise they'll only be run when
somebody uses a custom --target_board that includes -std=gnu++20.

For 29_atomics/headers/stdatomic.h/115807.cc we need to compile with
-std=gnu++23 instead.

libstdc++-v3/ChangeLog:

* testsuite/20_util/integer_sequence/112473.cc: Compile with
-std=gnu++20.
* testsuite/21_strings/char_traits/requirements/113200.cc:
Likewise.
* testsuite/23_containers/array/comparison_operators/106212.cc:
Likewise.
* testsuite/23_containers/span/117966.cc: Likewise.
* testsuite/23_containers/vector/cons/113841.cc: Compile with
-std=gnu++20.
* testsuite/24_iterators/move_iterator/lwg3736.cc: Likewise.
* testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc:
Likewise.
* testsuite/27_io/filesystem/iterators/lwg3480.cc: Likewise.
* testsuite/29_atomics/headers/stdatomic.h/115807.cc: Compile
with -std=gnu++23.
* testsuite/std/ranges/subrange/lwg3589.cc: Likewise.
* testsuite/std/time/month/2.cc: Likewise.
* testsuite/std/time/weekday/2.cc: Likewise.

(cherry picked from commit 4182fa87758d5a94c1f6d71f471842207e56f933)

3 weeks agolibstdc++: Fix get<0> constraint for lvalue ranges::subrange (LWG 3589)
Jonathan Wakely [Thu, 14 Nov 2024 17:31:43 +0000 (17:31 +0000)]
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 4a3a0be34f723df192361e43bb48b9292dfe3a54)

3 weeks agolibstdc++: Skip redundant assertions in std::array equality [PR106212]
Jonathan Wakely [Mon, 9 Dec 2024 17:35:24 +0000 (17:35 +0000)]
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 3aeb2edee2f9fc39ab77c7e020f09d7204b167ac)

3 weeks agolibstdc++: Skip redundant assertions in std::span construction [PR117966]
Jonathan Wakely [Mon, 9 Dec 2024 17:35:24 +0000 (17:35 +0000)]
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 e95bda027e0b81922c1bf44770674190bdf787e8)

3 weeks agolibstdc++: Constrain std::vector default constructor [PR113841]
Jonathan Wakely [Fri, 9 Feb 2024 17:06:20 +0000 (17:06 +0000)]
libstdc++: Constrain std::vector default constructor [PR113841]

This is needed to avoid errors outside the immediate context when
evaluating is_default_constructible_v<vector<T, A>> when A is not
default constructible.

To avoid diagnostic regressions for 23_containers/vector/48101_neg.cc we
need to make the std::allocator<cv T> partial specializations default
constructible, which they probably should have been anyway.

libstdc++-v3/ChangeLog:

PR libstdc++/113841
* include/bits/allocator.h (allocator<cv T>): Add default
constructor to partial specializations for cv-qualified types.
* include/bits/stl_vector.h (_Vector_impl::_Vector_impl()):
Constrain so that it's only present if the allocator is default
constructible.
* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()):
Likewise.
* testsuite/23_containers/vector/cons/113841.cc: New test.

(cherry picked from commit 142cc4c223d695e515ed2504501b91d8a7ac6eb8)

3 weeks agolibstdc++: Specialize std::disable_sized_sentinel_for for std::move_iterator [PR116549]
Jonathan Wakely [Mon, 2 Sep 2024 10:29:13 +0000 (11:29 +0100)]
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 819deae0a5bee079a7d5582fafaa098c26144ae8)

3 weeks agolibstdc++: Add missing parts of LWG 3480 for directory iterators [PR117560]
Jonathan Wakely [Thu, 14 Nov 2024 01:14:44 +0000 (01:14 +0000)]
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 eec6e8923586b9a54e37f32cef112d26d86e8f01)

3 weeks agoDaily bump.
GCC Administrator [Wed, 16 Apr 2025 00:20:39 +0000 (00:20 +0000)]
Daily bump.

3 weeks agolibstdc++: Document thread-safety for COW std::string [PR21334]
Jonathan Wakely [Fri, 11 Apr 2025 10:08:34 +0000 (11:08 +0100)]
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 dd35f66287b7cca196a720c9641e463255dceb1c)

3 weeks agoDaily bump.
GCC Administrator [Tue, 15 Apr 2025 00:21:18 +0000 (00:21 +0000)]
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Mon, 14 Apr 2025 00:19:22 +0000 (00:19 +0000)]
Daily bump.

3 weeks agortl-optimization/119689 - compare-debug failure with LRA
Richard Biener [Wed, 9 Apr 2025 12:36:19 +0000 (14:36 +0200)]
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 088887de7717a22b1503760e9b79dfbe22a0f428)

3 weeks ago[PR115568][LRA]: Use more strict output reload check in rematerialization
Vladimir N. Makarov [Wed, 5 Feb 2025 19:23:23 +0000 (14:23 -0500)]
[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 98545441308c2ae4d535f14b108ad6551fd927d5)

3 weeks agoDaily bump.
GCC Administrator [Sun, 13 Apr 2025 00:18:50 +0000 (00:18 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Sat, 12 Apr 2025 00:18:48 +0000 (00:18 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Fri, 11 Apr 2025 00:18:50 +0000 (00:18 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Thu, 10 Apr 2025 00:19:05 +0000 (00:19 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Wed, 9 Apr 2025 00:19:41 +0000 (00:19 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Tue, 8 Apr 2025 00:20:16 +0000 (00:20 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Mon, 7 Apr 2025 00:19:02 +0000 (00:19 +0000)]
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Sun, 6 Apr 2025 00:18:50 +0000 (00:18 +0000)]
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Sat, 5 Apr 2025 00:19:15 +0000 (00:19 +0000)]
Daily bump.

5 weeks agotree-optimization/114246 - invalid call argument from DSE
Richard Biener [Wed, 6 Mar 2024 08:02:31 +0000 (09:02 +0100)]
tree-optimization/114246 - invalid call argument from DSE

The following makes sure to strip type conversions added by
build_fold_addr_expr before placing the result in a call argument.

PR tree-optimization/114246
* tree-ssa-dse.cc (increment_start_addr): Strip useless
type conversions from the adjusted address.

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

(cherry picked from commit 0249744a9fe0775c2c895727aeebec4c59fd5f95)

5 weeks agomiddle-end/115641 - invalid address construction
Richard Biener [Thu, 18 Jul 2024 11:35:33 +0000 (13:35 +0200)]
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 3670c70c561656a19f6bff36dd229f18120af127)

5 weeks agotree-optimization/116481 - avoid building function_type[]
Richard Biener [Sun, 13 Oct 2024 09:42:27 +0000 (11:42 +0200)]
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 1506027347776a2f6ec5b92d56ef192e85944e2e)

5 weeks agotree-optimization/116850 - corrupt post-dom info
Richard Biener [Thu, 26 Sep 2024 13:41:59 +0000 (15:41 +0200)]
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 64163657ba7e70347087a63bb2b32d83b52ea7d9)

5 weeks 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 weeks agotree-optimization/117574 - bougs niter lt-to-ne
Richard Biener [Fri, 15 Nov 2024 10:56:14 +0000 (11:56 +0100)]
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 ff5a14abeb31cd6bd0ca55e7043d05c8141a8c7f)

5 weeks agotree-optimization/117912 - bogus address equivalences for __builtin_object_size
Richard Biener [Thu, 5 Dec 2024 09:47:13 +0000 (10:47 +0100)]
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 233972ab3b5338d7a5d1d7af9108c1f366170e44)

5 weeks 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 weeks agoAda: Fix thinko in Eigensystem for complex Hermitian matrices
Eric Botcazou [Fri, 4 Apr 2025 09:45:23 +0000 (11:45 +0200)]
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.

5 weeks agoDaily bump.
GCC Administrator [Fri, 4 Apr 2025 00:19:26 +0000 (00:19 +0000)]
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Thu, 3 Apr 2025 00:20:14 +0000 (00:20 +0000)]
Daily bump.

5 weeks agolibstdc++: Teach optimizer that empty COW strings are empty [PR107087]
Jonathan Wakely [Fri, 31 Mar 2023 12:44:04 +0000 (13:44 +0100)]
libstdc++: Teach optimizer that empty COW strings are empty [PR107087]

The compiler doesn't know about the invariant that the _S_empty_rep()
object is immutable and so _M_length and _M_refcount are always zero.
This means that we get warnings about writing possibly-non-zero length
strings into buffers that can't hold them. If we teach the compiler that
the empty rep is always zero length, it knows it can be copied into any
buffer.

For Stage 1 we might want to also consider adding this to capacity():

if (_S_empty_rep()._M_capacity != 0)
  __builtin_unreachable();

And this to _Rep::_M_is_leaked() and _Rep::_M_is_shared():

  if (_S_empty_rep()._M_refcount != 0)
    __builtin_unreachable();

libstdc++-v3/ChangeLog:

PR tree-optimization/107087
* include/bits/cow_string.h (basic_string::size()): Add
optimizer hint that _S_empty_rep()._M_length is always zero.
(basic_string::length()): Call size().

(cherry picked from commit 4969dcd2b7a94ce6c0d07225b21b5f3c040a4902)

5 weeks agolibstdc++: Avoid aliasing violation in std::valarray [PR99117]
Jonathan Wakely [Thu, 8 Feb 2024 13:59:42 +0000 (13:59 +0000)]
libstdc++: Avoid aliasing violation in std::valarray [PR99117]

The call to __valarray_copy constructs an _Array object to refer to
this->_M_data but that means that accesses to this->_M_data are through
a restrict-qualified pointer. This leads to undefined behaviour when
copying from an _Expr object that actually aliases this->_M_data.

Replace the call to __valarray_copy with a plain loop. I think this
removes the only use of that overload of __valarray_copy, so it could
probably be removed. I haven't done that here.

libstdc++-v3/ChangeLog:

PR libstdc++/99117
* include/std/valarray (valarray::operator=(const _Expr&)):
Use loop to copy instead of __valarray_copy with _Array.
* testsuite/26_numerics/valarray/99117.cc: New test.

(cherry picked from commit b58f0e5216a3053486e7f1aa96c3f2443b14d630)

5 weeks agoDaily bump.
GCC Administrator [Wed, 2 Apr 2025 00:21:11 +0000 (00:21 +0000)]
Daily bump.

5 weeks agoaarch64: Use PAUTH instead of V8_3A in some places
Andrew Carlotti [Tue, 30 Jul 2024 15:26:04 +0000 (16:26 +0100)]
aarch64: Use PAUTH instead of V8_3A in some places

gcc/ChangeLog:

PR target/119372
* config/aarch64/aarch64.cc
(aarch64_expand_epilogue): Use TARGET_PAUTH.
* config/aarch64/aarch64.md: Update comment.

(cherry-picked from commit 20385cb92cbd4a1934661ab97a162c1e25935836)

5 weeks agoDaily bump.
GCC Administrator [Tue, 1 Apr 2025 00:20:52 +0000 (00:20 +0000)]
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Mon, 31 Mar 2025 00:20:31 +0000 (00:20 +0000)]
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Sun, 30 Mar 2025 00:19:50 +0000 (00:19 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Sat, 29 Mar 2025 00:21:19 +0000 (00:21 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Fri, 28 Mar 2025 00:21:02 +0000 (00:21 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Thu, 27 Mar 2025 00:20:08 +0000 (00:20 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Wed, 26 Mar 2025 00:18:57 +0000 (00:18 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Tue, 25 Mar 2025 00:20:53 +0000 (00:20 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Mon, 24 Mar 2025 00:19:41 +0000 (00:19 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Sun, 23 Mar 2025 00:18:55 +0000 (00:18 +0000)]
Daily bump.

6 weeks agoDaily bump.
GCC Administrator [Sat, 22 Mar 2025 09:28:13 +0000 (09:28 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Fri, 21 Mar 2025 00:20:10 +0000 (00:20 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Thu, 20 Mar 2025 00:20:51 +0000 (00:20 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Wed, 19 Mar 2025 00:19:26 +0000 (00:19 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Tue, 18 Mar 2025 00:20:36 +0000 (00:20 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Mon, 17 Mar 2025 00:19:25 +0000 (00:19 +0000)]
Daily bump.

7 weeks agoDaily bump.
GCC Administrator [Sun, 16 Mar 2025 00:20:00 +0000 (00:20 +0000)]
Daily bump.

This page took 0.098367 seconds and 5 git commands to generate.