platform/upstream/gcc.git
16 months agoFortran: Add support for WEAK attribute for variables
Rimvydas Jasinskas [Fri, 24 Feb 2023 04:41:00 +0000 (04:41 +0000)]
Fortran: Add support for WEAK attribute for variables

Add the rest of the weak-*.f90 testcases.

gcc/fortran/ChangeLog:

* trans-decl.cc (gfc_finish_var_decl): Apply attribute.
(generate_local_decl): Add diagnostic for dummy and local variables.

gcc/testsuite/ChangeLog:

* gfortran.dg/weak-2.f90: New test.
* gfortran.dg/weak-3.f90: New test.

Signed-off-by: Rimvydas Jasinskas <rimvydas.jas@gmail.com>
16 months agofortran: Plug leak of associated_dummy memory. [PR108923]
Mikael Morin [Fri, 24 Feb 2023 21:11:17 +0000 (22:11 +0100)]
fortran: Plug leak of associated_dummy memory. [PR108923]

This fixes a memory leak by accompanying the release of
gfc_actual_arglist elements' memory with a release of the
associated_dummy field memory (if allocated).
Actual argument copy is adjusted as well so that each copy can free
its field independently.

PR fortran/108923

gcc/fortran/ChangeLog:

* expr.cc (gfc_free_actual_arglist): Free associated_dummy
memory.
(gfc_copy_actual_arglist): Make a copy of the associated_dummy
field if it is set in the original element.

16 months agoFortran: frontend passes do_subscript leaks gmp memory [PR108924]
Harald Anlauf [Fri, 24 Feb 2023 18:56:32 +0000 (19:56 +0100)]
Fortran: frontend passes do_subscript leaks gmp memory [PR108924]

gcc/fortran/ChangeLog:

PR fortran/108924
* frontend-passes.cc (do_subscript): Clear used gmp variable.

16 months agolibstdc++: Fix formatting
Matthias Kretz [Tue, 21 Feb 2023 07:48:18 +0000 (08:48 +0100)]
libstdc++: Fix formatting

Whitespace changes only.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h: Line breaks and indenting
fixed to follow the libstdc++ standard.
* include/experimental/bits/simd_builtin.h: Likewise.
* include/experimental/bits/simd_fixed_size.h: Likewise.
* include/experimental/bits/simd_neon.h: Likewise.
* include/experimental/bits/simd_ppc.h: Likewise.
* include/experimental/bits/simd_scalar.h: Likewise.
* include/experimental/bits/simd_x86.h: Likewise.

16 months agolibstdc++: Always-inline most of non-cmath fixed_size implementation
Matthias Kretz [Mon, 20 Feb 2023 16:49:37 +0000 (17:49 +0100)]
libstdc++: Always-inline most of non-cmath fixed_size implementation

For simd, the inlining behavior should be similar to builtin types. (No
operator on buitin types is ever translated into a function call.)
Therefore, always_inline is the right choice (i.e. inline on -O0 as
well).

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/108030
* include/experimental/bits/simd_fixed_size.h
(_SimdImplFixedSize::_S_broadcast): Replace inline with
_GLIBCXX_SIMD_INTRINSIC.
(_SimdImplFixedSize::_S_generate): Likewise.
(_SimdImplFixedSize::_S_load): Likewise.
(_SimdImplFixedSize::_S_masked_load): Likewise.
(_SimdImplFixedSize::_S_store): Likewise.
(_SimdImplFixedSize::_S_masked_store): Likewise.
(_SimdImplFixedSize::_S_min): Likewise.
(_SimdImplFixedSize::_S_max): Likewise.
(_SimdImplFixedSize::_S_complement): Likewise.
(_SimdImplFixedSize::_S_unary_minus): Likewise.
(_SimdImplFixedSize::_S_plus): Likewise.
(_SimdImplFixedSize::_S_minus): Likewise.
(_SimdImplFixedSize::_S_multiplies): Likewise.
(_SimdImplFixedSize::_S_divides): Likewise.
(_SimdImplFixedSize::_S_modulus): Likewise.
(_SimdImplFixedSize::_S_bit_and): Likewise.
(_SimdImplFixedSize::_S_bit_or): Likewise.
(_SimdImplFixedSize::_S_bit_xor): Likewise.
(_SimdImplFixedSize::_S_bit_shift_left): Likewise.
(_SimdImplFixedSize::_S_bit_shift_right): Likewise.
(_SimdImplFixedSize::_S_remquo): Add inline keyword (to be
explicit about not always-inline, yet).
(_SimdImplFixedSize::_S_isinf): Likewise.
(_SimdImplFixedSize::_S_isfinite): Likewise.
(_SimdImplFixedSize::_S_isnan): Likewise.
(_SimdImplFixedSize::_S_isnormal): Likewise.
(_SimdImplFixedSize::_S_signbit): Likewise.

16 months agolibstdc++: More efficient masked inc-/decrement implementation
Matthias Kretz [Mon, 20 Feb 2023 15:33:31 +0000 (16:33 +0100)]
libstdc++: More efficient masked inc-/decrement implementation

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/108856
* include/experimental/bits/simd_builtin.h
(_SimdImplBuiltin::_S_masked_unary): More efficient
implementation of masked inc-/decrement for integers and floats
without AVX2.
* include/experimental/bits/simd_x86.h
(_SimdImplX86::_S_masked_unary): New. Use AVX512 masked subtract
builtins for masked inc-/decrement.

16 months agoAvoid default-initializing auto_vec<T, N> storage, fix vec<vl_embed>
Richard Biener [Thu, 23 Feb 2023 10:56:17 +0000 (11:56 +0100)]
Avoid default-initializing auto_vec<T, N> storage, fix vec<vl_embed>

The following avoids default-initializing auto_vec storage for
non-POD T since that's not what the allocated storage fallback
will do and it's also not expected for existing cases like

  auto_vec<std::pair<unsigned, unsigned>, 64> elts;

which exist to optimize the allocation.

It also fixes the array accesses done by vec<vl_embed> to not
use its own m_vecdata member but instead access the container
provided storage via pointer arithmetic.

* vec.h (vec<T, A, vl_embed>::m_vecdata): Remove.
(vec<T, A, vl_embed>::m_vecpfx): Align as T to avoid
changing alignment of vec<T, A, vl_embed> and simplifying
address.
(vec<T, A, vl_embed>::address): Compute as this + 1.
(vec<T, A, vl_embed>::embedded_size): Use sizeof the
vector instead of the offset of the m_vecdata member.
(auto_vec<T, N>::m_data): Turn storage into
uninitialized unsigned char.
(auto_vec<T, N>::auto_vec): Allow allocation of one
stack member.  Initialize m_vec in a special way to
avoid later stringop overflow diagnostics.
* vec.cc (test_auto_alias): New.
(vec_cc_tests): Call it.

16 months agoChange vec<,,vl_embed>::m_vecdata refrences into address ()
Richard Biener [Fri, 24 Feb 2023 08:54:09 +0000 (09:54 +0100)]
Change vec<,,vl_embed>::m_vecdata refrences into address ()

As preparation to remove m_vecdata in the vl_embed vector this
changes references to it into calls to address ().

As I was here it also fixes ::contains to avoid repeated bounds
checking and the same issue in ::lower_bound which also suffers
from unnecessary copying around values.

* vec.h (vec<T, A, vl_embed>::lower_bound): Adjust to
take a const reference to the object, use address to
access data.
(vec<T, A, vl_embed>::contains): Use address to access data.
(vec<T, A, vl_embed>::operator[]): Use address instead of
m_vecdata to access data.
(vec<T, A, vl_embed>::iterate): Likewise.
(vec<T, A, vl_embed>::copy): Likewise.
(vec<T, A, vl_embed>::quick_push): Likewise.
(vec<T, A, vl_embed>::pop): Likewise.
(vec<T, A, vl_embed>::quick_insert): Likewise.
(vec<T, A, vl_embed>::ordered_remove): Likewise.
(vec<T, A, vl_embed>::unordered_remove): Likewise.
(vec<T, A, vl_embed>::block_remove): Likewise.
(vec<T, A, vl_heap>::address): Likewise.

16 months agoasan: adjust module name for global variables
Martin Liska [Fri, 17 Feb 2023 14:11:02 +0000 (15:11 +0100)]
asan: adjust module name for global variables

As mentioned in the PR, when we use LTO, we wrongly use ltrans output
file name as a module name of a global variable. That leads to a
non-reproducible output.

After the suggested change, we emit context name of normal global
variables. And for artificial variables (like .Lubsan_data3), we use
aux_base_name (e.g. "./a.ltrans0.ltrans").

PR sanitizer/108834

gcc/ChangeLog:

* asan.cc (asan_add_global): Use proper TU name for normal
global variables (and aux_base_name for the artificial one).

gcc/testsuite/ChangeLog:

* c-c++-common/asan/global-overflow-1.c: Test line and column
info for a global variable.

16 months ago[PR105224] C++ modules and AAPCS/ARM EABI clash on inline key methods
Alexandre Oliva [Fri, 24 Feb 2023 14:31:05 +0000 (11:31 -0300)]
[PR105224] C++ modules and AAPCS/ARM EABI clash on inline key methods

g++.dg/modules/virt-2_a.C fails on arm-eabi and many other arm targets
that use the AAPCS variant.  ARM is the only target that overrides
TARGET_CXX_KEY_METHOD_MAY_BE_INLINE.  It's not clear to me which way
the clash between AAPCS and C++ Modules design should be resolved, but
currently it favors AAPCS and thus the test fails, so skip it on
arm_eabi.

for  gcc/testsuite/ChangeLog

PR c++/105224
* g++.dg/modules/virt-2_a.C: Skip on arm_eabi.

16 months agolibstdc++: Constrain net::executor constructors
Jonathan Wakely [Fri, 24 Feb 2023 13:03:49 +0000 (13:03 +0000)]
libstdc++: Constrain net::executor constructors

The TS says the arguments to these constructors shall meet the Executor
requirements, so it's undefined if they don't. Constraining on a subset
of those requirements won't affect valid cases, but prevents the
majority of invalid cases from trying to instantiate the constructor.

This prevents the non-explicit executor(Executor) constructor being a
candidate anywhere that a net::executor could be constructed e.g.
comparing ip::tcp::v4() == ip::udp::v4() would try to convert both
operands to executor using that constructor, then compare then using
operator==(const executor&, const executor&).

libstdc++-v3/ChangeLog:

* include/experimental/executor (executor): Constrain template
constructors.

16 months agolibstdc++: Make net::ip::basic_endpoint comparisons constexpr
Jonathan Wakely [Fri, 24 Feb 2023 13:00:41 +0000 (13:00 +0000)]
libstdc++: Make net::ip::basic_endpoint comparisons constexpr

libstdc++-v3/ChangeLog:

* include/experimental/internet (basic_endpoint): Add missing
constexpr to comparison operators.
* testsuite/experimental/net/internet/endpoint/cons.cc: New test.

16 months agolibstdc++: Fix members of net::ip::network_v4
Jonathan Wakely [Fri, 24 Feb 2023 12:21:06 +0000 (12:21 +0000)]
libstdc++: Fix members of net::ip::network_v4

libstdc++-v3/ChangeLog:

* include/experimental/internet (network_v4::netmask()): Avoid
undefined shift.
(network_v4::broadcast()): Optimize and fix for targets with
uint_least32_t wider than 32 bits.
(network_v4::to_string(const Allocator&)): Fix for custom
allocators and optimize using to_chars.
(operator==(const network_v4&, const network_v4&)): Add missing
constexpr.
(operator==(const network_v6&, const network_v6&)): Likewise.
* testsuite/experimental/net/internet/network/v4/cons.cc: New test.
* testsuite/experimental/net/internet/network/v4/members.cc: New test.

16 months agolibstdc++: Fix conversion to/from net::ip::address_v4::bytes_type
Jonathan Wakely [Fri, 24 Feb 2023 10:08:26 +0000 (10:08 +0000)]
libstdc++: Fix conversion to/from net::ip::address_v4::bytes_type

I messed up the endianness of the address_v4::bytes_type array, which
should always be in network byte order. We can just use bit_cast to
convert the _M_addr member to/from bytes_type.

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_4(const bytes_type&)):
Use __builtin_bit_cast if available, otherwise convert to
network byte order.
(address_v4::to_bytes()): Likewise, but convert from network
byte order.
* testsuite/experimental/net/internet/address/v4/cons.cc: Fix
incorrect tests. Check for constexpr too.
* testsuite/experimental/net/internet/address/v4/creation.cc:
Likewise.
* testsuite/experimental/net/internet/address/v4/members.cc:
Check that bytes_type is a standard-layout type.

16 months agolibstdc++: Optimize net::ip::address_v4::to_string()
Jonathan Wakely [Thu, 23 Feb 2023 17:39:33 +0000 (17:39 +0000)]
libstdc++: Optimize net::ip::address_v4::to_string()

This is an order of magnitude faster than calling inet_ntop (and not
only because we now avoid allocating a string that is one byte larger
than the SSO buffer).

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v4::to_string):
Optimize.
* testsuite/experimental/net/internet/address/v4/members.cc:
Check more addresses.

16 months agolibstdc++: Suppress warnings about use of deprecated std::aligned_storage
Jonathan Wakely [Thu, 23 Feb 2023 17:37:59 +0000 (17:37 +0000)]
libstdc++: Suppress warnings about use of deprecated std::aligned_storage

libstdc++-v3/ChangeLog:

* include/ext/aligned_buffer.h (__aligned_buffer): Add
diagnostic pragmas.

16 months agolibstdc++: Reorder dg-options before dg-do
Jonathan Wakely [Thu, 16 Feb 2023 15:31:22 +0000 (15:31 +0000)]
libstdc++: Reorder dg-options before dg-do

The options need to be set first, so that -std=gnu++20 is used when
checking the c++20 effective target.

libstdc++-v3/ChangeLog:

* testsuite/std/format/arguments/lwg3810.cc: Move dg-options
before dg-do.

16 months agoi386: Update i386-builtin.def file comment description of BDESC{,_FIRST}
Jakub Jelinek [Fri, 24 Feb 2023 12:07:58 +0000 (13:07 +0100)]
i386: Update i386-builtin.def file comment description of BDESC{,_FIRST}

I've noticed the description of these wasn't updated when the mask2
argument has been added in 2019.

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

* config/i386/i386-builtin.def: Update description of BDESC
and BDESC_FIRST in file comment to include mask2.

16 months agoaarch64: Update FLAGS field documentation comment in aarch64-cores.def
Kyrylo Tkachov [Fri, 24 Feb 2023 11:41:28 +0000 (11:41 +0000)]
aarch64: Update FLAGS field documentation comment in aarch64-cores.def

With the cleanup of the arch features in GCC 13 the comment on the FLAGS field in aarch64-cores.def
is now outdated. It's now a comma-separated list rather than a bitwise or.
Spotted while reviewing an aarch64-cores.def patch.
Update the comment.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (FLAGS): Update comment.

16 months agocgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk ...
Jakub Jelinek [Fri, 24 Feb 2023 10:05:27 +0000 (11:05 +0100)]
cgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk [PR108854]

The following testcase ICEs on x86_64-linux with -m32.  The problem is
we create an artificial thunk and because of -fPIC, ia32 and thunk
destination which doesn't bind locally can't use a mi thunk.
The ICE is because during expansion to RTL we see SSA_NAME for a PARM_DECL,
but the PARM_DECL doesn't have DECL_CONTEXT of the current function.
This is because duplicate_thunk_for_node creates a new DECL_ARGUMENTS chain
only if some arguments need modification.

The following patch fixes it by copying the DECL_ARGUMENTS list even if
the arguments can stay as is, to update DECL_CONTEXT on them.  While for
mi thunks it doesn't really matter because we don't use those arguments
in any way, for other thunks it is important.

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

PR middle-end/108854
* cgraphclones.cc (duplicate_thunk_for_node): If no parameter
changes are needed, copy at least DECL_ARGUMENTS PARM_DECL
nodes and adjust their DECL_CONTEXT.

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

16 months agoi386: Fix up builtins used in avx512bf16vlintrin.h [PR108881]
Jakub Jelinek [Fri, 24 Feb 2023 09:12:44 +0000 (10:12 +0100)]
i386: Fix up builtins used in avx512bf16vlintrin.h [PR108881]

The builtins used in avx512bf16vlintrin.h implementation need both
avx512bf16 and avx512vl ISAs, which the header ensures for them, but
the builtins weren't actually requiring avx512vl, so when used by hand
with just -mavx512bf16 -mno-avx512vl it resulted in ICEs.

Fixed by adding OPTION_MASK_ISA_AVX512VL to their BDESC.

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

PR target/108881
* config/i386/i386-builtin.def (__builtin_ia32_cvtne2ps2bf16_v16bf,
__builtin_ia32_cvtne2ps2bf16_v16bf_mask,
__builtin_ia32_cvtne2ps2bf16_v16bf_maskz,
__builtin_ia32_cvtne2ps2bf16_v8bf,
__builtin_ia32_cvtne2ps2bf16_v8bf_mask,
__builtin_ia32_cvtne2ps2bf16_v8bf_maskz,
__builtin_ia32_cvtneps2bf16_v8sf_mask,
__builtin_ia32_cvtneps2bf16_v8sf_maskz,
__builtin_ia32_cvtneps2bf16_v4sf_mask,
__builtin_ia32_cvtneps2bf16_v4sf_maskz,
__builtin_ia32_dpbf16ps_v8sf, __builtin_ia32_dpbf16ps_v8sf_mask,
__builtin_ia32_dpbf16ps_v8sf_maskz, __builtin_ia32_dpbf16ps_v4sf,
__builtin_ia32_dpbf16ps_v4sf_mask,
__builtin_ia32_dpbf16ps_v4sf_maskz): Require also
OPTION_MASK_ISA_AVX512VL.

* gcc.target/i386/avx512bf16-pr108881.c: New test.

16 months agolibsanitizer: cherry-pick commit 8f5962b1ccb5fcd4d4544121d43efb860ac3cc6d from upstream
Martin Liska [Fri, 24 Feb 2023 08:14:40 +0000 (09:14 +0100)]
libsanitizer: cherry-pick commit 8f5962b1ccb5fcd4d4544121d43efb860ac3cc6d from upstream

ASAN: keep support for Global::location

We as GCC still emit __asan_global_source_location for global variables
and we would like to use it in the future. On other hand, we don't
support llvm-symbolizer and the default libbacktraace symbolizer
does not support location info.

16 months agoRTEMS: Tune multilib selection
Sebastian Huber [Wed, 22 Feb 2023 20:38:18 +0000 (21:38 +0100)]
RTEMS: Tune multilib selection

gcc/ChangeLog:

* config/riscv/t-rtems: Keep only -mcmodel=medany 64-bit multilibs.
Add non-compact 32-bit multilibs.

16 months agoMIPS: Add pattern for clo
Junxian Zhu [Fri, 17 Feb 2023 08:35:56 +0000 (16:35 +0800)]
MIPS: Add pattern for clo

gcc/ChangeLog:

* config/mips/mips.md (*clo<mode>2): New pattern.

gcc/testsuite/ChangeLog:

* gcc.target/mips/clz.c: New test.
* gcc.target/mips/clo.c: New test.
* gcc.target/mips/mips.exp: New option HAS_CLZ.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
16 months agoHazard barrier return support
Junxian Zhu [Fri, 17 Feb 2023 08:24:55 +0000 (16:24 +0800)]
Hazard barrier return support

This patch allows a function to request clearing of all instruction and execution
hazards upon normal return via __attribute__ ((use_hazard_barrier_return)).

2017-04-25  Prachi Godbole  <prachi.godbole@imgtec.com>

gcc/ChangeLog:

* config/mips/mips.h (machine_function): New variable
use_hazard_barrier_return_p.
* config/mips/mips.md (UNSPEC_JRHB): New unspec.
(mips_hb_return_internal): New insn pattern.
* config/mips/mips.cc (mips_attribute_table): Add attribute
use_hazard_barrier_return.
(mips_use_hazard_barrier_return_p): New static function.
(mips_function_attr_inlinable_p): Likewise.
(mips_compute_frame_info): Set use_hazard_barrier_return_p.
Emit error for unsupported architecture choice.
(mips_function_ok_for_sibcall, mips_can_use_return_insn):
Return false for use_hazard_barrier_return.
(mips_expand_epilogue): Emit hazard barrier return.
* doc/extend.texi: Document use_hazard_barrier_return.

gcc/testsuite/ChangeLog:

* gcc.target/mips/hazard-barrier-return-attribute.c: New test.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
16 months agoDaily bump.
GCC Administrator [Fri, 24 Feb 2023 00:17:09 +0000 (00:17 +0000)]
Daily bump.

16 months agogcc: xtensa: update include style in xtensa-dynconfig.cc
Max Filippov [Thu, 23 Feb 2023 23:50:29 +0000 (15:50 -0800)]
gcc: xtensa: update include style in xtensa-dynconfig.cc

gcc/
* config/xtensa/xtensa-dynconfig.cc (config.h, system.h)
(coretypes.h, diagnostic.h, intl.h): Use "..." instead of <...>
for the gcc-internal headers.

16 months agogcc: xtensa: rename xtensa-dynconfig.c and update its build rule
Max Filippov [Thu, 23 Feb 2023 23:43:48 +0000 (15:43 -0800)]
gcc: xtensa: rename xtensa-dynconfig.c and update its build rule

gcc/
* config/xtensa/t-xtensa (xtensa-dynconfig.o): Use $(COMPILE)
and $(POSTCOMPILE) instead of manual dependency listing.
* config/xtensa/xtensa-dynconfig.c: Rename to ...
* config/xtensa/xtensa-dynconfig.cc: ... this.

16 months ago**/*.texi: Reorder index entries
Arsen Arsenović [Thu, 23 Feb 2023 10:27:11 +0000 (11:27 +0100)]
**/*.texi: Reorder index entries

This change is a generalization of r13-6292-gddf6fe375d9110.

Historically, makeinfo exhibited a bug, due to which a structure like:

  @item foo
  @cindex foo
  @cindex bar

... would be transformed into an item heading, with the first index
entry on it, followed by an item body, with the second index entry in
it.  This has often lead to index entries not linking to relevant items,
but rather, just below them.

This bug was exhibited in both Info and HTML documentation, and was most
glaringly obvious in the latter.

After a discussion with the Texinfo developers, it was decided that the
appropriate construct for this case is:

  @cindex foo
  @cindex bar
  @item foo

... which behaves correctly in newer versions, linking all the index
entries to the item itself.  This pattern also produces copiable
anchors in HTML output.

This commit fixes most indices to follow the pattern above, however,
omits relevant changes in the Ada manuals, as the algorithm described
below lead to many false positives and unwanted changes in that manual.

Much like the previous commit, this change is mostly mechanical, with a
simple script.  I have, however, gone over the patch myself also, to see
if there's anything that ought to be kept as-is.  Formatter:

  # GPL3+
  use v5.35;
  use strict;
  use warnings;

  my @lineq = ();
  my @itemq = ();
  my @indxq = ();
  my $lstin = 0;

  while (<>)
    {
      push (@lineq, $_);
      if (/^\@[a-zA-Z0-9]{1,2}index\W/)
        {
          $lstin = @lineq;
          push (@indxq, $_);
          next;
        }
      if (/^\@itemx?\W/)
        {
          $lstin = @lineq;
          push (@itemq, $_);
          next;
        }
      next if $lstin && /^\s*(\@c(omment)?\W.*)?$/;

      if (@indxq and @itemq)
        {
          print @indxq;
          print @itemq;
          print @lineq[$lstin..@lineq-1];
        }
      else
        {
          print @lineq;
        }
      @lineq = ();
      @itemq = ();
      @indxq = ();
      $lstin = 0;
    }

  if (@indxq and @itemq)
    {
      print @indxq;
      print @itemq;
      print @lineq[$lstin..@lineq-1];
    }
  else
    {
      print @lineq;
    }

  # Local Variables:
  # indent-tabs-mode: nil
  # End:

gcc/d/ChangeLog:

* implement-d.texi: Reorder index entries around @items.

gcc/ChangeLog:

* doc/cfg.texi: Reorder index entries around @items.
* doc/cpp.texi: Ditto.
* doc/cppenv.texi: Ditto.
* doc/cppopts.texi: Ditto.
* doc/generic.texi: Ditto.
* doc/install.texi: Ditto.
* doc/extend.texi: Ditto.
* doc/invoke.texi: Ditto.
* doc/md.texi: Ditto.
* doc/rtl.texi: Ditto.
* doc/tm.texi.in: Ditto.
* doc/trouble.texi: Ditto.
* doc/tm.texi: Regenerate.

gcc/fortran/ChangeLog:

* invoke.texi: Reorder index entries around @items.

gcc/go/ChangeLog:

* gccgo.texi: Reorder index entries around @items.

16 months agoxtensa: Eliminate unnecessary general-purpose reg-reg moves
Takayuki 'January June' Suwa [Sat, 18 Feb 2023 04:43:34 +0000 (13:43 +0900)]
xtensa: Eliminate unnecessary general-purpose reg-reg moves

Register-register move instructions that can be easily seen as
unnecessary by the human eye may remain in the compiled result.
For example:

/* example */
double test(double a, double b) {
  return __builtin_copysign(a, b);
}

test:
add.n a3, a3, a3
extui a5, a5, 31, 1
ssai 1
;; Be in the same BB
src a7, a5, a3 ;; Replacing the destination doesn't
;;   violate any constraints of the
;;   operands
;; No CALL insns in this span
;; Both A3 and A7 are irrelevant to
;;   insns in this span
mov.n a3, a7 ;; An unnecessary reg-reg move
;; A7 is not used after this
ret.n

The last two instructions above, excluding the return instruction,
could be done like this:

src a3, a5, a3

This symptom often occurs when handling DI/DFmode values with SImode
instructions.  This patch solves the above problem using peephole2
pattern.

gcc/ChangeLog:

* config/xtensa/xtensa.md: New peephole2 pattern that eliminates
the occurrence of general-purpose register used only once and for
transferring intermediate value.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/elim_GP_regmove_0.c: New test.
* gcc.target/xtensa/elim_GP_regmove_1.c: New test.

16 months agoxtensa: Eliminate the use of callee-saved register that saves and restores only once
Takayuki 'January June' Suwa [Fri, 27 Jan 2023 03:17:33 +0000 (12:17 +0900)]
xtensa: Eliminate the use of callee-saved register that saves and restores only once

In the case of the CALL0 ABI, values that must be retained before and
after function calls are placed in the callee-saved registers (A12
through A15) and referenced later.  However, it is often the case that
the save and the reference are each only once and a simple register-
register move (with two exceptions; i. the register saved to/restored
from is the stack pointer, ii. the function needs an additional stack
pointer adjustment to grow the stack).

e.g. in the following example, if there are no other occurrences of
register A14:

;; before
; prologue {
  ...
s32i.n a14, sp, 16
  ... ;; no frame pointer needed
;; no additional stack growth
; } prologue
  ...
mov.n a14, a6 ;; A6 is not SP
  ...
call0 foo
  ...
mov.n a8, a14 ;; A8 is not SP
  ...
; epilogue {
  ...
l32i.n a14, sp, 16
  ...
; } epilogue

It can be possible like this:

;; after
; prologue {
  ...
(no save needed)
  ...
; } prologue
  ...
s32i.n a6, sp, 16 ;; replaced with A14's slot
  ...
call0 foo
  ...
l32i.n a8, sp, 16 ;; through SP
  ...
; epilogue {
  ...
(no restoration needed)
  ...
; } epilogue

This patch adds the abovementioned logic to the function prologue/epilogue
RTL expander code.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (machine_function): Add new member
'eliminated_callee_saved_bmp'.
(xtensa_can_eliminate_callee_saved_reg_p): New function to
determine whether the register can be eliminated or not.
(xtensa_expand_prologue): Add invoking the above function and
elimination the use of callee-saved register by using its stack
slot through the stack pointer (or the frame pointer if needed)
directly.
(xtensa_expand_prologue): Modify to not emit register restoration
insn from its stack slot if the register is already eliminated.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/elim_callee_saved.c: New.

16 months agoxtensa: Fix up fatal_error message strings in xtensa-dynconfig.c [PR108890]
Jakub Jelinek [Thu, 23 Feb 2023 22:26:43 +0000 (23:26 +0100)]
xtensa: Fix up fatal_error message strings in xtensa-dynconfig.c [PR108890]

The translation PR complains that these 4 messages from xtensa-dynconfig.c
are marked in po/gcc.pot as c-format (which doesn't allow %qs) while they
should be gcc-internal-format.

The problem is in the manual translation of the strings with _(),
that should be both unnecessary because fatal_error invokes _() on its
argument already, but also incorrect for the above reason, for
gcc-internal-format strings one should use G_("...") instead if really
needed.

The following patch drops those _("..."), tested by regenerating po/gcc.pot
to see they are now gcc-internal-format, but not really tested on xtensa
target.

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

PR translation/108890
* config/xtensa/xtensa-dynconfig.c (xtensa_load_config): Drop _()s
around fatal_error format strings.

16 months agotestsuite: Fix up modules.exp [PR108899]
Jakub Jelinek [Thu, 23 Feb 2023 16:17:05 +0000 (17:17 +0100)]
testsuite: Fix up modules.exp [PR108899]

On Wed, Feb 22, 2023 at 02:33:42PM -0300, Alexandre Oliva via Gcc-patches wrote:
> When a multi-source module is found to be unsupported, we fail
> module_cmi_p and subsequent sources.  Override proc unsupported to
> mark the result in module_do, and test it to skip module_cmp_p and
> subsequent related tests.
>
> for  gcc/testsuite/ChangeLog
>
>       * g++.dg/modules/modules.exp: Override unsupported to update
>       module_do, and test it after dg-test.

This patch breaks testing with more than one set of options in
target board, like
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} modules.exp'
yields:
...
                 === g++ Summary for unix/-m32 ===

 # of expected passes            7217
 # of unexpected failures        1
 # of expected failures          18
 # of unsupported tests          2
 Running target unix/-m64
...
 ERROR: tcl error sourcing /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp.
 ERROR: tcl error code TCL OPERATION RENAME TARGET_EXISTS
 ERROR: can't rename to "saved-unsupported": command already exists
     while executing
 "rename unsupported saved-unsupported"
     (file "/home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp" line 322)
     invoked from within
 "source /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp"
     ("uplevel" body line 1)
     invoked from within
 "uplevel #0 source /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp"
     invoked from within
 "catch "uplevel #0 source $test_file_name" msg"

In other spots where we in *.exp files rename some routine, we guard that
and the following patch does that for modules.exp too.

Tested with running
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} modules.exp'
again which now works properly again.

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

PR testsuite/108899
* g++.dg/modules/modules.exp: Only override unsupported if it
exists and saved-unsupported doesn't.

16 months agoFix memory leak in PTA
Richard Biener [Thu, 23 Feb 2023 13:09:04 +0000 (14:09 +0100)]
Fix memory leak in PTA

When handle_lhs_call calls .create on the passed in vector it leaks
any previous allocated storage.  Avoid doing that and instead rely
on the caller for memory management, just truncate the vector.

* tree-ssa-structalias.cc (handle_lhs_call): Do not
re-create rhsc, only truncate it.

16 months agoc++: Fix up -fcontracts option description [PR108890]
Jakub Jelinek [Thu, 23 Feb 2023 14:27:31 +0000 (15:27 +0100)]
c++: Fix up -fcontracts option description [PR108890]

This translation PR mentioned the description is a little bit weird.

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

PR translation/108890
* c.opt (fcontracts): Fix description.

16 months agoipa-prop: Fix another case of missing BUILT_IN_UNREACHABLE_TRAP handling [PR106258]
Jakub Jelinek [Thu, 23 Feb 2023 14:24:43 +0000 (15:24 +0100)]
ipa-prop: Fix another case of missing BUILT_IN_UNREACHABLE_TRAP handling [PR106258]

There is another spot that handles in IPA just BUILT_IN_UNREACHABLE and
not BUILT_IN_UNREACHABLE_TRAP.

This patch fixes that.

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

PR middle-end/106258
* ipa-prop.cc (try_make_edge_direct_virtual_call): Handle
BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE.

16 months agolibstdc++: Test that integral simd reductions are precise
Matthias Kretz [Tue, 21 Feb 2023 09:43:13 +0000 (10:43 +0100)]
libstdc++: Test that integral simd reductions are precise

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* testsuite/experimental/simd/tests/reductions.cc: Introduce
max_distance as the type-dependent max error.

16 months agolibstdc++: Fix -Wsign-compare issue
Matthias Kretz [Tue, 21 Feb 2023 09:31:55 +0000 (10:31 +0100)]
libstdc++: Fix -Wsign-compare issue

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_builtin.h (_S_set): Compare as
int. The actual range of these indexes is very small.

16 months agolibstdc++: Add missing constexpr on simd shift implementation
Matthias Kretz [Mon, 20 Feb 2023 16:35:59 +0000 (17:35 +0100)]
libstdc++: Add missing constexpr on simd shift implementation

Resolves -Wtautological-compare warnings about `if
(__builtin_is_constant_evaluated())` in the implementations of these
functions.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_x86.h (_S_bit_shift_left)
(_S_bit_shift_right): Declare constexpr. The implementation was
already expecting constexpr evaluation.

16 months agolibstdc++: Fix simd build failure on clang
Matthias Kretz [Mon, 20 Feb 2023 10:13:44 +0000 (11:13 +0100)]
libstdc++: Fix simd build failure on clang

Clang does not support __attribute__ on lambdas. Therefore, only set
_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA if __clang__ is not defined.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/108030
* include/experimental/bits/simd_detail.h
(_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA): Define as empty for
__clang__.

16 months agolibstdc++: Simplify three helper functions into one
Matthias Kretz [Sat, 14 Jan 2023 22:32:38 +0000 (23:32 +0100)]
libstdc++: Simplify three helper functions into one

Broadcast is a very common function. This should reduce compile-time
effort.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/108030
* include/experimental/bits/simd.h (__vector_broadcast):
Implement via __vector_broadcast_impl instead of
__call_with_n_evaluations + 2 lambdas.
(__vector_broadcast_impl): New.

16 months agoFix memory leak in if-conversion
Richard Biener [Thu, 23 Feb 2023 10:05:47 +0000 (11:05 +0100)]
Fix memory leak in if-conversion

The following fixes if-conversion failing to release data-references
and the data-reference vector.

* tree-if-conv.cc (tree_if_conversion): Properly manage
memory of refs and the contained data references.

16 months agotree-optimization/108888 - call if-conversion
Richard Biener [Thu, 23 Feb 2023 10:03:03 +0000 (11:03 +0100)]
tree-optimization/108888 - call if-conversion

The following makes sure to only predicate calls necessary.

PR tree-optimization/108888
* tree-if-conv.cc (if_convertible_stmt_p): Set PLF_2 on
calls to predicate.
(predicate_statements): Only predicate calls with PLF_2.

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

16 months agoxtensa: Fix missing mode warnings in machine description
Takayuki 'January June' Suwa [Thu, 23 Feb 2023 03:42:32 +0000 (12:42 +0900)]
xtensa: Fix missing mode warnings in machine description

gcc/ChangeLog:

* config/xtensa/xtensa.md
(zero_cost_loop_start, zero_cost_loop_end, loop_end):
Add missing "SI:" to PLUS RTXes.

16 months agoxtensa: fix PR target/108876
Max Filippov [Thu, 23 Feb 2023 06:08:21 +0000 (22:08 -0800)]
xtensa: fix PR target/108876

In commit b2ef02e8cbbaf95fee98be255f697f47193960ec, the sibling call
insn included (use (reg:SI A0_REG)) to fix the problem, which added
a USE chain unconditionally to the data flow of register A0 during
the sibling call.

As a result, df_regs_ever_live_p (A0_REG) returns true, so even if
register A0 is not used outside of the sibling call insn, saves and
restores to stack slots are emitted in pro/epilogue, and finally
code size increases.
(This is why I never included (use A0) in sibling calls)

    /* example */
    extern int foo(int);
    int test(int a) {
      return foo(a * 3 + 1);
    }

;; before
    test:
addi sp, sp, -16 ;; unneeded stack frame allocation (induced)
s32i.n a0, sp, 12 ;; unneeded saving of register A0
l32i.n a0, sp, 12 ;; unneeded restoration of register A0
addx2 a2, a2, a2
addi.n a2, a2, 1
addi sp, sp, 16 ;; unneeded stack frame freeing (induced)
j.l foo, a9 ;; sibling call (truly needs register A0)

The essential cause is that we emit (use A0) *before* the insns that
does the stack pointer adjustment during epilogue expansion, so the
liveness of register A0 ends early, so register A0 is reused afterwards.

This patch fixes the problem and avoids such regression by doing the
emit of (use A0) in the sibling call epilogue expansion at the end.

;; after
test:
addx2 a2, a2, a2
addi.n a2, a2, 1
j.l foo, a9

>From RTL-pass "315r.rnreg" by
"gfortran -O3 -funroll-loops -mabi=call0 -S -da gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":

    ;; Function selector_init (__selectors_MOD_selector_init, funcdef_no=2, decl_uid=987, cgraph_uid=3, symbol_order=4)
    ...
    (insn 3807 3806 3808 121 (set (reg:SI 15 a15)
            (mem/c:SI (plus:SI (reg/f:SI 1 sp)
                    (const_int 268 [0x10c])) [31  S4 A32])) "gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal}
         (nil))
    (insn 3808 3807 3809 121 (set (reg:SI 7 a7)
            (const_int 288 [0x120])) "gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal}
         (nil))
    (insn 3809 3808 3810 121 (set (reg/f:SI 1 sp)
            (plus:SI (reg/f:SI 1 sp)
                (reg:SI 7 a7))) "gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 1 {addsi3}
         (expr_list:REG_DEAD (reg:SI 9 a9)
            (nil)))
    (insn 3810 3809 721 121 (use (reg:SI 0 a0)) "gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1
         (expr_list:REG_DEAD (reg:SI 0 a0)
            (nil)))
    (call_insn/j 721 3810 722 121 (call (mem:SI (symbol_ref:SI ("free") [flags 0x41]  <function_decl 0x7f7c885f6000 __builtin_free>) [0 __builtin_free S4 A32])
            (const_int 0 [0])) "gcc-gnu/gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 discrim 1 106 {sibcall_internal}
         (expr_list:REG_DEAD (reg:SI 2 a2)
            (expr_list:REG_CALL_DECL (symbol_ref:SI ("free") [flags 0x41]  <function_decl 0x7f7c885f6000 __builtin_free>)
                (expr_list:REG_EH_REGION (const_int 0 [0])
                    (nil))))
        (expr_list:SI (use (reg:SI 2 a2))
            (nil)))

(IMHO the "rnreg" pass doesn't take REG_ALLOC_ORDER into account;
it just seems to allocate registers in fixed_regs index order,
which may have hurt register A0 that became allocatable in the recent
patch)

gcc/ChangeLog:
PR target/108876

* config/xtensa/xtensa.cc (xtensa_expand_epilogue):
Emit (use (reg:SI A0_REG)) at the end in the sibling call
(i.e. the same place as (return) in the normal call).

16 months agoRevert "gcc: xtensa: fix PR target/108876"
Max Filippov [Thu, 23 Feb 2023 06:07:58 +0000 (22:07 -0800)]
Revert "gcc: xtensa: fix PR target/108876"

This reverts commit b2ef02e8cbbaf95fee98be255f697f47193960ec.

16 months agodocs: Reorder @opindex before corresponding options
Arsen Arsenović [Thu, 23 Feb 2023 01:06:49 +0000 (02:06 +0100)]
docs: Reorder @opindex before corresponding options

gcc/d/ChangeLog:

* gdc.texi: Reorder @opindex commands to precede @items they
relate to.

gcc/ChangeLog:

* doc/cppdiropts.texi: Reorder @opindex commands to precede
@items they relate to.
* doc/cppopts.texi: Ditto.
* doc/cppwarnopts.texi: Ditto.
* doc/invoke.texi: Ditto.
* doc/lto.texi: Ditto.

gcc/fortran/ChangeLog:

* invoke.texi: Reorder @opindex commands to precede @items they
relate to.

16 months agoDaily bump.
GCC Administrator [Thu, 23 Feb 2023 00:17:57 +0000 (00:17 +0000)]
Daily bump.

16 months agoc-family: avoid compile-time-hog in c_genericize [PR108880]
Marek Polacek [Wed, 22 Feb 2023 20:17:03 +0000 (15:17 -0500)]
c-family: avoid compile-time-hog in c_genericize [PR108880]

This fixes a compile-time hog with UBSan.  This only happened in cc1 but
not cc1plus.  The problem is ultimately that c_genericize_control_stmt/
STATEMENT_LIST -> walk_tree_1 doesn't use a hash_set to remember visited
nodes, so it kept on recursing for a long time.  We should be able to
use the pset that c_genericize created.  We just need to use walk_tree
instead of walk_tree_w_d so that the pset is explicit.

PR c/108880

gcc/c-family/ChangeLog:

* c-gimplify.cc (c_genericize_control_stmt) <case STATEMENT_LIST>: Pass
pset to walk_tree_1.
(c_genericize): Call walk_tree with an explicit pset.

gcc/testsuite/ChangeLog:

* c-c++-common/ubsan/pr108880.c: New test.

16 months agoFortran: reject invalid CHARACTER length of derived type components [PR96024]
Harald Anlauf [Tue, 21 Feb 2023 21:06:33 +0000 (22:06 +0100)]
Fortran: reject invalid CHARACTER length of derived type components [PR96024]

gcc/fortran/ChangeLog:

PR fortran/96024
* resolve.cc (resolve_component): The type of a CHARACTER length
expression must be INTEGER.

gcc/testsuite/ChangeLog:

PR fortran/96024
* gfortran.dg/pr96024.f90: New test.

16 months agotestsuite: Skip module_cmi_p and related unsupported module test
Alexandre Oliva [Wed, 22 Feb 2023 17:35:36 +0000 (14:35 -0300)]
testsuite: Skip module_cmi_p and related unsupported module test

When a multi-source module is found to be unsupported, we fail
module_cmi_p and subsequent sources.  Override proc unsupported to
mark the result in module_do, and test it to skip module_cmp_p and
subsequent related tests.

for  gcc/testsuite/ChangeLog

* g++.dg/modules/modules.exp: Override unsupported to update
module_do, and test it after dg-test.

16 months ago[arm] avoid aes-1742098 mitigation in combine tests
Alexandre Oliva [Wed, 22 Feb 2023 17:35:34 +0000 (14:35 -0300)]
[arm] avoid aes-1742098 mitigation in combine tests

The expected asm output for aes-fuse-[12].c does not correspond to
that which is generated when -mfix-cortex-a57-aes-1742098 is enabled.
The mitigation was introduced after the test, and enabled by default
for the selected processor, a72.  Select a53 instead, where the
migitation is not enabled by default, and all the expected fusions can
take place.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/aes-fuse-1.c: Switch to -mcpu=cortex-a53.
* gcc.target/arm/aes-fuse-2.c: Likewise.

16 months agoDrop need for constant I in ctf test
Alexandre Oliva [Wed, 22 Feb 2023 17:35:31 +0000 (14:35 -0300)]
Drop need for constant I in ctf test

Though I is supposed to be a constant expression, this is not the case
on vxworks, but this is not what this debug information format test is
testing for, so use real constants to initialize complex variables.

for  gcc/testsuite/ChangeLog

* gcc.dg/debug/ctf/ctf-complex-1.c: Do not test whether I is
usable in initializers.

16 months agoxfail fp-uint64-convert-double-* on all arm targets
Alexandre Oliva [Wed, 22 Feb 2023 17:35:27 +0000 (14:35 -0300)]
xfail fp-uint64-convert-double-* on all arm targets

It wasn't long ago that I xfailed these tests on arm-*-eabi, but the
fail is expected on all other arm targets: even when hard float is
available, conversions between 64-bit integers and double are always
emulated on ARM, and the emulation disregards rounding modes.  So,
bump the xfail to all of arm-*-*.

for  gcc/testsuite/ChangeLog

* gcc.dg/torture/fp-uint64-convert-double-1.c: XFAIL on all of
arm-*-*.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise.

16 months ago[arm] [testsuite] asm-flag-4.c: match quotes in expected message
Alexandre Oliva [Wed, 22 Feb 2023 17:35:22 +0000 (14:35 -0300)]
[arm] [testsuite] asm-flag-4.c: match quotes in expected message

Quotes were added around the "asm" keyword in the message expected by
the test, so the test needs adjusting.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/asm-flag-4.c: Match quotes around "asm" in
message.

16 months agotestsuite: Accept pmf-vbit-in-delta extra warning
Alexandre Oliva [Wed, 22 Feb 2023 17:35:20 +0000 (14:35 -0300)]
testsuite: Accept pmf-vbit-in-delta extra warning

cp_build_binary_op, that issues -Waddress warnings, issues an extra
warning on arm targets, that g++.dg/warn/Waddress-5.C does not expect
when comparing a pointer-to-member-function literal with null.

The reason for the extra warning is that, on arm targets,
TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, which
causes a different path to be taken, that extracts the
pointer-to-function and the delta fields (minus the vbit) and compares
each one with zero.  It's when comparing this pointer-to-function with
zero, in a recursive cp_build_binary_op, that another warning is
issued.

I suppose there should be a way to skip the warning in this recursive
call, without disabling other warnings that might be issued there, but
this patch only arranges for the test to tolerate the extra warning.

for  gcc/testsuite/ChangeLog

* g++.dg/warn/Waddress-5.C: Tolerate extra -Waddress warning.

16 months ago[libstdc++] do not destruct mutex_pool mutexes
Alexandre Oliva [Wed, 22 Feb 2023 17:35:18 +0000 (14:35 -0300)]
[libstdc++] do not destruct mutex_pool mutexes

On vxworks, after destroying the semaphore used to implement a mutex,
__gthread_mutex_lock fails and __gnu_cxx::__mutex::lock calls
__throw_concurrence_lock_error.  Nothing ensures the mutex_pool
mutexes survive init-once objects containing _Safe_sequence_base.  If
such an object completes construction before mutex_pool
initialization, it will be registered for atexit destruction after the
mutex_pool mutexes, so the _M_detach_all() call in the
_Safe_sequence_base dtor will use already-destructed mutexes, and
basic_string/requirements/citerators_cc fails calling terminate.

This patch fixes this problem by ensuring the mutex pool mutexes are
constructed on demand, on a statically-allocated buffer, but never
destructed.

for  libstdc++-v3/ChangeLog

* src/c++11/shared_ptr.cc (__gnu_internal::get_mutex):
Avoid destruction of the mutex pool.

16 months ago[libstdc++] xfail noreplace tests on vxworks
Alexandre Oliva [Wed, 22 Feb 2023 17:35:15 +0000 (14:35 -0300)]
[libstdc++] xfail noreplace tests on vxworks

vxworks ignores O_EXCL in open, so noreplace open succeeds when it is
expected to fail.  xfail the tests.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/basic_ofstream/open/char/noreplace.cc: xfail
on vxworks.
* testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc:
Likewise.

16 months ago[libstdc++] [testsuite] intro/names.cc: undef func on vxw7krn
Alexandre Oliva [Wed, 22 Feb 2023 17:35:13 +0000 (14:35 -0300)]
[libstdc++] [testsuite] intro/names.cc: undef func on vxw7krn

The '#define func' added in 2021, to test that system headers don't
violate the user namespace, exposes such a bug in the vxworks sysLib.h
header, so add yet another such annotated workaround.

for  libstdc++-v3/ChangeLog

* testsuite/17_intro/names.cc: Undef func on vxworks >= 7 in
kernel mode.

16 months agoRust: In 'type_for_mode' langhook also consider all 'int_n' modes/types
Thomas Schwinge [Wed, 22 Feb 2023 10:42:43 +0000 (11:42 +0100)]
Rust: In 'type_for_mode' langhook also consider all 'int_n' modes/types

As reported in "Rust related issues" at the end of
<https://inbox.sourceware.org/gcc-patches/20221219212344.ewtuzd2jtztm77x2@lug-owl.de>
"Modula-2 / Rust: Many targets failing",
<https://github.com/Rust-GCC/gccrs/issues/1713>
"Test failure on msp430-elfbare target", for '--target=msp430-elfbar' we ICE:

    <built-in>: internal compiler error: Segmentation fault
    0xf2efbf crash_signal
          ../../gcc/gcc/toplev.cc:314
    0x120c8c7 build_function_type(tree_node*, tree_node*, bool)
          ../../gcc/gcc/tree.cc:7360
    0x120cc20 build_function_type_list(tree_node*, ...)
          ../../gcc/gcc/tree.cc:7442
    0x120d16b build_common_builtin_nodes()
          ../../gcc/gcc/tree.cc:9883
    0x8449b4 grs_langhook_init
          ../../gcc/gcc/rust/rust-lang.cc:132
    [...]

This is due to 'tmp == NULL' for 'gcc/tree.cc:build_common_builtin_nodes':

    tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0);

..., were 'targetm.eh_return_filter_mode' (that is,
'gcc/targhooks.cc:default_eh_return_filter_mode',
via calling 'targetm.unwind_word_mode':
'gcc/config/msp430/msp430.cc:msp430_unwind_word_mode') returns 'PSImode',
and 'lang_hooks.types.type_for_mode' (that is,
'gcc/rust/rust-lang.cc:grs_langhook_type_for_mode') returns 'NULL' for
'PSImode'.

As, for example, discussed in <https://gcc.gnu.org/PR46805>
"ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize",
we have to support "random" modes/types in the 'type_for_mode' langhook.

gcc/rust/
* rust-lang.cc (grs_langhook_type_for_mode): Also consider all
'int_n' modes/types.

16 months agovect: inbranch SIMD clones
Andrew Stubbs [Thu, 28 Jul 2022 15:07:22 +0000 (16:07 +0100)]
vect: inbranch SIMD clones

There has been support for generating "inbranch" SIMD clones for a long time,
but nothing actually uses them (as far as I can see).

This patch add supports for a sub-set of possible cases (those using
mask_mode == VOIDmode).  The other cases fail to vectorize, just as before,
so there should be no regressions.

The sub-set of support should cover all cases needed by amdgcn, at present.

gcc/ChangeLog:

* internal-fn.cc (expand_MASK_CALL): New.
* internal-fn.def (MASK_CALL): New.
* internal-fn.h (expand_MASK_CALL): New prototype.
* omp-simd-clone.cc (simd_clone_adjust_argument_types): Set vector_type
for mask arguments also.
* tree-if-conv.cc: Include cgraph.h.
(if_convertible_stmt_p): Do if conversions for calls to SIMD calls.
(predicate_statements): Convert functions to IFN_MASK_CALL.
* tree-vect-loop.cc (vect_get_datarefs_in_loop): Recognise
IFN_MASK_CALL as a SIMD function call.
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Handle
IFN_MASK_CALL as an inbranch SIMD function call.
Generate the mask vector arguments.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-simd-clone-16.c: New test.
* gcc.dg/vect/vect-simd-clone-16b.c: New test.
* gcc.dg/vect/vect-simd-clone-16c.c: New test.
* gcc.dg/vect/vect-simd-clone-16d.c: New test.
* gcc.dg/vect/vect-simd-clone-16e.c: New test.
* gcc.dg/vect/vect-simd-clone-16f.c: New test.
* gcc.dg/vect/vect-simd-clone-17.c: New test.
* gcc.dg/vect/vect-simd-clone-17b.c: New test.
* gcc.dg/vect/vect-simd-clone-17c.c: New test.
* gcc.dg/vect/vect-simd-clone-17d.c: New test.
* gcc.dg/vect/vect-simd-clone-17e.c: New test.
* gcc.dg/vect/vect-simd-clone-17f.c: New test.
* gcc.dg/vect/vect-simd-clone-18.c: New test.
* gcc.dg/vect/vect-simd-clone-18b.c: New test.
* gcc.dg/vect/vect-simd-clone-18c.c: New test.
* gcc.dg/vect/vect-simd-clone-18d.c: New test.
* gcc.dg/vect/vect-simd-clone-18e.c: New test.
* gcc.dg/vect/vect-simd-clone-18f.c: New test.

16 months agoRISC-V: Add RVV reduction C/C++ intrinsics support
Ju-Zhe Zhong [Mon, 20 Feb 2023 06:54:45 +0000 (14:54 +0800)]
RISC-V: Add RVV reduction C/C++ intrinsics support

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-bases.cc (class reducop): New class.
(class widen_reducop): Ditto.
(class freducop): Ditto.
(class widen_freducop): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vredsum): Add reduction support.
(vredmaxu): Ditto.
(vredmax): Ditto.
(vredminu): Ditto.
(vredmin): Ditto.
(vredand): Ditto.
(vredor): Ditto.
(vredxor): Ditto.
(vwredsum): Ditto.
(vwredsumu): Ditto.
(vfredusum): Ditto.
(vfredosum): Ditto.
(vfredmax): Ditto.
(vfredmin): Ditto.
(vfwredosum): Ditto.
(vfwredusum): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (struct reduc_alu_def): Ditto.
(SHAPE): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_WI_OPS): New macro.
(DEF_RVV_WU_OPS): Ditto.
(DEF_RVV_WF_OPS): Ditto.
(vint8mf8_t): Ditto.
(vint8mf4_t): Ditto.
(vint8mf2_t): Ditto.
(vint8m1_t): Ditto.
(vint8m2_t): Ditto.
(vint8m4_t): Ditto.
(vint8m8_t): Ditto.
(vint16mf4_t): Ditto.
(vint16mf2_t): Ditto.
(vint16m1_t): Ditto.
(vint16m2_t): Ditto.
(vint16m4_t): Ditto.
(vint16m8_t): Ditto.
(vint32mf2_t): Ditto.
(vint32m1_t): Ditto.
(vint32m2_t): Ditto.
(vint32m4_t): Ditto.
(vint32m8_t): Ditto.
(vuint8mf8_t): Ditto.
(vuint8mf4_t): Ditto.
(vuint8mf2_t): Ditto.
(vuint8m1_t): Ditto.
(vuint8m2_t): Ditto.
(vuint8m4_t): Ditto.
(vuint8m8_t): Ditto.
(vuint16mf4_t): Ditto.
(vuint16mf2_t): Ditto.
(vuint16m1_t): Ditto.
(vuint16m2_t): Ditto.
(vuint16m4_t): Ditto.
(vuint16m8_t): Ditto.
(vuint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat32m8_t): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_WI_OPS): Ditto.
(DEF_RVV_WU_OPS): Ditto.
(DEF_RVV_WF_OPS): Ditto.
(required_extensions_p): Add reduction support.
(rvv_arg_type_info::get_base_vector_type): Ditto.
(rvv_arg_type_info::get_tree_type): Ditto.
* config/riscv/riscv-vector-builtins.h (enum rvv_base_type): Ditto.
* config/riscv/riscv.md: Ditto.
* config/riscv/vector-iterators.md (minu): Ditto.
* config/riscv/vector.md (@pred_reduc_<reduc><mode><vlmul1>): New patern.
(@pred_reduc_<reduc><mode><vlmul1_zve32>): Ditto.
(@pred_widen_reduc_plus<v_su><mode><vwlmul1>): Ditto.
(@pred_widen_reduc_plus<v_su><mode><vwlmul1_zve32>):Ditto.
(@pred_reduc_plus<order><mode><vlmul1>): Ditto.
(@pred_reduc_plus<order><mode><vlmul1_zve32>): Ditto.
(@pred_widen_reduc_plus<order><mode><vwlmul1>): Ditto.

16 months agoRISC-V: Add floating-point RVV C/C++ api
Ju-Zhe Zhong [Fri, 17 Feb 2023 12:51:14 +0000 (20:51 +0800)]
RISC-V: Add floating-point RVV C/C++ api

Add RVV floating-point C/C++ api tests.
The api unit-tests are all passed but not commit.
They are located at RISC-V foundation repo:
https://github.com/riscv-collab/riscv-gcc/tree/rvv-submission-v1

gcc/ChangeLog:

* config/riscv/iterators.md: New iterator.
* config/riscv/riscv-vector-builtins-bases.cc (class widen_binop): New class.
(enum ternop_type): New enum.
(class vmacc): New class.
(class imac): Ditto.
(class vnmsac): Ditto.
(enum widen_ternop_type): New enum.
(class vmadd): Ditto.
(class vnmsub): Ditto.
(class iwmac): Ditto.
(class vwmacc): Ditto.
(class vwmaccu): Ditto.
(class vwmaccsu): Ditto.
(class vwmaccus): Ditto.
(class reverse_binop): Ditto.
(class vfmacc): Ditto.
(class vfnmsac): Ditto.
(class vfmadd): Ditto.
(class vfnmsub): Ditto.
(class vfnmacc): Ditto.
(class vfmsac): Ditto.
(class vfnmadd): Ditto.
(class vfmsub): Ditto.
(class vfwmacc): Ditto.
(class vfwnmacc): Ditto.
(class vfwmsac): Ditto.
(class vfwnmsac): Ditto.
(class float_misc): Ditto.
(class fcmp): Ditto.
(class vfclass): Ditto.
(class vfcvt_x): Ditto.
(class vfcvt_rtz_x): Ditto.
(class vfcvt_f): Ditto.
(class vfwcvt_x): Ditto.
(class vfwcvt_rtz_x): Ditto.
(class vfwcvt_f): Ditto.
(class vfncvt_x): Ditto.
(class vfncvt_rtz_x): Ditto.
(class vfncvt_f): Ditto.
(class vfncvt_rod_f): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h:
* config/riscv/riscv-vector-builtins-functions.def (vzext): Ditto.
(vsext): Ditto.
(vfadd): Ditto.
(vfsub): Ditto.
(vfrsub): Ditto.
(vfwadd): Ditto.
(vfwsub): Ditto.
(vfmul): Ditto.
(vfdiv): Ditto.
(vfrdiv): Ditto.
(vfwmul): Ditto.
(vfmacc): Ditto.
(vfnmsac): Ditto.
(vfmadd): Ditto.
(vfnmsub): Ditto.
(vfnmacc): Ditto.
(vfmsac): Ditto.
(vfnmadd): Ditto.
(vfmsub): Ditto.
(vfwmacc): Ditto.
(vfwnmacc): Ditto.
(vfwmsac): Ditto.
(vfwnmsac): Ditto.
(vfsqrt): Ditto.
(vfrsqrt7): Ditto.
(vfrec7): Ditto.
(vfmin): Ditto.
(vfmax): Ditto.
(vfsgnj): Ditto.
(vfsgnjn): Ditto.
(vfsgnjx): Ditto.
(vfneg): Ditto.
(vfabs): Ditto.
(vmfeq): Ditto.
(vmfne): Ditto.
(vmflt): Ditto.
(vmfle): Ditto.
(vmfgt): Ditto.
(vmfge): Ditto.
(vfclass): Ditto.
(vfmerge): Ditto.
(vfmv_v): Ditto.
(vfcvt_x): Ditto.
(vfcvt_xu): Ditto.
(vfcvt_rtz_x): Ditto.
(vfcvt_rtz_xu): Ditto.
(vfcvt_f): Ditto.
(vfwcvt_x): Ditto.
(vfwcvt_xu): Ditto.
(vfwcvt_rtz_x): Ditto.
(vfwcvt_rtz_xu): Ditto.
(vfwcvt_f): Ditto.
(vfncvt_x): Ditto.
(vfncvt_xu): Ditto.
(vfncvt_rtz_x): Ditto.
(vfncvt_rtz_xu): Ditto.
(vfncvt_f): Ditto.
(vfncvt_rod_f): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (struct alu_def): Ditto.
(struct move_def): Ditto.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_WEXTF_OPS): New macro.
(DEF_RVV_CONVERT_I_OPS): Ditto.
(DEF_RVV_CONVERT_U_OPS): Ditto.
(DEF_RVV_WCONVERT_I_OPS): Ditto.
(DEF_RVV_WCONVERT_U_OPS): Ditto.
(DEF_RVV_WCONVERT_F_OPS): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m2_t): Ditto.
(vfloat64m4_t): Ditto.
(vfloat64m8_t): Ditto.
(vint32mf2_t): Ditto.
(vint32m1_t): Ditto.
(vint32m2_t): Ditto.
(vint32m4_t): Ditto.
(vint32m8_t): Ditto.
(vint64m1_t): Ditto.
(vint64m2_t): Ditto.
(vint64m4_t): Ditto.
(vint64m8_t): Ditto.
(vuint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vuint64m1_t): Ditto.
(vuint64m2_t): Ditto.
(vuint64m4_t): Ditto.
(vuint64m8_t): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_CONVERT_I_OPS): Ditto.
(DEF_RVV_CONVERT_U_OPS): Ditto.
(DEF_RVV_WCONVERT_I_OPS): Ditto.
(DEF_RVV_WCONVERT_U_OPS): Ditto.
(DEF_RVV_WCONVERT_F_OPS): Ditto.
(DEF_RVV_F_OPS): Ditto.
(DEF_RVV_WEXTF_OPS): Ditto.
(required_extensions_p): Adjust for floating-point support.
(check_required_extensions): Ditto.
(unsigned_base_type_p): Ditto.
(get_mode_for_bitsize): Ditto.
(rvv_arg_type_info::get_base_vector_type): Ditto.
(rvv_arg_type_info::get_tree_type): Ditto.
* config/riscv/riscv-vector-builtins.def (v_f): New define.
(f): New define.
(f_v): New define.
(xu_v): New define.
(f_w): New define.
(xu_w): New define.
* config/riscv/riscv-vector-builtins.h (enum rvv_base_type): New enum.
(function_expander::arg_mode): New function.
* config/riscv/vector-iterators.md (sof): New iterator.
(vfrecp): Ditto.
(copysign): Ditto.
(n): Ditto.
(msac): Ditto.
(msub): Ditto.
(fixuns_trunc): Ditto.
(floatuns): Ditto.
* config/riscv/vector.md (@pred_broadcast<mode>): New pattern.
(@pred_<optab><mode>): Ditto.
(@pred_<optab><mode>_scalar): Ditto.
(@pred_<optab><mode>_reverse_scalar): Ditto.
(@pred_<copysign><mode>): Ditto.
(@pred_<copysign><mode>_scalar): Ditto.
(@pred_mul_<optab><mode>): Ditto.
(pred_mul_<optab><mode>_undef_merge): Ditto.
(*pred_<madd_nmsub><mode>): Ditto.
(*pred_<macc_nmsac><mode>): Ditto.
(*pred_mul_<optab><mode>): Ditto.
(@pred_mul_<optab><mode>_scalar): Ditto.
(*pred_mul_<optab><mode>_undef_merge_scalar): Ditto.
(*pred_<madd_nmsub><mode>_scalar): Ditto.
(*pred_<macc_nmsac><mode>_scalar): Ditto.
(*pred_mul_<optab><mode>_scalar): Ditto.
(@pred_neg_mul_<optab><mode>): Ditto.
(pred_neg_mul_<optab><mode>_undef_merge): Ditto.
(*pred_<nmadd_msub><mode>): Ditto.
(*pred_<nmacc_msac><mode>): Ditto.
(*pred_neg_mul_<optab><mode>): Ditto.
(@pred_neg_mul_<optab><mode>_scalar): Ditto.
(*pred_neg_mul_<optab><mode>_undef_merge_scalar): Ditto.
(*pred_<nmadd_msub><mode>_scalar): Ditto.
(*pred_<nmacc_msac><mode>_scalar): Ditto.
(*pred_neg_mul_<optab><mode>_scalar): Ditto.
(@pred_<misc_op><mode>): Ditto.
(@pred_class<mode>): Ditto.
(@pred_dual_widen_<optab><mode>): Ditto.
(@pred_dual_widen_<optab><mode>_scalar): Ditto.
(@pred_single_widen_<plus_minus:optab><mode>): Ditto.
(@pred_single_widen_<plus_minus:optab><mode>_scalar): Ditto.
(@pred_widen_mul_<optab><mode>): Ditto.
(@pred_widen_mul_<optab><mode>_scalar): Ditto.
(@pred_widen_neg_mul_<optab><mode>): Ditto.
(@pred_widen_neg_mul_<optab><mode>_scalar): Ditto.
(@pred_cmp<mode>): Ditto.
(*pred_cmp<mode>): Ditto.
(*pred_cmp<mode>_narrow): Ditto.
(@pred_cmp<mode>_scalar): Ditto.
(*pred_cmp<mode>_scalar): Ditto.
(*pred_cmp<mode>_scalar_narrow): Ditto.
(@pred_eqne<mode>_scalar): Ditto.
(*pred_eqne<mode>_scalar): Ditto.
(*pred_eqne<mode>_scalar_narrow): Ditto.
(@pred_merge<mode>_scalar): Ditto.
(@pred_fcvt_x<v_su>_f<mode>): Ditto.
(@pred_<fix_cvt><mode>): Ditto.
(@pred_<float_cvt><mode>): Ditto.
(@pred_widen_fcvt_x<v_su>_f<mode>): Ditto.
(@pred_widen_<fix_cvt><mode>): Ditto.
(@pred_widen_<float_cvt><mode>): Ditto.
(@pred_extend<mode>): Ditto.
(@pred_narrow_fcvt_x<v_su>_f<mode>): Ditto.
(@pred_narrow_<fix_cvt><mode>): Ditto.
(@pred_narrow_<float_cvt><mode>): Ditto.
(@pred_trunc<mode>): Ditto.
(@pred_rod_trunc<mode>): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/ternop_vv_constraint-3.c: New test.
* gcc.target/riscv/rvv/base/ternop_vv_constraint-4.c: New test.
* gcc.target/riscv/rvv/base/ternop_vv_constraint-5.c: New test.
* gcc.target/riscv/rvv/base/ternop_vv_constraint-6.c: New test.
* gcc.target/riscv/rvv/base/ternop_vx_constraint-8.c: New test.
* gcc.target/riscv/rvv/base/ternop_vx_constraint-9.c: New test.

16 months agoRISC-V: Make the test condition more strict for gcc.target/riscv/_Float16-zhinxmin-1.c
Kito Cheng [Wed, 22 Feb 2023 09:16:20 +0000 (17:16 +0800)]
RISC-V: Make the test condition more strict for gcc.target/riscv/_Float16-zhinxmin-1.c

LTO might generate random string for the section name, which might contain `mv`,
then might cause random false alarm.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/_Float16-zhinxmin-1.c: Tweak test
condition.

16 months agoRISC-V: Adjust vsetvl testcase.
Kito Cheng [Mon, 20 Feb 2023 15:54:51 +0000 (23:54 +0800)]
RISC-V: Adjust vsetvl testcase.

- Fitler out 'Oz' for vsetvl testcases.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/avl_multiple-1.c: Filter out '-Oz'.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_multiple-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-30.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-38.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-41.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-42.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-43.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-44.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-45.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-48.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-50.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-51.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-65.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-66.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-67.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-68.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-69.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-70.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-71.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-73.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-74.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-75.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/avl_single-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_bb_prop-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_bb_prop-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_bb_prop-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_conflict-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_conflict-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_loop_invariant-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_loop_invariant-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_loop_invariant-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_loop_invariant-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_loop_invariant-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_switch-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_switch-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_switch-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_switch-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/imm_switch-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-17.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-21.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-22.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-28.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-29.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-30.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-31.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-32.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-33.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-34.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-35.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-37.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-38.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-39.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-40.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-41.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-42.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-43.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-44.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-45.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-17.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-21.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-22.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-24.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-25.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-26.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-28.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-17.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-21.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-22.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-24.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-25.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-26.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-28.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-17.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-21.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-22.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-24.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-25.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-26.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-28.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvl-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-17.c: Filter
out -Oz and -Og -g.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-18.c: Ditto.

16 months agocgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots...
Jakub Jelinek [Wed, 22 Feb 2023 10:22:03 +0000 (11:22 +0100)]
cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258]

The following testcase ICEs because we still have some spots that
treat BUILT_IN_UNREACHABLE specially but not BUILT_IN_UNREACHABLE_TRAP
the same.

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

PR middle-end/106258
* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee,
cgraph_update_edges_for_call_stmt_node, cgraph_node::verify_node):
Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE.
* cgraphclones.cc (cgraph_node::create_clone): Likewise.

* g++.dg/ipa/pr106258.C: New test.

16 months agoRust: Move void_list_node init to common code
Thomas Schwinge [Wed, 22 Feb 2023 09:15:19 +0000 (10:15 +0100)]
Rust: Move void_list_node init to common code

Apply commit r13-2682-g8ff2a92a0450243e52d3299a13b30f208bafa7e0
"Move void_list_node init to common code" to the Rust front end, too.

gcc/rust/
* rust-lang.cc (grs_langhook_init): Do not initialize
void_list_node.

16 months agoAdd '-Wno-complain-wrong-lang', and use it in 'gcc/testsuite/lib/target-supports...
Thomas Schwinge [Wed, 14 Dec 2022 16:16:42 +0000 (17:16 +0100)]
Add '-Wno-complain-wrong-lang', and use it in 'gcc/testsuite/lib/target-supports.exp:check_compile' and elsewhere

I noticed that GCC/Rust recently lost all LTO variants in torture testing:

     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O0  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O1  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2  (test for excess errors)
    -PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
    -PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O3 -g  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -Os  (test for excess errors)

Etc.

The reason is that when probing for availability of LTO, we run into:

    spawn [...]/build-gcc/gcc/testsuite/rust/../../gccrs -B[...]/build-gcc/gcc/testsuite/rust/../../ -fdiagnostics-plain-output -frust-incomplete-and-experimental-compiler-do-not-use -flto -c -o lto8274.o lto8274.c
    cc1: warning: command-line option '-frust-incomplete-and-experimental-compiler-do-not-use' is valid for Rust but not for C

For GCC/Rust testing, this flag is (as of recently) defaulted in
'gcc/testsuite/lib/rust.exp:rust_init':

    lappend ALWAYS_RUSTFLAGS "additional_flags=-frust-incomplete-and-experimental-compiler-do-not-use"

A few more "command-line option [...] is valid for [...] but not for [...]"
instances were found in the test suite logs, when more than one language is
involved.

With '-Wno-complain-wrong-lang' used in
'gcc/testsuite/lib/target-supports.exp:check_compile', we get back:

     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O0  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O1  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2  (test for excess errors)
    +PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
    +PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -O3 -g  (test for excess errors)
     PASS: rust/compile/torture/all_doc_comment_line_blocks.rs   -Os  (test for excess errors)

Etc., and in total:

                    === rust Summary for unix ===

    # of expected passes            [-4990-]{+6718+}
    # of expected failures          [-39-]{+51+}

Anything that 'gcc/opts-global.cc:complain_wrong_lang' might do is cut
short by '-Wno-complain-wrong-lang', not just the one 'warning'
diagnostic.  This corresponds to what already exists via
'lang_hooks.complain_wrong_lang_p'.

The 'gcc/opts-common.cc:prune_options' changes follow the same rationale
as PR67640 "driver passes -fdiagnostics-color= always last": we need to
process '-Wno-complain-wrong-lang' early, so that it properly affects
other options appearing before it on the command line.

gcc/
* common.opt (-Wcomplain-wrong-lang): New.
* doc/invoke.texi (-Wno-complain-wrong-lang): Document it.
* opts-common.cc (prune_options): Handle it.
* opts-global.cc (complain_wrong_lang): Use it.
gcc/testsuite/
* gcc.dg/Wcomplain-wrong-lang-1.c: New.
* gcc.dg/Wcomplain-wrong-lang-2.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-3.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-4.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-5.c: Likewise.
* lib/target-supports.exp (check_compile): Use
'-Wno-complain-wrong-lang'.
* g++.dg/abi/empty12.C: Likewise.
* g++.dg/abi/empty13.C: Likewise.
* g++.dg/abi/empty14.C: Likewise.
* g++.dg/abi/empty15.C: Likewise.
* g++.dg/abi/empty16.C: Likewise.
* g++.dg/abi/empty17.C: Likewise.
* g++.dg/abi/empty18.C: Likewise.
* g++.dg/abi/empty19.C: Likewise.
* g++.dg/abi/empty22.C: Likewise.
* g++.dg/abi/empty25.C: Likewise.
* g++.dg/abi/empty26.C: Likewise.
* gfortran.dg/bind-c-contiguous-1.f90: Likewise.
* gfortran.dg/bind-c-contiguous-4.f90: Likewise.
* gfortran.dg/bind-c-contiguous-5.f90: Likewise.
libgomp/
* testsuite/libgomp.fortran/alloc-10.f90: Use
'-Wno-complain-wrong-lang'.
* testsuite/libgomp.fortran/alloc-11.f90: Likewise.
* testsuite/libgomp.fortran/alloc-7.f90: Likewise.
* testsuite/libgomp.fortran/alloc-9.f90: Likewise.
* testsuite/libgomp.fortran/allocate-1.f90: Likewise.
* testsuite/libgomp.fortran/depend-4.f90: Likewise.
* testsuite/libgomp.fortran/depend-5.f90: Likewise.
* testsuite/libgomp.fortran/depend-6.f90: Likewise.
* testsuite/libgomp.fortran/depend-7.f90: Likewise.
* testsuite/libgomp.fortran/depend-inoutset-1.f90: Likewise.
* testsuite/libgomp.fortran/examples-4/declare_target-1.f90:
Likewise.
* testsuite/libgomp.fortran/examples-4/declare_target-2.f90:
Likewise.
* testsuite/libgomp.fortran/order-reproducible-1.f90: Likewise.
* testsuite/libgomp.fortran/order-reproducible-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
* testsuite/libgomp.fortran/task-detach-6.f90: Remove left-over
'dg-prune-output'.

16 months agoRust: Don't depend on unused 'target-libffi', 'target-libbacktrace'
Thomas Schwinge [Mon, 20 Feb 2023 12:01:50 +0000 (13:01 +0100)]
Rust: Don't depend on unused 'target-libffi', 'target-libbacktrace'

For example:

    configure: error: "libffi has not been ported to nvptx-unknown-none."

Follow-up to commit a75f038c069cc3a23b214854bedf04321fe88bc5
"gccrs: Add config-lang.in", which said:

> This was a copy/paste from gccgo front-end. We do not use any of the
> target_libs yet, [...]

gcc/rust/
* config-lang.in (target_libs): Remove.

16 months agoIn 'contrib/config-list.mk', clarify i686-symbolics-gnu to i686-gnu
Thomas Schwinge [Fri, 10 Feb 2023 09:43:24 +0000 (10:43 +0100)]
In 'contrib/config-list.mk', clarify i686-symbolics-gnu to i686-gnu

Already in the first revision of 'contrib/config-list.mk', i686-symbolics-gnu
has been present, but it's not clear to me whether that was meant to be
Symbolics as in the manufacturer, <https://en.wikipedia.org/wiki/Symbolics>,
with GNU (that is, GNU/Hurd) kernel/operating system (user land), or Symbolics
kernel with GNU operating system (user land)?

I can't find any mention of "Symbolics" in the history of 'config.sub'
upstream.

Either way, GCC configures i686-symbolics-gnu exactly the same as i686-gnu:

    $ sed -n -e '/Using .* host machine hooks\.$/q' -e '/^Using the following target machine macro files:$/,$p' log/i686-gnu-make.out
    Using the following target machine macro files:
            [...]/gcc/config/vxworks-dummy.h
            [...]/gcc/config/i386/i386.h
            [...]/gcc/config/i386/unix.h
            [...]/gcc/config/i386/att.h
            [...]/gcc/config/elfos.h
            [...]/gcc/config/gnu-user.h
            [...]/gcc/config/glibc-stdint.h
            [...]/gcc/config/i386/gnu-user-common.h
            [...]/gcc/config/i386/gnu-user.h
            [...]/gcc/config/gnu.h
            [...]/gcc/config/i386/gnu.h
            [...]/gcc/config/initfini-array.h

..., so let's clarify i686-symbolics-gnu to i686-gnu.

contrib/
* config-list.mk (LIST): Clarify i686-symbolics-gnu to i686-gnu.

16 months agoDaily bump.
GCC Administrator [Wed, 22 Feb 2023 00:18:49 +0000 (00:18 +0000)]
Daily bump.

16 months agoanalyzer: stop exploring the path after certain diagnostics [PR108830]
David Malcolm [Tue, 21 Feb 2023 21:58:36 +0000 (16:58 -0500)]
analyzer: stop exploring the path after certain diagnostics [PR108830]

PR analyzer/108830 reports a situation in which there are lots of
followup -Wanalyzer-null-dereference warnings after the first access of
a NULL pointer, leading to very noisy output from -fanalyzer.

The analyzer's logic for stopping emitting multiple warnings from a
state machine doesn't quite work for NULL pointers: it attempts to
transition the malloc state machine's NULL pointer to the "stop" state,
which doesn't seem to make much sense in retrospect, and seems to get
confused over types.

Similarly, poisoned_value_diagnostic can be very noisy for uninit
variables, emitting a warning for every access to an uninitialized
variable.  In theory, region_model::check_for_poison makes some attempts
to suppress followups, but only for the symbolic value itself; if the
user's code keeps accessing the same region, we would get a warning on
each one.  For example, this showed up in Doom's s_sound.c where there
were 7 followup uninit warnings after the first uninit warning in
"S_ChangeMusic".

This patch adds an extra mechanism, giving pending diagnostics the
option of stopping the analysis of an execution path if they're saved
for emission on it, and turning this on for these warnings:
  -Wanalyzer-null-dereference
  -Wanalyzer-null-argument
  -Wanalyzer-use-after-free
  -Wanalyzer-use-of-pointer-in-stale-stack-frame
  -Wanalyzer-use-of-uninitialized-value

Doing so should hopefully reduce the cascades of diagnostics that
-fanalyzer can sometimes emit.

I added a -fno-analyzer-suppress-followups for the cases where you
really want the followup warnings (e.g. in some DejaGnu tests, and
for microbenchmarks of UB detection, such as PR analyzer/104224).

Integration testing shows this patch reduces the number of probable
false positives reported by 94, and finds one more true positive:

Comparison: 9.34% -> 10.91%
  GOOD:  66 ->  67  (+1)
   BAD: 641 -> 547 (-94)

where the affected warnings/projects are:

  -Wanalyzer-null-dereference: 0.00% GOOD: 0 BAD: 269 -> 239 (-30)
     Unclassified: 257 -> 228 (-29)
                  apr-1.7.0:  12 ->   5  (-7)
                       doom:   1 ->   0  (-1)
              haproxy-2.7.1:  47 ->  41  (-6)
       ImageMagick-7.1.0-57:  13 ->   9  (-4)
                 qemu-7.2.0: 165 -> 154 (-11)

      Known false: 7 -> 6 (-1)
                   xz-5.4.0:   4 ->   3  (-1)

  -Wanalyzer-use-of-uninitialized-value: 0.00% GOOD: 0 BAD: 143 -> 80 (-63)
      Known false: 47 -> 16 (-31)
                       doom: 42 -> 11 (-31)

     Unclassified: 96 -> 64 (-32)
              coreutils-9.1: 14 -> 10  (-4)
              haproxy-2.7.1: 29 -> 23  (-6)
                 qemu-7.2.0: 48 -> 26 (-22)

  -Wanalyzer-null-argument: 0.00% -> 2.33% GOOD: 0 -> 1 (+1) BAD: 43 -> 42 (-1)
     Unclassified: 39 -> 38 (-1)
      due to coreutils-9.1: 9 -> 8 (-1)

    True positive: 0 -> 1 (+1)
      (in haproxy-2.7.1)

gcc/analyzer/ChangeLog:
PR analyzer/108830
* analyzer.opt (fanalyzer-suppress-followups): New option.
* engine.cc (impl_region_model_context::warn): Terminate the path
if the diagnostic's terminate_path_p vfunc returns true and
-fanalyzer-suppress-followups is true (the default).
(impl_sm_context::warn): Likewise, for both overloads.
* pending-diagnostic.h (pending_diagnostic::terminate_path_p): New
vfunc.
* program-state.cc (program_state::on_edge): Terminate the path if
the ctxt requests it during updating the edge.
* region-model.cc (poisoned_value_diagnostic::terminate_path_p):
New vfunc.
* sm-malloc.cc (null_deref::terminate_path_p): New vfunc.
(null_arg::terminate_path_p): New vfunc.

gcc/ChangeLog:
PR analyzer/108830
* doc/invoke.texi: Document -fno-analyzer-suppress-followups.

gcc/testsuite/ChangeLog:
PR analyzer/108830
* gcc.dg/analyzer/attribute-nonnull.c: Update for
-Wanalyzer-use-of-uninitialized-value terminating analysis along
a path.
* gcc.dg/analyzer/call-summaries-2.c: Likewise.
* gcc.dg/analyzer/data-model-1.c: Likewise.
* gcc.dg/analyzer/data-model-5.c: Likewise.
* gcc.dg/analyzer/doom-s_sound-pr108867.c: New test.
* gcc.dg/analyzer/memset-CVE-2017-18549-1.c: Add
-fno-analyzer-suppress-followups.
* gcc.dg/analyzer/null-deref-pr108830.c: New test.
* gcc.dg/analyzer/pipe-1.c: Add -fno-analyzer-suppress-followups.
* gcc.dg/analyzer/pipe-void-return.c: Likewise.
* gcc.dg/analyzer/pipe2-1.c: Likewise.
* gcc.dg/analyzer/pr101547.c: Update for
-Wanalyzer-use-of-uninitialized-value terminating analysis along
a path.
* gcc.dg/analyzer/pr101875.c: Likewise.
* gcc.dg/analyzer/pr104224-split.c: New test, based on...
* gcc.dg/analyzer/pr104224.c: Add
-fno-analyzer-suppress-followups.
* gcc.dg/analyzer/realloc-2.c: Add
-fno-analyzer-suppress-followups.
* gcc.dg/analyzer/realloc-3.c: Likewise.
* gcc.dg/analyzer/realloc-5.c: Likewise.
* gcc.dg/analyzer/stdarg-1-ms_abi.c: Likewise.
* gcc.dg/analyzer/stdarg-1-sysv_abi.c: Likewise.
* gcc.dg/analyzer/stdarg-1.c: Likewise.
* gcc.dg/analyzer/symbolic-1.c: Likewise.
* gcc.dg/analyzer/symbolic-7.c: Update for
-Wanalyzer-use-of-uninitialized-value terminating analysis along a
path.
* gcc.dg/analyzer/uninit-4.c: Likewise.
* gcc.dg/analyzer/uninit-8.c: New test.
* gcc.dg/analyzer/uninit-pr94713.c: Update for
-Wanalyzer-use-of-uninitialized-value terminating analysis along a
path.
* gcc.dg/analyzer/zlib-6a.c: Add -fno-analyzer-suppress-followups.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agogcc: xtensa: fix PR target/108876
Max Filippov [Tue, 21 Feb 2023 19:49:35 +0000 (11:49 -0800)]
gcc: xtensa: fix PR target/108876

gcc/
PR target/108876
* config/xtensa/xtensa.cc (xtensa_expand_epilogue): Drop emit_use
for A0_REG.
* config/xtensa/xtensa.md (sibcall, sibcall_internal)
(sibcall_value, sibcall_value_internal): Add 'use' expression
for A0_REG.

16 months agoFortran: improve checking of character length specification [PR96025]
Harald Anlauf [Mon, 20 Feb 2023 20:28:09 +0000 (21:28 +0100)]
Fortran: improve checking of character length specification [PR96025]

gcc/fortran/ChangeLog:

PR fortran/96025
* parse.cc (check_function_result_typed): Improve type check of
specification expression for character length and return status.
(parse_spec): Use status from above.
* resolve.cc (resolve_fntype): Prevent use of invalid specification
expression for character length.

gcc/testsuite/ChangeLog:

PR fortran/96025
* gfortran.dg/pr96025.f90: New test.

16 months agolibphobos: Merge upstream phobos e5a521ab2.
Iain Buclaw [Fri, 3 Feb 2023 22:40:20 +0000 (23:40 +0100)]
libphobos: Merge upstream phobos e5a521ab2.

Phobos changes:

    - Unicode tables have been updated to version 15.

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos e5a521ab2.

16 months agod: Merge upstream dmd, druntime 09faa4eacd, phobos 13ef27a56.
Iain Buclaw [Sun, 29 Jan 2023 20:06:59 +0000 (21:06 +0100)]
d: Merge upstream dmd, druntime 09faa4eacd, phobos 13ef27a56.

D front-end changes:

- Import dmd v2.102.0-beta.1
- `static assert' now supports multiple message arguments.

D runtime changes:

- Import druntime v2.102.0-beta.1
- The default `Throwable.TraceInfo' generation now is `@nogc'.
- `Object.factory' method has now been deprecated.

Phobos changes:

- Import phobos v2.102.0-beta.1
- Added float- and double-precision implementations for log
  function families in std.math.
- `std.typecons.Unique' now calls `destroy` on struct types

gcc/d/ChangeLog:

* Make-lang.in (D_FRONTEND_OBJS): Add d/location.o.
* d-lang.cc (d_init_options): Update for new front-end interface.
(d_post_options): Call Loc::set after handling options.
* dmd/MERGE: Merge upstream dmd 09faa4eacd.
* dmd/VERSION: Bump version to v2.102.0-beta.1.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 09faa4eacd.
* src/MERGE: Merge upstream phobos 13ef27a56.
* testsuite/libphobos.exceptions/refcounted.d: Add test for chained
reference counted exceptions.
* testsuite/libphobos.shared/finalize.d: Add dg-warning for deprecated
factory interfaces.
* testsuite/libphobos.gc/issue22843.d: New test.

gcc/testsuite/ChangeLog:

* gdc.dg/simd2a.d: Update.
* gdc.dg/simd2b.d: Update.
* gdc.dg/simd2c.d: Update.
* gdc.dg/simd2d.d: Update.
* gdc.dg/simd2e.d: Update.
* gdc.dg/simd2f.d: Update.
* gdc.dg/simd2g.d: Update.
* gdc.dg/simd2h.d: Update.
* gdc.dg/simd2i.d: Update.
* gdc.dg/simd2j.d: Update.

16 months agod: Only handle the left-to-right evaluation of a call expression during gimplify
Iain Buclaw [Sun, 29 Jan 2023 20:25:40 +0000 (21:25 +0100)]
d: Only handle the left-to-right evaluation of a call expression during gimplify

Removes an unnecessary rewriting of the front-end AST during lowering.

gcc/d/ChangeLog:

* d-codegen.cc (d_build_call): Remove front-end expansion of
side-effects in a call expression.
* d-gimplify.cc (d_gimplify_call_expr): Gimplify the callee before its
arguments.

16 months agod: Set doing_semantic_analysis_p before calling functionSemantic3
Iain Buclaw [Sun, 29 Jan 2023 20:17:47 +0000 (21:17 +0100)]
d: Set doing_semantic_analysis_p before calling functionSemantic3

As functions which have semantic analysis ran late may still require
the use of CTFE built-ins to be evaluated.

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set
doing_semantic_analysis_p before calling functionSemantic3.

gcc/testsuite/ChangeLog:

* gdc.dg/ctfeintrinsics.d: New test.

16 months agolibphobos: Add @nogc to gcc.backtrace and gcc.libbacktrace modules.
Iain Buclaw [Sun, 29 Jan 2023 20:14:48 +0000 (21:14 +0100)]
libphobos: Add @nogc to gcc.backtrace and gcc.libbacktrace modules.

libphobos/ChangeLog:

* libdruntime/gcc/backtrace.d (simpleErrorCallback): Add @nogc.
(LibBacktrace.initLibBacktrace): Likewise.
(LibBacktrace.this): Likewise.
(UnwindBacktrace.this): Likewise.
(getBacktrace): Likewise.
(getBacktraceSymbols): Likewise.
* libdruntime/gcc/libbacktrace.d.in (backtrace_create_state):
Likewise.
(backtrace_full): Likewise.
(backtrace_simple): Likewise.
(backtrace_print): Likewise.
(backtrace_pcinfo): Likewise.
(backtrace_syminfo): Likewise.

16 months agotree-optimization/108691 - remove trigger-happy assert
Richard Biener [Tue, 21 Feb 2023 12:02:31 +0000 (13:02 +0100)]
tree-optimization/108691 - remove trigger-happy assert

The following gets rid of the idea that we should prevent setjmp
like calls from popping up in uncontrolled way in the IL for now.
The solution is probably to handle it similar as noreturn has
the ctrl-altering flag on stmts, but use another flag, for example
ctrl-receiving which would also make sure the stmt is first.

PR tree-optimization/108691
* tree-ssa-dce.cc (eliminate_unnecessary_stmts): Remove
assert about calls_setjmp not becoming true when it was false.

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

16 months agotree-optimization/108793 - niter compute type mismatch
Richard Biener [Mon, 20 Feb 2023 11:58:50 +0000 (12:58 +0100)]
tree-optimization/108793 - niter compute type mismatch

When computing the number of iterations until wrap types are mixed up,
eventually leading to checking ICEs with a pointer bitwise inversion.
The following uses niter_type for the calculation.

PR tree-optimization/108793
* tree-ssa-loop-niter.cc (number_of_iterations_until_wrap):
Use convert operands to niter_type when computing num.

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

16 months agoUpdate copyright years.
Thomas Schwinge [Tue, 21 Feb 2023 12:49:42 +0000 (13:49 +0100)]
Update copyright years.

... which accidentally had gotten reverted in recent
commit r13-6156-g1e8eb102200902e12c1b00e867e338be0a92c292
"gccrs: dump: Emit visibility when dumping items".

16 months agogccrs: add math intrinsics
Raiki Tamura [Thu, 15 Dec 2022 17:27:59 +0000 (02:27 +0900)]
gccrs: add math intrinsics

gcc/rust/ChangeLog:

* backend/rust-builtins.cc (BuiltinsContext::setup_math_fns): New functions.

gcc/testsuite/ChangeLog:

* rust/compile/torture/intrinsics-math.rs: New test.

16 months agogccrs: const evaluator: Remove get_nth_callarg
Arthur Cohen [Thu, 17 Nov 2022 15:50:58 +0000 (16:50 +0100)]
gccrs: const evaluator: Remove get_nth_callarg

We only used one path of the C++ folder's get_nth_callarg function:
CALL_EXPR_ARG. Replace all calls to get_nth_callarg by macro calls to
CALL_EXPR_ARG

gcc/rust/ChangeLog:

* backend/rust-constexpr.cc (get_nth_callarg): Remove function.
(rs_bind_parameters_in_call): Use CALL_EXPR_ARG instead.
(potential_constant_expression_1): Likewise.

16 months agogccrs: Repair 'gcc/rust/lang.opt' comment
Thomas Schwinge [Wed, 7 Dec 2022 08:18:26 +0000 (09:18 +0100)]
gccrs: Repair 'gcc/rust/lang.opt' comment

... lost in #1527 commit 138a6260124740208b8f3aff2e38617f43b05fe8
"rust: Add -frust-compile-until option".

gcc/rust/ChangeLog:

* lang.opt: Fix ordering of file.

16 months agogccrs: Cleanup unused parameters to fix the bootstrap build
Philip Herron [Mon, 5 Dec 2022 02:20:55 +0000 (02:20 +0000)]
gccrs: Cleanup unused parameters to fix the bootstrap build

gcc/rust/ChangeLog:

* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Remove unused parameters.
* backend/rust-constexpr.cc (constant_value_1): Likewise.
(fold_non_dependent_init): Likewise.
* backend/rust-tree.cc (publicly_uniquely_derived_p): Likewise.
(instantiation_dependent_expression_p): Likewise.
(type_has_nontrivial_copy_init): Likewise.
(is_normal_capture_proxy): Likewise.
(resolve_nondeduced_context): Likewise.
(undeduced_auto_decl): Likewise.
(require_deduced_type): Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise.
* checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
* checks/lints/rust-lint-unused-var.cc (unused_var_walk_fn): Likewise.
* expand/rust-macro-builtins.cc (try_expand_single_string_literal): Likewise.
(try_expand_many_expr): Likewise.
(parse_single_string_literal): Likewise.
(MacroBuiltin::assert_handler): Likewise.
(MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
(ASTLoweringBase::handle_doc_item_attribute): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/tree/rust-hir-full-test.cc (ConstGenericParam::accept_vis): Likewise.
* lex/rust-lex.cc (Lexer::parse_utf8_escape): Likewise.
(Lexer::parse_string): Likewise.
(Lexer::parse_char_or_lifetime): Likewise.
* lex/rust-lex.h: Likewise.
* metadata/rust-export-metadata.cc: Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
* resolve/rust-ast-verify-assignee.h: Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-item.h: Likewise.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise.
* typecheck/rust-tyty-rules.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.

16 months agogccrs: Skip this debug test case which is failing on the latest mac-os devtools and...
Philip Herron [Mon, 5 Dec 2022 00:31:18 +0000 (00:31 +0000)]
gccrs: Skip this debug test case which is failing on the latest mac-os devtools and its only for debug info

gcc/testsuite/ChangeLog:

* rust/debug/chartype.rs: Skip testcases on Darwin architectures.

16 months agogccrs: Fix undefined behaviour issues on macos
Philip Herron [Mon, 7 Nov 2022 13:43:04 +0000 (13:43 +0000)]
gccrs: Fix undefined behaviour issues on macos

This adds missing copy constructors to HIR::PathExprSegment which were
wrongly defaulting to empty vectors when apply specified generic arguments
to method calls.

gcc/rust/ChangeLog:

* hir/tree/rust-hir-expr.h: Add const `get_method_name`.
* hir/tree/rust-hir-full-decls.h (struct GenericArgs): Move from `struct`...
(class GenericArgs): ...to `class`.
* hir/tree/rust-hir-path.h (struct GenericArgs): Likewise.
(class GenericArgs): Clear `type_args` in copy constructor.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Reorder
debug print.
* typecheck/rust-tyty.h: Add default constructors for `SubstitutionArgumentMappings`.

16 months agogccrs: Add initial support for argument capture of closures
Philip Herron [Fri, 21 Oct 2022 14:43:54 +0000 (15:43 +0100)]
gccrs: Add initial support for argument capture of closures

When we have a closure expression that captures a parent function's
variable we must setup the closure data to contain this. Ignoring
moveability and mutability requires for now, this patch creates the closure
structure with fields for each of the captured variables. When it comes to
compilation of the closure expression in order to support nested closures
we must setup a context of implicit mappings so that for all path
resolution we hit this implicit closure mappings lookups code before any
lookup_var_decl as this decl will not exist so the order here is important
during path resolution which is a similar problem to match expression
destructuring.

Fixes #195

gcc/rust/ChangeLog:

* backend/rust-compile-context.cc (Context::push_closure_context): New function.
(Context::pop_closure_context): Likewise.
(Context::insert_closure_binding): Likewise.
(Context::lookup_closure_binding): Likewise.
* backend/rust-compile-context.h: Declare new functions and closure mappings.
* backend/rust-compile-expr.cc (CompileExpr::visit): Visit captures properly.
(CompileExpr::generate_closure_function): Compile captures properly.
* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Check for
closure bindings.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Compile capture list's
types as well.

gcc/testsuite/ChangeLog:

* rust/execute/torture/closure3.rs: New test.

16 months agogccrs: Add capture tracking to the type info for closures
Philip Herron [Fri, 21 Oct 2022 14:39:52 +0000 (15:39 +0100)]
gccrs: Add capture tracking to the type info for closures

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Pass captures
properly to `TyTy::ClosureType` constructor.
* typecheck/rust-tyty.cc (ClosureType::as_string): Fix string representation.
(ClosureType::clone): Pass `captures` argument.
* typecheck/rust-tyty.h: Add `captures` field.

16 months agogccrs: Add closure binding's tracking to name resolution
Philip Herron [Fri, 21 Oct 2022 12:40:40 +0000 (13:40 +0100)]
gccrs: Add closure binding's tracking to name resolution

When we have a closure block referencing variables in a parent function,
we must track what these are. We do this by having a context of closures
so if we have a variable reference and its declared in a rib whose node id
is less than the node id of the closure's node id we know it must be a
captured variable. We also need to iterate all possible closure contexts
as we might be in the case of a nested closure.

Addresses #195

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Use proper closure
contexts.
* resolve/rust-name-resolver.cc (Scope::lookup_decl_type): New function.
(Scope::lookup_rib_for_decl): Likewise.
(Resolver::insert_resolved_name): Insert captured items.
(Resolver::push_closure_context): New function.
(Resolver::pop_closure_context): Likewise.
(Resolver::insert_captured_item): Likewise.
(Resolver::decl_needs_capture): Likewise.
(Resolver::get_captures): Likewise.
* resolve/rust-name-resolver.h: Declare new functions.

16 months agogccrs: Refactor name resolver to take a Rib::ItemType
Philip Herron [Fri, 21 Oct 2022 11:54:52 +0000 (12:54 +0100)]
gccrs: Refactor name resolver to take a Rib::ItemType

This allows us to track the type of declaration that is stored within a
Rib.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add Rib argument.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise.
(ResolveItem::visit): Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-name-resolver.cc (Rib::lookup_decl_type): Likewise.
(Scope::insert): Likewise.
(Resolver::insert_builtin_types): Likewise.
* resolve/rust-name-resolver.h: Likewise.

16 months agogccrs: Get rid of make builtin macro
Philip Herron [Fri, 21 Oct 2022 12:01:43 +0000 (13:01 +0100)]
gccrs: Get rid of make builtin macro

This macro is a mess and a helper method is much better for this case.

gcc/rust/ChangeLog:

* resolve/rust-name-resolver.cc (MKBUILTIN_TYPE): Remove macro.
(Rib::Rib): Remove `mappings` field.
(Resolver::generate_builtins): Use `setup_builtin` instead of macro.
(Resolver::setup_builtin): New function.
* resolve/rust-name-resolver.h: Declare `setup_builtin`, add FIXME
comment.

16 months agogccrs: Improve lexer dump
Raiki Tamura [Wed, 16 Nov 2022 08:15:24 +0000 (17:15 +0900)]
gccrs: Improve lexer dump

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::Lexer): Add `dump_lex` boolean flag.
(Lexer::skip_token): Dump tokens if flag is enabled.
(Lexer::dump_and_skip): New function.
* lex/rust-lex.h: Include optional.h and declare functions.
* parse/rust-parse-impl.h (Parser::debug_dump_lex_output): Remove old
unused function.
* parse/rust-parse.h: Likewise.
* rust-session-manager.cc (Session::compile_crate): Pass lexer dump
option to lexer.
(Session::dump_lex): New function.
* util/rust-optional.h: Add missing constructor.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
16 months agogccrs: Remove default location. Add visibility location to create_* functions
Dave [Wed, 16 Nov 2022 23:06:44 +0000 (17:06 -0600)]
gccrs: Remove default location. Add visibility location to create_* functions

gcc/rust/ChangeLog:

* ast/rust-item.h: Remoe default location for Visibility class.
* parse/rust-parse-impl.h (Parser::parse_visibility): Pass proper location
when instantiating visibilities.

16 months agogccrs: ast: Dump no comma after self in fn params if it is the last one
Jakub Dupak [Wed, 16 Nov 2022 13:16:51 +0000 (14:16 +0100)]
gccrs: ast: Dump no comma after self in fn params if it is the last one

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agogccrs: ast: Dump remove /* stmp */ comment to not clutter the dump
Jakub Dupak [Wed, 16 Nov 2022 13:03:07 +0000 (14:03 +0100)]
gccrs: ast: Dump remove /* stmp */ comment to not clutter the dump

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Remove extraneous string when
dumping statements.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agogccrs: ast: Remove unused include in rust-ast-dump.cc
Jakub Dupak [Wed, 16 Nov 2022 12:59:16 +0000 (13:59 +0100)]
gccrs: ast: Remove unused include in rust-ast-dump.cc

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc: Remove unused include.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agogccrs: ast: Dump generic parameters
Jakub Dupak [Wed, 16 Nov 2022 12:58:50 +0000 (13:58 +0100)]
gccrs: ast: Dump generic parameters

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
* ast/rust-ast-dump.h: Likewise.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agogccrs: ast: Dump type param type
Jakub Dupak [Tue, 15 Nov 2022 17:39:41 +0000 (18:39 +0100)]
gccrs: ast: Dump type param type

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>