platform/upstream/gcc.git
2 years agoDaily bump.
GCC Administrator [Wed, 30 Mar 2022 00:16:49 +0000 (00:16 +0000)]
Daily bump.

2 years agoanalyzer: skip constant pool in -fdump-analyzer-untracked [PR testsuite/105085]
David Malcolm [Tue, 29 Mar 2022 21:50:48 +0000 (17:50 -0400)]
analyzer: skip constant pool in -fdump-analyzer-untracked [PR testsuite/105085]

In r12-7809-g5f6197d7c197f9 I added -fdump-analyzer-untracked as support
for DejaGnu testing of an optimization of -fanalyzer,
PR analyzer/104954.

PR testsuite/105085 notes testsuite failures of the form:
  FAIL: gcc.dg/analyzer/untracked-1.c (test for excess errors)
  Excess errors:
  cc1: warning: track '*.LC1': yes
where these warnings are emitted on some targets where the test
causes labelled constants to be created in the constant pool.

We probably ought not to be tracking the values of such decls in the
store, given that they're meant to be constant, and I attempted various
fixes to make the "should we track this decl" logic smarter, but given
that we're in stage 4, the simplest fix seems to be for
-fdump-analyzer-untracked to skip such decls in its output, to minimize
test output differences between targets.

gcc/analyzer/ChangeLog:
PR testsuite/105085
* region-model-manager.cc (dump_untracked_region): Skip decls in
the constant pool.

gcc/testsuite/ChangeLog:
PR testsuite/105085
* gcc.dg/analyzer/untracked-1.c: Add further test coverage.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoFortran: avoid NULL pointer dereference checking elemental procedure args
Harald Anlauf [Tue, 29 Mar 2022 20:12:15 +0000 (22:12 +0200)]
Fortran: avoid NULL pointer dereference checking elemental procedure args

gcc/fortran/ChangeLog:

PR fortran/104571
* resolve.cc (resolve_elemental_actual): Avoid NULL pointer
dereference.

gcc/testsuite/ChangeLog:

PR fortran/104571
* gfortran.dg/pr104571.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 years agotestsuite: Allow setting gpp_std_list in configuration files
Jonathan Wakely [Tue, 29 Mar 2022 10:17:01 +0000 (11:17 +0100)]
testsuite: Allow setting gpp_std_list in configuration files

This allows the gpp_std_list variable to be set in ~/.dejagnurc instead
of using the GXX_TESTSUITE_STDS environment variable.  This is
consistent with how other defaults such as tool_timeout can be set.

The environment variable can still be used to override the default.

gcc/testsuite/ChangeLog:

* lib/g++-dg.exp: Update comments.
* lib/g++.exp (gpp_std_list): Check for an existing value before
setting it to an empty list.

2 years agotestsuite: Disable tests for C++23 that depend on std::unexpected
Jonathan Wakely [Mon, 28 Mar 2022 21:05:01 +0000 (22:05 +0100)]
testsuite: Disable tests for C++23 that depend on std::unexpected

These tests depend on unexpected handlers, which are no longer declared
for C++23 mode. Adjust the target specifier so they don't run.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept06.C: Disable for C++23.

libstdc++-v3/ChangeLog:

* testsuite/18_support/exception/38732.cc: Disable for C++23.
* testsuite/18_support/headers/exception/synopsis.cc: Likewise.
* testsuite/18_support/unexpected_handler.cc: Likewise.

2 years agoUpdate gcc hr.po
Joseph Myers [Tue, 29 Mar 2022 19:01:02 +0000 (19:01 +0000)]
Update gcc hr.po

* hr.po: Update.

2 years agoFortran: character length of pointer assignments in structure constructors
Harald Anlauf [Sun, 27 Mar 2022 19:35:15 +0000 (21:35 +0200)]
Fortran: character length of pointer assignments in structure constructors

gcc/fortran/ChangeLog:

PR fortran/50549
* resolve.cc (resolve_structure_cons): Reject pointer assignments
of character with different lengths in structure constructor.

gcc/testsuite/ChangeLog:

PR fortran/50549
* gfortran.dg/char_pointer_assign_7.f90: New test.

2 years agogimple: Wrong -Wimplicit-fallthrough with if(1) [PR103597]
Marek Polacek [Mon, 28 Mar 2022 22:19:20 +0000 (18:19 -0400)]
gimple: Wrong -Wimplicit-fallthrough with if(1) [PR103597]

This patch fixes a wrong -Wimplicit-fallthrough warning for

    case 0:
      if (1)  // wrong may fallthrough
return 0;
    case 1:

which in .gimple looks like

    <D.1981>: // case 0
    if (1 != 0) goto <D.1985>; else goto <D.1986>;
    <D.1985>:
    D.1987 = 0;
    // predicted unlikely by early return (on trees) predictor.
    return D.1987;
    <D.1986>:  // dead
    <D.1982>: // case 1

and the warning thinks that <D.1986>: falls through to <D.1982>:.  It
does not know that <D.1986> is effectively a dead label, only reachable
through fallthrough from previous instructions, never jumped to.  To
that effect, Jakub introduced UNUSED_LABEL_P, which is set on such dead
labels.

collect_fallthrough_labels has code to deal with cases like

    case 2:
      if (e != 10)
i++; // this may fallthru, warn
      else
return 44;
    case 3:

which collects labels that may fall through.  Here it sees the "goto <D.1990>;"
at the end of the then branch and so when the warning reaches

    ...
    <D.1990>: // from if-then
    <D.1984>: // case 3

it knows it should warn about the possible fallthrough.  But an UNUSED_LABEL_P
is not a label that can fallthrough like that, so it should ignore those.

However, we still want to warn about this:

    case 0:
      if (1)
n++; // falls through
    case 1:

so collect_fallthrough_labels needs to return the "n = n + 1;" statement, rather
than the dead label.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
PR middle-end/103597

gcc/ChangeLog:

* gimplify.cc (collect_fallthrough_labels): Don't push UNUSED_LABEL_Ps
into labels.  Maybe set prev to the statement preceding UNUSED_LABEL_P.
(gimplify_cond_expr): Set UNUSED_LABEL_P.
* tree.h (UNUSED_LABEL_P): New.

gcc/testsuite/ChangeLog:

* c-c++-common/Wimplicit-fallthrough-39.c: New test.

2 years agoc-family: Add -Wmisleading-indentation testcase [PR71637]
Patrick Palka [Tue, 29 Mar 2022 17:44:05 +0000 (13:44 -0400)]
c-family: Add -Wmisleading-indentation testcase [PR71637]

We no longer emit a bogus warning for the below testcase after
r11-3266-g4839de55e2c986.

PR c++/71637

gcc/testsuite/ChangeLog:

* c-c++-common/Wmisleading-indentation-6.c: New test.

2 years agoAllow vsx_extract_<mode> to use Altivec registers.
Michael Meissner [Tue, 29 Mar 2022 17:14:43 +0000 (13:14 -0400)]
Allow vsx_extract_<mode> to use Altivec registers.

I noticed that the vsx_extract_<mode> pattern for V2DImode and V2DFmode
only allowed traditional floating point registers, and it did not allow
Altivec registers.  The original code was written a few years ago when we
used the old register allocator, and support for scalar floating point in
Altivec registers was just being added to GCC.

I have built the spec 2017 benchmark suite With all 4 patches in this
series applied, and compared it to the build with the previous 3 patches
applied.  In addition to the changes from the previous 3 patches, this
patch now changes the code for the following 3 benchmarks (2 floating
point, 1 integer):

bwaves_r, fotonik3d_r, xalancbmk_r

I have built bootstrap versions on the following systems.  There were no
regressions in the runs:

Power9 little endian, --with-cpu=power9
Power10 little endian, --with-cpu=power10
Power8 big endian, --with-cpu=power8 (both 32-bit & 64-bit tests)

2022-03-29   Michael Meissner  <meissner@linux.ibm.com>

gcc/
* config/rs6000/vsx.md (vsx_extract_<mode>): Allow destination to
be any VSX register.

2 years agoaarch64: correctly handle zero-sized bit-fields in AAPCS64 [PR102024]
Richard Earnshaw [Tue, 29 Mar 2022 15:07:09 +0000 (16:07 +0100)]
aarch64: correctly handle zero-sized bit-fields in AAPCS64 [PR102024]

On aarch64 the AAPCS64 states that an HFA is determined by the 'shape' of
the object after layout has been completed, so anything that adds no
members and does not cause the layout to be modified should be ignored
for the purposes of determining which registers are used for parameter
passing.

A zero-sized bit-field falls into this category.  This was not handled
correctly for C structs and in G++-11 only handled correctly because
such fields were eliminated early by the front end.

gcc/ChangeLog:

PR target/102024
* config/aarch64/aarch64.cc (aapcs_vfp_sub_candidate): Handle
zero-sized bit-fields.  Detect cases where a warning may be needed.
(aarch64_vfp_is_call_or_return_candidate): Emit a note if a
zero-sized bit-field has caused parameter passing to change.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/aapcs64/test_28.c: New test.

2 years agoarm: correctly handle zero-sized bit-fields in AAPCS [PR102024]
Richard Earnshaw [Tue, 29 Mar 2022 09:24:49 +0000 (10:24 +0100)]
arm: correctly handle zero-sized bit-fields in AAPCS [PR102024]

On arm the AAPCS states that an HFA is determined by the 'shape' of
the object after layout has been completed, so anything that adds no
members and does not cause the layout to be modified should be ignored
for the purposes of determining which registers are used for parameter
passing.

A zero-sized bit-field falls into this category.  This was not handled
correctly for C structs and in G++-11 only handled correctly because
such fields were eliminated early by the front end.

gcc/ChangeLog:

PR target/102024
* config/arm/arm.cc (aapcs_vfp_sub_candidate): Handle zero-sized
bit-fields.  Detect cases where a warning may be needed.
(aapcs_vfp_is_call_or_return_candidate): Emit a note if
a zero-sized bit-field has caused parameter passing to change.

gcc/testsuite/ChangeLog:

PR target/102024
* gcc.target/arm/aapcs/vfp26.c: New test.

2 years agoarm: temporarily disable 'local' pcs selection (PR96882)
Richard Earnshaw [Tue, 29 Mar 2022 15:59:37 +0000 (16:59 +0100)]
arm: temporarily disable 'local' pcs selection (PR96882)

The arm port has an optimization used during selection of the
function's ABI to permit deviation from the strict ABI when the
function does not escape the current translation unit.

Unfortunately, the ABI selection it makes can be unsafe if it changes
how a result is returned because not enough information is available
via the RETURN_IN_MEMORY hook to determine where the function gets
used.  This can result in some parts of the compiler thinking a value
is returned in memory while others think it is returned in registers.

To mitigate this, this patch temporarily disables the optimization and
falls back to using the default ABI for the translation.

gcc/ChangeLog:

PR target/96882
* config/arm/arm.cc (arm_get_pcs_model): Disable selection of
ARM_PCS_AAPCS_LOCAL.

2 years ago[nvptx] Add __PTX_ISA_VERSION_{MAJOR,MINOR}__
Tom de Vries [Tue, 29 Mar 2022 14:04:09 +0000 (16:04 +0200)]
[nvptx] Add __PTX_ISA_VERSION_{MAJOR,MINOR}__

Add preprocessor macros __PTX_ISA_VERSION_MAJOR__ and
__PTX_ISA_VERSION_MINOR__.

For the default 6.0, we have:
...
 $ echo | cc1 -E -dD - 2>&1 | grep PTX_ISA_VERSION
 #define __PTX_ISA_VERSION_MAJOR__ 6
 #define __PTX_ISA_VERSION_MINOR__ 0
...
and for 3.1, we have:
...
 $ echo | cc1 -mptx=3.1 -E -dD - 2>&1 | grep PTX_ISA_VERSION
 #define __PTX_ISA_VERSION_MAJOR__ 3
 #define __PTX_ISA_VERSION_MINOR__ 1
...

These can be used to express things like:
...
 #if __PTX_ISA_VERSION_MAJOR__ >= 4 && __PTX_ISA_VERSION_MAJOR__ >= 1
   /* Code using %dynamic_smem_size.  */
 #else
   /* Fallback code.  */
 #endif
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

PR target/104857
* config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Emit
__PTX_ISA_VERSION_MAJOR__ and __PTX_ISA_VERSION_MINOR__.
* config/nvptx/nvptx.cc (ptx_version_to_number): New function.
* config/nvptx/nvptx-protos.h (ptx_version_to_number): Declare.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

PR target/104857
* gcc.target/nvptx/ptx31.c: New test.
* gcc.target/nvptx/ptx60.c: New test.
* gcc.target/nvptx/ptx63.c: New test.
* gcc.target/nvptx/ptx70.c: New test.

2 years ago[nvptx] Update help text for m64
Tom de Vries [Tue, 29 Mar 2022 12:24:41 +0000 (14:24 +0200)]
[nvptx] Update help text for m64

In the docs we have for m64:
...
Ignored, but preserved for backward compatibility.  Only 64-bit ABI is
supported.
...

But with --target-help, we have instead:
...
$ gcc --target-help
  ...
  -m64    Generate code for a 64-bit ABI.
...
which could be interpreted as meaning that generating code for a 32-bit ABI is
still possible.

Fix this by instead emitting the same text as in the docs:
...
  -m64    Ignored, but preserved for backward compatibility.  Only 64-bit
          ABI is supported.
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.opt (m64): Update help text to reflect that it
is ignored.

2 years ago[nvptx] Add march-map
Tom de Vries [Tue, 29 Mar 2022 08:32:13 +0000 (10:32 +0200)]
[nvptx] Add march-map

Say we have an sm_50 board, and we want to run a benchmark using the highest
possible march setting.

Currently there's march=sm_30, march=sm_35, march=sm_53, but no march=sm_50.

So, we'd need to pick march=sm_35.

Likewise, for a test script that handles multiple boards, we'd need a mapping
from native board sm_xx to march, which might have to be updated with newer
gcc releases.

Add an option march-map, such that we can just specify march-map=sm_50, and
let the compiler map this to the appropriate march.

The option is implemented as a list of aliases, such that we have a somewhat
lengthy (17 lines in total):
...
$ gcc --help=target
  ...
  -march-map=sm_30            Same as -misa=sm_30.
  -march-map=sm_32            Same as -misa=sm_30.
  ...
  -march-map=sm_87            Same as -misa=sm_80.
  -march-map=sm_90            Same as -misa=sm_80.
...

This implementation was chosen in the hope that it'll be easier if
we end up with some misa multilib.

It would be nice to have the mapping list generated from an updated
nvptx-sm.def, but for now it's spelled out in nvptx.opt.

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

PR target/104714
* config/nvptx/nvptx.opt (march-map=*): Add aliases.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

PR target/104714
* gcc.target/nvptx/march-map.c: New test.

2 years agoDisable gathers for znver3 for vectors with 2 or 4 elements
Jan Hubicka [Tue, 29 Mar 2022 11:59:14 +0000 (13:59 +0200)]
Disable gathers for znver3 for vectors with 2 or 4 elements

gcc/ChangeLog:

2022-03-28  Jan Hubicka  <hubicka@ucw.cz>

* config/i386/i386-builtins.cc (ix86_vectorize_builtin_gather): Test
TARGET_USE_GATHER_2PARTS and TARGET_USE_GATHER_4PARTS.
* config/i386/i386.h (TARGET_USE_GATHER_2PARTS): New macro.
(TARGET_USE_GATHER_4PARTS): New macro.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): New tune
(X86_TUNE_USE_GATHER_4PARTS): New tune

2 years ago[nvptx] Add march alias for misa
Tom de Vries [Tue, 29 Mar 2022 08:31:51 +0000 (10:31 +0200)]
[nvptx] Add march alias for misa

The target option misa has the following description:
...
$ gcc --target-help 2>&1 | grep misa
  -misa=                      Specify the PTX ISA target architecture to use.
...

The name misa is somewhat poorly chosen.  It suggests that for a use
-misa=sm_30, sm_30 is the name of a specific Instruction Set Architecture.
Instead, sm_30 is the name of a specific target architecture in the generic
PTX Instruction Set Architecture.

Futhermore, there's mptx, which also has ISA in the description:
...
  -mptx=                      Specify the PTX ISA version to use.
...

Add the more intuitive alias march for misa:
...
$ gcc --target-help 2>&1 | grep march
  -march=                     Alias:  Same as -misa=.
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.opt (march): Add alias of misa.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

* gcc.target/nvptx/main.c: New test.
* gcc.target/nvptx/march.c: New test.

2 years agoMAINTAINERS: Add myself and Lulu as LoongArch port maintainer.
Chenghua Xu [Tue, 29 Mar 2022 09:56:06 +0000 (17:56 +0800)]
MAINTAINERS: Add myself and Lulu as LoongArch port maintainer.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>

ChangeLog:

* MAINTAINERS: (CPU Port Maintainers): Add myself and
Lulu as LoongArch port maintainer.

2 years agoLoongArch Port: Add doc.
chenglulu [Sat, 27 Nov 2021 07:09:39 +0000 (15:09 +0800)]
LoongArch Port: Add doc.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* doc/install.texi: Add LoongArch options section.
* doc/invoke.texi: Add LoongArch options section.
* doc/md.texi: Add LoongArch options section.

contrib/ChangeLog:

* config-list.mk: Add LoongArch triplet.

2 years agoLoongArch Port: gcc/testsuite
chenglulu [Sat, 27 Nov 2021 07:07:31 +0000 (15:07 +0800)]
LoongArch Port: gcc/testsuite

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-rom.C: Add build options for LoongArch.
* g++.old-deja/g++.abi/ptrmem.C: Add LoongArch support.
* g++.old-deja/g++.pt/ptrmem6.C: xfail for LoongArch.
* gcc.dg/20020312-2.c: Add LoongArch support.
* c-c++-common/zero-scratch-regs-10.c: Like wise
* c-c++-common/zero-scratch-regs-11.c: Like wise
* c-c++-common/zero-scratch-regs-8.c: Like wise
* c-c++-common/zero-scratch-regs-9.c: Like wise
* gcc.dg/loop-8.c: Skip on LoongArch.
* gcc.dg/torture/stackalign/builtin-apply-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-3.c: Likewise.
* go.test/go-test.exp: Define the LoongArch target.
* lib/target-supports.exp: Like wise.
* gcc.target/loongarch/loongarch.exp: New file.
* gcc.target/loongarch/tst-asm-const.c: Like wise.
* gcc.target/loongarch/larch-builtin.c: Like wise.

2 years agoLoongArch Port: libgomp
chenglulu [Sat, 27 Nov 2021 07:07:04 +0000 (15:07 +0800)]
LoongArch Port: libgomp

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

libgomp/ChangeLog:

* configure.tgt: Add LoongArch triplet.

2 years agoLoongArch Port: Regenerate libgcc/configure.
chenglulu [Sat, 27 Nov 2021 07:06:34 +0000 (15:06 +0800)]
LoongArch Port: Regenerate libgcc/configure.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

libgcc/ChangeLog:

* configure: Regenerate file.

2 years agoLoongArch Port: libgcc
chenglulu [Sat, 27 Nov 2021 07:05:47 +0000 (15:05 +0800)]
LoongArch Port: libgcc

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

libgcc/ChangeLog:

* config/loongarch/crtfastmath.c: New file.
* config/loongarch/linux-unwind.h: Like wise.
* config/loongarch/sfp-machine.h: Like wise.
* config/loongarch/t-crtstuff: Like wise.
* config/loongarch/t-loongarch: Like wise.
* config/loongarch/t-loongarch64: Like wise.
* config/loongarch/t-softfp-tf: Like wise.
* config.host: Add LoongArch tuples.
* configure.ac: Add LoongArch support.

2 years agoLoongArch Port: Builtin macros.
chenglulu [Sat, 27 Nov 2021 07:02:46 +0000 (15:02 +0800)]
LoongArch Port: Builtin macros.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* config/loongarch/loongarch-c.cc

2 years agoLoongArch Port: Builtin functions.
chenglulu [Sat, 27 Nov 2021 07:00:22 +0000 (15:00 +0800)]
LoongArch Port: Builtin functions.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* config/loongarch/larchintrin.h: New file.
* config/loongarch/loongarch-builtins.cc: New file.

2 years agoLoongArch Port: Machine description C files and .h files.
chenglulu [Sat, 27 Nov 2021 06:58:21 +0000 (14:58 +0800)]
LoongArch Port: Machine description C files and .h files.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* config/host-linux.cc: Add LoongArch support.
* config/loongarch/loongarch-protos.h: New file.
* config/loongarch/loongarch-tune.h: Likewise.
* config/loongarch/loongarch.cc: Likewise.
* config/loongarch/loongarch.h: Likewise.

2 years agoLoongArch Port: Machine description files.
chenglulu [Sat, 27 Nov 2021 06:50:20 +0000 (14:50 +0800)]
LoongArch Port: Machine description files.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* config/loongarch/constraints.md: New file.
* config/loongarch/generic.md: New file.
* config/loongarch/la464.md: New file.
* config/loongarch/loongarch-ftypes.def: New file.
* config/loongarch/loongarch-modes.def: New file.
* config/loongarch/loongarch.md: New file.
* config/loongarch/predicates.md: New file.
* config/loongarch/sync.md: New file.

2 years agoLoongArch Port: Regenerate gcc/configure.
chenglulu [Thu, 2 Dec 2021 06:15:50 +0000 (14:15 +0800)]
LoongArch Port: Regenerate gcc/configure.

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* configure: Regenerate file.

2 years agoLoongArch Port: gcc build
chenglulu [Sat, 27 Nov 2021 06:42:57 +0000 (14:42 +0800)]
LoongArch Port: gcc build

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

* common/config/loongarch/loongarch-common.cc: New file.
* config/loongarch/genopts/genstr.sh: New file.
* config/loongarch/genopts/loongarch-strings: New file.
* config/loongarch/genopts/loongarch.opt.in: New file.
* config/loongarch/loongarch-str.h: New file.
* config/loongarch/gnu-user.h: New file.
* config/loongarch/linux.h: New file.
* config/loongarch/loongarch-cpu.cc: New file.
* config/loongarch/loongarch-cpu.h: New file.
* config/loongarch/loongarch-def.c: New file.
* config/loongarch/loongarch-def.h: New file.
* config/loongarch/loongarch-driver.cc: New file.
* config/loongarch/loongarch-driver.h: New file.
* config/loongarch/loongarch-opts.cc: New file.
* config/loongarch/loongarch-opts.h: New file.
* config/loongarch/loongarch.opt: New file.
* config/loongarch/t-linux: New file.
* config/loongarch/t-loongarch: New file.
* config.gcc: Add LoongArch support.
* configure.ac: Add LoongArch support.

contrib/ChangeLog:

* gcc_update (files_and_dependencies): Add
  config/loongarch/loongarch.opt and config/loongarch/loongarch-str.h.

2 years agoLoongArch Port: Regenerate configure
chenglulu [Sat, 27 Nov 2021 07:09:11 +0000 (15:09 +0800)]
LoongArch Port: Regenerate configure

2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
    Lulu Cheng  <chenglulu@loongson.cn>

ChangeLog:

* configure.ac: Add LoongArch tuples.
* configure: Regenerate.

config/ChangeLog:

* picflag.m4: Default add build option '-fpic' for LoongArch.

2 years agooptions: Fix 'enabledby_negargs' typo in 'LangEnabledBy' option property diagnostics
Thomas Schwinge [Mon, 28 Mar 2022 08:25:16 +0000 (10:25 +0200)]
options: Fix 'enabledby_negargs' typo in 'LangEnabledBy' option property diagnostics

Originally introduced almost ten years ago in
r193303/commit 0829c7f7c5210cd1581042115cfe95c97283f44c
"optc-gen.awk: Factor code out to...".

gcc/
* opt-functions.awk (lang_enabled_by): Fix 'enabledby_negargs'
typo.

2 years agolibstdc++: Workaround for missing 'using enum' in Clang 12
Jonathan Wakely [Mon, 28 Mar 2022 11:27:23 +0000 (12:27 +0100)]
libstdc++: Workaround for missing 'using enum' in Clang 12

Once we no longer care about older compilers without this feature, we
can drop these static data members, so the names don't have to be
visible at class scope.

libstdc++-v3/ChangeLog:

* libsupc++/compare (_Strong_order) [!__cpp_using_enum]: Add
static data members for _Fp_fmt enumerators.

2 years agolibstdc++: Fix incorrect preprocessor conditions in <version>
Jonathan Wakely [Mon, 28 Mar 2022 10:39:21 +0000 (11:39 +0100)]
libstdc++: Fix incorrect preprocessor conditions in <version>

The conditions that guard the feature test macros in <version> should
match the main definitions of the macros in other headers.

This doesn't matter for GCC, because it supports all the conditions
being tested here, but it does matter for non-GCC compilers without the
relevant C++20 features.

libstdc++-v3/ChangeLog:

* include/std/version (__cpp_lib_variant): Fix conditions to
match <variant>.
(__cpp_lib_expected): Fix condition to match <expected>.

2 years agotestsuite: Check fpic support in pr103275.c
Marc Poulhiès [Mon, 21 Feb 2022 10:54:28 +0000 (10:54 +0000)]
testsuite: Check fpic support in pr103275.c

Test must check for effective support of fpic.

gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103275.c: Add missing
dg-require-effective-target for checking fpic.

2 years agotestsuite: fixup pr97521.c and pr96713.c on i686-*
Marc Poulhiès [Tue, 8 Mar 2022 16:05:52 +0000 (16:05 +0000)]
testsuite: fixup pr97521.c and pr96713.c on i686-*

On targets that do not have MXX/SSE enabled by default, pr97521
and pr96713 fail because they emit warnings:

pr97521.c:12:1: warning: MMX vector return without MMX enabled
                changes the ABI [-Wpsabi]
pr97521.c:11:1: note: the ABI for passing parameters with
                16-byte alignment has changed in GCC 4.6
pr97521.c:11:1: warning: SSE vector argument without SSE enabled
                changes the ABI [-Wpsabi]

Add -Wno-psabi to dg-options.

gcc/testsuite/ChangeLog:
* gcc.target/i386/pr97521.c: Add -Wno-psabi to dg-options.
* gcc.dg/analyzer/pr96713.c: Likewise.

2 years agotree-optimization/105080 - make sure SCEV is available for ranger
Richard Biener [Mon, 28 Mar 2022 12:55:49 +0000 (14:55 +0200)]
tree-optimization/105080 - make sure SCEV is available for ranger

When doing format diagnostics at -O0 we should make sure to make
SCEV available to avoid false positives due to ranges we otherwise
can trivially compute.

2022-03-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105080
* tree-ssa-strlen.cc (printf_strlen_execute): Always init
loops and SCEV.

* gcc.dg/pr105080.c: New testcase.

2 years agoanalyzer: ensure that we purge state when reusing a conjured_svalue [PR105087]
David Malcolm [Tue, 29 Mar 2022 00:41:23 +0000 (20:41 -0400)]
analyzer: ensure that we purge state when reusing a conjured_svalue [PR105087]

PR analyzer/105087 describes a false positive from
-Wanalyzer-double-free in which the analyzer erroneously considers two
successive inlined vasprintf calls to have allocated the same pointer.

The root cause is that the result written back from vasprintf is a
conjured_svalue, and that we normally purge state when reusing a
conjured_svalue, but various places in the code were calling
region_model_manager::get_or_create_conjured_svalue but failing to
then call region_model::purge_state_involving on the result.

This patch fixes things by moving responsibility for calling
region_model::purge_state_involving into
region_model_manager::get_or_create_conjured_svalue, so that it is
always called when reusing a conjured_svalue, fixing the false positive.

gcc/analyzer/ChangeLog:
PR analyzer/105087
* analyzer.h (class conjured_purge): New forward decl.
* region-model-asm.cc (region_model::on_asm_stmt): Add
conjured_purge param to calls binding_cluster::on_asm and
region_model_manager::get_or_create_conjured_svalue.
* region-model-impl-calls.cc
(call_details::get_or_create_conjured_svalue): Likewise for call
to region_model_manager::get_or_create_conjured_svalue.
(region_model::impl_call_fgets): Remove call to
region_model::purge_state_involving, as this is now done
implicitly by call_details::get_or_create_conjured_svalue.
(region_model::impl_call_fread): Likewise.
(region_model::impl_call_strchr): Pass conjured_purge param to
call to region_model_manager::get_or_create_conjured_svalue.
* region-model-manager.cc (conjured_purge::purge): New.
(region_model_manager::get_or_create_conjured_svalue): Add
param "p".  Use it to purge state when reusing an existing
conjured_svalue.
* region-model.cc (region_model::on_call_pre): Replace call to
region_model::purge_state_involving with passing conjured_purge
to region_model_manager::get_or_create_conjured_svalue.
(region_model::handle_unrecognized_call): Pass conjured_purge to
store::on_unknown_fncall.
* region-model.h
(region_model_manager::get_or_create_conjured_svalue): Add param
"p".
* store.cc (binding_cluster::on_unknown_fncall): Likewise.  Pass
it on to region_model_manager::get_or_create_conjured_svalue.
(binding_cluster::on_asm): Likewise.
(store::on_unknown_fncall): Add param "p" and pass it on to
binding_cluster::on_unknown_fncall.
* store.h (binding_cluster::on_unknown_fncall): Add param p.
(binding_cluster::on_asm): Likewise.
(store::on_unknown_fncall): Likewise.
* svalue.h (class conjured_purge): New.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/pr105087-1.c: New test.
* gcc.dg/analyzer/pr105087-2.c: New test.
* gcc.dg/analyzer/vasprintf-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix ICE with incorrect lookup of cgraph node [PR105074]
David Malcolm [Tue, 29 Mar 2022 00:40:16 +0000 (20:40 -0400)]
analyzer: fix ICE with incorrect lookup of cgraph node [PR105074]

gcc/analyzer/ChangeLog:
PR analyzer/105074
* region.cc (ipa_ref_requires_tracking): Drop "context_fndecl",
instead using the ref->referring to get the cgraph node of the
caller.
(symnode_requires_tracking_p): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/105074
* gcc.dg/analyzer/pr105074.c: New test.
* gcc.dg/analyzer/untracked-1.c (extern_fn_char_ptr): New decl.
(test_13): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoDaily bump.
GCC Administrator [Tue, 29 Mar 2022 00:17:13 +0000 (00:17 +0000)]
Daily bump.

2 years agoctfout: use ctfc_get_num_ctf_vars instead
Indu Bhagat [Mon, 28 Mar 2022 20:24:45 +0000 (13:24 -0700)]
ctfout: use ctfc_get_num_ctf_vars instead

A minor cosmetic fix.

2022-03-28  Indu Bhagat  <indu.bhagat@oracle.com>

gcc/ChangeLog:

* ctfout.cc (ctf_preprocess): Use ctfc_get_num_ctf_vars instead.
(output_ctf_vars): Likewise.

2 years agoRemove --with-gmp-dir and --with-mpfr-dir
Tom Tromey [Mon, 28 Mar 2022 20:15:36 +0000 (14:15 -0600)]
Remove --with-gmp-dir and --with-mpfr-dir

The top-level configure options --with-gmp-dir and --with-mpfr-dir
were obsoleted and marked as "REMOVED" back in 2006.  I think that's
long enough ago for everyone to have updated their scripts, so this
patch removes them entirely.  While doing this, I also found one other
leftover that wasn't removed by the earlier patch.  This is also
removed here.

2022-03-28  Tom Tromey  <tromey@adacore.com>

* configure.ac: Remove --with-mpfr-dir and --with-gmp-dir.
* configure: Rebuild.

2 years agoUpdate gcc sv.po
Joseph Myers [Mon, 28 Mar 2022 20:04:59 +0000 (20:04 +0000)]
Update gcc sv.po

* sv.po: Update.

2 years agoc++: Fix __has_trivial_* docs [PR59426]
Jason Merrill [Mon, 28 Mar 2022 19:32:30 +0000 (15:32 -0400)]
c++: Fix __has_trivial_* docs [PR59426]

These have been misdocumented since C++98 POD was split into C++11 trivial
and standard-layout in r149721.

PR c++/59426

gcc/ChangeLog:

* doc/extend.texi: Refer to __is_trivial instead of __is_pod.

2 years agoc++: add comment
Jason Merrill [Tue, 15 Mar 2022 20:23:47 +0000 (16:23 -0400)]
c++: add comment

gcc/cp/ChangeLog:

* pt.cc (determine_specialization): Add comment.

2 years agoc++: reject concept w/ multiple tparm lists [PR105067]
Patrick Palka [Mon, 28 Mar 2022 18:15:39 +0000 (14:15 -0400)]
c++: reject concept w/ multiple tparm lists [PR105067]

We weren't rejecting a concept declared with multiple template
parameter lists.

PR c++/105067

gcc/cp/ChangeLog:

* pt.cc (finish_concept_definition): Check that a concept is
declared with exactly one template parameter list.

gcc/testsuite/ChangeLog:

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

2 years agoc++: constrained template friend matching ICE [PR105064]
Patrick Palka [Mon, 28 Mar 2022 18:15:16 +0000 (14:15 -0400)]
c++: constrained template friend matching ICE [PR105064]

Here during declaration matching for the two constrained template
friends, we crash from maybe_substitute_reqs_for because the second
friend doesn't yet have DECL_TEMPLATE_INFO set (we're being called
indirectly from push_template_decl).

As far as I can tell, this situation happens only when declaring a
constrained template friend within a non-template class (as in the
testcase), in which case the substitution would be a no-op anyway.
So this patch rearranges maybe_substitute_reqs_for to gracefully
handle missing DECL_TEMPLATE_INFO by just skipping the substitution.

PR c++/105064

gcc/cp/ChangeLog:

* constraint.cc (maybe_substitute_reqs_for): Don't assume
DECL_TEMPLATE_INFO is available.

gcc/testsuite/ChangeLog:

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

2 years agox86: Also use Yw in *ssse3_pshufbv8qi3 clobber
H.J. Lu [Mon, 28 Mar 2022 16:32:53 +0000 (09:32 -0700)]
x86: Also use Yw in *ssse3_pshufbv8qi3 clobber

PR target/105068
* config/i386/sse.md (*ssse3_pshufbv8qi3): Also replace "Yv" with
"Yw" in clobber.

2 years ago[nvptx] Improve help description of misa and mptx
Tom de Vries [Mon, 28 Mar 2022 15:55:49 +0000 (17:55 +0200)]
[nvptx] Improve help description of misa and mptx

Currently we have:
...
$ gcc --target-help 2>&1 | egrep "misa|mptx"
  -misa=                      Specify the version of the ptx ISA to use.
  -mptx=                      Specify the version of the ptx version to use.
  Known PTX ISA versions (for use with the -misa= option):
  Known PTX versions (for use with the -mptx= option):
...

As reported in PR104818, the "version of the ptx version" doesn't make much
sense.

Furthermore, the description of misa (and 'Known ISA versions') is misleading
because it does not specify the version of the PTX ISA, but rather the PTX ISA
target architecture.

Fix this by printing instead:
...
$ gcc --target-help 2>&1 | egrep "misa|mptx"
  -misa=                      Specify the PTX ISA target architecture to use.
  -mptx=                      Specify the PTX ISA version to use.
  Known PTX ISA target architectures (for use with the -misa= option):
  Known PTX ISA versions (for use with the -mptx= option):
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-28  Tom de Vries  <tdevries@suse.de>

PR target/104818
* config/nvptx/gen-opt.sh (ptx_isa): Improve help text.
* config/nvptx/nvptx-gen.opt: Regenerate.
* config/nvptx/nvptx.opt (misa, mptx, ptx_version): Improve help text.
* config/nvptx/t-nvptx (s-nvptx-gen-opt): Add missing dependency on
gen-opt.sh.

2 years agoc++: hash table ICE with variadic alias [PR105003]
Jason Merrill [Fri, 25 Mar 2022 17:13:35 +0000 (13:13 -0400)]
c++: hash table ICE with variadic alias [PR105003]

For PR104008 we thought it might be enough to keep strip_typedefs from
removing this alias template specialization, but this PR demonstrates that
other parts of the compiler also need to know to consider it dependent.

So, this patch changes complex_alias_template_p to no longer consider
template parameters used when their only use appears in a pack expansion,
unless they are the parameter packs being expanded.

To do that I also needed to change it to use cp_walk_tree instead of
for_each_template_parm.  It occurs to me that find_template_parameters
should probably also use cp_walk_tree, but I'm not messing with that now.

PR c++/105003
PR c++/104008
PR c++/102869

gcc/cp/ChangeLog:

* pt.cc (complex_alias_template_r): walk_tree callback, replacing
uses_all_template_parms_r, complex_pack_expansion_r.
(complex_alias_template_p): Adjust.
* tree.cc (strip_typedefs): Revert r12-7710 change.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-alias6.C: New test.
* g++.dg/cpp0x/variadic-alias7.C: New test.

2 years agogimple-fold: fix location of loads for memory ops [PR104308]
David Malcolm [Mon, 28 Mar 2022 13:43:07 +0000 (09:43 -0400)]
gimple-fold: fix location of loads for memory ops [PR104308]

PR analyzer/104308 reports that when -Wanalyzer-use-of-uninitialized-value
complains about certain memmove operations where the source is
uninitialized, the diagnostic uses UNKNOWN_LOCATION:

In function 'main':
cc1: warning: use of uninitialized value '*(short unsigned int *)&s + 1' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
  'main': event 1
    |
    |pr104308.c:5:8:
    |    5 |   char s[5]; /* { dg-message "region created on stack here" } */
    |      |        ^
    |      |        |
    |      |        (1) region created on stack here
    |
  'main': event 2
    |
    |cc1:
    | (2): use of uninitialized value '*(short unsigned int *)&s + 1' here
    |

The issue is that gimple_fold_builtin_memory_op converts a memmove to:

  _3 = MEM <unsigned short> [(char * {ref-all})_1];
  MEM <unsigned short> [(char * {ref-all})&s] = _3;

but only sets the location of the 2nd stmt, not the 1st.

Fixed thusly, giving:

pr104308.c: In function 'main':
pr104308.c:6:3: warning: use of uninitialized value '*(short unsigned int *)&s + 1' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
    6 |   memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
      |   ^~~~~~~~~~~~~~~~~~~~
  'main': events 1-2
    |
    |    5 |   char s[5]; /* { dg-message "region created on stack here" } */
    |      |        ^
    |      |        |
    |      |        (1) region created on stack here
    |    6 |   memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
    |      |   ~~~~~~~~~~~~~~~~~~~~
    |      |   |
    |      |   (2) use of uninitialized value '*(short unsigned int *)&s + 1' here
    |

One side-effect of this change is a change in part of the output of
gcc.dg/uninit-40.c from:

  uninit-40.c:47:3: warning: ‘*(long unsigned int *)(&u[1][0][0])’ is used uninitialized [-Wuninitialized]
     47 |   __builtin_memcpy (&v[1], &u[1], sizeof (V));
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  uninit-40.c:45:5: note: ‘*(long unsigned int *)(&u[1][0][0])’ was declared here
     45 |   V u[2], v[2];
        |     ^

to:

  uninit-40.c:47:3: warning: ‘u’ is used uninitialized [-Wuninitialized]
     47 |   __builtin_memcpy (&v[1], &u[1], sizeof (V));
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  uninit-40.c:45:5: note: ‘u’ declared here
     45 |   V u[2], v[2];
        |     ^

What's happening is that pass "early_uninit"(29)'s call to
maybe_warn_operand is guarded by this condition:
  1051            else if (gimple_assign_load_p (stmt)
  1052                     && gimple_has_location (stmt))

Before the patch, the stmt:
  _3 = MEM <unsigned long> [(char * {ref-all})&u + 8B];
has no location, and so early_uninit skips this operand at line
1052 above.  Later, pass "uninit"(217) tests the var_decl "u$8", and
emits a warning for it.

With the patch, the stmt has a location, and so early_uninit emits a
warning for "u" and sets a NW_UNINIT warning suppression at that
location.  Later, pass "uninit"(217)'s test of "u$8" is rejected
due to that per-location suppression of uninit warnings, from the
earlier warning.

gcc/ChangeLog:
PR analyzer/104308
* gimple-fold.cc (gimple_fold_builtin_memory_op): When optimizing
to loads then stores, set the location of the new load stmt.

gcc/testsuite/ChangeLog:
PR analyzer/104308
* gcc.dg/analyzer/pr104308.c: New test.
* gcc.dg/uninit-40.c (foo): Update expression in expected message.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoc++: low -faligned-new [PR102071]
Jason Merrill [Sun, 27 Mar 2022 16:36:13 +0000 (12:36 -0400)]
c++: low -faligned-new [PR102071]

This test ICEd after the constexpr new patch (r10-3661) because alloc_call
had a NOP_EXPR around it; fixed by moving the NOP_EXPR to alloc_expr.  And
the PR pointed out that the size_t cookie might need more alignment, so I
fix that as well.

PR c++/102071

gcc/cp/ChangeLog:

* init.cc (build_new_1): Include cookie in alignment.  Omit
constexpr wrapper from alloc_call.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/aligned-new9.C: New test.

2 years agoc++: visibility of local extern [PR103291]
Jason Merrill [Sun, 27 Mar 2022 13:44:59 +0000 (09:44 -0400)]
c++: visibility of local extern [PR103291]

When setting up the hidden namespace-scope decl for a local extern, we also
need to set its visibility.

PR c++/103291

gcc/cp/ChangeLog:

* name-lookup.cc (push_local_extern_decl_alias): Call
determine_visibility.

gcc/testsuite/ChangeLog:

* g++.dg/ext/visibility/visibility-local-extern1.C: New test.

2 years agoc++: CTAD and member alias template [PR102123]
Jason Merrill [Sun, 27 Mar 2022 03:54:22 +0000 (23:54 -0400)]
c++: CTAD and member alias template [PR102123]

When building a deduction guide from the Test constructor, we need to
rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template
_dummy.  We were using SCOPE_REF for both type and non-type templates; we
need to use UNBOUND_CLASS_TEMPLATE for type templates.

PR c++/102123

gcc/cp/ChangeLog:

* pt.cc (tsubst_copy): Use make_unbound_class_template for rewriting
a type template reference.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction110.C: New test.

2 years agoc++: member alias declaration [PR103968]
Jason Merrill [Sun, 27 Mar 2022 04:28:30 +0000 (00:28 -0400)]
c++: member alias declaration [PR103968]

Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is
not value-dependent because neither the type nor the (value of) c_options
are dependent, but since we're binding it to a reference we also need to
consider that it has a value-dependent address.

PR c++/103968

gcc/cp/ChangeLog:

* pt.cc (value_dependent_expression_p): Check
has_value_dependent_address for conversion to reference.

gcc/testsuite/ChangeLog:

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

2 years agoc++: CTAD and member function references [PR103943]
Jason Merrill [Sun, 27 Mar 2022 02:05:53 +0000 (22:05 -0400)]
c++: CTAD and member function references [PR103943]

More quirks of rewriting member references to dependent references for
CTAD.  A reference to a member of dependent scope is definitely dependent.
And since r11-7044, tsubst_baselink builds a SCOPE_REF, so
tsubst_qualified_id should just use it.

PR c++/103943

gcc/cp/ChangeLog:

* pt.cc (tsubst_qualified_id): Handle getting SCOPE_REF from
tsubst_baselink.
(instantiation_dependent_scope_ref_p): Check dependent_scope_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction109.C: New test.

2 years agoc++: missing aggregate base ctor [PR102045]
Jason Merrill [Sun, 27 Mar 2022 00:38:54 +0000 (20:38 -0400)]
c++: missing aggregate base ctor [PR102045]

When make_base_init_ok changes a call to a complete constructor into a call
to a base constructor, we were never marking the base ctor as used, so it
didn't get emitted.

PR c++/102045

gcc/cp/ChangeLog:

* call.cc (make_base_init_ok): Call make_used.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/aggr-base12.C: New test.

2 years agoc++: mangling union{1} in template [PR104847]
Jason Merrill [Sun, 27 Mar 2022 00:10:19 +0000 (20:10 -0400)]
c++: mangling union{1} in template [PR104847]

My implementation of union non-type template arguments in r11-2016 broke
braced casts of union type, because they are still in syntactic (undigested)
form.

PR c++/104847

gcc/cp/ChangeLog:

* mangle.cc (write_expression): Don't write a union designator when
undigested.

gcc/testsuite/ChangeLog:

* g++.dg/abi/mangle-union1.C: New test.

2 years agoc++: ICE with alias in pack expansion [PR103769]
Jason Merrill [Fri, 25 Mar 2022 15:26:06 +0000 (11:26 -0400)]
c++: ICE with alias in pack expansion [PR103769]

This was breaking because when we stripped the 't' typedef in s<t<Args>...>
to be s<Args...>, the TYPE_MAIN_VARIANT of "Args..." was still
"t<Args>...", because type pack expansions are treated as types.  Fixed by
using the right function to copy a "type".

PR c++/99445
PR c++/103769

gcc/cp/ChangeLog:

* tree.cc (strip_typedefs): Use build_distinct_type_copy.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-alias5.C: New test.

2 years ago[libgomp, testsuite] Fix hardcoded libexec in plugin/configfrag.ac
Tom de Vries [Mon, 28 Mar 2022 08:45:45 +0000 (10:45 +0200)]
[libgomp, testsuite] Fix hardcoded libexec in plugin/configfrag.ac

When building an nvptx offloading configuration on openSUSE Leap 15.3, the
site script /usr/share/site/x86_64-unknown-linux-gnu is activated, setting
libexecdir to ${exec_prefix}/lib rather than ${exec_prefix}/libexec:
...
| # If user did not specify libexecdir, set the correct target:
| # Nor FHS nor openSUSE allow prefix/libexec. Let's default to prefix/lib.
|
| if test "$libexecdir" = '${exec_prefix}/libexec' ; then
|       libexecdir='${exec_prefix}/lib'
| fi
...

However, in libgomp libgomp/plugin/configfrag.ac we hardcode libexec:
...
    # Configure additional search paths.
    if test x"$tgt_dir" != x; then
      offload_additional_options="$offload_additional_options \
        -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) \
-B$tgt_dir/bin"
...

Fix this by using /$(libexecdir:\$(exec_prefix)/%=%)/ instead of /libexec/.

Tested on x86_64-linux with nvptx accelerator.

libgomp/ChangeLog:

2022-03-28  Tom de Vries  <tdevries@suse.de>

* plugin/configfrag.ac: Use /$(libexecdir:\$(exec_prefix)/%=%)/
instead of /libexec/.
* configure: Regenerate.

2 years agolibstdc++: Fix typos in comments in tests
Jonathan Wakely [Mon, 28 Mar 2022 10:38:11 +0000 (11:38 +0100)]
libstdc++: Fix typos in comments in tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/optional/monadic/and_then.cc: Fix typo.
* testsuite/20_util/optional/monadic/transform.cc: Likewise.
* testsuite/22_locale/codecvt/always_noconv/char/1.cc: Likewise.
* testsuite/22_locale/codecvt/encoding/char/1.cc: Likewise.
* testsuite/22_locale/codecvt/in/char/1.cc: Likewise.
* testsuite/22_locale/codecvt/max_length/char/1.cc: Likewise.
* testsuite/22_locale/codecvt/out/char/1.cc: Likewise.
* testsuite/22_locale/codecvt/unshift/char/1.cc: Likewise.

2 years agogcc-changelog: Update revert_regex.
Martin Liska [Mon, 28 Mar 2022 10:42:46 +0000 (12:42 +0200)]
gcc-changelog: Update revert_regex.

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Match trailing dot literally.

2 years agogcc-changelog: Make This reverts stricter.
Martin Liska [Mon, 28 Mar 2022 10:29:29 +0000 (12:29 +0200)]
gcc-changelog: Make This reverts stricter.

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Make the parsing stricter.

2 years agotree-optimization/105070 - annotate bit cluster tests with locations
Richard Biener [Mon, 28 Mar 2022 08:07:53 +0000 (10:07 +0200)]
tree-optimization/105070 - annotate bit cluster tests with locations

The following makes sure to annotate the tests generated by
switch lowering bit-clustering with locations which otherwise
can be completely lost even at -O0.

2022-03-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105070
* tree-switch-conversion.h
(bit_test_cluster::hoist_edge_and_branch_if_true): Add location
argument.
* tree-switch-conversion.cc
(bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
cond with location.
(bit_test_cluster::emit): Annotate all generated expressions
with location.

2 years agoaarch64: Update Neoverse N2 core definition
Andre Vieira [Mon, 28 Mar 2022 08:24:04 +0000 (09:24 +0100)]
aarch64: Update Neoverse N2 core definition

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def: Update Neoverse N2 core entry.

2 years agoFix typo in vec_setv8hi_0.
liuhongt [Mon, 28 Mar 2022 03:12:37 +0000 (11:12 +0800)]
Fix typo in vec_setv8hi_0.

pinsrw is available for both reg and mem operand under sse2.
pextrw requires sse4.1 for mem operands.

The patch change attr "isa" for pinsrw mem alternative from sse4_noavx
to noavx, will enable below optimization.

-        movzwl  (%rdi), %eax
         pxor    %xmm1, %xmm1
-        pinsrw  $0, %eax, %xmm1
+        pinsrw  $0, (%rdi), %xmm1
         movdqa  %xmm1, %xmm0

gcc/ChangeLog:

PR target/105066
* config/i386/sse.md (vec_set<mode>_0): Change attr "isa" of
alternative 4 from sse4_noavx to noavx.

gcc/testsuite/ChangeLog:

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

2 years agopredcom: Fix up component::component [PR105056]
Jakub Jelinek [Mon, 28 Mar 2022 07:51:28 +0000 (09:51 +0200)]
predcom: Fix up component::component [PR105056]

The recent change didn't initialize comp_step while previously we used
XCNEW to allocate it.

I think RS_ANY is better than RS_INTERNAL (== 0) as the default.

2022-03-28  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105056
* tree-predcom.cc (component::component): Initialize also comp_step.

2 years agoadd missing dg-require alias to gcc.dg/torture/pr100786.c
Richard Biener [Mon, 28 Mar 2022 07:48:08 +0000 (09:48 +0200)]
add missing dg-require alias to gcc.dg/torture/pr100786.c

2022-03-28  Richard Biener  <rguenther@suse.de>

* gcc.dg/torture/pr100786.c: Add dg-require alias.

2 years agoDaily bump.
GCC Administrator [Mon, 28 Mar 2022 00:16:40 +0000 (00:16 +0000)]
Daily bump.

2 years agox86: Use Yw constraint on *ssse3_pshufbv8qi3
H.J. Lu [Sun, 27 Mar 2022 18:07:39 +0000 (11:07 -0700)]
x86: Use Yw constraint on *ssse3_pshufbv8qi3

Since AVX512VL and AVX512BW are required for AVX512 VPSHUFB, replace the
"Yv" register constraint with the "Yw" register constraint.

gcc/

PR target/105068
* config/i386/sse.md (*ssse3_pshufbv8qi3): Replace "Yv" with
"Yw".

gcc/testsuite/

PR target/105068
* gcc.target/i386/pr105068.c: New test.

2 years agolibstdc++: Define std::expected for C++23 (P0323R12)
Jonathan Wakely [Thu, 24 Mar 2022 20:37:13 +0000 (20:37 +0000)]
libstdc++: Define std::expected for C++23 (P0323R12)

Because this adds a new class template called std::unexpected, we have
to stop declaring the std::unexpected() function (which was deprecated
in C++11 and removed in C++17).

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in: Add new header.
* include/Makefile.am: Likewise.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Add new header.
* include/std/version (__cpp_lib_expected): Define.
* libsupc++/exception [__cplusplus > 202002] (unexpected)
(unexpected_handler, set_unexpected): Do not declare for C++23.
* include/std/expected: New file.
* testsuite/20_util/expected/assign.cc: New test.
* testsuite/20_util/expected/cons.cc: New test.
* testsuite/20_util/expected/illformed_neg.cc: New test.
* testsuite/20_util/expected/observers.cc: New test.
* testsuite/20_util/expected/requirements.cc: New test.
* testsuite/20_util/expected/swap.cc: New test.
* testsuite/20_util/expected/synopsis.cc: New test.
* testsuite/20_util/expected/unexpected.cc: New test.
* testsuite/20_util/expected/version.cc: New test.

2 years agoDaily bump.
GCC Administrator [Sun, 27 Mar 2022 00:16:33 +0000 (00:16 +0000)]
Daily bump.

2 years agoRemove mysterious '-# Defining these options here in addition to common.opt is necess...
Thomas Schwinge [Thu, 24 Mar 2022 21:34:30 +0000 (22:34 +0100)]
Remove mysterious '-# Defining these options here in addition to common.opt is necessary' command-line option

Before:

    $ [...]/gcc '-# Defining these options here in addition to common.opt is necessary' -S -x c /dev/null && echo MYSTERIOUS
    MYSTERIOUS

After:

    $ [...]/gcc '-# Defining these options here in addition to common.opt is necessary' -S -x c /dev/null && echo MYSTERIOUS
    gcc: error: unrecognized command-line option ‘-# Defining these options here in addition to common.opt is necessary’

This commit changes:

    --- [...]/build-gcc/gcc/optionlist 2022-03-24 22:12:07.936746648 +0100
    +++ [...]/build-gcc/gcc/optionlist 2022-03-24 22:30:06.976737341 +0100
    @@ -1,4 +1,3 @@
    -# Defining these options here in addition to common.opt is necessary\1c# in order for the default -Wall setting of -Wuse-after-free=2 to take\1c# effect.
     ###\1cDriver
     -all-warnings\1cAda AdaWhy AdaSCIL Alias(Wall)
     -all-warnings\1cC ObjC C++ ObjC++ Warning Alias(Wall)
    [...]

    --- [...]/build-gcc/gcc/options.cc 2022-03-24 22:12:09.548727738 +0100
    +++ [...]/build-gcc/gcc/options.cc 2022-03-24 22:30:08.904727249 +0100
    @@ -3222,15 +3222,6 @@
     const struct cl_option cl_options[] =
     {
      /* [0] = */ {
    -    "-# Defining these options here in addition to common.opt is necessary",
    -    "# effect.",
    -    NULL,
    -    NULL,
    -    NULL, NULL, N_OPTS, N_OPTS, 68, /* .neg_idx = */ -1,
    -    0,
    -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    -    (unsigned short) -1, 0, CLVC_INTEGER, 0, -1, -1 },
    - /* [1] = */ {
         "-###",
         NULL,
         NULL,
    [...]

..., and re-numbers all following options.

    --- [...]/build-gcc/gcc/options.h 2022-03-21 23:24:25.894226828 +0100
    +++ [...]/build-gcc/gcc/options.h 2022-03-24 22:30:07.288735708 +0100
    @@ -9753,2118 +9753,2117 @@

     enum opt_code
     {
    -  OPT___Defining_these_options_here_in_addition_to_common_opt_is_necessary = 0,/* -# Defining these options here in addition to common.opt is necessary */
    [...]

..., and likewise re-numbers all following options.

Clean-up for commit 671a283636de75f7ed638ee6b01ed2d44361b8b6
"Add -Wuse-after-free [PR80532]".

gcc/c-family/
* c.opt: Properly quote comment.

2 years agoPR middle-end/104885: Fix ICE with large stack frame on powerpc64.
Roger Sayle [Sat, 26 Mar 2022 18:10:27 +0000 (08:10 -1000)]
PR middle-end/104885: Fix ICE with large stack frame on powerpc64.

My recent testcase for PR c++/84964.C stress tests the middle-end by
attempting to pass a UINT_MAX sized structure on the stack.  Although
my fix to PR84964 avoids the ICE after sorry on x86_64 and similar
targets, a related issue still exists on powerpc64 (and similar
ACCUMULATE_OUTGOING_ARGS/ARGS_GROW_DOWNWARD targets) which don't
issue a "sorry, unimplemented" message, but instead ICE elsewhere.

After attempting several alternate fixes, the simplest solution is
to just defensively check in mark_stack_region_used that the upper
bound of the region lies within the allocated stack_usage_map
array, which is of size highest_outgoing_arg_in_use.  When this isn't
the case, the code now follows the same path as for variable sized
regions, and uses stack_usage_watermark rather than a map.

2022-03-26  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR middle-end/104885
* calls.cc (mark_stack_region_used): Check that the region
is within the allocated size of stack_usage_map.

2 years agoecog: Return 1 from insn_invalid_p if REG_INC reg overlaps some stored reg [PR103775]
Jakub Jelinek [Sat, 26 Mar 2022 15:21:36 +0000 (16:21 +0100)]
ecog: Return 1 from insn_invalid_p if REG_INC reg overlaps some stored reg [PR103775]

The following testcase ICEs on aarch64-linux with -g and
assembles with a warning otherwise, because it emits
ldrb w0,[x0,16]!
instruction which sets the x0 register multiple times.
Due to disabled DCE (from -Og) we end up before REE with:
(insn 12 39 13 2 (set (reg:SI 1 x1 [orig:93 _2 ] [93])
        (zero_extend:SI (mem/c:QI (pre_modify:DI (reg/f:DI 0 x0 [114])
                    (plus:DI (reg/f:DI 0 x0 [114])
                        (const_int 16 [0x10]))) [1 u128_1+0 S1 A128]))) "pr103775.c":5:35 117 {*zero_extendqisi2_aarch64}
     (expr_list:REG_INC (reg/f:DI 0 x0 [114])
        (nil)))
(insn 13 12 14 2 (set (reg:DI 0 x0 [orig:112 _2 ] [112])
        (zero_extend:DI (reg:SI 1 x1 [orig:93 _2 ] [93]))) "pr103775.c":5:16 111 {*zero_extendsidi2_aarch64}
     (nil))
which is valid but not exactly efficient as x0 is dead after the
insn that auto-increments it.  REE turns it into:
(insn 12 39 44 2 (set (reg:DI 0 x0)
        (zero_extend:DI (mem/c:QI (pre_modify:DI (reg/f:DI 0 x0 [114])
                    (plus:DI (reg/f:DI 0 x0 [114])
                        (const_int 16 [0x10]))) [1 u128_1+0 S1 A128]))) "pr103775.c":5:35 119 {*zero_extendqidi2_aarch64}
     (expr_list:REG_INC (reg/f:DI 0 x0 [114])
        (nil)))
(insn 44 12 14 2 (set (reg:DI 1 x1)
        (reg:DI 0 x0)) "pr103775.c":5:35 -1
     (nil))
which is invalid because it sets x0 multiple times, one
in SET_DEST of the PATTERN and once in PRE_MODIFY.
As perhaps other passes than REE might suffer from it, IMHO it is better
to reject this during change validation.

2022-03-26  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/103775
* recog.cc (check_invalid_inc_dec): New function.
(insn_invalid_p): Return 1 if REG_INC operand overlaps
any stored REGs.

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

2 years agoc++: diagnosing if-stmt with non-constant branches [PR105050]
Patrick Palka [Sat, 26 Mar 2022 14:20:18 +0000 (10:20 -0400)]
c++: diagnosing if-stmt with non-constant branches [PR105050]

When an if-stmt is determined to be non-constant because both of its
branches are non-constant, we issue a somewhat generic error which,
since the error also points to the 'if' token, misleadingly suggests
the condition is at fault:

  constexpr-105050.C:8:3: error: expression ‘<statement>’ is not a constant expression
      8 |   if (p != q && *p < 0)
        |   ^~

This patch clarifies the error message to instead read:

  constexpr-105050.C:8:3: error: neither branch of ‘if’ is a constant expression
      8 |   if (p != q && *p < 0)
        |   ^~

PR c++/105050

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1) <case IF_STMT>:
Clarify error message when a if-stmt is non-constant because its
branches are non-constant.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/constexpr-105050.C: New test.

2 years agoc++: ICE when building builtin operator->* set [PR103455]
Patrick Palka [Sat, 26 Mar 2022 14:20:16 +0000 (10:20 -0400)]
c++: ICE when building builtin operator->* set [PR103455]

Here when constructing the builtin operator->* candidate set according
to the available conversion functions for the operand types, we end up
considering a candidate with C1=T (through B's dependent conversion
function) and C2=F, during which we crash from DERIVED_FROM_P because
dependent_type_p sees a TEMPLATE_TYPE_PARM outside of a template
context.

Sidestepping the question of whether we should be considering such a
dependent conversion function here in the first place, it seems futile
to test DERIVED_FROM_P for anything other than an actual class type, so
this patch fixes this ICE by simply guarding the DERIVED_FROM_P test
with CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.

PR c++/103455

gcc/cp/ChangeLog:

* call.cc (add_builtin_candidate) <case MEMBER_REF>: Test
CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/overload/builtin6.C: New test.

2 years agox86: Use x constraint on KL patterns
H.J. Lu [Fri, 25 Mar 2022 17:48:16 +0000 (10:48 -0700)]
x86: Use x constraint on KL patterns

Since KL instructions have no AVX512 version, replace the "v" register
constraint with the "x" register constraint.

PR target/105058
* config/i386/sse.md (loadiwkey): Replace "v" with "x".
(aes<aesklvariant>u8): Likewise.

2 years agox86: Use x constraint on SSSE3 patterns with MMX operands
H.J. Lu [Fri, 25 Mar 2022 04:41:12 +0000 (21:41 -0700)]
x86: Use x constraint on SSSE3 patterns with MMX operands

Since PHADDW/PHADDD/PHADDSW/PHSUBW/PHSUBD/PHSUBSW/PSIGNB/PSIGNW/PSIGND
have no AVX512 version, replace the "Yv" register constraint with the
"x" register constraint.

PR target/105052
* config/i386/sse.md (ssse3_ph<plusminus_mnemonic>wv4hi3):
Replace "Yv" with "x".
(ssse3_ph<plusminus_mnemonic>dv2si3): Likewise.
(ssse3_psign<mode>3): Likewise.

2 years agoanalyzer: fix ICE on memset of untracked region [PR105057]
David Malcolm [Fri, 25 Mar 2022 20:50:51 +0000 (16:50 -0400)]
analyzer: fix ICE on memset of untracked region [PR105057]

In r12-7809-g5f6197d7c197f9d2b7fb2e1a19dac39a023755e8 I added an
optimization to avoid tracking the state of certain memory regions
in the store.

Unfortunately, I didn't cover every way in which
store::get_or_create_cluster can be called for a base region, leading
to assertion failure ICEs in -fanalyzer on certain function calls
with certain params.

I've worked through all uses of store::get_or_create_cluster and found
four places where the assertion could fire.

This patch fixes them, and adds regression tests where possible.

gcc/analyzer/ChangeLog:
PR analyzer/105057
* store.cc (binding_cluster::make_unknown_relative_to): Reject
attempts to create a cluster for untracked base regions.
(store::set_value): Likewise.
(store::fill_region): Likewise.
(store::mark_region_as_unknown): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/105057
* gcc.dg/analyzer/fread-2.c: New test, as a regression test for
ICE in store::set_value on untracked base region.
* gcc.dg/analyzer/memset-2.c: Likewise, for ICE in
store::fill_region.
* gcc.dg/analyzer/strcpy-2.c: Likewise, for ICE in
store::mark_region_as_unknown.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoManually add entry for r12-7818-g3ab5c8cd03d92bf4ec41e351820349d92fbc40c4
Jakub Jelinek [Sat, 26 Mar 2022 10:28:35 +0000 (11:28 +0100)]
Manually add entry for r12-7818-g3ab5c8cd03d92bf4ec41e351820349d92fbc40c4

Because update_version_git gave up on it.

2 years agoDaily bump.
GCC Administrator [Sat, 26 Mar 2022 10:22:39 +0000 (10:22 +0000)]
Daily bump.

2 years agoAdd another commit to ignore
Jakub Jelinek [Sat, 26 Mar 2022 10:20:58 +0000 (11:20 +0100)]
Add another commit to ignore

We can't handle r12-7818-g3ab5c8cd03d92bf4ec41e351820349d92fbc40c4

* gcc-changelog/git_update_version.py: Add
3ab5c8cd03d92bf4ec41e351820349d92fbc40c4 to ignored commits.

2 years agoc++: Fix up __builtin_{bit_cast,convertvector} parsing
Jakub Jelinek [Sat, 26 Mar 2022 07:11:58 +0000 (08:11 +0100)]
c++: Fix up __builtin_{bit_cast,convertvector} parsing

Jonathan reported on IRC that we don't parse
__builtin_bit_cast (type, val).field
etc.
The problem is that for these 2 builtins we return from
cp_parser_postfix_expression instead of setting postfix_expression
to the cp_build_* value and falling through into the postfix regression
suffix handling loop.

2022-03-26  Jakub Jelinek  <jakub@redhat.com>

* parser.cc (cp_parser_postfix_expression)
<case RID_BILTIN_CONVERTVECTOR, case RID_BUILTIN_BIT_CAST>: Don't
return cp_build_{vec,convert,bit_cast} result right away, instead
set postfix_expression to it and break.

* c-c++-common/builtin-convertvector-3.c: New test.
* g++.dg/cpp2a/bit-cast15.C: New test.

2 years agoreload: Adjust comment in find_reloads about subset, not intersection
Hans-Peter Nilsson [Sat, 26 Mar 2022 04:31:22 +0000 (05:31 +0100)]
reload: Adjust comment in find_reloads about subset, not intersection

gcc:
* reload.cc (find_reloads): Align comment with code where
considering the intersection of register classes then tweaking the
regclass for the current alternative or rejecting it.

2 years agors6000: Update testsuite to use -mdejagnu-cpu= and -mdejagnu-tune= options
Peter Bergner [Fri, 25 Mar 2022 22:59:07 +0000 (17:59 -0500)]
rs6000: Update testsuite to use -mdejagnu-cpu= and -mdejagnu-tune= options

This patch updates the POWER testsuite test cases using -mcpu= and -mtune=
to use the preferred -mdejagnu-cpu= and -mdejagnu-tune= options.  This also
obviates the need for the dg-skip-if directive, since the user cannot
override the -mcpu= value being used to compile the test case.

2022-03-25  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/

* g++.dg/pr65240-1.C: Use -mdejagnu-cpu=.  Remove dg-skip-if.
* g++.dg/pr65240-2.C: Likewise.
* g++.dg/pr65240-3.C: Likewise.
* g++.dg/pr65240-4.C: Likewise.
* g++.dg/pr65242.C: Likewise.
* g++.dg/pr67211.C: Likewise.
* g++.dg/pr69667.C: Likewise.
* g++.dg/pr71294.C: Likewise.
* g++.dg/pr84279.C: Likewise.
* g++.dg/torture/ppc-ldst-array.C: Likewise.
* gfortran.dg/nint_p7.f90: Likewise.
* gfortran.dg/pr102860.f90: Likewise.
* gcc.target/powerpc/fusion.c: Use -mdejagnu-cpu= and -mdejagnu-tune=.
* gcc.target/powerpc/fusion2.c: Likewise.
* gcc.target/powerpc/int_128bit-runnable.c: Use -mdejagnu-cpu=.
* gcc.target/powerpc/test_mffsl.c: Likewise.
* gfortran.dg/pr47614.f: Likewise.
* gfortran.dg/pr58968.f: Likewise.

2 years agox86: Use -msse2 on gcc.target/i386/pr95483-1.c
H.J. Lu [Fri, 25 Mar 2022 20:53:34 +0000 (13:53 -0700)]
x86: Use -msse2 on gcc.target/i386/pr95483-1.c

Replace -msse with -msse2 since <emmintrin.h> requires SSE2.

PR testsuite/105055
* gcc.target/i386/pr95483-1.c: Replace -msse with -msse2.

2 years agolibstdc++: Add more doxygen comments in <bit>
Jonathan Wakely [Wed, 23 Mar 2022 12:16:25 +0000 (12:16 +0000)]
libstdc++: Add more doxygen comments in <bit>

libstdc++-v3/ChangeLog:

* include/std/bit (bit_cast, byteswap, endian): Add doxygen
comments.

2 years agoarm: Revert Auto-vectorization for MVE: add pack/unpack patterns PR target/104882
Christophe Lyon [Fri, 18 Mar 2022 08:30:00 +0000 (08:30 +0000)]
arm: Revert Auto-vectorization for MVE: add pack/unpack patterns PR target/104882

This reverts commit r12-1434-g046a3beb1673bf to fix PR target/104882.

As discussed in the PR, it turns out that the MVE ISA has no natural
mapping with GCC's vec_pack_trunc / vec_unpack standard patterns, unlike
Neon or SVE for instance.

This patch also adds the executable testcase provided in the PR.
This test passes at -O3 because the generated code does not need
to use the pack/unpack patterns, hence the use of -O2 which now
triggers vectorization since a few months ago.

2022-03-18  Christophe Lyon  <christohe.lyon@arm.com>

PR target/104882
Revert
2021-06-11  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* config/arm/mve.md (mve_vec_unpack<US>_lo_<mode>): Delete.
(mve_vec_unpack<US>_hi_<mode>): Delete.
(@mve_vec_pack_trunc_lo_<mode>): Delete.
(mve_vmovntq_<supf><mode>): Remove '@' prefix.
* config/arm/neon.md (vec_unpack<US>_hi_<mode>): Move back
from vec-common.md.
(vec_unpack<US>_lo_<mode>): Likewise.
(vec_pack_trunc_<mode>): Rename from
neon_quad_vec_pack_trunc_<mode>.
* config/arm/vec-common.md (vec_unpack<US>_hi_<mode>): Delete.
(vec_unpack<US>_lo_<mode>): Delete.
(vec_pack_trunc_<mode>): Delete.

PR target/104882
gcc/testsuite/
* gcc.target/arm/simd/mve-vclz.c: Update expected results.
* gcc.target/arm/simd/mve-vshl.c: Likewise.
* gcc.target/arm/simd/mve-vec-pack.c: Delete.
* gcc.target/arm/simd/mve-vec-unpack.c: Delete.
* gcc.target/arm/simd/pr104882.c: New test.

2 years ago[PR104971] LRA: check live hard regs to remove a dead insn
Vladimir N. Makarov [Fri, 25 Mar 2022 16:22:08 +0000 (12:22 -0400)]
[PR104971] LRA: check live hard regs to remove a dead insn

LRA removes insn modifying sp for given PR test set.  We should also have
checked living hard regs to prevent this.  The patch fixes this.

gcc/ChangeLog:

PR middle-end/104971
* lra-lives.cc (process_bb_lives): Check hard_regs_live for hard
regs to clear remove_p flag.

2 years agotree-optimization/105053 - fix reduction chain epilogue generation
Richard Biener [Fri, 25 Mar 2022 13:31:25 +0000 (14:31 +0100)]
tree-optimization/105053 - fix reduction chain epilogue generation

When we optimize permutations in a reduction chain we have to
be careful to select the correct live-out stmt, otherwise the
reduction result will be unused and the retained scalar code will
execute only the number of vector iterations.

2022-03-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105053
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Pick
the correct live-out stmt for a reduction chain.

* g++.dg/vect/pr105053.cc: New testcase.

2 years agoc++: alignas and alignof void [PR104944]
Marek Polacek [Wed, 23 Mar 2022 21:12:29 +0000 (17:12 -0400)]
c++: alignas and alignof void [PR104944]

I started looking into this PR because in GCC 4.9 we were able to
detect the invalid

  struct alignas(void) S{};

but I broke it in r210262.

It's ill-formed code in C++:
[dcl.align]/3: "An alignment-specifier of the form alignas(type-id) has
the same effect as alignas(alignof(type-id))", and [expr.align]/1:
"The operand shall be a type-id representing a complete object type,
or an array thereof, or a reference to one of those types." and void
is not a complete type.

It's also invalid in C:
6.7.5: _Alignas(type-name) is equivalent to _Alignas(_Alignof(type-name))
6.5.3.4: "The _Alignof operator shall not be applied to a function type
or an incomplete type."

We have a GNU extension whereby we treat sizeof(void) as 1, but I assume
it doesn't apply to alignof, at least in C++.  However, __alignof__(void)
is still accepted with a -Wpedantic warning.

We still say "invalid application of 'alignof'" rather than 'alignas' in the
void diagnostic, but I felt that fixing that may not be suitable as part of
this patch.  The "incomplete type" diagnostic still always prints
'__alignof__'.

PR c++/104944

gcc/cp/ChangeLog:

* typeck.cc (cxx_sizeof_or_alignof_type): Diagnose alignof(void).
(cxx_alignas_expr): Call cxx_sizeof_or_alignof_type with
complain == true.

gcc/testsuite/ChangeLog:

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

2 years ago[libgomp, testsuite] Scale down some OpenACC test-cases
Tom de Vries [Fri, 25 Mar 2022 09:06:41 +0000 (10:06 +0100)]
[libgomp, testsuite] Scale down some OpenACC test-cases

When a display manager is running on an nvidia card, all CUDA kernel launches
get a 5 seconds watchdog timer.

Consequently, when running the libgomp testsuite with nvptx accelerator and
GOMP_NVPTX_JIT=-O0 we run into a few FAILs like this:
...
libgomp: cuStreamSynchronize error: the launch timed out and was terminated
FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/parallel-dims.c \
  -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 \
  execution test
...

Fix this by scaling down the failing test-cases by default, and reverting to
the original behaviour for GCC_TEST_RUN_EXPENSIVE=1.

Tested on x86_64-linux with nvptx accelerator.

libgomp/ChangeLog:

2022-03-25  Tom de Vries  <tdevries@suse.de>

PR libgomp/105042
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Reduce
execution time.
* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Same.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Same.

2 years agomiddle-end/105049 - fix uniform_vector_p and vector CTOR gimplification
Richard Biener [Fri, 25 Mar 2022 07:43:45 +0000 (08:43 +0100)]
middle-end/105049 - fix uniform_vector_p and vector CTOR gimplification

We have

  return VIEW_CONVERT_EXPR<U>( VEC_PERM_EXPR < {<<< Unknown tree: compound_literal_expr
        V D.1984 = { 0 }; >>>, { 0 }} , {<<< Unknown tree: compound_literal_expr
        V D.1985 = { 0 }; >>>, { 0 }} , { 0, 0 } >  & {(short int) SAVE_EXPR <c>, (short int) SAVE_EXPR <c>});

where we gimplify the init CTORs to

  _1 = {{ 0 }, { 0 }};
  _2 = {{ 0 }, { 0 }};

instead of to vector constants.  That later runs into a bug in
uniform_vector_p which doesn't handle CTORs of vector elements
correctly.

The following adjusts uniform_vector_p to handle CTORs of vector
elements.

2022-03-25  Richard Biener  <rguenther@suse.de>

PR middle-end/105049
* tree.cc (uniform_vector_p): Recurse for VECTOR_CST or
CONSTRUCTOR first elements.

* gcc.dg/pr105049.c: New testcase.

2 years agoFix issue for pointers to anonymous types with -fdump-ada-spec
Eric Botcazou [Fri, 25 Mar 2022 11:35:33 +0000 (12:35 +0100)]
Fix issue for pointers to anonymous types with -fdump-ada-spec

This used to work long ago but broke at some point.

gcc/c-family/
* c-ada-spec.cc (dump_ada_import): Deal with the "section" attribute
(dump_ada_node) <POINTER_TYPE>: Do not modify and pass the name, but
the referenced type instead.  Deal with the anonymous original type
of a typedef'ed type.  In the actual access case, follow the chain
of external subtypes.
<TYPE_DECL>: Tidy up control flow.

2 years agofortran: Fix up initializers of param(0) PARAMETERs [PR103691]
Jakub Jelinek [Fri, 25 Mar 2022 10:22:15 +0000 (11:22 +0100)]
fortran: Fix up initializers of param(0) PARAMETERs [PR103691]

On the gfortran.dg/pr103691.f90 testcase the Fortran ICE emits
  static real(kind=4) a[0] = {[0 ... -1]=2.0e+0};
That is an invalid RANGE_EXPR where the maximum is smaller than the minimum.

The following patch fixes that.  If TYPE_MAX_VALUE is smaller than
TYPE_MIN_VALUE, the array is empty and so doesn't need any initializer,
if the two are equal, we don't need to bother with a RANGE_EXPR and
can just use that INTEGER_CST as the index and finally for the 2+ values
in the range it uses a RANGE_EXPR as before.

2022-03-25  Jakub Jelinek  <jakub@redhat.com>

PR fortran/103691
* trans-array.cc (gfc_conv_array_initializer): If TYPE_MAX_VALUE is
smaller than TYPE_MIN_VALUE (i.e. empty array), ignore the
initializer; if TYPE_MIN_VALUE is equal to TYPE_MAX_VALUE, use just
the TYPE_MIN_VALUE as index instead of RANGE_EXPR.

2 years agodoc/invoke.texi: Move @ignore block out of @gccoptlist [PR103533]
Tobias Burnus [Fri, 25 Mar 2022 09:47:49 +0000 (10:47 +0100)]
doc/invoke.texi: Move @ignore block out of @gccoptlist [PR103533]

With TeX output ("make pdf"), @gccoptlist's content end up in a single
line such that TeX does not find the matching '@end ignore' for the
'@ignore' block – failing with a runaway error. Solution is to move
the @ignore block after the closing '}'.
(Follow up to r12-7808-g319ba7e241e7e21f9eb481f075310796f13d2035 )

gcc/
PR analyzer/103533
* doc/invoke.texi (Static Analyzer Options): Move
@ignore block after @gccoptlist's '}' for 'make pdf'.

2 years agoanalyzer: add region::tracked_p to optimize state objects [PR104954]
David Malcolm [Fri, 25 Mar 2022 00:58:10 +0000 (20:58 -0400)]
analyzer: add region::tracked_p to optimize state objects [PR104954]

PR analyzer/104954 tracks that -fanalyzer was taking a very long time
on a particular source file in the Linux kernel:
  drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c

One issue occurs with the repeated use of dynamic debug lines e.g. via
the DC_LOG_BANDWIDTH_CALCS macro, such as in print_bw_calcs_dceip in
drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h:

  DC_LOG_BANDWIDTH_CALCS("#####################################################################");
  DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_dceip");
  DC_LOG_BANDWIDTH_CALCS("#####################################################################");

  [...snip dozens of lines...]

  DC_LOG_BANDWIDTH_CALCS("[bw_fixed] dmif_request_buffer_size: %d",
                         bw_fixed_to_int(dceip->dmif_request_buffer_size));

When this is configured to use __dynamic_pr_debug, each of these becomes
code like:

  do {
    static struct _ddebug __attribute__((__aligned__(8)))
    __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug277 = {
      [...snip...]
    };
    if (arch_static_branch(&__UNIQUE_ID_ddebug277.key, false))
      __dynamic_pr_debug(&__UNIQUE_ID_ddebug277, [...the message...]);
  } while (0);

The analyzer was naively seeing each call to __dynamic_pr_debug, noting
that the __UNIQUE_ID_nnnn object escapes.  At each call, as successive
__UNIQUE_ID_nnnn object escapes, there are N escaped objects, and thus N
need clobbering, and so we have O(N^2) clobbering of escaped objects overall,
leading to huge amounts of pointless work: print_bw_calcs_data has 225
uses of DC_LOG_BANDWIDTH_CALCS, many of which are in loops.

This patch adds a way to identify declarations that aren't interesting
to the analyzer, so that we don't attempt to create binding_clusters
for them (i.e. we don't store any state for them in our state objects).
This is implemented by adding a new region::tracked_p, implemented for
declarations by walking the existing IPA data the first time the
analyzer sees a declaration, setting it to false for global vars that
have no loads/stores/aliases, and "sufficiently safe" address-of
ipa-refs.

The patch gives a large speedup of -fanalyzer on the above kernel
source file:
                           Before  After
Total cc1 wallclock time:    180s    36s
analyzer wallclock time:     162s    17s
% spent in analyzer:          90%    47%

gcc/analyzer/ChangeLog:
PR analyzer/104954
* analyzer.opt (-fdump-analyzer-untracked): New option.
* engine.cc (impl_run_checkers): Handle it.
* region-model-asm.cc (region_model::on_asm_stmt): Don't attempt
to clobber regions with !tracked_p ().
* region-model-manager.cc (dump_untracked_region): New.
(region_model_manager::dump_untracked_regions): New.
(frame_region::dump_untracked_regions): New.
* region-model.h (region_model_manager::dump_untracked_regions):
New decl.
* region.cc (ipa_ref_requires_tracking): New.
(symnode_requires_tracking_p): New.
(decl_region::calc_tracked_p): New.
* region.h (region::tracked_p): New vfunc.
(frame_region::dump_untracked_regions): New decl.
(class decl_region): Note that this is also used fo SSA names.
(decl_region::decl_region): Initialize m_tracked.
(decl_region::tracked_p): New.
(decl_region::calc_tracked_p): New decl.
(decl_region::m_tracked): New.
* store.cc (store::get_or_create_cluster): Assert that we
don't try to create clusters for base regions that aren't
trackable.
(store::mark_as_escaped): Don't mark base regions that we're not
tracking.

gcc/ChangeLog:
PR analyzer/104954
* doc/invoke.texi (Static Analyzer Options): Add
-fdump-analyzer-untracked.

gcc/testsuite/ChangeLog:
PR analyzer/104954
* gcc.dg/analyzer/asm-x86-dyndbg-1.c: New test.
* gcc.dg/analyzer/asm-x86-dyndbg-2.c: New test.
* gcc.dg/analyzer/many-unused-locals.c: New test.
* gcc.dg/analyzer/untracked-1.c: New test.
* gcc.dg/analyzer/unused-local-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoDocs: Document that taint analyzer checker disables some warnings [PR103533]
Avinash Sonawane [Tue, 22 Mar 2022 02:02:44 +0000 (07:32 +0530)]
Docs: Document that taint analyzer checker disables some warnings [PR103533]

gcc/ChangeLog:
PR analyzer/103533
* doc/invoke.texi: Document that enabling taint analyzer
checker disables some warnings from `-fanalyzer`.

Signed-off-by: Avinash Sonawane <rootkea@gmail.com>
2 years agoDaily bump.
GCC Administrator [Fri, 25 Mar 2022 00:17:18 +0000 (00:17 +0000)]
Daily bump.