Commit Graph

210206 Commits

Author SHA1 Message Date
Jason Merrill
8f3afb83c8 c++: initializer_list<string> and EH [PR114935]
When we initialize an array of a type with a non-trivial destructor, such as
the backing array for the initializer_list, we have a cleanup to destroy any
constructed elements if a later constructor throws.  When the array being
created is a variable, the end of that EH region naturally coincides with
the beginning of the EH region for the cleanup for the variable as a whole.

But if the array is a temporary, or a subobject of one, the array cleanup
region lasts for the rest of the full-expression, along with the normal
cleanup for the TARGET_EXPR.  As a result, when tata throws we clean it up
twice.  Before r14-1705 we avoided this by disabling the array cleanup in
split_nonconstant_init, but after that we don't go through
split_nonconstant_init, so let's handle it in cp_genericize_target_expr.

	PR c++/114935

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_genericize_init): Add flags parm.
	(cp_genericize_init_expr): Pass nullptr.
	(cp_genericize_target_expr): Handle cleanup flags.
	* typeck2.cc (build_disable_temp_cleanup): Factor out of...
	(split_nonconstant_init): ...here.
	* cp-tree.h (build_disable_temp_cleanup): Declare.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-eh1.C: New test.
2024-05-03 16:00:02 -04:00
Gaius Mulley
c943d7b5c4 PR modula2/114929 extra for loop iteration count regression tests
This patch introduces three more for loop tests checking the iteration
count using the CHAR and enumeration data types.

gcc/testsuite/ChangeLog:

	PR modula2/114929
	* gm2/pim/run/pass/testforloopchar.mod: New test.
	* gm2/pim/run/pass/testforloopchar2.mod: New test.
	* gm2/pim/run/pass/testforloopenum.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-03 20:48:01 +01:00
Ken Matsui
cb5d904c77
c++: Implement __is_pointer built-in trait
This patch implements built-in trait for std::is_pointer.

gcc/cp/ChangeLog:

	* cp-trait.def: Define __is_pointer.
	* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER.
	* semantics.cc (trait_expr_value): Likewise.
	(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer.
	Arrange the order lexically around __is_pointer.
	* g++.dg/ext/is_pointer.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03 12:26:36 -07:00
Ken Matsui
9b51b3e79e
c++: Implement __is_volatile built-in trait
This patch implements built-in trait for std::is_volatile.

gcc/cp/ChangeLog:

	* cp-trait.def: Define __is_volatile.
	* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_VOLATILE.
	* semantics.cc (trait_expr_value): Likewise.
	(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/has-builtin-1.C: Test existence of __is_volatile.
	* g++.dg/ext/is_volatile.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03 12:26:17 -07:00
Ken Matsui
7dd8c90521
c++: Implement __is_const built-in trait
This patch implements built-in trait for std::is_const.

gcc/cp/ChangeLog:

	* cp-trait.def: Define __is_const.
	* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_CONST.
	* semantics.cc (trait_expr_value): Likewise.
	(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/has-builtin-1.C: Test existence of __is_const.
	* g++.dg/ext/is_const.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03 12:26:00 -07:00
Vineet Gupta
467ca4a195 RISC-V: miscll comment fixes [NFC]
gcc/ChangeLog:
	* config/riscv/riscv.cc: Comment updates.
	* config/riscv/riscv.h: Ditto.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
2024-05-03 09:33:02 -07:00
Vineet Gupta
301b954940 docs: rtl: document GET_MODE_INNER
gcc/ChangeLog
	* doc/rtl.texi: Add entry for GET_MODE_INNER.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
2024-05-03 09:33:02 -07:00
David Malcolm
5219414f3c testsuite: fix analyzer C++ failures on Solaris [PR111475]
As part of PR analyzer/96395, these patches moved testcases from
gcc.dg/analyzer to c-c++-common/analyzer:
- r14-3503-g55f6a7d949abc7
- r14-3823-g50b5199cff6908
- r14-6564-gae034b9106fbdd

Unfortunately this led to numerous g++ testsuite failures on Solaris,
tracked as PR analyzer/111475.

Almost all of the failures are due to standard library differences where
including a C standard library on C++ e.g. <stdlib.h> leads to the plain
symbols referencing the symbols "std::" via a "using" declaration,
whereas I had written the code expecting them to use symbols in the root
namespace.

The analyzer has special-case handling of many functions by name.
This patch generalizes such handling to also match against functions
in "std::" for all of the cases I found in the testsuite (via manual
inspection of the preprocessed test cases against Solaris headers).
This fixes cases where the analyzer was failing to "know about" the
behavior of such functions.

Other such failures are due to "std::" prefixes appearing in names of
functions in the output, leading to mismatches against expected output.
The patch adds regexes to some cases, and moves some other cases back
from c-c++-common to gcc.dg where the dg-multiline syntax isn't
expressive enough.

Various "fd-*.c" failures relate to Solaris's socket-handling functions
not being marked with "noexcept", where due to PR analyzer/97111 we
mishandle the exception-handling edges in the CFG, leading to leak
false positives.  The patch works around this by adding -fno-exceptions
to these cases, pending a proper fix for PR analyzer/97111.

gcc/analyzer/ChangeLog:
	PR analyzer/111475
	* analyzer.cc (is_special_named_call_p): Add "look_in_std" param.
	(is_std_function_p): Make non-static.
	* analyzer.h (is_special_named_call_p): Add optional "look_in_std"
	param.
	(is_std_function_p): New decl.
	* engine.cc (stmt_requires_new_enode_p): Look for both "signal"
	and "std::signal".
	* kf.cc (register_known_functions): Add various "std::" copies
	of the known functions.
	* known-function-manager.cc
	(known_function_manager::~known_function_manager): Clean up
	m_std_ns_map_id_to_kf.
	(known_function_manager::add_std_ns): New.
	(known_function_manager::get_match): Also look for known "std::"
	functions.
	(known_function_manager::get_by_identifier_in_std_ns): New.
	* known-function-manager.h
	(known_function_manager::add_std_ns): New decl.
	(known_function_manager::get_by_identifier_in_std_ns): New decl.
	(known_function_manager::m_std_ns_map_id_to_kf): New field.
	* sm-file.cc (register_known_file_functions): Add various "std::"
	copies of the known functions.
	* sm-malloc.cc (malloc_state_machine::on_stmt): Handle
	"std::realloc".
	* sm-signal.cc (signal_unsafe_p): Consider "std::" copies of the
	functions as also being async-signal-unsafe.
	(signal_state_machine::on_stmt): Consider "std::signal".

gcc/testsuite/ChangeLog:
	PR analyzer/111475
	* c-c++-common/analyzer/fd-glibc-byte-stream-socket.c: Add
	-fno-exceptions for now.
	* c-c++-common/analyzer/fd-manpage-getaddrinfo-client.c: Likewise.
	* c-c++-common/analyzer/fd-mappage-getaddrinfo-server.c: Rename to...
	* c-c++-common/analyzer/fd-manpage-getaddrinfo-server.c: ...this, and
	add -fno-exceptions for now.
	* c-c++-common/analyzer/fd-socket-meaning.c: Add -fno-exceptions
	for now.
	* c-c++-common/analyzer/fd-symbolic-socket.c: Likewise.
	* c-c++-common/analyzer/flexible-array-member-1.c: Use regexp to
	handle C vs C++ differences in spelling of function name, which
	could have a "std::" prefix on some targets.
	* c-c++-common/analyzer/pr106539.c: Likewise.
	* c-c++-common/analyzer/malloc-ipa-8-unchecked.c: Move back to...
	* gcc.dg/analyzer/malloc-ipa-8-unchecked.c: ...here, dropping
	attempt to generalize output for C vs C++.
	* c-c++-common/analyzer/signal-4a.c: Move back to...
	* gcc.dg/analyzer/signal-4a.c: ...here, dropping attempt to
	generalize output for C vs C++.
	* c-c++-common/analyzer/signal-4b.c: Move back to...
	* gcc.dg/analyzer/signal-4b.c: ...here, dropping attempt to
	generalize output for C vs C++.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-05-03 09:05:29 -04:00
Richard Biener
a2e9032dea Add default bitmap obstack allocation check
The following adds a check that the global bitmap obstack is initialized
when allocating a bitmap from it.

	* bitmap.cc (bitmap_alloc): When using the global bitmap obstack
	assert that is initialized.
2024-05-03 13:26:27 +02:00
Peter Damianov
c5245c869f Silence two instances of -Wcalloc-transposed-args
libgcc/
	* libgcov-util.c (tag_counters): Swap order of arguments to xcalloc.
	(topen_to_memory_representation): Likewise.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>
2024-05-03 13:24:10 +02:00
Andreas Schwab
212d93f4b3 libstdc++: Update powerpc-linux-gnu baseline_symbols
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt: Update.
2024-05-03 13:14:13 +02:00
Richard Biener
7a212ac678 Avoid changing type in the type_hash_canon hash
When building a type and type_hash_canon returns an existing type
avoid changing it, in particular its TYPE_CANONICAL.

	PR middle-end/114931
	* tree.cc (build_array_type_1): Return early when type_hash_canon
	returned an older existing type.
	(build_function_type): Likewise.
	(build_method_type_directly): Likewise.
	(build_offset_type): Likewise.
2024-05-03 13:01:10 +02:00
Alex Coplan
fe40d52561 cfgrtl: Fix MEM_EXPR update in duplicate_insn_chain [PR114924]
The PR shows that when cfgrtl.cc:duplicate_insn_chain attempts to
update the MR_DEPENDENCE_CLIQUE information for a MEM_EXPR we can end up
accidentally dropping (e.g.) an ARRAY_REF from the MEM_EXPR and end up
replacing it with the underlying MEM_REF.  This leads to an
inconsistency in the MEM_EXPR information, and could lead to wrong code.

While the walk down to the MEM_REF is necessary to update
MR_DEPENDENCE_CLIQUE, we should use the outer tree expression for the
MEM_EXPR.  This patch does that.

gcc/ChangeLog:

	PR rtl-optimization/114924
	* cfgrtl.cc (duplicate_insn_chain): When updating MEM_EXPRs,
	don't strip (e.g.) ARRAY_REFs from the final MEM_EXPR.
2024-05-03 09:23:59 +01:00
Jakub Jelinek
7117e1f6bf tree-inline: Add __builtin_stack_{save,restore} pair about inline calls with calls to alloca [PR113596]
The following patch adds save_NNN = __builtin_stack_save (); ...
__builtin_stack_restore (save_NNN);
pair around inline calls which call alloca (alloca calls because of
VLA vars are ignored in that decision).
The patch doesn't change anything on whether we try to inline such calls or
not, it just fixes the behavior when we inline them despite those checks.
The stack save/restore restores the behavior that alloca acquired regions
are freed at the end of the containing call.

2024-05-03  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/113596
	* tree-inline.cc (expand_call_inline): Emit __builtin_stack_save
	and __builtin_stack_restore calls around inlined functions which
	call alloca.

	* gcc.dg/pr113596.c: New test.
	* gcc.dg/tree-ssa/pr113596.c: New test.
2024-05-03 09:44:30 +02:00
Richard Biener
87e35da16d tree-optimization/114921 - _Float16 -> __bf16 isn't noop
The vectorizer handles a _Float16 to __bf16 conversion through
vectorizable_assignment, thinking it's a noop.  The following
fixes this by requiring the same vector component mode when
checking for CONVERT_EXPR_CODE_P, being stricter than for
VIEW_CONVERT_EXPR.

	PR tree-optimization/114921
	* tree-vect-stmts.cc (vectorizable_assignment): Require
	same vector component modes for input and output for
	CONVERT_EXPR_CODE_P.
2024-05-03 08:19:51 +02:00
Patrick Palka
f04dc89a99 c++: remove lookup_template_class's entering_scope flag
lookup_template_class's entering_scope flag controls whether to prefer
returning the primary template type A<T> instead of the corresponding
implicit instantiation A<T>.  When we want to set this flag as part of
substitution, we need to use tsubst_aggr_type which also takes this flag
as a parameter.  But having this separate entry point to type substitution
turned out to be subtly problematic because it doesn't reuse typedefs
like tsubst does, which r13-4729-gbe124477b38a71 fixed in a way that
respects the flag after the fact, by adjusting the entering_scope=false
result of lookup_template_class as if entering_scope=true was passed.

But if that's possible then it means lookup_template_class's
entering_scope flag is not necessary after all -- we can just do the
after-the-fact adjustment everywhere that we currently pass
entering_scope=true to it and tsubst_aggr_type.

To that end, this patch replaces this flag with an adjustment function
adjust_type_for_entering_scope, to be used whereever we currently need
the entering_scope=true behavior.  In turn we can get rid of
tsubst_aggr_type since the only reason we needed this entry point
was to be able to pass entering_scope=true to lookup_template_class.

gcc/cp/ChangeLog:

	* coroutines.cc (instantiate_coro_traits): Adjust call to
	lookup_template_class.
	(instantiate_coro_handle_for_promise_type): Likewise.
	* cp-tree.h (adjust_type_for_entering_scope): Declare.
	(lookup_template_class): Adjust declaration.
	* decl.cc (make_typename_type): Adjust call to
	lookup_template_class. Likewise.
	(get_tuple_size): Likewise.
	(get_tuple_element_type): Likewise.
	* pt.cc (adjust_type_for_entering_scope): Define.
	(tsubst_entering_scope): Define.
	(lookup_template_class): Remove entering_scope parameter.
	Replace tsubst_aggr_type call with tsubst_entering_scope.
	(tsubst_aggr_type): Remove.
	(tsubst_aggr_type_1): Inline into tsubst.
	(tsubst_function_decl): Replace tsubst_aggr_type call
	with tsubst_entering_scope.
	(tsubst_template_decl): Likewise.
	(tsubst_decl): Likewise.
	(tsubst) <case RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE>:
	Inlined from tsubst_aggr_type_1.
	<case BOUND_TEMPLATE_TEMPLATE_PARM>: Adjust calls to
	lookup_template_class.
	<case TYPENAME_TYPE>: Replace tsubst_aggr_type call with
	tsubst_entering_scope.
	<case UNBOUND_CLASS_TEMPLATE>: Likewise.
	Increment processing_template_decl when substituting the
	context.
	(tsubst_expr) <case FIELD_DECL>: Replace tsubst_aggr_type
	call with tsubst_entering_scope.
	<case TEMPLATE_DECL>: Likewise.
	(instantiate_template): Likewise.
	(resolve_typename_type): Adjust lookup_template_class call
	and call adjust_type_for_entering_scope afterward.
	(listify): Adjust lookup_template_class call.
	(alias_ctad_tweaks): Likewise.
	* semantics.cc (finish_template_type): Adjust lookup_template_class
	call and maybe call adjust_type_for_entering_scope afterward.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-02 21:14:30 -04:00
Gaius Mulley
a561dc0f6c PR modula2/114929 for loop fails to iterate down to zero when using a cardinal type
There is a bug in the for loop control code which is exposed when an
unsigned type is used in the iterator variable.  See
gm2/pim/run/pass/testforloopzero[234].mod.  The bug is in the
calculation of the last iterator value.  The bug fix is to avoid using
negative expressions when calculating the last iterator value with a
negative step value.  This patch detects if e1, e2, step value are all
constant, in which case the ztype is used internally and there is no
overflow.  If the last iterator value is held in a variable then it
uses a different method to calculate the last iterator depending upon
the sign of the step value.

gcc/m2/ChangeLog:

	PR modula2/114929
	* gm2-compiler/M2LangDump.mod (GenQualidentSymString): Add
	missing return result into identstr.
	* gm2-compiler/M2Quads.mod (ForLoopLastIteratorVariable): New
	procedure.
	(ForLoopLastIteratorConstant): Ditto.
	(ForLoopLastIterator): Ditto.
	(BuildForToByDo): Remove LastIterator calculation and call
	ForLoopLastIterator instead.
	(FinalValue): Replace with ...
	(LastIterator): ... this.

gcc/testsuite/ChangeLog:

	PR modula2/114929
	* gm2/pim/run/pass/testforloopzero.mod: New test.
	* gm2/pim/run/pass/testforloopzero2.mod: New test.
	* gm2/pim/run/pass/testforloopzero3.mod: New test.
	* gm2/pim/run/pass/testforloopzero4.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-03 01:22:10 +01:00
GCC Administrator
f2d0116090 Daily bump. 2024-05-03 00:17:26 +00:00
Jeff Law
8367c996e5 [committed][RISC-V] Fix nearbyint failure on rv32 and formatting nits
The CI system tripped an execution failure for rv32 with the ceil/round patch.

The fundamental problem is the FP->INT step in these sequences requires the
input size to match the output size.  The output size was based on rv32/rv64.
Meaning that we'd try to do DF->SI->DF.

That doesn't preserve the semantics we want in at least two ways.

The net is we can't use this trick for DF values on rv32.  While inside the
code I realized we had a similar problem for HF modes.  HF modes we can support
only for Zfa.  So I fixed that proactively.

The CI system also pointed out various formatting nits.  I think this fixes all
but one overly long line.

Note I could have factored the TARGET_ZFA test.  But I think as-written it's
clearer what the desired cases to transform are.

gcc/
	* config/riscv/riscv.md (<round_pattern><ANYF:mode>2): Adjust
	condition to match what can be properly implemented.  Fix various
	formatting issues.
	(l<round_pattern><ANYF:mode>si2_sext): Fix formatting
2024-05-02 17:13:12 -06:00
Francois-Xavier Coudert
affd24bfc6 libgfortran: Fix up the autoreconf warnings
This means using sub-dirs and amending some of the recipes accordingly.

libgfortran/ChangeLog:

	* Makefile.am: Use sub-dirs, amend recipies accordingly.
	* Makefile.in: Regenerate.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-05-02 23:03:37 +02:00
Jeff Law
9b54bea455 [RFA][RISC-V] Improve constant synthesis for constants with 2 bits set
In doing some preparation work for using zbkb's pack instructions for constant
synthesis I figured it would be wise to get a sense of how well our constant
synthesis is actually working and address any clear issues.

So the first glaring inefficiency is in our handling of constants with a small
number of bits set.  Let's start with just two bits set.   There are 2016
distinct constants in that space (rv64).  With Zbs enabled the absolute worst
we should ever do is two instructions (bseti+bseti).  Yet we have 503 cases
where we're generating 3+ instructions when there's just two bits set in the
constant.  A constant like 0x8000000000001000 generates 4 instructions!

This patch adds bseti (and indirectly binvi if we needed it) as a first class
citizen for constant synthesis.  There's two components to this change.

First, we can't generate an IOR with a constant like (1 << 45) as an operand.
The IOR/XOR define_insn is in riscv.md.  The constant argument for those
patterns must match an arith_operand which means its not really usable for
generating bseti directly in the cases we care about (at least one of the bits
will be in the 32..63 range and thus won't match arith_operand).

We have a few things we could do.  One would be to extend the existing pattern
to incorporate bseti cases.  But I suspect folks like the separation of the
base architecture (riscv.md) from the Zb* extensions (bitmanip.md).  We could
also try to generate the RTL for bseti
directly, bypassing gen_fmt_ee (which forces undesirable constants into registers based on the predicate of the appropriate define_insn). Neither of these seemed particularly appealing to me.

So what I've done instead is to make ior/xor a define_expand and have the
expander allow a wider set of constant operands when Zbs is enabled.  That
allows us to keep the bulk of Zb* support inside bitmanip.md and continue to
use gen_fmt_ee in the constant synthesis paths.

Note the code generation in this case is designed to first set as many bits as
we can with lui, then with addi since those can both set multiple bits at a
time.  If there are any residual bits left to set we can emit bseti
instructions up to the current cost ceiling.

This results in fixing all of the 503 2-bit set cases where we emitted too many
instructions.  It also significantly helps other scenarios with more bits set.

The testcase I'm including verifies the number of instructions we generate for
the full set of 2016 possible cases.  Obviously this won't be possible as we
increase the number of bits (there are something like 48k cases with just 3
bits set).

gcc/

	* config/riscv/predicates.md (arith_or_zbs_operand): New predicate.
	* config/riscv/riscv.cc (riscv_build_integer_one): Use bseti to set
	single bits when profitable.
	* config/riscv/riscv.md (*<optab><mode>3): Renamed with '*' prefix.
	(<optab><mode>3): New expander for IOR/XOR.

gcc/testsuite
	* gcc.target/riscv/synthesis-1.c: New test.
2024-05-02 14:07:29 -06:00
Joseph Myers
bd010e904d Regenerate gcc.pot
* gcc.pot: Regenerate.
2024-05-02 19:43:15 +00:00
Patrick O'Neill
ff4dc8b10a
RISC-V: Add testcase for pr114734
gcc/testsuite/ChangeLog:

	PR middle-end/114734

	* gcc.target/riscv/rvv/autovec/pr114734.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2024-05-02 09:21:47 -07:00
Jeff Law
1e29da0b65 [committed] [RISC-V] Don't run new rounding tests on newlib risc-v targets
The new round_32.c and round_64.c tests depend on the optimizers to recognize
the conversions feeding the floor/ceil calls and convert them into ceilf,
floorf and the like.

Those transformations only occur when the target indicates the C library has
the appropriate routines (fnclass == function_c99_misc).  While newlib has
these routines, they are not exposed as available to the compiler and thus the
transformation the tests depend on do not happen. Naturally the scan-tests then
fail.

gcc/testsuite
	* gcc.target/riscv/round_32.c: Add require-effective-target glibc.
	* gcc.target/riscv/round_64.c: Likewise.
2024-05-02 08:44:16 -06:00
Nathaniel Shead
7317d62a12 c++: Clear is_unbraced_* when parsing declaration_seq_opt [PR114917]
Currently we incorrectly retain "in_unbraced_linkage_specification_p"
and "in_unbraced_export_declaration_p" when parsing a (braced)
declaration-seq.  This patch ensures that we clear these flags before
parsing the toplevel declarations.

Strictly speaking we don't need to save and restore the flags around the
parsing because there's currently no way to provide new declarations
within the unbraced context after the closing brace, but this patch does
it anyway in case this ever changes and for consistency with other
places that these flags are adjusted.

	PR c++/114917

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_declaration_seq_opt): Clear
	parser->in_unbraced_* flags when parsing toplevel declarations.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/export-5_a.C: New test.
	* g++.dg/modules/export-5_b.C: New test.
	* g++.dg/parse/linkage4.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-05-02 23:52:44 +10:00
Gaius Mulley
67e66c973c modula2: Regenerate libgm2 Makefile.ins using correct include order
Regenerated libgm2/Makefile.in (and subdir Makefile.in) using
aclocal -I .. -I ../config (or autoreconf).

libgm2/ChangeLog:

	* Makefile.in: Regenerate.
	* libm2cor/Makefile.in: Ditto.
	* libm2iso/Makefile.in: Ditto.
	* libm2log/Makefile.in: Ditto.
	* libm2min/Makefile.in: Ditto.
	* libm2pim/Makefile.in: Ditto.
	* aclocal.m4: Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-02 14:38:51 +01:00
Richard Biener
bf33fe90e7 Improve SLP dump and graph
The following notes which lanes are considered live and adds an overload
to produce a graphviz graph for multiple entries into an SLP graph.

	* tree-vect-slp.cc (vect_print_slp_tree): Mark live lanes.
	(dot_slp_tree): New overload for multiple entries.
2024-05-02 15:30:17 +02:00
Iain Sandoe
9b5c0be59d Objective-C, NeXT, v2: Correct a regression in code-gen.
There have been several changes in the ABI of Objective-C which
depend on the OS version targetted.  In this case Protocols and
LabelProtocols should be made weak/hidden/extern from macOS 10.7
however there was a mistake in the code causing this to occur
from macOS 10.6.  Fixed thus.

gcc/objc/ChangeLog:

	* objc-next-runtime-abi-02.cc (WEAK_PROTOCOLS_AFTER): New.
	(next_runtime_abi_02_protocol_decl): Use WEAK_PROTOCOLS_AFTER
	to determine this ABI change.
	(build_v2_protocol_list_address_table): Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-05-02 13:46:37 +01:00
Gaius Mulley
43dc4302b4 PR modula2/113836 gm2 does not dump gimple or quadruples to a file
This patch completes the implementation of dumping the intermediate forms
to file.  It implements the filtering on symbol rules.  Filtering can be
performed through the full text name (given to the GCC tree) or qualified
modula-2 symbol or filename:qualident.

gcc/ChangeLog:

	PR modula2/113836
	* doc/gm2.texi (Compiler options): Add -fm2-debug-trace=,
	-fm2-dump, -fm2-dump-decl=, -fm2-dump-gimple=, -fm2-dump-quad=
	and -fm2-dump-filter=.

gcc/m2/ChangeLog:

	PR modula2/113836
	* gm2-compiler/M2AsmUtil.def: Remove export qualified and
	unused import.
	* gm2-compiler/M2LangDump.mod (AddRuleTextDump): New procedure.
	(AddRuleScopeQualidentDump): Add warning check against unmatched
	rule.
	(GenQualidentSymString): New procedure function.
	(IdentQualidentMatch): New procedure function.
	(IsRuleFilenameMatch): New procedure function.
	(CheckRuleMatch): New procedure function.
	(AddRuleFilenameDump): New procedure function.
	* gm2-gcc/m2misc.cc (m2misc_warning_m2_dump_filter): New function.
	* gm2-gcc/m2misc.def (warning_m2_dump_filter): New procedure.
	* gm2-gcc/m2misc.h (m2misc_warning_m2_dump_filter): New prototype.
	* gm2-gcc/m2pp.cc (VERBOSE_TYPE_DESC): New define.
	(m2pp_identifier): Define out verbose type info.
	(m2pp_constructor): Define out verbose type info.
	(m2pp_assignment): Define out verbose type info.
	* gm2-lang.cc (ENABLE_M2DUMP_ALL): Remove.
	* lang.opt (fm2-dump): Add.
	(fm2-dump-decl=): Add.
	(fm2-dump-gimple=): Add.
	(fm2-dump-quad=): Add.
	(fm2-dump-filter=): Add.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-05-02 13:16:07 +01:00
Marc Poulhiès
4bb21b5cd7 fix single argument static_assert
Single argument static_assert is C++17 only.

gcc/ChangeLog:

	* value-range.h: fix static_assert to use 2 arguments.
2024-05-02 13:49:51 +02:00
Peter Damianov
a704554d2e lto-wrapper: Truncate files using -truncate driver option [PR110710]
This commit changes the Makefiles generated by lto-wrapper to no longer use
the "mv" and "touch" shell commands. These don't exist on Windows, so when the
Makefile attempts to call them, it results in errors like:
The system cannot find the file specified.

This problem only manifested when calling gcc from cmd.exe, and having no
sh.exe present on the PATH. The Windows port of GNU Make searches the PATH for
an sh.exe, and uses it if present.

I have tested this in environments with and without sh.exe on the PATH and
confirmed it works as expected.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>

	PR lto/110710
	* lto-wrapper.cc (run_gcc): Instead of truncating a processed
	ltrans input from the Makefile use the new -truncate option
	to accomplish the same.
2024-05-02 12:42:33 +02:00
Peter Damianov
985b5a90f7 Driver: Add new -truncate option
This commit adds a new option to the driver that truncates one file after
linking.

Tested likeso:

$ gcc hello.c -c
$ du -h hello.o
4.0K  hello.o
$ gcc hello.o -truncate hello.o
$ ./a.out
Hello world
$ du -h hello.o
$ 0   hello.o

$ gcc hello.o -truncate
gcc: error: missing filename after '-truncate'

The motivation for adding this is PR110710. It is used by lto-wrapper to
truncate files in a shell-independent manner.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>

	PR lto/110710
	* common.opt (truncate): New internal option.
	* gcc.cc (totruncate_file): New global.
	(driver_handle_option): Handle -truncate <file>.
	(driver::final_actions): Truncate the file indicated.
2024-05-02 12:42:33 +02:00
Jakub Jelinek
5eb25d1561 libgomp: Add gfx90c, 1036 and 1103 declare variant tests
Recently -march=gfx{90c,1036,1103} support has been added, but corresponding
changes weren't done in the testsuite.

The following patch adds that.

Tested on x86_64-linux (with fiji and gfx1103 devices; had to use
OMP_DEFAULT_DEVICE=1 there, fiji doesn't really work due to LLVM dropping
support, but we still list those as offloading devices).

2024-05-02  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/libgomp.c/declare-variant-4.h (gfx90c, gfx1036, gfx1103):
	New functions.
	(f): Add #pragma omp declare variant directives for those.
	* testsuite/libgomp.c/declare-variant-4-gfx90c.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1036.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1103.c: New test.
2024-05-02 11:56:16 +02:00
Jakub Jelinek
2f15787f2e c++: Implement C++26 P2573R2 - = delete("should have a reason"); [PR114458]
The following patch implements the C++26 P2573R2
= delete("should have a reason"); paper.
I've tried to avoid increasing compile time memory for it when it isn't
used (e.g. by adding a new lang_decl tree member), so the reason is
represented as STRING_CST in DECL_INITIAL (which normally is for
DECL_DELETED_FN error_mark_node) and to differentiate this delete("reason")
initializer from some bogus attempt to initialize a function with "reason"
using the RID_DELETE identifier as TREE_TYPE of the STRING_CST, as nothing
needs to care about the type of the reason.  If preferred it could
be say TREE_LIST with the reason STRING_CST and RID_DELETE identifier or
something similar instead, but that would need more compile time memory when
it is used.

2024-05-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/114458
gcc/c-family/
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine
	__cpp_deleted_function=202403L for C++26.
gcc/cp/ChangeLog
	* parser.cc (cp_parser_pure_specifier): Implement C++26 P2573R2
	- = delete("should have a reason");.  Parse deleted-function-body.
	* decl.cc (duplicate_decls): Copy DECL_INITIAL from DECL_DELETED_FN
	olddecl to newdecl if it is a STRING_CST.
	(cp_finish_decl): Handle deleted init with a reason.
	* decl2.cc: Include "escaped_string.h".
	(grokfield): Handle deleted init with a reason.
	(mark_used): Emit DECL_DELETED_FN reason in the message if any.
	* cp-tree.h (DECL_DELETED_FN): Document representation of
	= delete("reason") on a DECL.
gcc/testsuite/
	* g++.dg/cpp26/feat-cxx26.C (__cpp_deleted_function): Add test.
	* g++.dg/cpp26/delete-reason1.C: New test.
	* g++.dg/cpp26/delete-reason2.C: New test.
	* g++.dg/parse/error65.C (f1): Adjust expected diagnostics.
2024-05-02 09:34:31 +02:00
Richard Biener
c59708fba3 Make graph dumps use graphviz format
SLP build eventually uses graphds graphs, the following makes its
dump use graphviz format so you can easily visualize it.

	* graphds.cc (dump_graph): Dump in graphviz format.
2024-05-02 09:01:11 +02:00
Richard Biener
5176402d6f Remove live-info global bitmap
The following removes the unused tree_live_info_d->global bitmap.

	* tree-ssa-live.h (tree_live_info_d::global): Remove.
	(partition_is_global): Likewise.
	(make_live_on_entry): Do not set bit in global.
	* tree-ssa-live.cc (new_tree_live_info): Do not allocate
	global bitmap.
	(delete_tree_live_info): Do not release it.
	(set_var_live_on_entry): Do not set bits in it.
2024-05-02 09:01:11 +02:00
Stefan Schulze Frielinghaus
66f49ccd40 s390: testsuite: Fix risbg-ll-2.c
Starting with r14-2047-gd0e891406b16dc we see through subregs which
means for f10 in risbg-ll-2.c we do not end up with rosbg_si_noshift but
rather rosbg_di_noshift which materializes in slightly different start
index.  This saves us an extend.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/risbg-ll-2.c: Fix start offset for rosbg of
	f10.
2024-05-02 08:43:50 +02:00
Nathaniel Shead
02917ac452 c++: Don't emit unused GMF partial specializations [PR114630]
The change in r14-8408 to also emit partial specializations in the
global module fragment caused the regression in the linked PR; this
patch fixes this by restricting emitted GM partial specializations to
those that are actually used.

	PR c++/114630

gcc/cp/ChangeLog:

	* module.cc (depset:#️⃣:add_partial_entities): Mark GM
	specializations as unreached.
	(depset:#️⃣:find_dependencies): Also reach entities in the
	DECL_TEMPLATE_SPECIALIZATIONS list.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/partial-3.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-05-02 16:42:56 +10:00
Stefan Schulze Frielinghaus
6c4a745c69 s390: testsuite: Fix zero_bits_compound-1.c
Starting with r12-2731-g96146e61cd7aee we do not generate code like

_5 = (unsigned int) c_2(D);
i_6 = _5 << 8;
_7 = _5 << 20;
i_8 = i_6 | _7;

anymore but instead

_5 = (unsigned int) c_2(D);
_3 = _5 * 1048832;

which leads finally to slightly different assembly code where we
previously ended up for z10 or newer with

lr      %r1,%r2
sll     %r1,8
rosbg   %r1,%r2,32,43,20
llgfr   %r2,%r1
br      %r14

and now

lr      %r1,%r2
sll     %r1,12
ar      %r2,%r1
risbg   %r2,%r2,35,128+55,8
br      %r14

The zero-extend materializes via risbg for which the pattern contains an
"and" which is why the test fails.  Thus, instead of scanning for RTL
expressions rather scan for assembler instructions for s390.

gcc/testsuite/ChangeLog:

	* gcc.dg/zero_bits_compound-1.c: Fix for s390.
2024-05-02 08:39:32 +02:00
Richard Biener
bbe8359932 middle-end/114579 - speed up add_scope_conflicts
The following speeds up stack variable conflict detection by recognizing
that the all-to-all conflict recording is only necessary for CFG merges
as it's the unioning of the live variable sets that doesn't come with
explicit mentions we record conflicts for.

If we employ this optimization we have to make sure to perform the
all-to-all conflict recording for all CFG merges even those into
empty blocks where we might previously have skipped this.

I have reworded the comment before the all-to-all conflict recording
since it seemed to be confusing and missing the point - but maybe I
am also missing something here.

Nevertheless for the testcase in the PR the compile-time spend in
add_scope_conflicts at -O1 drops from previously 67s (39%) to 10s (9%).

	PR middle-end/114579
	* cfgexpand.cc (add_scope_conflicts_1): Record all-to-all
	conflicts only when there's a CFG merge but for all CFG merges.
2024-05-02 08:31:54 +02:00
Nathaniel Shead
ad30265ccf c++: Implement modules ABI for vtable emissions
This patch implements the changes described in
https://github.com/itanium-cxx-abi/cxx-abi/pull/171.

One restriction that is lifted in the ABI that hasn't been updated here
is that the ABI no longer requires unique vtables to be emitted with
vague linkage.  I haven't changed this behaviour for this patch, but in
the future we could look into changing the relevant target hook
('class_data_always_comdat') to default to 'false'.  But the current
behaviour is more forgiving to changes in key function identification.

Since the ABI for vtables attached to named modules no longer depends on
key methods, this also resolves the issue described in PR c++/105224.

	PR c++/105224

gcc/cp/ChangeLog:

	* class.cc (finish_struct_1): Also push classes attached to a
	module into the 'keyed_classes' list.
	* decl.cc (record_key_method_defined): Don't push classes
	attached to a named module into the 'keyed_classes' list.
	* module.cc (trees_in::read_class_def): Likewise.
	* decl2.cc (import_export_class): Uniquely emit vtables for
	non-template classes attached to a named module.
	(vtables_uniquely_emitted): New function.
	(import_export_decl): Update comments. Update with knowledge
	about new kinds of uniquely emitted vtables.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/virt-2_a.C: Update linkage requirements.
	* g++.dg/modules/virt-2_b.C: Likewise.
	* g++.dg/modules/virt-2_c.C: Likewise.
	* g++.dg/modules/virt-4_a.C: New test.
	* g++.dg/modules/virt-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-02 11:38:54 +10:00
GCC Administrator
fd48e674fd Daily bump. 2024-05-02 00:17:09 +00:00
Gerald Pfeifer
ff98aab108 doc: Describe limitations re Ada, D, and Go on FreeBSD
gcc:
	PR target/69374
	PR target/112959
	* doc/install.texi (Specific) <*-*-freebsd*>: The Ada and D
	run-time libraries are broken on i386 which also can affect
	64-bit builds. Go is broken.
2024-05-02 00:47:55 +02:00
Jason Merrill
a12cae9739 c++: drop in-charge for dtors without vbases
Constructors and destructors use the in-charge parameter to decide whether
they're responsible for recursing into virtual bases.  Historically all
destructors had this parameter in order to also distinguish the deleting
destructor.  But r151673 in GCC 4.5 changed the deleting destructor to just
call the complete destructor and then operator delete, making the in-charge
parameter no longer relevant for destructors in classes without virtual
bases.  Having it causes confusion in constexpr evaluation, which assumes
that clones will have the same parameters as the cloned 'tor.

gcc/cp/ChangeLog:

	* cp-tree.h (base_ctor_identifier): Adjust comment.
	* call.cc (in_charge_arg_for_name): Abort on deleting dtor.
	* decl2.cc (maybe_retrofit_in_chrg): Don't add it for
	destructors without vbases, either.
	* constexpr.cc (cxx_eval_call_expression): Remove workaround.

gcc/testsuite/ChangeLog:

	* g++.dg/debug/dwarf2/array-3.C: No more 'int' for in-chrg parm.
	* g++.dg/debug/dwarf2/array-4.C: Likewise.
2024-05-01 14:59:26 -04:00
Jeff Law
76ca6e1f8b [committed] [RISC-V] Trivial pattern cleanup
As I was reviewing and cleaning up some internal work, I noticed a particular
idiom being used elsewhere in the RISC-V backend.

Specifically the use of explicit subregs when an adjustment to the
match_operand would be sufficient.

Let's take this example from the and-not splitter:

>  (define_split
>    [(set (match_operand:X 0 "register_operand")
>         (and:X (not:X (lshiftrt:X (match_operand:X 1 "register_operand")
>                                   (subreg:QI (match_operand:X 2 "register_operand") 0)))
>                (const_int 1)))]

Note the explicit subreg.  We can instead use a match_operand with QImode.
This ever-so-slightly simplifies the machine description.

It also means that if we have a QImode object lying around (say we loaded it
from memory in QImode), we can use it directly rather than first extending it
to X, then truncing to QI.  So we end up with simpler RTL and in rare cases
improve the code we generate.

When used in a define_split or define_insn_and_split we need to make suitable
adjustments to the split RTL.

Bootstrapped a while back.  Just re-tested with a cross.

gcc/
	* config/riscv/bitmanip.md (splitter to use w-form division): Remove
	explicit subregs.
	(zero extended bitfield extraction): Similarly.
	* config/riscv/thead.md (*th_memidx_operand): Similarly.
2024-05-01 12:43:37 -06:00
Jeff Law
fad93e7617 [committed] [RISC-V] Fix detection of store pair fusion cases
We've got the ability to count the number of store pair fusions happening in
the front-end of the pipeline.  When comparing some code from last year vs the
current trunk we saw a fairly dramatic drop.

The problem is the store pair fusion detection code was actively harmful due to
a minor bug in checking offsets.   So instead of pairing up 8 byte stores such
as sp+0 with sp+8, it tried to pair up sp+8 and sp+16.

Given uarch sensitivity I didn't try to pull together a testcase.  But we could
certainly see the undesirable behavior in benchmarks as simplistic as dhrystone
up through spec2017.

Anyway, bootstrapped a while back.  Also verified through our performance
counters that store pair fusion rates are back up.  Regression tested with
crosses a few minutes ago.

gcc/
	* config/riscv/riscv.cc (riscv_macro_fusion_pair_p): Break out
	tests for easier debugging in store pair fusion case.  Fix offset
	check in same.
2024-05-01 11:28:41 -06:00
Jonathan Wakely
1fbe1a50d8
libstdc++: Guard uses of is_pointer_interconvertible_v [PR114891]
This type trait isn't supported by Clang 18. It's only used in static
assertions, so they can just be omitted if the trait isn't available.

libstdc++-v3/ChangeLog:

	PR libstdc++/114891
	* include/std/generator: Check feature test macro before using
	is_pointer_interconvertible_v.
2024-05-01 17:24:01 +01:00
Jason Merrill
c3bc2787b8 c++: const void* memchr [PR113706]
The C++ standard specifies that the <string.h> functions have const and
non-const overloads, unlike C's single function with const argument and
non-const return.  Many systems don't actually implement this, but only add
an overload with non-const argument, so both end up having non-const return.
Solaris <string.h> does what the standard says, but we were penalizing it by
not recognizing the const overload as the built-in memchr.

	PR c++/113706

gcc/cp/ChangeLog:

	* decl.cc (decls_match): Handle memchr return type being
	const-qualified.

gcc/testsuite/ChangeLog:

	* g++.dg/opt/const-builtin1.C: New test.
	* c-c++-common/pr103798-2.c: Remove xfail.
2024-05-01 11:44:13 -04:00
Gerald Pfeifer
0695aba3e9 doc: FreeBSD no longer has a GNU toolchain in base
gcc:
	PR target/69374
	PR target/112959
	* doc/install.texi (Specific) <*-*-freebsd*>: No longer refer
	to GCC or binutils in base. Recommend bootstrap using binutils.
2024-05-01 16:24:12 +02:00
Gerald Pfeifer
81f7965e63 doc: Remove old details on libunwind for ia64-*-hpux*
gcc:
	PR target/69374
	* doc/install.texi (Specific) <ia64-*-hpux*>: Remove details
	on libunwind for GCC 3.4 and earlier.
2024-05-01 11:18:19 +02:00