]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
20 months agoApply some TLC to vect_slp_analyze_instance_dependence
Richard Biener [Fri, 25 Aug 2023 09:43:36 +0000 (11:43 +0200)] 
Apply some TLC to vect_slp_analyze_instance_dependence

This refactors things, separating load and store handing, adjusting
comments to reflect reality and removing some dead code.

* tree-vect-data-refs.cc (vect_slp_analyze_store_dependences):
Split out from vect_slp_analyze_node_dependences, remove
dead code.
(vect_slp_analyze_load_dependences): Split out from
vect_slp_analyze_node_dependences, adjust comments.  Process
queued stores before any disambiguation.
(vect_slp_analyze_node_dependences): Remove.
(vect_slp_analyze_instance_dependence): Adjust.

(cherry picked from commit 470da3b27e6dbeb3286b09dcb1c1b810ac75b276)

20 months agoDaily bump.
GCC Administrator [Fri, 24 Nov 2023 00:21:24 +0000 (00:21 +0000)] 
Daily bump.

20 months agoi386: Wrong code with __builtin_parityl [PR112672]
Uros Bizjak [Thu, 23 Nov 2023 15:17:57 +0000 (16:17 +0100)] 
i386: Wrong code with __builtin_parityl [PR112672]

gen_parityhi2_cmp instruction clobbers its input operand, so use
a temporary register in the call to gen_parityhi2_cmp.

PR target/112672

gcc/ChangeLog:

* config/i386/i386.md (parityhi2):
Use temporary register in the call to gen_parityhi2_cmp.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112672.c: New test.

(cherry picked from commit b2d17bdd45b582b93e89c00b04763a45f97d7a34)

20 months agoDaily bump.
GCC Administrator [Thu, 23 Nov 2023 00:22:04 +0000 (00:22 +0000)] 
Daily bump.

20 months agoc++: alias template of non-template class [PR112633]
Patrick Palka [Thu, 23 Nov 2023 00:07:19 +0000 (19:07 -0500)] 
c++: alias template of non-template class [PR112633]

The entering_scope adjustment in tsubst_aggr_type assumes if an alias is
dependent, then so is the aliased type (and therefore it has template info)
but that's not true for the dependent alias template specialization ty1<T>
below which aliases the non-template class A.  In this case no adjustment
is needed anyway, so we can just punt.

PR c++/112633

gcc/cp/ChangeLog:

* pt.cc (tsubst_aggr_type): Handle empty TYPE_TEMPLATE_INFO
in the entering_scope adjustment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-75.C: New test.

(cherry picked from commit 3f266c84a15d63e42bfad46397fea9aff92b0720)

20 months agoPR target/111815: VAX: Only accept the index scaler as the RHS operand to ASHIFT
Maciej W. Rozycki [Wed, 22 Nov 2023 01:27:02 +0000 (01:27 +0000)] 
PR target/111815: VAX: Only accept the index scaler as the RHS operand to ASHIFT

As from commit 9df1ba9a35b8 ("libbacktrace: support zstd decompression")
GCC for the `vax-netbsdelf' target fails to complete building, with an
ICE:

during RTL pass: final
.../libbacktrace/elf.c: In function 'elf_zstd_decompress':
.../libbacktrace/elf.c:5006:1: internal compiler error: in print_operand_address, at config/vax/vax.cc:514
 5006 | }
      | ^
0x1113df97 print_operand_address(_IO_FILE*, rtx_def*)
.../gcc/config/vax/vax.cc:514
0x10c2489b default_print_operand_address(_IO_FILE*, machine_mode, rtx_def*)
.../gcc/targhooks.cc:373
0x106ddd0b output_address(machine_mode, rtx_def*)
.../gcc/final.cc:3648
0x106ddd0b output_asm_insn(char const*, rtx_def**)
.../gcc/final.cc:3505
0x106e2143 output_asm_insn(char const*, rtx_def**)
.../gcc/final.cc:3421
0x106e2143 final_scan_insn_1
.../gcc/final.cc:2841
0x106e28e3 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
.../gcc/final.cc:2887
0x106e2bf7 final_1
.../gcc/final.cc:1979
0x106e3c67 rest_of_handle_final
.../gcc/final.cc:4240
0x106e3c67 execute
.../gcc/final.cc:4318
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

This is due to combine producing an invalid address RTX:

(plus:SI (ashift:SI (const_int 1 [0x1])
        (reg:QI 3 %r3 [1232]))
    (reg/v:SI 10 %r10 [orig:736 weight_mask ] [736]))

where the expression is ((1 << R3) + R10), which does not match a valid
machine addressing mode.  Consequently `print_operand_address' chokes.

This can be reduced to the testcase included, where it triggers the same
ICE in `p'.  Preincrements are required so that their results land in
registers and consequently an indexed addressing mode is tried or
otherwise doing operations piecemeal on stack-based function arguments
as direct input operands turns out more profitable in terms of RTX costs
and the ICE is avoided.

The ultimate cause has been commit c605a8bf9270 ("VAX: Accept ASHIFT in
address expressions"), where a shift of an immediate value by a register
has been mistakenly allowed as an index expression as if the shift
operation was commutative such as multiplication is.  So with ASHIFT the
scaler in an index expression has to be the right-hand operand, and the
backend has to enforce that, whereas with MULT the scaler can be either
operand.

Fix this by only accepting the index scaler as the RHS operand to
ASHIFT.

gcc/
PR target/111815
* config/vax/vax.cc (index_term_p): Only accept the index scaler
as the RHS operand to ASHIFT.

gcc/testsuite/
PR target/111815
* gcc.dg/torture/pr111815.c: New test.

(cherry picked from commit 56ff988e6be3fdba70cad86d73ec0038bc3b6b5a)

20 months agoDaily bump.
GCC Administrator [Wed, 22 Nov 2023 00:21:36 +0000 (00:21 +0000)] 
Daily bump.

20 months agoBump LTO_minor_version
Martin Jambor [Tue, 21 Nov 2023 12:41:56 +0000 (13:41 +0100)] 
Bump LTO_minor_version

I believe r13-8039-g06ee3438a4fcf9 has changed LTO format and
therefore we should bump the minor version of the GCC 13 LTO format.

gcc/ChangeLog:

2023-11-20  Martin Jambor  <mjambor@suse.cz>

* lto-streamer.h (LTO_minor_version): Bump.

20 months agoDaily bump.
GCC Administrator [Tue, 21 Nov 2023 00:22:21 +0000 (00:22 +0000)] 
Daily bump.

20 months agoLoongArch: Modify MUSL_DYNAMIC_LINKER.
Lulu Cheng [Sat, 18 Nov 2023 03:04:42 +0000 (11:04 +0800)] 
LoongArch: Modify MUSL_DYNAMIC_LINKER.

Use no suffix at all in the musl dynamic linker name for hard
float ABI. Use -sf and -sp suffixes in musl dynamic linker name
for soft float and single precision ABIs. The following table
outlines the musl interpreter names for the LoongArch64 ABI names.

musl interpreter            | LoongArch64 ABI
--------------------------- | -----------------
ld-musl-loongarch64.so.1    | loongarch64-lp64d
ld-musl-loongarch64-sp.so.1 | loongarch64-lp64f
ld-musl-loongarch64-sf.so.1 | loongarch64-lp64s

gcc/ChangeLog:

* config/loongarch/gnu-user.h (MUSL_ABI_SPEC): Modify suffix.

(cherry picked from commit 8bccee51f0deac64b79cd9ad75df599422f4c8ff)

20 months agoLoongArch: Fix MUSL_DYNAMIC_LINKER
Peng Fan [Wed, 19 Apr 2023 08:23:42 +0000 (16:23 +0800)] 
LoongArch: Fix MUSL_DYNAMIC_LINKER

The system based on musl has no '/lib64', so change it.

https://wiki.musl-libc.org/guidelines-for-distributions.html,
"Multilib/multi-arch" section of this introduces it.

gcc/
* config/loongarch/gnu-user.h (MUSL_DYNAMIC_LINKER): Redefine.

Signed-off-by: Peng Fan <fanpeng@loongson.cn>
Suggested-by: Xi Ruoyao <xry111@xry111.site>
(cherry picked from commit a80c68a08604b0ac625ac7fc59eae40b551b1176)

20 months agoDaily bump.
GCC Administrator [Mon, 20 Nov 2023 00:20:40 +0000 (00:20 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sun, 19 Nov 2023 00:21:26 +0000 (00:21 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sat, 18 Nov 2023 00:21:20 +0000 (00:21 +0000)] 
Daily bump.

20 months agoPR target/53372: Don't ignore section attribute with address-space.
Georg-Johann Lay [Fri, 17 Nov 2023 11:51:16 +0000 (12:51 +0100)] 
PR target/53372: Don't ignore section attribute with address-space.

gcc/
PR target/53372
* config/avr/avr.cc (avr_asm_named_section) [AVR_SECTION_PROGMEM]:
Only return some .progmem*.data section if the user did not
specify a section attribute.
(avr_section_type_flags) [avr_progmem_p]: Unset SECTION_NOTYPE
in returned section flags.

gcc/testsuite/
PR target/53372
* gcc.target/avr/pr53372-1.c: New test.
* gcc.target/avr/pr53372-2.c: New test.

(cherry picked from commit 68221c54a9752dbf131c231413edfd21046f8dad)

20 months agoc++: retval dtor on rethrow [PR112301]
Jason Merrill [Mon, 30 Oct 2023 21:44:54 +0000 (17:44 -0400)] 
c++: retval dtor on rethrow [PR112301]

In r12-6333 for PR33799, I fixed the example in [except.ctor]/2.  In that
testcase, the exception is caught and the function returns again,
successfully.

In this testcase, however, the exception is rethrown, and hits two separate
cleanups: one in the try block and the other in the function body.  So we
destroy twice an object that was only constructed once.

Fortunately, the fix for the normal case is easy: we just need to clear the
"return value constructed by return" flag when we do it the first time.

This gets more complicated with the named return value optimization, since
we don't want to destroy the return value while the NRV variable is still in
scope.

PR c++/112301
PR c++/102191
PR c++/33799

gcc/cp/ChangeLog:

* except.cc (maybe_splice_retval_cleanup): Clear
current_retval_sentinel when destroying retval.
* semantics.cc (nrv_data): Add in_nrv_cleanup.
(finalize_nrv): Set it.
(finalize_nrv_r): Fix handling of throwing cleanups.

gcc/testsuite/ChangeLog:

* g++.dg/eh/return1.C: Add more cases.

20 months agoc++: fix contracts with NRV
Jason Merrill [Tue, 6 Jun 2023 03:58:32 +0000 (23:58 -0400)] 
c++: fix contracts with NRV

The NRV implementation was blindly replacing the operand of RETURN_EXPR,
clobbering anything that check_return_expr might have added on to the actual
initialization, such as checking the postcondition.

gcc/cp/ChangeLog:

* semantics.cc (finalize_nrv_r): [RETURN_EXPR]: Only replace the
INIT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts-post7.C: New test.

20 months agoc++: fix throwing cleanup with label
Jason Merrill [Tue, 6 Jun 2023 19:31:23 +0000 (15:31 -0400)] 
c++: fix throwing cleanup with label

While looking at PR92407 I noticed that the expectations of
maybe_splice_retval_cleanup weren't being met; an sk_cleanup level was
confusing its attempt to recognize the outer block of the function.  And
even if I fixed the detection, it failed to actually wrap the body of the
function because the STATEMENT_LIST it got only had the label, not anything
after it.  So I moved the call after poplevel does pop_stmt_list on all the
sk_cleanup levels.

PR c++/33799

gcc/cp/ChangeLog:

* except.cc (maybe_splice_retval_cleanup): Change
recognition of function body and try scopes.
* semantics.cc (do_poplevel): Call it after poplevel.
(at_try_scope): New.
* cp-tree.h (maybe_splice_retval_cleanup): Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/eh/return1.C: Add label cases.

20 months agoFix warning on new Ada testcase
Eric Botcazou [Thu, 16 Nov 2023 21:41:53 +0000 (22:41 +0100)] 
Fix warning on new Ada testcase

gcc/testsuite/
* gnat.dg/varsize4.adb (Func): Initialize Byte_Read parameter.

20 months agoFix internal error on function returning dynamically-sized type
Eric Botcazou [Thu, 16 Nov 2023 17:36:44 +0000 (18:36 +0100)] 
Fix internal error on function returning dynamically-sized type

This is a tree sharing issue for the internal return type synthesized for
a function returning a dynamically-sized type and taking an Out or In/Out
parameter passed by copy.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a
TYPE_DECL for the return type built for the CI/CO mechanism.

gcc/testsuite/
* gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test.
* gnat.dg/varsize4_pkg.ads: New helper.

20 months agoLoongArch: Remove redundant barrier instructions before LL-SC loops
Xi Ruoyao [Mon, 6 Nov 2023 08:06:08 +0000 (16:06 +0800)] 
LoongArch: Remove redundant barrier instructions before LL-SC loops

This is isomorphic to the LLVM changes [1-2].

On LoongArch, the LL and SC instructions has memory barrier semantics:

- LL: <memory-barrier> + <load-exclusive>
- SC: <store-conditional> + <memory-barrier>

But the compare and swap operation is allowed to fail, and if it fails
the SC instruction is not executed, thus the guarantee of acquiring
semantics cannot be ensured. Therefore, an acquire barrier needs to be
generated when failure_memorder includes an acquire operation.

On CPUs implementing LoongArch v1.10 or later, "dbar 0b10100" is an
acquire barrier; on CPUs implementing LoongArch v1.00, it is a full
barrier.  So it's always enough for acquire semantics.  OTOH if an
acquire semantic is not needed, we still needs the "dbar 0x700" as the
load-load barrier like all LL-SC loops.

[1]:https://github.com/llvm/llvm-project/pull/67391
[2]:https://github.com/llvm/llvm-project/pull/69339

Backported for fixing the acquire semantic issue which is known to
cause troubles on LA664.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_memmodel_needs_release_fence): Remove.
(loongarch_cas_failure_memorder_needs_acquire): New static
function.
(loongarch_print_operand): Redefine 'G' for the barrier on CAS
failure.
* config/loongarch/sync.md (atomic_cas_value_strong<mode>):
Remove the redundant barrier before the LL instruction, and
emit an acquire barrier on failure if needed by
failure_memorder.
(atomic_cas_value_cmp_and_7_<mode>): Likewise.
(atomic_cas_value_add_7_<mode>): Remove the unnecessary barrier
before the LL instruction.
(atomic_cas_value_sub_7_<mode>): Likewise.
(atomic_cas_value_and_7_<mode>): Likewise.
(atomic_cas_value_xor_7_<mode>): Likewise.
(atomic_cas_value_or_7_<mode>): Likewise.
(atomic_cas_value_nand_7_<mode>): Likewise.
(atomic_cas_value_exchange_7_<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/cas-acquire.c: New test.

(cherry picked from commit 4d86dc51e34d2a5695b617afeb56e3414836a79a)

20 months agoDaily bump.
GCC Administrator [Thu, 16 Nov 2023 00:21:25 +0000 (00:21 +0000)] 
Daily bump.

20 months agolibstdc++: Fix std::deque::operator[] Xmethod [PR112491]
Jonathan Wakely [Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)] 
libstdc++: Fix std::deque::operator[] Xmethod [PR112491]

The Xmethod for std::deque::operator[] has the same bug that I recently
fixed for the std::deque::size() Xmethod. The first node might have
unused capacity at the start, which needs to be accounted for when
indexing into the deque.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index):
Correctly handle unused capacity at the start of the first node.
* testsuite/libstdc++-xmethods/deque.cc: Check index operator
when elements have been removed from the front.

(cherry picked from commit 452476db0c705caeac8712d560fc16ced0ca5226)

20 months agolibstdc++: std::stacktrace tweaks
Jonathan Wakely [Wed, 15 Nov 2023 09:17:49 +0000 (09:17 +0000)] 
libstdc++: std::stacktrace tweaks

Fix a typo in a string literal and make the new hash.cc test gracefully
handle missing stacktrace data (see PR 112541).

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::at): Fix class name
in exception message.
* testsuite/19_diagnostics/stacktrace/hash.cc: Do not fail if
current() returns a non-empty stacktrace.

(cherry picked from commit cbd0fe22a5ced9751d2450dc4fd6fe3525c2fc02)

20 months agors6000: Consider inline asm as safe if no assembler complains [PR111828]
Kewen Lin [Mon, 6 Nov 2023 06:14:43 +0000 (00:14 -0600)] 
rs6000: Consider inline asm as safe if no assembler complains [PR111828]

As discussed in PR111828, rs6000_update_ipa_fn_target_info
is much conservative, currently for any non-empty inline
asm, without any parsing, it would take inline asm could
have HTM insns.  It means for one function attributed with
power8 having inline asm, even if it has no HTM insns, we
don't make a function attributed with power10 inline it.

Peter pointed out an inline asm parser can be a slippery
slope, and noticed that the current gnu assembler still
allows HTM insns even with power10 machine type, so he
suggested that we can aggressively ignore the handling on
inline asm, this patch goes for this suggestion.

Considering that there are a few assembler alternatives
and assembler can update its behaviors (complaining HTM
insns at power10 and later cpus sounds reasonable from a
certain point of view), this patch also checks assembler
complains on HTM insns at power10 or not.  For a case that
a caller attributed power10 calls a callee attributed
power8 having inline asm with HTM insn, without inlining
at least the compilation succeeds, but if assembler
complains HTM insns at power10, after inlining the
compilation would fail.

The two associated test cases are fine without and with
this patch (effective target takes effect or not).

PR target/111828

gcc/ChangeLog:

* config.in: Regenerate.
* config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Guard
inline asm handling under !HAVE_AS_POWER10_HTM.
* configure: Regenerate.
* configure.ac: Detect assembler support for HTM insns at power10.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_powerpc_as_p10_htm): New proc.
* g++.target/powerpc/pr111828-1.C: New test.
* g++.target/powerpc/pr111828-2.C: New test.

(cherry picked from commit b2075291af8810794c7184fd125b991c2341cb1e)

20 months agoDaily bump.
GCC Administrator [Wed, 15 Nov 2023 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

20 months agoFix ICE in vectorizable_nonlinear_induction with bitfield.
liuhongt [Mon, 13 Nov 2023 09:56:49 +0000 (17:56 +0800)] 
Fix ICE in vectorizable_nonlinear_induction with bitfield.

 if (TREE_CODE (init_expr) == INTEGER_CST)
    init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
  else
    gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
                                       TREE_TYPE (init_expr)));

and init_expr is a 24 bit integer type while vectype has 32bit components.

The "fix" is to bail out instead of asserting.

gcc/ChangeLog:

PR tree-optimization/112496
* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
false when !tree_nop_conversion_p (TREE_TYPE (vectype),
TREE_TYPE (init_expr)).

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112496.c: New test.

(cherry picked from commit f28306b4fd309b579c8a4a5bf2f1b24fa40f8f7f)

20 months agolibstdc++: Fix std::hash<std::stacktrace> [PR112348]
Jonathan Wakely [Tue, 14 Nov 2023 22:36:31 +0000 (22:36 +0000)] 
libstdc++: Fix std::hash<std::stacktrace> [PR112348]

libstdc++-v3/ChangeLog:

PR libstdc++/112348
* include/std/stacktrace (hash<basic_stacktrace<Alloc>>): Fix
type of hash function for entries.
* testsuite/19_diagnostics/stacktrace/hash.cc: New test.

(cherry picked from commit 6f2fc42d9e52e8322e718e0154cd235d00906f99)

20 months agolibstdc++: Fix std::deque::size() Xmethod [PR112491]
Jonathan Wakely [Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)] 
libstdc++: Fix std::deque::size() Xmethod [PR112491]

The Xmethod for std::deque::size() assumed that the first element would
be at the start of the first node. That's only true if elements are only
added at the back. If an element is inserted at the front, or removed
from the front (or anywhere before the middle) then the first node will
not be completely populated, and the Xmethod will give the wrong result.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
calculation to use _M_start._M_cur.
* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.

(cherry picked from commit 4db820928065eccbeb725406450d826186582b9f)

20 months agolibstdc++: Add dg-timeout-factor to remaining <chrono> IO tests
Jonathan Wakely [Mon, 13 Nov 2023 10:50:39 +0000 (10:50 +0000)] 
libstdc++: Add dg-timeout-factor to remaining <chrono> IO tests

I meant to add these changes as part of r14-4959-g7d06b29f814580 but
missed these files out.

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/file/io.cc: Double timeout using
dg-timeout-factor.
* testsuite/std/time/clock/gps/io.cc: Likewise.
* testsuite/std/time/clock/system/io.cc: Likewise.
* testsuite/std/time/clock/tai/io.cc: Likewise.
* testsuite/std/time/clock/utc/io.cc: Likewise.

(cherry picked from commit c28b0326ce040cf8c9ce0b008cc7a920ae4b7db7)

20 months agors6000: Don't allow AltiVec address in movoo & movxo pattern [PR110411]
Jeevitha [Thu, 31 Aug 2023 10:40:18 +0000 (05:40 -0500)] 
rs6000: Don't allow AltiVec address in movoo & movxo pattern [PR110411]

There are no instructions that do traditional AltiVec addresses (i.e.
with the low four bits of the address masked off) for OOmode and XOmode
objects. The solution is to modify the constraints used in the movoo and
movxo pattern to disallow these types of addresses, which assists LRA in
resolving this issue. Furthermore, the mode size 16 check has been
removed in vsx_quad_dform_memory_operand to allow OOmode and XOmode, and
quad_address_p already handles less than size 16.

2023-08-31  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
PR target/110411
* config/rs6000/mma.md (define_insn_and_split movoo): Disallow
AltiVec address operands.
(define_insn_and_split movxo): Likewise.
* config/rs6000/predicates.md (vsx_quad_dform_memory_operand): Remove
redundant mode size check.

gcc/testsuite/
PR target/110411
* gcc.target/powerpc/pr110411-1.c: New testcase.
* gcc.target/powerpc/pr110411-2.c: New testcase.

(cherry picked from commit 9ea1248604d7b65009af32103814332f35bd33e2)

20 months agoDaily bump.
GCC Administrator [Tue, 14 Nov 2023 12:27:11 +0000 (12:27 +0000)] 
Daily bump.

20 months agoLibF7: sinh: Fix loss of precision due to cancellation for small values.
Georg-Johann Lay [Tue, 14 Nov 2023 11:05:19 +0000 (12:05 +0100)] 
LibF7: sinh: Fix loss of precision due to cancellation for small values.

libgcc/config/avr/libf7/
* libf7-const.def [F7MOD_sinh_]: Add MiniMax polynomial.
* libf7.c (f7_sinh): Use it instead of (exp(x) - exp(-x)) / 2
when |x| < 0.5 to avoid loss of precision due to cancellation.

20 months agolibstdc++: Correctly call _string_types function
Tom Tromey [Wed, 4 Oct 2023 14:59:47 +0000 (08:59 -0600)] 
libstdc++: Correctly call _string_types function

flake8 points out that the new call to _string_types from
StdExpAnyPrinter.__init__ is not correct -- it needs to be qualified.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py
(StdExpAnyPrinter.__init__): Qualify call to
_string_types.

(cherry picked from commit 4bf77db70e2521dc89f9d7f51c7ae6e58a94b4f9)

20 months agolibstdc++: _versioned_namespace is always non-None
Tom Tromey [Tue, 3 Oct 2023 17:14:45 +0000 (11:14 -0600)] 
libstdc++: _versioned_namespace is always non-None

Some code in the pretty-printers seems to assume that the
_versioned_namespace global might be None (or the empty string).
However, doesn't occur, as the variable is never reassigned.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Assume that
_versioned_namespace is non-None.
* python/libstdcxx/v6/xmethods.py (is_specialization_of):
Assume that _versioned_namespace is non-None.

(cherry picked from commit d342c9de6a1534cbce324bcc3c7c0898ff74d386)

20 months agolibstdc++: Define _versioned_namespace in xmethods.py
Tom Tromey [Tue, 3 Oct 2023 17:08:02 +0000 (11:08 -0600)] 
libstdc++: Define _versioned_namespace in xmethods.py

flake8 pointed out that is_specialization_of in xmethods.py looks at a
global that wasn't added to the file.  This patch correct the
oversight.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/xmethods.py (_versioned_namespace):
Define.

(cherry picked from commit 83ec6e80ff0d56342fc066c2ef649036c0983529)

20 months agolibstdc++: Use Python "not in" operator
Tom Tromey [Wed, 27 Sep 2023 15:26:01 +0000 (09:26 -0600)] 
libstdc++: Use Python "not in" operator

flake8 warns about code like

    not something in "whatever"

Ordinarily in Python this should be written as:

    something not in "whatever"

This patch makes this change.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (Printer.add_version)
(add_one_template_type_printer)
(FilteringTypePrinter.add_one_type_printer): Use Python
"not in" operator.

(cherry picked from commit 202810947ca793b17653658e584008fb151e0937)

20 months agolibstdc++: Remove std_ratio_t_tuple
Tom Tromey [Tue, 26 Sep 2023 20:04:26 +0000 (14:04 -0600)] 
libstdc++: Remove std_ratio_t_tuple

This removes the std_ratio_t_tuple function from the Python
pretty-printer code.  It is not used.  Apparently the relevant parts
were moved to StdChronoDurationPrinter._ratio at some point in the
past.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (std_ratio_t_tuple):
Remove.

(cherry picked from commit 860b284e3eea49e5bd49e6fe07c66e53faebb893)

20 months agolibstdc++: Remove unused locals from printers.py
Tom Tromey [Tue, 26 Sep 2023 19:58:57 +0000 (13:58 -0600)] 
libstdc++: Remove unused locals from printers.py

flake8 pointed out some unused local variables in the libstdc++
pretty-printers.  This removes them.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py
(StdExpOptionalPrinter.__init__, lookup_node_type):
Remove unused variables.

(cherry picked from commit 33841921a2b1153e6d79f0b4a5870f12aa2e86a1)

20 months agolibstdc++: Remove unused Python imports
Tom Tromey [Tue, 26 Sep 2023 19:46:57 +0000 (13:46 -0600)] 
libstdc++: Remove unused Python imports

flake8 pointed out some unused imports.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Don't import 'os'.
* python/libstdcxx/v6/__init__.py: Don't import 'gdb'.

(cherry picked from commit bed1f8498a1ba0c5ffdb09fd9bd0c080d9bdfe8c)

20 months agolibstdc++: Use gdb.ValuePrinter base class
Tom Tromey [Tue, 26 Sep 2023 19:38:42 +0000 (13:38 -0600)] 
libstdc++: Use gdb.ValuePrinter base class

GDB 14 will add a new ValuePrinter tag class that will be used to
signal that pretty-printers will agree to the "extension protocol" --
essentially that they will follow some simple namespace rules, so that
GDB can add new methods over time.

A couple new methods have already been added to GDB, to support DAP.
While I haven't implemented these for any libstdc++ printers yet, this
patch makes the basic conversion: printers derive from
gdb.ValuePrinter if it is available, and all "non-standard" (that is,
not specified by GDB) members of the various value-printing classes
are renamed to have a leading underscore.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Use gdb.ValuePrinter
everywhere.  Rename members to start with "_".

(cherry picked from commit 64f121030135b421d6ec16bf619cb14c50443aff)

20 months agolibstdc++: Refactor Python Xmethods to use is_specialization_of
Jonathan Wakely [Thu, 28 Sep 2023 19:52:01 +0000 (20:52 +0100)] 
libstdc++: Refactor Python Xmethods to use is_specialization_of

This copies the is_specialization_of function from printers.py (with
slight modification for versioned namespace handling) and reuses it in
xmethods.py to replace repetitive re.match calls in every class.

This fixes the problem that the regular expressions used \d without
escaping the backslash properly.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/xmethods.py (is_specialization_of): Define
new function.
(ArrayMethodsMatcher, DequeMethodsMatcher)
(ForwardListMethodsMatcher, ListMethodsMatcher)
(VectorMethodsMatcher, AssociativeContainerMethodsMatcher)
(UniquePtrGetWorker, UniquePtrMethodsMatcher)
(SharedPtrSubscriptWorker, SharedPtrMethodsMatcher): Use
is_specialization_of instead of re.match.

(cherry picked from commit 17d3477fa89466604bee5af2a2caf8de5441aeb5)

20 months agolibstdc++: Reformat Python code
Jonathan Wakely [Thu, 28 Sep 2023 13:54:59 +0000 (14:54 +0100)] 
libstdc++: Reformat Python code

Some of these changes were suggested by autopep8's --aggressive
option, others are for readability.

Break long lines by splitting strings across multiple lines, or
introducing local variables to hold results.

Use raw strings for regular expressions, so that backslashes don't need
to be escaped.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Break long lines. Use raw
strings for regular expressions. Add whitespace around
operators.
(is_member_of_namespace): Use isinstance to check type.
(is_specialization_of): Likewise. Adjust template_name
for versioned namespace instead of duplicating the re.match
call.
(StdExpAnyPrinter._string_types): New static method.
(StdExpAnyPrinter.to_string): Use _string_types.

(cherry picked from commit 6b5c3f9b8139d9eee358b354b35da0b757a0270d)

20 months agolibstdc++: Format Python docstrings according to PEP 357
Jonathan Wakely [Thu, 28 Sep 2023 10:06:02 +0000 (11:06 +0100)] 
libstdc++: Format Python docstrings according to PEP 357

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Format docstrings according
to PEP 257.
* python/libstdcxx/v6/xmethods.py: Likewise.

(cherry picked from commit 0ef4cc8225f8669463bca501f36b6951967a692a)

20 months agolibstdc++: Fix format string in StdChronoTimeZoneRulePrinter
Jonathan Wakely [Wed, 27 Sep 2023 16:03:51 +0000 (17:03 +0100)] 
libstdc++: Fix format string in StdChronoTimeZoneRulePrinter

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdChronoTimeZoneRulePrinter):
Fix incorrect number of replacement fields.

(cherry picked from commit 1fab05a885a308c19cf42b72fd36805ddf27fdc8)

20 months agolibstdc++: Format Python code according to PEP8
Jonathan Wakely [Mon, 11 Sep 2023 20:47:00 +0000 (21:47 +0100)] 
libstdc++: Format Python code according to PEP8

These files were filtered through autopep8 to reformat them more
conventionally.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Reformat.
* python/libstdcxx/v6/xmethods.py: Likewise.

(cherry picked from commit e08559271b2d797f658579ac8610dbf5e58bcfd8)

20 months agolibstdc++: Add pretty printer for std::locale
Jonathan Wakely [Wed, 23 Aug 2023 11:10:16 +0000 (12:10 +0100)] 
libstdc++: Add pretty printer for std::locale

Print the locale's name, except when it uses the same named C locale for
all categories except one, in which case print something like:
std::locale = "en_GB.UTF-8" with "LC_CTYPE=en_US.UTF-8"

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdLocalePrinter): New
printer class.
* testsuite/libstdc++-prettyprinters/locale.cc: New test.

(cherry picked from commit 3d2e240af7704b7c4fc15fb3c8b282556841108d)

20 months agolibstdc++: Declutter std::optional and std:variant pretty printers [PR110944]
Jonathan Wakely [Tue, 22 Aug 2023 13:26:51 +0000 (14:26 +0100)] 
libstdc++: Declutter std::optional and std:variant pretty printers [PR110944]

As the PR says, including the template arguments in the GDB output of
these class templates can result in very long names, especially for
std::variant. You can use 'whatis' or other GDB commands to get details
of the type, we don't need to include it in the value.

We could consider including the type if it's not too long, but I think
consistency is better (and we already omit the template arguments for
std::vector and other class templates).

libstdc++-v3/ChangeLog:

PR libstdc++/110944
* python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Do
not show template arguments.
(StdVariantPrinter): Likewise.
* testsuite/libstdc++-prettyprinters/compat.cc: Adjust expected
output.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.

(cherry picked from commit 701ce3c723623af13597c05df09a049c57c52fc0)

20 months agoLibF7: Use paper-pencil method for sqrt instead of Newton-Raphson iteration.
Georg-Johann Lay [Sun, 12 Nov 2023 14:55:40 +0000 (15:55 +0100)] 
LibF7: Use paper-pencil method for sqrt instead of Newton-Raphson iteration.

libgcc/config/avr/libf7/
* libf7-asm.sx (sqrt_approx): Rewrite.
* libf7.c (f7_sqrt): Use it instead of sqrt_worker.
(sqrt_worker): Remove.

20 months agotree-optimization/111917 - bougs IL after guard hoisting
Richard Biener [Mon, 23 Oct 2023 09:25:17 +0000 (11:25 +0200)] 
tree-optimization/111917 - bougs IL after guard hoisting

The unswitching code to hoist guards inserts conditions in wrong
places.  The following fixes this, simplifying code.

PR tree-optimization/111917
* tree-ssa-loop-unswitch.cc (hoist_guard): Always insert
new conditional after last stmt.

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

(cherry picked from commit d96bd4aade170fcd86f5f09b68b770dde798e631)

20 months agomiddle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile
Richard Biener [Mon, 16 Oct 2023 10:50:46 +0000 (12:50 +0200)] 
middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile

The following addresses a missed DECL_NOT_GIMPLE_REG_P setting of
a volatile declared parameter which causes inlining to substitute
a constant parameter into a context where its address is required.

The main issue is in update_address_taken which clears
DECL_NOT_GIMPLE_REG_P from the parameter but fails to rewrite it
because is_gimple_reg returns false for volatiles.  The following
changes maybe_optimize_var to make the 1:1 correspondence between
clearing DECL_NOT_GIMPLE_REG_P of a register typed decl and
actually rewriting it to SSA.

PR middle-end/111818
* tree-ssa.cc (maybe_optimize_var): When clearing
DECL_NOT_GIMPLE_REG_P always rewrite into SSA.

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

(cherry picked from commit ce55521bcd149fdc431f1d78e706b66d470210ae)

20 months agotree-optimization/111764 - wrong reduction vectorization
Richard Biener [Thu, 12 Oct 2023 07:09:46 +0000 (09:09 +0200)] 
tree-optimization/111764 - wrong reduction vectorization

The following removes a misguided attempt to allow x + x in a reduction
path, also allowing x * x which isn't valid.  x + x actually never
arrives this way but instead is canonicalized to 2 * x.  This makes
reduction path handling consistent with how we handle the single-stmt
reduction case.

PR tree-optimization/111764
* tree-vect-loop.cc (check_reduction_path): Remove the attempt
to allow x + x via special-casing of assigns.

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

(cherry picked from commit 05f98310b54da95e468d799f4a910174320cccbb)

20 months agotree-optimization/111614 - missing convert in undistribute_bitref_for_vector
Richard Biener [Thu, 28 Sep 2023 07:41:30 +0000 (09:41 +0200)] 
tree-optimization/111614 - missing convert in undistribute_bitref_for_vector

The following adjusts a flawed guard for converting the first vector
of the sum we create in undistribute_bitref_for_vector.

PR tree-optimization/111614
* tree-ssa-reassoc.cc (undistribute_bitref_for_vector): Properly
convert the first vector when required.

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

(cherry picked from commit 88d79b9b03eccf39921d13c2cbd1acc50aeda126)

20 months agotree-optimization/111583 - loop distribution issue
Richard Biener [Fri, 29 Sep 2023 09:08:18 +0000 (11:08 +0200)] 
tree-optimization/111583 - loop distribution issue

The following conservatively fixes loop distribution to only
recognize memset/memcpy and friends when at least one element
is going to be processed.  This avoids having an unconditional
builtin call in the IL that might imply the source and destination
pointers are non-NULL when originally pointers were not always
dereferenced.

With -Os loop header copying is less likely to ensure this.

PR tree-optimization/111583
* tree-loop-distribution.cc (find_single_drs): Ensure the
load/store are always executed.

* gcc.dg/tree-ssa/pr111583-1.c: New testcase.
* gcc.dg/tree-ssa/pr111583-2.c: Likewise.

(cherry picked from commit 962ca7149d652e4077a2259886e5cd2ea3cea0ab)

20 months agotree-optimization/111489 - raise --param uninit-max-chain-len to 8
Richard Biener [Wed, 20 Sep 2023 06:44:43 +0000 (08:44 +0200)] 
tree-optimization/111489 - raise --param uninit-max-chain-len to 8

This raises --param uninit-max-chain-len to avoid a bogus diagnostic
for the large testcase in PR111489.

PR tree-optimization/111489
* params.opt (-param uninit-max-chain-len=): Raise default to 8.

* gcc.dg/uninit-pr111489.c: New testcase.

(cherry picked from commit daf175e8170c18f59cc42c916005698437446272)

20 months agotree-optimization/111489 - turn uninit limits to params
Richard Biener [Wed, 20 Sep 2023 06:40:34 +0000 (08:40 +0200)] 
tree-optimization/111489 - turn uninit limits to params

The following turns MAX_NUM_CHAINS and MAX_CHAIN_LEN to params which
allows to experiment with raising them.  For the testcase in PR111489
raising MAX_CHAIN_LEN from 5 to 8 avoids the bogus diagnostics
at -O2, at -O3 we need a MAX_CHAIN_LEN of 6.

PR tree-optimization/111489
* doc/invoke.texi (--param uninit-max-chain-len): Document.
(--param uninit-max-num-chains): Likewise.
* params.opt (-param=uninit-max-chain-len=): New.
(-param=uninit-max-num-chains=): Likewise.
* gimple-predicate-analysis.cc (MAX_NUM_CHAINS): Define to
param_uninit_max_num_chains.
(MAX_CHAIN_LEN): Define to param_uninit_max_chain_len.
(uninit_analysis::init_use_preds): Avoid VLA.
(uninit_analysis::init_from_phi_def): Likewise.
(compute_control_dep_chain): Avoid using MAX_CHAIN_LEN in
template parameter.

(cherry picked from commit b8a2a12464d25c45a51c14a025e8e2d3ca8ebeb0)

20 months agotree-optimization/111445 - simple_iv simplification fault
Richard Biener [Fri, 20 Oct 2023 13:08:49 +0000 (15:08 +0200)] 
tree-optimization/111445 - simple_iv simplification fault

The following fixes a missed check in the simple_iv attempt
to simplify (signed T)((unsigned T) base + step) where it
allows a truncating inner conversion leading to wrong code.

PR tree-optimization/111445
* tree-scalar-evolution.cc (simple_iv_with_niters):
Add missing check for a sign-conversion.

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

(cherry picked from commit 9692309ed6b625f0fb358c0e230404b5603f69a6)

20 months agotree-optimization/111397 - missed copy propagation involving abnormal dest
Richard Biener [Wed, 13 Sep 2023 07:28:34 +0000 (09:28 +0200)] 
tree-optimization/111397 - missed copy propagation involving abnormal dest

The following extends the previous enhancement to copy propagation
involving abnormals.  We can easily replace abnormal uses by not
abnormal uses and only need to preserve the abnormals in PHI arguments
flowing in from abnormal edges.  This changes the may_propagate_copy
argument indicating we are not propagating into a PHI node to indicate
whether we know we are not propagating into a PHI argument from an
abnormal PHI instead.

PR tree-optimization/111397
* tree-ssa-propagate.cc (may_propagate_copy): Change optional
argument to specify whether the PHI destination doesn't flow in
from an abnormal PHI.
(propagate_value): Adjust.
* tree-ssa-forwprop.cc (pass_forwprop::execute): Indicate abnormal
PHI dest.
* tree-ssa-sccvn.cc (eliminate_dom_walker::before_dom_children):
Likewise.
(process_bb): Likewise.

* gcc.dg/uninit-pr111397.c: New testcase.

(cherry picked from commit 92ea12ea99fce546772a40b7bbc2ea850db9b1be)

20 months agomiddle-end/111253 - partly revert r11-6508-gabb1b6058c09a7
Richard Biener [Thu, 31 Aug 2023 11:53:21 +0000 (13:53 +0200)] 
middle-end/111253 - partly revert r11-6508-gabb1b6058c09a7

The following keeps dumping SSA def stmt RHS during diagnostic
reporting only for gimple_assign_single_p defs which means
memory loads.  This avoids diagnostics containing PHI nodes
like

  warning: 'realloc' called on pointer '*_42 = PHI <lcs.14_40(29), lcs.19_48(30)>.t_mem_caches' with nonzero offset 40

instead getting back the previous behavior:

  warning: 'realloc' called on pointer '*<unknown>.t_mem_caches' with nonzero offset 40

PR middle-end/111253
gcc/c-family/
* c-pretty-print.cc (c_pretty_printer::primary_expression):
Only dump gimple_assign_single_p SSA def RHS.

gcc/testsuite/
* gcc.dg/Wfree-nonheap-object-7.c: New testcase.

(cherry picked from commit e3ece7684b02c47d2b259899cf8009d6bdcccaf3)

21 months agoFix wrong code due to vec_merge + pcmp to blendvb splitter.
liuhongt [Thu, 9 Nov 2023 05:20:05 +0000 (13:20 +0800)] 
Fix wrong code due to vec_merge + pcmp to blendvb splitter.

gcc/ChangeLog:

PR target/112443
* config/i386/sse.md (*avx2_pcmp<mode>3_4): Fix swap condition
from LT to GT since there's not in the pattern.
(*avx2_pcmp<mode>3_5): Ditto.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr112443.C: New test.

(cherry picked from commit 9a0cc04b9c9b02426762892b88efc5c44ba546bd)

21 months agoDaily bump.
GCC Administrator [Fri, 10 Nov 2023 00:21:05 +0000 (00:21 +0000)] 
Daily bump.

21 months agoPR modula2/112110: fails to build on freebsd when compiling wrapclock.cc
Gaius Mulley [Thu, 9 Nov 2023 16:14:43 +0000 (16:14 +0000)] 
PR modula2/112110: fails to build on freebsd when compiling wrapclock.cc

This patch fixes a mangled #if #endif conditional section within
wrapclock.cc.  The conditional section in wrapclock_timezone should
return 0 rather than return timezone.

libgm2/ChangeLog:

PR modula2/112110
* libm2iso/wrapclock.cc (timezone): Return 0 if unable to
get the timezone from the tm struct.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
21 months agolibstdc++: Fix 29_atomics/headers/atomic/types_std_c++2a_neg.cc for C++23
Jonathan Wakely [Fri, 15 Sep 2023 20:37:46 +0000 (21:37 +0100)] 
libstdc++: Fix 29_atomics/headers/atomic/types_std_c++2a_neg.cc for C++23

This test fails when run as C++23 because the <bits/stdc++.h> PCH
includes <stdatomic.h> which declares ::memory_order, invalidating the
test's assumptions. Disable PCH so that the test verifies that <atomic>
doesn't declare ::memory_order, as originally intended.

Also fix the using-declaration which would be invalid even if the type
was declared in the global namespace, and adjust the expected error.

libstdc++-v3/ChangeLog:

* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc:
Fix test to work for C++23 and C++26 too.

(cherry picked from commit 038c0afa893f8cb2277ff44be3e2c09cfab4bc0c)

21 months agolibstdc++: Disable PCH for tests that rely on include order
Jonathan Wakely [Wed, 16 Aug 2023 20:29:46 +0000 (21:29 +0100)] 
libstdc++: Disable PCH for tests that rely on include order

These tests expect to be able to #undef a feature test macro and then
include <version> to get it redefined. But if <version> has already been
included by the <bits/stdc++.h> PCH then including it again does nothing
and the macro remains undefined.

libstdc++-v3/ChangeLog:

* testsuite/24_iterators/move_iterator/p2520r0.cc: Add no_pch.
* testsuite/std/format/functions/format.cc: Likewise.
* testsuite/std/format/functions/format_c++23.cc: Likewise.

(cherry picked from commit 51d702f3baf73aa4016b9798045d13318074ca1e)

21 months agolibstdc++: Fix std::basic_string::resize_and_overwrite
Jonathan Wakely [Tue, 15 Aug 2023 12:48:23 +0000 (13:48 +0100)] 
libstdc++: Fix std::basic_string::resize_and_overwrite

The callable used for resize_and_overwrite was being passed the string's
expanded capacity, which might be greater than the new size being
requested. This is not conforming, as the standard requires the same n
to be passed to the callable that the user passed to
resize_and_overwrite.

The existing tests didn't catch this because they all used a value which
was more than twice the existing capacity, so the _M_create call
allocated exactly what was requested, and the value passed to the
callable was correct. But when the requested size is greater than the
current capacity but smaller than twice the current capacity, _M_create
will allocate twice the current capacity and then that value was being
passed to the callable.

I noticed this because std::format(L"{}", 0.25) was producing L"0.25XX"
where the XX characters were whatever happened to be on the stack before
the call. When std::format used resize_and_overwrite to widen a string
it was copying too many characters into the destination and setting the
result's length too long. I've added a test for this case, and a new
test that doesn't hardcode -std=gnu++20 so can be used to test
std::format in C++23 and C++26 modes.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (resize_and_overwrite): Invoke
the callable with the same size as resize_and_overwrite was
called with.
* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
Check with small values for the new size.
* testsuite/std/format/functions/format.cc: Check wide
formatting of double values that produce small strings.
* testsuite/std/format/functions/format_c++23.cc: New test.

(cherry picked from commit 4a2b262597e4a6bc5732d4564673c1e19381dcfa)

21 months agolibstdc++: Fix testsuite no_pch directive
Jonathan Wakely [Wed, 16 Aug 2023 20:46:05 +0000 (21:46 +0100)] 
libstdc++: Fix testsuite no_pch directive

The { dg-add-options no_pch } directive is supposed to add a macro
definition that invalidates the PCH file, and ensures that the #include
directives in the test file are processed as written. But the proc that
adds the options actually removes all existing options, cancelling out
any previous dg-options directive.

This means that using no_pch will cause FAILs in a file that relies on
other options set by an earlier dg-options.

The no_pch directive was added for PR libstdc++/21769 where Janis
suggested adding it as return "$flags -D__GLIBCXX__=99999999" but what
was actually committed didn't include the $flags so replaced them.

Additionally, using no_pch  only prevents the precompiled version of
<bits/stdc++.h> from being included, it doesn't prevent the
non-precompiled version being included by -include bits/stdc++.h in the
test flags. Use regsub to filter that out of the options as well.

libstdc++-v3/ChangeLog:

* testsuite/lib/dg-options.exp (add_options_for_no_pch): Remove
any "-include bits/stdc++.h" from options and add the macro to
the existing options instead of replacing them.

(cherry picked from commit 91315f23ba127ea4d1a584023bae34e143f6eb8c)

21 months agolibstdc++: Fix some -Wmismatched-tags warnings
Jonathan Wakely [Tue, 8 Aug 2023 21:07:29 +0000 (22:07 +0100)] 
libstdc++: Fix some -Wmismatched-tags warnings

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (atomic): Change class-head
to struct.
* include/bits/stl_tree.h (_Rb_tree_merge_helper): Change
class-head to struct in friend declaration.
* include/std/chrono (tzdb_list::_Node): Likewise.
* include/std/future (_Task_state_base, _Task_state): Likewise.
* include/std/scoped_allocator (__inner_type_impl): Likewise.
* include/std/valarray (_BinClos, _SClos, _GClos, _IClos)
(_ValFunClos, _RefFunClos): Change class-head to struct.

(cherry picked from commit 5b46eacc4949ec62ee718b172cf8eb056ff27654)

21 months agolibstdc++: Fix some -Wunused-parameter warnings
Jonathan Wakely [Tue, 8 Aug 2023 21:01:36 +0000 (22:01 +0100)] 
libstdc++: Fix some -Wunused-parameter warnings

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h (allocate): Add [[maybe_unused]]
attribute.
* include/bits/regex_executor.tcc: Remove name of unused
parameter.
* include/bits/shared_ptr_atomic.h (atomic_is_lock_free):
Likewise.
* include/bits/stl_uninitialized.h: Likewise.
* include/bits/streambuf_iterator.h (operator==): Likewise.
* include/bits/uses_allocator.h: Likewise.
* include/c_global/cmath (isfinite, isinf, isnan): Likewise.
* include/std/chrono (zoned_time): Likewise.
* include/std/future (__future_base::_S_allocate_result):
Likewise.
(packaged_task): Likewise.
* include/std/optional (_Optional_payload_base): Likewise.
* include/std/scoped_allocator (__inner_type_impl): Likewise.
* include/std/tuple (_Tuple_impl): Likewise.

(cherry picked from commit af89c7792d722b7c7c2568bd4dfd9c2b34eeb4f9)

21 months agolibstdc++: Fix -Wunused-parameter warnings
Pekka Seppänen [Thu, 7 Sep 2023 19:30:00 +0000 (22:30 +0300)] 
libstdc++: Fix -Wunused-parameter warnings

Fix -Wunused-parameter warnings when _GLIBCXX_USE_WCHAR_T is not
defined.

libstdc++-v3/ChangeLog:

* src/c++11/cow-locale_init.cc: Add [[maybe_unused]] attribute.
* src/c++17/fs_path.cc (path::_S_convert_loc): Likewise.
* src/filesystem/path.cc (path::_S_convert_loc): Likewise.

Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
(cherry picked from commit 390fa3a78c84d97783afda9278df70d4a4ac2471)

21 months agolibstdc++: Fix unconditional -Werror in libbacktrace directory
Alexey Lapshin [Fri, 8 Sep 2023 10:23:16 +0000 (11:23 +0100)] 
libstdc++: Fix unconditional -Werror in libbacktrace directory

The -Werror flag should depend on the --enable-werror configure option.

libstdc++-v3/ChangeLog:

* src/libbacktrace/Makefile.am: Remove -Werror.
* src/libbacktrace/Makefile.in: Regenerate.

(cherry picked from commit 1a0c6decd2112267c88438466df2e1c46b20248e)

21 months agolibstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests
Jonathan Wakely [Wed, 6 Sep 2023 23:21:37 +0000 (00:21 +0100)] 
libstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests

These tests do not run by default, because the c++20 effective target
selector isn't matched.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/unordered_map/operations/1.cc: Add
dg-options for C++20 mode.
* testsuite/23_containers/unordered_multimap/operations/1.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/operations/1.cc:
Likewise.
* testsuite/23_containers/unordered_set/operations/1.cc:
Likewise.

(cherry picked from commit b1ca841b8972e546570553df3e61326c86135404)

21 months agolibstdc++: Explicitly default some copy ctors and assignments
Jonathan Wakely [Tue, 8 Aug 2023 15:24:31 +0000 (16:24 +0100)] 
libstdc++: Explicitly default some copy ctors and assignments

The standard says that the implicit copy assignment operator is
deprecated for classes that have a user-provided copy constructor, and
vice versa.

libstdc++-v3/ChangeLog:

* include/bits/new_allocator.h (__new_allocator): Define copy
assignment operator as defaulted.
* include/std/complex (complex<float>, complex<double>)
(complex<long double>): Define copy constructor as defaulted.

(cherry picked from commit 008e439f34d4b356825a6c9b70245143f00bd353)

21 months agolibstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd
Jonathan Wakely [Thu, 7 Sep 2023 16:03:40 +0000 (17:03 +0100)] 
libstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd

The filesystem code was using these functions without checking for their
existence, assuming that any UNIX-like libc with <unistd.h> would always
provide them. That's not true for some newlib targets like arm-eabi.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for mkdir,
chmod, chdir, and getcwd.
* config.h.in: Regenerate.
* configure: Regenerate.
* src/c++17/fs_ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.
* src/filesystem/ops-common.h [FILESYSTEM_IS_WINDOWS]
(chmod, mkdir, getcwd, chdir): Define new macros.
[FILESYSTEM_IS_WINDOWS] (chmod, mkdir, getcwd, chdir): Use
new macros.
* src/filesystem/ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.

(cherry picked from commit 5435449be0eb9ca41824eb16f774db3ccc2a593b)

21 months agolibstdc++: Remove non-void static assertions in variant's std::get [PR111172]
Jonathan Wakely [Tue, 12 Sep 2023 20:28:38 +0000 (21:28 +0100)] 
libstdc++: Remove non-void static assertions in variant's std::get [PR111172]

A void template argument would cause a substitution failure when trying
to form a reference for the return type, so the function body would
never be instantiated.

libstdc++-v3/ChangeLog:

PR libstdc++/111172
* include/std/variant (get<T>): Remove !is_void static
assertions.

(cherry picked from commit d19bdf8874059457fdfe50a9e14dad8f8b8cecbb)

21 months agolibstdc++: Remove unconditional use of atomics in Debug Mode
Jonathan Wakely [Mon, 11 Sep 2023 15:42:54 +0000 (16:42 +0100)] 
libstdc++: Remove unconditional use of atomics in Debug Mode

The fix for PR 91910 (r10-3426-gf7a3a382279585) introduced unconditional
uses of atomics into src/c++11/debug.cc, which causes linker errors for
arm4t where GCC emits an unresolved reference to __sync_synchronize.

By making the uses of atomics depend on _GLIBCXX_HAS_GTHREADS we can
avoid those unconditional references to __sync_synchronize for targets
where the atomics are unnecessary. As a minor performance optimization
we can also check the __gnu_cxx::__is_single_threaded function to avoid
atomics for single-threaded programs even where they don't cause linker
errors.

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc (acquire_sequence_ptr_for_lock): New
function.
(reset_sequence_ptr): New function.
(_Safe_iterator_base::_M_detach)
(_Safe_local_iterator_base::_M_detach): Replace bare atomic_load
with acquire_sequence_ptr_for_lock.
(_Safe_iterator_base::_M_reset): Replace bare atomic_store with
reset_sequence_ptr.

(cherry picked from commit 4a2766ed00a47904dc8b85bf0538aa116d8e658b)

21 months agolibstdc++: Move __glibcxx_assert_fail to its own file
Jonathan Wakely [Mon, 11 Sep 2023 14:58:48 +0000 (15:58 +0100)] 
libstdc++: Move __glibcxx_assert_fail to its own file

This avoids a dependency on the other symbols in src/c++11/debug.o when
linking statically to libstdc++.a without using -Wl,--gc-sections.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add new file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/debug.cc (__glibcxx_assert_fail): Move to ...
* src/c++11/assert_fail.cc: New file.

(cherry picked from commit c7db9000fa7caceadb4e72dcc6226abebf7a6239)

21 months agoDaily bump.
GCC Administrator [Thu, 9 Nov 2023 00:20:49 +0000 (00:20 +0000)] 
Daily bump.

21 months agoLibF7: Tweak IEEE double multiplication.
Georg-Johann Lay [Wed, 8 Nov 2023 11:43:49 +0000 (12:43 +0100)] 
LibF7: Tweak IEEE double multiplication.

libgcc/config/avr/libf7/
* libf7-asm.sx (mul_mant) [AVR_HAVE_MUL]: Tweak code.

21 months agolibstdc++: Improve static assert messages for monadic operations
Jonathan Wakely [Wed, 1 Nov 2023 14:28:55 +0000 (14:28 +0000)] 
libstdc++: Improve static assert messages for monadic operations

The monadic operations for std::optional and std::expected make use of
internal helper traits __is_optional nad __is_expected, which are not
very user-friendly when shown in diagnostics. Add messages to the
assertions explaining the problem more clearly.

libstdc++-v3/ChangeLog:

* include/std/expected (expected::and_then, expected::or_else):
Add string literals to static assertions.
* include/std/optional (optional::and_then, optional::or_else):
Likewise.

(cherry picked from commit 3d654f96d4c583c35e4f73aa8f11371730671534)

21 months agolibstdc++: Remove redundant partial specialization in _Nth_type
Feng Jisen [Fri, 3 Nov 2023 16:33:44 +0000 (16:33 +0000)] 
libstdc++: Remove redundant partial specialization in _Nth_type

libstdc++-v3/ChangeLog:

* include/bits/utility.h (_Nth_type): Remove redundant partial
specialization.

(cherry picked from commit ada871cfadd3f4960b4435f6f7f07a5aca1887d3)

21 months agolibstdc++: Add assertion to std::string_view::remove_suffix [PR112314]
Jonathan Wakely [Wed, 1 Nov 2023 15:01:22 +0000 (15:01 +0000)] 
libstdc++: Add assertion to std::string_view::remove_suffix [PR112314]

libstdc++-v3/ChangeLog:

PR libstdc++/112314
* include/std/string_view (string_view::remove_suffix): Add
debug assertion.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc:
New test.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc:
New test.

(cherry picked from commit 6afa984f47e16e8bd958646d7407b74e61041f5d)

21 months agolibstdc++: Fix warning during configure
Jonathan Wakely [Wed, 1 Nov 2023 14:20:33 +0000 (14:20 +0000)] 
libstdc++: Fix warning during configure

The checks for snprintf give a -Wformat warning due to a missing
argument.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_C99): Fix snprintf checks.
* configure: Regenerate.

(cherry picked from commit 8a4cde6319b40802a842a8fe71267524dd8af828)

21 months agolibstdc++: Fix exception thrown by std::shared_lock::unlock() [PR112089]
Jonathan Wakely [Thu, 26 Oct 2023 15:51:30 +0000 (16:51 +0100)] 
libstdc++: Fix exception thrown by std::shared_lock::unlock() [PR112089]

The incorrect errc constant here looks like a copy&paste error.

libstdc++-v3/ChangeLog:

PR libstdc++/112089
* include/std/shared_mutex (shared_lock::unlock): Change errc
constant to operation_not_permitted.
* testsuite/30_threads/shared_lock/locking/112089.cc: New test.

(cherry picked from commit 0c305f3dec9a992dd775a3b9607b7b1e8c051859)

21 months agolibstdc++: Add dg-timeout-factor to <chrono> IO tests
Jonathan Wakely [Tue, 24 Oct 2023 20:50:17 +0000 (21:50 +0100)] 
libstdc++: Add dg-timeout-factor to <chrono> IO tests

This avoids failures due to compilation timeouts when testing with a low
tool_timeout value.

libstdc++-v3/ChangeLog:

* testsuite/20_util/duration/io.cc: Double timeout using
dg-timeout-factor.
* testsuite/std/time/day/io.cc: Likewise.
* testsuite/std/time/format.cc: Likewise.
* testsuite/std/time/hh_mm_ss/io.cc: Likewise.
* testsuite/std/time/month/io.cc: Likewise.
* testsuite/std/time/month_day/io.cc: Likewise.
* testsuite/std/time/month_day_last/io.cc: Likewise.
* testsuite/std/time/month_weekday/io.cc: Likewise.
* testsuite/std/time/month_weekday_last/io.cc: Likewise.
* testsuite/std/time/weekday/io.cc: Likewise.
* testsuite/std/time/weekday_indexed/io.cc: Likewise.
* testsuite/std/time/weekday_last/io.cc: Likewise.
* testsuite/std/time/year/io.cc: Likewise.
* testsuite/std/time/year_month/io.cc: Likewise.
* testsuite/std/time/year_month_day/io.cc: Likewise.
* testsuite/std/time/year_month_day_last/io.cc: Likewise.
* testsuite/std/time/year_month_weekday/io.cc: Likewise.
* testsuite/std/time/year_month_weekday_last/io.cc: Likewise.
* testsuite/std/time/zoned_time/io.cc: Likewise.

(cherry picked from commit 7d06b29f8145805f33a33fb54a7d69acf31cecd6)

21 months agolibstdc++: Split std::basic_string::_M_use_local_data into two functions
Jonathan Wakely [Fri, 29 Sep 2023 11:12:22 +0000 (12:12 +0100)] 
libstdc++: Split std::basic_string::_M_use_local_data into two functions

This splits out the activate-the-union-member-for-constexpr logic from
_M_use_local_data, so that it can be used separately in cases that don't
need to use std::pointer_traits<pointer>::pointer_to to obtain the
return value.

This leaves only three uses of _M_use_local_data() which are all of the
same form:

  __s._M_data(_M_use_local_data());
  __s._M_set_length(0);

We could remove _M_use_local_data() and change those three places to use
a new _M_reset() function that does:

  _M_init_local_buf();
  _M_data(_M_local_data());
  _M_set_length(0);

This is left for a future change.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (_M_init_local_buf()): New
function.
(_M_use_local_data()): Use _M_init_local_buf.
(basic_string(), basic_string(const Alloc&))
(basic_string(basic_string&&))
(basic_string(basic_string&&, const Alloc&)): Use
_M_init_local_buf instead of _M_use_local_data().
* include/bits/basic_string.tcc (swap(basic_string&))
(_M_construct(InIter, InIter, input_iterator_tag))
(_M_construct(InIter, InIter, forward_iterator_tag))
(_M_construct(size_type, CharT), reserve()): Likewise.

(cherry picked from commit 405a4140fc30bce86b1ec885a98bb17704e0c8c6)

21 months agoDaily bump.
GCC Administrator [Wed, 8 Nov 2023 00:21:03 +0000 (00:21 +0000)] 
Daily bump.

21 months agolibphobos: Fix regression d21 loops in getCpuInfo0B in Solaris/x86 kernel zone
Iain Buclaw [Tue, 7 Nov 2023 13:04:07 +0000 (14:04 +0100)] 
libphobos: Fix regression d21 loops in getCpuInfo0B in Solaris/x86 kernel zone

This function assumes that cpuid would return "invalid domain" when a
sub-leaf index greater than what's supported is requested.  This turned
out not to always be the case when running on some virtual machines.

As the loop only does anything for levels 0 and 1, make that a hard
limit for number of times the loop is ran.

    PR d/112408

libphobos/ChangeLog:

* libdruntime/core/cpuid.d (getCpuInfo0B): Limit number of times loop
runs.

21 months agoDaily bump.
GCC Administrator [Tue, 7 Nov 2023 00:20:51 +0000 (00:20 +0000)] 
Daily bump.

21 months agolibstdc++: use -D_GNU_SOURCE when building libbacktrace
Ian Lance Taylor [Mon, 6 Nov 2023 23:12:05 +0000 (15:12 -0800)] 
libstdc++: use -D_GNU_SOURCE when building libbacktrace

PR libbacktrace/111315
PR libbacktrace/112263
* acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when
grepping link.h for dl_iterate_phdr.
* configure: Regenerate.

21 months agohppa: Fix typo in PA 2.0 trampoline template
John David Anglin [Mon, 6 Nov 2023 20:45:13 +0000 (20:45 +0000)] 
hppa: Fix typo in PA 2.0 trampoline template

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

* config/pa/pa.cc (pa_asm_trampoline_template): Fix typo.

21 months agoDaily bump.
GCC Administrator [Mon, 6 Nov 2023 00:24:16 +0000 (00:24 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Sun, 5 Nov 2023 02:50:05 +0000 (02:50 +0000)] 
Daily bump.

21 months agoFortran: fix issue with multiple references of a procedure pointer [PR97245]
Harald Anlauf [Fri, 3 Nov 2023 18:41:54 +0000 (19:41 +0100)] 
Fortran: fix issue with multiple references of a procedure pointer [PR97245]

gcc/fortran/ChangeLog:

PR fortran/97245
* match.cc (gfc_match_call): If a procedure pointer has already been
resolved, do not create a new symbol in a procedure reference of
the same name shadowing the first one if it is host-associated.

gcc/testsuite/ChangeLog:

PR fortran/97245
* gfortran.dg/proc_ptr_53.f90: New test.

(cherry picked from commit 5340f48b7639fcc874f64aac214f9ef9ae43d43e)

21 months agoDaily bump.
GCC Administrator [Sat, 4 Nov 2023 01:34:33 +0000 (01:34 +0000)] 
Daily bump.

21 months agoFortran: Fix for regression in ASSOCIATE [PR112316]
Paul Thomas [Thu, 2 Nov 2023 22:23:05 +0000 (22:23 +0000)] 
Fortran: Fix for regression in ASSOCIATE [PR112316]

2023-11-02  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/112316
* parse.cc (parse_associate): Remove condition that caused this
regression.

gcc/testsuite/
PR fortran/112316
* gfortran.dg/pr112316.f90: New test.

(cherry picked from commit 7c1d011bc1f8b26dba4ebcbd4a429628dfb2698d)

21 months agoDaily bump.
GCC Administrator [Fri, 3 Nov 2023 00:21:12 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Thu, 2 Nov 2023 00:21:20 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Wed, 1 Nov 2023 00:22:10 +0000 (00:22 +0000)] 
Daily bump.

21 months agoRISC-V: Fix ICE of RVV vget/vset intrinsic[PR111935]
xuli [Tue, 24 Oct 2023 07:39:02 +0000 (07:39 +0000)] 
RISC-V: Fix ICE of RVV vget/vset intrinsic[PR111935]

Calling vget/vset intrinsic without receiving a return value will cause
a crash. Because in this case e.target is null.
This patch should be backported to releases/gcc-13.

PR target/111935

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-bases.cc: fix bug.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr111935.c: New test.

(cherry picked from commit b44d4ff7b43ff6a34d5c074c7ade03c4a38974fa)

21 months agoDaily bump.
GCC Administrator [Tue, 31 Oct 2023 00:21:12 +0000 (00:21 +0000)] 
Daily bump.