]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
20 months agoRevert "libgcc: Specialize execute_cfa_program in DWARF unwinder for alignments"
Florian Weimer [Tue, 3 Jan 2023 15:47:31 +0000 (16:47 +0100)] 
Revert "libgcc: Specialize execute_cfa_program in DWARF unwinder for alignments"

This reverts commit cb775ecd6e437de8fdba9a3f173f3787e90e98f2.

20 months agotree-optimization/105043: Object Size Checking docs cleanup
Siddhesh Poyarekar [Thu, 15 Dec 2022 19:24:55 +0000 (14:24 -0500)] 
tree-optimization/105043: Object Size Checking docs cleanup

Break the _FORTIFY_SOURCE-specific builtins out into a separate
subsection from Object Size Checking built-ins and mention
_FORTIFY_SOURCE in there so that the link between the object size
checking builtins, the helper builtins (e.g. __builtin___memcpy_chk) and
_FORTIFY_SOURCE is clearer.

gcc/ChangeLog:

PR tree-optimization/105043
* doc/extend.texi (Object Size Checking): Split out into two
subsections and mention _FORTIFY_SOURCE.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
20 months agoImprove ix86_expand_int_movcc to allow condition (mask) sharing.
Roger Sayle [Tue, 3 Jan 2023 13:40:47 +0000 (13:40 +0000)] 
Improve ix86_expand_int_movcc to allow condition (mask) sharing.

This patch modifies the way that ix86_expand_int_movcc generates RTL,
to allow the condition mask to be shared/reused between multiple
conditional move sequences.  Such redundancy is common when RTL
if-conversion transforms non-trivial basic blocks.

As a motivating example, consider the new test case:

int a, b, c, d;
int foo(int x)
{
    if (x == 0) {
        a = 3;
        b = 1;
        c = 4;
        d = 1;
    } else {
        a = 5;
        b = 9;
        c = 2;
        d = 7;
    }
    return x;
}

This is currently compiled, with -O2, to:

foo: cmpl $1, %edi
movl %edi, %eax
sbbl %edi, %edi
andl $-2, %edi
addl $5, %edi
cmpl $1, %eax
sbbl %esi, %esi
movl %edi, a(%rip)
andl $-8, %esi
addl $9, %esi
cmpl $1, %eax
sbbl %ecx, %ecx
movl %esi, b(%rip)
andl $2, %ecx
addl $2, %ecx
cmpl $1, %eax
sbbl %edx, %edx
movl %ecx, c(%rip)
andl $-6, %edx
addl $7, %edx
movl %edx, d(%rip)
ret

Notice that the if-then-else blocks have been if-converted into four
conditional move sequences/assignments, each consisting of cmpl, sbbl,
andl and addl.  However, as the conditions are the same, the cmpl and
sbbl instructions used to generate the mask could be shared by CSE.

This patch enables that so that we now generate:

foo:    cmpl    $1, %edi
        movl    %edi, %eax
        sbbl    %edx, %edx
        movl    %edx, %edi
        movl    %edx, %esi
        movl    %edx, %ecx
        andl    $-6, %edx
        andl    $-2, %edi
        andl    $-8, %esi
        andl    $2, %ecx
        addl    $7, %edx
        addl    $5, %edi
        addl    $9, %esi
        addl    $2, %ecx
        movl    %edx, d(%rip)
        movl    %edi, a(%rip)
        movl    %esi, b(%rip)
        movl    %ecx, c(%rip)
        ret

Notice, the code now contains only a single cmpl and a single sbbl,
with result being shared (via movl).

2023-01-03  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_expand_int_movcc): Rewrite
RTL expansion to allow condition (mask) to be shared/reused,
by avoiding overwriting pseudos and adding REG_EQUAL notes.

gcc/testsuite/ChangeLog
* gcc.target/i386/cmov10.c: New test case.

20 months agoPR target/108229: A minor STV compute_convert_gain tweak on x86.
Roger Sayle [Tue, 3 Jan 2023 13:37:31 +0000 (13:37 +0000)] 
PR target/108229: A minor STV compute_convert_gain tweak on x86.

This patch addresses PR target/108229, which is a change in code
generation during the STV pass, due to the recently approved patch
to handle vec_select (reductions) in the vector unit.  The recent
change is innocent, but exposes a latent STV "gain" calculation issue
that is benign (or closely balanced) on most microarchitectures.

The issue is when STV considers converting PLUS with a MEM operand.

On TARGET_64BIT (m=1):
addq 24(%rdi), %rdx // 4 bytes
or with -m32 (m=2)
        addl    24(%esi), %eax // 3 bytes
        adcl    28(%esi), %edx // 3 bytes
is being converted by STV to
        vmovq   24(%rdi), %xmm5 // 5 bytes
        vpaddq  %xmm5, %xmm4, %xmm4 // 4 bytes

The current code in general_scalar_chain::compute_convert_gain
considers that scalar unit addition is replaced with a vector
unit addition (usually about the same cost), but doesn't consider
anything special about MEM operands, assuming that a scalar load
gains/costs nothing compared to a vector load.  We can allow the
backend slightly better fine tuning by including in the gain
calculation that m scalar loads are being replaced by one vector
load, and when optimizing for size including that we're increasing
code size (e.g. an extra vmovq instruction for a MEM operand).

This patch is a win on the CSiBE benchmark when compiled with -Os.

2023-01-03  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/108229
* config/i386/i386-features.cc
(general_scalar_chain::compute_convert_gain) <case PLUS>: Consider
the gain/cost of converting a MEM operand.

20 months agoexpr: Fix up store_expr into SUBREG_PROMOTED_* target [PR108264]
Jakub Jelinek [Tue, 3 Jan 2023 11:13:24 +0000 (12:13 +0100)] 
expr: Fix up store_expr into SUBREG_PROMOTED_* target [PR108264]

The following testcase ICEs on s390x-linux (e.g. with -march=z13).
The problem is that target is (subreg/s/u:SI (reg/v:DI 66 [ x+-4 ]) 4)
and we call convert_move from temp to the SUBREG_REG of that, expecting
to extend the value properly.  That works nicely if temp has some
scalar integer mode (or partial one), but ICEs when temp has V4QImode
on the assertion that from and to modes have the same bitsize.
store_expr generally allows say store from V4QI to SI target because
they have the same size and if temp is a CONST_INT, we already have code
to convert the constant properly, so the following patch just adds handling
of non-scalar integer modes by converting them to the mode of target
first before convert_move extends them.

2023-01-03  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/108264
* expr.cc (store_expr): For stores into SUBREG_PROMOTED_* targets
from source which doesn't have scalar integral mode first convert
it to outer_mode.

* gcc.dg/pr108264.c: New test.

20 months agocfgrtl: Don't try to redirect asm goto to EXIT [PR108263]
Jakub Jelinek [Tue, 3 Jan 2023 11:12:35 +0000 (12:12 +0100)] 
cfgrtl: Don't try to redirect asm goto to EXIT [PR108263]

The following testcase distilled from Linux kernel on ppc64le ICEs,
because fixup_reorder_chain sees a bb with a single fallthru edge
falling into a bb with simple return and decides to redirect
that fallthru edge to EXIT.  That is possible if the bb ending
in the fallthru edge doesn't end with a jump or ends with a normal
unconditional jump, but not when the bb ends with asm goto which can despite
a single fallthru have multiple labels to the fallthrough basic block.

The following patch makes sure we never try to redirect such cases to EXIT.

2023-01-03  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/108263
* cfgrtl.cc (fixup_reorder_chain): Avoid trying to redirect
asm goto to EXIT.

* gcc.dg/pr108263.c: New test.

20 months agoada: Fix unescaped quotes when combining fdiagnostics-format=json and gnatdJ
Ghjuvan Lacambre [Mon, 12 Dec 2022 13:54:47 +0000 (14:54 +0100)] 
ada: Fix unescaped quotes when combining fdiagnostics-format=json and gnatdJ

This commit fixes a small bug where GNAT would emit unescaped quotes in
its -fdiagnostics-format=json output when using -gnatdJ and emitting
messages about operator functions (e.g. "=").

gcc/ada/

* errout.adb (Write_JSON_Span): Escape subprogram name.

20 months agoada: output.adb: fix newline being inserted when buffer is full
Ghjuvan Lacambre [Thu, 8 Dec 2022 08:58:28 +0000 (09:58 +0100)] 
ada: output.adb: fix newline being inserted when buffer is full

Before this commit, when GNAT needed to emit lines longer than
the buffer, it accidentally inserted a newline in its output when
attempting to flush its buffer.

We fix this by using Flush_Buffer instead of Write_Eol in Write_Char.

gcc/ada/

* output.adb (Write_Buffer): Use Flush_Buffer instead of Write_Eol.

20 months agoada: Fix GNAT.Formatted_String's handling of real values
Ronan Desplanques [Fri, 9 Dec 2022 10:29:02 +0000 (11:29 +0100)] 
ada: Fix GNAT.Formatted_String's handling of real values

Before this patch, passing a width and a precision through
arguments with the "*" syntax always failed for real values in
GNAT.Formatted_String's routines.

gcc/ada/

* libgnat/g-forstr.adb (P_Flt_Format): Add "*" syntax handling.

20 months agoada: Fix parsing bug in GNAT.Formatted_String
Ronan Desplanques [Fri, 9 Dec 2022 10:29:02 +0000 (11:29 +0100)] 
ada: Fix parsing bug in GNAT.Formatted_String

Before this patch, GNAT.Formatted_String.Formatted_String failed to
handle format strings with two or more specifiers whose widths were
specified with the "*" syntax. This patch makes the parser
correctly reset its bits of state related to width and precision
parsing when needed.

gcc/ada/

* libgnat/g-forstr.adb (P_Int_Format): Fix parsing bug.

20 months agoada: Fix premature finalization of return temporary
Eric Botcazou [Fri, 9 Dec 2022 23:51:10 +0000 (00:51 +0100)] 
ada: Fix premature finalization of return temporary

Various parts of the expander and the code generator must have a consistent
view on which temporaries generated for return statements must be finalized
because they are regular temporaries, and which ones must not be since they
are allocated on the return stack directly.  The Is_Related_To_Func_Return
predicate is used for this purpose and needs to be tested consistently.

gcc/ada/

* exp_ch6.adb (Expand_Simple_Function_Return): Make sure that a
captured function call also verifies Is_Related_To_Func_Return.
Do not generate an actual subtype for special return objects.
* exp_util.ads (Is_Related_To_Func_Return): Add commentary.

20 months agoada: Fix format string parsing in GNAT.Formatted_String
Ronan Desplanques [Wed, 7 Dec 2022 16:37:21 +0000 (17:37 +0100)] 
ada: Fix format string parsing in GNAT.Formatted_String

Before this patch, format strings ending with "%%" (two consecutive
percent signs) caused GNAT.Formatted_String."-" to give the wrong
output, and cause the various GNAT.Formatted_String."&" to raise
exceptions with misleading error messages.

Also before this patch, a bug in GNAT.Formatted_String."-" caused
characters from the format string to be dropped. Calling
GNAT.Formatted_String."-" on an instance of
GNAT.Formatted_String.Formatted_String caused subsequent uses of
that instance to return wrong results.

In addition to fixing the parsing of format strings, this patch
centralizes the detection of format specifiers in a unique
procedure.

gcc/ada/

* libgnat/g-forstr.adb
(Advance_And_Accumulate_Until_Next_Specifier): New procedure.
("-"): Replace inline code with call to
Advance_And_Accumulate_Until_Next_Specifier.
(Next_Format): likewise.

20 months agoada: Make Apply_Discriminant_Check.Denotes_Explicit_Dereference more robust
Eric Botcazou [Thu, 8 Dec 2022 22:21:58 +0000 (23:21 +0100)] 
ada: Make Apply_Discriminant_Check.Denotes_Explicit_Dereference more robust

The predicate implements the rules of the language so it needs to cope with
constructs rewritten by the expander, in particular explicit dereferences
that the expander uses liberally for various purposes.

This change makes the detection of rewritten calls more robust and adds the
detection of rewritten return objects.

gcc/ada/

* checks.adb (Apply_Discriminant_Check.Denotes_Explicit_Dereference):
Return false for artificial dereferences generated by the expander.

20 months agoada: Fix calling convention of foreign functions returning limited type
Eric Botcazou [Thu, 8 Dec 2022 09:51:29 +0000 (10:51 +0100)] 
ada: Fix calling convention of foreign functions returning limited type

Such functions use neither Ada 2005's build-in-place mechanism nor Ada 95's
return-by-reference mechanism, but instead the common calling convention of
functions returning a nonlimited by-reference type.

gcc/ada/

* exp_ch6.adb (Is_Build_In_Place_Function): Adjust comment.
* sem_util.adb (Compute_Returns_By_Ref): Do not set Returns_By_Ref
on functions with foreign convention.

20 months agoada: Adapt frontend optimization for aggregate assignment
Marc Poulhiès [Fri, 25 Nov 2022 13:52:04 +0000 (14:52 +0100)] 
ada: Adapt frontend optimization for aggregate assignment

The frontend currently relies on gigi to use efficient assignment in
particular cases like:

  Some_Var.all := (others => (others => 0));

gigi would use memset to clear memory pointed to by Some_Var.

In the case of an access with a Designated_Storage_Model aspect with a Copy_To
procedure, memset can't be used directly. Instead of simply disabling this
frontend/gigi optimization and having the frontend emit several assignments, a
temporary is used (through the new Build_Assignment_With_Temporary): gigi can
still memset it, and this temporary is then copied into the original
target (and the regular storage model mechanism handles it).

gcc/ada/

* exp_aggr.adb (Build_Assignment_With_Temporary): New.
(Expand_Array_Aggregate): Tune backend optimization
and insert a temporary in the case of an access with
Designated_Storage_Model aspect.
(Convert_Array_Aggr_In_Allocator): Likewise.

20 months agoada: Another small adjustment to special resolution of membership test
Eric Botcazou [Wed, 7 Dec 2022 16:54:37 +0000 (17:54 +0100)] 
ada: Another small adjustment to special resolution of membership test

This goes back to the original implementation but keeps the special size
test with universal_integer to cope with its limited range.

gcc/ada/

* sem_res.adb (Resolve_Membership_Op): Adjust again latest change.

20 months agoada: Make Sem_Util.Is_Aliased_View predicate more robust
Eric Botcazou [Wed, 7 Dec 2022 16:26:27 +0000 (17:26 +0100)] 
ada: Make Sem_Util.Is_Aliased_View predicate more robust

The predicate implements the rules of the language so it needs to cope with
constructs rewritten by the expander, in particular explicit dereferences
that the expander uses liberally for various purposes.

This change makes the detection of rewritten calls more robust, plugging an
existing loophole for specific objects and exposing a missing propagation of
the Is_Aliased flag for certain build-in-place objects, as well as adds the
detection of rewritten return objects.

It also contains a small enhancement to Set_Debug_Info_Defining_Id aimed at
making it easier to debug the generated code by means of -gnatD.

gcc/ada/

* sem_util.ads (Set_Debug_Info_Defining_Id): Adjust comment.
* sem_util.adb (Is_Aliased_View) <N_Explicit_Dereference>: Return
false for more artificial dereferences generated by the expander.
(Set_Debug_Info_Defining_Id): Set Debug_Info_Needed unconditionally
in -gnatD mode.
* exp_ch6.adb (Replace_Renaming_Declaration_Id): Also preserve the
Is_Aliased flag.

20 months agoada: GNAT UGN: Adjust wording in "Platform-specific Information" chapter
Joel Brobecker [Tue, 6 Dec 2022 05:21:57 +0000 (09:21 +0400)] 
ada: GNAT UGN: Adjust wording in "Platform-specific Information" chapter

The wording of the introduction paragraph specified an incomplete
list of OSes. Rather than trying to update the list, this commit
changes the text to make it more general. For those parts of
this chapter which only apply to specific OSes, the documentation
is written in a way that it is clear which OS it applies to.

gcc/ada/

* doc/gnat_ugn/platform_specific_information.rst
(_Platform_Specific_Information): Minor rewording of intro text.
* gnat_ugn.texi: Regenerate.

20 months agoada: Fix detection of function calls in object declarations
Eric Botcazou [Tue, 6 Dec 2022 23:56:43 +0000 (00:56 +0100)] 
ada: Fix detection of function calls in object declarations

The current code has relied on Original_Node to detect rewritten function
calls in object declarations but that's not robust enough in the presence
of function calls written in object notation.

gcc/ada/

* exp_util.ads (Is_Captured_Function_Call): Declare.
* exp_util.adb (Is_Captured_Function_Call): New predicate.
* exp_ch3.adb (Expand_N_Object_Declaration): Use it to detect a
rewritten function call as the initializing expression.
* exp_ch6.adb (Expand_Simple_Function_Return): Use it to detect a
rewritten function call as the returned expression.

20 months agoada: Simplify [Small_]Integer_Type_For
Bob Duff [Tue, 6 Dec 2022 16:37:27 +0000 (11:37 -0500)] 
ada: Simplify [Small_]Integer_Type_For

Make Small_Integer_Type_For call Integer_Type_For,
so they share most of the code.

Remove Standard_Long_Integer from consideration,
because that's different on different machines (32- or 64-bit).
Standard_Integer or Standard_Long_Long_Integer will be
chosen.

gcc/ada/

* exp_util.adb (Integer_Type_For): Assertion and comment.
(Small_Integer_Type_For): Remove some code and call
Integer_Type_For instead.
* sem_util.ads (Rep_To_Pos_Flag): Improve comments. "Standard_..."
seems overly pedantic here.
* exp_attr.adb (Succ, Pred): Clean up: make the code as similar as
possible.
* exp_ch4.adb: Minor: named notation.

20 months agoada: Cannot reference ghost entity in class-wide precondition
Javier Miranda [Mon, 28 Nov 2022 09:15:54 +0000 (09:15 +0000)] 
ada: Cannot reference ghost entity in class-wide precondition

gcc/ada/

* ghost.adb (Is_OK_Declaration): A reference to a Ghost entity may
appear within the class-wide precondition of a helper subprogram.
This context is treated as suitable because it was already
verified when we were analyzing the original class-wide
precondition.

20 months agoada: Fix support of Default_Component_Value aspect on derived types
Eric Botcazou [Mon, 5 Dec 2022 21:31:50 +0000 (22:31 +0100)] 
ada: Fix support of Default_Component_Value aspect on derived types

The support of the Default_Component_Value aspect on derived constrained
array types is broken because of a couple of issues: 1) the derived types
incorrectly inherit the initialization procedure of the ancestor types
and 2) the propagation of the aspect does not work for constrained array
types (unlike for unconstrained array types).

gcc/ada/

* exp_tss.adb (Base_Init_Proc): Do not return the Init_Proc of the
ancestor type for a derived array type.
* sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Factor out the
common processing done on representation items.
For Default_Component_Value and Default_Value, look into the first
subtype to find out the representation items.

20 months agoDaily bump.
GCC Administrator [Tue, 3 Jan 2023 00:17:09 +0000 (00:17 +0000)] 
Daily bump.

20 months agoi386: correct division modeling in lujiazui.md
Alexander Monakov [Fri, 9 Dec 2022 17:47:55 +0000 (20:47 +0300)] 
i386: correct division modeling in lujiazui.md

Model the divider in Lujiazui processors as a separate automaton to
significantly reduce the overall model size. This should also result
in improved accuracy, as pipe 0 should be able to accept new
instructions while the divider is occupied.

It is unclear why integer divisions are modeled as if pipes 0-3 are all
occupied. I've opted to keep a single-cycle reservation of all four
pipes together, so GCC should continue trying to pack instructions
around a division accordingly.

Currently top three symbols in insn-automata.o are:

106102 r lujiazui_core_check
106102 r lujiazui_core_transitions
196123 r lujiazui_core_min_issue_delay

This patch shrinks all lujiazui tables to:

3 r lujiazui_decoder_min_issue_delay
20 r lujiazui_decoder_transitions
32 r lujiazui_agu_min_issue_delay
126 r lujiazui_agu_transitions
304 r lujiazui_div_base
352 r lujiazui_div_check
352 r lujiazui_div_transitions
1152 r lujiazui_core_min_issue_delay
1592 r lujiazui_agu_translate
1592 r lujiazui_core_translate
1592 r lujiazui_decoder_translate
1592 r lujiazui_div_translate
3952 r lujiazui_div_min_issue_delay
9216 r lujiazui_core_transitions

This continues the work on reducing i386 insn-automata.o size started
with similar fixes for division and multiplication instructions in
znver.md.

gcc/ChangeLog:

PR target/87832
* config/i386/lujiazui.md (lujiazui_div): New automaton.
(lua_div): New unit.
(lua_idiv_qi): Correct unit in the reservation.
(lua_idiv_qi_load): Ditto.
(lua_idiv_hi): Ditto.
(lua_idiv_hi_load): Ditto.
(lua_idiv_si): Ditto.
(lua_idiv_si_load): Ditto.
(lua_idiv_di): Ditto.
(lua_idiv_di_load): Ditto.
(lua_fdiv_SF): Ditto.
(lua_fdiv_SF_load): Ditto.
(lua_fdiv_DF): Ditto.
(lua_fdiv_DF_load): Ditto.
(lua_fdiv_XF): Ditto.
(lua_fdiv_XF_load): Ditto.
(lua_ssediv_SF): Ditto.
(lua_ssediv_load_SF): Ditto.
(lua_ssediv_V4SF): Ditto.
(lua_ssediv_load_V4SF): Ditto.
(lua_ssediv_V8SF): Ditto.
(lua_ssediv_load_V8SF): Ditto.
(lua_ssediv_SD): Ditto.
(lua_ssediv_load_SD): Ditto.
(lua_ssediv_V2DF): Ditto.
(lua_ssediv_load_V2DF): Ditto.
(lua_ssediv_V4DF): Ditto.
(lua_ssediv_load_V4DF): Ditto.

20 months agolibgcc: Specialize execute_cfa_program in DWARF unwinder for alignments
Florian Weimer [Mon, 2 Jan 2023 15:18:02 +0000 (16:18 +0100)] 
libgcc: Specialize execute_cfa_program in DWARF unwinder for alignments

The parameters fs->data_align and fs->code_align always have fixed
values for a particular target in GCC-generated code.  Specialize
execute_cfa_program for these values, to avoid multiplications.

gcc/c-family/

* c-cppbuiltin.cc (c_cpp_builtins): Define
__LIBGCC_DWARF_CIE_DATA_ALIGNMENT__.

libgcc/

* unwind-dw2-execute_cfa.h: New file.  Extracted from
the execute_cfa_program function in unwind-dw2.c.
* unwind-dw2.c (execute_cfa_program_generic): New function.
(execute_cfa_program_specialized): Likewise.
(execute_cfa_program): Call execute_cfa_program_specialized
or execute_cfa_program_generic, as appropriate.

20 months agoDefine __LIBGCC_DWARF_REG_SIZES_CONSTANT__ if DWARF register size is constant
Florian Weimer [Mon, 2 Jan 2023 15:18:02 +0000 (16:18 +0100)] 
Define __LIBGCC_DWARF_REG_SIZES_CONSTANT__ if DWARF register size is constant

And use that to speed up the libgcc unwinder.

gcc/

* debug.h (dwarf_reg_sizes_constant): Declare.
* dwarf2cfi.cc (dwarf_reg_sizes_constant): New function.

gcc/c-family/

* c-cppbuiltin.cc (__LIBGCC_DWARF_REG_SIZES_CONSTANT__):
Define if constant is known.

libgcc/

* unwind-dw2.c (dwarf_reg_size): New function.
(_Unwind_GetGR, _Unwind_SetGR, _Unwind_SetGRPtr)
(_Unwind_SetSpColumn, uw_install_context_1): Use it.
(uw_init_context_1): Do not initialize dwarf_reg_size_table
if not in use.

20 months agoCompute a table of DWARF register sizes at compile
Florian Weimer [Mon, 2 Jan 2023 15:18:02 +0000 (16:18 +0100)] 
Compute a table of DWARF register sizes at compile

The sizes are compile-time constants.  Create a vector with them,
so that they can be inspected at compile time.

gcc/

* dwarf2cfi.cc (init_return_column_size): Remove.
(init_one_dwarf_reg_size): Adjust.
(generate_dwarf_reg_sizes): New function.  Extracted
from expand_builtin_init_dwarf_reg_sizes.
(expand_builtin_init_dwarf_reg_sizes): Call
generate_dwarf_reg_sizes.
* target.def (init_dwarf_reg_sizes_extra): Adjust
hook signature.
* config/msp430/msp430.cc
(msp430_init_dwarf_reg_sizes_extra): Adjust.
* config/rs6000/rs6000.cc
(rs6000_init_dwarf_reg_sizes_extra): Likewise.
* doc/tm.texi: Update.

20 months agoAda,Darwin: Do not link libgcc statically on Darwin 8 and 9 [PR108202].
Iain Sandoe [Thu, 22 Dec 2022 17:32:59 +0000 (17:32 +0000)] 
Ada,Darwin: Do not link libgcc statically on Darwin 8 and 9 [PR108202].

Normally, GCC executables are built with -static-libstdc++ -static-libgcc
on Darwin.  This is fine in most cases, because GCC executables typically
do no use exceptions.   However gnat1 does use exceptions and also pulls
in system libraries that are linked against the installed shared libgcc
which contains the system unwinder.  This means that gnat1 effectively has
two unwinder instances (which does not work reliably since the unwinders
have global state).

A recent change in the initialization of FDEs has made this a hard error
now on Darwin versions (8 and 9) with libgcc installed in /usr/lib (gnat1
now hangs when an exception is thrown).

The solution is to link libgcc dynamically, picking up the installed
system version.  To do this we strip -static-libgcc from the link flags.

PR ada/108202

gcc/ada/ChangeLog:

* gcc-interface/Make-lang.in (GCC_LINKERFLAGS, GCC_LDFLAGS):
Versions of ALL_LINKERFLAGS, LDFLAGS with -Werror and
-static-libgcc filtered out for Darwin8 and 9 (-Werror is filtered
out for other hosts).

20 months agoUpdate copyright years.
Jakub Jelinek [Mon, 2 Jan 2023 08:46:13 +0000 (09:46 +0100)] 
Update copyright years.

20 months agoUpdate copyright years.
Jakub Jelinek [Mon, 2 Jan 2023 08:37:43 +0000 (09:37 +0100)] 
Update copyright years.

20 months agoUpdate Copyright year in ChangeLog files
Jakub Jelinek [Mon, 2 Jan 2023 08:36:59 +0000 (09:36 +0100)] 
Update Copyright year in ChangeLog files

2022 -> 2023

20 months agoUpdate copyright dates.
Jakub Jelinek [Mon, 2 Jan 2023 08:26:59 +0000 (09:26 +0100)] 
Update copyright dates.

Manual part of copyright year updates.

2023-01-02  Jakub Jelinek  <jakub@redhat.com>

gcc/
* gcc.cc (process_command): Update copyright notice dates.
* gcov-dump.cc (print_version): Ditto.
* gcov.cc (print_version): Ditto.
* gcov-tool.cc (print_version): Ditto.
* gengtype.cc (create_file): Ditto.
* doc/cpp.texi: Bump @copying's copyright year.
* doc/cppinternals.texi: Ditto.
* doc/gcc.texi: Ditto.
* doc/gccint.texi: Ditto.
* doc/gcov.texi: Ditto.
* doc/install.texi: Ditto.
* doc/invoke.texi: Ditto.
gcc/ada/
* gnat_ugn.texi: Bump @copying's copyright year.
* gnat_rm.texi: Likewise.
gcc/d/
* gdc.texi: Bump @copyrights-d year.
gcc/fortran/
* gfortranspec.cc (lang_specific_driver): Update copyright notice
dates.
* gfc-internals.texi: Bump @copying's copyright year.
* gfortran.texi: Ditto.
* intrinsic.texi: Ditto.
* invoke.texi: Ditto.
gcc/go/
* gccgo.texi: Bump @copyrights-go year.
libgomp/
* libgomp.texi: Bump @copying's copyright year.
libitm/
* libitm.texi: Bump @copying's copyright year.
libquadmath/
* libquadmath.texi: Bump @copying's copyright year.

20 months agoUpdate Copyright year in ChangeLog files
Jakub Jelinek [Mon, 2 Jan 2023 08:23:36 +0000 (09:23 +0100)] 
Update Copyright year in ChangeLog files

2022 -> 2023

20 months agoDaily bump.
GCC Administrator [Mon, 2 Jan 2023 00:16:34 +0000 (00:16 +0000)] 
Daily bump.

20 months agoAdd post-reload splitter for extendditi2 on x86_64.
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.

20 months agoRotate ChangeLog files.
Jakub Jelinek [Sun, 1 Jan 2023 15:20:13 +0000 (16:20 +0100)] 
Rotate ChangeLog files.

Rotate ChangeLog files for ChangeLogs with yearly cadence.

20 months agomodula2: Ensure that module registration constructors are 'extern' [PR108183].
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>
20 months agoDaily bump.
GCC Administrator [Sun, 1 Jan 2023 00:17:17 +0000 (00:17 +0000)] 
Daily bump.

20 months agoconfigure: Do not build the ununsed libffi shared library.
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.

20 months agomodula-2,libgm2: Add undefined, dynamic_lookup to m2 libs links.
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.

20 months agomodula-2: Fix building the plugin for Darwin [PR107612].
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>
20 months agoDaily bump.
GCC Administrator [Sat, 31 Dec 2022 00:17:04 +0000 (00:17 +0000)] 
Daily bump.

20 months agocheck hash table insertions
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.

20 months agoregressions tests for PR103770
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.

20 months agoFix memory constraint on MVE v[ld/st][2/4] instructions [PR107714]
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.

20 months agoModify checks to avoid referencing NULL pointer.
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.

20 months agoDaily bump.
GCC Administrator [Fri, 30 Dec 2022 00:16:36 +0000 (00:16 +0000)] 
Daily bump.

20 months agoprevent hash set/map insertion of deleted entries
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.

20 months agoparloops: don't request insert that won't be completed
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.

20 months agohash-map: reject empty-looking insertions
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.

20 months agohash set: reject attempts to add empty values
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.

20 months agoada: don't map NULL decl to locus
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.

20 months agolto: drop dummy partition mapping
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.

20 months ago[C++] constexpr: request insert iff depth is ok
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.

20 months agotm: complete tm_restart insertion
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.

20 months agopostreload-gcse: no insert on mere lookup
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.

20 months agotree-inline decl_map: skip mapping result's NULL default def
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.

20 months agossa-loop-niter: skip caching of null operands
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.

20 months ago[C++] constraint: insert norm entry once
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.

20 months agotree-inline decl_map: skip mapping NULL to itself
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.

20 months agovarpool: do not add NULL vnodes to referenced
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.

20 months agoscoped tables: insert before further lookups
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.

20 months agogcc: xtensa: use GP_RETURN_* instead of magic constant
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.

20 months agoxtensa: Check DF availability before use
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.

20 months agoDaily bump.
GCC Administrator [Thu, 29 Dec 2022 00:17:39 +0000 (00:17 +0000)] 
Daily bump.

20 months agoProvide zero_extend versions/variants of several patterns on x86.
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.

20 months agoUse ix86_expand_clear in ix86_split_ashl.
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.

20 months agocontrib: add contrib to update-copyright.py script
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.

20 months agostrlen: do not use cond_expr for boundaries
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.

20 months agoRISC-V: Return const ref. for vl_vtype_info::get_avl_info
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.

20 months agoDaily bump.
GCC Administrator [Wed, 28 Dec 2022 00:17:27 +0000 (00:17 +0000)] 
Daily bump.

20 months agoCommit right version of last patch (missing modes)
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

20 months agoRISC-V: Produce better code with complex constants [PR95632] [PR106602]
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.

20 months agoriscv: Restructure callee-saved register save/restore code
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>
20 months agoriscv: attr: Synchronize comments with code
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>
20 months agoFixed typo in RISCV
jinma [Tue, 27 Dec 2022 17:30:46 +0000 (10:30 -0700)] 
Fixed typo in RISCV

gcc/ChangeLog:

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

20 months agogcc: fix Windows target binutils secrel detection
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>
20 months agogcc: xtensa: use define_c_enums instead of define_constants
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.

20 months agoxtensa: Generate density instructions in set_frame_ptr
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.

20 months agoxtensa: Change GP_RETURN{,_REG_COUNT} to GP_RETURN_{FIRST,LAST}
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.

20 months agoxtensa: Clean up xtensa_expand_prologue
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.

20 months agoxtensa: Tabify, and trim trailing spaces
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.

20 months agoRISC-V: Add riscv_vector.h wrapper
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.

20 months agoRISC-V: Fix ICE of visiting non-existing block in CFG.
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.

20 months agoRISC-V: Fix ICE for avl_info deprecated copy and pp_print error.
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.

20 months agors6000: Rework option -mpowerpc64 handling [PR106680]
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>

20 months agoDaily bump.
GCC Administrator [Tue, 27 Dec 2022 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

21 months agotestsuite: fix analyzer failures on AIX
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.

21 months agox86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.
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.

21 months agoDaily bump.
GCC Administrator [Mon, 26 Dec 2022 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

21 months agoUse movss/movsd to implement V4SI/V2DI VEC_PERM on x86.
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.

21 months agolibgcc: fix gfortran build on Windows
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>
21 months agoDaily bump.
GCC Administrator [Sun, 25 Dec 2022 00:16:57 +0000 (00:16 +0000)] 
Daily bump.

21 months ago[Committed] Tweak new gcc.target/i386/pr107548-1.c for -march=cascadelake.
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.

21 months agolibstdc++: Test for tzdata.zi before fallback version files.
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.

21 months agolibstdc++, testsuite: Correct an init.
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.

21 months agolibgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib.
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.

21 months agoDaily bump.
GCC Administrator [Sat, 24 Dec 2022 00:17:19 +0000 (00:17 +0000)] 
Daily bump.

21 months agoReimplement GNU threads library on native Windows
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>
21 months agoFortran: incorrect array bounds when bound intrinsic used in decl [PR108131]
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.