platform/upstream/gcc.git
2 years agoanalyzer: whitespace cleanups
David Malcolm [Fri, 24 Jun 2022 17:43:01 +0000 (13:43 -0400)]
analyzer: whitespace cleanups

Clean up whitespace in preparation for a follow-up patch.

No functional change intended.

gcc/analyzer/ChangeLog:
* call-string.cc (call_string::calc_recursion_depth): Whitespace
cleanups.
(call_string::cmp): Likewise.
(call_string::get_caller_node): Likewise.
(call_string::validate): Likewise.
* engine.cc (dynamic_call_info_t::add_events_to_path): Likewise.
(exploded_graph::get_per_function_data): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::process_node): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years ago[PATCH,RS6000 5/5] Replace MASK_<xxxx> usage with OPTION_MASK_<xxxx>
Will Schmidt [Thu, 23 Jun 2022 20:54:19 +0000 (15:54 -0500)]
[PATCH,RS6000 5/5] Replace MASK_<xxxx> usage with OPTION_MASK_<xxxx>

This continues the changes of replacing the MASK_<xxxx> defines
with their OPTION_MASK_<xxxx> equivalents.

This patch removes the defines for
MASK_P8_VECTOR, MASK_P9_VECTOR, MASK_P9_MISC, MASK_POPCNTB,
MASK_POPCNTD, MASK_PPC_GFXOPT, MASK_PPC_GPOPT, MASK_RECIP_PRECISION,
MASK_SOFT_FLOAT, MASK_VSX, MASK_POWER10, MASK_P10_FUSION.

gcc/
* config/rs6000/aix71.h (MASK_PPC_GPOPT, MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GPOPT, OPTION_MASK_PPC_GFXOPT.
* config/rs6000/darwin.h (MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GFXOPT.
* config/rs6000/darwin64-biarch.h (MASK_PPC_GFXOPT): Same.
* config/rs6000/default64.h (MASK_PPC_GPOPT, MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GPOPT, OPTION_MASK_PPC_GFXOPT.
* config/rs6000/rs6000-c.cc: Update comment.
* config/rs6000/rs6000-cpus.def: Update RS6000_CPU macro calls.
* config/rs6000/rs6000.cc (rs6000_darwin_file_start): Replace
MASK_PPC_GPOPT with OPTION_MASK_PPC_GPOPT.
(rs6000_builtin_mask_names): Replace MASK_PPC_GFXOPT, MASK_POPCNTB
with OPTION_MASK_PPC_GFXOPT, OPTION_MASK_POPCNTB.
* config/rs6000/rs6000.h: (MASK_P8_VECTOR, MASK_P9_VECTOR,
MASK_P9_MISC, MASK_POPCNTB, MASK_POPCNTD, MASK_PPC_GFXOPT,
MASK_PPC_GPOPT, MASK_RECIP_PRECISION, MASK_SOFT_FLOAT,
MASK_VSX, MASK_POWER10, MASK_P10_FUSION): Delete.

2 years ago[PATCH,RS6000 4/5] Replace MASK_<xxxx> with OPTION_MASK_<xxxx>
Will Schmidt [Thu, 23 Jun 2022 20:52:33 +0000 (15:52 -0500)]
[PATCH,RS6000 4/5] Replace MASK_<xxxx> with OPTION_MASK_<xxxx>

This replaces the MASK_<xxxx> references with OPTION_MASK_<xxxx>
and removes the now unused defines.

This patch removes the defines for
MASK_ALTIVEC, MASK_CMPB, MASK_CRYPTO, MASK_DFP,
MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI, MASK_FLOAT128_KEYWORD,
MASK_FLOAT128_HW, MASK_FPRND, MASK_P8_FUSION, MASK_HARD_FLOAT,
MASK_HTM, MASK_MFCRF, MASK_MMA, MASK_MULHW, MASK_MULTIPLE,
MASK_NO_UPDATE.

gcc/
* config/rs6000/aix71.h (TARGET_DEFAULT): Replace MASK_MFCRF with
OPTION_MASK_MFCRF.
* config/rs6000/darwin.h (TARGET_DEFAULT): Replace MASK_MULTIPLE with
OPTION_MASK_MULTIPLE.
* config/rs6000/darwin64-biarch.h (TARGET_DEFAULT): Same.
* config/rs6000/default64.h (TARGET_DEFAULT): Replace MASK_MFCRF with
OPTION_MASK_MFCRF.
* config/rs6000/eabi.h (TARGET_DEFAULT): Replace MASK_EABI with
OPTION_MASK_EABI.
* config/rs6000/eabialtivec.h (TARGET_DEFAULT): Same.
* config/rs6000/linuxaltivec.h (TARGET_DEFAULT): Replace
MASK_ALTIVEC with OPTION_MASK_ALTIVEC.
* config/rs6000/rs6000-cpus.def (MASK_ALTIVEC, MASK_CMPB,
MASK_CRYPTO, MASK_DFP, MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI,
MASK_FLOAT128_KEYWORD, MASK_FLOAT128_HW, MASK_FPRND,
MASK_P8_FUSION, MASK_HARD_FLOAT, MASK_HTM, MASK_ISEL, MASK_MFCRF,
MASK_MMA, MASK_MULHW, MASK_MULTIPLE, MASK_NO_UPDATE):
Replace with
OPTION_MASK_ALTIVEC, OPTION_MASK_CMPB, OPTION_MASK_CRYPTO,
OPTION_MASK_DFP, OPTION_MASK_DIRECT_MOVE, OPTION_MASK_DLMZB,
OPTION_MASK_EABI, OPTION_MASK_FLOAT128_KEYWORD,
OPTION_MASK_FLOAT128_HW, OPTION_MASK_FPRND, OPTION_MASK_P8_FUSION,
OPTION_MASK_HARD_FLOAT, OPTION_MASK_HTM, OPTION_MASK_ISEL,
OPTION_MASK_MFCRF, OPTION_MASK_MMA, OPTION_MASK_MULHW,
OPTION_MASK_MULTIPLE, OPTION_MASK_NO_UPDATE.
* config/rs6000/rs6000.cc (rs6000_darwin_file_start): Replace
MASK_MFCRF, MASK_ALTIVEC with OPTION_MASK_MFCRF, OPTION_MASK_ALTIVEC.
* config/rs6000/rs6000.h (TARGET_DEFAULT): Replace MASK_MULTIPLE
with OPTION_MASK_MULTIPLE.
(MASK_ALTIVEC, MASK_CMPB, MASK_CRYPTO, MASK_DFP,
MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI, MASK_FLOAT128_KEYWORD,
MASK_FLOAT128_HW, MASK_FPRND, MASK_P8_FUSION, MASK_HARD_FLOAT,
MASK_HTM, MASK_ISEL, MASK_MFCRF, MASK_MMA, MASK_MULHW,
MASK_MULTIPLE, MASK_NO_UPDATE): Delete.
* config/rs6000/vxworks.h (TARGET_DEFAULT): Replace MASK_EABI
with OPTION_MASK_EABI.

2 years ago[PATCH,RS6000 3/5] Rework the RS6000_BTM defines, continued.
Will Schmidt [Thu, 23 Jun 2022 20:50:57 +0000 (15:50 -0500)]
[PATCH,RS6000 3/5] Rework the RS6000_BTM defines, continued.

The RS6000_BTM_<xxxx> definitions are mostly unused after
the rs6000 builtin code was reworked.   This cleans
up the remaining RS6000_BTM_<xxxx> references by replacing
them with their OPTION_MASK_<xxxx> equivalents.

This patch removes the defines
RS6000_BTM_MODULO, RS6000_BTM_ALTIVEC, RS6000_BTM_CMPB,
RS6000_BTM_VSX, RS6000_BTM_P8_VECTOR, RS6000_BTM_P9_VECTOR,
RS6000_BTM_P9_MISC, RS6000_BTM_CRYPTO, RS6000_BTM_HTM,
RS6000_BTM_FRE.

gcc/
* config/rs6000/rs6000.cc (RS6000_BTM_ALTIVEC, RS6000_BTM_CMPB,
RS6000_BTM_VSX, RS6000_BTM_FRE, RS6000_BTM_P8_VECTOR,
RS6000_BTM_P9_VECTOR, RS6000_BTM_P9_MISC, RS6000_BTM_MODULO,
RS6000_BTM_CRYPTO, RS6000_BTM_HTM): Replace with OPTION_MASK_ALTIVEC,
OPTION_MASK_CMPB, OPTION_MASK_VSX, OPTION_MASK_POPCNTB,
OPTION_MASK_P8_VECTOR, OPTION_MASK_P9_VECTOR, OPTION_MASK_P9_MISC,
OPTION_MASK_MODULO, OPTION_MASK_CRYPTO, OPTION_MASK_HTM.
* config/rs6000/rs6000.h (RS6000_BTM_MODULO, RS6000_BTM_ALTIVEC,
RS6000_BTM_CMPB, RS6000_BTM_VSX, RS6000_BTM_P8_VECTOR,
RS6000_BTM_P9_VECTOR, RS6000_BTM_P9_MISC, RS6000_BTM_CRYPTO,
RS6000_BTM_HTM, RS6000_BTM_FRE): Remove.

2 years ago[PATCH,RS6000 2/5] Rework the RS6000_BTM defines.
Will Schmidt [Thu, 23 Jun 2022 20:48:21 +0000 (15:48 -0500)]
[PATCH,RS6000 2/5] Rework the RS6000_BTM defines.

The RS6000_BTM_<xxxx> definitions are mostly unused after the rs6000
builtin code was reworked.  The remaining references can be replaced
with the OPTION_MASK_<xxxx> and MASK_<xxxx> equivalents.

This patch remvoes the defines:
RS6000_BTM_FRES, RS6000_BTM_FRSQRTE, RS6000_BTM_FRSQRTES,
RS6000_BTM_POPCNTD, RS6000_BTM_CELL, RS6000_BTM_DFP,
RS6000_BTM_HARD_FLOAT, RS6000_BTM_LDBL128, RS6000_BTM_64BIT,
RS6000_BTM_POWERPC64, RS6000_BTM_FLOAT128, RS6000_BTM_FLOAT128_HW
RS6000_BTM_MMA, RS6000_BTM_P10.

I note that the BTM -> OPTION_MASK mappings are not always 1-to-1.
in particular the BTM_FRES and BTM_FRSQRTE values were both mapped to
OPTION_MASK_PPC_GFXOPT, while the BTM_FRE and BTM_FRSQRTES both mapped
to OPTION_MASK_POPCNTB.  In total I spent quite a bit of time
double-checking these since it looked like copy/paste errors.  I split
some of these changes out into a subsequent patch to limit the amount
of potential confusion in any particular patch.

gcc/
* config/rs6000/rs6000-c.cc: Update comments.
* config/rs6000/rs6000.cc (RS6000_BTM_FRES, RS6000_BTM_FRSQRTE,
RS6000_BTM_FRSQRTES, RS6000_BTM_POPCNTD, RS6000_BTM_CELL,
RS6000_BTM_64BIT, RS6000_BTM_POWERPC64, RS6000_BTM_DFP,
RS6000_BTM_HARD_FLOAT,RS6000_BTM_LDBL128, RS6000_BTM_FLOAT128,
RS6000_BTM_FLOAT128_HW, RS6000_BTM_MMA, RS6000_BTM_P10): Replace
with OPTION_MASK_PPC_GFXOPT, OPTION_MASK_PPC_GFXOPT,
OPTION_MASK_POPCNTB, OPTION_MASK_POPCNTD,
OPTION_MASK_FPRND, MASK_64BIT, MASK_POWERPC64,
OPTION_MASK_DFP, OPTION_MASK_SOFT_FLOAT, OPTION_MASK_MULTIPLE,
OPTION_MASK_FLOAT128_KEYWORD, OPTION_MASK_FLOAT128_HW,
OPTION_MASK_MMA, OPTION_MASK_POWER10.
* config/rs6000/rs6000.h (RS6000_BTM_FRES, RS6000_BTM_FRSQRTE,
RS6000_BTM_FRSQRTES, RS6000_BTM_POPCNTD, RS6000_BTM_CELL,
RS6000_BTM_DFP, RS6000_BTM_HARD_FLOAT, RS6000_BTM_LDBL128,
RS6000_BTM_64BIT, RS6000_BTM_POWERPC64, RS6000_BTM_FLOAT128,
RS6000_BTM_FLOAT128_HW, RS6000_BTM_MMA, RS6000_BTM_P10): Delete.

2 years ago[PATCH,RS6000 1/5] Clean-up MASK_<xxxx> and RS6000_BTM_<xxxx> definitions.
Will Schmidt [Thu, 23 Jun 2022 20:45:15 +0000 (15:45 -0500)]
[PATCH,RS6000 1/5] Clean-up MASK_<xxxx> and RS6000_BTM_<xxxx> definitions.

This patch removes the defines that are no longer used, and
updates the comment for the set of MASK_<xxxx> defines.

This patch removes the defines for
MASK_REGNAMES, MASK_PROTOTYPE, RS6000_BTM_ALWAYS, RS6000_BTM_COMMON.

gcc/
* config/rs6000/rs6000.h (RS6000_BTM_COMMON, RS6000_BTM_ALWAYS,
MASK_REGNAMES, OPTION_MASK_REGNAMES, MASK_PROTOTYPE,
OPTION_MASK_PROTOTYPE, MASK_UPDATE, OPTION_MASK_UPDATE): Remove.

2 years agomiddle-end/106070 - bogus cond-expr folding
Richard Biener [Fri, 24 Jun 2022 11:37:22 +0000 (13:37 +0200)]
middle-end/106070 - bogus cond-expr folding

The following fixes up r13-469-g9a53101caadae1b5 by properly
implementing what operand_equal_for_comparison_p did.

2022-06-24  Richard Biener  <rguenther@suse.de>

PR middle-end/106070
* match.pd (a != b ? a : b): Fix translation of
operand_equal_for_comparison_p.

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

2 years agolibstdc++: use grep -E instead of egrep in scripts
Xi Ruoyao [Fri, 24 Jun 2022 07:02:23 +0000 (15:02 +0800)]
libstdc++: use grep -E instead of egrep in scripts

egrep has been deprecated in favor of grep -E for a long time, and the
next grep release (3.8 or 4.0) will print a warning of egrep is used.
Stop using egrep so we won't see the warning.

grep's from GNU, BSD (including Mac OS X), AIX, BusyBox all support -E
and -F.  Solaris grep doesn't support -E, but extract_symvers.in already
contains a special case for Solaris and doxygen documentation generation
is already broken on non-GNU.

libstdc++-v3/ChangeLog:

* scripts/extract_symvers.in: Use grep -E instead of egrep.
* scripts/run_doxygen: Likewise.

2 years agoFix stmt_kills_ref_p WRT external throws
Jan Hubicka [Fri, 24 Jun 2022 11:52:44 +0000 (13:52 +0200)]
Fix stmt_kills_ref_p WRT external throws

Add missing check to stmt_kills_ref_p for case that function
is terminated by EH before call return value kills the ref. In the PR
I tried to construct testcase but I don't know how to do that until I
annotate EH code with fnspec attributes which I will do in separate patch
and add a testcase.

PR ipa/106057
* tree-ssa-alias.cc (stmt_kills_ref_p): Check for external throw.

2 years agoprofile-count: fix /= and *= operators
Martin Liska [Thu, 23 Jun 2022 20:59:11 +0000 (22:59 +0200)]
profile-count: fix /= and *= operators

PR middle-end/106059

gcc/ChangeLog:

* profile-count.h: *= and /= operators need to modify this
object.

2 years agoPR target/105930: Split *xordi3_doubleword after reload on x86.
Roger Sayle [Fri, 24 Jun 2022 06:15:08 +0000 (07:15 +0100)]
PR target/105930: Split *xordi3_doubleword after reload on x86.

This patch addresses PR target/105930 which is an ia32 stack frame size
regression in high-register pressure XOR-rich cryptography functions
reported by Linus Torvalds.  The underlying problem is once the limited
number of registers on the x86 are exhausted, the register allocator
has to decide which to spill, where some eviction choices lead to much
poorer code, but these consequences are difficult to predict in advance.

The patch below, which splits xordi3_doubleword and iordi3_doubleword
after reload (instead of before), significantly reduces the amount of
spill code and stack frame size, in what might appear to be an arbitrary
choice.

My explanation of this behaviour is that the mixing of pre-reload split
SImode instructions and post-reload split DImode instructions is
confusing some of the heuristics used by reload.  One might think
that splitting early gives the register allocator more freedom to
use available registers, but in practice the constraint that double
word values occupy consecutive registers (when ultimately used as a
DImode value) is the greater constraint.  Instead, I believe in this
case, the pseudo registers used in memory addressing, appear to be
double counted for split SImode instructions compared to unsplit
DImode instructions.  For the reduced test case in comment #13, this
leads to %eax being used to hold the long-lived argument pointer "v",
blocking the use of the ax:dx pair for processing double word values.
The important lines are at the very top of the assembly output:

GCC 11 [use %ecx to address memory, require a 24-byte stack frame]
        sub     esp, 24
        mov     ecx, DWORD PTR [esp+40]

GCC 12 [use %eax to address memory, require a 44-byte stack frame]
        sub     esp, 44
        mov     eax, DWORD PTR [esp+64]

2022-06-24  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
PR target/105930
* config/i386/i386.md (*<any_or>di3_doubleword): Split after
reload.  Use rtx_equal_p to avoid creating memory-to-memory moves,
and emit NOTE_INSN_DELETED if operand[2] is zero (i.e. with -O0).

2 years agolibstdc++: check for openat
Alexandre Oliva [Fri, 24 Jun 2022 02:20:53 +0000 (23:20 -0300)]
libstdc++: check for openat

rtems6.0 has fdopendir, and fcntl.h defines AT_FDCWD and declares
openat, but there's no openat in libc.  Adjust dir-common.h to not
assume ::openat just because of AT_FDCWD.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
openat.
* configure, config.h.in: Rebuilt.
* src/filesystem/dir-common.h (openat): Use ::openat if
_GLIBCXX_HAVE_OPENAT.
* src/filesystem/dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

2 years agolibstdc++: xfail rename tests on rtems
Alexandre Oliva [Fri, 24 Jun 2022 02:20:52 +0000 (23:20 -0300)]
libstdc++: xfail rename tests on rtems

::rename on RTEMS does not meet several POSIX requirements, despite
compliance with C and C++ standards.  ::std::filesystem::rename, in
turn, has requirements borrowed from POSIX, so it would have to be a
lot more than a simple wrapper around ::rename on RTEMS, and even then
fall short.

Until RTEMS reimplements ::rename for POSIX compliance, expect
filesystem rename tests to fail on it.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/operations/rename.cc: xfail on
rtems.
* testsuite/experimental/filesystem/operations/rename.cc:
Likewise.

2 years agolibstdc++: testsuite: skip fs last_write_time tests if dummy
Alexandre Oliva [Fri, 24 Jun 2022 02:20:51 +0000 (23:20 -0300)]
libstdc++: testsuite: skip fs last_write_time tests if dummy

The last_write_time functions are defined in ways that are useful, or
that fail immediately, depending on various macros.  When they fail
immediately, the filesystem last_write_time.cc tests fail noisily, but
the fail is entirely expected.

Define NO_LAST_WRITE_TIME in the last_write_time.cc tests, according
to the macros that select implementations of last_write_time, and use
it through the new dg-require-target-fs-lwt to skip tests that are
expected to fail.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_LAST_WRITE_TIME): Define
when appropriate.
* testsuite/lib/libstdc++.exp
(check_v3_target_fs_last_write_time): New.
* testsuite/lib/dg-options.exp (dg-require-target-fs-lwt):
New.
* testsuite/27_io/filesystem/operations/last_write_time.cc:
Skip the test if the features are unavailable.
* testsuite/experimental/filesystem/operations/last_write_time.cc:
Likewise.

2 years agolibstdc++: testsuite: skip fs space tests on dummy implementations
Alexandre Oliva [Fri, 24 Jun 2022 02:20:51 +0000 (23:20 -0300)]
libstdc++: testsuite: skip fs space tests on dummy implementations

The do_space function is defined in ways that are useful, or that fail
immediately, depending on various macros.  When it fails immediately,
the filesystem space.cc tests fail noisily, but the fail is entirely
expected.

Define NO_SPACE in testsuite_fs.h, according to the macros that select
implementations of do_space, and use it to skip tests that are
expected to fail, through a new dg-require.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_SPACE): Define if
appropriate.
* testsuite/lib/libstdc++.exp (check_v3_target_fs_space): New.
* testsuite/lib/dg-options.exp (dg-require-target-fs-space):
New.
* testsuite/27_io/filesystem/operations/space.cc: Require
target-fs-space.
* testsuite/experimental/filesystem/operations/space.cc:
Likewise.

2 years agolibstdc++: testsuite: conditionalize symlink tests
Alexandre Oliva [Fri, 24 Jun 2022 02:20:50 +0000 (23:20 -0300)]
libstdc++: testsuite: conditionalize symlink tests

Several filesystem tests expect to be able to create symlinks even
when !defined (_GLIBCXX_HAVE_SYMLINK), and fail predictably, reducing
the amount of testing of other filesystem features.

They are already skipped for mingw targets.  I've extended the
skipping to other targets in which _GLIBCXX_HAVE_SYMLINK is undefined,
through a new NO_SYMLINKS macro in testsuite_fs.h that guards
skippable portions of tests, and dg-require-target-fs-symlinks for
tests that would be reduced to nothing.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_SYMLINKS): Define on
mingw and when create_symlink is a dummy.
* testsuite/27_io/filesystem/operations/symlink_status.cc:
Drop mingw xfail.
(test01, test02): Don't create symlinks when NO_SYMLINKS is
defined.
* testsuite/27_io/filesystem/operations/canonical.cc (test03):
Likewise.
* testsuite/27_io/filesystem/operations/copy.cc (test02):
Likewise.
* testsuite/27_io/filesystem/operations/create_directories.cc
(test04): Likewise.
* testsuite/27_io/filesystem/operations/create_directory.cc
(test01): Likewise.
* testsuite/27_io/filesystem/operations/permissions.cc
(test03, test04): Likewise.
* testsuite/27_io/filesystem/operations/remove.cc (test01):
Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc (test01):
Likewise.
* testsuite/27_io/filesystem/operations/rename.cc
(test_symlinks): Likewise.
* testsuite/27_io/filesystem/operations/weakly_canonical.cc
(test01): Likewise.
* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc
(test06): Likewise.
* testsuite/experimental/filesystem/operations/copy.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/create_directories.cc
(test04): Likewise.
* testsuite/experimental/filesystem/operations/create_directory.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/permissions.cc
(test03, test04): Likewise.
* testsuite/experimental/filesystem/operations/remove.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/remove_all.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/rename.cc
(test01): Likewise.
* testsuite/lib/libstdc++.exp
(v3_check_preprocessor_condition): Add optional inc parameter.
Add it to the test program after include bits/c++config.h.
(check_v3_target_fs_symlinks): New.
* testsuite/lib/dg-options.exp
(dg-require-target-fs-symlinks): New.
* testsuite/27_io/filesystem/operations/read_symlink.cc:
Replace mingw xfail with require target-fs-symlinks.
* testsuite/experimental/filesystem/operations/read_symlink.cc:
Likewise.

2 years agoIntroduce -nostdlib++ option
Alexandre Oliva [Fri, 24 Jun 2022 02:20:48 +0000 (23:20 -0300)]
Introduce -nostdlib++ option

Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C,
is error prone, because there's no way to tell g++ to drop libstdc++
without also dropping libc and any other libraries that the target
implicitly links in.

This has often led to the need for manual adjustments to this
testcase.

I figured adding support for -nostdlib++, even though redundant, makes
some sense.  One could presumably use gcc rather than g++ for linking,
for the same effect, but sometimes changing the link command is harder
than adding an option, as in our testsuite.

Since clang already had an option with this effect, we've adopted the
same spelling.

for  gcc/ChangeLog

* common.opt (nostdlib++): New.
* doc/invoke.texi (-nostdlib++): Document it.

for  gcc/cp/ChangeLog

* g++spec.cc (lang_specific_driver): Implement -nostdlib++.

for  gcc/testsuite/ChangeLog

* g++.dg/abi/pure-virtual1.C: Use -nostdlib++.

2 years agolibstdc++: testsuite: avoid predictable mkstemp
Alexandre Oliva [Fri, 24 Jun 2022 02:20:47 +0000 (23:20 -0300)]
libstdc++: testsuite: avoid predictable mkstemp

This patch was originally meant to reduce the likelihood that
nonexistent_path() returns the same pathname for from and to.

It was prompted by a target system with a non-random implementation of
mkstemp, that returns a predictable sequence of filenames and selects
the first one that isn't already taken.

That turned out not to be enough: nonexistent_path adds a suffix to
the filename chosen by mkstemp and removes the file it created, so
mkstemp may very well insist on the same basename, and the case that
doesn't use mkstemp doesn't even check whether the file already
exists.

Anyway, by the time I realized this wasn't enough, I'd already
implemented some of the changes, and I figured I might as well
contribute them, even though they don't really solve any problem, and
even if they did, they'd be just a partial solution.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/operations/copy.cc (test02):
Select TO after creating FROM.
(test03, test04): Likewise.
* testsuite/experimental/filesystem/operations/copy.cc
(test02, test03, test04): Likewise.

2 years agolibstdc++: testsuite: tolerate non-cancelling sleep
Alexandre Oliva [Fri, 24 Jun 2022 02:20:46 +0000 (23:20 -0300)]
libstdc++: testsuite: tolerate non-cancelling sleep

Though sleep, nanosleep and clock_nanosleep are all POSIX cancellation
points, not all target systems follow this POSIX requirement.
30_threads/thread/native_handle/cancel.cc will run until it times out
on such systems.

Rather than failing a C++ library test because of a limitation of the
target system, this patch gives the test a chance to successfully
exercise the features it intends to exercise, by introducing a
cancellation point in a loop that would otherwise run indefinitely on
systems exhibiting this limitation.

for  libstdc++-v3/ChangeLog

* testsuite/30_threads/thread/native_handle/cancel.cc: Add an
explicit cancellation point in case sleep_for lacks one.

2 years agolibstdc++: testsuite: use -lbsd for net_ts on RTEMS
Alexandre Oliva [Fri, 24 Jun 2022 02:20:46 +0000 (23:20 -0300)]
libstdc++: testsuite: use -lbsd for net_ts on RTEMS

Networking functions that net_ts tests rely on are defined in libbsd
on RTEMS, so link with it.

for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp (add_options_for_net_ts): Add
-lbsd for RTEMS targets.

2 years agoaarch64: testsuite: symbol-range fallback to compile
Alexandre Oliva [Fri, 24 Jun 2022 02:20:45 +0000 (23:20 -0300)]
aarch64: testsuite: symbol-range fallback to compile

On some of our embedded aarch64 targets, RAM size is too small for
this test to fit.  It doesn't look like this test requires linking,
and if it does, the -tiny version may presumably get most of the
coverage without going overboard in target system requirements.

Still, linking may be useful, so introduce a two_plus_gigs effective
target, that checks for the ability to link a program with 2GiB of
sbss, and use that to select whether to link or just compile
symbol-range.c.

for  gcc/ChangeLog

* doc/sourcebuild.texi (Environment attributes): Document
two_plus_gigs.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp
(check_effective_target_two_plus_gigs): New.
* gcc.target/aarch64/symbol-range.c: Link only on
two_plus_gigs targets, compile otherwise.

2 years agoDaily bump.
GCC Administrator [Fri, 24 Jun 2022 00:16:41 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: designated init cleanup [PR105925]
Jason Merrill [Thu, 23 Jun 2022 18:41:19 +0000 (14:41 -0400)]
c++: designated init cleanup [PR105925]

build_aggr_conv expects to run after reshape_init, which will usually have
filled out all the CONSTRUCTOR indexes; there's no reason to limit using
those to the case where the user gave an explicit designator.

PR c++/105925

gcc/cp/ChangeLog:

* call.cc (build_aggr_conv): Don't depend on
CONSTRUCTOR_IS_DESIGNATED_INIT.

2 years agoc++: anon union designated init [PR105925]
Jason Merrill [Thu, 23 Jun 2022 20:04:02 +0000 (16:04 -0400)]
c++: anon union designated init [PR105925]

This testcase was failing because CONSTRUCTOR_IS_DESIGNATED_INIT wasn't
getting set on the introduced CONSTRUCTOR for the anonymous union, and
build_aggr_conv uses that flag to decide whether to pay attention to the
indexes of the CONSTRUCTOR.  So set the flag when we see a designator rather
than relying on copying it from another CONSTRUCTOR.

This avoids some redundant errors on desig4.C because we stop setting
CONSTRUCTOR_IS_DESIGNATED_INIT on _Complex CONSTRUCTORs where it's
nonsense.

PR c++/105925

gcc/cp/ChangeLog:

* decl.cc (reshape_init_array_1): Set
CONSTRUCTOR_IS_DESIGNATED_INIT here.
(reshape_init_class): And here.
(reshape_init): Not here.

gcc/testsuite/ChangeLog:

* g++.dg/ext/desig4.C: Remove extra errors.
* g++.dg/cpp2a/desig26.C: New test.

2 years agoc++: constexpr folding in unevaluated context [PR105931]
Patrick Palka [Thu, 23 Jun 2022 20:36:43 +0000 (16:36 -0400)]
c++: constexpr folding in unevaluated context [PR105931]

Changing the type of N from int to unsigned in decltype82.C (from
r13-986-g0ecb6b906f215e) reveals another spot where we perform constexpr
evaluation in an unevaluated context for sake of warnings, this time
from the call to shorten_compare in cp_build_binary_op, which calls
fold_for_warn.

We could (and probably should) suppress the shorten_compare warnings
when in an unevaluated context, but there's probably other callers of
fold_for_warn that are similarly affected.  So this patch takes the
approach of directly suppressing fold_for_warn when in an unevaluated
context.

PR c++/105931

gcc/cp/ChangeLog:

* expr.cc (fold_for_warn): Don't fold when in an unevaluated
context.

gcc/testsuite/ChangeLog:

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

2 years agoc++: context completion in lookup_template_class [PR105982]
Patrick Palka [Thu, 23 Jun 2022 20:18:55 +0000 (16:18 -0400)]
c++: context completion in lookup_template_class [PR105982]

The below testcase demonstrates that completion of the substituted
context during lookup_template_class can end up registering the desired
specialization for us in more cases than r13-1045-gcb7fd1ea85feea
anticipated.  In particular this can happen for a non-dependent
specialization of a nested class as well.

For this testcase, during overload resolution with A's guides, we
substitute the deduced argument T=int into the TYPENAME_TYPE B::C,
during which we call lookup_template_class for A<T>::B with T=int,
which completes A<int> for the first time, which recursively registers
the desired specialization of B already.  The parent call to
lookup_template_class then tries to register the same specialization,
triggering an ICE.

This patch fixes this by making lookup_template_class determine more
directly whether we need to recheck the specializations table after
completion of the context -- when and only when the call to complete_type
had an effect.

PR c++/105982

gcc/cp/ChangeLog:

* pt.cc (lookup_template_class): After calling complete_type for
the substituted context, check the table again iff the type was
previously incomplete and complete_type made it complete.

gcc/testsuite/ChangeLog:

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

2 years agocompiler: in Sort_bindings return false if comparing value to itself
zhangjian [Tue, 21 Jun 2022 16:08:47 +0000 (16:08 +0000)]
compiler: in Sort_bindings return false if comparing value to itself

Some versions of std::sort may pass elements at the same iterator location.

Fixes golang/go#53483

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413434

2 years agocompiler: unalias types for hash/equality functions
Ian Lance Taylor [Wed, 22 Jun 2022 23:40:24 +0000 (16:40 -0700)]
compiler: unalias types for hash/equality functions

Test case is https://go.dev/cl/413694.

Fixes golang/go#52846

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413660

2 years agodiagnostics: add ability to associate diagnostics with rules from coding standards
David Malcolm [Thu, 23 Jun 2022 18:59:24 +0000 (14:59 -0400)]
diagnostics: add ability to associate diagnostics with rules from coding standards

gcc/ChangeLog:
* common.opt (fdiagnostics-show-rules): New option.
* diagnostic-format-json.cc (diagnostic_output_format_init_json):
Fix up context->show_rules.
* diagnostic-format-sarif.cc
(diagnostic_output_format_init_sarif): Likewise.
* diagnostic-metadata.h (diagnostic_metadata::rule): New class.
(diagnostic_metadata::precanned_rule): New class.
(diagnostic_metadata::add_rule): New.
(diagnostic_metadata::get_num_rules): New.
(diagnostic_metadata::get_rule): New.
(diagnostic_metadata::m_rules): New field.
* diagnostic.cc (diagnostic_initialize): Initialize show_rules.
(print_any_rules): New.
(diagnostic_report_diagnostic): Call it.
* diagnostic.h (diagnostic_context::show_rules): New field.
* doc/invoke.texi (-fno-diagnostics-show-rules): New option.
* opts.cc (common_handle_option): Handle
OPT_fdiagnostics_show_rules.
* toplev.cc (general_init): Set up global_dc->show_rules.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-metadata.c: Expect " [STR34-C]" to
be emitted at the "gets" call.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.c
(pass_test_metadata::execute): Associate the "gets" diagnostic
with a rule named "STR34-C".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agolibstdc++: Properly remove temporary directories in filesystem tests
Jonathan Wakely [Thu, 23 Jun 2022 13:25:49 +0000 (14:25 +0100)]
libstdc++: Properly remove temporary directories in filesystem tests

Although these tests use filesystem::remove_all to clean up, that fails
because it uses recursive_directory_iterator which is intentionally
bodged by the custom readdir defined in the test.

Just use POSIX rmdir to clean up. We don't need to use _rmdir or _wrmdir
for Windows, because we'll never reach test02() on targets where the
custom readdir doesn't interpose the one from libc.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
rmdir to remove directories.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.

2 years agoc++: -Waddress and if constexpr [PR94554]
Jason Merrill [Thu, 23 Jun 2022 04:24:22 +0000 (00:24 -0400)]
c++: -Waddress and if constexpr [PR94554]

Like we avoid various warnings for seemingly tautological expressions when
substituting a template, we should avoid warning for the implicit conversion
to bool in an if statement.  I considered also doing this for the conditions
in loop expressions, but that seems unnecessary, as a loop condition is
unlikely to be a constant.

The change to finish_if_stmt_cond isn't necessary since dependent_operand_p
looks through IMPLICIT_CONV_EXPR, but makes it more constent with
e.g. build_x_binary_op that determines the type of an expression and then
builds it using the original operands.

PR c++/94554

gcc/cp/ChangeLog:

* pt.cc (dependent_operand_p): Split out from...
(tsubst_copy_and_build): ...here.
(tsubst_expr) [IF_STMT]: Use it.
* semantics.cc (finish_if_stmt_cond): Keep the pre-conversion
condition in the template tree.

gcc/testsuite/ChangeLog:

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

2 years agoc++: -Waddress and value-dependent expr [PR105885]
Jason Merrill [Thu, 23 Jun 2022 03:50:23 +0000 (23:50 -0400)]
c++: -Waddress and value-dependent expr [PR105885]

We already suppress various warnings for code that would be tautological if
written directly, but not when it's the result of template substitution.  It
seems we need to do this for -Waddress as well.

PR c++/105885

gcc/cp/ChangeLog:

* pt.cc (tsubst_copy_and_build): Also suppress -Waddress for
comparison of dependent operands.

gcc/testsuite/ChangeLog:

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

2 years agoc++: properly initialize UBSAN built-ins
Martin Liska [Thu, 23 Jun 2022 12:43:50 +0000 (14:43 +0200)]
c++: properly initialize UBSAN built-ins

PR c++/106062

gcc/ChangeLog:

* ubsan.cc (sanitize_unreachable_fn): Change order of calls
in order to initialize UBSAN built-ins.

gcc/testsuite/ChangeLog:

* gfortran.dg/ubsan/pr106062.f90: New test.

2 years agoc++: Prune unneeded macro locations
Nathan Sidwell [Wed, 22 Jun 2022 12:54:30 +0000 (05:54 -0700)]
c++: Prune unneeded macro locations

This implements garbage collection on locations within macro
expansions, when streaming out a CMI.  When doing the reachability
walks, we now note which macro locations we need and then only write
those locations.  The complication here is that every macro expansion
location has an independently calculated offset.  This complicates
writing, but reading remains the same -- the macro locations of a CMI
continue to form a contiguous block.

For std headers this reduced the number of macro maps by 40% and the
number of locations by 16%.  For a GMF including iostream, it reduced
it by 80% and 60% respectively.

Ordinary locations are still transformed en-mass.  They are somewhat
more complicated to apply a similar optimization to.

gcc/cp/
* module.cc (struct macro_info): New.
(struct macro_traits): New.
(macro_remap, macro_table): New globals.
(depset::hash::find_dependencies): Note namespace location.
(module_for_macro_loc): Adjust.
(module_state::note_location): New.
(module_state::Write_location): Note location when not
streaming. Adjust macro location streaming.
(module_state::read_location): Adjust macro location
streaming.
(module_state::write_init_maps): New.
(module_state::write_prepare_maps): Reimplement macro map
preparation.
(module_state::write_macro_maps): Reimplement.
(module_state::read_macro_maps): Likewise.
(module_state::write_begin): Adjust.
gcc/testsuite/
* g++.dg/modules/loc-prune-1.C: New.
* g++.dg/modules/loc-prune-2.C: New.
* g++.dg/modules/loc-prune-3.C: New.
* g++.dg/modules/pr98718_a.C: Adjust.
* g++.dg/modules/pr98718_b.C: Adjust.

2 years agotestsuite: Compile slsr-39.c without vectorisation
Richard Sandiford [Thu, 23 Jun 2022 11:54:10 +0000 (12:54 +0100)]
testsuite: Compile slsr-39.c without vectorisation

The fix for PR106019 regressed slsr-39.c for -m32 -march=cascadelake
because we are now able to vectorise the code.  (Whether the code model
should be allowing that is a different question -- the vectorised code
looked worse to me.)

The test runs at -O2 and predates vectorisation being enabled at -O2,
so this patch just adds -fno-tree-vectorize.

gcc/testsuite/
* gcc.dg/tree-ssa/slsr-39.c: Force vectorization off.

2 years agolibstdc++: Simplify test by not using std::log2
Jonathan Wakely [Thu, 23 Jun 2022 10:58:16 +0000 (11:58 +0100)]
libstdc++: Simplify test by not using std::log2

This test uses std::log2 without including <cmath>, but it doesn't need
to use it at all. Just get the number of digits from numeric_limits
instead.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/random_device/entropy.cc: Use
numeric_limits<unsigned>::digits.

2 years agoipa-icf: skip variables with body_removed
Martin Liska [Wed, 18 May 2022 13:07:53 +0000 (15:07 +0200)]
ipa-icf: skip variables with body_removed

Similarly to cgraph_nodes, it may happen that body_removed is set
during merging of symbols.

PR ipa/105600

gcc/ChangeLog:

* ipa-icf.cc (sem_item_optimizer::filter_removed_items):
Skip variables with body_removed.

2 years agoReplace REGNO with reg_or_subregno in pre_reload splitter.
liuhongt [Wed, 22 Jun 2022 06:08:42 +0000 (14:08 +0800)]
Replace REGNO with reg_or_subregno in pre_reload splitter.

gcc/ChangeLog:

* config/i386/sse.md:(sse4_2_pcmpestr): Replace REGNO with
reg_or_subregno.
(sse4_2_pcmpistr): Ditto.

2 years agoc++: tweak deduction with auto template parms
Jason Merrill [Thu, 23 Jun 2022 01:29:16 +0000 (21:29 -0400)]
c++: tweak deduction with auto template parms

While looking at PR105964 I noticed that we were unnecessarily repeating
the deduction loop because of seeing a non-type parameter with type 'auto'.
It is indeed dependent, but not on any other deductions.

gcc/cp/ChangeLog:

* pt.cc (type_unification_real): An auto tparm can't
be affected by other deductions.

2 years agoc++: dependence of baselink [PR105964]
Jason Merrill [Wed, 22 Jun 2022 22:19:11 +0000 (18:19 -0400)]
c++: dependence of baselink [PR105964]

helper<token>::c isn't dependent just because we haven't deduced its return
type yet.  type_dependent_expression_p already knows how to deal with that
for bare FUNCTION_DECL, but needs to learn to look through a BASELINK.

PR c++/105964

gcc/cp/ChangeLog:

* pt.cc (type_dependent_expression_p): Look through BASELINK.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/nontype-auto21.C: New test.

2 years agoFix typo
Xionghu Luo [Wed, 22 Jun 2022 07:18:39 +0000 (15:18 +0800)]
Fix typo

Fix typo and commit as obvious.

Signed-off-by: Xionghu Luo <xionghuluo@tencent.com>
gcc/ChangeLog:

* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): Fix
typo.
* tree-ssa-loop-ivopts.cc (struct iv_cand): Likewise.
* tree-switch-conversion.h: Likewise.

2 years agoDaily bump.
GCC Administrator [Thu, 23 Jun 2022 00:16:40 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: class scope function lookup [PR105908]
Jason Merrill [Wed, 22 Jun 2022 18:57:21 +0000 (14:57 -0400)]
c++: class scope function lookup [PR105908]

In r12-1273 for PR91706, I removed the code in get_class_binding that
stripped BASELINK.  This testcase demonstrates that we still need to strip
it in outer_binding before putting the overload set in IDENTIFIER_BINDING,
for compatibility with bindings added directly for declarations.

PR c++/105908

gcc/cp/ChangeLog:

* name-lookup.cc (outer_binding): Strip BASELINK.

gcc/testsuite/ChangeLog:

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

2 years agod: Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.
Iain Buclaw [Wed, 22 Jun 2022 15:03:33 +0000 (17:03 +0200)]
d:  Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.

D front-end changes:

    - Input parameters can now be applied on extern(C++) functions to
      bind to `const &' when the `-fpreview=in' flag is in effect.

D runtime changes:

    - Run-time flag `--DRT-oncycle=deprecate' has been removed.

Phobos changes:

    - Removed std.experimental.logger's capability to set the minimal
      LogLevel at compile time.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 6203135dc.
* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)):
Update for new front-end interface.
(SpeculativeTypeVisitor::visit (TypeStruct *)): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e150cca1.
* src/MERGE: Merge upstream phobos a4a18d21c.
* testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update
expected result of deprecate test.

2 years agoc++: Remove ifdefed code
Nathan Sidwell [Wed, 22 Jun 2022 14:51:44 +0000 (07:51 -0700)]
c++: Remove ifdefed code

The only reason I chose to use DECL_UID on this hash table was to make
it stable against ASLR and perturbations due to other allocations.
It's not required for correctness, as the comment mentions the
equality fn uses pointer identity.

gcc/cp/
* module.cc (struct duplicate_hash): Remove.
(duplicate_hash_map): Adjust.

2 years agoubsan: default to trap on unreachable at -O0 and -Og [PR104642]
Jason Merrill [Fri, 10 Jun 2022 20:35:21 +0000 (16:35 -0400)]
ubsan: default to trap on unreachable at -O0 and -Og [PR104642]

When not optimizing, we can't do anything useful with unreachability in
terms of code performance, so we might as well improve debugging by turning
__builtin_unreachable into a trap.  I think it also makes sense to do this
when we're explicitly optimizing for the debugging experience.

In the PR richi suggested introducing an -funreachable-traps flag for this.
This functionality is already implemented as -fsanitize=unreachable
-fsanitize-trap=unreachable, and we want to share the implementation, but it
does seem useful to have a separate flag that isn't affected by the various
sanitization controls.  -fsanitize=unreachable takes priority over
-funreachable-traps if both are enabled.

Jakub observed that this would slow down -O0 by default from running the
sanopt pass, so this revision avoids the need for sanopt by rewriting calls
introduced by the compiler immediately, and calls written by the user at
fold time.  Many of the calls introduced by the compiler are also rewritten
immediately to ubsan calls when not trapping, which fixes ubsan-8b.C;
previously the call to f() was optimized away before sanopt.  But this early
rewriting isn't practical for uses of __builtin_unreachable in
devirtualization and such, so sanopt rewriting is still done for
non-trapping sanitize.

PR c++/104642

gcc/ChangeLog:

* common.opt: Add -funreachable-traps.
* doc/invoke.texi (-funreachable-traps): Document it.
* opts.cc (finish_options): Enable at -O0 or -Og.
* tree.cc (build_common_builtin_nodes): Add __builtin_trap.
(builtin_decl_unreachable, build_builtin_unreachable): New.
* tree.h: Declare them.
* ubsan.cc (sanitize_unreachable_fn): Factor out.
(ubsan_instrument_unreachable): Use
gimple_build_builtin_unreachable.
* ubsan.h (sanitize_unreachable_fn): Declare.
* gimple.cc (gimple_build_builtin_unreachable): New.
* gimple.h: Declare it.
* builtins.cc (expand_builtin_unreachable): Add assert.
(fold_builtin_0): Call build_builtin_unreachable.
* sanopt.cc: Don't run for just SANITIZE_RETURN
or SANITIZE_UNREACHABLE when trapping.
* cgraphunit.cc (walk_polymorphic_call_targets): Use new
unreachable functions.
* gimple-fold.cc (gimple_fold_call)
(gimple_get_virt_method_for_vtable)
* ipa-fnsummary.cc (redirect_to_unreachable)
* ipa-prop.cc (ipa_make_edge_direct_to_target)
(ipa_impossible_devirt_target)
* ipa.cc (walk_polymorphic_call_targets)
* tree-cfg.cc (pass_warn_function_return::execute)
(execute_fixup_cfg)
* tree-ssa-loop-ivcanon.cc (remove_exits_and_undefined_stmts)
(unloop_loops)
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt):
Likewise.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_builtin_function_call): Handle
unreachable/trap earlier.
* cp-gimplify.cc (cp_maybe_instrument_return): Use
build_builtin_unreachable.

gcc/testsuite/ChangeLog:

* g++.dg/ubsan/return-8a.C: New test.
* g++.dg/ubsan/return-8b.C: New test.
* g++.dg/ubsan/return-8d.C: New test.
* g++.dg/ubsan/return-8e.C: New test.

2 years agodata-ref: Improve non-loop disambiguation [PR106019]
Richard Sandiford [Wed, 22 Jun 2022 10:27:15 +0000 (11:27 +0100)]
data-ref: Improve non-loop disambiguation [PR106019]

When dr_may_alias_p is called without a loop context, it tries
to use the tree-affine interface to calculate the difference
between the two addresses and use that difference to check whether
the gap between the accesses is known at compile time.  However, as the
example in the PR shows, this doesn't expand SSA_NAMEs and so can easily
be defeated by things like reassociation.

One fix would have been to use aff_combination_expand to expand the
SSA_NAMEs, but we'd then need some way of maintaining the associated
cache.  This patch instead reuses the innermost_loop_behavior fields
(which exist even when no loop context is provided).

It might still be useful to do the aff_combination_expand thing too,
if an example turns out to need it.

gcc/
PR tree-optimization/106019
* tree-data-ref.cc (dr_may_alias_p): Try using the
innermost_loop_behavior to disambiguate non-loop queries.

gcc/testsuite/
PR tree-optimization/106019
* gcc.dg/vect/bb-slp-pr106019.c: New test.

2 years agoRISC-V: Add -mtune=thead-c906 to the invoke docs
Palmer Dabbelt [Thu, 26 May 2022 02:30:55 +0000 (19:30 -0700)]
RISC-V: Add -mtune=thead-c906 to the invoke docs

gcc/ChangeLog

* doc/invoke.texi (RISC-V): Document -mtune=thead-c906.

2 years agolibstdc++: eh_globals: gthreads: reset _S_init before deleting key
Alexandre Oliva [Wed, 22 Jun 2022 02:11:02 +0000 (23:11 -0300)]
libstdc++: eh_globals: gthreads: reset _S_init before deleting key

Clear __eh_globals_init's _S_init in the dtor before deleting the
gthread key.

This ensures that, in case any code involved in deleting the key
interacts with eh_globals, the key that is being deleted won't be
used, and the non-thread-specific eh_globals fallback will.

for  libstdc++-v3/ChangeLog

* libsupc++/eh_globals.cc [!_GLIBCXX_HAVE_TLS]
(__eh_globals_init::~__eh_globals_init): Clear _S_init first.

2 years agolibstdc++: testsuite: call sched_yield for nonpreemptive targets
Alexandre Oliva [Wed, 22 Jun 2022 02:11:01 +0000 (23:11 -0300)]
libstdc++: testsuite: call sched_yield for nonpreemptive targets

As in the gcc testsuite, systems without preemptive multi-threading
require sched_yield calls to be placed at points in which a context
switch might be needed to enable the test to complete.

for  libstdc++-v3/ChangeLog

* testsuite/30_threads/this_thread/60421.cc (test02): Call
sched_yield.

2 years agolibstdc++: testsuite: require cmath for nexttowardl
Alexandre Oliva [Wed, 22 Jun 2022 02:11:00 +0000 (23:11 -0300)]
libstdc++: testsuite: require cmath for nexttowardl

nexttowardl is only expected to be available with C99 math, but
20_util/to_chars/long_double.cc uses it unconditionally.

State the cmath requirement in the test.

for  libstdc++-v3/ChangeLog

* testsuite/20_util/to_chars/long_double.cc: Require cmath.

2 years agolibstdc++: testsuite: work around bitset namespace pollution
Alexandre Oliva [Wed, 22 Jun 2022 02:11:00 +0000 (23:11 -0300)]
libstdc++: testsuite: work around bitset namespace pollution

rtems6 declares a global struct bitset in a header file included
indirectly by sys/types.h, that ambiguates the unqualified references
to bitset after "using namespace std" in the testsuite.

Work around the namespace pollution with using declarations of
std::bitset.

for  libstdc++-v3/ChangeLog

* testsuite/23_containers/bitset/cons/dr1325-2.cc: Work around
global struct bitset.
* testsuite/23_containers/bitset/ext/15361.cc: Likewise.
* testsuite/23_containers/bitset/input/1.cc: Likewise.
* testsuite/23_containers/bitset/to_string/1.cc: Likewise.
* testsuite/23_containers/bitset/to_string/dr396.cc: Likewise.

2 years agotestsuite: outputs.exp: cleanup before running tests
Alexandre Oliva [Wed, 22 Jun 2022 02:10:59 +0000 (23:10 -0300)]
testsuite: outputs.exp: cleanup before running tests

Use the just-added dry-run infrastructure to clean up files that may
have been left over by interrupted runs of outputs.exp, which used to
lead to spurious non-repeatable (self-fixing) failures.

for  gcc/testsuite/ChangeLog

* gcc.misc-tests/outputs.exp: Clean up left-overs first.

2 years agotestsuite: outputs.exp: test for skip_atsave more thoroughly
Alexandre Oliva [Wed, 22 Jun 2022 02:10:58 +0000 (23:10 -0300)]
testsuite: outputs.exp: test for skip_atsave more thoroughly

The presence of -I or -L flags in link command lines changes the
driver's, and thus the linker's behavior, WRT naming files with
command-line options.  With such flags, the driver creates .args.0 and
.args.1 files, whereas without them it's the linker (collect2, really)
that creates .ld1_args.

I've hit some fails on a target system that doesn't have -I or -L
flags in the board config file, but it does add some of them
implicitly with configured-in driver self specs.  Alas, the test in
outputs.exp doesn't catch that, so we proceed to run rather than
skip_atsave tests.

I've reworked the outest procedure to allow dry runs and to return
would-have-been pass/fail results as lists, so we can now test whether
certain files are created and use that to configure the actual test
runs.

for  gcc/testsuite/ChangeLog

* gcc.misc-tests/outputs.exp (outest): Introduce quiet mode,
create and return lists of passes and fails.  Use it to catch
skip_atsave cases where -L flags are implicitly added by
driver self specs.

2 years agoc++: testsuite: require lto_incremental in pr90990_0.C
Alexandre Oliva [Wed, 22 Jun 2022 02:10:58 +0000 (23:10 -0300)]
c++: testsuite: require lto_incremental in pr90990_0.C

Other LTO tests that use -r require the lto_incremental effective
target.  I suppose pr90990_0.C is missing it due to an oversight.
This patch arranges for this test to also be skipped on
non-lto_incremental targets.

for  gcc/testsuite/ChangeLog

* g++.dg/lto/pr90990_0.C: Require lto_incremental target.

2 years agoi386: Add syscall to enable AMX for latest kernels
Haochen Jiang [Thu, 16 Jun 2022 07:15:53 +0000 (00:15 -0700)]
i386: Add syscall to enable AMX for latest kernels

gcc/testsuite/ChangeLog:

* gcc.target/i386/amx-check.h (request_perm_xtile_data):
New function to check if AMX is usable and enable AMX.
(main): Run test if AMX is usable.

2 years agoxtensa: Fix buffer overflow
Takayuki 'January June' Suwa [Tue, 21 Jun 2022 19:51:32 +0000 (04:51 +0900)]
xtensa: Fix buffer overflow

Fortify buffer overflow message reported.
(see https://github.com/earlephilhower/esp-quick-toolchain/issues/36)

gcc/ChangeLog:

* config/xtensa/xtensa.md (bswapsi2_internal):
Enlarge the buffer that is obviously smaller than the template
string given to sprintf().

2 years agoDaily bump.
GCC Administrator [Wed, 22 Jun 2022 00:16:25 +0000 (00:16 +0000)]
Daily bump.

2 years agoPR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md.
Roger Sayle [Tue, 21 Jun 2022 23:08:56 +0000 (00:08 +0100)]
PR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md.

This patch addresses PR target/105991 where a change to prefer representing
shifts and adds at the tree-level as multiplications, causes problems for
the rldimi patterns in the powerpc backend.  The issue is that rs6000.md
models this pattern using IOR, and some variants that have the equivalent
PLUS or XOR in the RTL fail to match some *rotl<mode>4_insert patterns.
This is fixed in this patch by adding a define_insn_and_split to locally
canonicalize the PLUS and XOR forms to the backend's preferred IOR form.

An alternative fix might be for the RTL optimizers to define a canonical
form for these plus_xor_ior equivalent expressions, but the logical
choice might be plus (which may appear in an addressing mode), and such
a change may require a number of tweaks to update various backends
(i.e.  a more intrusive change than the one proposed here).

Many thanks for Marek Polacek for bootstrapping and regression testing
this change without problems.

2022-06-22  Roger Sayle  <roger@nextmovesoftware.com>
    Marek Polacek  <polacek@redhat.com>
    Segher Boessenkool  <segher@kernel.crashing.org>
    Kewen Lin  <linkw@linux.ibm.com>

gcc/ChangeLog
PR target/105991
* config/rs6000/rs6000.md (rotl<mode>3_insert_3): Check that
exact_log2 doesn't return -1 (or zero).
(plus_xor): New code iterator.
(*rotl<mode>3_insert_3_<code>): New define_insn_and_split.

gcc/testsuite/ChangeLog
PR target/105991
* gcc.target/powerpc/pr105991.c: New test case.

2 years agolibgomp: Fix up target-31.c test [PR106045]
Jakub Jelinek [Tue, 21 Jun 2022 15:51:08 +0000 (17:51 +0200)]
libgomp: Fix up target-31.c test [PR106045]

The i variable is used inside of the parallel in:
      #pragma omp simd safelen(32) private (v)
      for (i = 0; i < 64; i++)
        {
          v = 3 * i;
          ll[i] = u1 + v * u2[0] + u2[1] + x + y[0] + y[1] + v + h[0] + u3[i];
        }
where i is predetermined linear (so while inside of the body
it is safe, private per SIMD lane var) the final value is written to
the shared variable, and in:
      for (i = 0; i < 64; i++)
        if (ll[i] != u1 + 3 * i * u2[0] + u2[1] + x + y[0] + y[1] + 3 * i + 13 + 14 + i)
          #pragma omp atomic write
            err = 1;
which is a normal loop and so it isn't in any way privatized there.
So we have a data race, fixed by adding private (i) clause to the
parallel.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>
    Paul Iannetta  <piannetta@kalrayinc.com>

PR libgomp/106045
* testsuite/libgomp.c/target-31.c: Add private (i) clause.

2 years agolibgo: #include <sys/types.h> when checking for loff_t
Ian Lance Taylor [Sun, 19 Jun 2022 01:19:28 +0000 (18:19 -0700)]
libgo: #include <sys/types.h> when checking for loff_t

PR go/106033

Fixes golang/go#53469

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214

2 years agodoc: Document module language-linkage supported
Nathan Sidwell [Tue, 21 Jun 2022 13:23:11 +0000 (06:23 -0700)]
doc: Document module language-linkage supported

I missed we documented this as unimplemented, when I implemented it.

gcc/
* doc/invoke.texi (C++ Modules): Remove language-linkage
as missing feature.

2 years agomatch.pd: Remove "+ 0x80000000" in int comparisons [PR94899]
Arjun Shankar [Tue, 21 Jun 2022 10:12:11 +0000 (12:12 +0200)]
match.pd: Remove "+ 0x80000000" in int comparisons [PR94899]

Expressions of the form "X + CST < Y + CST" where:

* CST is an unsigned integer constant with only the MSB set, and
* X and Y's types have integer conversion ranks <= CST's

can be simplified to "(signed) X < (signed) Y".

This is because, assuming a 32-bit signed numbers,
(unsigned) INT_MIN + 0x80000000 is 0, and
(unsigned) INT_MAX + 0x80000000 is UINT_MAX.

i.e. the result increases monotonically with signed input.

This means:
((signed) X < (signed) Y) iff (X + 0x80000000 < Y + 0x80000000)

gcc/
PR tree-optimization/94899
* match.pd (X + C < Y + C -> (signed) X < (signed) Y, if C is
0x80000000): New simplification.
gcc/testsuite/
* gcc.dg/pr94899.c: New test.

2 years agoifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]
Jakub Jelinek [Tue, 21 Jun 2022 09:40:16 +0000 (11:40 +0200)]
ifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]

noce_try_sign_mask as documented will optimize
  if (c < 0)
    x = t;
  else
    x = 0;
into x = (c >> bitsm1) & t;
The optimization is done if either t is unconditional
(e.g. for
  x = t;
  if (c >= 0)
    x = 0;
) or if it is cheap.  We already check that t doesn't have side-effects,
but if t is conditional, we need to punt also if it may trap or fault,
as we make it unconditional.

I've briefly skimmed other noce_try* optimizations and didn't find one that
would suffer from the same problem.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/106032
* ifcvt.cc (noce_try_sign_mask): Punt if !t_unconditional, and
t may_trap_or_fault_p, even if it is cheap.

* gcc.c-torture/execute/pr106032.c: New test.

2 years agoexpand: Fix up expand_cond_expr_using_cmove [PR106030]
Jakub Jelinek [Tue, 21 Jun 2022 09:38:59 +0000 (11:38 +0200)]
expand: Fix up expand_cond_expr_using_cmove [PR106030]

If expand_cond_expr_using_cmove can't find a cmove optab for a particular
mode, it tries to promote the mode and perform the cmove in the promoted
mode.

The testcase in the patch ICEs on arm because in that case we pass temp which
has the promoted mode (SImode) as target to expand_operands where the
operands have the non-promoted mode (QImode).
Later on the function uses paradoxical subregs:
  if (GET_MODE (op1) != mode)
    op1 = gen_lowpart (mode, op1);

  if (GET_MODE (op2) != mode)
    op2 = gen_lowpart (mode, op2);
to change the operand modes.

The following patch fixes it by passing NULL_RTX as target if it has
promoted mode.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106030
* expr.cc (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
temp to expand_operands if mode has been promoted.

* gcc.c-torture/compile/pr106030.c: New test.

2 years agoif-to-switch: Don't skip the first condition bb when find_conditions in if-to-switch...
Xionghu Luo [Thu, 9 Jun 2022 07:46:30 +0000 (15:46 +0800)]
if-to-switch: Don't skip the first condition bb when find_conditions in if-to-switch [PR105740]

The if condition is at last of first bb, so side effect statement in first BB
doesn't matter, then the first if condition could also be folded to switch
table.

gcc/ChangeLog:

PR target/105740
* gimple-if-to-switch.cc (find_conditions): Don't skip the first
condition bb.

gcc/testsuite/ChangeLog:

PR target/105740
* gcc.dg/tree-ssa/if-to-switch-11.c: New test.

Signed-off-by: Xionghu Luo <xionghuluo@tencent.com>
2 years agotree-object-size: Don't let error_mark_node escape for ADDR_EXPR [PR105736]
Siddhesh Poyarekar [Tue, 21 Jun 2022 06:45:07 +0000 (12:15 +0530)]
tree-object-size: Don't let error_mark_node escape for ADDR_EXPR [PR105736]

The addr_expr computation does not check for error_mark_node before
returning the size expression.  This used to work in the constant case
because the conversion to uhwi would end up causing it to return
size_unknown, but that won't work for the dynamic case.

Modify the control flow to explicitly return size_unknown if the offset
computation returns an error_mark_node.

gcc/ChangeLog:

PR tree-optimization/105736
* tree-object-size.cc (addr_object_size): Return size_unknown
when object offset computation returns an error.

gcc/testsuite/ChangeLog:

PR tree-optimization/105736
* gcc.dg/builtin-dynamic-object-size-0.c (TV4): New struct.
(val3): New variable.
(test_pr105736): New test.
(main): Call it.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2 years agoDaily bump.
GCC Administrator [Tue, 21 Jun 2022 00:16:27 +0000 (00:16 +0000)]
Daily bump.

2 years agotestsuite, asan: Avoid color in asan test output.
Iain Sandoe [Sun, 19 Jun 2022 09:31:01 +0000 (10:31 +0100)]
testsuite, asan: Avoid color in asan test output.

The presence of the color markers in the some of the asan tests
appears to confuse the dg-output matching (possibly a platform
TCL or termios bug) on some Darwin platforms.

Since the color is not being tested, switch it off (makes the log
files easier to read too).  This fixes a large number of spurious
test fails on AVX512 Darwin19.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* lib/asan-dg.exp: Do not apply color to asan output when
under test.

2 years agoi386: Disallow sibcall for calling ifunc functions with PIC register
H.J. Lu [Tue, 14 Jun 2022 15:20:16 +0000 (08:20 -0700)]
i386: Disallow sibcall for calling ifunc functions with PIC register

Disallow siball when calling ifunc functions with PIC register so that
PIC register can be restored.

gcc/

PR target/105960
* config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
false if PIC register is used when calling ifunc functions.

gcc/testsuite/

PR target/105960
* gcc.target/i386/pr105960.c: New test.

2 years agotestsuite, Darwin: Skip an unsupported test.
Iain Sandoe [Sun, 19 Jun 2022 09:28:05 +0000 (10:28 +0100)]
testsuite, Darwin: Skip an unsupported test.

Darwin does not support patchable function entries, skip the test
there.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr105169_a.C: Skip the test on Darwin.
* g++.dg/modules/pr105169_b.C: Likewise.

2 years agotestsuite, Darwin: Allow for two CTOR bodies in array61 test.
Iain Sandoe [Sun, 19 Jun 2022 09:21:28 +0000 (10:21 +0100)]
testsuite, Darwin: Allow for two CTOR bodies in array61 test.

For targets without alias support, we emit two essentially identical function
bodies into the gimple (complete and base CTORs). So this test needs to allow
for that when the target does not support aliases.  The target support alias
test does not seem to be usable in the context of a single scan-tree-dump so
the fix here uses the target designation.

Note that the array has 10 elements, so that if the test were failing (because
we were emitting 10 inits instead of a loop) the count would be expected to
exceed 2, on Darwin and 1 where there's alias support.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* g++.dg/init/array61.C: Allow for two CTOR bodies on Darwin, where
aliases are not currently supported.

2 years agoarm: more testsutie fallout for mve move-immediate changes
Richard Earnshaw [Mon, 20 Jun 2022 15:18:36 +0000 (16:18 +0100)]
arm: more testsutie fallout for mve move-immediate changes

Unfortunately, there is more fall-out in the testsuite for my changes
to use MVE move-immediate operations instead of literal pool loads.
Fixed as follows:

gcc/testsuite/ChangeLog:
* gcc.target/arm/simd/mve-vcmp-f32-2.c: Adjust expected output.
* gcc.target/arm/simd/pr100757.c: Likewise.
* gcc.target/arm/simd/pr100757-2.c: Likewise.
* gcc.target/arm/simd/pr100757-3.c: Likewise.
* gcc.target/arm/simd/pr100757-4.c: Likewise.

2 years agotestsuite: Add a missing USER_LABEL_PREFIX to a regex.
Iain Sandoe [Sun, 19 Jun 2022 09:16:26 +0000 (10:16 +0100)]
testsuite: Add a missing USER_LABEL_PREFIX to a regex.

Fixes this test on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* g++.dg/modules/init-2_b.C: Add a missing USER_LABEL_PREFIX
to a regex.

2 years agotestsuite: Require init_priority target support in a test.
Iain Sandoe [Sun, 19 Jun 2022 09:12:47 +0000 (10:12 +0100)]
testsuite: Require init_priority target support in a test.

The attr-cdtor-1 test fails on targets without init priority since the
diagnostic emitted concerns the absence of support.  Disable the test
on such targets.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* c-c++-common/attr-cdtor-1.c: Requite init_priority support.

2 years agomiddle-end/106027 - fix types in needle folding
Richard Biener [Mon, 20 Jun 2022 11:40:50 +0000 (13:40 +0200)]
middle-end/106027 - fix types in needle folding

The fold_to_nonsharp_ineq_using_bound folding ends up creating invalid
typed IL which confuses later foldings.  The following fixes that.

2022-06-20  Richard Biener  <rguenther@suse.de>

PR middle-end/106027
* fold-const.cc (fold_to_nonsharp_ineq_using_bound): Use the
type of the prevailing comparison for the new comparison type.
(fold_binary_loc): Use proper types for the A < X && A + 1 > Y
to A < X && A >= Y folding.

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

2 years agovect: Respect slp decision when applying suggested uf [PR105940]
Kewen Lin [Mon, 20 Jun 2022 12:44:21 +0000 (07:44 -0500)]
vect: Respect slp decision when applying suggested uf [PR105940]

This follows Richi's suggestion in PR105940, it aims to avoid
inconsistent slp decision between when the suggested unroll
factor is worked out and when the suggested unroll factor is
applied.

If the previous slp decision is true when the suggested unroll
factor is worked out, when we are applying unroll factor we
don't need to start over with slp off if the analysis with slp
on fails.  On the other hand, if the previous slp decision is
false when the suggested unroll factor is worked out, when we
are applying unroll factor we can skip the slp handlings.

Function vect_is_simple_reduction saves reduction chains for
subsequent slp analyses, we have to disable this early otherwise
there is an ICE in vectorizable_reduction for below:

  if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
    gcc_assert (slp_node
&& REDUC_GROUP_FIRST_ELEMENT (stmt_info)
   == stmt_info);

PR tree-optimization/105940

gcc/ChangeLog:

* tree-vect-loop.cc (vect_analyze_loop_2): Add new parameter
slp_done_for_suggested_uf and adjust with it accordingly.
(vect_analyze_loop_1): Add new variable slp_done_for_suggested_uf,
pass it down to vect_analyze_loop_2 for the initial analysis and
applying suggested unroll factor.
(vect_is_simple_reduction): Add parameter slp and adjust with it.
(vect_analyze_scalar_cycles_1): Add parameter slp and pass down.
(vect_analyze_scalar_cycles): Likewise.

2 years agolto-plugin: support LDPT_GET_SYMBOLS_V3
Martin Liska [Mon, 14 Feb 2022 10:31:43 +0000 (11:31 +0100)]
lto-plugin: support LDPT_GET_SYMBOLS_V3

That supports skipping of an object file (LDPS_NO_SYMS).

lto-plugin/ChangeLog:

* lto-plugin.c (struct plugin_file_info): Add skip_file flag.
(write_resolution): Write resolution only if get_symbols != LDPS_NO_SYMS.
(all_symbols_read_handler): Ignore file if skip_file is true.
(onload): Handle LDPT_GET_SYMBOLS_V3.

2 years agoAdd operators / and * for profile_{count,probability}.
Martin Liska [Tue, 25 Jan 2022 18:16:06 +0000 (19:16 +0100)]
Add operators / and * for profile_{count,probability}.

gcc/ChangeLog:

* bb-reorder.cc (find_traces_1_round): Add operators / and * and
use them.
(better_edge_p): Likewise.
* cfgloop.cc (find_subloop_latch_edge_by_profile): Likewise.
* cfgloopmanip.cc (scale_loop_profile): Likewise.
* cfgrtl.cc (force_nonfallthru_and_redirect): Likewise.
* cgraph.cc (cgraph_edge::maybe_hot_p): Likewise.
* config/sh/sh.cc (expand_cbranchdi4): Likewise.
* dojump.cc (do_compare_rtx_and_jump): Likewise.
* final.cc (compute_alignments): Likewise.
* ipa-cp.cc (update_counts_for_self_gen_clones): Likewise.
(decide_about_value): Likewise.
* ipa-inline-analysis.cc (do_estimate_edge_time): Likewise.
* loop-unroll.cc (unroll_loop_runtime_iterations): Likewise.
* modulo-sched.cc (sms_schedule): Likewise.
* omp-expand.cc (extract_omp_for_update_vars): Likewise.
(expand_omp_ordered_sink): Likewise.
(expand_omp_for_ordered_loops): Likewise.
(expand_omp_for_static_nochunk): Likewise.
* predict.cc (maybe_hot_count_p): Likewise.
(probably_never_executed): Likewise.
(set_even_probabilities): Likewise.
(handle_missing_profiles): Likewise.
(expensive_function_p): Likewise.
* profile-count.h: Likewise.
* profile.cc (compute_branch_probabilities): Likewise.
* stmt.cc (emit_case_dispatch_table): Likewise.
* symtab-thunks.cc (expand_thunk): Likewise.
* tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop): Likewise.
* tree-ssa-sink.cc (select_best_block): Likewise.
* tree-switch-conversion.cc (switch_decision_tree::analyze_switch_statement): Likewise.
(switch_decision_tree::balance_case_nodes): Likewise.
(switch_decision_tree::emit_case_nodes): Likewise.
* tree-vect-loop.cc (scale_profile_for_vect_loop): Likewise.

2 years agoRISC-V: Fix a bug that is the CMO builtins are missing parameter
yulong [Wed, 8 Jun 2022 02:19:21 +0000 (10:19 +0800)]
RISC-V: Fix a bug that is the CMO builtins are missing parameter

We changed builtins format about zicbom and zicboz subextensions and modified test cases.

diff with the previous version:
1.We modified the FUNCTION_TYPE from RISCV_VOID_FTYPE_SI/DI to RISCV_VOID_FTYPE_VOID_PTR.
2.We added a new RISCV_ATYPE_VOID_PTR in riscv-builtins.cc and a new DEF_RISCV_FTYPE (1, (VOID, VOID_PTR)) in riscv-ftypes.def.
3.We deleted DEF_RISCV_FTYPE (1, (VOID, SI/DI)).
4.We modified the input parameters of the test cases.

Thanks, Simon and Kito.

gcc/ChangeLog:

* config/riscv/riscv-builtins.cc (RISCV_ATYPE_VOID_PTR): New.
* config/riscv/riscv-cmo.def (RISCV_BUILTIN): Changed the FUNCTION_TYPE
of RISCV_BUILTIN.
* config/riscv/riscv-ftypes.def (0): Remove unused.
(1): New.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/cmo-zicbom-1.c: modified the input parameters.
* gcc.target/riscv/cmo-zicbom-2.c: modified the input parameters.
* gcc.target/riscv/cmo-zicboz-1.c: modified the input parameters.
* gcc.target/riscv/cmo-zicboz-2.c: modified the input parameters.

2 years agoDaily bump.
GCC Administrator [Mon, 20 Jun 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoxtensa: Fix RTL insn cost estimation about relaxed MOVI instructions
Takayuki 'January June' Suwa [Sun, 19 Jun 2022 19:13:56 +0000 (04:13 +0900)]
xtensa: Fix RTL insn cost estimation about relaxed MOVI instructions

These instructions will all be converted to L32R ones with litpool entries
by the assembler.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_is_insn_L32R_p):
Consider relaxed MOVI instructions as L32R.

2 years agoxtensa: Apply a few minor fixes
Takayuki 'January June' Suwa [Sun, 19 Jun 2022 19:12:48 +0000 (04:12 +0900)]
xtensa: Apply a few minor fixes

No functional changes.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_emit_move_sequence):
Use can_create_pseudo_p(), instead of using individual
reload_in_progress and reload_completed.
(xtensa_expand_block_set_small_loop): Use xtensa_simm8x256(),
the existing predicate function.
(xtensa_is_insn_L32R_p, gen_int_relational, xtensa_emit_sibcall):
Use the standard RTX code predicate macros such as MEM_P,
SYMBOL_REF_P and/or CONST_INT_P.
* config/xtensa/xtensa.md: Avoid using numeric literals to determine
if callee-saved register, at the split patterns for indirect sibcall
fixups.

2 years agoDaily bump.
GCC Administrator [Sun, 19 Jun 2022 00:16:23 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: check POS and LEN arguments simplifying bit intrinsics [PR105986]
Harald Anlauf [Wed, 15 Jun 2022 20:20:09 +0000 (22:20 +0200)]
Fortran: check POS and LEN arguments simplifying bit intrinsics [PR105986]

gcc/fortran/ChangeLog:

PR fortran/105986
* simplify.cc (gfc_simplify_btest): Add check for POS argument.
(gfc_simplify_ibclr): Add check for POS argument.
(gfc_simplify_ibits): Add check for POS and LEN arguments.
(gfc_simplify_ibset): Add check for POS argument.

gcc/testsuite/ChangeLog:

PR fortran/105986
* gfortran.dg/check_bits_3.f90: New test.

2 years agoubsan: Add -fsanitize-trap= support
Jakub Jelinek [Sat, 18 Jun 2022 09:09:48 +0000 (11:09 +0200)]
ubsan: Add -fsanitize-trap= support

On Thu, Jun 16, 2022 at 09:32:02PM +0100, Jonathan Wakely wrote:
> It looks like clang has addressed this deficiency now:
>
> https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#usage

Thanks, that is roughly what I'd implement anyway and apparently they have
it already since 2015, we've added the -fsanitize-undefined-trap-on-error
support back in 2014 and didn't change it since then.

As a small divergence from clang, I chose -fsanitize-undefined-trap-on-error
to be a (deprecated) alias for -fsanitize-trap aka -fsanitize-trap=all
rather thn -fsanitize-trap=undefined which seems to be what clang does,
because for a deprecated option it is IMHO more important backwards
compatibility with what gcc did over the past 8 years rather than clang
compatibility.
Some sanitizers (e.g. asan, lsan, tsan) don't support traps,
-fsanitize-trap=address etc. will be rejected (if enabled at the end of
command line), -fno-sanitize-trap= can be specified even for them.
This is similar behavior to -fsanitize-recover=.
One complication is vptr sanitization, which can't easily trap,
as the whole slow path of the checking is inside of libubsan.
Previously, -fsanitize=vptr -fsanitize-undefined-trap-on-error
silently ignored vptr sanitization.
This patch similarly to what clang does will accept
-fsanitize-trap=all or -fsanitize-trap=undefined which enable
the vptr bit as trapping and again that causes silent disabling
of vptr sanitization, while -fsanitize-trap=vptr is rejected
(already during option processing).

2022-06-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* common.opt (flag_sanitize_trap): New variable.
(fsanitize-trap=, fsanitize-trap): New options.
(fsanitize-undefined-trap-on-error): Change into deprecated alias
for -fsanitize-trap=all.
* opts.h (struct sanitizer_opts_s): Add can_trap member.
* opts.cc (finish_options): Complain about unsupported
-fsanitize-trap= options.
(sanitizer_opts): Add can_trap values to all entries.
(get_closest_sanitizer_option): Ignore -fsanitize-trap=
options which have can_trap false.
(parse_sanitizer_options): Add support for -fsanitize-trap=.
For -fsanitize-trap=all, enable
SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT.  Disallow
-fsanitize-trap=vptr here.
(common_handle_option): Handle OPT_fsanitize_trap_ and
OPT_fsanitize_trap.
* sanopt.cc (maybe_optimize_ubsan_null_ifn): Check
flag_sanitize_trap & SANITIZE_{NULL,ALIGNMENT} instead of
flag_sanitize_undefined_trap_on_error.
* gcc.cc (sanitize_spec_function): Use
flag_sanitize & ~flag_sanitize_trap instead of flag_sanitize
and drop use of flag_sanitize_undefined_trap_on_error in
"undefined" handling.
* ubsan.cc (ubsan_instrument_unreachable): Use
flag_sanitize_trap & SANITIZE_??? instead of
flag_sanitize_undefined_trap_on_error.
(ubsan_expand_bounds_ifn, ubsan_expand_null_ifn,
ubsan_expand_objsize_ifn, ubsan_expand_ptr_ifn,
ubsan_build_overflow_builtin, instrument_bool_enum_load,
ubsan_instrument_float_cast, instrument_nonnull_arg,
instrument_nonnull_return, instrument_builtin): Likewise.
* doc/invoke.texi (-fsanitize-trap=, -fsanitize-trap): Document.
(-fsanitize-undefined-trap-on-error): Document as deprecated
alias of -fsanitize-trap.
gcc/c-family/
* c-ubsan.cc (ubsan_instrument_division, ubsan_instrument_shift):
Use flag_sanitize_trap & SANITIZE_??? instead of
flag_sanitize_undefined_trap_on_error.  If 2 sanitizers are involved
and flag_sanitize_trap differs for them, emit __builtin_trap only
for the comparison where trap is requested.
(ubsan_instrument_vla, ubsan_instrument_return): Use
lag_sanitize_trap & SANITIZE_??? instead of
flag_sanitize_undefined_trap_on_error.
gcc/cp/
* cp-ubsan.cc (cp_ubsan_instrument_vptr_p): Use
flag_sanitize_trap & SANITIZE_VPTR instead of
flag_sanitize_undefined_trap_on_error.
gcc/testsuite/
* c-c++-common/ubsan/nonnull-4.c: Use -fsanitize-trap=all
instead of -fsanitize-undefined-trap-on-error.
* c-c++-common/ubsan/div-by-zero-4.c: Use
-fsanitize-trap=signed-integer-overflow instead of
-fsanitize-undefined-trap-on-error.
* c-c++-common/ubsan/overflow-add-4.c: Use -fsanitize-trap=undefined
instead of -fsanitize-undefined-trap-on-error.
* c-c++-common/ubsan/pr56956.c: Likewise.
* c-c++-common/ubsan/pr68142.c: Likewise.
* c-c++-common/ubsan/pr80932.c: Use
-fno-sanitize-trap=all -fsanitize-trap=shift,undefined
instead of -fsanitize-undefined-trap-on-error.
* c-c++-common/ubsan/align-8.c: Use -fsanitize-trap=alignment
instead of -fsanitize-undefined-trap-on-error.

2 years agovarasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]
Jakub Jelinek [Sat, 18 Jun 2022 09:07:13 +0000 (11:07 +0200)]
varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]

The following testcase ICEs because there is NON_LVALUE_EXPR (location
wrapper) around a VAR_DECL and has TYPE_MODE V2SImode and
SCALAR_INT_TYPE_MODE on that ICEs.  Or for -m32 -march=i386 TYPE_MODE
is DImode, but SCALAR_INT_TYPE_MODE still uses the raw V2SImode and ICEs
too.

2022-06-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/105998
* varasm.cc (narrowing_initializer_constant_valid_p): Check
SCALAR_INT_MODE_P instead of INTEGRAL_MODE_P, also break on
! INTEGRAL_TYPE_P and do the same check also on op{0,1}'s type.

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

2 years agoPR tree-optimization/105835: Two narrowing patterns for match.pd.
Roger Sayle [Sat, 18 Jun 2022 08:06:20 +0000 (09:06 +0100)]
PR tree-optimization/105835: Two narrowing patterns for match.pd.

This patch resolves PR tree-optimization/105835, which is a code quality
(dead code elimination) regression at -O1 triggered/exposed by a recent
change to canonicalize X&-Y as X*Y.  The new (shorter) form exposes some
missed optimization opportunities that can be handled by adding some
extra simplifications to match.pd.

One transformation is to simplify "(short)(x ? 65535 : 0)" into the
equivalent "x ? -1 : 0", or more accurately x ? (short)-1 : (short)0",
as INTEGER_CSTs record their type, and integer conversions can be
pushed inside COND_EXPRs reducing the number of gimple statements.

The other transformation is that (short)(X * 65535), where X is [0,1],
into the equivalent (short)X * -1, (or again (short)-1 where tree's
INTEGER_CSTs encode their type).  This is valid because multiplications
where one operand is [0,1] are guaranteed not to overflow, and hence
integer conversions can also be pushed inside these multiplications.

These narrowing conversion optimizations can be identified by range
analyses, such as EVRP, but these are only performed at -O2 and above,
which is why this regression is only visible with -O1.

2022-06-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR tree-optimization/105835
* match.pd (convert (mult zero_one_valued_p@1 INTEGER_CST@2)):
Narrow integer multiplication by a zero_one_valued_p operand.
(convert (cond @1 INTEGER_CST@2 INTEGER_CST@3)): Push integer
conversions inside COND_EXPR where both data operands are
integer constants.

gcc/testsuite/ChangeLog
PR tree-optimization/105835
* gcc.dg/pr105835.c: New test case.

2 years agoxtensa: Defer storing integer constants into litpool until reload
Takayuki 'January June' Suwa [Fri, 17 Jun 2022 13:47:49 +0000 (22:47 +0900)]
xtensa: Defer storing integer constants into litpool until reload

Storing integer constants into litpool in the early stage of compilation
hinders some integer optimizations.  In fact, such integer constants are
not subject to the constant folding process.

For example:

    extern unsigned short value;
    extern void foo(void);
    void test(void) {
      if (value == 30001)
        foo();
    }

.literal_position
.literal .LC0, value
.literal .LC1, 30001
    test:
l32r a3, .LC0
l32r a2, .LC1
l16ui a3, a3, 0
extui a2, a2, 0, 16  // runtime zero-extension despite constant
bne a3, a2, .L1
j.l foo, a9
    .L1:
ret.n

This patch defers the placement of integer constants into litpool until
the start of reload:

.literal_position
.literal .LC0, value
.literal .LC1, 30001
    test:
l32r a3, .LC0
l32r a2, .LC1
l16ui a3, a3, 0
bne a3, a2, .L1
j.l foo, a9
    .L1:
ret.n

gcc/ChangeLog:

* config/xtensa/constraints.md (Y):
Change to include integer constants until reload begins.
* config/xtensa/predicates.md (move_operand): Ditto.
* config/xtensa/xtensa.cc (xtensa_emit_move_sequence):
Change to allow storing integer constants into litpool only after
reload begins.

2 years agoDaily bump.
GCC Administrator [Sat, 18 Jun 2022 00:16:19 +0000 (00:16 +0000)]
Daily bump.

2 years agolibgo: permit loff_t and off_t to be macros
Ian Lance Taylor [Tue, 14 Jun 2022 18:33:42 +0000 (11:33 -0700)]
libgo: permit loff_t and off_t to be macros

They are macros in musl libc, rather than typedefs, and -fgo-dump-spec
doesn't handle that case.

Based on patch by Sören Tempel.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/412075

2 years agoc++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shuffl...
Jakub Jelinek [Fri, 17 Jun 2022 15:40:49 +0000 (17:40 +0200)]
c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]

In this case the STATIC_CAST_EXPR expressions in the call aren't
type nor value dependent, but maybe_constant_value still ICEs on those
when processing_template_decl.  Calling fold_non_dependent_expr on it
instead fixes the ICE and folds them to INTEGER_CSTs.

2022-06-17  Jakub Jelinek  <jakub@redhat.com>

PR c++/106001
* typeck.cc (build_x_shufflevector): Use fold_non_dependent_expr
instead of maybe_constant_value.

* g++.dg/ext/builtin-shufflevector-4.C: New test.

2 years agoalpha: Introduce target specific store_data_bypass_p function [PR105209]
Uros Bizjak [Fri, 17 Jun 2022 15:19:44 +0000 (17:19 +0200)]
alpha: Introduce target specific store_data_bypass_p function [PR105209]

This patch introduces alpha-specific version of store_data_bypass_p that
ignores TRAP_IF that would result in assertion failure (and internal
compiler error) in the generic store_data_bypass_p function.

While at it, also remove ev4_ist_c reservation, store_data_bypass_p
can handle the patterns with multiple sets since some time ago.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/105209
* config/alpha/alpha-protos.h (alpha_store_data_bypass_p): New.
* config/alpha/alpha.cc (alpha_store_data_bypass_p): New function.
(alpha_store_data_bypass_p_1): Ditto.
* config/alpha/ev4.md: Use alpha_store_data_bypass_p instead
of generic store_data_bypass_p.
(ev4_ist_c): Remove insn reservation.

gcc/testsuite/ChangeLog:

PR target/105209
* gcc.target/alpha/pr105209.c: New test.

2 years agoi386: Fix assert in ix86_function_arg [PR105970]
Uros Bizjak [Fri, 17 Jun 2022 15:01:31 +0000 (17:01 +0200)]
i386: Fix assert in ix86_function_arg [PR105970]

The mode of pointer argument should equal ptr_mode, not Pmode.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/105970
* config/i386/i386.cc (ix86_function_arg): Assert that
the mode of pointer argumet is equal to ptr_mode, not Pmode.

gcc/testsuite/ChangeLog:

PR target/105970
* gcc.target/i386/pr105970.c: New test.

2 years agoi386: Fix VPMOV splitter [PR105993]
Uros Bizjak [Fri, 17 Jun 2022 14:22:20 +0000 (16:22 +0200)]
i386: Fix VPMOV splitter [PR105993]

REGNO should not be used with register_operand before reload because
subregs of registers or even subregs of memory match the predicate.
The build with RTL checking enabled does not tolerate REGNO with
non-reg operand.
The patch splits the splitter into two related splitters and uses
(match_dup ...) RTXes instead of REGNO comparisons.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/105993
* config/i386/sse.md (vpmov splitter): Use (match_dup ...)
instead of REGNO comparisons in combine splitter.

gcc/testsuite/ChangeLog:

PR target/105993
* gcc.target/i386/pr105993.c: New test.

2 years agors6000: Fix some error messages for invalid conversions
Segher Boessenkool [Fri, 17 Jun 2022 14:07:37 +0000 (14:07 +0000)]
rs6000: Fix some error messages for invalid conversions

"* something" isn't a type.  "something *" is.

2022-06-17  Segher Boessenkool  <segher@kernel.crashing.org>

* config/rs6000/rs6000.cc (rs6000_invalid_conversion): Correct some
types.

2 years agoRISC-V: Supress warning for comparison of integer expressions of different signedness
Kito Cheng [Fri, 17 Jun 2022 13:57:35 +0000 (21:57 +0800)]
RISC-V: Supress warning for comparison of integer expressions of different signedness

gcc/ChangeLog:

* config/riscv/bitmanip.md: Supress warning.

2 years agoarm: fix checking ICE in arm_print_operand [PR106004]
Richard Earnshaw [Fri, 17 Jun 2022 13:25:51 +0000 (14:25 +0100)]
arm: fix checking ICE in arm_print_operand [PR106004]

Sigh, another instance where I incorrectly used XUINT instead of
UINTVAL.

I've also made the code here a little more robust (although I think
this case can't in fact be reached) if the 32-bit clear mask includes
bit 31.  This case, if reached, would print out an out-of-range value
based on the size of the compiler's HOST_WIDE_INT type due to
sign-extension.  We avoid this by masking the value after inversion.

gcc/ChangeLog:
PR target/106004
* config/arm/arm.cc (arm_print_operand, case 'V'): Use UINTVAL.
Clear bits in the mask above bit 31.

2 years agolibstdc++: Add missing #include <string> to new test
Jonathan Wakely [Fri, 17 Jun 2022 12:29:05 +0000 (13:29 +0100)]
libstdc++: Add missing #include <string> to new test

Somehow I pushed a different version of this test to the one I actually
tested.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/cons/char/105995.cc: Add
missing #include.

2 years agodocs: add missing table header
Martin Liska [Fri, 17 Jun 2022 11:33:35 +0000 (13:33 +0200)]
docs: add missing table header

libgomp/ChangeLog:

* libgomp.texi: Add table header for new features of
OpenMP 5.2.