platform/upstream/gcc.git
19 months agotree-inline: Fix up multiversioning with vector arguments [PR105554]
Jakub Jelinek [Fri, 17 Mar 2023 17:59:56 +0000 (18:59 +0100)]
tree-inline: Fix up multiversioning with vector arguments [PR105554]

The following testcase ICEs, because we call tree_function_versioning from
old_decl which has target attributes not supporting V4DImode and so
DECL_MODE of DECL_ARGUMENTS is BLKmode, while new_decl supports those.
tree_function_versioning initially copies DECL_RESULT and DECL_ARGUMENTS
from old_decl to new_decl, then calls initialize_cfun to create cfun
and only when the cfun is created it can later actually remap_decl
DECL_RESULT and DECL_ARGUMENTS etc.
The problem is that initialize_cfun -> push_struct_function ->
allocate_struct_function calls relayout_decl on DECL_RESULT and
DECL_ARGUMENTS, which clobbers DECL_MODE of old_decl and we then ICE because
of it.
In particular, allocate_struct_function does:
      if (!abstract_p)
        {
          /* Now that we have activated any function-specific attributes
             that might affect layout, particularly vector modes, relayout
             each of the parameters and the result.  */
          relayout_decl (result);
          for (tree parm = DECL_ARGUMENTS (fndecl); parm;
               parm = DECL_CHAIN (parm))
            relayout_decl (parm);

          /* Similarly relayout the function decl.  */
          targetm.target_option.relayout_function (fndecl);
        }

      if (!abstract_p && aggregate_value_p (result, fndecl))
        {
 #ifdef PCC_STATIC_STRUCT_RETURN
          cfun->returns_pcc_struct = 1;
 #endif
          cfun->returns_struct = 1;
        }
Now, in the case of tree_function_versioning, I believe all that we need
from these is possibly the
targetm.target_option.relayout_function (fndecl);
call (arm only), we will remap DECL_RESULT and DECL_ARGUMENTS later on
and copy_decl_for_dup_finish in that case will handle all we need:
  /* For vector typed decls make sure to update DECL_MODE according
     to the new function context.  */
  if (VECTOR_TYPE_P (TREE_TYPE (copy)))
    SET_DECL_MODE (copy, TYPE_MODE (TREE_TYPE (copy)));
We don't need the cfun->returns_*struct either, because we override it
in initialize_cfun a few lines later:
  /* Copy items we preserve during cloning.  */
...
  cfun->returns_struct = src_cfun->returns_struct;
  cfun->returns_pcc_struct = src_cfun->returns_pcc_struct;

So, to avoid the clobbering of DECL_RESULT/DECL_ARGUMENTS of old_decl,
the following patch arranges allocate_struct_function to be called with
abstract_p true and calls targetm.target_option.relayout_function (fndecl);
by hand.

The removal of DECL_RESULT/DECL_ARGUMENTS copying at the start of
initialize_cfun is removed because the only caller -
tree_function_versioning, does that unconditionally before.

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

PR target/105554
* function.h (push_struct_function): Add ABSTRACT_P argument defaulted
to false.
* function.cc (push_struct_function): Add ABSTRACT_P argument, pass it
to allocate_struct_function instead of false.
* tree-inline.cc (initialize_cfun): Don't copy DECL_ARGUMENTS
nor DECL_RESULT here.  Pass true as ABSTRACT_P to
push_struct_function.  Call targetm.target_option.relayout_function
after it.
(tree_function_versioning): Formatting fix.

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

19 months agoc, ubsan: Instrument even shortened divisions [PR109151]
Jakub Jelinek [Fri, 17 Mar 2023 15:10:14 +0000 (16:10 +0100)]
c, ubsan: Instrument even shortened divisions [PR109151]

On the following testcase, the C FE decides to shorten the division because
it has a guarantee that INT_MIN / -1 division won't be encountered, the
first operand is widened from narrower unsigned and/or the second operand is
a constant other than all ones (in this case both are true).
The problem is that the narrower type in this case is _Bool and
ubsan_instrument_division only instruments it if op0's type is INTEGER_TYPE
or REAL_TYPE.  Strangely this doesn't happen in C++ FE.
Anyway, we only shorten divisions if the INT_MIN / -1 case is impossible,
so I think we should be fine even with -fstrict-enums in C++ in case it
shortened to ENUMERAL_TYPEs.

The following patch just instruments those on the ubsan_instrument_division
side.  Perhaps only the first hunk and testcase might be needed because
we shouldn't shorten if the other case could be triggered.

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

PR c/109151
* c-ubsan.cc (ubsan_instrument_division): Handle all scalar integral
types rather than just INTEGER_TYPE.

* c-c++-common/ubsan/div-by-zero-8.c: New test.

19 months agoPR modula2/109032 - message 'compiler checks to force' is too complicated
Gaius Mulley [Fri, 17 Mar 2023 14:32:22 +0000 (14:32 +0000)]
PR modula2/109032 - message 'compiler checks to force' is too complicated

Correct typos and improve the descriptions of command line options.
Improve comments in gm2-gcc/m2expr.cc.

gcc/m2/ChangeLog:

PR modula2/109032
* gm2-gcc/m2expr.cc: Correct ? : order in comments.
(m2expr_BuildDivM2): Improve comment.
* lang.opt: Improve option descriptions.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoLRA: Implement combining secondary memory reload and original insn
Vladimir N. Makarov [Fri, 17 Mar 2023 12:58:58 +0000 (08:58 -0400)]
LRA: Implement combining secondary memory reload and original insn

LRA creates secondary memory reload insns but do not try to combine it
with the original insn.  This patch implements a simple insn combining
for such cases in LRA.

        PR rtl-optimization/109052

gcc/ChangeLog:

* lra-constraints.cc: Include hooks.h.
(combine_reload_insn): New function.
(lra_constraints): Call it.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr109052.c: New.

19 months agoPR modula2/109102 Wrong quotes in diagnostic
Gaius Mulley [Fri, 17 Mar 2023 12:47:06 +0000 (12:47 +0000)]
PR modula2/109102 Wrong quotes in diagnostic

The backtick and single quote should be replaced with %< and %> or
%qs.

gcc/m2/ChangeLog:

PR modula2/109102
* gm2-gcc/m2builtins.cc (ASSERT): Change format specifier to
use %qs rather than quotes.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoRISC-V: Handle undef for vector mask patterns
Ju-Zhe Zhong [Mon, 13 Mar 2023 07:52:01 +0000 (15:52 +0800)]
RISC-V: Handle undef for vector mask patterns

Add new instruction pattern for setting vector mask to undefine value,
also merge undef and non-undef ternary operation pattern like MAC operations to
single pattern.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (legitimize_move): Allow undef value
as legitimate value.
* config/riscv/riscv-vector-builtins.cc
(function_expander::use_ternop_insn): Fix bugs of ternary intrinsic.
(function_expander::use_widen_ternop_insn): Ditto.
* config/riscv/vector.md (@vundefined<mode>): New pattern.
(pred_mul_<optab><mode>_undef_merge): Remove.
(*pred_mul_<optab><mode>_undef_merge_scalar): Ditto.
(*pred_mul_<optab><mode>_undef_merge_extended_scalar): Ditto.
(pred_neg_mul_<optab><mode>_undef_merge): Ditto.
(*pred_neg_mul_<optab><mode>_undef_merge_scalar): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/binop_vv_constraint-4.c: Adapt the test.
* gcc.target/riscv/rvv/base/binop_vv_constraint-6.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-127.c: Ditto.
* g++.target/riscv/rvv/base/bug-1.C: New test.
* gcc.target/riscv/rvv/base/bug-2.c: New test.

Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Co-authored-by: kito-cheng <kito.cheng@sifive.com>
19 months agoRISC-V: Use reg_or_subregno to check regno [PR109092]
Ju-Zhe Zhong [Mon, 13 Mar 2023 14:17:57 +0000 (22:17 +0800)]
RISC-V: Use reg_or_subregno to check regno [PR109092]

gcc/ChangeLog:

PR target/109092
* config/riscv/riscv.md: Fix subreg bug.

19 months agotestsuite: Fix up forwprop-39.c testcase [PR109145]
Jakub Jelinek [Fri, 17 Mar 2023 08:58:08 +0000 (09:58 +0100)]
testsuite: Fix up forwprop-39.c testcase [PR109145]

As written in the PR, newlib headers aren't C11 compliant in that they
don't define CMPLXF macro, and glibc before 2.16 doesn't define that
either.  I think it is easier to use __builtin_complex directly, over
another patch which keeps including complex.h but defines CMPLXF if it
isn't defined, we want to test how forwprop behaves rather than what
complex.h defines or doesn't define.

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

PR testsuite/109145
* gcc.dg/tree-ssa/forwprop-39.c: Remove -std=c11 from dg-options.
Don't include complex.h.
(foo): Use __builtin_complex rather than CMPLXF.

19 months agoopenmp: Fix up handling of doacross loops with noreturn body in loops [PR108685]
Jakub Jelinek [Fri, 17 Mar 2023 07:46:28 +0000 (08:46 +0100)]
openmp: Fix up handling of doacross loops with noreturn body in loops [PR108685]

The following patch fixes an ICE with doacross loops which have a single entry
no exit body, at least one of the ordered > collapse loops isn't guaranteed to
have at least one iteration and the whole doacross loop is inside some other loop.
The OpenMP constructs aren't represented by struct loop until the omp expansions,
so for a normal doacross loop which doesn't have a noreturn body the entry_bb
with the GOMP_FOR statement and the first bb of the body typically have the
same loop_father, and if the doacross loop isn't inside of some other loop
and the body is noreturn as well, both are part of loop 0.  The problematic
case is when the entry_bb is inside of some deeper loop, but the body, because
it falls through into EXIT, has loop 0 as loop_father.  l0_bb is created by
splitting the entry_bb fallthru edge into l1_bb, and because the two basic blocks
have different loop_father, a common loop is found for those (which is loop 0).
Now, if the doacross loop has collapse == ordered or all the ordered > collapse
loops are guaranteed to iterate at least once, all is still fine, because all
enter the l1_bb (body), which doesn't return and so doesn't loop further either.
But, if one of those loops could loop 0 times, the user written body wouldn't be
reached at all, so unlike the expectations the whole construct actually wouldn't
be noreturn if entry_bb is encountered and decides to handle at least one
iteration.

In this case, we need to fix up, move the l0_bb into the same loop as entry_bb
(initially) and for the extra added loops put them as children of that same
loop, rather than of loop 0.

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

PR middle-end/108685
* omp-expand.cc (expand_omp_for_ordered_loops): Add L0_BB argument,
use its loop_father rather than BODY_BB's loop_father.
(expand_omp_for_generic): Adjust expand_omp_for_ordered_loops caller.
If broken_loop with ordered > collapse and at least one of those
extra loops aren't guaranteed to have at least one iteration, change
l0_bb's loop_father to entry_bb's loop_father.  Set cont_bb's
loop_father to l0_bb's loop_father rather than l1_bb's.

* c-c++-common/gomp/doacross-8.c: New test.

19 months agogdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634]
Jakub Jelinek [Fri, 17 Mar 2023 07:44:19 +0000 (08:44 +0100)]
gdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634]

On Mon, Mar 13, 2023 at 04:15:12PM -0400, Jason Merrill wrote:
> The r13-6577 change to use tree_code_type_tmpl in earlier C++ dialects broke
> gdbhooks, which expects tree_code_type to always be available.  I considered
> trying to make gdbhooks more robust, but it seemed simpler to define
> tree_code_type as a reference to the template.

As I said earlier, I think it is better to tweak gdbhooks.

The following patch does that, I've tested it now both with gcc 12 and
older gcc as system compiler and the patch fixed the latter while keeping
the former working as before.

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

PR plugins/108634
* gdbhooks.py (TreePrinter.to_string): Wrap
gdb.parse_and_eval('tree_code_type') in a try block, parse
and eval 'tree_code_type_tmpl<0>::tree_code_type' instead if it
raises exception.  Update comments for the recent tree_code_type
changes.

19 months agod: Merge upstream dmd, druntime 5f7552bb28, phobos 67a47cf39.
Iain Buclaw [Thu, 16 Mar 2023 23:27:52 +0000 (00:27 +0100)]
d: Merge upstream dmd, druntime 5f7552bb28, phobos 67a47cf39.

D front-end changes:

- Import dmd v2.103.0-rc.1.

D runtime changes:

- Import druntime v2.103.0-rc.1.

Phobos changes:

- Import phobos v2.103.0-rc.1.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 5f7552bb28.
* dmd/VERSION: Bump version to v2.103.0-rc.1.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 5f7552bb28.
* src/MERGE: Merge upstream phobos 67a47cf39.

19 months agoDocs: Fix formatting issues in BPF built-ins documentation.
Sandra Loosemore [Thu, 16 Mar 2023 21:07:18 +0000 (21:07 +0000)]
Docs: Fix formatting issues in BPF built-ins documentation.

gcc/ChangeLog:
* doc/extend.texi (BPF Built-in Functions): Fix numerous markup
issues.  Add more line breaks to example so it doesn't overflow
the margins.

19 months agoDocs: Fix some too-long lines in Texinfo manual.
Sandra Loosemore [Thu, 16 Mar 2023 21:05:53 +0000 (21:05 +0000)]
Docs: Fix some too-long lines in Texinfo manual.

gcc/ChangeLog:
* doc/extend.texi (Common Function Attributes) <access>: Fix bad
line breaks in examples.
<malloc>: Fix bad line breaks in running text, also copy-edit
for consistency.
(Extended Asm) <Generic Operand Modifiers>: Fix @multitable width.
* doc/invoke.texi (Option Summary) <Developer Options>: Fix misplaced
@gol.
(C++ Dialect Options) <-fcontracts>: Add line break in example.
<-Wctad-maybe-unsupported>: Likewise.
<-Winvalid-constexpr>: Likewise.
(Warning Options) <-Wdangling-pointer>: Likewise.
<-Winterference-size>: Likewise.
<-Wvla-parameter>: Likewise.
(Static Analyzer Options): Fix bad line breaks in running text,
plus add some missing markup.
(Optimize Options) <openacc-privatization>: Fix more bad line
breaks in running text.

19 months ago[modula2] Bugfix local symbol names for -fm2-whole-program
Gaius Mulley [Fri, 17 Mar 2023 00:23:02 +0000 (00:23 +0000)]
[modula2] Bugfix local symbol names for -fm2-whole-program

Local symbols must be prefixed by the modulename if
-fm2-whole-program is used to avoid a name clash.

gcc/m2/ChangeLog:

* gm2-compiler/M2AsmUtil.mod (SymNeedsModulePrefix):
Re-implemented.
* gm2-libs/SysStorage.mod (enableTrace): Disable tracing.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoDaily bump.
GCC Administrator [Fri, 17 Mar 2023 00:17:03 +0000 (00:17 +0000)]
Daily bump.

19 months agomaintainer-scripts: Add Modula-2 manual to update_web_docs_git
Gaius Mulley [Thu, 16 Mar 2023 23:08:20 +0000 (00:08 +0100)]
maintainer-scripts: Add Modula-2 manual to update_web_docs_git

maintainer-scripts/ChangeLog:

* update_web_docs_git (MANUALS): Add gm2.
Add include path for gm2 manual.

19 months agoc++: __func__ and local class DMI [PR105809]
Jason Merrill [Thu, 16 Mar 2023 19:35:15 +0000 (15:35 -0400)]
c++: __func__ and local class DMI [PR105809]

As in 108242, we need to instantiate in the context of the enclosing
function, not after it's gone.

PR c++/105809

gcc/cp/ChangeLog:

* init.cc (get_nsdmi): Split out...
(maybe_instantiate_nsdmi_init): ...this function.
* cp-tree.h: Declare it.
* pt.cc (tsubst_expr): Use it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-__func__3.C: New test.

19 months agoc++: generic lambda, local class, __func__ [PR108242]
Jason Merrill [Thu, 16 Mar 2023 19:11:25 +0000 (15:11 -0400)]
c++: generic lambda, local class, __func__ [PR108242]

Here we are trying to do name lookup in a deferred instantiation of t() and
failing to find __func__.  tsubst_expr already tries to instantiate members
of local classes, but was failing with the partial instantiation of generic
lambdas.

PR c++/108242

gcc/cp/ChangeLog:

* pt.cc (tsubst_expr) [TAG_DEFN]: Handle partial instantiation.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-generic-func2.C: New test.

19 months agoc++: &enum::enumerator [PR101869]
Jason Merrill [Thu, 16 Mar 2023 17:11:32 +0000 (13:11 -0400)]
c++: &enum::enumerator [PR101869]

We don't want to call build_offset_ref with an enum.

PR c++/101869

gcc/cp/ChangeLog:

* semantics.cc (finish_qualified_id_expr): Don't try to build a
pointer-to-member if the scope is an enumeration.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/enum43.C: New test.

19 months ago[modula2] Add missing stdbool to testcode
Gaius Mulley [Thu, 16 Mar 2023 21:50:02 +0000 (21:50 +0000)]
[modula2] Add missing stdbool to testcode

The type bool is now used to represent BOOLEAN.  The C source
must now include <stdbool.h>.

gcc/testsuite/ChangeLog:

* gm2/types/run/pass/d.c: Add missing include <stdbool.h>.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoPR modula2/109125 SIGBUS in m2pim_ldtoa_ldtoa
Gaius Mulley [Thu, 16 Mar 2023 20:41:20 +0000 (20:41 +0000)]
PR modula2/109125 SIGBUS in m2pim_ldtoa_ldtoa

13 regression failures seen on sparc SIGBUS in m2pim_ldtoa_ldtoa.
This patch fixes int bool struct field mismatches between the
definition modules and their C/C++ implementations.

gcc/testsuite/ChangeLog:

PR modula2/109125
* gm2/types/run/pass/d.c: Convert data structure from
BOOLEAN int to bool and cast int to bool in test function.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoPR 107630 runtime libs should be self-contained
Gaius Mulley [Thu, 16 Mar 2023 20:34:32 +0000 (20:34 +0000)]
PR 107630 runtime libs should be self-contained

This is a patch to improve the layering of libgm2.
It removes the m2cor Debug.{def,mod} (the codebase will use
m2pim Debug instead).  It also layers SysStorage under
both m2pim Storage and m2iso Storage.  SysStorage is now
a dependant of m2pim Storage.mod.  Halt parameters for
Debug.mod and M2RTS.mod now have the same order.

gcc/m2/ChangeLog:

* gm2-compiler/SymbolKey.mod (PutSymKey): Halt parameters
reordered.
(DelSymKey): Ditto.
* gm2-compiler/ppg.mod (GetEpsilon): Ditto.
(GetReachEnd): Ditto.
(GetFollow): Ditto.
(CodeCondition): Ditto.
(CodeThenDo): Ditto.
(CodeEnd): Ditto.
(RecoverCondition): Ditto.
(ConditionIndent): Ditto.
* gm2-libs-ch/m2rts.h (M2RTS_Halt): Ditto.
* gm2-libs-coroutines/Executive.mod (Assert): Ditto.
(Resume): Remove redundant comments.
(Wait): Remove redundant comments.
* gm2-libs-coroutines/SYSTEM.mod (TRANSFER): Halt parameters
reordered.
(IOTransferHandler): Ditto.
(Finished): Ditto.
(localInit): Ditto.
* gm2-libs-coroutines/TimerHandler.mod (WaitOn): Halt parameters
reordered.
(Cancel): Ditto.
(ReArmEvent): Ditto.
(OnActiveQueue): Ditto.
* gm2-libs-iso/COROUTINES.mod (NEWCOROUTINE): Ditto.
(Transfer): Ditto.
(IOTRANSFER): Ditto.
* gm2-libs-iso/EXCEPTIONS.mod (RAISE): Correct Halt parameters.
* gm2-libs-iso/M2RTS.def (Halt): Halt parameters reordered.
(HaltC): Ditto.
* gm2-libs-iso/M2RTS.mod: Ditto.
* gm2-libs-iso/RTentity.mod (PutKey): Ditto.
(DelKey): Ditto.
(findChildAndParent): Ditto.
(assert): Ditto.
* gm2-libs-iso/Storage.mod (ALLOCATE): Add DebugTrace.
Add UseMallocFree test.
(DEALLOCATE): Add DebugTrace.  Add UseMallocFree test.
(assert): Halt parameters reordered.
* gm2-libs-log/Termbase.mod (Read): Ditto.
(KeyPressed): Ditto.
(Write): Ditto.
(Init): Ditto.
* gm2-libs/Debug.def (Halt): Halt parameters reordered.
* gm2-libs/Debug.mod (Halt): Ditto.
* gm2-libs/DynamicStrings.def (PopAllocation): Improve comment.
* gm2-libs/DynamicStrings.mod (PopAllocation): Improve comment.
Halt parameters reordered.
* gm2-libs/M2RTS.def (Halt): Ditto.
(HaltC): Ditto.
* gm2-libs/M2RTS.mod (Halt): Ditto.
(HaltC): Ditto.
* gm2-libs/PushBackInput.mod (PutStr): Ditto.
(PutString): Ditto.
(PutCh): Ditto.
* gm2-libs/RTExceptions.mod (GetBaseExceptionBlock): Ditto.
* gm2-libs/RTint.mod (ReArmTimeVector): Ditto.
(GetTimeVector): Ditto.
(AttachVector): Ditto.
(IncludeVector): Ditto.
(Listen): Ditto.
* gm2-libs/SysStorage.mod (ALLOCATE): Ditto.
(DEALLOCATE): Ditto.
(REALLOCATE): Ditto.
* gm2-libs-coroutines/Debug.def: Removed.
* gm2-libs-coroutines/Debug.mod: Removed.

libgm2/ChangeLog:

* libm2cor/Makefile.am: Remove
* libm2cor/Makefile.in: Rebuild.
* libm2iso/RTco.cc (newSem): Halt parameters reordered.
(currentThread): Ditto.
(never): Ditto.
(defined): Ditto.
(initThread): Ditto.
* libm2iso/m2rts.h (m2iso_M2RTS_HaltC): Ditto.

gcc/testsuite/ChangeLog:

* gm2/complex/pass/arith3.mod: Halt parameters reordered.
* gm2/complex/run/pass/arith3.mod: Ditto.
* gm2/complex/run/pass/arith4.mod: Ditto.
* gm2/complex/run/pass/arith5.mod: Ditto.
* gm2/isolib/run/pass/real2.mod: Ditto.
* gm2/isolib/run/pass/real3.mod: Ditto.
* gm2/isolib/run/pass/realconv.mod: Ditto.
* gm2/isolib/run/pass/realconv2.mod: Ditto.
* gm2/pim/pass/testshort.mod: Ditto.
* gm2/projects/pim/run/pass/tower/AdvSystem.mod: Ditto.
* gm2/projects/pim/run/pass/tower/DrawL.mod: Ditto.
* gm2/warnings/returntype/pass/Termbase.mod: Ditto.
* gm2/warnings/returntype/pass/keypressedsimple.mod: Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoi386: Robustify vec perm blend functions for TARGET_MMX_WITH_SSE
Uros Bizjak [Thu, 16 Mar 2023 19:41:55 +0000 (20:41 +0100)]
i386: Robustify vec perm blend functions for TARGET_MMX_WITH_SSE

8-byte modes should be processed only for TARGET_MMX_WITH_SSE.

gcc/ChangeLog:

* config/i386/i386-expand.cc (expand_vec_perm_pblendv):
Handle 8-byte modes only with TARGET_MMX_WITH_SSE.
(expand_vec_perm_2perm_pblendv): Ditto.

19 months agoc++: maybe_constant_init and unevaluated operands [PR109030]
Patrick Palka [Thu, 16 Mar 2023 18:47:43 +0000 (14:47 -0400)]
c++: maybe_constant_init and unevaluated operands [PR109030]

This testcase in this PR (already fixed by r13-6526-ge4692319fd5fc7)
demonstrates that maybe_constant_init can be called on an unevaluated
operand (e.g. from massage_init_elt) so this entry point should also
limit constant evaluation in that case, like maybe_constant_value does.

PR c++/109030

gcc/cp/ChangeLog:

* constexpr.cc (maybe_constant_init_1): For an unevaluated
non-manifestly-constant operand, don't constant evaluate
and instead call fold_to_constant as in maybe_constant_value.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-inst2.C: New test.

19 months agoc++: checking ICE with diagnosed constraint recursion [PR100288]
Patrick Palka [Thu, 16 Mar 2023 18:22:54 +0000 (14:22 -0400)]
c++: checking ICE with diagnosed constraint recursion [PR100288]

When satisfaction_cache::get detects constraint recursion, it asserts
that entry->result is empty.  This makes sense when we're initially
detecting/diagnosing recursion from the inner recursive call, but
afterwards from the outer recursive call the recursion error is treated
like any other unrelated constraint failure encountered during
satisfaction, and we set entry->result to whatever the satisfaction
value ended up being.

Perhaps we should keep entry->result cleared in this case, but that'd
require the inner recursive call to communicate to the outer recursive
call that constraint recursion occurred, likely via setting entry->result
to some sentinel value, which doesn't seem to be worth the complexity.
So this patch just relaxes the problematic assert to accept non-empty
entry->result as long as we've already issued an error.

PR c++/100288

gcc/cp/ChangeLog:

* constraint.cc (satisfaction_cache::get): Relax overly strict
checking assert in the constraint recursion case.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-recursive-sat5.C: New test.

19 months agod: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.
Iain Buclaw [Sun, 5 Mar 2023 00:47:19 +0000 (01:47 +0100)]
d: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.

D front-end changes:

- Import dmd v2.103.0-beta.1.
- Using `alias this' for classes has been deprecated.
- The feature `-fpreview=dip25` is now enabled by default.
- The compile-time traits `isVirtualFunction' and
  `getVirtualFunctions' have been deprecated.

D runtime changes:

- Import druntime v2.103.0-beta.1.

Phobos changes:

- Import phobos v2.103.0-beta.1.
- Updated unicode grapheme walking updated to conform to Unicode
  version 15.
- Improved friendliness of error messages when instantiating
  `std.algorithm.iteration.joiner' and
  `std.algorithm.sorting.sort' with wrong inputs.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4ca4140e58.
* dmd/VERSION: Bump version to v2.103.0-beta.1.
* Make-lang.in (D_FRONTEND_OBJS): Add d/errorsink.o.
* d-ctfloat.cc (CTFloat::sprint): Update signature for new front-end
interface.
* d-frontend.cc (getTypeInfoType): Likewise.
* d-lang.cc (d_handle_option): Remove handling of -fpreview=dip25 and
-frevert=dip25.
(d_post_options): Remove enabling of sealed references language
feature when scoped pointers is enabled.
* d-tree.h (create_typeinfo): Update signature.
* decl.cc (DeclVisitor::finish_vtable): Update for new front-end
interface.
(DeclVisitor::visit (VarDeclaration *)): Likewise.
(DeclVisitor::visit (FuncDeclaration *)): Check skipCodegen to see if
front-end explicitly requested not to generate code.
* expr.cc (ExprVisitor::visit (NewExp *)): Update for new front-end
interface.
* lang.opt (fpreview=dip25): Remove.
(frevert=dip25): Remove.
* modules.cc (layout_moduleinfo_fields): Update for new front-end
interface.
(layout_moduleinfo): Likewise.
* runtime.def (NEWCLASS): Remove.
* toir.cc (IRVisitor::visit (IfStatement *)): Don't generate IR for if
statement list when condition is `__ctfe'.
* typeinfo.cc (create_typeinfo): Add generate parameter.
* types.cc (layout_aggregate_members): Update for new front-end
interface.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 4ca4140e58.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/factory.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 454dff14d.
* testsuite/libphobos.hash/test_hash.d: Update test.
* testsuite/libphobos.shared/finalize.d: Update test.
* libdruntime/core/factory.d: New file.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/simd23084.d: New test.
* gdc.dg/torture/simd23085.d: New test.
* gdc.dg/torture/simd23218.d: New test.

19 months agomiddle-end: always find a basename for -fdiagnostics-format=*
Martin Liska [Tue, 10 Jan 2023 14:14:05 +0000 (15:14 +0100)]
middle-end: always find a basename for -fdiagnostics-format=*

In some situations, x_dump_base_name is NULL and thus we can
and should use x_main_input_basename which should never be NULL.

PR middle-end/106133

gcc/ChangeLog:

* gcc.cc (driver_handle_option): Use x_main_input_basename
if x_dump_base_name is null.
* opts.cc (common_handle_option): Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/pr106133.c: New test.

19 months ago[testsuite] fix array element count
Alexandre Oliva [Thu, 16 Mar 2023 13:10:54 +0000 (10:10 -0300)]
[testsuite] fix array element count

This test is similar to pr103116-1.c, but instead of writing to
4*COUNT elements of x, it writes to 8*COUNT elements, but the
definition of x seems to have been adjusted along with the loop.  Fix
the array size so that it doesn't scribble over unrelated
statically-allocated objects.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/pr103116-2.c (x): Fix array size.

19 months agoc++: co_await and move-only type [PR105406]
Jason Merrill [Wed, 15 Mar 2023 21:02:15 +0000 (17:02 -0400)]
c++: co_await and move-only type [PR105406]

Here we were building a temporary MoveOnlyAwaitable to hold the result of
evaluating 'o', but since 'o' is an lvalue we should build a reference
instead.

PR c++/105406

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Handle lvalue 'o'.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/co-await-moveonly1.C: New test.

19 months agod: Fix closure fields don't get same alignment as local variable [PR109144]
Iain Buclaw [Thu, 16 Mar 2023 00:07:02 +0000 (01:07 +0100)]
d: Fix closure fields don't get same alignment as local variable [PR109144]

Local variables with both non-local references and explicit alignment
did not propagate their alignment to either the closure field or closure
frame type, resulting in the closure being misaligned. This is now
correctly set-up when building the frame type.

PR d/109144

gcc/d/ChangeLog:

* d-codegen.cc (build_frame_type): Set frame field and type alignment.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr109144.d: New test.

19 months agocontrib: Update instructions regarding Unicode updates
Jakub Jelinek [Thu, 16 Mar 2023 09:28:25 +0000 (10:28 +0100)]
contrib: Update instructions regarding Unicode updates

I've noticed we have instructions on how to update from newer Unicode
standard, but it didn't mention uname2c.h regeneration.

The following patch mentions that, also mentions that the Copyright years
of Unicode should be updated and adds a copy of NameAliases.txt which
is used for uname2c.h generation.

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

* unicode/README: Update to mention also makeuname2c.
* unicode/NameAliases.txt: New file.

19 months agolibcpp: Update Unicode copyright years
Jakub Jelinek [Thu, 16 Mar 2023 09:19:04 +0000 (10:19 +0100)]
libcpp: Update Unicode copyright years

I've noticed I forgot to update copyright years when updating from
Unicode 15.0.0 (and makeucnid.cc had it hopelessly obsolete).

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

* makeucnid.cc (write_copyright): Update Unicode copyright years
up to 2022.
* makeuname2c.cc (write_copyright): Likewise.
* ucnid.h: Regenerated.
* uname2c.h: Regenerated.

19 months agotree-optimization/109123 - run -Wuse-afer-free only early
Richard Biener [Wed, 15 Mar 2023 08:12:33 +0000 (09:12 +0100)]
tree-optimization/109123 - run -Wuse-afer-free only early

The following switches the -Wuse-after-free diagnostics from emitted
during the late access warning passes to the early access warning
passes to make sure we run before passes performing code motion run
which are the source of a lot of false positives on use-after-free
not involving memory operations.

The patch also fixes an issue in c-c++-common/Wuse-after-free-6.c
and causes the name of the unused pointer to appear in the diagnostic
for extra cases in gcc.dg/Wuse-after-free-2.c

PR tree-optimization/109123
* gimple-ssa-warn-access.cc (pass_waccess::warn_invalid_pointer):
Do not emit -Wuse-after-free late.
(pass_waccess::check_call): Always check call pointer uses.

* gcc.dg/Wuse-after-free-pr109123.c: New testcase.
* gcc.dg/Wuse-after-free-2.c: Amend expected diagnostic with
the name of the pointer.
* c-c++-common/Wuse-after-free-6.c: Un-XFAIL case.

19 months agoAvoid random stmt order result in pass_waccess::use_after_inval_p
Richard Biener [Wed, 15 Mar 2023 10:41:20 +0000 (11:41 +0100)]
Avoid random stmt order result in pass_waccess::use_after_inval_p

use_after_inval_p uses stmt UIDs to speed up repeated dominance
checks within a basic-block but it fails to assign UIDs to PHIs
which means compares with PHIs in the same block get a random
result.

The following factors renumber_gimple_stmt_uids to expose a new
renumber_gimple_stmt_uids_in_block we can share.

But since we rely on processing even earlier PHIs to follow
pointer adjustments (we look at those even if earlier) the patch
also moves PHI handling out of the use_after_inval_p guard.
This then also fixes PR109141.

PR tree-optimization/109141
* tree-dfa.h (renumber_gimple_stmt_uids_in_block): New.
* tree-dfa.cc (renumber_gimple_stmt_uids_in_block): Split
out from ...
(renumber_gimple_stmt_uids): ... here and
(renumber_gimple_stmt_uids_in_blocks): ... here.
* gimple-ssa-warn-access.cc (pass_waccess::use_after_inval_p):
Use renumber_gimple_stmt_uids_in_block to also assign UIDs
to PHIs.
(pass_waccess::check_pointer_uses): Process all PHIs.

19 months agoMove target independent documentation files into subdir
Gaius Mulley [Thu, 16 Mar 2023 04:17:28 +0000 (04:17 +0000)]
Move target independent documentation files into subdir

Move target independent documentation files into a subdir m2 so that
the maintainer-scripts/update_web_docs_git can build gm2.texi from the
source tree (and without any build dir).

gcc/m2/ChangeLog:

* Make-lang.in: Rename target-independent to
target-independent/m2.
* target-independent/readme.txt: Update.
* target-independent/m2/gm2-ebnf.texi: New file.
* target-independent/m2/gpl_v3_without_node.texi: New file.
* target-independent/Builtins.texi: Rename ...
* target-independent/m2/Builtins.texi: ... to this.
* target-independent/SYSTEM-iso.texi: Rename ...
* target-independent/m2/SYSTEM-iso.texi: ... to this.
* target-independent/SYSTEM-pim.texi: Rename ...
* target-independent/m2/SYSTEM-pim.texi: ... to this.
* target-independent/gm2-libs.texi: Rename ...
* target-independent/m2/gm2-libs.texi: ... to this.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agomaintainer-scripts: Abstract BUGURL in update_web_docs_git
Gerald Pfeifer [Thu, 16 Mar 2023 00:20:26 +0000 (01:20 +0100)]
maintainer-scripts: Abstract BUGURL in update_web_docs_git

The URL where to report bugs is hard coded in two places; abstract that
into one variable, defined up front.

maintainer-scripts/ChangeLog:

* update_web_docs_git (BUGURL): Introduce and use throughout.

19 months agoDaily bump.
GCC Administrator [Thu, 16 Mar 2023 00:16:56 +0000 (00:16 +0000)]
Daily bump.

19 months agoc++: co_await and initializer_list [PR103871]
Jason Merrill [Wed, 15 Mar 2023 20:33:37 +0000 (16:33 -0400)]
c++: co_await and initializer_list [PR103871]

When flatten_await_stmt processes the backing array for an initializer_list,
we call cp_build_modify_expr to initialize the promoted variable from the
TARGET_EXPR; that needs to be accepted.

PR c++/103871
PR c++/98056

gcc/cp/ChangeLog:

* typeck.cc (cp_build_modify_expr): Allow array initialization of
DECL_ARTIFICIAL variable.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/co-await-initlist1.C: New test.

19 months agodiagnostics: attempt to capture crash info in SARIF output [PR109097]
David Malcolm [Wed, 15 Mar 2023 22:16:17 +0000 (18:16 -0400)]
diagnostics: attempt to capture crash info in SARIF output [PR109097]

As noted in PR analyzer/109097, if an internal compiler error occurs
when -fdiagnostics-format=sarif-file is specified, we currently fail
to write out a .sarif file, and the output to stderr doesn't contain
"internal compiler error" or "Internal compiler error"; just the
backtrace if we're lucky, and the "Please submit a full bug report"
messages.

This is a nuisance e.g. for my integration testing of -fanalyzer, where
I'm gathering the results of builds via the .sarif output: if it crashes
on a particular source file, then no output is generated, and it's
effectively silent about the crash.

This patch fixes things by adding a callback to diagnostic_context so
that the SARIF output code can make one final attempt to write its
output if an ICE occurs.  It also special-cases the output, so that an
ICE is treated as an "error"-level "notification" relating to the
operation of the tool (SARIF v2.1.0 section 3.58), rather than a
"result" about the code being analyzed by the tool.

The patch adds test coverage for this via a plugin that can inject:
* calls to internal_compiler_error, and
* writes through a NULL pointer
and verifying that a  .sarif file is written out capturing the crash
(and also that an ICE occurs via dg-ice, which seems to treat the ICE as
an XFAIL, which is reasonable).

I've added support for this to my integration-testing scripts: testing
shows that with this patch we capture analyzer crashes in .sarif files
(specifically, the analyzer crash on qemu: PR analyzer/109094), and I've
updated my scripts to work with and report such output.

I manually verified that the resulting .sarif files validate against the
schema.

gcc/ChangeLog:
PR analyzer/109097
* diagnostic-format-sarif.cc (class sarif_invocation): New.
(class sarif_ice_notification): New.
(sarif_builder::m_invocation_obj): New field.
(sarif_invocation::add_notification_for_ice): New.
(sarif_invocation::prepare_to_flush): New.
(sarif_ice_notification::sarif_ice_notification): New.
(sarif_builder::sarif_builder): Add m_invocation_obj.
(sarif_builder::end_diagnostic): Special-case DK_ICE and
DK_ICE_NOBT.
(sarif_builder::flush_to_file): Call prepare_to_flush on
m_invocation_obj.  Pass the latter to make_top_level_object.
(sarif_builder::make_result_object): Move creation of "locations"
array to...
(sarif_builder::make_locations_arr): ...this new function.
(sarif_builder::make_top_level_object): Add "invocation_obj" param
and pass it to make_run_object.
(sarif_builder::make_run_object): Add "invocation_obj" param and
use it.
(sarif_ice_handler): New callback.
(diagnostic_output_format_init_sarif): Wire up sarif_ice_handler.
* diagnostic.cc (diagnostic_initialize): Initialize new field
"ice_handler_cb".
(diagnostic_action_after_output): If it is set, make one attempt
to call ice_handler_cb.
* diagnostic.h (diagnostic_context::ice_handler_cb): New field.

gcc/testsuite/ChangeLog:
PR analyzer/109097
* c-c++-common/diagnostic-format-sarif-file-1.c: Verify that we
have an invocation object marked as succeeding, with no
notifications.
* gcc.dg/plugin/crash-test-ice-sarif.c: New test.
* gcc.dg/plugin/crash-test-ice-stderr.c: New test.
* gcc.dg/plugin/crash-test-write-though-null-sarif.c: New test.
* gcc.dg/plugin/crash-test-write-though-null-stderr.c: New test.
* gcc.dg/plugin/crash_test_plugin.c: New plugin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the new plugin
and test cases.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoPR 109125 13 regression SIGBUS in m2pim_ldtoa_ldtoa
Gaius Mulley [Wed, 15 Mar 2023 21:30:33 +0000 (21:30 +0000)]
PR 109125 13 regression SIGBUS in m2pim_ldtoa_ldtoa

This patch fixes more bool int parameter mismatches
found in dtoa and ldtoa.

gcc/m2/ChangeLog:

PR modula2/109125
* gm2-libs-ch/dtoa.cc (dtoa_strtod): Replace int with bool.
* gm2-libs-ch/ldtoa.cc (ldtoa_strtold): Replace int with bool.

libgm2/ChangeLog:

PR modula2/109125
* libm2pim/dtoa.cc (TRUE): Remove.
(FALSE): Remove.  Replace int with bool.
* libm2pim/ldtoa.cc (TRUE): Remove.
(FALSE): Remove.  Replace int with bool.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoi386: Fix blend vector permutation for 8-byte modes
Uros Bizjak [Wed, 15 Mar 2023 19:33:48 +0000 (20:33 +0100)]
i386: Fix blend vector permutation for 8-byte modes

8-byte modes should be processed only for TARGET_MMX_WITH_SSE. Handle
V2SFmode and fix V2HImode handling. The resulting BLEND instructions
are always faster than MOVSS/MOVSD, so prioritize them w.r.t MOVSS/MOVSD
for TARGET_SSE4_1.

gcc/ChangeLog:

* config/i386/i386-expand.cc (expand_vec_perm_blend):
Handle 8-byte modes only with TARGET_MMX_WITH_SSE. Handle V2SFmode
and fix V2HImode handling.
(expand_vec_perm_1): Try to emit BLEND instruction
before MOVSS/MOVSD.
* config/i386/mmx.md (*mmx_blendps): New insn pattern.

gcc/testsuite/ChangeLog:

* gcc.target/i386/merge-1.c (dg-options): Use -mno-sse4.
* gcc.target/i386/sse2-mmx-21.c (dg-options): Ditto.
* gcc.target/i386/sse-movss-4.c (dg-options):
Use -mno-sse4.  Simplify scan-assembler-not strings.
* gcc.target/i386/sse2-movsd-3.c (dg-options): Ditto.
* gcc.target/i386/sse2-mmx-movss-1.c: New test.

19 months agoFortran: rank checking with explicit-/assumed-size arrays and CLASS [PR58331]
Harald Anlauf [Tue, 14 Mar 2023 19:23:06 +0000 (20:23 +0100)]
Fortran: rank checking with explicit-/assumed-size arrays and CLASS [PR58331]

gcc/fortran/ChangeLog:

PR fortran/58331
* interface.cc (compare_parameter): Adjust check of array dummy
arguments to handle the case of CLASS variables.

gcc/testsuite/ChangeLog:

PR fortran/58331
* gfortran.dg/class_dummy_10.f90: New test.

Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
19 months agoc++: ICE with constexpr lambda [PR107280]
Marek Polacek [Fri, 10 Mar 2023 15:14:20 +0000 (10:14 -0500)]
c++: ICE with constexpr lambda [PR107280]

We crash here since r10-3661, the store_init_value hunk in particular.
Before, we called cp_fully_fold_init, so e.g.

  {.str=VIEW_CONVERT_EXPR<char[8]>("")}

was folded into

  {.str=""}

but now we don't fold and keep the VCE around, and it causes trouble in
cxx_eval_store_expression: in the !refs->is_empty () loop we descend on
.str's initializer but since it's wrapped in a VCE, we skip the STRING_CST
check and then crash on the CONSTRUCTOR_NO_CLEARING.

PR c++/107280

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_store_expression): Strip location wrappers.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/constexpr-lambda28.C: New test.

19 months agoOpenMP: Add omp_in_explicit_task to omp_runtime_api_call
Tobias Burnus [Wed, 15 Mar 2023 14:31:52 +0000 (15:31 +0100)]
OpenMP: Add omp_in_explicit_task to omp_runtime_api_call

gcc/
* omp-low.cc (omp_runtime_api_call): Add omp_in_explicit_task.

19 months agoAvoid duplicate diagnostic in g++.dg/warn/Wuse-after-free3.C
Richard Biener [Wed, 15 Mar 2023 13:48:57 +0000 (14:48 +0100)]
Avoid duplicate diagnostic in g++.dg/warn/Wuse-after-free3.C

We are diagnosing

  operator delete (this_3(D));
  A::f (this_3(D));
  *this_3(D) ={v} CLOBBER;

where the CLOBBER appears at the end of the DTOR for C++11 and later.
The following avoids this by simply never diagnosing clobbers as
use-after-free.

* gimple-ssa-warn-access.cc (pass_waccess::check_pointer_uses):
Do not diagnose clobbers.

* g++.dg/warn/Wuse-after-free3.C: Remove expected duplicate
diagnostic.

19 months agoc++: injected class name as default ttp arg [PR58538]
Jason Merrill [Wed, 15 Mar 2023 03:16:21 +0000 (23:16 -0400)]
c++: injected class name as default ttp arg [PR58538]

This function needs to handle this case like convert_template_argument.

PR c++/58538

gcc/cp/ChangeLog:

* semantics.cc (check_template_template_default_arg): Check
maybe_get_template_decl_from_type_decl.

gcc/testsuite/ChangeLog:

* g++.dg/template/ttp7.C: Remove expected error.

19 months agoc++: passing one ttp to another [PR108179]
Jason Merrill [Fri, 10 Mar 2023 19:55:27 +0000 (14:55 -0500)]
c++: passing one ttp to another [PR108179]

I kept trying to improve our choice of how many levels of outer_args to add,
when really the problem was that outer_args are for PARM and for this
reverse deduction we should be adding the outer arguments for ARG.

I spent quite a while trying to get DECL_CONTEXT set consistently on
template template parameters that have gone through
reduce_template_parm_level before I realized I could just use
current_scope().

PR c++/108179
PR c++/104107
PR c++/95036

gcc/cp/ChangeLog:

* pt.cc (coerce_template_template_parms): Use args from
DECL_CONTEXT (arg_tmpl) instead of outer_args.

gcc/testsuite/ChangeLog:

* g++.dg/template/ttp35.C: New test.

19 months agoc++: coerce_template_template_parms interface tweak
Jason Merrill [Wed, 15 Mar 2023 02:07:45 +0000 (22:07 -0400)]
c++: coerce_template_template_parms interface tweak

This should have no semantic effect, but is a prerequisite for the PR108179
fix to follow.

PR c++/108179

gcc/cp/ChangeLog:

* pt.cc (coerce_template_template_parms): Take the arg and parm
templates directly.
(coerce_template_template_parm): Adjust.
(template_template_parm_bindings_ok_p): Adjust.
(convert_template_argument): Adjust.

19 months agotree-optimization/109139 - fix .DEFERRED_INIT removal
Richard Biener [Wed, 15 Mar 2023 08:47:18 +0000 (09:47 +0100)]
tree-optimization/109139 - fix .DEFERRED_INIT removal

The following make sure to strip MEMs when looking for unused
decls on the LHS of .DEFERRED_INIT.

PR tree-optimization/109139
* tree-ssa-live.cc (remove_unused_locals): Look at the
base address for unused decls on the LHS of .DEFERRED_INIT.

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

19 months agobuiltins: Move the character difference into result instead of reassigning result...
Xi Ruoyao [Wed, 15 Mar 2023 07:34:52 +0000 (15:34 +0800)]
builtins: Move the character difference into result instead of reassigning result [PR109086]

expand_simple_binop() is allowed to allocate a new pseudo-register and
return it, instead of forcing the result into the provided
pseudo-register.  This can cause a problem when we expand the unrolled
loop for __builtin_strcmp: the compiler always generates code for all n
iterations of the loop, so "result" will be an alias of the
pseudo-register allocated and used in the last iteration; but at runtime
the loop can break early, causing this pseudo-register uninitialized.

Emit a move instruction in the iteration to force the difference into
one register which has been allocated before the loop, to avoid this
issue.

gcc/ChangeLog:

PR other/109086
* builtins.cc (inline_string_cmp): Force the character
difference into "result" pseudo-register, instead of reassign
the pseudo-register.

19 months agoriscv: thead: Add support for the XTheadMemPair ISA extension
Christoph Müllner [Fri, 24 Feb 2023 05:18:04 +0000 (06:18 +0100)]
riscv: thead: Add support for the XTheadMemPair ISA extension

The XTheadMemPair ISA extension allows to pair two loads or stores:
* th.ldd (2x LD)
* th.lwd (2x LW)
* th.lwud (2x LWU)
* th.sdd (2x SD)
* th.swd (2x SW)

The displacement of these instructions is quite limited:
* Displacement := imm2 << shamt
* imm2 is a 2-bit unsigned value {0..3}
* shamt is 4 for th.ldd/th.sdd and 3 otherwise
But even with this small displacement we can identify many candidates.

The merge of the two loads/stores is realized in form of peephole2
passes that support instruction reordering.
The CFA expansion (save/restore registers on/from stack) is not
processed by the peephole2 pass and, therefore, needs special-treatment.
Many ideas of this patch are inspired by similar/equal approaches
in other backends.

gcc/ChangeLog:

* config.gcc: Add thead.o to RISC-V extra_objs.
* config/riscv/peephole.md: Add mempair peephole passes.
* config/riscv/riscv-protos.h (riscv_split_64bit_move_p): New
prototype.
(th_mempair_operands_p): Likewise.
(th_mempair_order_operands): Likewise.
(th_mempair_prepare_save_restore_operands): Likewise.
(th_mempair_save_restore_regs): Likewise.
(th_mempair_output_move): Likewise.
* config/riscv/riscv.cc (riscv_save_reg): Move code.
(riscv_restore_reg): Move code.
(riscv_for_each_saved_reg): Add code to emit mempair insns.
* config/riscv/t-riscv: Add thead.cc.
* config/riscv/thead.md (*th_mempair_load_<GPR:mode>2):
New insn.
(*th_mempair_store_<GPR:mode>2): Likewise.
(*th_mempair_load_extendsidi2): Likewise.
(*th_mempair_load_zero_extendsidi2): Likewise.
* config/riscv/thead.cc: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadmempair-1.c: New test.
* gcc.target/riscv/xtheadmempair-2.c: New test.
* gcc.target/riscv/xtheadmempair-3.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: thead: Add support for the XTheadFmv ISA extension
Christoph Müllner [Sun, 4 Dec 2022 23:38:56 +0000 (00:38 +0100)]
riscv: thead: Add support for the XTheadFmv ISA extension

The XTheadFmv ISA extension provides instructions to move
data between 32-bit GP registers and 64-bit FP registers.

Co-Developed-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Signed-off-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/constraints.md (TARGET_XTHEADFMV ? FP_REGS : NO_REGS)
New constraint "th_f_fmv".
(TARGET_XTHEADFMV ? GR_REGS : NO_REGS): New constraint
"th_r_fmv".
* config/riscv/riscv.cc (riscv_split_doubleword_move):
Add split code for XTheadFmv.
(riscv_secondary_memory_needed): XTheadFmv does not need
secondary memory.
* config/riscv/riscv.md: Add new UNSPEC_XTHEADFMV and
UNSPEC_XTHEADFMV_HW. Add support for XTheadFmv to
movdf_hardfloat_rv32.
* config/riscv/thead.md (th_fmv_hw_w_x): New INSN.
(th_fmv_x_w): New INSN.
(th_fmv_x_hw): New INSN.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadfmv-fmv.c: New test.

19 months agoriscv: thead: Add support for the XTheadMac ISA extension
Christoph Müllner [Thu, 6 Oct 2022 11:17:40 +0000 (13:17 +0200)]
riscv: thead: Add support for the XTheadMac ISA extension

The XTheadMac ISA extension provides multiply-accumulate/subtract
instructions:
* mula/mulaw/mulah
* muls/mulsw/mulsh

To benefit from middle-end passes, we expand the following named
patterns in riscv.md (as they are not T-Head-specific):
* maddhisi4
* msubhisi4

Co-Developed-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Signed-off-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/riscv.md (maddhisi4): New expand.
(msubhisi4): New expand.
* config/riscv/thead.md (*th_mula<mode>): New pattern.
(*th_mulawsi): New pattern.
(*th_mulawsi2): New pattern.
(*th_maddhisi4): New pattern.
(*th_sextw_maddhisi4): New pattern.
(*th_muls<mode>): New pattern.
(*th_mulswsi): New pattern.
(*th_mulswsi2): New pattern.
(*th_msubhisi4): New pattern.
(*th_sextw_msubhisi4): New pattern.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadmac-mula-muls.c: New test.

19 months agoriscv: thead: Add support for the XTheadCondMov ISA extensions
Christoph Müllner [Mon, 8 Aug 2022 15:48:20 +0000 (17:48 +0200)]
riscv: thead: Add support for the XTheadCondMov ISA extensions

This patch adds support for XTheadCondMov ISA extension.
The extension brings a one-sided conditional move (no else-assignment).
Given that GCC has a great if-conversion pass, we don't need to do much,
besides properly expanding mov<mode>cc accordingly and adjust the cost
model.

gcc/ChangeLog:

* config/riscv/iterators.md (TARGET_64BIT): Add GPR2 iterator.
* config/riscv/riscv-protos.h (riscv_expand_conditional_move):
Add prototype.
* config/riscv/riscv.cc (riscv_rtx_costs): Add costs for
XTheadCondMov.
(riscv_expand_conditional_move): New function.
(riscv_expand_conditional_move_onesided): New function.
* config/riscv/riscv.md: Add support for XTheadCondMov.
* config/riscv/thead.md (*th_cond_mov<GPR:mode><GPR2:mode>): Add
support for XTheadCondMov.
(*th_cond_gpr_mov<GPR:mode><GPR2:mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadcondmov-mveqz-imm-eqz.c: New test.
* gcc.target/riscv/xtheadcondmov-mveqz-imm-not.c: New test.
* gcc.target/riscv/xtheadcondmov-mveqz-reg-eqz.c: New test.
* gcc.target/riscv/xtheadcondmov-mveqz-reg-not.c: New test.
* gcc.target/riscv/xtheadcondmov-mvnez-imm-cond.c: New test.
* gcc.target/riscv/xtheadcondmov-mvnez-imm-nez.c: New test.
* gcc.target/riscv/xtheadcondmov-mvnez-reg-cond.c: New test.
* gcc.target/riscv/xtheadcondmov-mvnez-reg-nez.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: thead: Add support for the XTheadBb ISA extension
Christoph Müllner [Fri, 29 Jul 2022 03:19:56 +0000 (05:19 +0200)]
riscv: thead: Add support for the XTheadBb ISA extension

This patch adds support for the XTheadBb ISA extension.
Thus, there is a functional overlap of the new instructions with
existing Bitmanip instruction, which allows a good amount of code
sharing. However, the vendor extensions are cleanly separated from
the standard extensions (e.g. by using INSN expand pattern that
will re-emit RTL that matches the patterns of either Bitmanip or
XThead INSNs).

gcc/ChangeLog:

* config/riscv/bitmanip.md (clzdi2): New expand.
(clzsi2): New expand.
(ctz<mode>2): New expand.
(popcount<mode>2): New expand.
(<bitmanip_optab>si2): Rename INSN.
(*<bitmanip_optab>si2): Hide INSN name.
(<bitmanip_optab>di2): Rename INSN.
(*<bitmanip_optab>di2): Hide INSN name.
(rotrsi3): Remove INSN.
(rotr<mode>3): Add expand.
(*rotrsi3): New INSN.
(rotrdi3): Rename INSN.
(*rotrdi3): Hide INSN name.
(rotrsi3_sext): Rename INSN.
(*rotrsi3_sext): Hide INSN name.
(bswap<mode>2): Remove INSN.
(bswapdi2): Add expand.
(bswapsi2): Add expand.
(*bswap<mode>2): Hide INSN name.
* config/riscv/riscv.cc (riscv_rtx_costs): Add costs for sign
extraction.
* config/riscv/riscv.md (extv<mode>): New expand.
(extzv<mode>): New expand.
* config/riscv/thead.md (*th_srri<mode>3): New INSN.
(*th_ext<mode>): New INSN.
(*th_extu<mode>): New INSN.
(*th_clz<mode>2): New INSN.
(*th_rev<mode>2): New INSN.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadbb-ext.c: New test.
* gcc.target/riscv/xtheadbb-extu-2.c: New test.
* gcc.target/riscv/xtheadbb-extu.c: New test.
* gcc.target/riscv/xtheadbb-ff1.c: New test.
* gcc.target/riscv/xtheadbb-rev.c: New test.
* gcc.target/riscv/xtheadbb-srri.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: thead: Add support for the XTheadBs ISA extension
Christoph Müllner [Mon, 5 Dec 2022 12:02:24 +0000 (13:02 +0100)]
riscv: thead: Add support for the XTheadBs ISA extension

This patch adds support for the XTheadBs ISA extension.
The new INSN pattern is defined in a new file to separate
this vendor extension from the standard extensions.
The cost model adjustment reuses the xbs:bext cost.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_rtx_costs): Add xthead:tst cost.
* config/riscv/thead.md (*th_tst<mode>3): New INSN.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadbs-tst.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: thead: Add support for the XTheadBa ISA extension
Christoph Müllner [Mon, 5 Dec 2022 11:55:16 +0000 (12:55 +0100)]
riscv: thead: Add support for the XTheadBa ISA extension

This patch adds support for the XTheadBa ISA extension.
The new INSN pattern is defined in a new file to separate
this vendor extension from the standard extensions.

gcc/ChangeLog:

* config/riscv/riscv.md: Include thead.md
* config/riscv/thead.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadba-addsl.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: riscv-cores.def: Add T-Head XuanTie C906
Christoph Müllner [Mon, 13 Jun 2022 13:09:46 +0000 (15:09 +0200)]
riscv: riscv-cores.def: Add T-Head XuanTie C906

This adds T-Head's XuanTie C906 to the list of known cores as "thead-c906".
The C906 is shipped for quite some time (it is the core of the Allwinner D1).
Note, that the tuning struct for the C906 is already part of GCC (it is
also name "thead-c906").

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_CORE): Add "thead-c906".

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mcpu-thead-c906.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoriscv: Add basic XThead* vendor extension support
Christoph Müllner [Thu, 6 Oct 2022 11:18:25 +0000 (13:18 +0200)]
riscv: Add basic XThead* vendor extension support

This patch add basic support for the following XThead* ISA extensions:

* XTheadBa
* XTheadBb
* XTheadBs
* XTheadCmo
* XTheadCondMov
* XTheadFMemIdx
* XTheadFmv
* XTheadInt
* XTheadMac
* XTheadMemIdx
* XTheadMemPair
* XTheadSync

The extensions are just recognized by the compiler and feature test
macros are generated (which this patch also brings tests for).

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Add xthead* extensions.
* config/riscv/riscv-opts.h (MASK_XTHEADBA): New.
(MASK_XTHEADBB): New.
(MASK_XTHEADBS): New.
(MASK_XTHEADCMO): New.
(MASK_XTHEADCONDMOV): New.
(MASK_XTHEADFMEMIDX): New.
(MASK_XTHEADFMV): New.
(MASK_XTHEADINT): New.
(MASK_XTHEADMAC): New.
(MASK_XTHEADMEMIDX): New.
(MASK_XTHEADMEMPAIR): New.
(MASK_XTHEADSYNC): New.
(TARGET_XTHEADBA): New.
(TARGET_XTHEADBB): New.
(TARGET_XTHEADBS): New.
(TARGET_XTHEADCMO): New.
(TARGET_XTHEADCONDMOV): New.
(TARGET_XTHEADFMEMIDX): New.
(TARGET_XTHEADFMV): New.
(TARGET_XTHEADINT): New.
(TARGET_XTHEADMAC): New.
(TARGET_XTHEADMEMIDX): New.
(TARGET_XTHEADMEMPAIR): new.
(TARGET_XTHEADSYNC): New.
* config/riscv/riscv.opt: Add riscv_xthead_subext.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadba.c: New test.
* gcc.target/riscv/xtheadbb.c: New test.
* gcc.target/riscv/xtheadbs.c: New test.
* gcc.target/riscv/xtheadcmo.c: New test.
* gcc.target/riscv/xtheadcondmov.c: New test.
* gcc.target/riscv/xtheadfmemidx.c: New test.
* gcc.target/riscv/xtheadfmv.c: New test.
* gcc.target/riscv/xtheadint.c: New test.
* gcc.target/riscv/xtheadmac.c: New test.
* gcc.target/riscv/xtheadmemidx.c: New test.
* gcc.target/riscv/xtheadmempair.c: New test.
* gcc.target/riscv/xtheadsync.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agoi386:Add missing OPTION_MASK_ISA_AVX512VL in i386-builtin.def for VAES builtins
Hu, Lin1 [Mon, 13 Mar 2023 07:50:11 +0000 (15:50 +0800)]
i386:Add missing OPTION_MASK_ISA_AVX512VL in i386-builtin.def for VAES builtins

gcc/ChangeLog:

PR target/109117
* config/i386/i386-builtin.def (__builtin_ia32_vaesdec_v16qi,
__builtin_ia32_vaesdeclast_v16qi,__builtin_ia32_vaesenc_v16qi,
__builtin_ia32_vaesenclast_v16qi): Require OPTION_MASK_ISA_AVX512VL.

gcc/testsuite/ChangeLog:

PR target/109117
* gcc.target/i386/pr109117-1.c: New test.

19 months agoDaily bump.
GCC Administrator [Wed, 15 Mar 2023 00:16:58 +0000 (00:16 +0000)]
Daily bump.

19 months agogcc/testsuite/gcc.dg: Fix pic test case for PE targets
Jonathan Yong [Tue, 14 Feb 2023 10:37:03 +0000 (10:37 +0000)]
gcc/testsuite/gcc.dg: Fix pic test case for PE targets

gcc/testsuite/ChangeLog:

* gcc.dg/pic-2.c: Fix expected __PIC__ value.
* gcc.dg/pic-3.c: Ditto.
* gcc.dg/pic-4.c: Ditto.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
19 months agoc++: redeclaring member of constrained class template [PR96830]
Patrick Palka [Tue, 14 Mar 2023 23:14:29 +0000 (19:14 -0400)]
c++: redeclaring member of constrained class template [PR96830]

An out-of-line definition of a member of a constrained class template
needs to repeat the template's constraints, but it turns out we don't
verify anywhere that the two sets of constraints match.  This patch
adds such a check to push_template_decl, nearby a similar consistency
check for the template parameter list lengths.

PR c++/96830

gcc/cp/ChangeLog:

* pt.cc (push_inline_template_parms_recursive): Set
TEMPLATE_PARMS_CONSTRAINTS.
(push_template_decl): For an out-of-line declaration, verify
constraints for each enclosing template scope match those of the
original template declaratation.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-class5.C: New test.
* g++.dg/cpp2a/concepts-class5a.C: New test.

19 months agoc++: constrained template friend class matching [PR96830]
Patrick Palka [Tue, 14 Mar 2023 23:12:08 +0000 (19:12 -0400)]
c++: constrained template friend class matching [PR96830]

When instantiating a constrained template friend naming an already
declared class template, tsubst_friend_class erroneously passes to
redeclare_class_template the existing template's constraints instead of
those of the friend declaration, which causes the constraint comparison
check therein to trivially succeed and we fail to diagnose legitimate
constraint mismatches.

PR c++/96830

gcc/cp/ChangeLog:

* pt.cc (redeclare_class_template): Add missing "of" in
constraint mismatch diagnostic.
(tsubst_friend_class): For an already declared class template,
substitute and pass the friend declaration's constraints to
redeclare_class_template instead of passing the existing
template's constraints.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-friend14.C: New test.

19 months agolibstdc++: Fix template-head of repeat_view::_Iterator [PR109111]
Patrick Palka [Tue, 14 Mar 2023 23:06:33 +0000 (19:06 -0400)]
libstdc++: Fix template-head of repeat_view::_Iterator [PR109111]

PR libstdc++/109111

libstdc++-v3/ChangeLog:

* include/std/ranges (repeat_view): Remove redundant parentheses
in requires-clause.
(repeat_view::_Iterator): Correct the requires-clause.

19 months agoc++: variable tmpl partial specialization [PR108468]
Jason Merrill [Tue, 14 Mar 2023 20:32:31 +0000 (16:32 -0400)]
c++: variable tmpl partial specialization [PR108468]

Generally we expect TPARMS_PRIMARY_TEMPLATE to be set, but sometimes it
isn't for partial instantiations.  This ought to be improved, but it's
trivial to work around it in this case.

PR c++/108468

gcc/cp/ChangeLog:

* pt.cc (unify_pack_expansion): Check that TPARMS_PRIMARY_TEMPLATE
is non-null.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/var-templ78.C: New test.

19 months agolibstdc++: Implement P2520R0 changes to move_iterator's iterator_concept
Patrick Palka [Tue, 14 Mar 2023 20:44:32 +0000 (16:44 -0400)]
libstdc++: Implement P2520R0 changes to move_iterator's iterator_concept

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (move_iterator::_S_iter_concept):
Define.
(__cpp_lib_move_iterator_concept): Define for C++20.
(move_iterator::iterator_concept): Strengthen as per P2520R0.
* include/std/version (__cpp_lib_move_iterator_concept): Define
for C++20.
* testsuite/24_iterators/move_iterator/p2520r0.cc: New test.

19 months agolibstdc++: Implement LWG 3715 changes to view_interface::empty
Patrick Palka [Tue, 14 Mar 2023 20:44:30 +0000 (16:44 -0400)]
libstdc++: Implement LWG 3715 changes to view_interface::empty

libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h (view_interface::empty): Add
preferred overloads that use ranges::size when the range is
sized as per LWG 3715.
* testsuite/std/ranges/adaptors/lwg3715.cc: New test.

19 months agoPR 109125 Modula2 SIGBUS in m2pim_ldtoa_ldtoa
Gaius Mulley [Tue, 14 Mar 2023 19:52:11 +0000 (19:52 +0000)]
PR 109125 Modula2 SIGBUS in m2pim_ldtoa_ldtoa

13 regression failures seen on sparc SIGBUS in m2pim_ldtoa_ldtoa.
This patch fixes int bool parameter mismatches between the
definition modules and their C/C++ implementations.

gcc/m2/ChangeLog:

PR modula2/109125
* gm2-libs-ch/cgetopt.c (cgetopt_SetOption): Replace int
for bool.
* gm2-libs-ch/termios.c (doSetUnset): Replace int for bool.
* gm2-libs/Builtins.mod (isfinitef): Correct typo in return
statement.

libgm2/ChangeLog:

PR modula2/109125
* libm2iso/ErrnoCategory.cc (FALSE): Remove.
(TRUE): Remove.
* libm2iso/wrapsock.c (TRUE): Remove.
(FALSE): Remove.
* libm2iso/wraptime.cc (TRUE): Remove.
(FALSE): Remove.
* libm2pim/cgetopt.cc: Replace int for bool for every BOOLEAN
parameter in the definition module.
* libm2pim/dtoa.cc: Ditto.
* libm2pim/ldtoa.cc: Ditto.
* libm2pim/termios.cc: Ditto.
(doSetUnset): Replace int for bool.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoc++: -Wreturn-type with if (true) throw [PR107310]
Jason Merrill [Tue, 14 Mar 2023 16:20:51 +0000 (12:20 -0400)]
c++: -Wreturn-type with if (true) throw [PR107310]

I removed this folding in GCC 12 because it was interfering with an
experiment of richi's, but that never went in and the change causes
regressions, so let's put it back.

This reverts commit r12-5638-ga3e75c1491cd2d.

PR c++/107310

gcc/cp/ChangeLog:

* cp-gimplify.cc (genericize_if_stmt): Restore folding
of constant conditions.

gcc/testsuite/ChangeLog:

* c-c++-common/Wimplicit-fallthrough-39.c: Adjust warning.
* g++.dg/warn/Wreturn-6.C: New test.

19 months agoi386: Fix up split_double_concat [PR109109]
Jakub Jelinek [Tue, 14 Mar 2023 18:20:23 +0000 (19:20 +0100)]
i386: Fix up split_double_concat [PR109109]

In my PR107627 change I've missed one important case, which causes
miscompilation of f4 and f6 in the following tests.

Combine matches there *concatsidi3_3 define_insn_and_split (as with all
other f* functions in those tests), and RA ends up with:
(insn 11 10 17 2 (set (reg:DI 0 ax [89])
        (ior:DI (ashift:DI (zero_extend:DI (mem:SI (plus:SI (mult:SI (reg:SI 0 ax [94])
                                (const_int 4 [0x4]))
                            (symbol_ref:SI ("arr") [flags 0x2]  <var_decl 0x7f4e7fe4ccf0 arr>)) [1 arr[ax_6(D)]+0 S4 A32]))
                (const_int 32 [0x20]))
            (zero_extend:DI (reg:SI 1 dx [95])))) "pr109109-6.c":24:49 681 {*concatsidi3_3}
     (nil))
split_double_concat turned that into:
        movl    arr(,%eax,4), %edx
        movl    %edx, %eax
which is incorrect, because the first instruction overrides the input
%edx value that should be put into output %eax; the two insns can't be
swapped because the MEM's address uses %eax.

The following patch fixes that case to emit
        movl    arr(,%eax,4), %eax
        xchgl   %edx, %eax
instead.

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

PR target/109109
* config/i386/i386-expand.cc (split_double_concat): Fix splitting
when lo is equal to dhi and hi is a MEM which uses dlo register.

* gcc.target/i386/pr109109-1.c: New test.
* gcc.target/i386/pr109109-2.c: New test.

19 months agod: Fix undefined reference to lambda defined in private enum [PR109108]
Iain Buclaw [Tue, 14 Mar 2023 12:16:11 +0000 (13:16 +0100)]
d: Fix undefined reference to lambda defined in private enum [PR109108]

Previously lambdas were connected to the module they were defined in.
Now they are emitted into every referencing compilation unit, and are
given one-only linkage.

PR d/109108

gcc/d/ChangeLog:

* decl.cc (function_defined_in_root_p): Remove.
(get_symbol_decl): Set DECL_LAMBDA_FUNCTION_P on function literals.
(start_function): Unconditionally unset DECL_EXTERNAL
(set_linkage_for_decl): Give lambda functions one-only linkage.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/imports/pr109108.d: New test.
* gdc.dg/torture/pr109108.d: New test.

19 months agoipa-cp: Improve updating behavior when profile counts have gone bad
Martin Jambor [Tue, 14 Mar 2023 17:53:16 +0000 (18:53 +0100)]
ipa-cp: Improve updating behavior when profile counts have gone bad

Looking into the behavior of profile count updating in PR 107925, I
noticed that an option not considered possible was actually happening,
and - with the guesswork in place to distribute unexplained counts -
it simply can happen.  Currently it is handled by dropping the counts
to local estimated zero, whereas it is probably better to leave the
count as they are but drop the category to GUESSED_GLOBAL0 - which is
what profile_count::combine_with_ipa_count in a similar case (or so I
hope :-)

gcc/ChangeLog:

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

PR ipa/107925
* ipa-cp.cc (update_profiling_info): Drop counts of orig_node to
global0 instead of zeroing when it does not have as many counts as
it should.

19 months agoipa-cp: Fix various issues in update_specialized_profile (PR 107925)
Martin Jambor [Tue, 14 Mar 2023 17:53:16 +0000 (18:53 +0100)]
ipa-cp: Fix various issues in update_specialized_profile (PR 107925)

The patch below fixes various issues in function
update_specialized_profile.  The main is removal of the assert which
is bogus in the case of recursive cloning.  The division of
unexplained counts is guesswork, which then leads to updates of counts
of recursive edges, which then can be redirected to the new clone and
their count subtracted from the count and there simply may not be
enough left in the count of the original node - especially when we
clone a lot because of using --param ipa-cp-eval-threshold=1.

The other issue was omission to drop the count of the original node to
ipa count.  And when calculating the remainder, we should use
lenient_count_portion_handling to account for partial train runs.
Finally, the patch adds dumping of the original count which I think
is useful.

gcc/ChangeLog:

2023-02-17  Martin Jambor  <mjambor@suse.cz>

PR ipa/107925
* ipa-cp.cc (update_specialized_profile): Drop orig_node_count to
ipa count, remove assert, lenient_count_portion_handling, dump
also orig_node_count.

19 months agoi386: Use movss to implement V2SImode VEC_PERM.
Uros Bizjak [Tue, 14 Mar 2023 17:41:06 +0000 (18:41 +0100)]
i386: Use movss to implement V2SImode VEC_PERM.

Perform V2SI vector permutation in the same way as existing V2SF for
TARGET_MMX_WITH_SSE targets. The testcase:

typedef unsigned int v2si __attribute__((vector_size(8)));
v2si foo(v2si x, v2si y) { return (v2si){y[0], x[1]}; }

is currently compiled to (-O2):

foo:
movdqa  %xmm0, %xmm2
movdqa  %xmm1, %xmm0
pshufd  $0xe5, %xmm2, %xmm2
punpckldq %xmm2, %xmm0
ret

and with the patched compiler:

foo:
movss   %xmm1, %xmm0
ret

The functionality is already tested in gcc.target/i386/vperm-v2si.c

gcc/ChangeLog:

* config/i386/i386-expand.cc (expand_vec_perm_movs):
Handle V2SImode for TARGET_MMX_WITH_SSE.
* config/i386/mmx.md (*mmx_movss_<mode>): Rename from *mmx_movss
using V2FI mode iterator to handle both V2SI and V2SF modes.

19 months agotestsuite: Fix up g++.dg/cpp2a/concepts-lambda3.C [PR108972]
Jakub Jelinek [Tue, 14 Mar 2023 15:18:47 +0000 (16:18 +0100)]
testsuite: Fix up g++.dg/cpp2a/concepts-lambda3.C [PR108972]

On Fri, Mar 10, 2023 at 01:49:38PM -0500, Jason Merrill via Gcc-patches wrote:
> gcc/testsuite/ChangeLog:
>
>       * g++.dg/cpp2a/concepts-lambda3.C: Run at lower std levels,
>       but expect errors.

I'm seeing
+UNRESOLVED: g++.dg/cpp2a/concepts-lambda3.C  -std=c++11 compilation failed to produce executable
+UNRESOLVED: g++.dg/cpp2a/concepts-lambda3.C  -std=c++14 compilation failed to produce executable
+UNRESOLVED: g++.dg/cpp2a/concepts-lambda3.C  -std=c++17 compilation failed to produce executable
+UNRESOLVED: g++.dg/cpp2a/concepts-lambda3.C  -std=c++98 compilation failed to produce executable
with this change, and if I test with
GXX_TESTSUITE_STDS=98,11,14,17,20,2b make check-g++ -k RUNTESTFLAGS="--target_board=unix\{-m32,-m64,-m64/-fconcepts\} dg.exp=concepts-lambda3.C"
I see even FAILs for the -fconcepts case, so apparently even -std=c++17
-fconcepts isn't enough to make it compile without errors.

The following patch will expect errors for all of c++17_down and will
make the test dg-do compile for that case too, such that the UNRESOLVED
stuff is gone.

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

PR c++/108972
PR testsuite/109129
* g++.dg/cpp2a/concepts-lambda3.C: Use dg-do run only for c++20,
for c++17_down dg-do compile.  Expect dg-excess-errors for c++17_down
rather than ! concepts.

19 months agoc++: Treat unnamed bitfields as padding for __has_unique_object_representations ...
Jakub Jelinek [Tue, 14 Mar 2023 15:17:32 +0000 (16:17 +0100)]
c++: Treat unnamed bitfields as padding for __has_unique_object_representations [PR109096]

As reported in the PR, for __has_unique_object_representations we
were treating unnamed bitfields as named ones, which is wrong, they
are actually padding.

THe following patch fixes that.

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

PR c++/109096
* tree.cc (record_has_unique_obj_representations): Ignore unnamed
bitfields.

* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.

19 months agoRISC-V: Avoid calloc() poisoning on musl
Sam James [Tue, 14 Mar 2023 00:23:53 +0000 (00:23 +0000)]
RISC-V: Avoid calloc() poisoning on musl

This fixes errors like:
```
In file included from /usr/include/pthread.h:30,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38,
                 from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38,
                 from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22:
/usr/include/sched.h:84:7: error: attempt to use poisoned "calloc"
   84 | void *calloc(size_t, size_t);
      |       ^
/usr/include/sched.h:124:36: error: attempt to use poisoned "calloc"
  124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
      |                                    ^
make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1
```

See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474,
which was fixed in PR106102.

gcc/ChangeLog:
* config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by
including <sstream> earlier.
* system.h: Add INCLUDE_SSTREAM.

Signed-off-by: Sam James <sam@gentoo.org>
19 months agoRemove variables only used with .DEFERRED_INIT
Richard Biener [Tue, 14 Mar 2023 08:42:45 +0000 (09:42 +0100)]
Remove variables only used with .DEFERRED_INIT

In PR109087 it was noticed that we rely on DSE to remove .DEFERRED_INIT
when it is the only remaining use of a variable.  Since DSE is imperfect
and even if it were not would be limited by the amount of statements to
walk the following enhances the unused var removal pass to handle
.DEFERRED_INIT like CLOBBERs, thus we do not keep local variables just
because they are deferred initialized.

* tree-ssa-live.cc (remove_unused_locals): Do not treat
the .DEFERRED_INIT of a variable as use, instead remove
that if it is the only use.

* gcc.dg/auto-init-unused-1.c: New testcase.

19 months agoAdd testcase for ifcvt fix
Eric Botcazou [Tue, 14 Mar 2023 10:28:24 +0000 (11:28 +0100)]
Add testcase for ifcvt fix

gcc/testsuite/
PR tree-optimization/109005
* gnat.dg/specs/opt6.ads: New test.

19 months agoRevert latest change to emit_group_store
Eric Botcazou [Tue, 14 Mar 2023 09:39:11 +0000 (10:39 +0100)]
Revert latest change to emit_group_store

This pessimizes on targets with insv instructions.

gcc/
PR rtl-optimization/107762
* expr.cc (emit_group_store): Revert latest change.

19 months agolibstdc++: Fix preprocessor condition for inline variables
Jonathan Wakely [Thu, 9 Mar 2023 15:04:45 +0000 (15:04 +0000)]
libstdc++: Fix preprocessor condition for inline variables

Although variable templates are valid in C++14, inline ones aren't.
These are only used in C++17 (or later) code, so they don't need to be
defined for C++14.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (__is_duration_v, __is_time_point_v):
Only define for C++17 and later.

19 months agolibstdc++: Add comment about symver linker scripts to makefile
Jonathan Wakely [Mon, 13 Mar 2023 18:20:20 +0000 (18:20 +0000)]
libstdc++: Add comment about symver linker scripts to makefile

libstdc++-v3/ChangeLog:

* src/Makefile.am: Add comment about linker script fragments.
* src/Makefile.in: Regenerate.

19 months agolibstdc++: Add assertions to std::mask_array operations [PR62196]
Jonathan Wakely [Mon, 6 Mar 2023 14:41:59 +0000 (14:41 +0000)]
libstdc++: Add assertions to std::mask_array operations [PR62196]

Add assertions to diagnose incorrect uses of valarray masks.

The assignment operators of std::mask_array do not have any explicit
preconditions in the standard, but the assignment operator
valarray<T>::operator=(const mask_array<T>&) requires the lengths to
match, so it seems consistent to also require that when the operands are
reversed.  In support of that interpretation, libstdc++ has undefined
behaviour if the right-hand operand has more elements than are selected
by the mask, and libc++ has undefined behaviour if it has fewer
elements. Our std::mask_array stores the number of selected elements as
_M_sz so it's easy to add an assertion that checks it.

For the valarray::operator[] that takes a valarray<bool> mask,
[valarray.sub] in the standard says: "In each case the selected
element(s) shall exist." This makes it undefined to have a mask that
refers to out-of-range elements. We can easily check this too.

libstdc++-v3/ChangeLog:

PR libstdc++/62196
* include/bits/mask_array.h (mask_array): Add assertions to
assignment operators.
* include/std/valarray (valarray::operator[](valarray<bool>)):
Add assertions.
* testsuite/26_numerics/valarray/mask-1_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-2_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-3_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-4_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-5_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-6_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-7_neg.cc: New test.
* testsuite/26_numerics/valarray/mask-8_neg.cc: New test.
* testsuite/26_numerics/valarray/mask.cc: New test.

19 months agotestsuite: move mla_1 test to aarch64 only [PR109118]
Tamar Christina [Tue, 14 Mar 2023 10:25:42 +0000 (10:25 +0000)]
testsuite: move mla_1 test to aarch64 only [PR109118]

I previously made the test generic, but there's no list
of targets that support integer MLA, and so it's not
really feasible for me to make this generic.

As such I've moved it to be AArch64 only.

gcc/testsuite/ChangeLog:

PR testsuite/109118
* gcc.dg/mla_1.c: Moved to...
* gcc.target/aarch64/sve/mla_3.c: ...here.

19 months agoifcvt: Lower bitfields only if suitable for scalar register [PR 109005]
Andre Vieira [Tue, 14 Mar 2023 09:51:38 +0000 (09:51 +0000)]
ifcvt: Lower bitfields only if suitable for scalar register [PR 109005]

This patch fixes the condition check for eligilibity of lowering bitfields,
where before we would check for non-BLKmode types, in the hope of excluding
unsuitable aggregate types, we now check directly the representative is not an
aggregate type, i.e. suitable for a scalar register.

gcc/ChangeLog:

PR tree-optimization/109005
* tree-if-conv.cc (get_bitfield_rep): Replace BLKmode check with
aggregate type check.

19 months agotree-vect-patterns: Fix up ICE in upper_bound [PR109115]
Jakub Jelinek [Tue, 14 Mar 2023 08:15:38 +0000 (09:15 +0100)]
tree-vect-patterns: Fix up ICE in upper_bound [PR109115]

As mentioned in the PR, range_of_expr returns false if the type
of the expression isn't suitable for corresponding range type,
but doesn't if the range is undefined for other reasons.  Still,
lower/upper_bound is defined only for ranges which actually have
at least one pair of subranges, VR_UNDEFINED range doesn't have it.

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

PR tree-optimization/109115
* tree-vect-patterns.cc (vect_recog_divmod_pattern): Don't use
r.upper_bound () on r.undefined_p () range.

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

19 months agoFix overactive sanity check in profile_count::to_sreal_scale
Jan Hubicka [Tue, 14 Mar 2023 08:10:35 +0000 (09:10 +0100)]
Fix overactive sanity check in profile_count::to_sreal_scale

As discussed in the PR log, profile_count::to_cgraph_frequency was originally
intended to work across function boundary and has some extra logic and sanity
check for that.  It is used only within single function and with current
API it can not really work well globally, so this patch synchronizes its
implementation with probability_in which does similar job but to determine
relative probability.

gcc/ChangeLog:

2023-03-14  Jan Hubicka  <hubicka@ucw.cz>

PR tree-optimization/106896
* profile-count.cc (profile_count::to_sreal_scale): Synchronize
implementatoin with probability_in; avoid some asserts.

19 months agoNew testcase
Richard Biener [Tue, 14 Mar 2023 07:25:52 +0000 (08:25 +0100)]
New testcase

This is a reduced testcase for an issue I ran into when trying to
improve PTA compile-time further, there wasn't any C family runfail
in the testsuite for this.

* g++.dg/torture/20230313.C: New testcase.

19 months agoDaily bump.
GCC Administrator [Tue, 14 Mar 2023 00:17:05 +0000 (00:17 +0000)]
Daily bump.

19 months agoPR 109103 Modula2 Missing function internal_error_at
Gaius Mulley [Mon, 13 Mar 2023 23:03:24 +0000 (23:03 +0000)]
PR 109103 Modula2 Missing function internal_error_at

m2expr.cc should call to internal_error_at, but that function
does not exist yet.  For symmetry with the other error reporting
functions, it should be added.  This patch provides this function
and also corrects obvious bool/int parameter mismatches in
m2options.h and m2expr.h.

gcc/m2/ChangeLog:

PR modula2/109103
* gm2-compiler/M2ALU.def (PushString): New parameter issueError.
* gm2-compiler/M2ALU.mod (PushString): New parameter issueError.
* gm2-compiler/SymbolTable.mod (PushString): New parameter issueError.
* gm2-gcc/m2decl.cc (m2decl_DetermineSizeOfConstant): Pass
location to interpret_m2_integer.
(m2decl_BuildConstLiteralNumber): New parameter issueError.
* gm2-gcc/m2expr.cc (m2expr_IsTrue): Replace int with bool.
(m2expr_IsFalse): Replace int with bool.
(m2expr_AreConstantsEqual): Replace int with bool.
(m2expr_BuildBinaryForeachWordDo): Call m2linemap_internal_error_at.
(append_digit): Ditto.
(m2expr_interpret_integer): Add location parameter.
(append_m2_digit): Call m2linemap_internal_error_at.
(m2expr_interpret_m2_integer): Add location parameter.
(m2expr_GetSizeOf): Replace sizeof with SIZE in error message.
* gm2-gcc/m2expr.h (m2expr_AreRealOrComplexConstantsEqual):
Replace int with bool.
(m2expr_AreConstantsEqual): Ditto.
(m2expr_IsFalse): Ditto.
(m2expr_IsTrue): Ditto.
(m2expr_interpret_integer): Add location parameter.
(m2expr_interpret_m2_integer): Add location parameter.
* gm2-gcc/m2linemap.cc (mformat_value): New function.
(expand_format): New function.
(expand_message): New function.
(gm2_internal_error_at): New function.
(m2linemap_internal_error_at): New function.
* gm2-gcc/m2linemap.h (m2linemap_internal_error_at): New function.
* gm2-gcc/m2options.h (M2Options_SetISO): Replace int with bool.
(M2Options_SetPIM): Ditto.
(M2Options_SetPIM2): Ditto.
(M2Options_SetPIM3): Ditto.
(M2Options_SetPIM4): Ditto.
(M2Options_SetFloatValueCheck): Ditto.
(M2Options_SetWholeValueCheck): Ditto.
(M2Options_GetISO): Ditto.
(M2Options_GetPIM): Ditto.
(M2Options_GetPIM2): Ditto.
(M2Options_GetPIM3): Ditto.
(M2Options_GetPIM4): Ditto.
(M2Options_GetPositiveModFloor): Ditto.
(M2Options_GetFloatValueCheck): Ditto.
(M2Options_GetWholeValueCheck): Ditto.
(M2Options_Setc): Ditto.
(M2Options_Getc): Ditto.
(M2Options_SetPPOnly): Ditto.
(M2Options_GetPPOnly): Ditto.
(M2Options_SetUselist): Ditto.
(M2Options_SetAutoInit): Ditto.
(M2Options_SetPositiveModFloor): Ditto.
(M2Options_SetNilCheck): Ditto.
(M2Options_SetWholeDiv): Ditto.
(M2Options_SetIndex): Ditto.
(M2Options_SetRange): Ditto.
(M2Options_SetReturnCheck): Ditto.
(M2Options_SetCaseCheck): Ditto.
(M2Options_SetCheckAll): Ditto.
(M2Options_SetExceptions): Ditto.
(M2Options_SetStyle): Ditto.
(M2Options_SetPedantic): Ditto.
(M2Options_SetPedanticParamNames): Ditto.
(M2Options_SetPedanticCast): Ditto.
(M2Options_SetExtendedOpaque): Ditto.
(M2Options_SetVerboseUnbounded): Ditto.
(M2Options_SetXCode): Ditto.
(M2Options_SetCompilerDebugging): Ditto.
(M2Options_SetQuadDebugging): Ditto.
(M2Options_SetDebugTraceQuad): Ditto.
(M2Options_SetDebugTraceAPI): Ditto.
(M2Options_SetSources): Ditto.
(M2Options_SetUnboundedByReference): Ditto.
(M2Options_SetDumpSystemExports): Ditto.
(M2Options_SetOptimizing): Ditto.
(M2Options_SetQuiet): Ditto.
(M2Options_SetCC1Quiet): Ditto.
(M2Options_SetCpp): Ditto.
(M2Options_SetSwig): Ditto.
(M2Options_SetWholeProgram): Ditto.
(M2Options_SetDebugFunctionLineNumbers): Ditto.
(M2Options_SetGenerateStatementNote): Ditto.
(M2Options_GetCpp): Ditto.
(M2Options_GetM2g): Ditto.
(M2Options_SetM2g): Ditto.
(M2Options_SetLowerCaseKeywords): Ditto.
(M2Options_SetVerbose): Ditto.
(M2Options_SetUnusedVariableChecking): Ditto.
(M2Options_SetUnusedParameterChecking): Ditto.
(M2Options_SetStrictTypeChecking): Ditto.
(M2Options_SetWall): Ditto.
(M2Options_SetSaveTemps): Ditto.
(M2Options_GetSaveTemps): Ditto.
(M2Options_SetScaffoldStatic): Ditto.
(M2Options_SetScaffoldDynamic): Ditto.
(M2Options_SetScaffoldMain): Ditto.
(M2Options_SetGenModuleList): Ditto.
(M2Options_SetShared): Ditto.
* gm2-libs-ch/M2LINK.c: Ditto.
* gm2-libs-ch/m2rts.h (M2RTS_RequestDependant): Replace
const char * with const void *.
(M2RTS_RegisterModule): Ditto.
(M2RTS_ConstructModules): Ditto.
* gm2-gcc/m2decl.def (DetermineSizeOfConstant): New parameter
issueError.
* gm2-gcc/m2decl.h (DetermineSizeOfConstant): New parameter
issueError.

gcc/testsuite/ChangeLog:

* gm2/pim/fail/largeconst.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoUpdate gcc sv.po
Joseph Myers [Mon, 13 Mar 2023 22:24:08 +0000 (22:24 +0000)]
Update gcc sv.po

* sv.po: Update.

19 months agoUpdate gcc de.po
Joseph Myers [Mon, 13 Mar 2023 22:16:46 +0000 (22:16 +0000)]
Update gcc de.po

* de.po: Update.

19 months agod: Delay removing DECL_EXTERNAL from thunks until funcion has finished
Iain Buclaw [Mon, 13 Mar 2023 21:04:24 +0000 (22:04 +0100)]
d: Delay removing DECL_EXTERNAL from thunks until funcion has finished

Second part to fixing PR109108, don't blindly generate the associated
function definition of all referenced thunks in the compilation. Just
delay finishing a thunk until the function gets codegen itself.  If the
function never gets a definition, then the thunk is left as "extern".

gcc/d/ChangeLog:

* decl.cc (finish_thunk): Unset DECL_EXTERNAL on thunk.
(make_thunk): Set DECL_EXTERNAL on thunk, don't call build_decl_tree.
(finish_function): Call finish_thunk on forward referenced thunks.

19 months agod: Refactor DECL_ARGUMENT and DECL_RESULT generation to own function
Iain Buclaw [Sun, 12 Mar 2023 20:43:31 +0000 (21:43 +0100)]
d: Refactor DECL_ARGUMENT and DECL_RESULT generation to own function

When looking into PR109108, the reason why things go awry is because
of the logic around functions with thunks - they have their definitions
generated even when they are external.  This subsequently then relied on
the detection of whether a function receiving codegen really is extern
or not, and this check ultimately prunes too much.

This is a first step to both removing the call to `build_decl_tree' from
`make_thunk' and the pruning of symbols within the `build_decl_tree'
visitor method for functions.  Move the generation of DECL_ARGUMENT and
DECL_RESULT out of `build_decl_tree' and into their own functions.

gcc/d/ChangeLog:

* decl.cc (get_fndecl_result): New function.
(get_fndecl_arguments): New function.
(DeclVisitor::visit (FuncDeclaration *)): Adjust to call
get_fndecl_arguments.
(make_thunk): Adjust to call get_fndecl_arguments and
get_fndecl_result.
(start_function): Adjust to call get_fndecl_result.

19 months agoxtensa: add .note.GNU-stack section on linux
Max Filippov [Thu, 2 Mar 2023 17:45:41 +0000 (09:45 -0800)]
xtensa: add .note.GNU-stack section on linux

gcc/
* config/xtensa/linux.h (TARGET_ASM_FILE_END): New macro.

libgcc/
* config/xtensa/crti.S: Add .note.GNU-stack section on linux.
* config/xtensa/crtn.S: Likewise.
* config/xtensa/lib1funcs.S: Likewise.
* config/xtensa/lib2funcs.S: Likewise.

19 months agoc++: handle _FloatNN redeclaration like bool [PR107128]
Jason Merrill [Mon, 13 Mar 2023 18:06:11 +0000 (14:06 -0400)]
c++: handle _FloatNN redeclaration like bool [PR107128]

It's been inconvenient to compile testcases preprocessed with GCC 12 or
earlier because they break on

  typedef __float128 _Float128;

We already had code for handling this with bool and wchar_t, it just needs
to be extended to _FloatNN as well.

PR c++/107128

gcc/cp/ChangeLog:

* parser.cc (cp_parser_set_decl_spec_type): Use
redefined_builtin_type for extended_float_type_p.

gcc/testsuite/ChangeLog:

* g++.dg/warn/pragma-system_header6.h: New test.
* g++.dg/warn/pragma-system_header6.C: New test.

19 months agoDocs: Fix double 'See' in zero-length-bounds docs.
Sean Bright [Mon, 13 Mar 2023 19:49:22 +0000 (19:49 +0000)]
Docs: Fix double 'See' in zero-length-bounds docs.

gcc/ChangeLog:
* doc/invoke.texi (Warning Options): Remove errant 'See'
before @xref.

19 months agotestsuite: add test coverage for analyzer leak false +ve [PR105906]
David Malcolm [Mon, 13 Mar 2023 18:53:05 +0000 (14:53 -0400)]
testsuite: add test coverage for analyzer leak false +ve [PR105906]

Adding regression test coverage; I believe I fixed this leak
false positive with r13-5113-g688fc162b76dc6.

gcc/testsuite/ChangeLog:
PR analyzer/105906
* gcc.dg/analyzer/leak-pr105906.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agotestsuite: add test coverage for PR analyzer/108045
David Malcolm [Mon, 13 Mar 2023 18:53:04 +0000 (14:53 -0400)]
testsuite: add test coverage for PR analyzer/108045

PR analyzer/108045 reports a leak false positive from -fanalyzer.

The false +ve as reported seems to have been fixed by
r13-6589-g14f5e56a8a766c, but with -fanalyzer-call-summaries there are
two additional false +ves which aren't fixed by that commit.

This patch adds test coverage for these cases.

gcc/testsuite/ChangeLog:
PR analyzer/108045
* gcc.dg/analyzer/leak-pr108045-with-call-summaries.c: New test.
* gcc.dg/analyzer/leak-pr108045-without-call-summaries.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>