Commit Graph

210238 Commits

Author SHA1 Message Date
YunQiang Su
70d30dd656 config-ml.in: Fix multi-os-dir search
When building multilib libraries, CC/CXX etc are set with an option
-B*/lib/, instead of -B<something>/lib/<multi-os-directory>.
This will make some trouble in some case, for example building
cross toolchain based on Debian's cross packages:

  If we have libc6-dev-i386-amd64-cross packages installed on
  a non-x86 machine. This package will have the files in
  /usr/x86_4-linux-gnu/lib32.  The fellow configure will fail
  when build libgcc for i386, with complains the libc is not
  i386 ones:
     ../configure --enable-multilib --enable-multilib \
            --target=x86_64-linux-gnu

Let's insert a "-B*/lib/`CC ${flags} --print-multi-os-directory`"
before "-B*/lib/".

This patch is based on the patch used by Debian now.

ChangeLog

	* config-ml.in: Insert an -B option with multi-os-dir into
	compiler commands used to build libraries.
2024-05-06 12:08:28 +08:00
GCC Administrator
ce343444c0 Daily bump. 2024-05-06 00:16:49 +00:00
Harald Anlauf
21e7aa5f3e Fortran: fix issues with class(*) assignment [PR114827]
gcc/fortran/ChangeLog:

	PR fortran/114827
	* trans-array.cc (gfc_alloc_allocatable_for_assignment): Take into
	account _len of unlimited polymorphic entities when calculating
	the effective element size for allocation size and array span.
	Set _len of lhs to _len of rhs.
	* trans-expr.cc (trans_class_assignment): Take into account _len
	of unlimited polymorphic entities for allocation size.

gcc/testsuite/ChangeLog:

	PR fortran/114827
	* gfortran.dg/asan/unlimited_polymorphic_34.f90: New test.
2024-05-05 20:34:15 +02:00
liuhongt
affd77d3fe Update libbid according to the latest Intel Decimal Floating-Point Math Library.
The Intel Decimal Floating-Point Math Library is available as open-source on Netlib[1].

[1] https://www.netlib.org/misc/intel/.

libgcc/config/libbid/ChangeLog:

	* bid128_fma.c (add_and_round): Fix bug: the result
	of (+5E+368)*(+10E-34)+(-10E+369) was returning
	-9999999999999999999999999999999999E+336 instead of expected
	result -1000000000000000000000000000000000E+337.
	(bid128_ext_fma): Ditto.
	(bid64qqq_fma): Ditto.
	* bid128_noncomp.c: Change return type of bid128_class from
	int to class_t.
	* bid128_round_integral.c: Add default case to avoid compiler
	warning.
	* bid128_string.c (bid128_to_string): Replace 0x30 with '0'
	for zero digit.
	(bid128_from_string): Ditto.
	* bid32_to_bid128.c (bid128_to_bid32): Fix Bug. In addition
	to the INEXACT flag, the UNDERFLOW flag needs to be set (and
	was not) when converting an input such as
	+6931674235302037148946035460357709E+1857 to +1000000E-101
	* bid32_to_bid64.c (bid64_to_bid32): fix Bug, In addition to
	the INEXACT flag, the UNDERFLOW flag needs to be set (and was
	not) when converting an input such as +9999999000000001E-111
	to +1000000E-101. Furthermore, significant bits of NaNs are
	set correctly now. For example,  0x7c00003b9aca0000 was
	returning 0x7c000002 instead of 0x 7c000100.
	* bid64_noncomp.c: Change return type of bid64_class from int
	to class_t.
	* bid64_round_integral.c (bid64_round_integral_exact): Add
	default case to avoid compiler warning.
	* bid64_string.c (bid64_from_string): Fix bug for rounding
	up. The input string "10000000000000000" was returning
	+1000000000000001E+1 instead of +1000000000000000E+1.
	* bid64_to_bid128.c (bid128_to_bid64): Fix bug, in addition to
	the INEXACT flag, the UNDERFLOW flag needs to be set (and was
	not) when converting an input such as
	+9999999999999999999999999999999999E-417 to
	+1000000000000000E-398.
	* bid_binarydecimal.c (bid32_to_binary64): Fix bug for
	conversion between binary and bid types. For example,
	0x7c0F4240 was returning 0x7FFFA12000000000 instead of
	expected double precision 0x7FF8000000000000.
	(binary64_to_bid32): Ditto.
	(binary80_to_bid32): Ditto.
	(binary128_to_bid32): Ditto.
	(binary80_to_bid64): Ditto.
	(binary128_to_bid64): Ditto.
	* bid_conf.h (BID_HIGH_128W): New macro.
	(BID_LOW_128W): Ditto.
	* bid_functions.h (__ENABLE_BINARY80__): Ditto.
	(ALIGN): Ditto.
	* bid_inline_add.h (get_add128): Add default case to avoid compiler
	warning.
	* bid_internal.h (get_BID64): Ditto.
	(fast_get_BID64_check_OF): Ditto.
	(ALIGN): New macro.

	Co-authored-by: Anderson, Cristina S <cristina.s.anderson@intel.com>
	Co-authored-by: Akkas, Ahmet <ahmet.akkas@intel.com>
	Co-authored-by: Cornea, Marius <marius.cornea@intel.com>
2024-05-05 16:03:46 +08:00
Andrew Pinski
ffb521f157 Remove m_nloops field from loop_versioning
This is a small cleanup of loop_versioning where m_nloops
is only used in the constructor so we can remove the whole
field.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* gimple-loop-versioning.cc (loop_versioning): Remove m_nloops field.
	(loop_versioning::loop_versioning): Remove initialization of
	m_nloops field and move it to be a local variable.
	(loop_versioning::analyze_blocks): Fix formating.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-05-04 17:25:05 -07:00
GCC Administrator
fda741998e Daily bump. 2024-05-05 00:16:48 +00:00
Aldy Hernandez
6cec31d44a Add prange entries in gimple-range-op.cc.
gcc/ChangeLog:

	* gimple-range-op.cc (class cfn_pass_through_arg1): Add overloads
	for prange operations.
	(cfn_strlen): Same.
2024-05-04 10:25:52 +02:00
Aldy Hernandez
ff306c77b7 Implement operator_ge for prange....
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_ge::fold_range): New.
	(operator_ge::op1_range): New.
	(operator_ge::op2_range): New.
	(operator_ge::op1_op2_relation): New.
	(operator_ge::pointers_handled_p): New.
2024-05-04 10:25:52 +02:00
Aldy Hernandez
76fae4051a Implement operator_gt for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_gt::fold_range): New.
	(operator_gt::op1_range): New.
	(operator_gt::op2_range): New.
	(operator_gt::op1_op2_relation): New.
	(operator_gt::pointers_handled_p): New.
2024-05-04 10:25:52 +02:00
Aldy Hernandez
3a4ee6ea86 Implement operator_le for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_le::fold_range): New.
	(operator_le::op1_range): New.
	(operator_le::op2_range): New.
	(operator_le::op1_op2_relation): New.
	(operator_le::pointers_handled_p): New.
2024-05-04 10:25:52 +02:00
Aldy Hernandez
bfa2323d1d Implement operator_lt for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (max_limit): New.
	(min_limit): New.
	(build_lt): New.
	(build_le): New.
	(build_gt): New.
	(build_ge): New.
	(operator_lt::fold_range): New.
	(operator_lt::op1_range): New.
	(operator_lt::op2_range): New.
	(operator_lt::op1_op2_relation): New.
	(operator_lt::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
bcb226924f Implement operator_equal for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_equal::fold_range): New.
	(operator_equal::op1_range): New.
	(operator_equal::op2_range): New.
	(operator_equal::op1_op2_relation): New.
	(operator_equal::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
d1be4c907f Implement operator_not_equal for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_not_equal::fold_range): New.
	(operator_not_equal::op1_range): New.
	(operator_not_equal::op2_range): New.
	(operator_not_equal::op1_op2_relation): New.
	(operator_not_equal::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
6b9e640d49 Implement operator_bitwise_or for prange.
We seem to have a range-op entry for pointer bitwise OR that we've
inherited from the original VRP implementation, but it never gets
used.  If this is not valid gimple, we can safely remove this entry.

gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_bitwise_or::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
e58f149169 Implement operator_bitwise_and for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_bitwise_and::fold_range): New.
	(operator_bitwise_and::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
f803b93fee Implement operator_pointer_diff for prange.
gcc/ChangeLog:

	* range-op-ptr.cc
	(operator_pointer_diff::op1_op2_relation_effect): New.
	(operator_pointer_diff::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
86ff3c45ea Implement pointer_plus_operator for prange.
gcc/ChangeLog:

	* range-op-ptr.cc (class pointer_plus_operator): Add overloaded declarations
	for pointer variants.
	(pointer_plus_operator::fold_range): New.
	(pointer_plus_operator::op2_range): New.
	(pointer_plus_operator::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
54d3fd6d9f Implement operator_addr_expr for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_addr_expr::op1_range): New.
	(operator_addr_expr::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
1a4f5d4991 Implement operator_min and operator_max for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_min::fold_range): New.
	(operator_min::pointers_handled_p): New.
	(operator_max::fold_range): New.
	(operator_max::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
95fce0dc73 Implement operator_cast for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_cast::fold_range): New.
	(operator_cast::op1_range): New.
	(operator_cast::lhs_op1_relation): New.
	(operator_cast::pointers_handled_p): New.
2024-05-04 10:25:51 +02:00
Aldy Hernandez
a91fd7b434 Implement operator_cst for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for pointer variants.
	* range-op-ptr.cc (operator_cst::fold_range): New.
	(operator_cst::pointers_handled_p): New.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
e7b6e9663e Implement operator_identity for prange.
gcc/ChangeLog:

	* range-op-mixed.h: Add overloaded declarations for fold_range, op1_range,
	lhs_op1_relation, pointers_handled_p.
	* range-op-ptr.cc (operator_identity::fold_range): New.
	(operator_identity::lhs_op1_relation): New.
	(operator_identity::op1_range): New.
	(operator_identity::pointers_handled_p): New.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
31377eed51 Implement range-op dispatch for prange.
This patch adds the range-op dispatch code for prange, and adds some
temporary sanity checks (for flag_checking only) to make sure we handle
all the pointer/integer variants.

In order to make sure I got all the combinations right, I started with
a clean slate, trapping on all pointer operands.  Then I added support
for each one piecemeal.  To verify the work, I added a
pointers_handled_p() helper that is implemented for each range-op
entry and returns TRUE iff the operator can handle a given combination
of pointers.  If this helper returns false, we will trap, because it
indicates an operator that was not implemented.  This is temporary
checking code, and I will rip it out once the the dust has
settled in a few days.

gcc/ChangeLog:

	* range-op-mixed.h: Add using declarator for all classes.
	* range-op-ptr.cc (range_operator::pointers_handled_p): New.
	(range_operator::fold_range): New.
	(range_operator::op1_op2_relation_effect): New.
	(range_operator::op1_range): New.
	(range_operator::op2_range): New.
	(range_operator::op1_op2_relation): New.
	(range_operator::lhs_op1_relation): New.
	(range_operator::update_bitmask): New.
	(class pointer_plus_operator): New.
	(class operator_pointer_diff): New.
	(class hybrid_min_operator): New.
	(class hybrid_max_operator): New.
	* range-op.cc: Add RO_PPP, RO_PPI, RO_IPP, RO_IPI, RO_PIP, RO_PII.
	(range_op_handler::discriminator_fail): New.
	(has_pointer_operand_p): New.
	(range_op_handler::fold_range): Add pointer support.
	(range_op_handler::op1_range): Same.
	(range_op_handler::op2_range): Same.
	(range_op_handler::lhs_op1_relation): Same.
	(range_op_handler::lhs_op2_relation): Same.
	(range_op_handler::op1_op2_relation): Same.
	(class operator_div): Add using.
	(class operator_lshift): Add using.
	(class operator_rshift):Add using.
	(class operator_trunc_mod):Add using.
	(class operator_absu):Add using.
	* range-op.h (enum range_op_dispatch_type): New.
	Add extern definitions for RO_*.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
ddf039adef Add prange implementation for get_legacy_range.
gcc/ChangeLog:

	* value-range.cc (get_legacy_range): New version for prange.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
7c1b136630 Add hashing support for prange.
gcc/ChangeLog:

	* value-range.cc (add_vrange): Add prange support.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
f859996a97 Add storage support for prange.
gcc/ChangeLog:

	* value-range-storage.cc (vrange_allocator::clone_varying): Add
	prange support.
	(vrange_allocator::clone_undefined): Same.
	(vrange_storage::alloc): Same.
	(vrange_storage::set_vrange): Same.
	(vrange_storage::get_vrange): Same.
	(vrange_storage::fits_p): Same.
	(vrange_storage::equal_p): Same.
	(prange_storage::alloc): New.
	(prange_storage::prange_storage): New.
	(prange_storage::set_prange): New.
	(prange_storage::get_prange): New.
	(prange_storage::equal_p): New.
	(prange_storage::fits_p): New.
	* value-range-storage.h (class prange_storage): Add prange support.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
a7f1285380 Add streaming support for prange.
gcc/ChangeLog:

	* data-streamer-in.cc (streamer_read_value_range): Add prange support.
	* data-streamer-out.cc (streamer_write_vrange): Same.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
64993a89ad Implement basic prange class.
This provides a bare prange class with bounds and bitmasks.  It will
be a drop-in replacement for pointer ranges, so we can pull their
support from irange.  The range-op code will be contributed as a
follow-up.

The code is disabled by default, as irange::supports_p still accepts
pointers:

inline bool
irange::supports_p (const_tree type)
{
  return INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type);
}

Once the prange operators are implemented in range-ops, pointer
support will be removed from irange to activate pranges.

gcc/ChangeLog:

	* value-range-pretty-print.cc (vrange_printer::visit): New.
	* value-range-pretty-print.h: Declare prange visit() method.
	* value-range.cc (vrange::operator=): Add prange support.
	(vrange::operator==): Same.
	(prange::accept): New.
	(prange::set_nonnegative): New.
	(prange::set): New.
	(prange::contains_p): New.
	(prange::singleton_p): New.
	(prange::lbound): New.
	(prange::ubound): New.
	(prange::union_): New.
	(prange::intersect): New.
	(prange::operator=): New.
	(prange::operator==): New.
	(prange::invert): New.
	(prange::verify_range): New.
	(prange::update_bitmask): New.
	(range_tests_misc): Use prange.
	* value-range.h (enum value_range_discriminator): Add VR_PRANGE.
	(class prange): New.
	(Value_Range::init): Add prange support.
	(Value_Range::operator=): Same.
	(Value_Range::supports_type_p): Same.
	(prange::prange):  New.
	(prange::supports_p): New.
	(prange::supports_type_p): New.
	(prange::set_undefined): New.
	(prange::set_varying): New.
	(prange::set_nonzero): New.
	(prange::set_zero): New.
	(prange::contains_p): New.
	(prange::zero_p): New.
	(prange::nonzero_p): New.
	(prange::type): New.
	(prange::lower_bound): New.
	(prange::upper_bound): New.
	(prange::varying_compatible_p): New.
	(prange::get_bitmask): New.
	(prange::fits_p): New.
2024-05-04 10:25:50 +02:00
Aldy Hernandez
f589196794 Minimal prange class showing inlining degradation to VRP.
There is a 2% slowdown to VRP unrelated to the work at hand.  This patch
is a skeleton implementation of prange that exhibits this degradation.  It
is meant as a place in the commit history we can return to in order to revisit
the issue.

The relevant discussion is here:

https://gcc.gnu.org/pipermail/gcc/2024-May/243898.html

gcc/ChangeLog:

	* value-range.h (class prange): New.
2024-05-04 10:25:23 +02:00
GCC Administrator
3e3d115c94 Daily bump. 2024-05-04 00:16:30 +00:00
Ian Lance Taylor
b69dac54ef libbacktrace: add DLLS as they are loaded
Patch from Björn Schäpers.

	* pecoff.c (struct dll_notification_data): Define.
	(LDR_DLL_NOTIFICATION): New typedef.
	(LDR_REGISTER_FUNCTION): New typedef.
	(struct dll_notification_context): Define.
	(dll_notification): New static function.
	(backtrace_initialize): Register DLL notification.
2024-05-03 15:25:00 -07:00
Andrew Pinski
04f24e44fb Fix printing COMPOUND_EXPR in .original [PR23872]
Starting with the merge of the openmp branch into the trunk
(r0-73077-g953ff28998b59b), COMPOUND_EXPR started to be printed
as `expr; , expr` which is wrong. This was due to the wrong
conversion of dumping_stmts into `!(flags & TDF_SLIM)`. That is wrong
as we are not dumping stmts at this point (`!(flags & TDF_SLIM)` was always
true for this case as TDF_SLIM case was handled before hand). So switch it
to be always false.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	PR middle-end/23872
	* tree-pretty-print.cc (dump_generic_node <case COMPOUND_EXPR>): Fix
	calls to dump_generic_node and also remove unreachable code that is testing
	`flags & TDF_SLIM`.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/atomic-21.f90: Update testcase for the removal of `;`.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-05-03 14:48:55 -07:00
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