Commit Graph

215361 Commits

Author SHA1 Message Date
Denis Chertykov
fe1486e118 The fix for PR117191
Wrong code appears after dse2 pass because it removes necessary insns.
(ie insn 554 - store to frame spill slot)
This happened because LRA pass doesn't cleanup the code exactly like reload does.
The reload1.c has a special pass for such cleanup.
The reload removes CLOBBER insns with spill slots like this:
(insn 202 184 186 7 (clobber (mem/c:TI (plus:HI (reg/f:HI 28 r28)
                (const_int 1 [0x1])) [3 %sfp+1 S16 A8])) -1
     (nil))

Fragment from reload1.c:
--------------------------------------------------------------------------------
  reload_completed = 1;

  /* Make a pass over all the insns and delete all USEs which we inserted
     only to tag a REG_EQUAL note on them.  Remove all REG_DEAD and REG_UNUSED
     notes.  Delete all CLOBBER insns, except those that refer to the return
     value and the special mem:BLK CLOBBERs added to prevent the scheduler
     from misarranging variable-array code, and simplify (subreg (reg))
     operands.  Strip and regenerate REG_INC notes that may have been moved
     around.  */

  for (insn = first; insn; insn = NEXT_INSN (insn))
    if (INSN_P (insn))
      {
	rtx *pnote;

	if (CALL_P (insn))
	  replace_pseudos_in (& CALL_INSN_FUNCTION_USAGE (insn),
			      VOIDmode, CALL_INSN_FUNCTION_USAGE (insn));

	if ((GET_CODE (PATTERN (insn)) == USE
	     /* We mark with QImode USEs introduced by reload itself.  */
	     && (GET_MODE (insn) == QImode
		 || find_reg_note (insn, REG_EQUAL, NULL_RTX)))
	    || (GET_CODE (PATTERN (insn)) == CLOBBER
		&& (!MEM_P (XEXP (PATTERN (insn), 0))
		    || GET_MODE (XEXP (PATTERN (insn), 0)) != BLKmode
		    || (GET_CODE (XEXP (XEXP (PATTERN (insn), 0), 0)) != SCRATCH
			&& XEXP (XEXP (PATTERN (insn), 0), 0)
				!= stack_pointer_rtx))
		&& (!REG_P (XEXP (PATTERN (insn), 0))
		    || ! REG_FUNCTION_VALUE_P (XEXP (PATTERN (insn), 0)))))
	  {
	    delete_insn (insn);
	    continue;
	  }
--------------------------------------------------------------------------------

LRA have a similar place where it removes unnecessary insns, but not CLOBBER insns with
memory spill slots. It's `lra_final_code_change' function.

I just mark a CLOBBER insn with pseudo spilled to memory for removing it later together
with LRA temporary CLOBBER insns.

	PR rtl-optimization/117191
gcc/
	* lra-spills.cc (spill_pseudos): Mark a CLOBBER insn with pseudo
	spilled to memory for removing it later together with LRA temporary
	CLOBBER insns.
2024-11-15 00:50:36 +04:00
Jonathan Wakely
45cc42d6dc
libstdc++: Make equal and is_permutation short-circuit (LWG 3560)
We already implement short-circuiting for random access iterators, but
we also need to do so for ranges::equal and ranges::is_permutation when
given sized ranges that are not random access ranges (e.g. std::list).

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__is_permutation_fn::operator()):
	Short-circuit for sized ranges with different sizes, as per LWG
	3560.
	* include/bits/ranges_algobase.h (__equal_fn::operator()):
	Likewise.
	* include/bits/stl_algo.h (__is_permutation): Use if-constexpr
	for random access iterator branches.
	* include/bits/stl_algobase.h (__equal4): Likewise.
	* testsuite/25_algorithms/equal/lwg3560.cc: New test.
	* testsuite/25_algorithms/is_permutation/lwg3560.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-11-14 20:01:25 +00:00
Martin Jambor
012f5a22ba
ipa: Rationalize IPA-VR computations across pass-through jump functions
Currently ipa_value_range_from_jfunc and
propagate_vr_across_jump_function contain similar but not same code
for dealing with pass-through jump functions.  This patch puts these
common bits into one function which can also handle comparison
operations.

gcc/ChangeLog:

2024-11-01  Martin Jambor  <mjambor@suse.cz>

	PR ipa/114985
	* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): New function.
	(ipa_value_range_from_jfunc): Move the common functionality to the
	above new function, adjust the rest so that it works with it well.
	(propagate_vr_across_jump_function): Likewise.
2024-11-14 20:55:22 +01:00
Patrick Palka
361050589b libstdc++: Implement LWG 3563 changes to keys_view and values_view
This LWG issue corrects the definition of these alias templates to make
them suitable for alias CTAD.

libstdc++-v3/ChangeLog:

	* include/std/ranges (keys_view): Adjust as per LWG 3563.
	(values_view): Likewise.
	* testsuite/std/ranges/adaptors/elements.cc (test08): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-11-14 13:27:41 -05:00
Jonathan Wakely
4a3a0be34f
libstdc++: Fix get<0> constraint for lvalue ranges::subrange (LWG 3589)
Apprived at October 2021 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::begin): Fix constraint,
	as per LWG 3589.
	* testsuite/std/ranges/subrange/lwg3589.cc: New test.
2024-11-14 17:34:29 +00:00
GCC Administrator
5673fc0c7b Daily bump. 2024-11-14 17:20:15 +00:00
Jeff Law
e5d6e857af contrib: Add another ignored commit
* gcc-changelog/git_update_version.py (ignored_commits): Add
	another ignored commit.
2024-11-14 10:14:53 -07:00
Jonathan Wakely
e627a941dc
libstdc++: Make _GLIBCXX_NODISCARD work for C++11 and C++14
The _GLIBCXX_NODISCARD macro only expands to [[__nodiscard__]] for C++17
and later, but all supported compilers will allow us to use that for
C++11 and C++14 too. Enable it for those older standards, to give
improved diagnostics for users of those older standards.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_NODISCARD): Expand for C++11
	and C++14.
	* testsuite/22_locale/locale/cons/12438.cc: Adjust dg-warning to
	expect nodiscard warnings for C++11 and C++14 as well.
	* testsuite/22_locale/locale/operations/2.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/1_neg.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/2_neg.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/3_neg.cc: Likewise.
	* testsuite/25_algorithms/find_first_of/concept_check_1.cc:
	Likewise.
	* testsuite/25_algorithms/is_permutation/2.cc: Likewise.
	* testsuite/25_algorithms/lexicographical_compare/71545.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/irreflexive.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc: Likewise.
	* testsuite/25_algorithms/minmax/3.cc: Likewise.
	* testsuite/25_algorithms/search/78346.cc: Likewise.
	* testsuite/25_algorithms/search_n/58358.cc: Likewise.
	* testsuite/25_algorithms/unique/1.cc: Likewise.
	* testsuite/25_algorithms/unique/11480.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc: Likewise.
	* testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc:
	Likewise.
	* testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc:
	Likewise.
	* testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc:
	Likewise.
	* testsuite/ext/concept_checks.cc: Likewise.
	* testsuite/ext/is_heap/47709.cc: Likewise.
	* testsuite/ext/is_sorted/cxx0x.cc: Likewise.
2024-11-14 17:00:40 +00:00
Jeff Law
c924a03ae1 contrib: Add 2 further ignored commits
I goof'd and double-reverted a change.  Add those to the ignore
list, leaving the final reversion as-is.

	* gcc-changelog/git_update_version.py (ignored_commits): Add 2
	further commits.
2024-11-14 09:44:54 -07:00
Jason Merrill
985bc95bd6 libstdc++: stdc++.h and <coroutine>
r13-3036 moved #include <coroutine> into the new freestanding section, but
also moved it from a C++20 section to a C++23 section.  This patch moves it
back.

Incidentally, I'm curious why a few headers were removed from the hosted
section (including <coroutine>), but most were left in place, so we have
redundant includes of most hosted headers.

libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h: <coroutine> is C++20.
2024-11-14 11:39:31 -05:00
Jason Merrill
835530f4ee c++: fix namespace alias export
This affected std::views in module std.

gcc/cp/ChangeLog:

	* name-lookup.cc (do_namespace_alias): set_originating_module after
	pushdecl.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/namespace-7_a.C: New test.
	* g++.dg/modules/namespace-7_b.C: New test.
2024-11-14 11:34:06 -05:00
Jason Merrill
e8ebc91615 c++: module dialect tweak
Coroutines have been enabled by -std=c++20 since GCC 11.

gcc/cp/ChangeLog:

	* module.cc (module_state_config::get_dialect): Expect coroutines in
	C++20.
2024-11-14 11:34:06 -05:00
Jan Hubicka
2361049082 Fix common.opt.urls
gcc/ChangeLog:

	* common.opt.urls: Fix.
2024-11-14 17:29:14 +01:00
Jeff Law
72677e1119 Revert "Reapply "[PATCH v2] RISC-V: zero_extend(not) -> xor optimization [PR112398]""
This reverts commit 10d76b7f1e.
2024-11-14 09:26:11 -07:00
Yury Khrustalev
4bce1f71c9 aarch64: Fix nonlocal goto tests incompatible with GCS
gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/gcs-nonlocal-3.c: New test.
	* gcc.target/aarch64/sme/nonlocal_goto_4.c: Update.
	* gcc.target/aarch64/sme/nonlocal_goto_5.c: Update.
	* gcc.target/aarch64/sme/nonlocal_goto_6.c: Update.
2024-11-14 16:15:14 +00:00
Matthieu Longo
6cc6f75374 aarch64: Fix tests incompatible with GCS
gcc/testsuite/ChangeLog:

	* g++.target/aarch64/return_address_sign_ab_exception.C: Update.
	* gcc.target/aarch64/eh_return.c: Update.
2024-11-14 16:15:14 +00:00
Richard Ball
e36249f822 aarch64: Add tests and docs for indirect_return attribute
This patch adds a new testcase and docs for indirect_return
attribute.

gcc/ChangeLog:

	* doc/extend.texi: Add AArch64 docs for indirect_return
	attribute.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/indirect_return-1.c: New test.
	* gcc.target/aarch64/indirect_return-2.c: New test.
	* gcc.target/aarch64/indirect_return-3.c: New test.

Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
2024-11-14 16:15:13 +00:00
Szabolcs Nagy
80fabc8d6b aarch64: Introduce indirect_return attribute
Tail calls of indirect_return functions from non-indirect_return
functions are disallowed even if BTI is disabled, since the call
site may have BTI enabled.

Needed for swapcontext within the same function when GCS is enabled.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_gnu_attributes): Add
	indirect_return.
	(aarch64_gen_callee_cookie): Use indirect_return attribute.
	(aarch64_callee_indirect_return): New.
	(aarch_fun_is_indirect_return): New.
	(aarch64_function_ok_for_sibcall): Disallow tail calls if caller
	is non-indirect_return but callee is indirect_return.
	(aarch64_function_arg): Add indirect_return to cookie.
	(aarch64_init_cumulative_args): Record indirect_return in
	CUMULATIVE_ARGS.
	(aarch64_comp_type_attributes): Check indirect_return attribute.
	(aarch64_output_mi_thunk): Add indirect_return to cookie.
	* config/aarch64/aarch64.h (CUMULATIVE_ARGS): Add new field
	indirect_return.
	* config/aarch64/aarch64.md (tlsdesc_small_<mode>): Update.
	* config/aarch64/aarch64-opts.h (AARCH64_NUM_ABI_ATTRIBUTES): New.
	* config/aarch64/aarch64-protos.h (aarch64_gen_callee_cookie): Update.
	* config/arm/aarch-bti-insert.cc (call_needs_bti_j): New.
	(rest_of_insert_bti): Use call_needs_bti_j.
	* config/arm/aarch-common-protos.h
	(aarch_fun_is_indirect_return): New.
	* config/arm/arm.cc
	(aarch_fun_is_indirect_return): New.

Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
2024-11-14 16:15:13 +00:00
Szabolcs Nagy
6f73c29d2f aarch64: libatomic: add GCS marking to asm
libatomic/ChangeLog:

	* config/linux/aarch64/atomic_16.S (FEATURE_1_GCS): Define.
	(GCS_FLAG): Define if GCS is enabled.
	(GNU_PROPERTY): Add GCS_FLAG.
2024-11-14 16:15:12 +00:00
Szabolcs Nagy
d8374290e5 aarch64: libgcc: add GCS marking to asm
libgcc/ChangeLog:

	* config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define.
	(GCS_FLAG): Define if GCS is enabled.
	(GNU_PROPERTY): Add GCS_FLAG.
2024-11-14 16:15:12 +00:00
Szabolcs Nagy
608da24401 aarch64: Emit GNU property NOTE for GCS
gcc/ChangeLog:

	* config/aarch64/aarch64.cc (GNU_PROPERTY_AARCH64_FEATURE_1_GCS):
	Define.
	(aarch64_file_end_indicate_exec_stack): Set GCS property bit.
2024-11-14 16:15:11 +00:00
Szabolcs Nagy
2a330ec149 aarch64: Add GCS support to the unwinder
Follows the current linux ABI that uses single signal entry token
and shared shadow stack between thread and alt stack.
Could be behind __ARM_FEATURE_GCS_DEFAULT ifdef (only do anything
special with gcs compat codegen) but there is a runtime check anyway.

Change affected tests to be compatible with -mbranch-protection=standard

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h (_Unwind_Frames_Extra): Update.
	(_Unwind_Frames_Increment): Define.
2024-11-14 16:15:11 +00:00
Szabolcs Nagy
c283cf27b0 aarch64: Add target pragma tests for gcs
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add gcs specific
	tests.
2024-11-14 16:15:10 +00:00
Szabolcs Nagy
500de6c0e5 aarch64: Add test for GCS ACLE defs
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pragma_cpp_predefs_1.c: GCS test.
2024-11-14 16:15:10 +00:00
Szabolcs Nagy
5ec239f1e2 aarch64: Add ACLE feature macros for GCS
gcc/ChangeLog:

	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define
	macros for GCS.
2024-11-14 16:15:09 +00:00
Szabolcs Nagy
89c7ebdee1 aarch64: Add non-local goto and jump tests for GCS
These are scan asm tests only, relying on existing execution tests
for runtime coverage.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/gcs-nonlocal-1.c: New test.
	* gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c: New test.
	* gcc.target/aarch64/gcs-nonlocal-2.c: New test.
	* gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c: New test.
	* gcc.target/aarch64/gcs-nonlocal-1.h: New header file.
	* gcc.target/aarch64/gcs-nonlocal-2.h: New header file.
2024-11-14 16:15:09 +00:00
Szabolcs Nagy
41479351d6 aarch64: Add GCS support for nonlocal stack save
Nonlocal stack save and restore has to also save and restore the GCS
pointer. This is used in __builtin_setjmp/longjmp and nonlocal goto.

The GCS specific code is only emitted if GCS branch-protection is
enabled and the code always checks at runtime if GCS is enabled.

The new -mbranch-protection=gcs and old -mbranch-protection=none code
are ABI compatible: jmpbuf for __builtin_setjmp has space for 5
pointers, the layout is

  old layout: fp, pc, sp, unused, unused
  new layout: fp, pc, sp, gcsp, unused

Note: the ILP32 code generation is wrong as it saves the pointers with
Pmode (i.e. 8 bytes per pointer), but the user supplied buffer size is
for 5 pointers (4 bytes per pointer), this is not fixed.

The nonlocal goto has no ABI compatibility issues as the goto and its
destination are in the same translation unit.

We use CDImode to allow extra space for GCS without the effect of 16-byte
alignment.

gcc/ChangeLog:

	* config/aarch64/aarch64.h (STACK_SAVEAREA_MODE): Make space for gcs.
	* config/aarch64/aarch64.md (save_stack_nonlocal): New.
	(restore_stack_nonlocal): New.
	* tree-nested.cc (get_nl_goto_field): Updated.
2024-11-14 16:15:08 +00:00
Szabolcs Nagy
bca0fc1410 aarch64: Add __builtin_aarch64_gcs* and __gcs* tests
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/gcs-1.c: New test.
	* gcc.target/aarch64/gcspopm-1.c: New test.
	* gcc.target/aarch64/gcspr-1.c: New test.
	* gcc.target/aarch64/gcsss-1.c: New test.

Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
2024-11-14 16:15:08 +00:00
Yury Khrustalev
a2bb4588f6 aarch64: Add ACLE __gcs* intrinsics
Add the following ACLE intrinsics:

 - void *__gcspr(void);
 - uint64_t __gcspopm(void);
 - void *__gcsss(void *);

gcc/ChangeLog:
	* config/aarch64/arm_acle.h (__gcspr): New.
	(__gcspopm): New.
	(__gcsss): New.
2024-11-14 16:15:07 +00:00
Szabolcs Nagy
af166d3adc aarch64: Add GCS builtins
Add new builtins for GCS:

  void *__builtin_aarch64_gcspr (void)
  uint64_t __builtin_aarch64_gcspopm (void)
  void *__builtin_aarch64_gcsss (void *)

The builtins are always enabled, but should be used behind runtime
checks in case the target does not support GCS. They are thin
wrappers around the corresponding instructions.

The GCS pointer is modelled with void * type (normal stores do not
work on GCS memory, but it is writable via the gcsss operation or
via GCSSTR if enabled so not const) and an entry on the GCS is
modelled with uint64_t (since it has fixed size and can be a token
that's not a pointer).

gcc/ChangeLog:

	* config/aarch64/aarch64-builtins.cc (enum aarch64_builtins): Add
	AARCH64_BUILTIN_GCSPR, AARCH64_BUILTIN_GCSPOPM, AARCH64_BUILTIN_GCSSS.
	(aarch64_init_gcs_builtins): New.
	(aarch64_general_init_builtins): Call aarch64_init_gcs_builtins.
	(aarch64_expand_gcs_builtin): New.
	(aarch64_general_expand_builtin): Call aarch64_expand_gcs_builtin.

Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
2024-11-14 16:15:07 +00:00
Szabolcs Nagy
8a366df481 aarch64: Add GCS instructions
Add instructions for the Guarded Control Stack extension.

GCSSS1 and GCSSS2 are always used together in the compiler and an extra
"mov xn, 0" should be always added before GCSSS2 to clear the output
register. This is needed to get reasonable result when GCS is disabled,
when these instructions are NOPs. Since the instructions are expected
to be used behind runtime feature checks, this is mainly relevant if
GCS can be disabled asynchronously.

GCSPOPM does not have embedded move and code code that emits this
instruction must first emit a zeroing of operand 1 to get a reasonable
result when GCS is not enabled.

The output of GCSPOPM is usually not needed, so a separate gcspopm_xzr
was added to model that. Did not do the same for GCSSS as it is a less
common operation.

The used mnemonics do not depend on updated assembler since these
instructions can be used without new -march setting behind a runtime
check.

Reading the GCSPR is modelled as unspec_volatile so it does not get
reordered wrt the other instructions changing the GCSPR.

gcc/ChangeLog:

	* config/aarch64/aarch64.md (aarch64_load_gcspr): New.
	(aarch64_gcspopm): New.
	(aarch64_gcspopm_xzr): New.
	(aarch64_gcsss1): New.
	(aarch64_gcsss2): New.
	Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
2024-11-14 16:15:06 +00:00
Szabolcs Nagy
8e3ee22346 aarch64: Add __builtin_aarch64_chkfeat and __chkfeat tests
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/chkfeat-1.c: New test.
	* gcc.target/aarch64/chkfeat-1.c: New test.
	* gcc.target/aarch64/chkfeat-2.c: New test.

Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
2024-11-14 16:15:06 +00:00
Yury Khrustalev
68d8a00bda aarch64: Add ACLE __chkfeat intrinsic
Note that compared to __builtin_aarch64_chkfeat (x) the ACLE __chkfeat(x)
flips the bits to be more intuitive (xor the input to output).

gcc/ChangeLog:
	* config/aarch64/arm_acle.h (__chkfeat): New.
2024-11-14 16:15:05 +00:00
Szabolcs Nagy
42e8d1a7e8 aarch64: Add __builtin_aarch64_chkfeat
Builtin for chkfeat: the input argument is used to initialize x16 then
execute chkfeat and return the updated x16.

Note: the ACLE __chkfeat(x) will flip the bits to be more intuitive
(xor the input to output), but for the builtin that seems unnecessary
complication.

gcc/ChangeLog:

	* config/aarch64/aarch64-builtins.cc (enum aarch64_builtins):
	Define AARCH64_BUILTIN_CHKFEAT.
	(aarch64_general_init_builtins): Handle chkfeat.
	(aarch64_general_expand_builtin): Handle chkfeat.
	Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
2024-11-14 16:15:05 +00:00
Szabolcs Nagy
0d4efa3b38 aarch64: Add support for chkfeat insn
This is a hint space instruction to check for enabled HW features and
update the x16 register accordingly.

Use unspec_volatile to prevent reordering it around calls since calls
can enable or disable HW features.

gcc/ChangeLog:

	* config/aarch64/aarch64.md (aarch64_chkfeat): New.
2024-11-14 16:15:04 +00:00
Szabolcs Nagy
2b43977d9c aarch64: Add branch-protection target pragma tests
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add branch-protection
	tests.
2024-11-14 16:15:04 +00:00
Szabolcs Nagy
56ded80b96 aarch64: Add -mbranch-protection=gcs option
This enables Guarded Control Stack (GCS) compatible code generation.

The "standard" branch-protection type enables it, and the default
depends on the compiler default.

gcc/ChangeLog:

	* config/aarch64/aarch64-protos.h (aarch_gcs_enabled): Declare.
	* config/aarch64/aarch64.cc (aarch_gcs_enabled): Define.
	(aarch_handle_no_branch_protection): Handle gcs.
	(aarch_handle_standard_branch_protection): Handle gcs.
	(aarch_handle_gcs_protection): New.
	* config/aarch64/aarch64.opt: Add aarch_enable_gcs.
	* configure: Regenerate.
	* configure.ac: Handle gcs in --enable-standard-branch-protection.
	* doc/invoke.texi: Document -mbranch-protection=gcs.
2024-11-14 16:15:03 +00:00
Jan Hubicka
269b647774 New testcase for operator new/delete removal.
* g++.dg/tree-ssa/dce-1.C: New test.
2024-11-14 17:08:03 +01:00
Jan Hubicka
7828dc0705 Remove allocations which are used only for NULL pointer check and free
Extend tree-ssa-dse to remove memory allocations that are used only
to check that return value is non-NULL and freed.

New -fmalloc-dce flag can be used to control malloc/free removal.  I
ended up copying what -fallocation-dse does so -fmalloc-dce=1 enables
malloc/free removal provided return value is unused otherwise and
-fmalloc-dce=2 allows additional NULL pointer checks which it folds to
non-NULL direction.

I also added compensation for the gcc.dg/analyzer/pr101837.c testcase and
added testcase that std::nothrow variant of operator new is now optimized way.

With the -fmalloc-dce=n I can also add a level which emits runtime check for half
of address space and calloc overflow if it seems useful, but perhaps
incrementally.  Adding size parameter tracking is not that hard (I posted WIP
patch for that).

gcc/ChangeLog:

	PR tree-optimization/117370
	* common.opt: Add -fmalloc-dce.
	* common.opt.urls: Update.
	* doc/invoke.texi: Document it; also add missing -flifetime-dse entry.
	* tree-ssa-dce.cc (is_removable_allocation_p): Break out from
	...
	(mark_stmt_if_obviously_necessary): ... here; also check that
	operator new satisfies gimple_call_from_new_or_delete.
	(checks_return_value_of_removable_allocation_p): New Function.
	(mark_all_reaching_defs_necessary_1): add missing case for
	STRDUP and STRNDUP
	(propagate_necessity): Use is_removable_allocation_p and
	checks_return_value_of_removable_allocation_p.
	(eliminate_unnecessary_stmts): Update conditionals that use
	removed allocation; use is_removable_allocation_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cdce3.C: Disable allocation dce.
	* g++.dg/tree-ssa/pr19476-1.C: Likewise.
	* g++.dg/tree-ssa/pr19476-2.C: Likewise.
	* g++.dg/tree-ssa/pr19476-3.C: Likewise.
	* g++.dg/tree-ssa/pr19476-4.C: Likewise.
	* gcc.dg/analyzer/pr101837.c: Disable malloc dce.
	* gcc.dg/tree-ssa/pr19831-3.c: Update.
	* gfortran.dg/pr68078.f90: Disable malloc DCE.
2024-11-14 17:07:06 +01:00
Jonathan Wakely
f91e34644e
libstdc++: Add missing constraint to operator+ for std::move_iterator
This constraint was added by the One Ranges proposal (P0896R4) and
then fixed by LWG 3293, but it was missing from libstdc++.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (operator+): Add constraint to
	move_iterator operator.
	* testsuite/24_iterators/move_iterator/rel_ops_c++20.cc:
2024-11-14 15:39:03 +00:00
Jonathan Wakely
dec2158b2c
libstdc++: Use requires-clause for __normal_iterator constructor
This is a very minor throughput optimization, to avoid instantiating
std::enable_if and std::is_convertible when concepts are available.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (__normal_iterator): Replace
	enable_if constraint with requires-clause.
2024-11-14 15:39:03 +00:00
Jonathan Wakely
e56d183c15
libstdc++: Use feature test macros consistently in <bits/stl_iterator.h>
Remove __cplusplus > 201703L checks that are redundant when used
alongside __glibcxx_concepts checks, because <version> already
guarantees that __glibcxx_concepts is only defined for C++20 and later.

Prefer to check __glibcxx_ranges for features such as move_sentinel that
were added by the One Ranges proposal (P0896R4), or for features which
depend on other components introduced by that proposal.

But prefer to check __glibcxx_concepts for constraints that only depend
on requires-clauses and concepts defined in <concepts>, even if those
constraints were added by the Ranges proposal (e.g. the constraints on
non-member operators for move_iterator).

Prefer #ifdef to #if when just testing for the presence of __glibcxx_foo
macros with caring about their value.

Also add/tweak some Doxygen comments.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h: Make use of feature test macros
	more consistent. Improve doxygen comments.
2024-11-14 15:39:03 +00:00
Tobias Burnus
28854cf68d libgomp.texi: Impl. Status - change TR13 to OpenMP 6.0 + fix routine typo
libgomp/
	* libgomp.texi (OpenMP Implementation Status): Change TR13 to
	OpenMP 6.0, now released. Fix a typo in the omp_target_memset_async
	routine name.
2024-11-14 16:28:20 +01:00
Richard Biener
119c1b76e2 Fix another thinko in peeling for gap compute of get_group_load_store_type
There's inconsistent handling of the cpart_size == cnunits which
currently avoids reporting peeling for gaps being insufficient, but
the following condition which is enough to trigger it,
cremain + group_size < cpart_size with cpart_size == cnunits is
equal to the condition that brings us here in the first place,
maybe_lt (remain + group_size, nunits).  The following fixes this
by not checking cpart_size against special values.

	* tree-vect-stmts.cc (get_group_load_store_type): Do not
	exempt cpart_size == cnunits from failing.
2024-11-14 15:30:42 +01:00
Richard Biener
faf594ce21 Fix typo in peeling for gap compute of get_group_load_store_type
When fixing a maybe-uninit diagnostic in r15-1309-ge575b5c56137b1 by
re-computing remain I failed to add braces, effectively now computing
garbage.

	* tree-vect-stmts.cc (get_group_load_store_type): Add missing
	braces.
2024-11-14 15:30:42 +01:00
Eric Botcazou
01413da3b0 ada: Avoid doing unnecessary work in elaborate_expression_2
This prevents the expression from being tweaked by the match.pd machinery
in the process, which can damage the readability of the -gnatR3 output.

gcc/ada/ChangeLog:

	* gcc-interface/decl.cc (elaborate_expression_2): Do not divide and
	multiply back if the alignment factor is already explicit.
2024-11-14 14:54:31 +01:00
Steve Baird
29112f5e1b ada: Improved legality checking for deep delta aggregates.
Enforce deep delta legality rules about nonoverlapping choices. For example,
do not allow both Aaa.Bbb and Aaa.Bbb.Ccc as choices in one delta aggregate.
One special case impacts "regular" Ada2022 delta aggregates - the rule
preventing a record component from occurring twice as a choice in a delta
aggregate was previously not being enforced.

gcc/ada/ChangeLog:

	* sem_aggr.adb (Resolve_Delta_Aggregate): The rule about
	discriminant dependent component references in choices applies to
	both array and record delta aggregates, so check for violations in
	Resolve_Delta_Aggregate. Call a new procedure,
	Check_For_Bad_Dd_Component_Choice, for each choice.
	(Resolve_Delta_Record_Aggregate): Call a new procedure,
	Check_For_Bad_Overlap, for each pair of choices.
2024-11-14 14:54:31 +01:00
Ronan Desplanques
35d36903dc ada: Tweak test for predefined units in binder
The new way makes better use of the existing abstractions.

gcc/ada/ChangeLog:

	* bindgen.adb (Gen_Elab_Calls): Tweak test.
	(Gen_Elab_Externals): Likewise.
2024-11-14 14:54:31 +01:00
Claire Dross
f62972f5ca ada: Adapt proofs of light runtime to current version of SPARK
gcc/ada/ChangeLog:

	* libgnat/a-strmap.adb: Add assert to regain proofs.
	* libgnat/a-strsup.adb: Likewise.
	* libgnat/s-aridou.adb: Add assertions to regain proofs.
	* libgnat/s-arit32.adb: Use Exceptional_Cases to specify Raise.
	* libgnat/s-arit64.adb: Use Round_Quatient from Impl instead of
	redefining it.
	* libgnat/s-arit64.ads: Likewise.
	* libgnat/s-expmod.adb: Regain proof of lemma.
	* libgnat/s-exponn.adb: Likewise.
	* libgnat/s-expont.adb: Likewise.
	* libgnat/s-imgboo.adb: Add local lemma to regain proof.
	* libgnat/s-valuti.ads: Add Always_Terminates on Bad_Value.
2024-11-14 14:54:31 +01:00
Eric Botcazou
3e4146b693 ada: Another small fix to the description of run-time library routines
gcc/ada/ChangeLog:

	* libgnat/s-imagef.ads (Image_Fixed): Adjust outdated sentence.
2024-11-14 14:54:31 +01:00