platform/upstream/gcc.git
2 years agoc++: ambiguous call not diagnosed after DR2352 [PR97296]
Marek Polacek [Tue, 12 Apr 2022 21:30:30 +0000 (17:30 -0400)]
c++: ambiguous call not diagnosed after DR2352 [PR97296]

DR 2352 changed the definitions of reference-related (so that it uses
"similar type" instead of "same type") and of reference-compatible (use
a standard conversion sequence).  That means that reference-related is
now more broad, which means that we will be binding more things directly.

The original patch for DR 2352 caused some problems, which were fixed in
r276251 by creating a "fake" ck_qual in direct_reference_binding, so
that in

  void f(int *); // #1
  void f(const int * const &); // #2
  int *x;
  int main()
  {
    f(x); // call #1
  }

we call #1.  The extra ck_qual in #2 causes compare_ics to select #1,
which is a better match for "int *" because then we don't have to do
a qualification conversion.

Let's turn to the problem in this PR.  We have

  void f(const int * const &); // #1
  void f(const int *); // #2
  int *x;
  int main()
  {
    f(x);
  }

We arrive in compare_ics to decide which one is better. The ICS for #1
looks like

    ck_ref_bind      <-    ck_qual         <-   ck_identity
  const int *const &     const int *const         int *

and the ICS for #2 is

    ck_qual     <-  ck_rvalue   <-  ck_identity
  const int *          int *           int *

We strip the reference and then comp_cv_qual_signature when comparing two
ck_quals sees that "const int *" is a proper subset of "const int *const"
and we return -1.  But that's wrong; presumably the top-level "const"
should be ignored and the call should be ambiguous.  This patch adjust
the type of the "fake" ck_qual so that this problem doesn't arise.

PR c++/97296

gcc/cp/ChangeLog:

* call.cc (direct_reference_binding): strip_top_quals when creating
a ck_qual.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/ref-bind4.C: Add dg-error.
* g++.dg/cpp0x/ref-bind8.C: New test.

2 years agomiddle-end/105259 - adjust gcc.target/i386/auto-init-4.c
Richard Biener [Wed, 13 Apr 2022 08:41:41 +0000 (10:41 +0200)]
middle-end/105259 - adjust gcc.target/i386/auto-init-4.c

This adjusts the FAILing testcase to only check for the pieces
that work.  The bug tracks improving pattern-init for long double.

2022-04-13  Richard Biener  <rguenther@suse.de>

PR middle-end/105259
* gcc.target/i386/auto-init-4.c: Adjust.

2 years agoi386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069]
Hongyu Wang [Wed, 13 Apr 2022 06:51:36 +0000 (14:51 +0800)]
i386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069]

For -mrelax-cmpxchg-loop which relaxes atomic_fetch_<logic> loops,
there is a missing set to %eax when compare fails, which would result
in infinite loop in some benchmark. Add set to %eax to avoid it.

gcc/ChangeLog:

PR target/103069
* config/i386/i386-expand.cc (ix86_expand_cmpxchg_loop):
  Add missing set to target_val at pause label.

2 years agoattribs: Restrict decl_attributes DECL_FUNCTION_SPECIFIC_TARGET changes to targets...
Jakub Jelinek [Wed, 13 Apr 2022 08:12:56 +0000 (10:12 +0200)]
attribs: Restrict decl_attributes DECL_FUNCTION_SPECIFIC_TARGET changes to targets that care about target attributes/pragmas [PR105234]

The following code is rejected e.g. on mips64el-linux (but I think many
other targets which don't support target attribute or pragma).
The problem is that the change to decl_attributes below is done
unconditionally and with just #pragma GCC push_options/pop_options pair
we have target_option_default_node NULL, but after popping options
target_option_current_node becomes non-NULL and this decl_attribute
spot fills in DECL_FUNCTION_SPECIFIC_TARGET of a subset of a functions.
Those appearing before push_options/pop_options will have it NULL and
as target_option_default_node is also NULL on those targets, the default
can_inline_p will refuse to inline any functions defined with NULL
DECL_FUNCTION_SPECIFIC_TARGET into any function with non-NULL
DECL_FUNCTION_SPECIFIC_TARGET (even when nothing in the options really
changed).

The following patch restricts that snippet to targets that care (initialize
target_option_default_node to non-NULL to the command line options early)
which include all targets that actually implement target attribute and/or
pragma.

2022-04-13  Jakub Jelinek  <jakub@redhat.com>

PR target/105234
* attribs.cc (decl_attributes): Don't set
DECL_FUNCTION_SPECIFIC_TARGET if target_option_default_node is
NULL.

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

2 years agotree-optimization/105250 - adjust fold_convertible_p PR105140 fix
Richard Biener [Wed, 13 Apr 2022 06:52:57 +0000 (08:52 +0200)]
tree-optimization/105250 - adjust fold_convertible_p PR105140 fix

The following reverts the original PR105140 fix and goes for instead
applying the additional fold_convert constraint for VECTOR_TYPE
conversions also to fold_convertible_p.  I did not try sanitizing
all of this at this point.

2022-04-13  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105250
* fold-const.cc (fold_convertible_p): Revert
r12-7979-geaaf77dd85c333, instead check for size equality
of the vector types involved.

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

2 years agoRevert "tree-optimization/104912 - ensure cost model is checked first"
Richard Biener [Wed, 13 Apr 2022 07:54:58 +0000 (09:54 +0200)]
Revert "tree-optimization/104912 - ensure cost model is checked first"

This reverts commit ac8340ee4d1e65f3fd41c547b16895875f4aefa7.

2 years agotree-optimization/104912 - ensure cost model is checked first
Richard Biener [Mon, 21 Mar 2022 13:08:25 +0000 (14:08 +0100)]
tree-optimization/104912 - ensure cost model is checked first

The following makes sure that when we build the versioning condition
for vectorization including the cost model check, we check for the
cost model and branch over other versioning checks.  That is what
the cost modeling assumes, since the cost model check is the only
one accounted for in the scalar outside cost.  Currently we emit
all checks as straight-line code combined with bitwise ops which
can result in surprising ordering of checks in the final assembly.

Since loop_version accepts only a single versioning condition
the splitting is done after the fact.

The result is a 1.5% speedup of 416.gamess on x86_64 when compiling
with -Ofast and tuning for generic or skylake.  That's not enough
to recover from the slowdown when vectorizing but it now cuts off
the expensive alias versioning test.

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

PR tree-optimization/104912
* tree-vect-loop-manip.cc (vect_loop_versioning): Split
the cost model check to a separate BB to make sure it is
checked first and not combined with other version checks.

2 years agoscev: Fix a comment typo
Jakub Jelinek [Wed, 13 Apr 2022 07:47:45 +0000 (09:47 +0200)]
scev: Fix a comment typo

When looking at the kernel __popcountdi2 issue, I've noticed a comment typo.

2022-04-13  Jakub Jelinek  <jakub@redhat.com>

* tree-scalar-evolution.cc (expression_expensive_p): Fix a comment typo.

2 years agolibgomp: Fix a documentation typo
Jakub Jelinek [Wed, 13 Apr 2022 07:46:53 +0000 (09:46 +0200)]
libgomp: Fix a documentation typo

This fixes a typo in the 5.0 feature support table.

2022-04-13  Jakub Jelinek  <jakub@redhat.com>

* libgomp.texi: Fix a typo - mutexinouset -> mutexinoutset.

2 years agoppc: testsuite: skip pr60203 on no ldbl128
Alexandre Oliva [Wed, 13 Apr 2022 01:41:46 +0000 (22:41 -0300)]
ppc: testsuite: skip pr60203 on no ldbl128

If neither 128-bit long double format is available, skip pr60203.c.

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/pr60203.c: Skip on no 128-bit long double.

2 years agoppc: testsuite: PROMOTE_MODE fallout pr56605 [PR102146]
Alexandre Oliva [Wed, 13 Apr 2022 01:41:45 +0000 (22:41 -0300)]
ppc: testsuite: PROMOTE_MODE fallout pr56605 [PR102146]

The test expects a compare of DImode values, but after the removal of
PROMOTE_MODE from rs6000/, we get SImode.  Adjust the expectations.

for  gcc/testsuite/ChangeLog

PR target/102146
* gcc.target/powerpc/pr56605.c: Accept SImode compare operand.

2 years agomips: testsuite: enforce -ffat-lto-objects for pr102024-4.c
Xi Ruoyao [Wed, 6 Apr 2022 22:38:47 +0000 (06:38 +0800)]
mips: testsuite: enforce -ffat-lto-objects for pr102024-4.c

The body of func is optimized away with -flto -fno-fat-lto-objects, so
the psABI inform is not emitted, causing a test failure.

gcc/testsuite/

* gcc.target/mips/pr102024-4.c (dg-options): Add
-ffat-lto-objects.

2 years agoDaily bump.
GCC Administrator [Wed, 13 Apr 2022 00:16:34 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Prefer to use mmap instead of malloc in libbacktrace
Jonathan Wakely [Tue, 12 Apr 2022 16:56:45 +0000 (17:56 +0100)]
libstdc++: Prefer to use mmap instead of malloc in libbacktrace

As reported in PR libbacktrace/105240, libbacktrace leaks memory when
using malloc for allocations. I originally thought it would be simpler
to just use malloc unconditionally (because it's supported on all
targets) but the leaks make that problematic.

This adds libbacktrace's detection for mmap to the libstdc++
configury, so that we use mmap.c and mmapio.c when possible. This avoids
the leaks seen previously, at least on linux.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Check for mmap.
* config.h.in: Regenerate.
* configure: Regenerate.

2 years agolibstdc++: shrink-to-fit in std::basic_stacktrace::current(skip, max)
Jonathan Wakely [Tue, 12 Apr 2022 16:17:20 +0000 (17:17 +0100)]
libstdc++: shrink-to-fit in std::basic_stacktrace::current(skip, max)

If a large stacktrace is reduced to a max depth that is less than half
the capacity it will now be reallocated to remove the unused capacity.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::current): Reallocate
a smaller container if the unused capacity is larger than the
used size.

2 years agolibstdc++: Use allocator to construct std::stacktrace_entry objects
Jonathan Wakely [Tue, 12 Apr 2022 15:48:31 +0000 (16:48 +0100)]
libstdc++: Use allocator to construct std::stacktrace_entry objects

Because std::basic_stacktrace<A> is an allocator-aware container its
elements should be initialized using allocator_traits<A>::construct and
destroyed using allocator_traits<A>::destroy.

This adds new _M_clone and _M_assign helper functions to construct
elements correctly and uses those functions instead of calling
std::uninitialized_copy_n.

The _Impl::_M_destroy function needs to be passed an allocator to
destroy the elements correctly, so is replaced by _M_resize which can
also be used to trim the container to a smaller size.

Because destroying and creating std::stacktrace_entry objects is cheap,
the copy/move assignment operators can just destroy all existing
elements and use _Impl._M_clone or _Impl._M_assign to create new ones.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace): Use _Impl::_M_clone
or _Impl::_M_assign to initialize elements in allocated storage.
(basic_stacktrace::_M_clear()): Use _Impl::_M_resize instead of
_Impl::_M_destroy.
(basic_stacktrace::_Impl::_M_destroy()): Replace with ...
(basic_stacktrace::_Impl::_M_resize(size_type, allocator&)): New
function.
(basic_stacktrace::_Impl::_M_push_back): Use _M_xclone. Construct
new element using allocator.
(basic_stacktrace::_Impl::_M_clone): New function.
(basic_stacktrace::_Impl::_M_xclone): New function.
(basic_stacktrace::_Impl::_M_assign): New function.

2 years agolibstdc++: Use nothrow new in std::stacktrace
Jonathan Wakely [Tue, 12 Apr 2022 09:35:43 +0000 (10:35 +0100)]
libstdc++: Use nothrow new in std::stacktrace

We can avoid the overhead of handling a bad_alloc exception from
std::allocator<std::stacktrace_entry>::allocate by just calling the
nothrow operator new instead.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
Use nothrow new instead of try block for std::allocator.
(basic_stacktrace::_Impl::_M_deallocate): Use delete for
std::allocator.

2 years agolibstdc++: Reduce memory usage in std::stacktrace::current
Jonathan Wakely [Mon, 11 Apr 2022 20:15:40 +0000 (21:15 +0100)]
libstdc++: Reduce memory usage in std::stacktrace::current

This adds an alternative callback for use in the overload of
basic_stacktrace::current that takes a max_depth parameter. The new
callback will not allow the container to grow past the initial capacity,
which is set to the specified maximum depth.  This avoids allocating
memory for hundreds of frames only to discard them again because of a
small maximum depth limit.

For larger maximum depths the normal callback is used, with a smaller
initial capacity that can grow as needed. The container will be resized
to the given max depth after the entire backtrace has been produced
(relying on the fact that std::stacktrace_entry objects are trivially
destructible to elide their destruction).

Currently the value for "larger" limits is 128, so a max depth <= 128
will allocate capacity for exactly that many frames. A larger max depth
(or an unspecified max depth) will use an initial capacity of 64 frames
and grow as needed. Since each frame is only a uintptr_t value it might
be reasonable to increase the first value so that memory usage can be
capped for larger maximum depths.

This change also delays the creation of the libbacktrace state until we
actually need it, so that the state is not created if allocation fails.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::current): Replace
calls to _M_reserve and _S_curr_cb with call to _M_prepare.
Check return value of backtrace_simple when max depth given.
(basic_stacktrace::_M_reserve): Remove.
(basic_stacktrace::_S_curr_cb): Remove.
(basic_stacktrace::_M_prepare(size_type)): New function to
reserve initial capacity and return callback.
(basic_stacktrace::_Impl::_M_allocate): Remove check for 0 < n
and remove redundant zeroing of _M_frames and _M_capacity.
(basic_stacktrace::_Impl::_M_push_back): Add [[unlikely]]
attribute. Assign _Impl instead of swapping.
* testsuite/19_diagnostics/stacktrace/current.cc: New test.

2 years agolibgccjit: Add support for setting the alignment [PR104293]
Antoni Boucher [Tue, 12 Apr 2022 21:25:04 +0000 (17:25 -0400)]
libgccjit: Add support for setting the alignment [PR104293]

gcc/jit/
PR jit/104293
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_24): New ABI tag.
* docs/topics/expressions.rst: Add documentation for the
functions gcc_jit_lvalue_set_alignment and
gcc_jit_lvalue_get_alignment.
* jit-playback.h: New function (set_alignment).
* jit-recording.cc: New function (set_alignment).
* jit-recording.h: New functions (set_alignment, get_alignment)
and new field (m_alignment).
* libgccjit.cc: New functions (gcc_jit_lvalue_get_alignment,
gcc_jit_lvalue_set_alignment)
* libgccjit.h: New functions (gcc_jit_lvalue_get_alignment,
gcc_jit_lvalue_set_alignment)
* libgccjit.map (LIBGCCJIT_ABI_24): New ABI tag.

gcc/testsuite/
PR jit/104293
* jit.dg/all-non-failing-tests.h: Mention
test-setting-alignment.
* jit.dg/test-setting-alignment.c: New test.

2 years agolibgccjit: Add function to hide stderr logs [PR104073]
Antoni Boucher [Tue, 12 Apr 2022 21:23:18 +0000 (17:23 -0400)]
libgccjit: Add function to hide stderr logs [PR104073]

gcc/jit/
PR jit/104073
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_23): New ABI tag.
* docs/topics/contexts.rst: Add documentation for the new
function gcc_jit_context_set_bool_print_errors_to_stderr.
* jit-common.h: New enum value
(INNER_BOOL_OPTION_PRINT_ERRORS_TO_STDERR).
* jit-recording.cc: Handle the new option
INNER_BOOL_OPTION_PRINT_ERRORS_TO_STDERR.
* libgccjit.cc: New function
(gcc_jit_context_set_bool_print_errors_to_stderr).
* libgccjit.h: New function
(gcc_jit_context_set_bool_print_errors_to_stderr).
* libgccjit.map (LIBGCCJIT_ABI_23): New ABI tag.

2 years agolibgccjit: Add support for register variables [PR104072]
Antoni Boucher [Tue, 12 Apr 2022 21:20:30 +0000 (17:20 -0400)]
libgccjit: Add support for register variables [PR104072]

gcc/jit/
PR jit/104072
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_22): New ABI tag.
* docs/topics/expressions.rst: Add documentation for the
function gcc_jit_lvalue_set_register_name.
* jit-playback.h: New function (set_register_name).
* jit-recording.cc: New function (set_register_name) and add
support for register variables.
* jit-recording.h: New field (m_reg_name) and new function
(set_register_name).
* libgccjit.cc: New function (gcc_jit_lvalue_set_register_name).
* libgccjit.h: New function (gcc_jit_lvalue_set_register_name).
* libgccjit.map (LIBGCCJIT_ABI_22): New ABI tag.

gcc/
PR jit/104072
* reginfo.cc: New functions (clear_global_regs_cache,
reginfo_cc_finalize) to avoid an issue where compiling the same
code multiple times gives an error about assigning the same
register to 2 global variables.
* rtl.h: New function (reginfo_cc_finalize).
* toplev.cc: Call it.

gcc/testsuite/
PR jit/104072
* jit.dg/all-non-failing-tests.h: Add new
test-register-variable.
* jit.dg/harness.h: Add -fdiagnostics-color=never to context's
command-line options.
* jit.dg/test-error-register-variable-bad-name.c: New test.
* jit.dg/test-error-register-variable-size-mismatch.c: New test.
* jit.dg/test-register-variable.c: New test.

2 years agolibgccjit: Add support for bitcasts [PR104071]
Antoni Boucher [Tue, 12 Apr 2022 21:17:50 +0000 (17:17 -0400)]
libgccjit: Add support for bitcasts [PR104071]

gcc/jit/
PR jit/104071
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_21): New ABI tag.
* docs/topics/expressions.rst: Add documentation for the
function gcc_jit_context_new_bitcast.
* jit-playback.cc: New function (new_bitcast).
* jit-playback.h: New function (new_bitcast).
* jit-recording.cc: New functions (new_bitcast,
bitcast::replay_into, bitcast::visit_children,
bitcast::make_debug_string, bitcast::write_reproducer).
* jit-recording.h: New class (bitcast) and new function
(new_bitcast, bitcast::replay_into, bitcast::visit_children,
bitcast::make_debug_string, bitcast::write_reproducer,
bitcast::get_precedence).
* libgccjit.cc: New function (gcc_jit_context_new_bitcast)
* libgccjit.h: New function (gcc_jit_context_new_bitcast)
* libgccjit.map (LIBGCCJIT_ABI_21): New ABI tag.

gcc/testsuite/
PR jit/104071
* jit.dg/all-non-failing-tests.h: Add new test-bitcast.
* jit.dg/test-bitcast.c: New test.
* jit.dg/test-error-bad-bitcast.c: New test.
* jit.dg/test-error-bad-bitcast2.c: New test.

gcc/
PR jit/104071
* toplev.cc: Call the new function tree_cc_finalize in
toplev::finalize.
* tree.cc: New functions (clear_nonstandard_integer_type_cache
and tree_cc_finalize) to clear the cache of non-standard integer
types to avoid having issues with some optimizations of
bitcast where the SSA_NAME will have a size of a cached
integer type that should have been invalidated, causing a
comparison of integer constant to fail.
* tree.h: New function (tree_cc_finalize).

2 years agolibgccjit: Add support for sized integer types, including 128-bit integers [PR95325]
Antoni Boucher [Tue, 12 Apr 2022 21:16:45 +0000 (17:16 -0400)]
libgccjit: Add support for sized integer types, including 128-bit integers [PR95325]

gcc/jit/
PR target/95325
* docs/_build/texinfo/libgccjit.texi: Regenerate
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_20): New ABI tag.
* docs/topics/types.rst: Add documentation for the new types
GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T, GCC_JIT_TYPE_INT16_T,
GCC_JIT_TYPE_INT32_T, GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T and
new functions (gcc_jit_compatible_types, gcc_jit_type_get_size).
* jit-builtins.cc: Add support for BT_UINT128.
* jit-common.h: Update the value of NUM_GCC_JIT_TYPES.
* jit-playback.cc: Add support for the sized integer types.
* jit-recording.cc: Add support for the sized integer types.
* jit-recording.h: Add support for comparing integer types
and new function (is_signed).
* libgccjit.cc (gcc_jit_compatible_types): New.
(gcc_jit_type_get_size) New.
* libgccjit.h: New enum variants for gcc_jit_types
(GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T,
GCC_JIT_TYPE_INT16_T, GCC_JIT_TYPE_INT32_T,
GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T) and new functions
(gcc_jit_compatible_types, gcc_jit_type_get_size).
* libgccjit.map (LIBGCCJIT_ABI_20): New ABI tag.

gcc/testsuite/
PR target/95325
* jit.dg/test-types.c: Add tests for sized integer types.

2 years agoc++: local function versioning [PR104669]
Jason Merrill [Tue, 12 Apr 2022 20:40:14 +0000 (16:40 -0400)]
c++: local function versioning [PR104669]

There were two problems with this testcase: we weren't copying the target
attribute from the second declaration to the global alias for the first
one (duplicate_decls hunk), and then we were treating the third one as
matching the earlier one even though both are versioned (decls_match hunk).
The latter change required a fix to find_last_decl (used for attribute
mismatch warnings) to give up if we see a versioned function, as in that
case we can't determine whether the decls match, because we are still in the
process of setting the attributes on the new decl.

PR c++/104669

gcc/cp/ChangeLog:

* decl.cc (decls_match): Compare versions even if not recording.
(duplicate_decls): Propagate attributes to alias.
* decl2.cc (find_last_decl): Give up if versioned.

gcc/testsuite/ChangeLog:

* g++.target/i386/mv31.C: New test.

2 years agoc++: non-array new alignment [PR102071]
Jason Merrill [Tue, 12 Apr 2022 20:06:18 +0000 (16:06 -0400)]
c++: non-array new alignment [PR102071]

While considering the PR102071 patch for backporting, I noticed that I was
considering the alignment of the array new cookie even when there isn't one
because we aren't allocating an array.

PR c++/102071

gcc/cp/ChangeLog:

* init.cc (build_new_1): Check array_p for alignment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/aligned-new9.C: Add single-object test.

2 years agoLet nvptx-as figure out the target architecture [PR97348]
Thomas Schwinge [Wed, 13 Jan 2021 08:04:47 +0000 (09:04 +0100)]
Let nvptx-as figure out the target architecture [PR97348]

... now that it has been enhanced to do so.

This is a follow-up to PR97348 commit 383400a6078d75bbfa1216c9af2c37f7e88740c9
"[nvptx] Set -misa=sm_35 by default".

gcc/
PR target/97348
* config/nvptx/nvptx.h (ASM_SPEC): Don't set.
* config/nvptx/nvptx.opt (misa): Adjust comment.

2 years agoRevert "[nvptx] Use --no-verify for sm_30"
Thomas Schwinge [Thu, 7 Apr 2022 13:32:31 +0000 (15:32 +0200)]
Revert "[nvptx] Use --no-verify for sm_30"

This reverts commit 12fa7641ceed9c9139e2ea7b62c11f3dc5b6f6f4.

2 years agoRevert "[nvptx] Fix ASM_SPEC workaround for sm_30"
Thomas Schwinge [Thu, 7 Apr 2022 13:16:41 +0000 (15:16 +0200)]
Revert "[nvptx] Fix ASM_SPEC workaround for sm_30"

This reverts commit bf4832d6fa817f66009f100a9cd68953062add7d.

2 years agoc++: requires-expr in pack expansion using pack [PR103105]
Patrick Palka [Tue, 12 Apr 2022 16:58:18 +0000 (12:58 -0400)]
c++: requires-expr in pack expansion using pack [PR103105]

Here after dependent substitution of {Ts...} into the alias 'wrap',
since we never partially instantiate a requires-expr, we end up with a
requires-expr whose REQUIRES_EXPR_EXTRA_ARGS contains an
ARGUMENT_PACK_SELECT (which just resolves to the parameter pack Ts).
Then when hashing the resulting dependent specialization of A, we crash
from iterative_hash_template_arg since it deliberately doesn't handle
ARGUMENT_PACK_SELECT.

Like in r12-7102-gdb5f1c17031ad8, it seems the right fix here is to
resolve ARGUMENT_PACK_SELECT arguments before storing them into an
extra args tree (such as REQUIRES_EXPR).

PR c++/103105

gcc/cp/ChangeLog:

* pt.cc (build_extra_args): Call preserve_args.

gcc/testsuite/ChangeLog:

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

2 years agoipa/104303 - revert overly conservative DCE change
Richard Biener [Tue, 12 Apr 2022 14:40:11 +0000 (16:40 +0200)]
ipa/104303 - revert overly conservative DCE change

The following reverts the DCE change back to the original behavior
which should be handled well during the propagation stage.  That
should fix the failures Thomas Schwinge is reporting.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR ipa/104303
* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Do not
include local escaped memory as obviously necessary stores.

2 years agoarm: fix testsuite failure of reg_equal_test.c [PR101755]
Richard Earnshaw [Tue, 12 Apr 2022 12:35:27 +0000 (13:35 +0100)]
arm: fix testsuite failure of reg_equal_test.c [PR101755]

The test failure in PR101755 is due to the gimple optimizers getting
smarter.  But really we are just testing that RTL expansion is doing
the right thing and annotating a constant accordingly.  So rework the
test to use GIMPLE input and simplify the code entirely.  Also, this
test only ever worked on architecture versions with the MOVW/MOVT
instructions, so check for this before running.

gcc/testsuite/ChangeLog:

PR target/101755
* gcc.target/arm/reg_equal_test.c: Convert to gimple test.  Restrict
to architectures with MOVW/MOVT.

2 years agotree-optimization/105235 - clean EH in execute_cse_conv_1
Richard Biener [Tue, 12 Apr 2022 08:07:10 +0000 (10:07 +0200)]
tree-optimization/105235 - clean EH in execute_cse_conv_1

When a FP conversion is removed we have to eventually clean EH.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105235
* tree-ssa-math-opts.cc (execute_cse_conv_1): Clean EH and
return whether the CFG changed.
(execute_cse_sincos_1): Adjust.

* g++.dg/opt/pr105235-1.C: New testcase.

2 years agoarm: remove unnecessary armv9-a multilib variant [PR104144]
Przemyslaw Wirkus [Mon, 11 Apr 2022 12:14:01 +0000 (13:14 +0100)]
arm: remove unnecessary armv9-a multilib variant [PR104144]

Remove the armv9-a specific multilib variants.  Instead, arrange to
use either the armv8-a multilibs or the armv7-a versions, depeding on
the configuration.  This eliminates the need to have a version of gas
that understands --march=armv9-a when building GCC.  Very little, if
anything in the standard libraries directly uses Armv9-a features
anyway.

Also remove the +crc variant rules for Armv9-a.  CRC is an implicit
part of Armv9-a, so doesn't have a explicit feature to handle it.

gcc/ChangeLog:

PR target/104144
* config/arm/t-aprofile (MULTI_ARCH_OPTS_A): Remove Armv9-a options.
(MULTI_ARCH_DIRS_A): Remove Armv9-a diretories.
(MULTILIB_REQUIRED): Don't require Armv9-a libraries.
(MULTILIB_MATCHES): Treat Armv9-a as equivalent to Armv8-a.
(MULTILIB_REUSE): Remove remap rules for Armv9-a.
* config/arm/t-multilib (v9_a_nosimd_variants): Delete.
(MULTILIB_MATCHES): Remove mappings for v9_a_nosimd_variants.

gcc/testsuite/ChangeLog:

PR target/104144
* gcc.target/arm/multilib.exp: Updated tests.

2 years agotree-optimization/105232 - handle overly large sizes in component_ref_size
Richard Biener [Tue, 12 Apr 2022 07:54:32 +0000 (09:54 +0200)]
tree-optimization/105232 - handle overly large sizes in component_ref_size

The following properly checks tree_fits_poly_int64_p before converting
a size to a poly_int64.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105232
* tree.cc (component_ref_size): Bail out for too large
or non-constant sizes.

2 years agotree-optimization/105226 - avoid splitting abnormal edges
Richard Biener [Tue, 12 Apr 2022 07:40:15 +0000 (09:40 +0200)]
tree-optimization/105226 - avoid splitting abnormal edges

Vectorizer loop versioning tries to version outer loops if possible
but fails to check whether it can actually split the single exit
edge as it will do.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105226
* tree-vect-loop-manip.cc (vect_loop_versioning): Verify
we can split the exit of an outer loop we choose to version.

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

2 years agoi386: i386-expand formatting fixes
Jakub Jelinek [Tue, 12 Apr 2022 07:20:11 +0000 (09:20 +0200)]
i386: i386-expand formatting fixes

While working on the PR105214 patch, I've noticed incorrect formatting
for a bunch of functions where the function names aren't at the start of
lines.

The following patch fixes it, though of course it isn't a regression.

2022-04-12  Jakub Jelinek  <jakub@redhat.com>

* config/i386/i386-expand.cc (ix86_emit_i387_sinh, ix86_emit_i387_cosh,
ix86_emit_i387_tanh, ix86_emit_i387_asinh, ix86_emit_i387_acosh,
ix86_emit_i387_atanh, ix86_emit_i387_log1p, ix86_emit_i387_round,
ix86_emit_swdivsf, ix86_emit_swsqrtsf,
ix86_expand_atomic_fetch_op_loop, ix86_expand_cmpxchg_loop):
Formatting fix.
* config/i386/i386.cc (warn_once_call_ms2sysv_xlogues): Likewise.

2 years agoi386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]
Jakub Jelinek [Tue, 12 Apr 2022 07:19:11 +0000 (09:19 +0200)]
i386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]

The following testcase ICEs, because ix86_emit_i387_log1p attempts to
emit something like
  if (cond)
    some_code1;
  else
    some_code2;
and emits a conditional jump using emit_jump_insn (standard way in
the file) and an unconditional jump using emit_jump.
The problem with that is that if there is pending stack adjustment,
it isn't emitted before the conditional jump, but is before the
unconditional jump and therefore stack is adjusted only conditionally
(at the end of some_code1 above), which makes dwarf2 pass unhappy about it
but is a serious wrong-code even if it doesn't ICE.

This can be fixed either by emitting pending stack adjust before the
conditional jump as the following patch does, or by not using
  emit_jump (label2);
and instead hand inlining what that function does except for the
pending stack adjustment, like:
  emit_jump_insn (targetm.gen_jump (label2));
  emit_barrier ();
In that case there will be no stack adjustment in the sequence and
it will be done later on somewhere else.

2022-04-12  Jakub Jelinek  <jakub@redhat.com>

PR target/105214
* config/i386/i386-expand.cc (ix86_emit_i387_log1p): Call
do_pending_stack_adjust.

* gcc.dg/asan/pr105214.c: New test.

2 years agobuiltins: Fix up expand_builtin_int_roundingfn_2 [PR105211]
Jakub Jelinek [Tue, 12 Apr 2022 07:16:06 +0000 (09:16 +0200)]
builtins: Fix up expand_builtin_int_roundingfn_2 [PR105211]

The expansion of __builtin_iround{,f,l} etc. builtins in some cases
emits calls to a different fallback builtin.  To locate the right builtin
it uses mathfn_built_in_1 with the type of the first argument.
If its TYPE_MAIN_VARIANT is {float,double,long_double}_type_node, all is
fine, but on the following testcase, because GIMPLE considers scalar
float conversions between types with the same mode as useless,
TYPE_MAIN_VARIANT of the arg's type is float32_type_node and because there
isn't __builtin_lroundf32 returns NULL and we ICE.

This patch will first try the type of the first argument of the builtin's
prototype (so that say on sizeof(double)==sizeof(long double) target it honors
whether it was a *l or non-*l call; though even that can't be 100% trusted,
user could incorrectly prototype it) and as fallback the type argument.
If neither works, doesn't fallback.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/105211
* builtins.cc (expand_builtin_int_roundingfn_2): If mathfn_built_in_1
fails for TREE_TYPE (arg), retry it with
TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))) and if even that
fails, emit call normally.

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

2 years agoIBM zSystems: Add support for z16 as CPU name.
Andreas Krebbel [Tue, 12 Apr 2022 05:41:33 +0000 (07:41 +0200)]
IBM zSystems: Add support for z16 as CPU name.

So far z16 was identified as arch14. After the machine has been
announced we can now add the real name.

gcc/ChangeLog:

* common/config/s390/s390-common.cc: Rename PF_ARCH14 to PF_Z16.
* config.gcc: Add z16 as march/mtune switch.
* config/s390/driver-native.cc (s390_host_detect_local_cpu):
Recognize z16 with -march=native.
* config/s390/s390-opts.h (enum processor_type): Rename
PROCESSOR_ARCH14 to PROCESSOR_3931_Z16.
* config/s390/s390.cc (PROCESSOR_ARCH14): Rename to ...
(PROCESSOR_3931_Z16): ... throughout the file.
(s390_processor processor_table): Add z16 as cpu string.
* config/s390/s390.h (enum processor_flags): Rename PF_ARCH14 to
PF_Z16.
(TARGET_CPU_ARCH14): Rename to ...
(TARGET_CPU_Z16): ... this.
(TARGET_CPU_ARCH14_P): Rename to ...
(TARGET_CPU_Z16_P): ... this.
(TARGET_ARCH14): Rename to ...
(TARGET_Z16): ... this.
(TARGET_ARCH14_P): Rename to ...
(TARGET_Z16_P): ... this.
* config/s390/s390.md (cpu_facility): Rename arch14 to z16 and
check TARGET_Z16 instead of TARGET_ARCH14.
* config/s390/s390.opt: Add z16 to processor_type.
* doc/invoke.texi: Document z16 and arch14.

2 years agoc++: rodata and defaulted ctor [PR104142]
Jason Merrill [Mon, 11 Apr 2022 18:50:14 +0000 (14:50 -0400)]
c++: rodata and defaulted ctor [PR104142]

Trivial initialization shouldn't bump a variable out of .rodata; if the
result of build_aggr_init is an empty STATEMENT_LIST, throw it away.

PR c++/104142

gcc/cp/ChangeLog:

* decl.cc (check_initializer): Check TREE_SIDE_EFFECTS.

gcc/testsuite/ChangeLog:

* g++.dg/opt/const7.C: New test.

2 years agoc++: using operator= [PR105223]
Jason Merrill [Mon, 11 Apr 2022 21:51:43 +0000 (17:51 -0400)]
c++: using operator= [PR105223]

In a template class A we normally add an implicit using A::operator= as a
placeholder for the implicitly declared operator whose signature we don't
know yet.  In my patch for PR92918 I stopped doing that if the class has an
explicit operator=, but that was wrong; an operator= taking an unrelated
type doesn't prevent the implicit declaration.

When I was working on that patch, the change was necessary to avoid another
regression, but apparently it is no longer needed.

PR c++/105223
PR c++/92918

gcc/cp/ChangeLog:

* class.cc (finish_struct): Always using op=.

gcc/testsuite/ChangeLog:

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

2 years agoLoongArch: Fix bug for tmpdir-g++.dg-struct-layout-1/t033.
chenglulu [Mon, 28 Mar 2022 09:02:39 +0000 (17:02 +0800)]
LoongArch: Fix bug for tmpdir-g++.dg-struct-layout-1/t033.

gcc/ChangeLog:

* config/loongarch/loongarch.cc: Fix bug for
tmpdir-g++.dg-struct-layout-1/t033.

2 years agoDaily bump.
GCC Administrator [Tue, 12 Apr 2022 00:16:37 +0000 (00:16 +0000)]
Daily bump.

2 years agors6000: Handle pcrel sibcalls to longcall functions [PR104894]
Peter Bergner [Mon, 11 Apr 2022 22:00:44 +0000 (17:00 -0500)]
rs6000: Handle pcrel sibcalls to longcall functions [PR104894]

Before PCREL in POWER10, we were not allowed to perform sibcalls to longcall
functions since callee's return would skip the TOC restore in the caller.
However, with PCREL we can now safely perform a sibling call to longcall
functions.  The problem with the current code is that pcrel sibcall
branches to a PLT stub label even though -fno-plt was used.  The solution
here is to check for a pcrel longcall and emit an inline plt stub in
that case.

2022-04-11  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/104894
* config/rs6000/rs6000.cc (rs6000_sibcall_aix): Handle pcrel sibcalls
to longcall functions.

gcc/testsuite/
PR target/104894
* gcc.target/powerpc/pr104894.c: New test.
* gcc.target/powerpc/pr104894-2.c: New test.

2 years agoipa: fix comment typos
Jason Merrill [Mon, 11 Apr 2022 17:59:15 +0000 (13:59 -0400)]
ipa: fix comment typos

gcc/ChangeLog:

* ipa-free-lang-data.cc (free_lang_data_in_decl): Fix typos.

2 years agoc++: operator new lookup [PR98249]
Jason Merrill [Mon, 11 Apr 2022 17:06:05 +0000 (13:06 -0400)]
c++: operator new lookup [PR98249]

The standard says, as we quote in the comment just above, that if we don't
find operator new in the allocated type, it should be looked up in the
global scope.  This is specifically ::, not just any namespace, and we
already give an error for an operator new declared in any other namespace.

PR c++/98249

gcc/cp/ChangeLog:

* call.cc (build_operator_new_call): Just look in ::.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/new3.C: New test.

2 years agolibstdc++: Fix incorrect branch prediction hint in std::stacktrace
Jonathan Wakely [Mon, 11 Apr 2022 19:13:44 +0000 (20:13 +0100)]
libstdc++: Fix incorrect branch prediction hint in std::stacktrace

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
Change [[unlikely]] attribute to [[likely]].

2 years agors6000: Fix unpack for no-direct-move (PR103623)
Segher Boessenkool [Mon, 11 Apr 2022 15:43:38 +0000 (15:43 +0000)]
rs6000: Fix unpack for no-direct-move (PR103623)

The _dm alternative works fine for soft-float, but the _nodm variant
pattern is missing that alternative.  So, let's add that.

There probably should be an r,r,i alternative as well (or we can make it
rm,r,i), but that is for later.

2022-04-11  Segher Boessenkool  <segher@kernel.crashing.org>

PR target/105213
PR target/103623
* config/rs6000/rs6000.md (unpack<mode>_nodm): Add m,r,i alternative.

2 years agophiopt: Fix up debug handling in the (x != cst1 ? x : cst2) != cst3 opt [PR105218]
Jakub Jelinek [Mon, 11 Apr 2022 17:06:59 +0000 (19:06 +0200)]
phiopt: Fix up debug handling in the (x != cst1 ? x : cst2) != cst3 opt [PR105218]

In the PR104639 optimization, I've added code to emit
  # DEBUG D#1 => arg != carg ? arg : oarg
instruction and replace debug uses of the phi with that debug
temp, so that the debug info is still accurrate.
Unfortunately, that is only correct if the middle-bb and
phi bb contain 1 and 2 predecessors, i.e. the ones that
we are using in the optimization (in particular middle-bb has
cond-bb as pred and phi bb cond-bb and middle-bb).
If that is not the case, then we can reach these from another bb
and so the arg SSA_NAME might not be valid there (its definition
doesn't dominate all incoming edges), or, even if it is valid,
might be wrong-debug, e.g. phi argument from some unrelated other
incoming edge might have the carg value that the debug stmt
remaps to oarg.  In theory we could check for that case and
if middle-bb doesn't have a single pred or phi bb 2 preds
check if arg SSA_NAME dominates the phi bb and if all other
phi arguments are expr_not_equal_to the carg value, but this patch
just uses a simpler approach and resets already if we have some
extra incoming edges.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105218
* tree-ssa-phiopt.cc (value_replacement): If middle_bb has
more than one predecessor or phi's bb more than 2 predecessors,
reset phi result uses instead of adding a debug temp.

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

2 years agolibstdc++: Fix std::basic_stacktrace special members [PR105031]
Jonathan Wakely [Mon, 11 Apr 2022 16:44:14 +0000 (17:44 +0100)]
libstdc++: Fix std::basic_stacktrace special members [PR105031]

The PR points out that there is a non-constant condition used for an
if-constexpr statement, but there are several other problems with the
copy, move and swap members of std::basic_stacktrace.

libstdc++-v3/ChangeLog:

PR libstdc++/105031
* include/std/stacktrace (basic_stacktrace::basic_stacktrace):
Fix allocator usage in constructors.
(basic_stacktrace::operator=(const basic_stacktrace&)): Do not
try to reallocate using const allocator.
(basic_stacktrace::operator=(basic_stacktrace&&)): Fix
if-constexpr with non-constant condition. Do not allocate new
storage if allocator propagates. Do not set _M_size if
allocation fails.
(basic_stacktrace::swap(basic_stacktrace&)): Fix typo. Add
assertion that non-propagating allocators are equal.
* testsuite/19_diagnostics/stacktrace/stacktrace.cc: New test.

2 years agolibstdc++: Improve behaviour of std::stacktrace::current
Jonathan Wakely [Mon, 11 Apr 2022 09:20:40 +0000 (10:20 +0100)]
libstdc++: Improve behaviour of std::stacktrace::current

This prevents inlining the current() function to guarantee that it is
present in the stacktrace, then tells libbacktrace to skip that frame.

To avoid overflow in the int argument to __glibcxx_backtrace_simple, we
need to check if the skip parameter exceeds INT_MAX (which is possible
for 16-bit targets where short and int have the same width). We also
need to limit the size of the returned value to the max_depth parameter,
which was missing previously.

This also fixes basic_stacktrace::max_size() to not exceed the maximum
size supported by the allocator, which might be smaller than the maximum
value of size_type.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::current): Duplicate
implementation into each overload. Add noinline attribute and
skip current frame.
(basic_stacktrace::max_size()): Call _Impl::_S_max_size.
(basic_stacktrace::_S_curr_cb()): New function defining lambda.
(basic_stacktrace::_Impl::_S_max_size): New function defining
maximum size in terms of allocator and size_type.
(basic_stacktrace::_Impl::_M_allocate): Check against
max_size().
* testsuite/19_diagnostics/stacktrace/entry.cc: Call function
for non-constexpr checks. Check line number is correct.

2 years agoppc: testsuite: require target effectively [PR104253]
Alexandre Oliva [Mon, 11 Apr 2022 15:11:10 +0000 (12:11 -0300)]
ppc: testsuite: require target effectively [PR104253]

The testcase was missing dg- before require-effective-target.

While at that, I'm also pruning the excess-error warning I got when
the test failed to be disabled because of the above.  I suppose it
might be useful for some target variants.

for gcc/testsuite/ChangeLog

PR target/104253
* gcc.target/powerpc/pr104253.c: Add missing dg- before
require-effective-target.  Prune warning about -mfloat128
possibly not being fully supported.

2 years agoc++: Tolerate cdtors returning this in constexpr
Alexandre Oliva [Mon, 11 Apr 2022 15:11:09 +0000 (12:11 -0300)]
c++: Tolerate cdtors returning this in constexpr

On targets that return this from cdtors, cxx_eval_call_expression may
flag flowing off the end of a dtor.  That's preempted for ctors, and
avoided entirely when dtors return void, but when they return this,
the return value should be conceptually disregarded, without making
room for such internal ABI details to make a program ill-formed, as in
g++.dg/cpp2a/constexpr-dtor12.C on arm-eabi.

for  gcc/cp/ChangeLog

* constexpr.cc (cxx_eval_call_expression): Disregard dtor
result.

2 years agoc++: Set loc on call even if result is discarded
Alexandre Oliva [Mon, 11 Apr 2022 15:11:08 +0000 (12:11 -0300)]
c++: Set loc on call even if result is discarded

This patch fixes a divergence in line numbers in diagnostics and,
presumably, debug information, between targets whose cdtors return
this and those that don't.

The problem was visible in g++.dg/cpp2a/constexpr-dtor3.C: while the
dtor call in the cleanup for f4 was expected at the closing brace, on
returning-this targets it came up at the assignment.

The reason is convoluted: statements in cleanups have their location
information removed, to avoid bumpy debugger behavior, and then set to
the location of the end of the scope.

The cleanup dtor call has its locus cleared in both kinds of targets,
but the end-of-scope locus doesn't make it on returning-this targets.
The calls are wrapped with a cast-to-void to discard the unused return
value, and the existing logic only attached the locus to the
conversion NOP_EXPR.

The call thus remains locus-less.  When constexpr logic copies and
evals the body, it sets unset locations; while copying cleanups, the
locus is taken from the cleanup expression, rather than matching the
end-of-scope locus set by the parser.  So we end up with different
locations.

This patch sets the locus of the call even when it's wrapped by a
convert-to-void NOP_EXPR, so it won't diverge any more.

for  gcc/cp/ChangeLog

* semantics.cc (set_cleanup_locs): Propagate locus to call
wrapped in cast-to-void.

2 years agoRISC-V: Support -misa-spec for arch-canonicalize and multilib-generator. [PR104853]
Kito Cheng [Mon, 11 Apr 2022 08:29:34 +0000 (16:29 +0800)]
RISC-V: Support -misa-spec for arch-canonicalize and multilib-generator. [PR104853]

We migrate the default ISA spec version from 2.2 to 20191213, but those scripts
aren't updated at the same time, this patch is making both scripts support
different ISA spec versions.

gcc/ChangeLog:

PR target/104853
* config.gcc: Pass -misa-spec to arch-canonicalize and
multilib-generator.
* config/riscv/arch-canonicalize: Adding -misa-spec option.
(SUPPORTED_ISA_SPEC): New.
(arch_canonicalize): New argument `isa_spec`.
Handle multiple ISA spec versions.
* config/riscv/multilib-generator: Adding -misa-spec option.

2 years agolibstdc++: Move stacktrace tests to 19_diagnostics directory
Jonathan Wakely [Mon, 11 Apr 2022 12:36:47 +0000 (13:36 +0100)]
libstdc++: Move stacktrace tests to 19_diagnostics directory

This matches where the feature is defined in the current draft.

libstdc++-v3/ChangeLog:

* testsuite/20_util/stacktrace/entry.cc: Moved to...
* testsuite/19_diagnostics/stacktrace/entry.cc: ...here.
* testsuite/20_util/stacktrace/synopsis.cc: Moved to...
* testsuite/19_diagnostics/stacktrace/synopsis.cc: ...here.
* testsuite/20_util/stacktrace/version.cc: Moved to...
* testsuite/19_diagnostics/stacktrace/version.cc: ...here.

2 years agolibstdc++: Move Filesystem TS path definitions out of class body
Jonathan Wakely [Fri, 1 Apr 2022 11:02:13 +0000 (12:02 +0100)]
libstdc++: Move Filesystem TS path definitions out of class body

This fixes some errors with clang caused by instantiating vector<_Cmpt>
before the _Cmpt type is complete.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path): Define special
members after path::_Cmpt is complete.

2 years agoRISC-V: Sync arch-canonicalize and riscv-common.cc
Kito Cheng [Mon, 11 Apr 2022 07:52:46 +0000 (15:52 +0800)]
RISC-V: Sync arch-canonicalize and riscv-common.cc

Currently we are sync that manually, but I guess we should re-implement
arch-canonicalize in C++, so that we could reuse the stuffs from
riscv-common.cc.

gcc/ChangeLog:

* config/riscv/arch-canonicalize: Add TODO item.
(IMPLIED_EXT): Sync.
(arch_canonicalize): Checking until no change.

2 years agomiddle-end: Prevent the use of the cond inversion detection code when both conditions...
Tamar Christina [Mon, 11 Apr 2022 14:09:05 +0000 (15:09 +0100)]
middle-end: Prevent the use of the cond inversion detection code when both conditions are external. [PR105197]

Previously ifcvt used to enforce that a mask A and the inverse of said mask be
represented as ~A. So for the masks

  _25 = _6 != 0;
  _44 = _4 != 0;

ifcvt would produce for an operation requiring the inverse of said mask

  _26 = ~_25;
  _43 = ~_44;

but now that VN is applied to the entire function body we get a simplification
on the mask and produce:

  _26 = _6 == 0;
  _43 = _4 == 0;

This in itself is not a problem semantically speaking (though it does create
more masks that need to be tracked) but when vectorizing the masked conditional
we would still detect _26 and _43 to be inverses of _25 and _44 and mark them
as requiring their operands be swapped.

When vectorizing we swap the operands but don't find the BIT_NOT_EXPR to remove
and so we leave the condition as is which produces invalid code:

------>vectorizing statement: _ifc__41 = _43 ? 0 : _ifc__40;
created new init_stmt: vect_cst__136 = { 0, ... }
add new stmt: _137 = mask__43.26_135 & loop_mask_111
note:  add new stmt: vect__ifc__41.27_138 = VEC_COND_EXPR <_137, vect__ifc__40.25_133, vect_cst__136>;

This fixes disabling the inversion detection code when the loop isn't masked
since both conditional would be external.  We'd then not use the new cond_code
and would incorrectly still swap the operands.

The resulting code is also better than GCC-11 with most operations now
predicated on the loop mask rather than a ptrue.

gcc/ChangeLog:

PR target/105197
* tree-vect-stmts.cc (vectorizable_condition): Prevent cond swap when
not masked.

gcc/testsuite/ChangeLog:

PR target/105197
* gcc.target/aarch64/sve/pr105197-1.c: New test.
* gcc.target/aarch64/sve/pr105197-2.c: New test.

2 years agoc++: -Wplacement-new and anon union member [PR100370]
Jason Merrill [Wed, 6 Apr 2022 02:29:06 +0000 (22:29 -0400)]
c++: -Wplacement-new and anon union member [PR100370]

This bug was an object/value confusion; we are interested in the size
of *b.ip, but instead the code was calculating the size of b.ip itself.

This seems to be because compute_objsize will compute the size of whatever
object it can find in the argument: if you pass it a VAR_DECL, it gives you
the size of that variable.  If you pass it an ADDR_EXPR of a VAR_DECL, it
again gives you the size of the variable.  The way you can tell the
difference is by looking at the deref member of access_ref: if it's -1, the
argument is a pointer to the object.  Since that's what we're interested in,
we should check for that, like check_dangling_stores does.

This regressed some tests because compute_objsize_r was wrongly zeroing
deref in the POINTER_PLUS_EXPR handling; adding an offset to a pointer
doesn't change whether the pointer is itself a variable or a pointer to
one.  In fact, handling POINTER_PLUS_EXPR only really makes sense for deref
== -1, where we're adjusting a pointer to the variable.

PR c++/100370

gcc/cp/ChangeLog:

* init.cc (warn_placement_new_too_small): Check deref.

gcc/ChangeLog:

* pointer-query.cc (compute_objsize_r) [POINTER_PLUS_EXPR]: Require
deref == -1.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wplacement-new-size-11.C: New test.

2 years agophiopt: Optimize (x != cst1 ? x : cst2) != cst3 [PR104639]
Jakub Jelinek [Mon, 11 Apr 2022 08:44:28 +0000 (10:44 +0200)]
phiopt: Optimize (x != cst1 ? x : cst2) != cst3 [PR104639]

Here is an attempt to resolve a P1 regression, where due to threading
changes we no longer optimize
bool foo(int i) {
    while (i == 4)
        i += 2;
    return i;
}
to just return i != 0; by enhancing the phiopt value_replacement
optimization.  Normally it will optimize x != cst1 ? x : cst1 to x.
Here we extend it to also optimize x != cst1 ? x : cst2 to x if
it (phi result) has a single immediate use which is a comparison
with some INTEGER_CST cst3 and we can prove that we don't care
whether x is cst1 or cst2 because both compare the same against cst3.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/104639
* tree-ssa-phiopt.cc: Include tree-ssa-propagate.h.
(value_replacement): Optimize (x != cst1 ? x : cst2) != cst3
into x != cst3.

* gcc.dg/tree-ssa/pr104639-1.c: New test.
* gcc.dg/tree-ssa/pr104639-2.c: New test.

2 years agoc-family: Initialize ridpointers for __int128 etc. [PR105186]
Jakub Jelinek [Mon, 11 Apr 2022 08:41:07 +0000 (10:41 +0200)]
c-family: Initialize ridpointers for __int128 etc. [PR105186]

The following testcase ICEs with C++ and is incorrectly rejected with C.
The reason is that both FEs use ridpointers identifiers for CPP_KEYWORD
and value or u.value for CPP_NAME e.g. when parsing attributes or OpenMP
directives etc., like:
         /* Save away the identifier that indicates which attribute
            this is.  */
         identifier = (token->type == CPP_KEYWORD)
           /* For keywords, use the canonical spelling, not the
              parsed identifier.  */
           ? ridpointers[(int) token->keyword]
           : id_token->u.value;

         identifier = canonicalize_attr_name (identifier);
I've tried to change those to use ridpointers only if non-NULL and otherwise
use the value/u.value even for CPP_KEYWORDS, but that was a large 10 hunks
patch.

The following patch instead just initializes ridpointers for the __intNN
keywords.  It can't be done earlier before we record_builtin_type as there
are 2 different spellings and if we initialize those ridpointers early, the
second record_builtin_type fails miserably.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/105186
* c-common.cc (c_common_nodes_and_builtins): After registering __int%d
and __int%d__ builtin types, initialize corresponding ridpointers
entry.

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

2 years ago[committed] Minor bfin codegen bugfix
Jeff Law [Mon, 11 Apr 2022 03:02:48 +0000 (23:02 -0400)]
[committed] Minor bfin codegen bugfix

gcc/
* config/bfin/bfin.md (rol_one): Fix pattern to indicate the
sign bit of the source ends up in CC.

2 years agors6000/test: Adjust p9-vec-length-{full,epil}-7.c [PR103196]
Kewen Lin [Mon, 11 Apr 2022 02:50:44 +0000 (21:50 -0500)]
rs6000/test: Adjust p9-vec-length-{full,epil}-7.c [PR103196]

As PR103196 shows, complete unrolling pass still takes effect even
if we have specified the option "-fno-unroll-loops".  The loops in
that case are not expected to be transformed by it, otherwise the
expected counts change.  This patch is to add the disabling option
to make them not sensitive to complete unrolling.

PR testsuite/103196

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/p9-vec-length-epil-7.c: Add option
-fdisable-tree-cunroll.
* gcc.target/powerpc/p9-vec-length-full-7.c: Likewise.

2 years agoDaily bump.
GCC Administrator [Mon, 11 Apr 2022 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: fix checking of coshape specification in ALLOCATE statement
Harald Anlauf [Wed, 6 Apr 2022 20:24:21 +0000 (22:24 +0200)]
Fortran: fix checking of coshape specification in ALLOCATE statement

gcc/fortran/ChangeLog:

PR fortran/105184
* array.cc (match_subscript): Reject assumed size coarray
specification with missing lower bound.
* resolve.cc (resolve_allocate_expr): Fix logic for checking
allocate-coshape-spec in ALLOCATE statement.

gcc/testsuite/ChangeLog:

PR fortran/105184
* gfortran.dg/coarray_44.f90: Adjust expected output.
* gfortran.dg/coarray_allocate_11.f90: Likewise.
* gfortran.dg/coarray_allocate_12.f90: New test.

2 years agoDaily bump.
GCC Administrator [Sun, 10 Apr 2022 00:16:34 +0000 (00:16 +0000)]
Daily bump.

2 years agoanalyzer: fix folding of regions involving unknown ptrs [PR103892]
David Malcolm [Sat, 9 Apr 2022 22:12:57 +0000 (18:12 -0400)]
analyzer: fix folding of regions involving unknown ptrs [PR103892]

PR analyzer/103892 reports a false positive from -Wanalyzer-double-free.

The root cause is the analyzer failing to properly handle "unknown"
symbolic regions, and thus confusing two different expressions.

Specifically, the analyzer eventually hits the complexity limit for
symbolic values, and starts using an "unknown" svalue for a pointer.
The analyzer uses
  symbolic_region(unknown_svalue([of ptr type]))
i.e.
  (*UNKNOWN_PTR)
in a few places to mean "we have an lvalue, but we're not going to
attempt to track what it is anymore".

"Unknown" should probably be renamed to "unknowable"; in theory, any
operation on such an unknown svalue should be also an unknown svalue.

The issue is that in various places where we create child regions, we
were failing to check for the parent region being (*UNKNOWN_PTR), and so
were erroneously creating regions based on (*UNKNOWN_PTR), such as
*(UNKNOWN_PTR + OFFSET).  The state-machine handling was erroneously
allowing e.g. INITIAL_VALUE (*(UNKNOWN_PTR + OFFSET)) to have state,
and thus we could record that such a value had had "free" called on it,
and thus eventually false report a double-free when a different
expression incorrectly "simplified" to the same expression.

This patch fixes things by checking when creating the various kinds of
child region for (*UNKNOWN_PTR) as the parent region, and simply
returning another (*UNKNOWN_PTR) for such child regions (using the
appropriate type).

Doing so fixes the false positive, and also fixes a state explosion on
this testcase, as the states at the program points more rapidly reach
a fixed point where everything is unknown.  I checked for other cases
that no longer needed -Wno-analyzer-too-complex; the only other one
seems to be gcc.dg/analyzer/pr96841.c, but that seems to already have
become redundant at some point before this patch.

gcc/analyzer/ChangeLog:
PR analyzer/103892
* region-model-manager.cc
(region_model_manager::get_unknown_symbolic_region): New,
extracted from...
(region_model_manager::get_field_region): ...here.
(region_model_manager::get_element_region): Use it here.
(region_model_manager::get_offset_region): Likewise.
(region_model_manager::get_sized_region): Likewise.
(region_model_manager::get_cast_region): Likewise.
(region_model_manager::get_bit_range): Likewise.
* region-model.h
(region_model_manager::get_unknown_symbolic_region): New decl.
* region.cc (symbolic_region::symbolic_region): Handle sval_ptr
having NULL type.
(symbolic_region::dump_to_pp): Handle having NULL type.

gcc/testsuite/ChangeLog:
PR analyzer/103892
* gcc.dg/analyzer/pr103892.c: New test.
* gcc.dg/analyzer/pr96841.c: Drop redundant
-Wno-analyzer-too-complex.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoUpdate semantic_interposition flag at analysis time
Jan Hubicka [Sat, 9 Apr 2022 19:22:58 +0000 (21:22 +0200)]
Update semantic_interposition flag at analysis time

This patch solves problem with FE first finalizing function and then adding
-fno-semantic-interposition flag (by parsing optimization attribute).

gcc/ChangeLog:

2022-04-09  Jan Hubicka  <hubicka@ucw.cz>

PR ipa/103376
* cgraphunit.cc (cgraph_node::analyze): update semantic_interposition
flag.

gcc/testsuite/ChangeLog:

2022-04-09  Jan Hubicka  <hubicka@ucw.cz>

PR ipa/103376
* gcc.c-torture/compile/pr103376.c: New test.

2 years agoPropagate nondeterministic and side_effects flags in modref summary after inlining
Jan Hubicka [Sat, 9 Apr 2022 19:05:52 +0000 (21:05 +0200)]
Propagate nondeterministic and side_effects flags in modref summary after inlining

gcc/ChangeLog:

2022-04-09  Jan Hubicka  <hubicka@ucw.cz>

* ipa-modref.cc (ipa_merge_modref_summary_after_inlining): Propagate
nondeterministic and side_effects flags.

gcc/testsuite/ChangeLog:

2022-04-09  Jan Hubicka  <hubicka@ucw.cz>

* gcc.dg/ipa/pr105160.c: New test.

2 years agoloongarch: testsuite: adapt stack-usage-1.c for LP64
Xi Ruoyao [Fri, 8 Apr 2022 17:58:40 +0000 (01:58 +0800)]
loongarch: testsuite: adapt stack-usage-1.c for LP64

LoongArch backend allocates two additional 8-byte stack slots for LP64,
one for saving $fp and another for saving the temporary value "1".
Ideally they are both unneeded, but (1) we're using -O0 so the code is
suboptimized by the nature; (2) any improvement (if possible) should be
deferred to GCC 13.  So for now simply adjust the test to make it pass.

gcc/testsuite/

* gcc.dg/stack-usage-1.c: Adjust for LoongArch LP64.

2 years agoloongarch: testsuite: skip builtin-apply2.c
Xi Ruoyao [Fri, 8 Apr 2022 17:37:37 +0000 (01:37 +0800)]
loongarch: testsuite: skip builtin-apply2.c

On LoongArch, variadic functions use different arugment passing
conventions so this test is not valid (see the section named "Variadic
argument" in the [ELF ABI][1]) and should be skipped.

[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

gcc/testsuite/

* gcc.dg/builtin-apply2.c (dg-skip-if): Add loongarch*-*-*.

2 years agoc++: constexpr non-trivial aggregate init [PR105191]
Jason Merrill [Fri, 8 Apr 2022 19:33:41 +0000 (15:33 -0400)]
c++: constexpr non-trivial aggregate init [PR105191]

My patch for PR92385 made us use VEC_INIT_EXPR for aggregate initialization
of an array where some elements are not explicitly initialized.  Constexpr
handling of that was treating initialization from {} as equivalent to
value-initialization, which is problematic for classes with default member
initializers that make the default constructor non-trivial; in older
standard modes, not initializing all members makes a constructor
non-constexpr, but aggregate initialization is fine.

PR c++/105191
PR c++/92385

gcc/cp/ChangeLog:

* tree.cc (build_vec_init_elt): Do {}-init for aggregates.
* constexpr.cc (cxx_eval_vec_init): Only treat {} as value-init
for non-aggregate types.
(build_vec_init_expr): Also check constancy of explicit
initializer elements.

gcc/testsuite/ChangeLog:

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

2 years agoc++: friend implicit template instantiation [PR91618]
Jason Merrill [Thu, 7 Apr 2022 03:46:53 +0000 (23:46 -0400)]
c++: friend implicit template instantiation [PR91618]

This rule that for a friend with a qualified name we try to find a
matching template was already in C++98, but it seems we never implemented
it, and nobody reported it until 2019.

This patch sets DECL_IMPLICIT_INSTANTIATION to signal to
check_explicit_specialization that we want to find a template, like
grokfndecl already did for explicit template args.  check_classfn also needs
to call it, as check_classfn is called after the call to
check_explicit_specialization in grokfndecl, whereas the call to
set_decl_namespace comes sooner.  This inconsistency is inelegant, but safer
at this point in the release cycle; I'll unify them in stage 1.

PR c++/91618
PR c++/96604

gcc/cp/ChangeLog:

* name-lookup.cc (set_decl_namespace): Set
DECL_IMPLICIT_INSTANTIATION if no non-template match.
* pt.cc (check_explicit_specialization): Check it.
* decl2.cc (check_classfn): Call it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/friend7.C: Remove xfail.
* g++.dg/template/friend72.C: New test.
* g++.dg/template/friend72a.C: New test.
* g++.dg/template/friend73.C: New test.

2 years agoDaily bump.
GCC Administrator [Sat, 9 Apr 2022 00:16:56 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Fix constraints on std::expected<void, E> constructor [PR105153]
Jonathan Wakely [Fri, 8 Apr 2022 17:26:23 +0000 (18:26 +0100)]
libstdc++: Fix constraints on std::expected<void, E> constructor [PR105153]

libstdc++-v3/ChangeLog:

PR libstdc++/105153
* include/std/expected
(expected<void,E>::expected(expected<U,G>&&)): Fix constraints.
* testsuite/20_util/expected/cons.cc: Check constructor.

2 years agolibstdc++: Fix std::expected<void, E>::swap(expected&) [PR105154]
Jonathan Wakely [Fri, 8 Apr 2022 17:17:47 +0000 (18:17 +0100)]
libstdc++: Fix std::expected<void, E>::swap(expected&) [PR105154]

libstdc++-v3/ChangeLog:

PR libstdc++/105154
* include/std/expected (expected<void, E>::swap): Set
_M_has_value to false for objects that previously had a value.
* testsuite/20_util/expected/swap.cc: Fix test to check void
specialization.

2 years agolibstdc++: Fix std::bad_expected_access constructor [PR105146]
Jonathan Wakely [Fri, 8 Apr 2022 17:04:04 +0000 (18:04 +0100)]
libstdc++: Fix std::bad_expected_access constructor [PR105146]

libstdc++-v3/ChangeLog:

PR libstdc++/105146
* include/std/expected (bad_expected_access): Move constructor
parameter.
* testsuite/20_util/expected/bad.cc: New test.

2 years agoaarch64: PR target/105157 Increase number of cores TARGET_CPU_DEFAULT can encode
Andre Vieira [Fri, 8 Apr 2022 14:12:23 +0000 (15:12 +0100)]
aarch64: PR target/105157 Increase number of cores TARGET_CPU_DEFAULT can encode

This addresses the compile-time increase seen in the PR target/105157. This was
being caused by selecting the wrong core tuning, as when we added the latest
AArch64 the TARGET_CPU_generic tuning was pushed beyond the 0x3f mask we used
to encode both target cpu and attributes into TARGET_CPU_DEFAULT.

gcc/ChangeLog:

PR target/105157
* config.gcc: Shift ext_mask by TARGET_CPU_NBITS.
* config/aarch64/aarch64.h (TARGET_CPU_NBITS): New macro.
(TARGET_CPU_MASK): Likewise.
(TARGET_CPU_DEFAULT): Use TARGET_CPU_NBITS.
* config/aarch64/aarch64.cc (aarch64_get_tune_cpu): Use TARGET_CPU_MASK.
(aarch64_get_arch): Likewise.
(aarch64_override_options): Use TARGET_CPU_NBITS.

2 years agotree-optimization/105198 - wrong code with predictive commoning
Richard Biener [Fri, 8 Apr 2022 11:13:29 +0000 (13:13 +0200)]
tree-optimization/105198 - wrong code with predictive commoning

When predictive commoning looks for a looparound PHI it tries
to match the entry value definition (a load) up with the appropriate
member of the chain.  But it fails to consider stmts clobbering
the very same memory location inbetween the load and loop entry.

In theory we could be more clever on must aliases that would be
also picked up from a load (so not exactly stmt_kills_ref_p) and
use the stored value from that if it is an exact match.  But we
currently have no way to propagate this information inside predcom.

2022-04-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105198
* tree-predcom.cc (find_looparound_phi): Check whether
the found memory location of the entry value is clobbered
inbetween the value we want to use and loop entry.

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

2 years agotestsuite: Fix up 20050113-1.c test for i686-linux [PR105187]
Jakub Jelinek [Fri, 8 Apr 2022 07:51:02 +0000 (09:51 +0200)]
testsuite: Fix up 20050113-1.c test for i686-linux [PR105187]

The test FAILs on i686-linux if neither MMX isn't enabled, can be also
reproduced with
make check-gcc check-g++ RUNTESTFLAGS='--target_board=unix/-m32/-mno-mmx/-mno-sse dg-torture.exp=20050113-1.c'
on x86_64-linux.  Previously the test was in gcc.c-torture/compile/
where -w is added by default.

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/105187
* c-c++-common/torture/20050113-1.c: Add dg-additional-options
-Wno-psabi.

2 years agoc: Error on va_arg with function type [PR105149]
Jakub Jelinek [Fri, 8 Apr 2022 07:16:30 +0000 (09:16 +0200)]
c: Error on va_arg with function type [PR105149]

In the PR Joseph said that the C standard for va_arg talks about
pointers to object type and as a function type is not object type,
it is invalid.

The following patch diagnoses it in the FE, instead of ICEing later on
when optimizations are turned on (and with -O0 doing something weird
at runtime).

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

PR c/105149
* c-typeck.cc (c_build_va_arg): Reject function types.

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

2 years agofold-const: Fix up make_range_step [PR105189]
Jakub Jelinek [Fri, 8 Apr 2022 07:14:44 +0000 (09:14 +0200)]
fold-const: Fix up make_range_step [PR105189]

The following testcase is miscompiled, because fold_truth_andor
incorrectly folds
(unsigned) foo () >= 0U && 1
into
foo () >= 0
For the unsigned comparison (which is useless in this case,
as >= 0U is always true, but hasn't been folded yet), previous
make_range_step derives exp (unsigned) foo () and +[0U, -]
range for it.  Next we process the NOP_EXPR.  We have special code
for unsigned to signed casts, already earlier punt if low or high
aren't representable in arg0_type or if it is a narrowing conversion.
For the signed to unsigned casts, I think if high is specified we
are still fine, as we punt for non-representable values in arg0_type,
n_high is then still representable and so was smaller or equal to
signed maximum and either low is not present (equivalent to 0U), or
low must be smaller or equal to high and so for unsigned exp
+[low, high] the signed exp +[n_low, n_high] will be correct.
Similarly, if both low and high aren't specified (always true or
always false), it is ok too.
But if we have for unsigned exp +[low, -] or -[low, -], using
+[n_low, -] or -[n_high, -] is incorrect.  Because low is smaller
or equal to signed maximum and high is unspecified (i.e. unsigned
maximum), when signed that range is a union of +[n_low, -] and
+[-, -1] which is equivalent to -[0, n_low-1], unless low
is 0, in that case we can treat it as [-, -].

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105189
* fold-const.cc (make_range_step): Fix up handling of
(unsigned) x +[low, -] ranges for signed x if low fits into
typeof (x).

* g++.dg/torture/pr105189.C: New test.

2 years agolibgcc: IA64: don't compile glibc-based unwinder without libc headers
Sergei Trofimovich [Thu, 7 Apr 2022 07:36:23 +0000 (08:36 +0100)]
libgcc: IA64: don't compile glibc-based unwinder without libc headers

In --without-headers mode gcc fails to bootstrap on libgcc as:

    /build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c fde-glibc.c
    ../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10:
        fatal error: stdlib.h: No such file or directory

Most other linux targets are able to build the --without-headers
compiler without additional effort. This change adds IA64 to the fold.

The change drops part of the code that relies on DYNAMIC glibc
section traversal for backtraces.

Tested bootstrap of ia64-unknown-linux-gnu with and without libc
headers present.

libgcc/
* config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode.

2 years agotree-optimization/105175 - avoid -Wvector-operation-performance
Richard Biener [Wed, 6 Apr 2022 09:18:12 +0000 (11:18 +0200)]
tree-optimization/105175 - avoid -Wvector-operation-performance

This avoids -Wvector-operation-performance diagnostics for vectorizer
produced code.  It's unfortunate the warning_at code in
tree-vect-generic.cc needs adjustments but the diagnostic suppression
code doesn't magically suppress those otherwise.

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

PR tree-optimization/105175
* tree-vect-stmts.cc (vectorizable_operation): Suppress
-Wvector-operation-performance if using emulated vectors.
* tree-vect-generic.cc (expand_vector_piecewise): Do not diagnose
-Wvector-operation-performance when suppressed.
(expand_vector_parallel): Likewise.
(expand_vector_comparison): Likewise.
(expand_vector_condition): Likewise.
(lower_vec_perm): Likewise.
(expand_vector_conversion): Likewise.

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

2 years agoDaily bump.
GCC Administrator [Fri, 8 Apr 2022 00:16:21 +0000 (00:16 +0000)]
Daily bump.

2 years agoDisable float128 tests on VxWorks, PR target/104253.
Michael Meissner [Thu, 7 Apr 2022 22:25:17 +0000 (18:25 -0400)]
Disable float128 tests on VxWorks, PR target/104253.

In PR target/104253, it was pointed out the that test case added as part
of fixing the PR does not work on VxWorks because float128 is not
supported on that system.  I have modified the three tests for float128 so
that they are manually excluded on VxWorks systems.  In looking at the
code, I also added checks in check_effective_target_ppc_ieee128_ok to
disable the systems that will never support VSX instructions which are
required for float128 support (eabi, eabispe, darwin).

2022-04-07   Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
PR target/104253
* lib/target-supports.exp (check_ppc_float128_sw_available): Do
not run float128 tests on VxWorks.
(check_ppc_float128_hw_available): Likewise.
(check_effective_target_ppc_ieee128_ok): Likewise.

2 years agoc++: use after free during name lookup w/ modules [PR99479]
Patrick Palka [Thu, 7 Apr 2022 20:09:52 +0000 (16:09 -0400)]
c++: use after free during name lookup w/ modules [PR99479]

name_lookup::search_unqualified uses a statically allocated vector
in order to avoid repeated reallocation, under the assumption that
the function can't be called recursively.  With modules however,
this assumption turns out to be false, and search_unqualified can
be called recursively as demonstrated by the testcase in comment #19
of PR99479[1] where the recursive call causes the vector to get
reallocated which invalidates the reference to queue[ix] held by the
parent call.

This patch makes search_unqualified instead use an auto_vec with 16
elements of internal storage.  In turn we can simplify the API of some
member functions to take the vector by reference and return void.

[1]: https://gcc.gnu.org/PR99479#c19

PR c++/99479

gcc/cp/ChangeLog:

* name-lookup.cc (name_lookup::using_queue): Change to an
auto_vec (with 16 elements of internal storage).
(name_lookup::queue_namespace): Change return type to void,
take queue parameter by reference and adjust function body
accordingly.
(name_lookup::do_queue_usings): Inline into ...
(name_lookup::queue_usings): ... here.  As in queue_namespace.
(name_lookup::search_unqualified): Don't make queue static,
remove length variable, and adjust function body accordingly.

2 years agotestsuite: delete slp scan from loop vect test.
Tamar Christina [Thu, 7 Apr 2022 18:53:43 +0000 (19:53 +0100)]
testsuite: delete slp scan from loop vect test.

I accidentally left in an slp1 check in the vect test which showed up as
UNRESOLVED and had missed it in the sum file.  This deletes that line.

gcc/testsuite/ChangeLog:

PR testsuite/105196
* gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c: Remove slp1 check.

2 years agoAArch64: fix ls64 intrinsics expansion [PR104409]
Tamar Christina [Thu, 7 Apr 2022 15:48:05 +0000 (16:48 +0100)]
AArch64: fix ls64 intrinsics expansion [PR104409]

The LS64 intrinsics used a machinery that's not safe to use unless being
called from a pragma instantiation.

This moves the initialization code to a new pragma for arm_acle.h.

gcc/ChangeLog:

PR target/104409
* config/aarch64/aarch64-builtins.cc (handle_arm_acle_h): New.
(aarch64_general_init_builtins): Move LS64 code.
* config/aarch64/aarch64-c.cc (aarch64_pragma_aarch64): Support
arm_acle.h
* config/aarch64/aarch64-protos.h (handle_arm_acle_h): New.
* config/aarch64/arm_acle.h: Add pragma GCC aarch64 "arm_acle.h".

2 years agoipa/104303 - miscompilation of gnatmake
Richard Biener [Thu, 7 Apr 2022 12:07:54 +0000 (14:07 +0200)]
ipa/104303 - miscompilation of gnatmake

Modref attempts to track memory accesses relative to the base pointers
which are parameters of functions.
If it fails, it still makes difference between unknown memory access and
global memory access.  The second makes it possible to disambiguate with
memory that is not accessible from outside world (i.e. everything that does
not escape from the caller function).  This is useful so we do not punt
when unknown function is called.

The added ref_may_access_global_memory_p ends up using
ptr_deref_may_alias_global_p which does not consider escaped automatic
variables as global.  For modref those are still global since they
can be accessed from functions called.

The following adds a flag to the *_global_p APIs indicating whether
escaped local memory should be considered as global or not and
removes ref_may_access_global_memory_p in favor of using
ref_may_alias_global_p with the flag set to true.

2022-04-07  Richard Biener  <rguenther@suse.de>
    Jan Hubicka  <hubicka@ucw.cz>

PR ipa/104303
* tree-ssa-alias.h (ptr_deref_may_alias_global_p,
ref_may_alias_global_p, ref_may_alias_global_p,
stmt_may_clobber_global_p, pt_solution_includes_global): Add
bool parameters indicating whether escaped locals should be
considered global.
* tree-ssa-structalias.cc (pt_solution_includes_global):
When the new escaped_nonlocal_p flag is true also consider
pt->vars_contains_escaped.
* tree-ssa-alias.cc (ptr_deref_may_alias_global_p):
Pass down new escaped_nonlocal_p flag.
(ref_may_alias_global_p): Likewise.
(stmt_may_clobber_global_p): Likewise.
(ref_may_alias_global_p_1): Likewise.  For decls also
query the escaped solution if true.
(ref_may_access_global_memory_p): Remove.
(modref_may_conflict): Use ref_may_alias_global_p with
escaped locals considered global.
(ref_maybe_used_by_stmt_p): Adjust.
* ipa-fnsummary.cc (points_to_local_or_readonly_memory_p):
Likewise.
* tree-ssa-dse.cc (dse_classify_store): Likewise.
* trans-mem.cc (thread_private_new_memory): Likewise, but
consider escaped locals global.
* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Likewise.

* gnat.dg/concat5.adb: New.
* gnat.dg/concat5_pkg1.adb: Likewise.
* gnat.dg/concat5_pkg1.ads: Likewise.
* gnat.dg/concat5_pkg2.adb: Likewise.
* gnat.dg/concat5_pkg2.ads: Likewise.

2 years agoanalyzer: fix leak false +ve with symbolic writes [PR102208]
David Malcolm [Thu, 7 Apr 2022 12:33:26 +0000 (08:33 -0400)]
analyzer: fix leak false +ve with symbolic writes [PR102208]

PR analyzer/102208 reports false positives from -Wanalyzer-malloc-leak.
The root cause is the analyzer getting confused about symbolic writes
that could alias a pointer referencing a malloced buffer.

struct st
{
  void *ptr;
  int arr[10];
};

struct st test (int idx)
{
  struct st s;
  s.ptr = __builtin_malloc (1024);  /* (1) */
  s.arr[idx] = 42;                  /* (2) */
  return s;
}

When removing overlapping bindings at (2),
store::remove_overlapping_bindings was failing to pass on the
uncertainty_t *, and thus when clobbering the binding of s.ptr, the
heap-allocated pointer was not being added to the set of maybe-bound
svalues, and thus being treated as leaking.

This patch fixes this, so that s.ptr from (1) is treated as maybe-bound
after the write at (2), fixing the leak false postive.

Doing so requires the store to be smarter about how clobbering happens
with various combinations of concrete keys and symbolic keys within
concrete clusters and symbolic clusters, so that we don't lose warnings
about definite leaks.

gcc/analyzer/ChangeLog:
PR analyzer/102208
* store.cc (binding_map::remove_overlapping_bindings): Add
"always_overlap" param, using it to generalize to the case where
we want to remove all bindings.  Update "uncertainty" logic to
only record maybe-bound values for cases where there is a symbolic
write involved.
(binding_cluster::mark_region_as_unknown): Split param "reg" into
"reg_to_bind" and "reg_for_overlap".
(binding_cluster::maybe_get_compound_binding): Pass "false" to
binding_map::remove_overlapping_bindings new "always_overlap" param.
(binding_cluster::remove_overlapping_bindings): Determine
"always_overlap" and pass it to
binding_map::remove_overlapping_bindings.
(store::set_value): Pass uncertainty to remove_overlapping_bindings
call.  Update for new param of
binding_cluster::mark_region_as_unknown, passing both the base
region of the iter_cluster, and the lhs_reg.
(store::mark_region_as_unknown): Update for new param of
binding_cluster::mark_region_as_unknown, passing "reg" for both.
(store::remove_overlapping_bindings): Add param "uncertainty", and
pass it on to call to
binding_cluster::remove_overlapping_bindings.
* store.h (binding_map::remove_overlapping_bindings): Add
"always_overlap" param.
(binding_cluster::mark_region_as_unknown): Split param "reg" into
"reg_to_bind" and "reg_for_overlap".
(store::remove_overlapping_bindings): Add param "uncertainty".

gcc/testsuite/ChangeLog:
PR analyzer/102208
* gcc.dg/analyzer/symbolic-9.c: New test.
* gcc.dg/analyzer/torture/leak-pr102308-1.c: New test.
* gcc.dg/analyzer/torture/leak-pr102308-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agotree-optimization/105185 - simplify modref query in SCCVN
Richard Biener [Thu, 7 Apr 2022 07:16:50 +0000 (09:16 +0200)]
tree-optimization/105185 - simplify modref query in SCCVN

This simplifies the modref query for calls in SCCVN again after
r12-8019-g4be08315124281, avoiding an ICE when the modref
analyzed access lacks an actual argument on the caller side.
It effectively reverts r12-7531-gdc46350d44c294.

2022-04-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105185
* tree-ssa-sccvn.cc (visit_reference_op_call): Simplify
modref query again.

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

2 years agoAArch64: Fix left fold sum reduction RTL patterns [PR104049]
Tamar Christina [Thu, 7 Apr 2022 07:27:53 +0000 (08:27 +0100)]
AArch64: Fix left fold sum reduction RTL patterns [PR104049]

As the discussion in the PR pointed out the RTL we have for the REDUC_PLUS
patterns are wrong.  The UNSPECs are modelled as returning a vector and then
in an expand pattern we emit a vec_select of the 0th element to get the scalar.

This is incorrect as the instruction itself already only returns a single scalar
and by declaring it returns a vector it allows combine to push in a subreg into
the pattern, which causes reload to make duplicate moves.

This patch corrects this by removing the weird indirection and making the RTL
pattern model the correct semantics of the instruction immediately.

gcc/ChangeLog:

PR target/104049
* config/aarch64/aarch64-simd.md
(aarch64_reduc_plus_internal<mode>): Fix RTL and rename to...
(reduc_plus_scal_<mode>): ... This.
(reduc_plus_scal_v4sf): Moved.
(aarch64_reduc_plus_internalv2si): Fix RTL and rename to...
(reduc_plus_scal_v2si): ... This.

gcc/testsuite/ChangeLog:

PR target/104049
* gcc.target/aarch64/vadd_reduc-1.c: New test.
* gcc.target/aarch64/vadd_reduc-2.c: New test.

2 years agotestsuite: enable fast-math-complex-* testcases.
Tamar Christina [Thu, 7 Apr 2022 07:26:36 +0000 (08:26 +0100)]
testsuite: enable fast-math-complex-* testcases.

As pointed out in PR105095 these tests weren't running, mainly because the .exp
file contains a filter on the first character so it can distinguish between
fast-math-bb-slp-* and fast-math-*, my test started with `c` and so didn't get
found.

This patch adds `c` to the list of filters and also updates the output and
required guards for the testcases now that they run.

gcc/testsuite/ChangeLog:

PR testsuite/105095
* gcc.dg/vect/complex/fast-math-complex-add-double.c: Update for codegen.
* gcc.dg/vect/complex/fast-math-complex-add-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-half-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mls-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mls-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mul-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mul-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c: Likewise.
* gcc.dg/vect/vect.exp: Add extra letter to filter.

2 years agotestsuite: skip PR103350 tests on big-endian
Tamar Christina [Thu, 7 Apr 2022 07:26:02 +0000 (08:26 +0100)]
testsuite: skip PR103350 tests on big-endian

These tests are reduced from a C program and use gcc vector extensions and so
aren't endianness agnostic. As such skip them on BE.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr103350-1.c: Skip on BE.
* gcc.target/aarch64/pr103350-2.c: Likewise.

2 years agoc++: Handle __builtin_clear_padding on non-trivially-copyable types [PR102586]
Jakub Jelinek [Thu, 7 Apr 2022 07:14:07 +0000 (09:14 +0200)]
c++: Handle __builtin_clear_padding on non-trivially-copyable types [PR102586]

On Fri, Feb 11, 2022 at 07:55:50PM +0100, Jakub Jelinek via Gcc-patches wrote:
> Something like the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c16
> will still be needed with adjusted testcase from
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c15 such that
> __builtin_clear_padding is called directly on var addresses rather than
> in separate functions.

Here is an updated version of the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c15
patch which uses FIELD_DECL in the langhook instead of its TREE_TYPE,
and the testcases have been adjusted for the builtin accepting
pointers to non-trivially-copyable types only if it is address of a
declaration.

2022-04-07  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/102586
gcc/
* langhooks.h (struct lang_hooks_for_types): Add classtype_as_base
langhook.
* langhooks-def.h (LANG_HOOKS_CLASSTYPE_AS_BASE): Define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add it.
* gimple-fold.cc (clear_padding_type): Use ftype instead of
TREE_TYPE (field) some more.  For artificial FIELD_DECLs without
name try the lang_hooks.types.classtype_as_base langhook and
if it returns non-NULL, use that instead of ftype for recursive call.
gcc/cp/
* cp-objcp-common.h (cp_classtype_as_base): Declare.
(LANG_HOOKS_CLASSTYPE_AS_BASE): Redefine.
* cp-objcp-common.cc (cp_classtype_as_base): New function.
gcc/testsuite/
* g++.dg/torture/builtin-clear-padding-5.C: New test.
* g++.dg/cpp2a/builtin-clear-padding1.C (bar): Uncomment one
call that is now accepted.

2 years agotree.cc: Add tree_builtin_call_types_compatible_p [PR105150]
Jakub Jelinek [Thu, 7 Apr 2022 07:10:58 +0000 (09:10 +0200)]
tree.cc: Add tree_builtin_call_types_compatible_p [PR105150]

And here is the follow-up patch that does the argument checking
on GENERIC.  It ensures TYPE_MAIN_VARIANT == TYPE_MAIN_VARIANT
compatibility on the arguments, except for pointer arguments
where both builtin's prototype and actual arguments have to be
pointers and satisfy tree_nop_conversion_p, and for promoted
char/short arguments where argument need to have integral
signed type tree_nop_conversion_p compatible with integer_type_node.

2022-04-07  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105150
* tree.cc (tree_builtin_call_types_compatible_p): New function.
(get_call_combined_fn): Use it.

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

2 years agomiddle-end/105165 - sorry instead of ICE for _Complex asm goto
Richard Biener [Wed, 6 Apr 2022 11:46:56 +0000 (13:46 +0200)]
middle-end/105165 - sorry instead of ICE for _Complex asm goto

Complex lowering cannot currently deal with asm gotos with _Complex
output operands.  Emit a sorry instead of ICEing, those should not
appear in practice.

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

PR middle-end/105165
* tree-complex.cc (expand_complex_asm): Sorry for asm goto
_Complex outputs.

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

2 years agoIBM zSystems/testsuite: PR105147: Skip pr105140.c
Andreas Krebbel [Thu, 7 Apr 2022 05:29:13 +0000 (07:29 +0200)]
IBM zSystems/testsuite: PR105147: Skip pr105140.c

pr105140.c fails on IBM zSystems with "vector argument passed to
unprototyped function".  s390_invalid_arg_for_unprototyped_fn in
s390.cc is triggered by that.

gcc/testsuite/ChangeLog:

PR target/105147
* gcc.dg/pr105140.c: Skip for s390*-*-*.