Commit Graph

192640 Commits

Author SHA1 Message Date
Jakub Jelinek
ccb5e63837 scev: Fix a comment typo
When looking at the kernel __popcountdi2 issue, I've noticed a comment typo.

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

	* tree-scalar-evolution.cc (expression_expensive_p): Fix a comment typo.
2022-04-13 09:47:45 +02:00
Jakub Jelinek
db14bb4c6b libgomp: Fix a documentation typo
This fixes a typo in the 5.0 feature support table.

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

	* libgomp.texi: Fix a typo - mutexinouset -> mutexinoutset.
2022-04-13 09:46:53 +02:00
Alexandre Oliva
c1ff207af6 ppc: testsuite: skip pr60203 on no ldbl128
If neither 128-bit long double format is available, skip pr60203.c.


for  gcc/testsuite/ChangeLog

	* gcc.target/powerpc/pr60203.c: Skip on no 128-bit long double.
2022-04-12 22:41:46 -03:00
Alexandre Oliva
6b7cc72947 ppc: testsuite: PROMOTE_MODE fallout pr56605 [PR102146]
The test expects a compare of DImode values, but after the removal of
PROMOTE_MODE from rs6000/, we get SImode.  Adjust the expectations.


for  gcc/testsuite/ChangeLog

	PR target/102146
	* gcc.target/powerpc/pr56605.c: Accept SImode compare operand.
2022-04-12 22:41:45 -03:00
Xi Ruoyao
bb50967fa4
mips: testsuite: enforce -ffat-lto-objects for pr102024-4.c
The body of func is optimized away with -flto -fno-fat-lto-objects, so
the psABI inform is not emitted, causing a test failure.

gcc/testsuite/

	* gcc.target/mips/pr102024-4.c (dg-options): Add
	-ffat-lto-objects.
2022-04-13 09:28:05 +08:00
GCC Administrator
504dae1d37 Daily bump. 2022-04-13 00:16:34 +00:00
Jonathan Wakely
3c742621ed libstdc++: Prefer to use mmap instead of malloc in libbacktrace
As reported in PR libbacktrace/105240, libbacktrace leaks memory when
using malloc for allocations. I originally thought it would be simpler
to just use malloc unconditionally (because it's supported on all
targets) but the leaks make that problematic.

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

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Check for mmap.
	* config.h.in: Regenerate.
	* configure: Regenerate.
2022-04-12 22:38:31 +01:00
Jonathan Wakely
b2c007b87d libstdc++: shrink-to-fit in std::basic_stacktrace::current(skip, max)
If a large stacktrace is reduced to a max depth that is less than half
the capacity it will now be reallocated to remove the unused capacity.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::current): Reallocate
	a smaller container if the unused capacity is larger than the
	used size.
2022-04-12 22:38:31 +01:00
Jonathan Wakely
7cf8875995 libstdc++: Use allocator to construct std::stacktrace_entry objects
Because std::basic_stacktrace<A> is an allocator-aware container its
elements should be initialized using allocator_traits<A>::construct and
destroyed using allocator_traits<A>::destroy.

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

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

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

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace): Use _Impl::_M_clone
	or _Impl::_M_assign to initialize elements in allocated storage.
	(basic_stacktrace::_M_clear()): Use _Impl::_M_resize instead of
	_Impl::_M_destroy.
	(basic_stacktrace::_Impl::_M_destroy()): Replace with ...
	(basic_stacktrace::_Impl::_M_resize(size_type, allocator&)): New
	function.
	(basic_stacktrace::_Impl::_M_push_back): Use _M_xclone. Construct
	new element using allocator.
	(basic_stacktrace::_Impl::_M_clone): New function.
	(basic_stacktrace::_Impl::_M_xclone): New function.
	(basic_stacktrace::_Impl::_M_assign): New function.
2022-04-12 22:38:31 +01:00
Jonathan Wakely
e48933f00d libstdc++: Use nothrow new in std::stacktrace
We can avoid the overhead of handling a bad_alloc exception from
std::allocator<std::stacktrace_entry>::allocate by just calling the
nothrow operator new instead.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
	Use nothrow new instead of try block for std::allocator.
	(basic_stacktrace::_Impl::_M_deallocate): Use delete for
	std::allocator.
2022-04-12 22:38:31 +01:00
Jonathan Wakely
2ce0f5185b libstdc++: Reduce memory usage in std::stacktrace::current
This adds an alternative callback for use in the overload of
basic_stacktrace::current that takes a max_depth parameter. The new
callback will not allow the container to grow past the initial capacity,
which is set to the specified maximum depth.  This avoids allocating
memory for hundreds of frames only to discard them again because of a
small maximum depth limit.

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

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

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

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::current): Replace
	calls to _M_reserve and _S_curr_cb with call to _M_prepare.
	Check return value of backtrace_simple when max depth given.
	(basic_stacktrace::_M_reserve): Remove.
	(basic_stacktrace::_S_curr_cb): Remove.
	(basic_stacktrace::_M_prepare(size_type)): New function to
	reserve initial capacity and return callback.
	(basic_stacktrace::_Impl::_M_allocate): Remove check for 0 < n
	and remove redundant zeroing of _M_frames and _M_capacity.
	(basic_stacktrace::_Impl::_M_push_back): Add [[unlikely]]
	attribute. Assign _Impl instead of swapping.
	* testsuite/19_diagnostics/stacktrace/current.cc: New test.
2022-04-12 22:38:31 +01:00
Antoni Boucher
6e5ad1cc24 libgccjit: Add support for setting the alignment [PR104293]
gcc/jit/
	PR jit/104293
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_24): New ABI tag.
	* docs/topics/expressions.rst: Add documentation for the
	functions gcc_jit_lvalue_set_alignment and
	gcc_jit_lvalue_get_alignment.
	* jit-playback.h: New function (set_alignment).
	* jit-recording.cc: New function (set_alignment).
	* jit-recording.h: New functions (set_alignment, get_alignment)
	and new field (m_alignment).
	* libgccjit.cc: New functions (gcc_jit_lvalue_get_alignment,
	gcc_jit_lvalue_set_alignment)
	* libgccjit.h: New functions (gcc_jit_lvalue_get_alignment,
	gcc_jit_lvalue_set_alignment)
	* libgccjit.map (LIBGCCJIT_ABI_24): New ABI tag.

gcc/testsuite/
	PR jit/104293
	* jit.dg/all-non-failing-tests.h: Mention
	test-setting-alignment.
	* jit.dg/test-setting-alignment.c: New test.
2022-04-12 17:25:04 -04:00
Antoni Boucher
79e1a6fb9b libgccjit: Add function to hide stderr logs [PR104073]
gcc/jit/
	PR jit/104073
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_23): New ABI tag.
	* docs/topics/contexts.rst: Add documentation for the new
	function gcc_jit_context_set_bool_print_errors_to_stderr.
	* jit-common.h: New enum value
	(INNER_BOOL_OPTION_PRINT_ERRORS_TO_STDERR).
	* jit-recording.cc: Handle the new option
	INNER_BOOL_OPTION_PRINT_ERRORS_TO_STDERR.
	* libgccjit.cc: New function
	(gcc_jit_context_set_bool_print_errors_to_stderr).
	* libgccjit.h: New function
	(gcc_jit_context_set_bool_print_errors_to_stderr).
	* libgccjit.map (LIBGCCJIT_ABI_23): New ABI tag.
2022-04-12 17:23:18 -04:00
Antoni Boucher
5780ff348a libgccjit: Add support for register variables [PR104072]
gcc/jit/
	PR jit/104072
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_22): New ABI tag.
	* docs/topics/expressions.rst: Add documentation for the
	function gcc_jit_lvalue_set_register_name.
	* jit-playback.h: New function (set_register_name).
	* jit-recording.cc: New function (set_register_name) and add
	support for register variables.
	* jit-recording.h: New field (m_reg_name) and new function
	(set_register_name).
	* libgccjit.cc: New function (gcc_jit_lvalue_set_register_name).
	* libgccjit.h: New function (gcc_jit_lvalue_set_register_name).
	* libgccjit.map (LIBGCCJIT_ABI_22): New ABI tag.

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

gcc/testsuite/
	PR jit/104072
	* jit.dg/all-non-failing-tests.h: Add new
	test-register-variable.
	* jit.dg/harness.h: Add -fdiagnostics-color=never to context's
	command-line options.
	* jit.dg/test-error-register-variable-bad-name.c: New test.
	* jit.dg/test-error-register-variable-size-mismatch.c: New test.
	* jit.dg/test-register-variable.c: New test.
2022-04-12 17:20:30 -04:00
Antoni Boucher
30f7c83e9c libgccjit: Add support for bitcasts [PR104071]
gcc/jit/
	PR jit/104071
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_21): New ABI tag.
	* docs/topics/expressions.rst: Add documentation for the
	function gcc_jit_context_new_bitcast.
	* jit-playback.cc: New function (new_bitcast).
	* jit-playback.h: New function (new_bitcast).
	* jit-recording.cc: New functions (new_bitcast,
	bitcast::replay_into, bitcast::visit_children,
	bitcast::make_debug_string, bitcast::write_reproducer).
	* jit-recording.h: New class (bitcast) and new function
	(new_bitcast, bitcast::replay_into, bitcast::visit_children,
	bitcast::make_debug_string, bitcast::write_reproducer,
	bitcast::get_precedence).
	* libgccjit.cc: New function (gcc_jit_context_new_bitcast)
	* libgccjit.h: New function (gcc_jit_context_new_bitcast)
	* libgccjit.map (LIBGCCJIT_ABI_21): New ABI tag.

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

gcc/
	PR jit/104071
	* toplev.cc: Call the new function tree_cc_finalize in
	toplev::finalize.
	* tree.cc: New functions (clear_nonstandard_integer_type_cache
	and tree_cc_finalize) to clear the cache of non-standard integer
	types to avoid having issues with some optimizations of
	bitcast where the SSA_NAME will have a size of a cached
	integer type that should have been invalidated, causing a
	comparison of integer constant to fail.
	* tree.h: New function (tree_cc_finalize).
2022-04-12 17:17:50 -04:00
Antoni Boucher
af80ea97b6 libgccjit: Add support for sized integer types, including 128-bit integers [PR95325]
gcc/jit/
	PR target/95325
	* docs/_build/texinfo/libgccjit.texi: Regenerate
	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_20): New ABI tag.
	* docs/topics/types.rst: Add documentation for the new types
	GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
	GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
	GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T, GCC_JIT_TYPE_INT16_T,
	GCC_JIT_TYPE_INT32_T, GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T and
	new functions (gcc_jit_compatible_types, gcc_jit_type_get_size).
	* jit-builtins.cc: Add support for BT_UINT128.
	* jit-common.h: Update the value of NUM_GCC_JIT_TYPES.
	* jit-playback.cc: Add support for the sized integer types.
	* jit-recording.cc: Add support for the sized integer types.
	* jit-recording.h: Add support for comparing integer types
	and new function (is_signed).
	* libgccjit.cc (gcc_jit_compatible_types): New.
	(gcc_jit_type_get_size) New.
	* libgccjit.h: New enum variants for gcc_jit_types
	(GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
	GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
	GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T,
	GCC_JIT_TYPE_INT16_T, GCC_JIT_TYPE_INT32_T,
	GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T) and new functions
	(gcc_jit_compatible_types, gcc_jit_type_get_size).
	* libgccjit.map (LIBGCCJIT_ABI_20): New ABI tag.

gcc/testsuite/
	PR target/95325
	* jit.dg/test-types.c: Add tests for sized integer types.
2022-04-12 17:16:45 -04:00
Jason Merrill
791a968630 c++: local function versioning [PR104669]
There were two problems with this testcase: we weren't copying the target
attribute from the second declaration to the global alias for the first
one (duplicate_decls hunk), and then we were treating the third one as
matching the earlier one even though both are versioned (decls_match hunk).
The latter change required a fix to find_last_decl (used for attribute
mismatch warnings) to give up if we see a versioned function, as in that
case we can't determine whether the decls match, because we are still in the
process of setting the attributes on the new decl.

	PR c++/104669

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* g++.target/i386/mv31.C: New test.
2022-04-12 16:46:58 -04:00
Jason Merrill
164c6a1c5d c++: non-array new alignment [PR102071]
While considering the PR102071 patch for backporting, I noticed that I was
considering the alignment of the array new cookie even when there isn't one
because we aren't allocating an array.

	PR c++/102071

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/aligned-new9.C: Add single-object test.
2022-04-12 16:45:41 -04:00
Thomas Schwinge
aa7874596b Let nvptx-as figure out the target architecture [PR97348]
... now that it has been enhanced to do so.

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

	gcc/
	PR target/97348
	* config/nvptx/nvptx.h (ASM_SPEC): Don't set.
	* config/nvptx/nvptx.opt (misa): Adjust comment.
2022-04-12 19:02:41 +02:00
Thomas Schwinge
71863c997b Revert "[nvptx] Use --no-verify for sm_30"
This reverts commit 12fa7641ce.
2022-04-12 19:02:40 +02:00
Thomas Schwinge
0c9bc1a227 Revert "[nvptx] Fix ASM_SPEC workaround for sm_30"
This reverts commit bf4832d6fa.
2022-04-12 19:02:40 +02:00
Patrick Palka
e2c7070ac7 c++: requires-expr in pack expansion using pack [PR103105]
Here after dependent substitution of {Ts...} into the alias 'wrap',
since we never partially instantiate a requires-expr, we end up with a
requires-expr whose REQUIRES_EXPR_EXTRA_ARGS contains an
ARGUMENT_PACK_SELECT (which just resolves to the parameter pack Ts).
Then when hashing the resulting dependent specialization of A, we crash
from iterative_hash_template_arg since it deliberately doesn't handle
ARGUMENT_PACK_SELECT.

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

	PR c++/103105

gcc/cp/ChangeLog:

	* pt.cc (build_extra_args): Call preserve_args.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires29.C: New test.
	* g++.dg/cpp2a/concepts-requires29a.C: New test.
2022-04-12 12:58:18 -04:00
Richard Biener
7c7e78e9c4 ipa/104303 - revert overly conservative DCE change
The following reverts the DCE change back to the original behavior
which should be handled well during the propagation stage.  That
should fix the failures Thomas Schwinge is reporting.

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

	PR ipa/104303
	* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Do not
	include local escaped memory as obviously necessary stores.
2022-04-12 16:43:08 +02:00
Richard Earnshaw
62082d278d arm: fix testsuite failure of reg_equal_test.c [PR101755]
The test failure in PR101755 is due to the gimple optimizers getting
smarter.  But really we are just testing that RTL expansion is doing
the right thing and annotating a constant accordingly.  So rework the
test to use GIMPLE input and simplify the code entirely.  Also, this
test only ever worked on architecture versions with the MOVW/MOVT
instructions, so check for this before running.

gcc/testsuite/ChangeLog:

	PR target/101755
	* gcc.target/arm/reg_equal_test.c: Convert to gimple test.  Restrict
	to architectures with MOVW/MOVT.
2022-04-12 13:38:44 +01:00
Richard Biener
31cccadcf2 tree-optimization/105235 - clean EH in execute_cse_conv_1
When a FP conversion is removed we have to eventually clean EH.

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

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

	* g++.dg/opt/pr105235-1.C: New testcase.
2022-04-12 11:48:30 +02:00
Przemyslaw Wirkus
1210fd6e69 arm: remove unnecessary armv9-a multilib variant [PR104144]
Remove the armv9-a specific multilib variants.  Instead, arrange to
use either the armv8-a multilibs or the armv7-a versions, depeding on
the configuration.  This eliminates the need to have a version of gas
that understands --march=armv9-a when building GCC.  Very little, if
anything in the standard libraries directly uses Armv9-a features
anyway.

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

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

	PR target/104144
	* gcc.target/arm/multilib.exp: Updated tests.
2022-04-12 10:40:23 +01:00
Richard Biener
1bd96873cf tree-optimization/105232 - handle overly large sizes in component_ref_size
The following properly checks tree_fits_poly_int64_p before converting
a size to a poly_int64.

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

	PR tree-optimization/105232
	* tree.cc (component_ref_size): Bail out for too large
	or non-constant sizes.
2022-04-12 10:53:46 +02:00
Richard Biener
62d5bb0f35 tree-optimization/105226 - avoid splitting abnormal edges
Vectorizer loop versioning tries to version outer loops if possible
but fails to check whether it can actually split the single exit
edge as it will do.

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

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

	* gcc.dg/pr105226.c: New testcase.
2022-04-12 10:53:46 +02:00
Jakub Jelinek
152f243fda i386: i386-expand formatting fixes
While working on the PR105214 patch, I've noticed incorrect formatting
for a bunch of functions where the function names aren't at the start of
lines.

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

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

	* config/i386/i386-expand.cc (ix86_emit_i387_sinh, ix86_emit_i387_cosh,
	ix86_emit_i387_tanh, ix86_emit_i387_asinh, ix86_emit_i387_acosh,
	ix86_emit_i387_atanh, ix86_emit_i387_log1p, ix86_emit_i387_round,
	ix86_emit_swdivsf, ix86_emit_swsqrtsf,
	ix86_expand_atomic_fetch_op_loop, ix86_expand_cmpxchg_loop):
	Formatting fix.
	* config/i386/i386.cc (warn_once_call_ms2sysv_xlogues): Likewise.
2022-04-12 09:20:11 +02:00
Jakub Jelinek
d481d13786 i386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]
The following testcase ICEs, because ix86_emit_i387_log1p attempts to
emit something like
  if (cond)
    some_code1;
  else
    some_code2;
and emits a conditional jump using emit_jump_insn (standard way in
the file) and an unconditional jump using emit_jump.
The problem with that is that if there is pending stack adjustment,
it isn't emitted before the conditional jump, but is before the
unconditional jump and therefore stack is adjusted only conditionally
(at the end of some_code1 above), which makes dwarf2 pass unhappy about it
but is a serious wrong-code even if it doesn't ICE.

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

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

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

	* gcc.dg/asan/pr105214.c: New test.
2022-04-12 09:19:11 +02:00
Jakub Jelinek
91a38e8a84 builtins: Fix up expand_builtin_int_roundingfn_2 [PR105211]
The expansion of __builtin_iround{,f,l} etc. builtins in some cases
emits calls to a different fallback builtin.  To locate the right builtin
it uses mathfn_built_in_1 with the type of the first argument.
If its TYPE_MAIN_VARIANT is {float,double,long_double}_type_node, all is
fine, but on the following testcase, because GIMPLE considers scalar
float conversions between types with the same mode as useless,
TYPE_MAIN_VARIANT of the arg's type is float32_type_node and because there
isn't __builtin_lroundf32 returns NULL and we ICE.

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

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

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

	* gcc.dg/pr105211.c: New test.
2022-04-12 09:16:06 +02:00
Andreas Krebbel
82a4c5c704 IBM zSystems: Add support for z16 as CPU name.
So far z16 was identified as arch14. After the machine has been
announced we can now add the real name.

gcc/ChangeLog:

	* common/config/s390/s390-common.cc: Rename PF_ARCH14 to PF_Z16.
	* config.gcc: Add z16 as march/mtune switch.
	* config/s390/driver-native.cc (s390_host_detect_local_cpu):
	Recognize z16 with -march=native.
	* config/s390/s390-opts.h (enum processor_type): Rename
	PROCESSOR_ARCH14 to PROCESSOR_3931_Z16.
	* config/s390/s390.cc (PROCESSOR_ARCH14): Rename to ...
	(PROCESSOR_3931_Z16): ... throughout the file.
	(s390_processor processor_table): Add z16 as cpu string.
	* config/s390/s390.h (enum processor_flags): Rename PF_ARCH14 to
	PF_Z16.
	(TARGET_CPU_ARCH14): Rename to ...
	(TARGET_CPU_Z16): ... this.
	(TARGET_CPU_ARCH14_P): Rename to ...
	(TARGET_CPU_Z16_P): ... this.
	(TARGET_ARCH14): Rename to ...
	(TARGET_Z16): ... this.
	(TARGET_ARCH14_P): Rename to ...
	(TARGET_Z16_P): ... this.
	* config/s390/s390.md (cpu_facility): Rename arch14 to z16 and
	check TARGET_Z16 instead of TARGET_ARCH14.
	* config/s390/s390.opt: Add z16 to processor_type.
	* doc/invoke.texi: Document z16 and arch14.
2022-04-12 07:58:57 +02:00
Jason Merrill
0899b22d93 c++: rodata and defaulted ctor [PR104142]
Trivial initialization shouldn't bump a variable out of .rodata; if the
result of build_aggr_init is an empty STATEMENT_LIST, throw it away.

	PR c++/104142

gcc/cp/ChangeLog:

	* decl.cc (check_initializer): Check TREE_SIDE_EFFECTS.

gcc/testsuite/ChangeLog:

	* g++.dg/opt/const7.C: New test.
2022-04-11 23:57:42 -04:00
Jason Merrill
4195fced8a c++: using operator= [PR105223]
In a template class A we normally add an implicit using A::operator= as a
placeholder for the implicitly declared operator whose signature we don't
know yet.  In my patch for PR92918 I stopped doing that if the class has an
explicit operator=, but that was wrong; an operator= taking an unrelated
type doesn't prevent the implicit declaration.

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

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

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* g++.dg/template/using31.C: New test.
2022-04-11 23:57:08 -04:00
chenglulu
6afb21b824 LoongArch: Fix bug for tmpdir-g++.dg-struct-layout-1/t033.
gcc/ChangeLog:

	* config/loongarch/loongarch.cc: Fix bug for
	tmpdir-g++.dg-struct-layout-1/t033.
2022-04-12 09:13:51 +08:00
GCC Administrator
da066c4269 Daily bump. 2022-04-12 00:16:37 +00:00
Peter Bergner
d74c4c6a1b rs6000: Handle pcrel sibcalls to longcall functions [PR104894]
Before PCREL in POWER10, we were not allowed to perform sibcalls to longcall
functions since callee's return would skip the TOC restore in the caller.
However, with PCREL we can now safely perform a sibling call to longcall
functions.  The problem with the current code is that pcrel sibcall
branches to a PLT stub label even though -fno-plt was used.  The solution
here is to check for a pcrel longcall and emit an inline plt stub in
that case.

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

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

gcc/testsuite/
	PR target/104894
	* gcc.target/powerpc/pr104894.c: New test.
	* gcc.target/powerpc/pr104894-2.c: New test.
2022-04-11 17:01:25 -05:00
Jason Merrill
3a5e662590 ipa: fix comment typos
gcc/ChangeLog:

	* ipa-free-lang-data.cc (free_lang_data_in_decl): Fix typos.
2022-04-11 17:40:41 -04:00
Jason Merrill
d087b59527 c++: operator new lookup [PR98249]
The standard says, as we quote in the comment just above, that if we don't
find operator new in the allocated type, it should be looked up in the
global scope.  This is specifically ::, not just any namespace, and we
already give an error for an operator new declared in any other namespace.

	PR c++/98249

gcc/cp/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/new3.C: New test.
2022-04-11 17:30:45 -04:00
Jonathan Wakely
b1124648ff libstdc++: Fix incorrect branch prediction hint in std::stacktrace
libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
	Change [[unlikely]] attribute to [[likely]].
2022-04-11 22:10:00 +01:00
Segher Boessenkool
0508f0b810 rs6000: Fix unpack for no-direct-move (PR103623)
The _dm alternative works fine for soft-float, but the _nodm variant
pattern is missing that alternative.  So, let's add that.

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

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

	PR target/105213
	PR target/103623
	* config/rs6000/rs6000.md (unpack<mode>_nodm): Add m,r,i alternative.
2022-04-11 21:00:25 +00:00
Jakub Jelinek
1774ab8486 phiopt: Fix up debug handling in the (x != cst1 ? x : cst2) != cst3 opt [PR105218]
In the PR104639 optimization, I've added code to emit
  # DEBUG D#1 => arg != carg ? arg : oarg
instruction and replace debug uses of the phi with that debug
temp, so that the debug info is still accurrate.
Unfortunately, that is only correct if the middle-bb and
phi bb contain 1 and 2 predecessors, i.e. the ones that
we are using in the optimization (in particular middle-bb has
cond-bb as pred and phi bb cond-bb and middle-bb).
If that is not the case, then we can reach these from another bb
and so the arg SSA_NAME might not be valid there (its definition
doesn't dominate all incoming edges), or, even if it is valid,
might be wrong-debug, e.g. phi argument from some unrelated other
incoming edge might have the carg value that the debug stmt
remaps to oarg.  In theory we could check for that case and
if middle-bb doesn't have a single pred or phi bb 2 preds
check if arg SSA_NAME dominates the phi bb and if all other
phi arguments are expr_not_equal_to the carg value, but this patch
just uses a simpler approach and resets already if we have some
extra incoming edges.

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

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

	* gcc.dg/pr105218.c: New test.
2022-04-11 19:06:59 +02:00
Jonathan Wakely
73da9ec556 libstdc++: Fix std::basic_stacktrace special members [PR105031]
The PR points out that there is a non-constant condition used for an
if-constexpr statement, but there are several other problems with the
copy, move and swap members of std::basic_stacktrace.

libstdc++-v3/ChangeLog:

	PR libstdc++/105031
	* include/std/stacktrace (basic_stacktrace::basic_stacktrace):
	Fix allocator usage in constructors.
	(basic_stacktrace::operator=(const basic_stacktrace&)): Do not
	try to reallocate using const allocator.
	(basic_stacktrace::operator=(basic_stacktrace&&)): Fix
	if-constexpr with non-constant condition. Do not allocate new
	storage if allocator propagates. Do not set _M_size if
	allocation fails.
	(basic_stacktrace::swap(basic_stacktrace&)): Fix typo. Add
	assertion that non-propagating allocators are equal.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: New test.
2022-04-11 17:59:50 +01:00
Jonathan Wakely
bdb9639ee9 libstdc++: Improve behaviour of std::stacktrace::current
This prevents inlining the current() function to guarantee that it is
present in the stacktrace, then tells libbacktrace to skip that frame.

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

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

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::current): Duplicate
	implementation into each overload. Add noinline attribute and
	skip current frame.
	(basic_stacktrace::max_size()): Call _Impl::_S_max_size.
	(basic_stacktrace::_S_curr_cb()): New function defining lambda.
	(basic_stacktrace::_Impl::_S_max_size): New function defining
	maximum size in terms of allocator and size_type.
	(basic_stacktrace::_Impl::_M_allocate): Check against
	max_size().
	* testsuite/19_diagnostics/stacktrace/entry.cc: Call function
	for non-constexpr checks. Check line number is correct.
2022-04-11 17:59:08 +01:00
Alexandre Oliva
ab0f04e4df ppc: testsuite: require target effectively [PR104253]
The testcase was missing dg- before require-effective-target.

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


for gcc/testsuite/ChangeLog

	PR target/104253
	* gcc.target/powerpc/pr104253.c: Add missing dg- before
	require-effective-target.  Prune warning about -mfloat128
	possibly not being fully supported.
2022-04-11 12:11:10 -03:00
Alexandre Oliva
5ce08ecb15 c++: Tolerate cdtors returning this in constexpr
On targets that return this from cdtors, cxx_eval_call_expression may
flag flowing off the end of a dtor.  That's preempted for ctors, and
avoided entirely when dtors return void, but when they return this,
the return value should be conceptually disregarded, without making
room for such internal ABI details to make a program ill-formed, as in
g++.dg/cpp2a/constexpr-dtor12.C on arm-eabi.


for  gcc/cp/ChangeLog

	* constexpr.cc (cxx_eval_call_expression): Disregard dtor
	result.
2022-04-11 12:11:09 -03:00
Alexandre Oliva
396a013a58 c++: Set loc on call even if result is discarded
This patch fixes a divergence in line numbers in diagnostics and,
presumably, debug information, between targets whose cdtors return
this and those that don't.

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

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

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

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

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


for  gcc/cp/ChangeLog

	* semantics.cc (set_cleanup_locs): Propagate locus to call
	wrapped in cast-to-void.
2022-04-11 12:11:08 -03:00
Kito Cheng
4132f6ba95 RISC-V: Support -misa-spec for arch-canonicalize and multilib-generator. [PR104853]
We migrate the default ISA spec version from 2.2 to 20191213, but those scripts
aren't updated at the same time, this patch is making both scripts support
different ISA spec versions.

gcc/ChangeLog:

	PR target/104853
	* config.gcc: Pass -misa-spec to arch-canonicalize and
	multilib-generator.
	* config/riscv/arch-canonicalize: Adding -misa-spec option.
	(SUPPORTED_ISA_SPEC): New.
	(arch_canonicalize): New argument `isa_spec`.
	Handle multiple ISA spec versions.
	* config/riscv/multilib-generator: Adding -misa-spec option.
2022-04-11 22:56:54 +08:00
Jonathan Wakely
c62b0f731b libstdc++: Move stacktrace tests to 19_diagnostics directory
This matches where the feature is defined in the current draft.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/stacktrace/entry.cc: Moved to...
	* testsuite/19_diagnostics/stacktrace/entry.cc: ...here.
	* testsuite/20_util/stacktrace/synopsis.cc: Moved to...
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: ...here.
	* testsuite/20_util/stacktrace/version.cc: Moved to...
	* testsuite/19_diagnostics/stacktrace/version.cc: ...here.
2022-04-11 15:53:22 +01:00
Jonathan Wakely
0df39b0803 libstdc++: Move Filesystem TS path definitions out of class body
This fixes some errors with clang caused by instantiating vector<_Cmpt>
before the _Cmpt type is complete.

libstdc++-v3/ChangeLog:

	* include/experimental/bits/fs_path.h (path): Define special
	members after path::_Cmpt is complete.
2022-04-11 15:53:22 +01:00