GCC Administrator [Mon, 2 Jan 2023 00:16:34 +0000 (00:16 +0000)]
Daily bump.
Roger Sayle [Sun, 1 Jan 2023 17:00:28 +0000 (17:00 +0000)]
Add post-reload splitter for extendditi2 on x86_64.
This is another step towards a possible solution for PR 105137.
This patch introduces a define_insn for extendditi2 that allows
DImode to TImode sign-extension to be represented in the early
RTL optimizers, before being split post-reload into the exact
same idiom as currently produced by RTL expansion.
Typically this produces the identical code, so the first new
test case:
__int128 foo(long long x) { return (__int128)x; }
continues to generate:
foo: movq %rdi, %rax
cqto
ret
The "magic" is that this representation allows combine and the
other RTL optimizers to do a better job. Hence, the second
test case:
__int128 foo(__int128 a, long long b) {
a += ((__int128)b) << 70;
return a;
}
which mainline with -O2 currently generates as:
foo: movq %rsi, %rax
movq %rdx, %rcx
movq %rdi, %rsi
salq $6, %rcx
movq %rax, %rdi
xorl %eax, %eax
movq %rcx, %rdx
addq %rsi, %rax
adcq %rdi, %rdx
ret
with this patch now becomes:
foo: movl $0, %eax
salq $6, %rdx
addq %rdi, %rax
adcq %rsi, %rdx
ret
i.e. the same code for the signed and unsigned extension variants.
2023-01-01 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
* config/i386/i386.md (extendditi2): New define_insn.
(define_split): Use DWIH mode iterator to treat new extendditi2
identically to existing extendsidi2_1.
(define_peephole2): Likewise.
(define_peephole2): Likewise.
(define_Split): Likewise.
gcc/testsuite/ChangeLog
* gcc.target/i386/extendditi2-1.c: New test case.
* gcc.target/i386/extendditi2-2.c: Likewise.
Jakub Jelinek [Sun, 1 Jan 2023 15:20:13 +0000 (16:20 +0100)]
Rotate ChangeLog files.
Rotate ChangeLog files for ChangeLogs with yearly cadence.
Iain Sandoe [Wed, 21 Dec 2022 09:05:32 +0000 (09:05 +0000)]
modula2: Ensure that module registration constructors are 'extern' [PR108183].
The symbols for module registration constructors need to be external
or we get wrong code generated for targets that allow direct access to
local symbol definitions.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR modula2/108183
gcc/m2/ChangeLog:
* gm2-compiler/M2GCCDeclare.mod: Module registration constructors are
externs to the builder of m2_link.
Co-Authored-By: Gaius Mulley <gaiusmod2@gmail.com>
GCC Administrator [Sun, 1 Jan 2023 00:17:17 +0000 (00:17 +0000)]
Daily bump.
Iain Sandoe [Fri, 30 Dec 2022 12:03:08 +0000 (12:03 +0000)]
configure: Do not build the ununsed libffi shared library.
We do not use the shared libffi libraray, nor do we install it.
However, on at least Darwin, the shared version will be picked
up for testing, so it is preferrable not to build it.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:
* Makefile.def: Do not build shared libffi.
* Makefile.in: Regenerate.
Iain Sandoe [Sat, 17 Dec 2022 14:48:03 +0000 (14:48 +0000)]
modula-2,libgm2: Add undefined, dynamic_lookup to m2 libs links.
The libm2 libraries are cross-linked, which means that we need to allow
symbols to be undefined at link time and then to be found at runtime.
This is implemented on Darwin by adding -undefined, dynamic_lookup to
the link command.
NOTE: It would probably be a better solution to rework the libraries
either to combine those that have inter-dependencies, or to reorder
the layering so the there is a fixed dependency tree.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgm2/ChangeLog:
* configure: Regenerate.
* configure.ac: Make a conditional for configurations targeting
Darwin.
* libm2cor/Makefile.am: Use -undefined,dynamic_lookup on Darwin.
* libm2iso/Makefile.am: Likewise.
* libm2log/Makefile.am: Likewise.
* libm2pim/Makefile.am: Likewise
* libm2min/Makefile.am: Likewise
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.
Rainer Orth [Thu, 15 Dec 2022 10:43:37 +0000 (10:43 +0000)]
modula-2: Fix building the plugin for Darwin [PR107612].
* Makes the configured value for INCINTL available as a variable so that
it can be used in language makefile fragements. It is then used in the m2
fragment to make the include path available to the plugin compile.
* Updates the DSO suffix to use .dylib for Darwin.
* Adds '-Wl,-undefined,dynamic_lookup' to the link flags so that symbols can
be resolved at runtime.
* Removes the extraneous $(exeext) from the DSO names.
Since the linking is driven by CXX, we also need to supress the addition of
default libraries otherwise:
(1) we will get a reference to an uninstalled libstdc++
(2) the process opening the plugin would have two instances 0f libstdc++ -
one statically linked into gm2 and one dynamically linked into the plugin.
PR modula2/107612
gcc/ChangeLog:
* Makefile.in: Make the configured libintl includes avaiable in INCINTL.
(BUILD_CPPFLAGS): Use INCINTL.
gcc/m2/ChangeLog:
* Make-lang.in (soext): Use .dylib for Darwin.
(PLUGINLDFLAGS): Use dynmic lookup, set the plugin name, and append
-nodefaultlibs to suppress the linking of libstdc++.
Use INCINTL in compile lines for the plugin.
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
GCC Administrator [Sat, 31 Dec 2022 00:17:04 +0000 (00:17 +0000)]
Daily bump.
Alexandre Oliva [Fri, 30 Dec 2022 16:44:50 +0000 (13:44 -0300)]
check hash table insertions
I've noticed a number of potential problems in hash tables, of three
kinds: insertion of entries that seem empty, dangling insertions, and
lookups during insertions.
These problems may all have the effect of replacing a deleted entry
with one that seems empty, which may disconnect double-hashing chains
involving that entry, and thus cause entries to go missing.
This patch detects such problems by recording a pending insertion and
checking that it's completed before other potentially-conflicting
operations. The additional field is only introduced when checking is
enabled.
for gcc/ChnageLog
* hash-table.h (check_complete_insertion, check_insert_slot):
New hash_table methods.
(m_inserting_slot): New hash_table field.
(begin, hash_table ctors, ~hash_table): Check previous insert.
(expand, empty_slow, clear_slot, find_with_hash): Likewise.
(remote_elt_with_hash, traverse_noresize): Likewise.
(gt_pch_nx): Likewise.
(find_slot_with_hash): Likewise. Record requested insert.
Martin Uecker [Fri, 30 Dec 2022 13:51:37 +0000 (14:51 +0100)]
regressions tests for PR103770
This adds tests from bugzilla for PR103770 and duplicates.
gcc/testsuite/
* gcc.dg/pr103770.c: New test.
* gcc.dg/pr103859.c: New test.
* gcc.dg/pr105065.c: New test.
Stam Markianos-Wright [Fri, 30 Dec 2022 11:25:22 +0000 (11:25 +0000)]
Fix memory constraint on MVE v[ld/st][2/4] instructions [PR107714]
In the M-Class Arm-ARM:
https://developer.arm.com/documentation/ddi0553/bu/?lang=en
these MVE instructions only have '!' writeback variant and at:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107714
we found that the Um constraint would also allow through a
register offset writeback, resulting in an assembler error.
Here I have added a new constraint and predicate for these
instructions, which (uniquely, AFAICT), only support a `!` writeback
increment by the data size (inside the compiler this is a POST_INC).
No regressions in arm-none-eabi with MVE and MVE.FP.
gcc/ChangeLog:
PR target/107714
* config/arm/arm-protos.h (mve_struct_mem_operand): New protoype.
* config/arm/arm.cc (mve_struct_mem_operand): New function.
* config/arm/constraints.md (Ug): New constraint.
* config/arm/mve.md (mve_vst4q<mode>): Change constraint.
(mve_vst2q<mode>): Likewise.
(mve_vld4q<mode>): Likewise.
(mve_vld2q<mode>): Likewise.
* config/arm/predicates.md (mve_struct_operand): New predicate.
gcc/testsuite/ChangeLog:
PR target/107714
* gcc.target/arm/mve/intrinsics/vldst24q_reg_offset.c: New test.
Steve Kargl [Mon, 26 Dec 2022 22:07:04 +0000 (14:07 -0800)]
Modify checks to avoid referencing NULL pointer.
Update test cases with error messages that changed as a result.
gcc/fortran/ChangeLog:
PR fortran/102595
* decl.cc (attr_decl1): Guard against NULL pointer.
* parse.cc (match_deferred_characteristics): Include BT_CLASS in check for
derived being undefined.
gcc/testsuite/ChangeLog:
PR fortran/102595
* gfortran.dg/class_result_4.f90: Update error message check.
* gfortran.dg/pr85779_3.f90: Update error message check.
GCC Administrator [Fri, 30 Dec 2022 00:16:36 +0000 (00:16 +0000)]
Daily bump.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:07 +0000 (14:33 -0300)]
prevent hash set/map insertion of deleted entries
Just like the recently-added checks for empty entries, add checks for
deleted entries as well. This didn't catch any problems, but it might
prevent future accidents. Suggested by David Malcolm.
for gcc/ChangeLog
* hash-map.h (put, get_or_insert): Check that added entry
doesn't look deleted either.
* hash-set.h (add): Likewise.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:06 +0000 (14:33 -0300)]
parloops: don't request insert that won't be completed
In take_address_of, we may refrain from completing a decl_address
INSERT if gsi is NULL, so dnn't even ask for an INSERT in this case.
for gcc/ChangeLog
* tree-parloops.cc (take_address_of): Skip INSERT if !gsi.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:04 +0000 (14:33 -0300)]
hash-map: reject empty-looking insertions
Check, after inserting entries, that they don't look empty.
for gcc/ChangeLog
* hash-map.h (put, get_or_insert): Check that entry does not
look empty after insertion.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:03 +0000 (14:33 -0300)]
hash set: reject attempts to add empty values
Check, after adding a key to a hash set, that the entry does not look
empty.
for gcc/ChangeLog
* hash-set.h (add): Check that the inserted entry does not
look empty.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:02 +0000 (14:33 -0300)]
ada: don't map NULL decl to locus
When decl is NULL, don't record its mapping in the
decl_to_instance_map.
for gcc/ada/ChangeLog
* gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl.
Alexandre Oliva [Thu, 29 Dec 2022 17:33:00 +0000 (14:33 -0300)]
lto: drop dummy partition mapping
When adding a catch-all partition, we map NULL to it. That mapping is
ineffective and unnecessary. Drop it.
for gcc/lto/ChangeLog
* lto-partition.cc (lto_1_to_1_map): Drop NULL partition
mapping.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:59 +0000 (14:32 -0300)]
[C++] constexpr: request insert iff depth is ok
cxx_eval_call_expression requests an INSERT even in cases when it
would later decide not to insert. This could break double-hashing
chains. Arrange for it to use NO_INSERT when the insertion would not
be completed.
for gcc/cp/ChangeLog
* constexpr.cc (cxx_eval_call_expression): Do not request an
INSERT that would not be completed.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:57 +0000 (14:32 -0300)]
tm: complete tm_restart insertion
Insertion of a tm_restart_node in tm_restart failed to record the
newly-allocated node in the hash table.
for gcc/ChangeLog
* trans-mem.cc (split_bb_make_tm_edge): Record new node in
tm_restart.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:56 +0000 (14:32 -0300)]
postreload-gcse: no insert on mere lookup
lookup_expr_in_table is not used for insertions, but it mistakenly
used INSERT rather than NO_INSERT.
for gcc/ChangeLog
* postreload-gcse.cc (lookup_expr_in_table): Use NO_INSERT.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:54 +0000 (14:32 -0300)]
tree-inline decl_map: skip mapping result's NULL default def
If a result doesn't have a default def, don't attempt to remap it.
for gcc/ChangeLog
* tree-inline.cc (declare_return_variable): Don't remap NULL
default def of result.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:53 +0000 (14:32 -0300)]
ssa-loop-niter: skip caching of null operands
When a TREE_OPERAND is NULL, do not cache it.
for gcc/ChangeLog
* tree-ssa-loop-niter.cc (expand_simple_operands): Refrain
from caching NULL TREE_OPERANDs.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:51 +0000 (14:32 -0300)]
[C++] constraint: insert norm entry once
Use NO_INSERT to test whether inserting should be attempted.
for gcc/cp/ChangeLog
* constraint.cc (normalize_concept_check): Use NO_INSERT for
pre-insertion check.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:49 +0000 (14:32 -0300)]
tree-inline decl_map: skip mapping NULL to itself
Mapping a NULL key is no use, skip it.
for gcc/ChangeLog
* tree-inline.cc (insert_decl_map): Skip mapping a NULL decl
as value to itself.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:48 +0000 (14:32 -0300)]
varpool: do not add NULL vnodes to referenced
Avoid adding NULL vnodes to referenced tables.
for gcc/ChangeLog
* varpool.cc (symbol_table::remove_unreferenced_decls): Do not
add NULL vnodes to referenced table.
Alexandre Oliva [Thu, 29 Dec 2022 17:32:46 +0000 (14:32 -0300)]
scoped tables: insert before further lookups
Avoid hash table lookups between requesting an insert and storing the
inserted value in avail_exprs_stack. Lookups before the insert is
completed could fail to find double-hashed elements.
for gcc/ChangeLog
* tree-ssa-scopedtables.cc
(avail_exprs_stack::lookup_avail_expr): Finish hash table
insertion before further lookups.
Max Filippov [Wed, 28 Dec 2022 19:27:21 +0000 (11:27 -0800)]
gcc: xtensa: use GP_RETURN_* instead of magic constant
gcc/
* config/xtensa/xtensa.cc (xtensa_return_in_memory): Use
GP_RETURN_* instead of magic constant.
Takayuki 'January June' Suwa [Thu, 29 Dec 2022 12:14:33 +0000 (21:14 +0900)]
xtensa: Check DF availability before use
Perhaps no problem, but for safety.
gcc/ChangeLog:
* config/xtensa/xtensa.cc (xtensa_expand_prologue): Fix to check
DF availability before use of DF_* macros.
GCC Administrator [Thu, 29 Dec 2022 00:17:39 +0000 (00:17 +0000)]
Daily bump.
Roger Sayle [Wed, 28 Dec 2022 19:30:17 +0000 (19:30 +0000)]
Provide zero_extend versions/variants of several patterns on x86.
The middle-end doesn't have a preferred canonical form for expressing
zero-extension, sometimes using an AND, sometimes pairs of SHIFTs,
and sometimes using zero_extend. Pending changes to RTL simplification
will/may alter some of these representations, so a few additional
patterns are required to recognize these alternate representations
and avoid any testsuite regressions.
As an example, *popcountsi2_zext is currently represented as:
[(set (match_operand:DI 0 "register_operand" "=r")
(and:DI
(subreg:DI
(popcount:SI
(match_operand:SI 1 "nonimmediate_operand" "rm")) 0)
(const_int 63)))
(clobber (reg:CC FLAGS_REG))]
this patch adds an alternate/equivalent pattern that matches:
[(set (match_operand:DI 0 "register_operand" "=r")
(zero_extend:DI
(popcount:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))))
(clobber (reg:CC FLAGS_REG))]
Another example is *popcounthi2 which is currently represented as:
[(set (match_operand:SI 0 "register_operand")
(popcount:SI
(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand"))))
(clobber (reg:CC FLAGS_REG))]
this patch adds an alternate/equivalent pattern that matches:
[(set (match_operand:SI 0 "register_operand")
(zero_extend:SI
(popcount:HI (match_operand:HI 1 "nonimmediate_operand"))))
(clobber (reg:CC FLAGS_REG))]
The contents of the machine description definitions remain the same.
it's just the expected RTL is slightly different but equivalent.
Providing both forms makes the backend more robust to middle-end
changes [and possibly catches some missed optimizations].
2022-12-28 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386.md (*clzsi2_lzcnt_zext_2): define_insn_and_split
to match ZERO_EXTEND form of *clzsi2_lzcnt_zext.
(*clzsi2_lzcnt_zext_2_falsedep): Likewise, new define_insn to match
ZERO_EXTEND form of *clzsi2_lzcnt_zext_falsedep.
(*bmi2_bzhi_zero_extendsidi_5): Likewise, new define_insn to match
ZERO_EXTEND form of *bmi2_bzhi_zero_extendsidi.
(*popcountsi2_zext_2): Likewise, new define_insn_and_split to match
ZERO_EXTEND form of *popcountsi2_zext.
(*popcountsi2_zext_2_falsedep): Likewise, new define_insn to match
ZERO_EXTEND form of *popcountsi2_zext_falsedep.
(*popcounthi2_2): Likewise, new define_insn_and_split to match
ZERO_EXTEND form of *popcounthi2.
(define_peephole2): ZERO_EXTEND variant of HImode popcount&1 using
parity flag peephole2.
Roger Sayle [Wed, 28 Dec 2022 19:27:52 +0000 (19:27 +0000)]
Use ix86_expand_clear in ix86_split_ashl.
This patch is a one line change, to call ix86_expand_clear instead of
emit_move_insn with const0_rtx in ix86_split_ashl, allowing the backend
to use an xor instruction to clear a register if appropriate.
The effect is demonstrated with the following function.
__int128 foo(__int128 x, unsigned long long b) {
return ((__int128)b << 72) + x;
}
previously with -O2, GCC would generate
foo: movl $0, %eax
salq $8, %rdx
addq %rdi, %rax
adcq %rsi, %rdx
ret
with this patch, it now generates
foo: xorl %eax, %eax
salq $8, %rdx
addq %rdi, %rax
adcq %rsi, %rdx
ret
2022-12-28 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_split_ashl): Call
ix86_expand_clear to generate an xor instruction.
gcc/testsuite/ChangeLog
* gcc.target/i386/ashlti3-1.c: New test case.
Martin Liska [Wed, 14 Dec 2022 12:51:03 +0000 (13:51 +0100)]
contrib: add contrib to update-copyright.py script
contrib/ChangeLog:
* update-copyright.py: Add contrib folder.
Martin Liska [Fri, 23 Dec 2022 14:27:32 +0000 (15:27 +0100)]
strlen: do not use cond_expr for boundaries
PR tree-optimization/108137
gcc/ChangeLog:
* tree-ssa-strlen.cc (get_range_strlen_phi): Reject anything
different from INTEGER_CST.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr108137.c: New test.
Kito Cheng [Tue, 27 Dec 2022 15:18:26 +0000 (23:18 +0800)]
RISC-V: Return const ref. for vl_vtype_info::get_avl_info
Return const reference could prevent unnecessary copying.
gcc/
* config/riscv/riscv-vsetvl.h (vl_vtype_info::get_avl_info):
Return const reference rather than value.
GCC Administrator [Wed, 28 Dec 2022 00:17:27 +0000 (00:17 +0000)]
Daily bump.
Jeff Law [Tue, 27 Dec 2022 23:57:09 +0000 (16:57 -0700)]
Commit right version of last patch (missing modes)
gcc/
* config/riscv/riscv.md: Add missing modes to last patch.t
Raphael Moreira Zinsly [Tue, 27 Dec 2022 23:29:25 +0000 (18:29 -0500)]
RISC-V: Produce better code with complex constants [PR95632] [PR106602]
gcc/Changelog:
PR target/95632
PR target/106602
* config/riscv/riscv.md: New pattern to simulate complex
const_int loads.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr95632.c: New test.
* gcc.target/riscv/pr106602.c: New test.
Christoph Müllner [Mon, 5 Dec 2022 03:26:03 +0000 (04:26 +0100)]
riscv: Restructure callee-saved register save/restore code
This patch restructures the loop over the GP registers
which saves/restores then as part of the prologue/epilogue.
No functional change is intended by this patch, but it
offers the possibility to use load-pair/store-pair instructions.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_next_saved_reg): New function.
(riscv_is_eh_return_data_register): New function.
(riscv_for_each_saved_reg): Restructure loop.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Christoph Müllner [Mon, 5 Dec 2022 13:03:36 +0000 (14:03 +0100)]
riscv: attr: Synchronize comments with code
The comment above the enumeration of existing attributes got out of
order and a few entries were forgotten.
This patch synchronizes the comments according to the list.
This commit does not include any functional change.
gcc/ChangeLog:
* config/riscv/riscv.md: Sync comments with code.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
jinma [Tue, 27 Dec 2022 17:30:46 +0000 (10:30 -0700)]
Fixed typo in RISCV
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc:
Jonathan Yong [Tue, 27 Dec 2022 15:57:50 +0000 (15:57 +0000)]
gcc: fix Windows target binutils secrel detection
Newer binutils uses all caps, where it was all lower case
previously. Pushed as obvious.
This should resolve:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100383
gcc/
* configure.ac: use grep -i for case insensitive test.
* configure: Regenerate.
Signed-off-by: Jonathan Yong <10walls@gmail.com>
Max Filippov [Fri, 23 Dec 2022 20:17:09 +0000 (12:17 -0800)]
gcc: xtensa: use define_c_enums instead of define_constants
This improves RTL dumps readability. No functional changes.
gcc/
* config/xtensa/xtensa.md (unspec): Extract UNSPEC_* constants
into this enum.
(unspecv): Extract UNSPECV_* constants into this enum.
Takayuki 'January June' Suwa [Tue, 27 Dec 2022 06:30:12 +0000 (15:30 +0900)]
xtensa: Generate density instructions in set_frame_ptr
gcc/ChangeLog:
* config/xtensa/xtensa.md (set_frame_ptr): Fix to reflect
TARGET_DENSITY.
Takayuki 'January June' Suwa [Tue, 27 Dec 2022 06:30:12 +0000 (15:30 +0900)]
xtensa: Change GP_RETURN{,_REG_COUNT} to GP_RETURN_{FIRST,LAST}
gcc/ChangeLog:
* config/xtensa/xtensa.h (GP_RETURN, GP_RETURN_REG_COUNT):
Change to GP_RETURN_FIRST and GP_RETURN_LAST, respectively.
* config/xtensa/xtensa.cc (xtensa_function_value,
xtensa_libcall_value, xtensa_function_value_regno_p): Ditto.
Takayuki 'January June' Suwa [Tue, 27 Dec 2022 06:30:12 +0000 (15:30 +0900)]
xtensa: Clean up xtensa_expand_prologue
gcc/ChangeLog:
* config/xtensa/xtensa.cc (xtensa_expand_prologue): Modify to
exit the inspection loops as soon as the necessity of stack
pointer is found.
Takayuki 'January June' Suwa [Tue, 27 Dec 2022 06:30:12 +0000 (15:30 +0900)]
xtensa: Tabify, and trim trailing spaces
Cosmetic and no functional changes.
gcc/ChangeLog:
* config/xtensa/elf.h: Tabify, and trim trailing spaces.
* config/xtensa/linux.h: Likewise.
* config/xtensa/uclinux.h: Likewise.
* config/xtensa/xtensa-dynconfig.c: Likewise.
* config/xtensa/xtensa.cc: Likewise.
* config/xtensa/xtensa.h: Likewise.
* config/xtensa/xtensa.md: Likewise.
Kito Cheng [Tue, 27 Dec 2022 15:06:17 +0000 (23:06 +0800)]
RISC-V: Add riscv_vector.h wrapper
Like
d0bbecb1c418b680505faa998fe420f0fd4bbfc1, we add a wrapper to
prevent it pull stdint.h from standard C library.
gcc/testsuite:
* gcc.target/riscv/rvv/vsetvl/riscv_vector.h: New.
Ju-Zhe Zhong [Sat, 24 Dec 2022 03:08:00 +0000 (11:08 +0800)]
RISC-V: Fix ICE of visiting non-existing block in CFG.
This patch is to fix issue of visiting non-existing block of CFG.
Since blocks index of CFG in GCC are not always contiguous, we will potentially
visit a gap block which is no existing in the current CFG.
This patch can avoid visiting non existing block in CFG.
I noticed such issue in my internal regression of current testsuite
when I change the X86 server machine. This patch fix it:
17:27:15 job(build_and_test_rv32): Increased FAIL List:
17:27:15 job(build_and_test_rv32): FAIL: gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c
-O2 -flto -fno-use-linker-plugin -flto-partition=none (internal compiler error: Segmentation fault)
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc
(pass_vsetvl::compute_global_backward_infos): Change to visit CFG.
(pass_vsetvl::prune_expressions): Ditto.
Ju-Zhe Zhong [Fri, 23 Dec 2022 12:42:27 +0000 (20:42 +0800)]
RISC-V: Fix ICE for avl_info deprecated copy and pp_print error.
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (change_insn): Remove pp_print.
(avl_info::avl_info): Add copy function.
(vector_insn_info::dump): Remove pp_print.
* config/riscv/riscv-vsetvl.h: Add copy function.
Kewen Lin [Tue, 27 Dec 2022 10:13:07 +0000 (04:13 -0600)]
rs6000: Rework option -mpowerpc64 handling [PR106680]
PR106680 shows that -m32 -mpowerpc64 is different from
-mpowerpc64 -m32, this is determined by the way how we
handle option powerpc64 in rs6000_handle_option.
Segher pointed out this difference should be taken as
a bug and we should ensure that option powerpc64 is
independent of -m32/-m64. So this patch removes the
handlings in rs6000_handle_option and add some necessary
supports in rs6000_option_override_internal instead.
With this patch, if users specify -m{no-,}powerpc64, the
specified value is honoured, otherwise, for 64bit it
always enables OPTION_MASK_POWERPC64; while for 32bit
and TARGET_POWERPC64 and OS_MISSING_POWERPC64, it disables
OPTION_MASK_POWERPC64.
btw, following Segher's suggestion, I did some tries to warn
when OPTION_MASK_POWERPC64 is set for OS_MISSING_POWERPC64.
If warn for the case that powerpc64 is specified explicitly,
there are some TCs using -m32 -mpowerpc64 on ppc64-linux,
they need some updates, meanwhile the artificial run
with "--target_board=unix'{-m32/-mpowerpc64}'" will have
noisy warnings on ppc64-linux. If warn for the case that
it's specified implicitly, they can just be initialized by
TARGET_DEFAULT (like -m32 on ppc64-linux) or set from the
given cpu mask, we have to special case them and not to warn.
As Segher's latest comment, I decide not to warn them and
keep it consistent with before.
Bootstrapped and regress-tested on:
- powerpc64-linux-gnu P7 and P8 {-m64,-m32}
- powerpc64le-linux-gnu P9 and P10
- powerpc-ibm-aix7.2.0.0 {-maix64,-maix32}
- powerpc-darwin9 (with Iain's help)
PR target/106680
gcc/ChangeLog:
* common/config/rs6000/rs6000-common.cc (rs6000_handle_option): Remove
the adjustment for option powerpc64 in -m64 handling, and remove the
whole -m32 handling.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): When no
explicit powerpc64 option is provided, enable it for -m64. For 32 bit
and OS_MISSING_POWERPC64, disable powerpc64 if it's enabled but not
specified explicitly.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr106680-1.c: New test.
* gcc.target/powerpc/pr106680-2.c: New test.
* gcc.target/powerpc/pr106680-3.c: New test.
* gcc.target/powerpc/pr106680-4.c: New test.
2022-12-27 Kewen Lin <linkw@linux.ibm.com>
Iain Sandoe <iain@sandoe.co.uk>
GCC Administrator [Tue, 27 Dec 2022 00:16:40 +0000 (00:16 +0000)]
Daily bump.
David Edelsohn [Fri, 23 Dec 2022 00:53:02 +0000 (19:53 -0500)]
testsuite: fix analyzer failures on AIX
Many analyzer testcases are failing on AIX, some due to specific system
header expectations. This patch skips the testcases to avoid the noise.
* gcc.dg/analyzer/fd-accept.c: Skip.
* gcc.dg/analyzer/fd-access-mode-target-headers.c: Skip.
* gcc.dg/analyzer/fd-bind.c: Skip.
* gcc.dg/analyzer/fd-connect.c: Skip.
* gcc.dg/analyzer/fd-datagram-socket.c: Skip.
* gcc.dg/analyzer/fd-glibc-datagram-client.c: Skip.
* gcc.dg/analyzer/fd-glibc-datagram-socket.c: Skip.
* gcc.dg/analyzer/fd-listen.c: Skip.
* gcc.dg/analyzer/fd-socket-misuse.c: Skip.
* gcc.dg/analyzer/fd-stream-socket-active-open.c: Skip.
* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Skip.
* gcc.dg/analyzer/fd-stream-socket.c: Skip.
* gcc.dg/analyzer/fd-symbolic-socket.c: Skip.
* gcc.dg/analyzer/flex-with-call-summaries.c: Skip.
* gcc.dg/analyzer/getchar-1.c: Skip.
* gcc.dg/analyzer/isatty-1.c: Skip.
* gcc.dg/analyzer/pr94851-1.c: Skip.
* gcc.dg/analyzer/pragma-2.c: Skip.
liuhongt [Mon, 12 Dec 2022 07:43:58 +0000 (15:43 +0800)]
x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.
if (mdaz-ftz)
link crtfastmath.o
else if ((Ofast || ffast-math || funsafe-math-optimizations)
&& !shared && !mno-daz-ftz)
link crtfastmath.o
else
Don't link crtfastmath.o
gcc/ChangeLog:
PR target/55522
PR target/36821
* config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
Link crtfastmath.o whenever -mdaz-ftz is specified. Don't link
crtfastmath.o when -share or -mno-daz-ftz is specified.
* config/i386/i386.opt (mdaz-ftz): New option.
* doc/invoke.texi (x86 options): Document mftz-daz.
GCC Administrator [Mon, 26 Dec 2022 00:16:27 +0000 (00:16 +0000)]
Daily bump.
Roger Sayle [Sun, 25 Dec 2022 11:57:12 +0000 (11:57 +0000)]
Use movss/movsd to implement V4SI/V2DI VEC_PERM on x86.
This patch tweaks the x86 backend to use the movss and movsd instructions
to perform some vector permutations on integer vectors (V4SI and V2DI) in
the same way they are used for floating point vectors (V4SF and V2DF).
As a motivating example, consider:
typedef unsigned int v4si __attribute__((vector_size(16)));
typedef float v4sf __attribute__((vector_size(16)));
v4si foo(v4si x,v4si y) { return (v4si){y[0],x[1],x[2],x[3]}; }
v4sf bar(v4sf x,v4sf y) { return (v4sf){y[0],x[1],x[2],x[3]}; }
which is currently compiled with -O2 to:
foo: movdqa %xmm0, %xmm2
shufps $80, %xmm0, %xmm1
movdqa %xmm1, %xmm0
shufps $232, %xmm2, %xmm0
ret
bar: movss %xmm1, %xmm0
ret
with this patch both functions compile to the same form.
Likewise for the V2DI case:
typedef unsigned long v2di __attribute__((vector_size(16)));
typedef double v2df __attribute__((vector_size(16)));
v2di foo(v2di x,v2di y) { return (v2di){y[0],x[1]}; }
v2df bar(v2df x,v2df y) { return (v2df){y[0],x[1]}; }
which currently generates:
foo: shufpd $2, %xmm0, %xmm1
movdqa %xmm1, %xmm0
ret
bar: movsd %xmm1, %xmm0
ret
2022-12-25 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
* config/i386/i386-builtin.def (__builtin_ia32_movss): Update
CODE_FOR_sse_movss to CODE_FOR_sse_movss_v4sf.
(__builtin_ia32_movsd): Likewise, update CODE_FOR_sse2_movsd to
CODE_FOR_sse2_movsd_v2df.
* config/i386/i386-expand.cc (split_convert_uns_si_sse): Update
gen_sse_movss call to gen_sse_movss_v4sf, and gen_sse2_movsd call
to gen_sse2_movsd_v2df.
(expand_vec_perm_movs): Also allow V4SImode with TARGET_SSE and
V2DImode with TARGET_SSE2.
* config/i386/sse.md
(avx512fp16_fcmaddcsh_v8hf_mask3<round_expand_name>): Update
gen_sse_movss call to gen_sse_movss_v4sf.
(avx512fp16_fmaddcsh_v8hf_mask3<round_expand_name>): Likewise.
(sse_movss_<mode>): Renamed from sse_movss using VI4F_128 mode
iterator to handle both V4SF and V4SI.
(sse2_movsd_<mode>): Likewise, renamed from sse2_movsd using
VI8F_128 mode iterator to handle both V2DF and V2DI.
gcc/testsuite/ChangeLog
* gcc.target/i386/sse-movss-4.c: New test case.
* gcc.target/i386/sse2-movsd-3.c: New test case.
Jonathan Yong [Sun, 25 Dec 2022 01:06:20 +0000 (01:06 +0000)]
libgcc: fix gfortran build on Windows
Broken by
9149a5b7e0a66b7b94d5b7db3194a975d18dea2f.
CC_NONE is defined by wingdi.h and conflicting with gcc.
Committed as obvious.
libgcc/:
* config/i386/gthr-win32.h: undef CC_NONE
Signed-off-by: Jonathan Yong <10walls@gmail.com>
GCC Administrator [Sun, 25 Dec 2022 00:16:57 +0000 (00:16 +0000)]
Daily bump.
Roger Sayle [Sat, 24 Dec 2022 22:07:11 +0000 (22:07 +0000)]
[Committed] Tweak new gcc.target/i386/pr107548-1.c for -march=cascadelake.
My recently added testcases gcc.target/i386/pr107548-[12].c need to be
tweaked slightly for -march=cascadelake. Committed as obvious.
2022-12-24 Roger Sayle <roger@nextmovesoftware.com>
gcc/testsuite/ChangeLog
PR target/107548
* gcc.target/i386/pr107548-1.c: Match both vmovd and movd.
* gcc.target/i386/pr107548-2.c: Match both vpaddq and paddq.
Iain Sandoe [Sat, 24 Dec 2022 10:59:26 +0000 (10:59 +0000)]
libstdc++: Test for tzdata.zi before fallback version files.
Several systems/distributions do not provide the raw tzdata.zi file in
their zoneinfo installation. However, we might provide an alternate
installation path at configure time, so that we should check for the
tzdata.zi file first and then fall back to system-specific files like
+VERSION etc. on those systems.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libstdc++-v3/ChangeLog:
* src/c++20/tzdb.cc (remote_version): Look for the tzdata.zi
file before falling back to system-specific ones on Darwin and
BSD.
Iain Sandoe [Sat, 24 Dec 2022 11:04:41 +0000 (11:04 +0000)]
libstdc++, testsuite: Correct an init.
in leap_seconds.cc, we are testing to see if the function that
overrides the default zoneinfo directory has been called. That
is implemented with a static boolean that needs to be initialized
to false.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libstdc++-v3/ChangeLog:
* testsuite/std/time/tzdb/leap_seconds.cc: Initialize the
override_used test var to false.
Iain Sandoe [Thu, 22 Dec 2022 17:32:06 +0000 (17:32 +0000)]
libgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib.
On Darwin, GCC now uses a libgcc_s.1.1 for builtins and forwards the system
unwinder. We do, however, build a backwards compatibility libgcc_s.1.dylib.
However, this is not needed by GCC and can cause incorrect operation when
DYLD_LIBRARY_PATH is in use.
Since we do not need or use it during the build, the solution is to skip the
installation into the $build/gcc directory.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:
* config/t-slibgcc-darwin (install-darwin-libgcc-stubs): Skip the
install of libgcc_s.1.dylib when the installation is into the build
gcc directory.
GCC Administrator [Sat, 24 Dec 2022 00:17:19 +0000 (00:17 +0000)]
Daily bump.
Eric Botcazou [Fri, 23 Dec 2022 23:45:15 +0000 (23:45 +0000)]
Reimplement GNU threads library on native Windows
This reimplements the GNU threads library on native Windows (except for the
Objective-C specific subset) using direct Win32 API calls, in lieu of the
implementation based on semaphores. This base implementations requires
Windows XP/Server 2003, which was the default minimal setting of MinGW-W64
until end of 2020. This also adds the support required for the C++11 threads,
using again direct Win32 API calls; this additional layer requires Windows
Vista/Server 2008 and is enabled only if _WIN32_WINNT >= 0x0600.
This also changes libstdc++ to pass -D_WIN32_WINNT=0x0600 but only when the
switch --enable-libstdcxx-threads is passed, which means that C++11 threads
are still disabled by default *unless* MinGW-W64 itself is configured for
Windows Vista/Server 2008 or later by default (this has been the case in
the development version since end of 2020, for earlier versions you can
configure it --with-default-win32-winnt=0x0600 to get the same effect).
I only manually tested it on i686-w64-mingw32 and x86_64-w64-mingw32 but
AdaCore has used it in their C/C++/Ada compilers for 3 years now and the
30_threads chapter of the libstdc++ testsuite was clean at the time.
2022-10-31 Eric Botcazou <ebotcazou@adacore.com>
libgcc/
* config.host (i[34567]86-*-mingw*): Add thread fragment after EH one
as well as new i386/t-slibgcc-mingw fragment.
(x86_64-*-mingw*): Likewise.
* config/i386/gthr-win32.h: If _WIN32_WINNT is at least 0x0600, define
both __GTHREAD_HAS_COND and __GTHREADS_CXX0X to 1.
Error out if _GTHREAD_USE_MUTEX_TIMEDLOCK is 1.
Include stdlib.h instead of errno.h and do not include _mingw.h.
(CONST_CAST2): Add specific definition for C++.
(ATTRIBUTE_UNUSED): New macro.
(__UNUSED_PARAM): Delete.
Define WIN32_LEAN_AND_MEAN before including windows.h.
(__gthread_objc_data_tls): Use TLS_OUT_OF_INDEXES instead of (DWORD)-1.
(__gthread_objc_init_thread_system): Likewise.
(__gthread_objc_thread_get_data): Minor tweak.
(__gthread_objc_condition_allocate): Use ATTRIBUTE_UNUSED.
(__gthread_objc_condition_deallocate): Likewise.
(__gthread_objc_condition_wait): Likewise.
(__gthread_objc_condition_broadcast): Likewise.
(__gthread_objc_condition_signal): Likewise.
Include sys/time.h.
(__gthr_win32_DWORD): New typedef.
(__gthr_win32_HANDLE): Likewise.
(__gthr_win32_CRITICAL_SECTION): Likewise.
(__gthr_win32_CONDITION_VARIABLE): Likewise.
(__gthread_t): Adjust.
(__gthread_key_t): Likewise.
(__gthread_mutex_t): Likewise.
(__gthread_recursive_mutex_t): Likewise.
(__gthread_cond_t): New typedef.
(__gthread_time_t): Likewise.
(__GTHREAD_MUTEX_INIT_DEFAULT): Delete.
(__GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT): Likewise.
(__GTHREAD_COND_INIT_FUNCTION): Define.
(__GTHREAD_TIME_INIT): Likewise.
(__gthr_i486_lock_cmp_xchg): Delete.
(__gthr_win32_create): Declare.
(__gthr_win32_join): Likewise.
(__gthr_win32_self): Likewise.
(__gthr_win32_detach): Likewise.
(__gthr_win32_equal): Likewise.
(__gthr_win32_yield): Likewise.
(__gthr_win32_mutex_destroy): Likewise.
(__gthr_win32_cond_init_function): Likewise if __GTHREADS_HAS_COND is 1.
(__gthr_win32_cond_broadcast): Likewise.
(__gthr_win32_cond_signal): Likewise.
(__gthr_win32_cond_wait): Likewise.
(__gthr_win32_cond_timedwait): Likewise.
(__gthr_win32_recursive_mutex_init_function): Delete.
(__gthr_win32_recursive_mutex_lock): Likewise.
(__gthr_win32_recursive_mutex_unlock): Likewise.
(__gthr_win32_recursive_mutex_destroy): Likewise.
(__gthread_create): New inline function.
(__gthread_join): Likewise.
(__gthread_self): Likewise.
(__gthread_detach): Likewise.
(__gthread_equal): Likewise.
(__gthread_yield): Likewise.
(__gthread_cond_init_function): Likewise if __GTHREADS_HAS_COND is 1.
(__gthread_cond_broadcast): Likewise.
(__gthread_cond_signal): Likewise.
(__gthread_cond_wait): Likewise.
(__gthread_cond_timedwait): Likewise.
(__GTHREAD_WIN32_INLINE): New macro.
(__GTHREAD_WIN32_COND_INLINE): Likewise.
(__GTHREAD_WIN32_ACTIVE_P): Likewise.
Define WIN32_LEAN_AND_MEAN before including windows.h.
(__gthread_once): Minor tweaks.
(__gthread_key_create): Use ATTRIBUTE_UNUSED and TLS_OUT_OF_INDEXES.
(__gthread_key_delete): Minor tweak.
(__gthread_getspecific): Likewise.
(__gthread_setspecific): Likewise.
(__gthread_mutex_init_function): Reimplement.
(__gthread_mutex_destroy): Likewise.
(__gthread_mutex_lock): Likewise.
(__gthread_mutex_trylock): Likewise.
(__gthread_mutex_unlock): Likewise.
(__gthr_win32_abs_to_rel_time): Declare.
(__gthread_recursive_mutex_init_function): Reimplement.
(__gthread_recursive_mutex_destroy): Likewise.
(__gthread_recursive_mutex_lock): Likewise.
(__gthread_recursive_mutex_trylock): Likewise.
(__gthread_recursive_mutex_unlock): Likewise.
(__gthread_cond_destroy): New inline function.
(__gthread_cond_wait_recursive): Likewise.
* config/i386/gthr-win32.c: Delete everything.
Include gthr-win32.h to get the out-of-line version of inline routines.
Add compile-time checks for the local version of the Win32 types.
* config/i386/gthr-win32-cond.c: New file.
* config/i386/gthr-win32-thread.c: Likewise.
* config/i386/t-gthr-win32: Add config/i386/gthr-win32-thread.c to the
EH part, config/i386/gthr-win32-cond.c and config/i386/gthr-win32.c to
the static version of libgcc.
* config/i386/t-slibgcc-mingw: New file.
* config/i386/libgcc-mingw.ver: Likewise.
libstdc++-v3/
* acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Substitute CPPFLAGS.
(GLIBCXX_ENABLE_LIBSTDCXX_TIME): Set ac_has_sched_yield and
ac_has_win32_sleep to yes for MinGW. Change HAVE_WIN32_SLEEP
into _GLIBCXX_USE_WIN32_SLEEP.
(GLIBCXX_CHECK_GTHREADS): Add _WIN32_THREADS to compilation flags for
Win32 threads and force _GTHREAD_USE_MUTEX_TIMEDLOCK to 0 for them.
Add -D_WIN32_WINNT=0x0600 to compilation flags if yes was configured
and add it to CPPFLAGS on success.
* config.h.in: Regenerate.
* configure: Likewise.
* config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_GET_NPROCS_WIN32):
Define to 1.
* config/os/mingw32/os_defines.h (_GLIBCXX_USE_GET_NPROCS_WIN32): Ditto
* src/c++11/thread.cc (get_nprocs): Provide Win32 implementation if
_GLIBCXX_USE_GET_NPROCS_WIN32 is defined. Replace HAVE_WIN32_SLEEP
with USE_WIN32_SLEEP.
* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: Add
missing conditional compilation.
* testsuite/lib/libstdc++.exp (check_v3_target_sleep): Add support for
_GLIBCXX_USE_WIN32_SLEEP.
(check_v3_target_nprocs): Likewise for _GLIBCXX_USE_GET_NPROCS_WIN32.
Signed-off-by: Eric Botcazou <ebotcazou@adacore.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
Harald Anlauf [Sat, 17 Dec 2022 21:04:32 +0000 (22:04 +0100)]
Fortran: incorrect array bounds when bound intrinsic used in decl [PR108131]
gcc/fortran/ChangeLog:
PR fortran/108131
* array.cc (match_array_element_spec): Avoid too early simplification
of matched array element specs that can lead to a misinterpretation
when used as array bounds in array declarations.
gcc/testsuite/ChangeLog:
PR fortran/108131
* gfortran.dg/pr103505.f90: Adjust expected patterns.
* gfortran.dg/pr108131.f90: New test.
Patrick Palka [Fri, 23 Dec 2022 16:17:45 +0000 (11:17 -0500)]
c++: get_nsdmi in template context [PR108116]
Here during ahead of time checking of C{}, we indirectly call get_nsdmi
for C::m from finish_compound_literal, which in turn calls
break_out_target_exprs for C::m's (non-templated) initializer, during
which we build a call to A::~A and check expr_noexcept_p for it (from
build_vec_delete_1). But this is all done with processing_template_decl
set, so the built A::~A call is templated (whose form was recently
changed by r12-6897-gdec8d0e5fa00ceb2) which expr_noexcept_p doesn't
expect, and we crash.
This patch fixes this by clearing processing_template_decl before
the call to break_out_target_exprs from get_nsdmi. And since it more
generally seems we shouldn't be seeing (or producing) non-templated
trees in break_out_target_exprs, this patch also adds an assert to
that effect.
PR c++/108116
gcc/cp/ChangeLog:
* constexpr.cc (maybe_constant_value): Clear
processing_template_decl before calling break_out_target_exprs.
* init.cc (get_nsdmi): Likewise.
* tree.cc (break_out_target_exprs): Assert processing_template_decl
is cleared.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/nsdmi-template24.C: New test.
Jakub Jelinek [Fri, 23 Dec 2022 15:19:08 +0000 (16:19 +0100)]
phiopt: Improve value_replacement maybe equal phires range handling
My previous patch added throwing away of SSA_NAME_RANGE_INFO of
phires when we have phires = x != carg ? x : oarg, but that could
throw away useful range info, all we need is merge phires current
range info with the carg constant which can newly appear there
(and the optimization proved the single user doesn't care about that).
2022-12-23 Jakub Jelinek <jakub@redhat.com>
Aldy Hernandez <aldyh@redhat.com>
* tree-ssa-phiopt.cc (value_replacement): Instead of resetting
phires range info, union it with carg.
Jakub Jelinek [Fri, 23 Dec 2022 15:12:21 +0000 (16:12 +0100)]
tree-ssa-dom: can_infer_simple_equiv fixes [PR108068]
As reported in the PR, tree-ssa-dom.cc uses real_zerop call to find
if a floating point constant is zero and it shouldn't try to infer
equivalences from comparison against it if signed zeros are honored.
This doesn't work at all for decimal types, because real_zerop always
returns false for them (one can have different representations of decimal
zero beyond -0/+0), and it doesn't work for vector compares either,
as real_zerop checks if all elements are zero, while we need to avoid
infering equivalences from comparison against vector constants which have
at least one zero element in it (if signed zeros are honored).
Furthermore, as mentioned by Joseph, for decimal types many other values
aren't singleton.
So, this patch stops infering anything if element mode is decimal, and
otherwise uses instead of real_zerop a new function, real_maybe_zerop,
which will work even for decimal types and for complex or vector will
return true if any element is or might be zero (so it returns true
for anything but constants for now).
2022-12-23 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/108068
* tree.h (real_maybe_zerop): Declare.
* tree.cc (real_maybe_zerop): Define.
* tree-ssa-dom.cc (record_edge_info): Use it instead of
real_zerop or TREE_CODE (op1) == SSA_NAME || real_zerop. Always set
can_infer_simple_equiv to false for decimal floating point types.
* gcc.dg/dfp/pr108068.c: New test.
Patrick Palka [Fri, 23 Dec 2022 14:18:37 +0000 (09:18 -0500)]
c++: template friend with variadic constraints [PR107853]
When instantiating a constrained hidden template friend, we substitute
into its template-head requirements in tsubst_friend_function. For this
substitution we use the template's full argument vector whose outer
levels correspond to the instantiated class's arguments and innermost
level corresponds to the template's own level-lowered generic arguments.
But for A<int>::f here, for which the relevant argument vector is
{{int}, {Us...}}, the substitution into (C<Ts, Us> && ...) triggers the
assert in use_pack_expansion_extra_args_p since one argument is a pack
expansion and the other isn't.
And for A<int, int>::f, for which the relevant argument vector is
{{int, int}, {Us...}}, the use_pack_expansion_extra_args_p assert would
also trigger but we first get a bogus "mismatched argument pack lengths"
error from tsubst_pack_expansion.
Sidestepping the question of whether tsubst_pack_expansion should be
able to handle such substitutions, it seems we can work around this by
using only the instantiated class's arguments and not also the template
friend's own generic arguments, which is consistent with how we normally
substitute into the signature of a member template.
PR c++/107853
gcc/cp/ChangeLog:
* constraint.cc (maybe_substitute_reqs_for): Substitute into
the template-head requirements of a template friend using only
its outer arguments via outer_template_args.
* cp-tree.h (outer_template_args): Declare.
* pt.cc (outer_template_args): Define, factored out and
generalized from ...
(ctor_deduction_guides_for): ... here.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-friend12.C: New test.
* g++.dg/cpp2a/concepts-friend13.C: New test.
Jonathan Wakely [Fri, 23 Dec 2022 13:43:52 +0000 (13:43 +0000)]
libstdc++: Fix Darwin bootstrap error in src/c++20/tzdb.cc
Mach-O requires weak symbols to have a definition, so add a default
implementation of __gnu_cxx::zoneinfo_dir_override.
libstdc++-v3/ChangeLog:
* src/c++20/tzdb.cc [__APPLE__] (zoneinfo_dir_override): Add
definition.
Julian Brown [Mon, 23 May 2022 13:19:10 +0000 (06:19 -0700)]
Fortran: Typo/unicode-o fixes
This patch fixes a minor typo in dump output and a stray unicode character
in a comment.
2022-06-01 Julian Brown <julian@codesourcery.com>
gcc/fortran/
* dump-parse-tree.cc (show_attr): Fix OMP-UDR-ARTIFICIAL-VAR typo.
* trans-openmp.cc (gfc_trans_omp_array_section): Replace stray unicode
m-dash character with hyphen.
Roger Sayle [Fri, 23 Dec 2022 09:56:30 +0000 (09:56 +0000)]
PR target/107548: Handle vec_select in STV on x86.
This patch enhances x86's STV pass to handle VEC_SELECT during general
scalar chain conversion, performing SImode scalar extraction from V4SI
and DImode scalar extraction from V2DI in vector registers.
The motivating test case from bugzilla is:
typedef unsigned int v4si __attribute__((vector_size(16)));
unsigned int f (v4si a, v4si b)
{
a[0] += b[0];
return a[0] + a[1];
}
currently with -O2 -march=znver2 this generates:
vpextrd $1, %xmm0, %edx
vmovd %xmm0, %eax
addl %edx, %eax
vmovd %xmm1, %edx
addl %edx, %eax
ret
which performs three transfers from the vector unit to the scalar unit,
and performs the two additions there. With this patch, we now generate:
vmovdqa %xmm0, %xmm2
vpshufd $85, %xmm0, %xmm0
vpaddd %xmm0, %xmm2, %xmm0
vpaddd %xmm1, %xmm0, %xmm0
vmovd %xmm0, %eax
ret
which performs the two additions in the vector unit, and then transfers
the result to the scalar unit. Technically the (cheap) movdqa isn't
needed with better register allocation (or this could be cleaned up
during peephole2), but even so this transform is still a win.
2022-12-23 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/107548
* config/i386/i386-features.cc (scalar_chain::add_insn): The
operands of a VEC_SELECT don't need to added to the scalar chain.
(general_scalar_chain::compute_convert_gain) <case VEC_SELECT>:
Provide gains for performing STV on a VEC_SELECT.
(general_scalar_chain::convert_insn): Convert VEC_SELECT to pshufd,
psrldq or no-op.
(general_scalar_to_vector_candidate_p): Handle VEC_SELECT of a
single element from a vector register to a scalar register.
gcc/testsuite/ChangeLog
PR target/107548
* gcc.target/i386/pr107548-1.c: New test V4SI case.
* gcc.target/i386/pr107548-2.c: New test V2DI case.
Roger Sayle [Fri, 23 Dec 2022 09:50:18 +0000 (09:50 +0000)]
PR target/106933: Limit TImode STV to SSA-like def-use chains on x86.
With many thanks to H.J. for doing all the hard work, this patch resolves
two P1 regressions; PR target/106933 and PR target/106959.
Although superficially similar, the i386 backend's two scalar-to-vector
(STV) passes perform their transformations in importantly different ways.
The original pass converting SImode and DImode operations to V4SImode
or V2DImode operations is "soft", allowing values to be maintained in
both integer and vector hard registers. The newer pass converting TImode
operations to V1TImode is "hard" (all or nothing) that converts all uses
of a pseudo to vector form. To implement this it invokes powerful ju-ju
calling SET_MODE on a reg_rtx, which due to RTL sharing, often updates
this pseudo's mode everywhere in the RTL chain. Hence, TImode STV can only
be performed when all uses of a pseudo are convertible to V1TImode form.
To ensure this the STV passes currently use data-flow analysis to inspect
all DEFs and USEs in a chain. This works fine for chains that are in
the usual single assignment form, but the occurrence of uninitialized
variables, or multiple assignments that split a pseudo's usage into
several independent chains (lifetimes) can lead to situations where
some but not all of a pseudo's occurrences need to be updated. This is
safe for the SImode/DImode pass, but leads to the above bugs during
the TImode pass.
My one minor tweak to HJ's patch from comment #4 of bugzilla PR106959
is to only perform the new single_def_chain_p check for TImode STV; it
turns out that STV of SImode/DImode min/max operates safely on multiple-def
chains, and prohibiting this leads to testsuite regressions. We don't
(yet) support V1TImode min/max, so this idiom isn't an issue during the
TImode STV pass.
For the record, the two alternate possible fixes are (i) make the TImode
STV pass "soft", by eliminating use of SET_MODE, instead using replace_rtx
with a new pseudo, or (ii) merging "chains" so that multiple DFA
chains/lifetimes are considered a single STV chain.
2022-12-23 H.J. Lu <hjl.tools@gmail.com>
Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/106933
PR target/106959
* config/i386/i386-features.cc (single_def_chain_p): New predicate
function to check that a pseudo's use-def chain is in SSA form.
(timode_scalar_to_vector_candidate_p): Check that TImode regs that
are SET_DEST or SET_SRC of an insn match/are single_def_chain_p.
gcc/testsuite/ChangeLog
PR target/106933
PR target/106959
* gcc.target/i386/pr106933-1.c: New test case.
* gcc.target/i386/pr106933-2.c: Likewise.
* gcc.target/i386/pr106959-1.c: Likewise.
* gcc.target/i386/pr106959-2.c: Likewise.
* gcc.target/i386/pr106959-3.c: Likewise.
Jonathan Wakely [Fri, 23 Dec 2022 09:19:38 +0000 (09:19 +0000)]
libstdc++: Remove problematic static_assert from src/c++20/tzdb.cc
This assertion fails for cris-elf where sizeof(datetime) is only 7, due
to lower alignment requirements. The assertion was used while I was
writing the code to check that the objects were as compact as I wanted,
but it doesn't need to be kept now.
libstdc++-v3/ChangeLog:
* src/c++20/tzdb.cc: Remove static_assert.
Iain Sandoe [Thu, 6 Jan 2022 08:37:18 +0000 (08:37 +0000)]
c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic.
The current implementation for swapping between the static and shared c++
runtimes relies on the static linker supporting Bstatic/dynamic which is
not available for every target (Darwin's linker does not support this).
Specs substitution (%s) is an alternative solution for this (which is what
Darwin uses for Fortran, D and Objective-C). However, specs substitution
requires that the '-static-libstdc++' be preserved in the driver's command
line. The patch here arranges for this to be done when the configuration
determines that linker support for Bstatic/dynamic is missing.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:
* g++spec.cc (lang_specific_driver): Preserve -static-libstdc++ in
the driver command line for targets without -Bstatic/dynamic support
in their static linker.
Ju-Zhe Zhong [Fri, 23 Dec 2022 03:33:06 +0000 (11:33 +0800)]
RISC-V: Fix vle constraints
gcc/ChangeLog:
* config/riscv/vector.md: Fix contraints.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/vle-constraint-1.c: New test.
Ju-Zhe Zhong [Fri, 23 Dec 2022 00:52:46 +0000 (08:52 +0800)]
RISC-V: Support vle.v/vse.v intrinsics
gcc/ChangeLog:
* config/riscv/riscv-protos.h (get_avl_type_rtx): New function.
* config/riscv/riscv-v.cc (get_avl_type_rtx): Ditto.
* config/riscv/riscv-vector-builtins-bases.cc (class loadstore): New
class.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vle): Ditto.
(vse): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (build_one): Ditto.
(struct loadstore_def): Ditto.
(SHAPE): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_U_OPS): New
macro.
(DEF_RVV_F_OPS): Ditto.
(vuint8mf8_t): Add corresponding mask type.
(vuint8mf4_t): Ditto.
(vuint8mf2_t): Ditto.
(vuint8m1_t): Ditto.
(vuint8m2_t): Ditto.
(vuint8m4_t): Ditto.
(vuint8m8_t): Ditto.
(vuint16mf4_t): Ditto.
(vuint16mf2_t): Ditto.
(vuint16m1_t): Ditto.
(vuint16m2_t): Ditto.
(vuint16m4_t): Ditto.
(vuint16m8_t): Ditto.
(vuint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vuint64m1_t): Ditto.
(vuint64m2_t): Ditto.
(vuint64m4_t): Ditto.
(vuint64m8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat32m8_t): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m2_t): Ditto.
(vfloat64m4_t): Ditto.
(vfloat64m8_t): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_TYPE): Adjust for new
macro.
(DEF_RVV_I_OPS): Ditto.
(DEF_RVV_U_OPS): New macro.
(DEF_RVV_F_OPS): New macro.
(use_real_mask_p): New function.
(use_real_merge_p): Ditto.
(get_tail_policy_for_pred): Ditto.
(get_mask_policy_for_pred): Ditto.
(function_builder::apply_predication): Ditto.
(function_builder::append_base_name): Ditto.
(function_builder::append_sew): Ditto.
(function_expander::add_vundef_operand): Ditto.
(function_expander::add_mem_operand): Ditto.
(function_expander::use_contiguous_load_insn): Ditto.
(function_expander::use_contiguous_store_insn): Ditto.
* config/riscv/riscv-vector-builtins.def (DEF_RVV_TYPE): Adjust for
adding mask type.
(vbool64_t): Ditto.
(vbool32_t): Ditto.
(vbool16_t): Ditto.
(vbool8_t): Ditto.
(vbool4_t): Ditto.
(vbool2_t): Ditto.
(vbool1_t): Ditto.
(vint8mf8_t): Ditto.
(vint8mf4_t): Ditto.
(vint8mf2_t): Ditto.
(vint8m1_t): Ditto.
(vint8m2_t): Ditto.
(vint8m4_t): Ditto.
(vint8m8_t): Ditto.
(vint16mf4_t): Ditto.
(vint16mf2_t): Ditto.
(vint16m1_t): Ditto.
(vint16m2_t): Ditto.
(vint16m4_t): Ditto.
(vint16m8_t): Ditto.
(vint32mf2_t): Ditto.
(vint32m1_t): Ditto.
(vint32m2_t): Ditto.
(vint32m4_t): Ditto.
(vint32m8_t): Ditto.
(vint64m1_t): Ditto.
(vint64m2_t): Ditto.
(vint64m4_t): Ditto.
(vint64m8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat32m8_t): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m4_t): Ditto.
* config/riscv/riscv-vector-builtins.h
(function_expander::add_output_operand): New function.
(function_expander::add_all_one_mask_operand): Ditto.
(function_expander::add_fixed_operand): Ditto.
(function_expander::vector_mode): Ditto.
(function_base::apply_vl_p): Ditto.
(function_base::can_be_overloaded_p): Ditto.
* config/riscv/riscv-vsetvl.cc (get_vl): Remove restrict of supporting
AVL is not VLMAX.
* config/riscv/t-riscv: Add include file.
Ju-Zhe Zhong [Tue, 20 Dec 2022 14:58:47 +0000 (22:58 +0800)]
RISC-V: Update vsetvl/vsetvlmax intrinsics to the latest api name.
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins-shapes.cc (struct vsetvl_def): Add
"__riscv_" prefix.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/vsetvl-1.c: Add "__riscv_" prefix.
Ju-Zhe Zhong [Tue, 20 Dec 2022 14:56:49 +0000 (22:56 +0800)]
RISC-V: Remove side effects of vsetvl pattern in RTL.
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins-bases.cc: Change it to no side effects.
* config/riscv/vector.md (@vsetvl<mode>_no_side_effects): New pattern.
Ju-Zhe Zhong [Tue, 20 Dec 2022 14:51:16 +0000 (22:51 +0800)]
RISC-V: Remove side effects of vsetvl/vsetvlmax intriniscs in properties
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins-bases.cc: Remove side effects.
Ju-Zhe Zhong [Mon, 19 Dec 2022 23:13:54 +0000 (07:13 +0800)]
RISC-V: Fix incorrect annotation
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (anticipatable_occurrence_p): Fix
incorrect annotations.
(available_occurrence_p): Ditto.
(backward_propagate_worthwhile_p): Ditto.
(can_backward_propagate_p): Ditto.
Ju-Zhe Zhong [Mon, 19 Dec 2022 23:09:35 +0000 (07:09 +0800)]
RISC-V: Fix muti-line condition format
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (vlmax_avl_insn_p): Fix multi-line
conditional.
(vsetvl_insn_p): Ditto.
(same_bb_and_before_p): Ditto.
(same_bb_and_after_or_equal_p): Ditto.
Steve Kargl [Fri, 23 Dec 2022 04:38:57 +0000 (20:38 -0800)]
Remove not needed assert macro which fails.
PR fortran/106731
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_trans_auto_array_allocation): Remove gcc_assert (!TREE_STATIC()).
gcc/testsuite/ChangeLog:
* gfortran.dg/pr106731.f90: New test.
Arsen Arsenović [Thu, 22 Dec 2022 11:03:06 +0000 (12:03 +0100)]
libstdc++: Improve output of default contract violation handler [PR107792]
Make the output more readable. Don't output anything unless verbose
termination is enabled at configure-time.
The testsuite change was almost entirely mechanical. Save for two files
which had very short matches, these changes were produced by two seds and a
Perl script, for the more involved cases. The latter will be added in a
subsequent commit. The former are as follows:
sed -E -i "/dg-output/s/default std::handle_contract_violation called: \
(\S+) (\S+) (\S+(<[A-Za-z0-9, ]*)?>?)\
/contract violation in function \3 at \1:\2: /" *.C
sed -i '/dg-output/s/ */ /g'
Whichever files remained failing after the above changes were checked-out,
re-ran, with output extracted, and ran through dg-out-generator.pl.
Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/107792
PR libstdc++/107778
* src/experimental/contract.cc (handle_contract_violation): Make
output more readable.
gcc/testsuite/ChangeLog:
* g++.dg/contracts/contracts-access1.C: Convert to new default
violation handler.
* g++.dg/contracts/contracts-assume2.C: Ditto.
* g++.dg/contracts/contracts-config1.C: Ditto.
* g++.dg/contracts/contracts-constexpr1.C: Ditto.
* g++.dg/contracts/contracts-ctor-dtor1.C: Ditto.
* g++.dg/contracts/contracts-deduced2.C: Ditto.
* g++.dg/contracts/contracts-friend1.C: Ditto.
* g++.dg/contracts/contracts-multiline1.C: Ditto.
* g++.dg/contracts/contracts-post3.C: Ditto.
* g++.dg/contracts/contracts-pre10.C: Ditto.
* g++.dg/contracts/contracts-pre2.C: Ditto.
* g++.dg/contracts/contracts-pre2a2.C: Ditto.
* g++.dg/contracts/contracts-pre3.C: Ditto.
* g++.dg/contracts/contracts-pre4.C: Ditto.
* g++.dg/contracts/contracts-pre5.C: Ditto.
* g++.dg/contracts/contracts-pre7.C: Ditto.
* g++.dg/contracts/contracts-pre9.C: Ditto.
* g++.dg/contracts/contracts-redecl3.C: Ditto.
* g++.dg/contracts/contracts-redecl4.C: Ditto.
* g++.dg/contracts/contracts-redecl6.C: Ditto.
* g++.dg/contracts/contracts-redecl7.C: Ditto.
* g++.dg/contracts/contracts-tmpl-spec1.C: Ditto.
* g++.dg/contracts/contracts-tmpl-spec2.C: Ditto.
* g++.dg/contracts/contracts-tmpl-spec3.C: Ditto.
* g++.dg/contracts/contracts10.C: Ditto.
* g++.dg/contracts/contracts14.C: Ditto.
* g++.dg/contracts/contracts15.C: Ditto.
* g++.dg/contracts/contracts16.C: Ditto.
* g++.dg/contracts/contracts17.C: Ditto.
* g++.dg/contracts/contracts19.C: Ditto.
* g++.dg/contracts/contracts25.C: Ditto.
* g++.dg/contracts/contracts3.C: Ditto.
* g++.dg/contracts/contracts35.C: Ditto.
* g++.dg/contracts/contracts5.C: Ditto.
* g++.dg/contracts/contracts7.C: Ditto.
* g++.dg/contracts/contracts9.C: Ditto.
Arsen Arsenović [Thu, 22 Dec 2022 11:03:08 +0000 (12:03 +0100)]
contrib: Add dg-out-generator.pl
This script is a helper used to generate dg-output lines from an existing
program output conveniently. It takes care of escaping Tcl and ARE stuff.
contrib/ChangeLog:
* dg-out-generator.pl: New file.
GCC Administrator [Fri, 23 Dec 2022 00:17:16 +0000 (00:17 +0000)]
Daily bump.
Jason Merrill [Thu, 22 Dec 2022 22:53:21 +0000 (17:53 -0500)]
testsuite: don't declare printf in coro.h
mingw stdio.h plays horrible games with extern "C++", but it also seems
sloppy for coro.h to declare printf in testcases that will also include
standard headers.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/coro.h: #include <stdio.h> instead of
declaring puts/printf.
* g++.dg/coroutines/torture/mid-suspend-destruction-0.C:
#include <stdio.h>.
* g++.dg/coroutines/pr95599.C: Use PRINT instead of puts.
* g++.dg/coroutines/torture/call-00-co-aw-arg.C:
* g++.dg/coroutines/torture/call-01-multiple-co-aw.C:
* g++.dg/coroutines/torture/call-02-temp-co-aw.C:
* g++.dg/coroutines/torture/call-03-temp-ref-co-aw.C:
* g++.dg/coroutines/torture/co-await-00-trivial.C:
* g++.dg/coroutines/torture/co-await-01-with-value.C:
* g++.dg/coroutines/torture/co-await-02-xform.C:
* g++.dg/coroutines/torture/co-await-03-rhs-op.C:
* g++.dg/coroutines/torture/co-await-04-control-flow.C:
* g++.dg/coroutines/torture/co-await-05-loop.C:
* g++.dg/coroutines/torture/co-await-06-ovl.C:
* g++.dg/coroutines/torture/co-await-07-tmpl.C:
* g++.dg/coroutines/torture/co-await-08-cascade.C:
* g++.dg/coroutines/torture/co-await-09-pair.C:
* g++.dg/coroutines/torture/co-await-11-forwarding.C:
* g++.dg/coroutines/torture/co-await-12-operator-2.C:
* g++.dg/coroutines/torture/co-await-13-return-ref.C:
* g++.dg/coroutines/torture/co-await-14-return-ref-to-auto.C:
* g++.dg/coroutines/torture/pr95003.C: Likewise.
Jonathan Wakely [Thu, 22 Dec 2022 09:56:47 +0000 (09:56 +0000)]
libstdc++: Avoid recursion in __nothrow_wait_cv::wait [PR105730]
The commit r12-5877-g9e18a25331fa25 removed the incorrect
noexcept-specifier from std::condition_variable::wait and gave the new
symbol version @@GLIBCXX_3.4.30. It also redefined the original symbol
std::condition_variable::wait(unique_lock<mutex>&)@GLIBCXX_3.4.11 as an
alias for a new symbol, __gnu_cxx::__nothrow_wait_cv::wait, which still
has the incorrect noexcept guarantee. That __nothrow_wait_cv::wait is
just a wrapper around the real condition_variable::wait which adds
noexcept and so terminates on a __forced_unwind exception.
This doesn't work on uclibc, possibly due to a dynamic linker bug. When
__nothrow_wait_cv::wait calls the condition_variable::wait function it
binds to the alias symbol, which means it just calls itself recursively
until the stack overflows.
This change avoids the possibility of a recursive call by changing the
__nothrow_wait_cv::wait function so that instead of calling
condition_variable::wait it re-implements it. This requires accessing
the private _M_cond member of condition_variable, so we need to use the
trick of instantiating a template with the member-pointer of the private
member.
libstdc++-v3/ChangeLog:
PR libstdc++/105730
* src/c++11/compatibility-condvar.cc (__nothrow_wait_cv::wait):
Access private data member of base class and call its wait
member.
Jonathan Wakely [Thu, 22 Dec 2022 01:29:22 +0000 (01:29 +0000)]
libstdc++: Add std::format support to <chrono>
This adds the operator<< overloads and std::formatter specializations
required by C++20 so that <chrono> types can be written to ostreams and
printed with std::format.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/chrono (operator<<): Move to new header.
(nonexistent_local_time::_M_make_what_str): Define correctly.
(ambiguous_local_time::_M_make_what_str): Likewise.
* include/bits/chrono_io.h: New file.
* src/c++20/tzdb.cc (operator<<(ostream&, const Rule&)): Use
new ostream output for month and weekday types.
* testsuite/20_util/duration/io.cc: Test std::format support.
* testsuite/std/time/exceptions.cc: Check what() strings.
* testsuite/std/time/syn_c++20.cc: Uncomment local_time_format.
* testsuite/std/time/time_zone/get_info_local.cc: Enable check
for formatted output of local_info objects.
* testsuite/std/time/clock/file/io.cc: New test.
* testsuite/std/time/clock/gps/io.cc: New test.
* testsuite/std/time/clock/system/io.cc: New test.
* testsuite/std/time/clock/tai/io.cc: New test.
* testsuite/std/time/clock/utc/io.cc: New test.
* testsuite/std/time/day/io.cc: New test.
* testsuite/std/time/format.cc: New test.
* testsuite/std/time/hh_mm_ss/io.cc: New test.
* testsuite/std/time/month/io.cc: New test.
* testsuite/std/time/weekday/io.cc: New test.
* testsuite/std/time/year/io.cc: New test.
* testsuite/std/time/year_month_day/io.cc: New test.
Jonathan Wakely [Thu, 22 Dec 2022 00:57:54 +0000 (00:57 +0000)]
libstdc++: Add helper function in <format>
Add a new __format::__write_padded_as_spec helper to remove duplicated
code in formatter specializations.
libstdc++-v3/ChangeLog:
* include/std/format (__format::__write_padded_as_spec): New
function.
(__format::__formatter_str, __format::__formatter_int::format)
(formatter<const void*, charT>): Use it.
Jonathan Wakely [Thu, 22 Dec 2022 01:15:55 +0000 (01:15 +0000)]
libstdc++: Add GDB printers for <chrono> types
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter)
(StdChronoTimePointPrinter, StdChronoZonedTimePrinter)
(StdChronoCalendarPrinter, StdChronoTimeZonePrinter)
(StdChronoLeapSecondPrinter, StdChronoTzdbPrinter)
(StdChronoTimeZoneRulePrinter): New printers.
Jonathan Wakely [Thu, 22 Dec 2022 00:37:54 +0000 (00:37 +0000)]
libstdc++: Implement C++20 time zone support in <chrono>
This is the largest missing piece of C++20 support. Only the cxx11 ABI
is supported, due to the use of std::string in the API for time zones.
For the old gcc4 ABI, utc_clock and leap seconds are supported, but only
using a hardcoded list of leap seconds, no up-to-date tzdb::leap_seconds
information is available, and no time zones or zoned_time conversions.
The implementation currently depends on a tzdata.zi file being provided
by the OS or the user. The expected location is /usr/share/zoneinfo but
that can be changed using --with-libstdcxx-zoneinfo-dir=PATH. On targets
that support it there is also a weak symbol that users can override in
their own program (which also helps with testing):
extern "C++" const char* __gnu_cxx::zoneinfo_dir_override();
If no file is found, a fallback tzdb object will be created which only
contains the "Etc/UTC" and "Etc/GMT" time zones.
A leapseconds file is also expected in the same directory, but if that
isn't present then a hardcoded list of leapseconds is used, which is
correct at least as far as 2023-06-28 (and it currently looks like no
leap second will be inserted for a few years).
The tzdata.zi and leapseconds files from https://www.iana.org/time-zones
are in the public domain, so shipping copies of them with GCC would be
an option. However, the tzdata.zi file will rapidly become outdated, so
users should really provide it themselves (or convince their OS vendor
to do so). It would also be possible to implement an alternative parser
for the compiled tzdata files (one per time zone) under
/usr/share/zoneinfo. Those files are present on more operating systems,
but do not contain all the information present in tzdata.zi.
Specifically, the "links" are not present, so that e.g. "UTC" and
"Universal" are distinct time zones, rather than both being links to the
canonical "Etc/UTC" zone. For some platforms those files are hard links
to the same file, but there's no indication which zone is the canonical
name and which is a link. Other platforms just store them in different
inodes anyway. I do not plan to add such an alternative parser for the
compiled files. That would need to be contributed by maintainers or
users of targets that require it, if making tzdata.zi available is not
an option. The library ABI would not need to change for a new tzdb
implementation, because everything in tzdb_list, tzdb and time_zone is
implemented as a pimpl (except for the shared_ptr links between nodes,
described below). That means the new exported symbols added by this
commit should be stable even if the implementation is completely
rewritten.
The information from tzdata.zi is parsed and stored in data structures
that closely model the info in the file. This is a space-efficient
representation that uses less memory that storing every transition for
every time zone. It also avoids spending time expanding that
information into time zone transitions that might never be needed by the
program. When a conversion to/from a local time to UTC is requested the
information will be processed to determine the time zone transitions
close to the time being converted.
There is a bug in some time zone transitions. When generating a sys_info
object immediately after one that was previously generated, we need to
find the previous rule that was in effect and note its offset and
letters. This is so that the start time and abbreviation of the new
sys_info will be correct. This only affects time zones that use a format
like "C%sT" where the LETTERS replacing %s are non-empty for standard
time, e.g. "Asia/Shanghai" which uses "CST" for standard time and "CDT"
for daylight time.
The tzdb_list structure maintains a linked list of tzdb nodes using
shared_ptr links. This allows the iterators into the list to share
ownership with the list itself. This offers a non-portable solution to a
lifetime issue in the API. Because tzdb objects can be erased from the
list using tzdb_list::erase_after, separate modules/libraries in a large
program cannot guarantee that any const tzdb& or const time_zone*
remains valid indefinitely. Holding onto a tzdb_list::const_iterator
will extend the tzdb object's lifetime, even if it's erased from the
list. An alternative design would be for the list iterator to hold a
weak_ptr. This would allow users to test whether the tzdb still exists
when the iterator is dereferenced, which is better than just having a
dangling raw pointer. That doesn't actually extend the tzdb's lifetime
though, and every use of it would need to be preceded by checking the
weak_ptr. Using shared_ptr adds a little bit of overhead but allows
users to solve the lifetime issue if they rely on the libstdc++-specific
iterator property.
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_ZONEINFO_DIR): New macro.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver: Export new symbols.
* configure: Regenerate.
* configure.ac (GLIBCXX_ZONEINFO_DIR): Use new macro.
* include/std/chrono (utc_clock::from_sys): Correct handling
of leap seconds.
(nonexistent_local_time::_M_make_what_str): Define.
(ambiguous_local_time::_M_make_what_str): Define.
(__throw_bad_local_time): Define new function.
(time_zone, tzdb_list, tzdb): Implement all members.
(remote_version, zoned_time, get_leap_second_info): Define.
* include/std/version: Add comment for __cpp_lib_chrono.
* src/c++20/Makefile.am: Add new file.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/tzdb.cc: New file.
* testsuite/lib/libstdc++.exp: Define effective target tzdb.
* testsuite/std/time/clock/file/members.cc: Check file_time
alias and file_clock::now() member.
* testsuite/std/time/clock/gps/1.cc: Likewise for gps_clock.
* testsuite/std/time/clock/tai/1.cc: Likewise for tai_clock.
* testsuite/std/time/syn_c++20.cc: Uncomment everything except
parse.
* testsuite/std/time/clock/utc/leap_second_info.cc: New test.
* testsuite/std/time/exceptions.cc: New test.
* testsuite/std/time/time_zone/get_info_local.cc: New test.
* testsuite/std/time/time_zone/get_info_sys.cc: New test.
* testsuite/std/time/time_zone/requirements.cc: New test.
* testsuite/std/time/tzdb/1.cc: New test.
* testsuite/std/time/tzdb/leap_seconds.cc: New test.
* testsuite/std/time/tzdb_list/1.cc: New test.
* testsuite/std/time/tzdb_list/requirements.cc: New test.
* testsuite/std/time/zoned_time/1.cc: New test.
* testsuite/std/time/zoned_time/custom.cc: New test.
* testsuite/std/time/zoned_time/deduction.cc: New test.
* testsuite/std/time/zoned_time/req_neg.cc: New test.
* testsuite/std/time/zoned_time/requirements.cc: New test.
* testsuite/std/time/zoned_traits.cc: New test.
Ian Lance Taylor [Wed, 21 Dec 2022 20:00:13 +0000 (12:00 -0800)]
compiler: remove unused fields
This avoids clang warnings:
gcc/go/gofrontend/escape.cc:1290:17: warning: private field 'fn_' is not used [-Wunused-private-field]
gcc/go/gofrontend/escape.cc:3478:19: warning: private field 'context_' is not used [-Wunused-private-field]
gcc/go/gofrontend/lex.h:564:15: warning: private field 'input_file_name_' is not used [-Wunused-private-field]
gcc/go/gofrontend/types.cc:5788:20: warning: private field 'call_' is not used [-Wunused-private-field]
gcc/go/gofrontend/wb.cc:206:9: warning: private field 'gogo_' is not used [-Wunused-private-field]
Path by Martin Liška.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/458975
Harald Anlauf [Thu, 22 Dec 2022 21:03:31 +0000 (22:03 +0100)]
Fortran: check for invalid uses of statement functions arguments [PR69604]
gcc/fortran/ChangeLog:
PR fortran/69604
* match.cc (chk_stmt_fcn_body): New function. Check for invalid uses
of statement functions arguments.
(gfc_match_st_function): Use above.
gcc/testsuite/ChangeLog:
PR fortran/69604
* gfortran.dg/statement_function_4.f90: New test.
Andrew Carlotti [Sun, 18 Dec 2022 02:52:02 +0000 (02:52 +0000)]
docs: Fix peephole paragraph ordering
The documentation for the DONE and FAIL macros was incorrectly inserted
between example code, and a remark attached to that example.
gcc/ChangeLog:
* doc/md.texi: Move example code remark next to it's code block.
Andrew Carlotti [Fri, 16 Dec 2022 15:14:35 +0000 (15:14 +0000)]
docs: Fix inconsistent example predicate name
It is unclear why the example C function was renamed to
`commutative_integer_operator` as part of
ec8e098d in 2004, while the
text and the example md were both left as `commutative_operator`. The
latter name appears to be more accurate, so revert the 2004 change.
gcc/ChangeLog:
* doc/md.texi: Fix inconsistent example name.
Andrew Carlotti [Fri, 16 Dec 2022 15:11:18 +0000 (15:11 +0000)]
docs: Link to correct section for constraint modifiers
gcc/ChangeLog:
* doc/md.texi: Fix incorrect pxref.
Richard Biener [Thu, 22 Dec 2022 14:51:46 +0000 (15:51 +0100)]
bootstrap/106482 - document minimal GCC version
There's no explicit mention of what GCC compiler supports C++11
and the cross compiler build requirement mentions GCC 4.8 but not
GCC 4.8.3 which is the earliest known version to not run into
C++11 implementation bugs. The following adds explicit wording.
PR bootstrap/106482
* doc/install.texi (ISO C++11 Compiler): Document GCC version
known to work.