Commit Graph

1798 Commits

Author SHA1 Message Date
GCC Administrator
ae9e48e5c0 Daily bump. 2023-12-07 00:17:06 +00:00
Jakub Jelinek
d7ceffab96 libgcc: Avoid -Wbuiltin-declaration-mismatch warnings in emutls.c
When libgcc is being built in --disable-tls configuration or on
a target without native TLS support, one gets annoying warnings:
../../../../libgcc/emutls.c:61:7: warning: conflicting types for built-in function ‘__emutls_get_address’; expected ‘void *(void *)’ [-Wbuiltin-declaration-mismatch]
   61 | void *__emutls_get_address (struct __emutls_object *);
      |       ^~~~~~~~~~~~~~~~~~~~
../../../../libgcc/emutls.c:63:6: warning: conflicting types for built-in function ‘__emutls_register_common’; expected ‘void(void *, unsigned int,  unsigned int,  void *)’
+[-Wbuiltin-declaration-mismatch]
   63 | void __emutls_register_common (struct __emutls_object *, word, word, void *);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
../../../../libgcc/emutls.c:140:1: warning: conflicting types for built-in function ‘__emutls_get_address’; expected ‘void *(void *)’ [-Wbuiltin-declaration-mismatch]
  140 | __emutls_get_address (struct __emutls_object *obj)
      | ^~~~~~~~~~~~~~~~~~~~
../../../../libgcc/emutls.c:204:1: warning: conflicting types for built-in function ‘__emutls_register_common’; expected ‘void(void *, unsigned int,  unsigned int,  void *)’
+[-Wbuiltin-declaration-mismatch]
  204 | __emutls_register_common (struct __emutls_object *obj,
      | ^~~~~~~~~~~~~~~~~~~~~~~~
The thing is that in that case __emutls_get_address and
__emutls_register_common are builtins, and are declared with void *
arguments rather than struct __emutls_object *.
Now, struct __emutls_object is a type private to libgcc/emutls.c and the
middle-end creates on demand when calling the builtins a similar structure
(with small differences, like not having the union in there).

We have a precedent for this e.g. for fprintf or strftime builtins where
the builtins are created with magic fileptr_type_node or const_tm_ptr_type_node
types and then match it with user definition of pointers to some structure,
but I think for this case users should never define these functions
themselves nor call them and having special types for them in the compiler
would mean extra compile time spent during compiler initialization and more
GC data, so I think it is better to keep the compiler as is.

On the library side, there is an option to just follow what the
compiler is doing and do
 EMUTLS_ATTR void
-__emutls_register_common (struct __emutls_object *obj,
+__emutls_register_common (void *xobj,
                           word size, word align, void *templ)
 {
+  struct __emutls_object *obj = (struct __emutls_object *) xobj;
but that will make e.g. libabigail complain about ABI change in libgcc.

So, the patch just turns the warning off.

2023-12-06  Thomas Schwinge  <thomas@codesourcery.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/109289
	* emutls.c: Add GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
	pragma.
2023-12-06 12:27:12 +01:00
GCC Administrator
3dd09cd9e1 Daily bump. 2023-12-06 00:17:50 +00:00
Alexandre Oliva
f0a90c7d73 Introduce strub: machine-independent stack scrubbing
This patch adds the strub attribute for function and variable types,
command-line options, passes and adjustments to implement it,
documentation, and tests.

Stack scrubbing is implemented in a machine-independent way: functions
with strub enabled are modified so that they take an extra stack
watermark argument, that they update with their stack use, and the
caller can then zero it out once it regains control, whether by return
or exception.  There are two ways to go about it: at-calls, that
modifies the visible interface (signature) of the function, and
internal, in which the body is moved to a clone, the clone undergoes
the interface change, and the function becomes a wrapper, preserving
its original interface, that calls the clone and then clears the stack
used by it.

Variables can also be annotated with the strub attribute, so that
functions that read from them get stack scrubbing enabled implicitly,
whether at-calls, for functions only usable within a translation unit,
or internal, for functions whose interfaces must not be modified.

There is a strict mode, in which functions that have their stack
scrubbed can only call other functions with stack-scrubbing
interfaces, or those explicitly marked as callable from strub
contexts, so that an entire call chain gets scrubbing, at once or
piecemeal depending on optimization levels.  In the default mode,
relaxed, this requirement is not enforced by the compiler.

The implementation adds two IPA passes, one that assigns strub modes
early on, another that modifies interfaces and adds calls to the
builtins that jointly implement stack scrubbing.  Another builtin,
that obtains the stack pointer, is added for use in the implementation
of the builtins, whether expanded inline or called in libgcc.

There are new command-line options to change operation modes and to
force the feature disabled; it is enabled by default, but it has no
effect and is implicitly disabled if the strub attribute is never
used.  There are also options meant to use for testing the feature,
enabling different strubbing modes for all (viable) functions.


for  gcc/ChangeLog

	* Makefile.in (OBJS): Add ipa-strub.o.
	(GTFILES): Add ipa-strub.cc.
	* builtins.def (BUILT_IN_STACK_ADDRESS): New.
	(BUILT_IN___STRUB_ENTER): New.
	(BUILT_IN___STRUB_UPDATE): New.
	(BUILT_IN___STRUB_LEAVE): New.
	* builtins.cc: Include ipa-strub.h.
	(STACK_STOPS, STACK_UNSIGNED): Define.
	(expand_builtin_stack_address): New.
	(expand_builtin_strub_enter): New.
	(expand_builtin_strub_update): New.
	(expand_builtin_strub_leave): New.
	(expand_builtin): Call them.
	* common.opt (fstrub=*): New options.
	* doc/extend.texi (strub): New type attribute.
	(__builtin_stack_address): New function.
	(Stack Scrubbing): New section.
	* doc/invoke.texi (-fstrub=*): New options.
	(-fdump-ipa-*): New passes.
	* gengtype-lex.l: Ignore multi-line pp-directives.
	* ipa-inline.cc: Include ipa-strub.h.
	(can_inline_edge_p): Test strub_inlinable_to_p.
	* ipa-split.cc: Include ipa-strub.h.
	(execute_split_functions): Test strub_splittable_p.
	* ipa-strub.cc, ipa-strub.h: New.
	* passes.def: Add strub_mode and strub passes.
	* tree-cfg.cc (gimple_verify_flow_info): Note on debug stmts.
	* tree-pass.h (make_pass_ipa_strub_mode): Declare.
	(make_pass_ipa_strub): Declare.
	(make_pass_ipa_function_and_variable_visibility): Fix
	formatting.
	* tree-ssa-ccp.cc (optimize_stack_restore): Keep restores
	before strub leave.
	* attribs.cc: Include ipa-strub.h.
	(decl_attributes): Support applying attributes to function
	type, rather than pointer type, at handler's request.
	(comp_type_attributes): Combine strub_comptypes and target
	comp_type results.
	* doc/tm.texi.in (TARGET_STRUB_USE_DYNAMIC_ARRAY): New.
	(TARGET_STRUB_MAY_USE_MEMSET): New.
	* doc/tm.texi: Rebuilt.
	* cgraph.h (symtab_node::reset): Add preserve_comdat_group
	param, with a default.
	* cgraphunit.cc (symtab_node::reset): Use it.

for  gcc/c-family/ChangeLog

	* c-attribs.cc: Include ipa-strub.h.
	(handle_strub_attribute): New.
	(c_common_attribute_table): Add strub.

for  gcc/ada/ChangeLog

	* gcc-interface/trans.cc: Include ipa-strub.h.
	(gigi): Make internal decls for targets of compiler-generated
	calls strub-callable too.
	(build_raise_check): Likewise.
	* gcc-interface/utils.cc: Include ipa-strub.h.
	(handle_strub_attribute): New.
	(gnat_internal_attribute_table): Add strub.

for  gcc/testsuite/ChangeLog

	* c-c++-common/strub-O0.c: New.
	* c-c++-common/strub-O1.c: New.
	* c-c++-common/strub-O2.c: New.
	* c-c++-common/strub-O2fni.c: New.
	* c-c++-common/strub-O3.c: New.
	* c-c++-common/strub-O3fni.c: New.
	* c-c++-common/strub-Og.c: New.
	* c-c++-common/strub-Os.c: New.
	* c-c++-common/strub-all1.c: New.
	* c-c++-common/strub-all2.c: New.
	* c-c++-common/strub-apply1.c: New.
	* c-c++-common/strub-apply2.c: New.
	* c-c++-common/strub-apply3.c: New.
	* c-c++-common/strub-apply4.c: New.
	* c-c++-common/strub-at-calls1.c: New.
	* c-c++-common/strub-at-calls2.c: New.
	* c-c++-common/strub-defer-O1.c: New.
	* c-c++-common/strub-defer-O2.c: New.
	* c-c++-common/strub-defer-O3.c: New.
	* c-c++-common/strub-defer-Os.c: New.
	* c-c++-common/strub-internal1.c: New.
	* c-c++-common/strub-internal2.c: New.
	* c-c++-common/strub-parms1.c: New.
	* c-c++-common/strub-parms2.c: New.
	* c-c++-common/strub-parms3.c: New.
	* c-c++-common/strub-relaxed1.c: New.
	* c-c++-common/strub-relaxed2.c: New.
	* c-c++-common/strub-short-O0-exc.c: New.
	* c-c++-common/strub-short-O0.c: New.
	* c-c++-common/strub-short-O1.c: New.
	* c-c++-common/strub-short-O2.c: New.
	* c-c++-common/strub-short-O3.c: New.
	* c-c++-common/strub-short-Os.c: New.
	* c-c++-common/strub-strict1.c: New.
	* c-c++-common/strub-strict2.c: New.
	* c-c++-common/strub-tail-O1.c: New.
	* c-c++-common/strub-tail-O2.c: New.
	* c-c++-common/torture/strub-callable1.c: New.
	* c-c++-common/torture/strub-callable2.c: New.
	* c-c++-common/torture/strub-const1.c: New.
	* c-c++-common/torture/strub-const2.c: New.
	* c-c++-common/torture/strub-const3.c: New.
	* c-c++-common/torture/strub-const4.c: New.
	* c-c++-common/torture/strub-data1.c: New.
	* c-c++-common/torture/strub-data2.c: New.
	* c-c++-common/torture/strub-data3.c: New.
	* c-c++-common/torture/strub-data4.c: New.
	* c-c++-common/torture/strub-data5.c: New.
	* c-c++-common/torture/strub-indcall1.c: New.
	* c-c++-common/torture/strub-indcall2.c: New.
	* c-c++-common/torture/strub-indcall3.c: New.
	* c-c++-common/torture/strub-inlinable1.c: New.
	* c-c++-common/torture/strub-inlinable2.c: New.
	* c-c++-common/torture/strub-ptrfn1.c: New.
	* c-c++-common/torture/strub-ptrfn2.c: New.
	* c-c++-common/torture/strub-ptrfn3.c: New.
	* c-c++-common/torture/strub-ptrfn4.c: New.
	* c-c++-common/torture/strub-pure1.c: New.
	* c-c++-common/torture/strub-pure2.c: New.
	* c-c++-common/torture/strub-pure3.c: New.
	* c-c++-common/torture/strub-pure4.c: New.
	* c-c++-common/torture/strub-run1.c: New.
	* c-c++-common/torture/strub-run2.c: New.
	* c-c++-common/torture/strub-run3.c: New.
	* c-c++-common/torture/strub-run4.c: New.
	* c-c++-common/torture/strub-run4c.c: New.
	* c-c++-common/torture/strub-run4d.c: New.
	* c-c++-common/torture/strub-run4i.c: New.
	* g++.dg/strub-run1.C: New.
	* g++.dg/torture/strub-init1.C: New.
	* g++.dg/torture/strub-init2.C: New.
	* g++.dg/torture/strub-init3.C: New.
	* gnat.dg/strub_attr.adb, gnat.dg/strub_attr.ads: New.
	* gnat.dg/strub_ind.adb, gnat.dg/strub_ind.ads: New.

for  libgcc/ChangeLog

	* Makefile.in (LIB2ADD): Add strub.c.
	* libgcc2.h (__strub_enter, __strub_update, __strub_leave):
	Declare.
	* strub.c: New.
	* libgcc-std.ver.in (__strub_enter): Add to GCC_14.0.0.
	(__strub_update, __strub_leave): Likewise.
2023-12-05 21:07:36 -03:00
GCC Administrator
833819e75a Daily bump. 2023-12-04 00:16:38 +00:00
Jeff Law
4cef6daf40 [committed] Fix build of libgcc on ports using FDPIC
read_encoded_value_with_base has an ifdef'd code path conditional on __FDPIC__
which was calling _Unwind_gnu_Find_got without a prototype.  This naturally
caused various build failures.

This adds a suitable prototype.

Pushed to the trunk.

libgcc

	* unwind-pe.h (_Unwind_gnu_Find_got): Add prototype.
2023-12-02 22:45:48 -07:00
Jeff Law
f1fdd2839c [committed] Fix rx build failure in libgcc
The rx port has a bunch of what I presume are ABI compatibility functions in
libgcc.  Those compatibility functions routines such as __eqdf2 from libgcc,
but without a prototype.  This patch adds the missing prototypes.

libgcc/
	* config/rx/rx-abi-functions.c (__ltdf2, __gtdf2): Add prototype.
	(__ledf2, __gedf2, __eqdf2, __nedf2): Likewise.
	(__ltsf2, __gtsf2, __lesf2, __gesf2, __eqsf2, __nesf2): Likewise.
2023-12-02 22:07:59 -07:00
Jeff Law
870b63fe71 [committed] Fix frv build after C99 changes
Two issues prevent the frv-elf port from building after the C99 changes.  First
the trampoline code emitted into libgcc has calls to exit, but no prototype.
Adding a trivial prototype for exit() into the macro fixes that little goof.

Second, frvbegin.c has a call to atexit, so a quick prototype is added into
frvbegin.c to fix that problem.

That's enough to get the compiler building again.

gcc/
	* config/frv/frv.h (TRANSFER_FROM_TRAMPOLINE): Add prototype for exit.

libgcc/
	* config/frv/frvbegin.c (atexit): Add prototype.
2023-12-02 21:54:36 -07:00
GCC Administrator
2e0f3f9759 Daily bump. 2023-12-02 00:16:54 +00:00
Alexandre Oliva
c4a49ebd1e hardcfr: libgcc sym versioning
The libgcc-exported runtime component of control flow redundancy
hardening was missing symbol versioning information.  Add it.


for  libgcc/ChangeLog

	* libgcc-std.ver.in (__hardcfr_check): Add to GCC_14.0.0.
2023-12-01 14:31:12 -03:00
Sebastian Huber
4b8078142e gcov: Fix use of __LIBGCC_HAVE_LIBATOMIC
libgcc/ChangeLog:

	PR target/112777

	* libgcov.h (GCOV_SUPPORTS_ATOMIC):  Honor that __LIBGCC_HAVE_LIBATOMIC is
	always defined as either 0 or 1.
2023-12-01 09:54:24 +01:00
Florian Weimer
335bd6c938 aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder
* config/aarch64/linux-unwind.h
	(aarch64_fallback_frame_state): Add cast to the expected type
	in sc assignment.
2023-12-01 08:10:12 +01:00
GCC Administrator
8428bcd703 Daily bump. 2023-12-01 00:17:36 +00:00
Wilco Dijkstra
df8958e6bc AArch64: Fix __sync_val_compare_and_swap [PR111404]
__sync_val_compare_and_swap may be used on 128-bit types and either calls the
outline atomic code or uses an inline loop.  On AArch64 LDXP is only atomic if
the value is stored successfully using STXP, but the current implementations
do not perform the store if the comparison fails.  In this case the value
returned is not read atomically.

gcc/ChangeLog:
	PR target/111404
	* config/aarch64/aarch64.cc (aarch64_split_compare_and_swap):
	For 128-bit store the loaded value and loop if needed.

libgcc/ChangeLog:
	PR target/111404
	* config/aarch64/lse.S (__aarch64_cas16_acq_rel): Execute STLXP using
	either new value or loaded value.
2023-11-30 16:15:29 +00:00
GCC Administrator
ad3e759c17 Daily bump. 2023-11-28 00:17:28 +00:00
Richard Earnshaw
eecdd96c8d arm: libgcc: tweak warning from __sync_synchronize
My previous patch to add an implementation of __sync_syncrhonize with
a warning trips a testsuite failure in fortran (and possibly other
languages as well) as the framework expects no blank lines in the
output, but this warning was generating one.  So remove the newline
from the end of the message and rely on the one added by the linker
instead.

Since we're there, remove the trailing period from the message as
well, since the convention seems to be not to have one.

libgcc/

	* config/arm/lib1funcs.S (__sync_synchronize): Adjust warning message.
2023-11-27 18:00:33 +00:00
GCC Administrator
77cf1dba78 Daily bump. 2023-11-25 00:17:46 +00:00
Richard Earnshaw
439779bace arm: libgcc: provide implementations of __sync_synchronize
Prior to Armv6 there was no architected method to synchronize data
across processors.  Armv6 saw the first introduction of
multi-processor support, using a CP15 operation; but this was
deprecated in Armv7 and is not supported on m-profile devices of any
form.  Armv7 (and armv6-m) and later support data synchronization via
the DMB instruction.

This all leads to difficulties when linking programs as the user
generally needs to know which synchronization method is needed, but
there seems no easy way around this, when there are no OS-related
primitives available.

I've addressed this by adding multiple variants of __sync_synchronize
to libgcc, one for each of the above use cases.  I've named these
__sync_synchronize_none, __sync_synchronize_cp15dmb and
__sync_synchronize_dmb.  I've also added three specs files that can be
used to direct the linker to pick the appropriate implementation.
Using specs fragments for this is preferable to directing the user to
directly use --defsym as the latter has to be placed at the correct
position on the command line to be effective and the spec rule ensures
this automatically.

I've also added a default implementation of __sync_synchronize.  The
default implementation will use DMB if that is available in the target
ISA, or fall back to a nul-implementation if it isn't.  In the latter
case it will cause the linker (GNU LD) to emit a warning that
specifies how to pick a specific implementation.  I've chosen not to
permit this default to use the CP15 solution as that has been
deprecated.

libgcc:

	* config.host (arm*-*-eabi* | arm*-*-rtems*):
	Add arm/t-sync to the makefile rules.
	* config/arm/lib1funcs.S (__sync_synchronize_none)
	(__sync_synchronize_cp15dmb, __sync_synchronize_dmb)
	(__sync_synchronize): New functions.
	* config/arm/t-sync: New file.
	* config/arm/sync-none.specs: Likewise.
	* config/arm/sync-dmb.specs: Likewise.
	* config/arm/sync-cp15dmb.specs: Likewise.
2023-11-24 14:15:26 +00:00
GCC Administrator
6fb55db0e1 Daily bump. 2023-11-24 00:17:53 +00:00
Jose E. Marchesi
2eb833534c libgcc: mark __hardcfr_check_fail as always_inline
The function __hardcfr_check_fail in hardcfr.c is internal and static
inline.  It receives many arguments, which require more than five
registers to be passed in bpf-none-unknown targets.  BPF is limited to
that number of registers to pass arguments, and therefore libgcc fails
to build in that target.  This patch marks the function with the
always_inline attribute, fixing the bpf build.

Tested in bpf-unknown-none target and x86_64-linux-gnu host.

libgcc/ChangeLog:

	* hardcfr.c (__hardcfr_check_fail): Mark as always_inline.
2023-11-23 17:31:40 +01:00
GCC Administrator
92c480a423 Daily bump. 2023-11-22 00:17:52 +00:00
Jakub Jelinek
69813540e3 gcov: Formatting fixes
I've noticed the r14-5579 commit introduced some formatting issues,
this patch fixes what I saw.

2023-11-21  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-profile.cc (gen_counter_update, tree_profiling): Formatting
	fixes.
libgcc/
	* libgcov.h (GCOV_SUPPORTS_ATOMIC): Formatting fixes.
2023-11-21 10:49:51 +01:00
GCC Administrator
9d58d2d8ba Daily bump. 2023-11-19 00:17:38 +00:00
Sebastian Huber
20a3c74c34 gcov: Improve -fprofile-update=atomic
The code coverage support uses counters to determine which edges in the control
flow graph were executed.  If a counter overflows, then the code coverage
information is invalid.  Therefore the counter type should be a 64-bit integer.
In multi-threaded applications, it is important that the counter increments are
atomic.  This is not the case by default.  The user can enable atomic counter
increments through the -fprofile-update=atomic and
-fprofile-update=prefer-atomic options.

If the target supports 64-bit atomic operations, then everything is fine.  If
not and -fprofile-update=prefer-atomic was chosen by the user, then non-atomic
counter increments will be used.  However, if the target does not support the
required atomic operations and -fprofile-atomic=update was chosen by the user,
then a warning was issued and as a forced fallback to non-atomic operations was
done.  This is probably not what a user wants.  There is still hardware on the
market which does not have atomic operations and is used for multi-threaded
applications.  A user which selects -fprofile-update=atomic wants consistent
code coverage data and not random data.

This patch removes the fallback to non-atomic operations for
-fprofile-update=atomic the target platform supports libatomic.  To
mitigate potential performance issues an optimization for systems which
only support 32-bit atomic operations is provided.  Here, the edge
counter increments are done like this:

  low = __atomic_add_fetch_4 (&counter.low, 1, MEMMODEL_RELAXED);
  high_inc = low == 0 ? 1 : 0;
  __atomic_add_fetch_4 (&counter.high, high_inc, MEMMODEL_RELAXED);

In gimple_gen_time_profiler() this split operation cannot be used, since the
updated counter value is also required.  Here, a library call is emitted.  This
is not a performance issue since the update is only done if counters[0] == 0.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins):  Define
	__LIBGCC_HAVE_LIBATOMIC for libgcov.

gcc/ChangeLog:

	* doc/invoke.texi (-fprofile-update): Clarify default method.  Document
	the atomic method behaviour.
	* tree-profile.cc (enum counter_update_method): New.
	(counter_update): Likewise.
	(gen_counter_update): Use counter_update_method.  Split the
	atomic counter update in two 32-bit atomic operations if
	necessary.
	(tree_profiling): Select counter_update_method.

libgcc/ChangeLog:

	* libgcov.h (GCOV_SUPPORTS_ATOMIC): Always define it.
	Set it also to 1, if __LIBGCC_HAVE_LIBATOMIC is defined.
2023-11-18 12:45:15 +01:00
Sebastian Huber
23d33775f9 gcov: Remove TARGET_GCOV_TYPE_SIZE target hook
This reverts commit 8cdcea51c0.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Do not define
	__LIBGCC_GCOV_TYPE_SIZE.

gcc/ChangeLog:

	* config/sparc/rtemself.h (SPARC_GCOV_TYPE_SIZE): Remove.
	* config/sparc/sparc.cc (sparc_gcov_type_size): Likewise.
	(TARGET_GCOV_TYPE_SIZE): Likewise.
	* coverage.cc (get_gcov_type): Use LONG_LONG_TYPE_SIZE instead
	of removed target hook.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in (TARGET_GCOV_TYPE_SIZE): Remove.
	* target.def: Likewise.
	* targhooks.cc (default_gcov_type_size): Likewise.
	* targhooks.h (default_gcov_type_size): Likewise.

libgcc/ChangeLog:

	* libgcov.h (gcov_type): Use LONG_LONG_TYPE_SIZE.
	(gcov_type_unsigned): Likewise.
2023-11-18 12:44:14 +01:00
GCC Administrator
b9fd8399ec Daily bump. 2023-11-14 12:23:39 +00:00
Georg-Johann Lay
3232e73c44 LibF7: sinh: Fix loss of precision due to cancellation for small values.
libgcc/config/avr/libf7/
	* libf7-const.def [F7MOD_sinh_]: Add MiniMax polynomial.
	* libf7.c (f7_sinh): Use it instead of (exp(x) - exp(-x)) / 2
	when |x| < 0.5 to avoid loss of precision due to cancellation.
2023-11-14 12:10:08 +01:00
Georg-Johann Lay
3a5a30792f LibF7: Use paper-pencil method for sqrt instead of Newton-Raphson iteration.
libgcc/config/avr/libf7/
	* libf7-asm.sx (sqrt_approx): Rewrite.
	* libf7.c (f7_sqrt): Use it instead of sqrt_worker.
	(sqrt_worker): Remove.
2023-11-12 15:58:02 +01:00
Keith Packard
e0c1476d5d [PATCH] libgcc/m68k: Fixes for soft float
Check for non-zero denorm in __adddf3. Need to check both the upper and
lower 32-bit chunks of a 64-bit float for a non-zero value when
checking to see if the value is -0.

Fix __addsf3 when the sum exponent is exactly 0xff to ensure that
produces infinity and not nan.

Handle converting NaN/inf values between formats.

Handle underflow and overflow when truncating.

Write a replacement for __fixxfsi so that it does not raise extra
exceptions during an extra conversion from long double to double.

libgcc/
	* config/m68k/lb1sf68.S (__adddf3): Properly check for non-zero denorm.
	(__divdf3): Restore sign bit properly.
	(__addsf3): Correct exponent check.
	* config/m68k/fpgnulib.c (EXPMASK): Define.
	(__extendsfdf2): Handle Inf and NaN properly.
	(__truncdfsf2): Handle underflow and overflow correctly.
	(__extenddfxf2): Handle underflow, denorms, Inf and NaN correctly.
	(__truncxfdf2): Handle underflow and denorms correctly.
	(__fixxfsi): Reimplement.
2023-11-10 16:47:22 -07:00
Jakub Jelinek
f172b9d38d libgcc: Add {unsigned ,}__int128 <-> _Decimal{32,64,128} conversion support [PR65833]
The following patch adds the missing
{unsigned ,}__int128 <-> _Decimal{32,64,128}
conversion support into libgcc.a on top of the _BitInt support
(doing it without that would be larger amount of code and I hope all
the targets which support __int128 will eventually support _BitInt,
after all it is a required part of C23) and because it is in libgcc.a
only, it doesn't hurt that much if it is added for some architectures
only in GCC 15.
Initially I thought about doing this on the compiler side, but doing
it on the library side seems to be easier and more -Os friendly.
The tests currently require bitint effective target, that can be
removed when all the int128 targets support bitint.

2023-11-09  Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/65833
libgcc/
	* config/t-softfp (softfp_bid_list): Add
	{U,}TItype <-> _Decimal{32,64,128} conversions.
	* soft-fp/floattisd.c: New file.
	* soft-fp/floattidd.c: New file.
	* soft-fp/floattitd.c: New file.
	* soft-fp/floatuntisd.c: New file.
	* soft-fp/floatuntidd.c: New file.
	* soft-fp/floatuntitd.c: New file.
	* soft-fp/fixsdti.c: New file.
	* soft-fp/fixddti.c: New file.
	* soft-fp/fixtdti.c: New file.
	* soft-fp/fixunssdti.c: New file.
	* soft-fp/fixunsddti.c: New file.
	* soft-fp/fixunstdti.c: New file.
gcc/testsuite/
	* gcc.dg/dfp/int128-1.c: New test.
	* gcc.dg/dfp/int128-2.c: New test.
	* gcc.dg/dfp/int128-3.c: New test.
	* gcc.dg/dfp/int128-4.c: New test.
2023-11-09 09:14:07 +01:00
GCC Administrator
3e9461a3c2 Daily bump. 2023-11-09 00:17:25 +00:00
Georg-Johann Lay
f7da59104c LibF7: Tweak IEEE double multiplication.
libgcc/config/avr/libf7/
	* libf7-asm.sx (mul_mant) [AVR_HAVE_MUL]: Tweak code.
2023-11-08 12:45:25 +01:00
GCC Administrator
c48f105685 Daily bump. 2023-11-08 00:17:35 +00:00
Kwok Cheung Yeung
a49c7d3193 openmp: Add support for the 'indirect' clause in C/C++
This adds support for the 'indirect' clause in the 'declare target'
directive.  Functions declared as indirect may be called via function
pointers passed from the host in offloaded code.

Virtual calls to member functions via the object pointer in C++ are
currently not supported in target regions.

2023-11-07  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/c-family/
	* c-attribs.cc (c_common_attribute_table): Add attribute for
	indirect functions.
	* c-pragma.h (enum parma_omp_clause): Add entry for indirect clause.

gcc/c/
	* c-decl.cc (c_decl_attributes): Add attribute for indirect
	functions.
	* c-lang.h (c_omp_declare_target_attr): Add indirect field.
	* c-parser.cc (c_parser_omp_clause_name): Handle indirect clause.
	(c_parser_omp_clause_indirect): New.
	(c_parser_omp_all_clauses): Handle indirect clause.
	(OMP_DECLARE_TARGET_CLAUSE_MASK): Add indirect clause to mask.
	(c_parser_omp_declare_target): Handle indirect clause.  Emit error
	message if device_type or indirect clauses used alone.  Emit error
	if indirect clause used with device_type that is not 'any'.
	(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Add indirect clause to mask.
	(c_parser_omp_begin): Handle indirect clause.
	* c-typeck.cc (c_finish_omp_clauses): Handle indirect clause.

gcc/cp/
	* cp-tree.h (cp_omp_declare_target_attr): Add indirect field.
	* decl2.cc (cplus_decl_attributes): Add attribute for indirect
	functions.
	* parser.cc (cp_parser_omp_clause_name): Handle indirect clause.
	(cp_parser_omp_clause_indirect): New.
	(cp_parser_omp_all_clauses): Handle indirect clause.
	(handle_omp_declare_target_clause): Add extra parameter.  Add
	indirect attribute for indirect functions.
	(OMP_DECLARE_TARGET_CLAUSE_MASK): Add indirect clause to mask.
	(cp_parser_omp_declare_target): Handle indirect clause.  Emit error
	message if device_type or indirect clauses used alone.  Emit error
	if indirect clause used with device_type that is not 'any'.
	(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Add indirect clause to mask.
	(cp_parser_omp_begin): Handle indirect clause.
	* semantics.cc (finish_omp_clauses): Handle indirect clause.

gcc/
	* lto-cgraph.cc (enum LTO_symtab_tags): Add tag for indirect
	functions.
	(output_offload_tables): Write indirect functions.
	(input_offload_tables): read indirect functions.
	* lto-section-names.h (OFFLOAD_IND_FUNC_TABLE_SECTION_NAME): New.
	* omp-builtins.def (BUILT_IN_GOMP_TARGET_MAP_INDIRECT_PTR): New.
	* omp-offload.cc (offload_ind_funcs): New.
	(omp_discover_implicit_declare_target): Add functions marked with
	'omp declare target indirect' to indirect functions list.
	(omp_finish_file): Add indirect functions to section for offload
	indirect functions.
	(execute_omp_device_lower): Redirect indirect calls on target by
	passing function pointer to BUILT_IN_GOMP_TARGET_MAP_INDIRECT_PTR.
	(pass_omp_device_lower::gate): Run pass_omp_device_lower if
	indirect functions are present on an accelerator device.
	* omp-offload.h (offload_ind_funcs): New.
	* tree-core.h (omp_clause_code): Add OMP_CLAUSE_INDIRECT.
	* tree.cc (omp_clause_num_ops): Add entry for OMP_CLAUSE_INDIRECT.
	(omp_clause_code_name): Likewise.
	* tree.h (OMP_CLAUSE_INDIRECT_EXPR): New.
	* config/gcn/mkoffload.cc (process_asm): Process offload_ind_funcs
	section.  Count number of indirect functions.
	(process_obj): Emit number of indirect functions.
	* config/nvptx/mkoffload.cc (ind_func_ids, ind_funcs_tail): New.
	(process): Emit offload_ind_func_table in PTX code.  Emit indirect
	function names and count in image.
	* config/nvptx/nvptx.cc (nvptx_record_offload_symbol): Mark
	indirect functions in PTX code with IND_FUNC_MAP.

gcc/testsuite/
	* c-c++-common/gomp/declare-target-7.c: Update expected error message.
	* c-c++-common/gomp/declare-target-indirect-1.c: New.
	* c-c++-common/gomp/declare-target-indirect-2.c: New.
	* g++.dg/gomp/attrs-21.C (v12): Update expected error message.
	* g++.dg/gomp/declare-target-indirect-1.C: New.
	* gcc.dg/gomp/attrs-21.c (v12): Update expected error message.

include/
	* gomp-constants.h (GOMP_VERSION): Increment to 3.
	(GOMP_VERSION_SUPPORTS_INDIRECT_FUNCS): New.

libgcc/
	* offloadstuff.c (OFFLOAD_IND_FUNC_TABLE_SECTION_NAME): New.
	(__offload_ind_func_table): New.
	(__offload_ind_funcs_end): New.
	(__OFFLOAD_TABLE__): Add entries for indirect functions.

libgomp/
	* Makefile.am (libgomp_la_SOURCES): Add target-indirect.c.
	* Makefile.in: Regenerate.
	* libgomp-plugin.h (GOMP_INDIRECT_ADDR_MAP): New define.
	(GOMP_OFFLOAD_load_image): Add extra argument.
	* libgomp.h (struct indirect_splay_tree_key_s): New.
	(indirect_splay_tree_node, indirect_splay_tree,
	indirect_splay_tree_key): New.
	(indirect_splay_compare): New.
	* libgomp.map (GOMP_5.1.1): Add GOMP_target_map_indirect_ptr.
	* libgomp.texi (OpenMP 5.1): Update documentation on indirect
	calls in target region and on indirect clause.
	(Other new OpenMP 5.2 features): Add entry for virtual function calls.
	* libgomp_g.h (GOMP_target_map_indirect_ptr): Add prototype.
	* oacc-host.c (host_load_image): Add extra argument.
	* target.c (gomp_load_image_to_device): If the GOMP_VERSION is high
	enough, read host indirect functions table and pass to
	load_image_func.
	* config/accel/target-indirect.c: New.
	* config/linux/target-indirect.c: New.
	* config/gcn/team.c (build_indirect_map): Add prototype.
	(gomp_gcn_enter_kernel): Initialize support for indirect
	function calls on GCN target.
	* config/nvptx/team.c (build_indirect_map): Add prototype.
	(gomp_nvptx_main): Initialize support for indirect function
	calls on NVPTX target.
	* plugin/plugin-gcn.c (struct gcn_image_desc): Add field for
	indirect functions count.
	(GOMP_OFFLOAD_load_image): Add extra argument.  If the GOMP_VERSION
	is high enough, build address translation table and copy it to target
	memory.
	* plugin/plugin-nvptx.c (nvptx_tdata): Add field for indirect
	functions count.
	(GOMP_OFFLOAD_load_image): Add extra argument.  If the GOMP_VERSION
	is high enough, Build address translation table and copy it to target
	memory.
	* testsuite/libgomp.c-c++-common/declare-target-indirect-1.c: New.
	* testsuite/libgomp.c-c++-common/declare-target-indirect-2.c: New.
	* testsuite/libgomp.c++/declare-target-indirect-1.C: New.
2023-11-07 15:44:50 +00:00
GCC Administrator
38904b732c Daily bump. 2023-11-04 00:16:45 +00:00
Thomas Schwinge
5926f30a8d GCN: Address undeclared 'NULL' usage in 'libgcc/config/gcn/gthr-gcn.h:__gthread_getspecific'
For 'libgcc/config/gcn/gthr-gcn.h' used in libstdc++ context (WIP), we have:

    [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libstdc++-v3/include/amdgcn-amdhsa/bits/gthr-default.h: In function ‘void* __gthread_getspecific(__gthread_key_t)’:
    [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libstdc++-v3/include/amdgcn-amdhsa/bits/gthr-default.h:90:10: error: ‘NULL’ was not declared in this scope
       90 |   return NULL;
          |          ^~~~

Resolve this with 's%NULL%0', as is used in
'libgcc/gthr-single.h:__gthread_getspecific', for example.

Follow-up to commit 76d4633107
"Create GCN-specific gthreads".

	libgcc/
	* config/gcn/gthr-gcn.h (__gthread_getspecific): 's%NULL%0'.
2023-11-03 15:49:27 +01:00
GCC Administrator
eac0917bd3 Daily bump. 2023-11-01 00:17:52 +00:00
Alexandre Oliva
15404016d9 hardcfr: support checking at abnormal edges [PR111943]
Control flow redundancy may choose abnormal edges for early checking,
but that breaks because we can't insert checks on such edges.

Introduce conditional checking on the dest block of abnormal edges,
and leave it for the optimizer to drop the conditional.


for  gcc/ChangeLog

	PR tree-optimization/111943
	* gimple-harden-control-flow.cc: Adjust copyright year.
	(rt_bb_visited): Add vfalse and vtrue data members.
	Zero-initialize them in the ctor.
	(rt_bb_visited::insert_exit_check_on_edge): Upon encountering
	abnormal edges, insert initializers for vfalse and vtrue on
	entry, and insert the check sequence guarded by a conditional
	in the dest block.

for  libgcc/ChangeLog

	* hardcfr.c: Adjust copyright year.

for  gcc/testsuite/ChangeLog

	PR tree-optimization/111943
	* gcc.dg/harden-cfr-pr111943.c: New.
2023-10-31 09:32:08 -03:00
GCC Administrator
444a485f8f Daily bump. 2023-10-25 00:19:04 +00:00
Sergei Trofimovich
eaf75155f3 libgcc: make heap-based trampolines conditional on libc presence
To build `libc` for a target one needs to build `gcc` without `libc`
support first. Commit r14-4823-g8abddb187b3348 "libgcc: support
heap-based trampolines" added unconditional `libc` dependency and broke
libc-less `gcc` builds.

An example failure on `x86_64-unknown-linux-gnu`:

    $ mkdir -p /tmp/empty
    $ ../gcc/configure \
        --disable-multilib \
        --without-headers \
        --with-newlib \
        --enable-languages=c \
        --disable-bootstrap \
        --disable-gcov \
        --disable-threads \
        --disable-shared \
        --disable-libssp \
        --disable-libquadmath \
        --disable-libgomp \
        --disable-libatomic \
        --with-build-sysroot=/tmp/empty
    $ make
    ...
    /tmp/gb/./gcc/xgcc -B/tmp/gb/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include --sysroot=/tmp/empty   -g -O2 -O2  -g -O2 -DIN_GCC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. -I../.././gcc -I/home/slyfox/dev/git/gcc/libgcc -I/home/slyfox/dev/git/gcc/libgcc/. -I/home/slyfox/dev/git/gcc/libgcc/../gcc -I/home/slyfox/dev/git/gcc/libgcc/../include  -DHAVE_CC_TLS  -DUSE_TLS  -o heap-trampoline.o -MT heap-trampoline.o -MD -MP -MF heap-trampoline.dep  -c .../gcc/libgcc/config/i386/heap-trampoline.c -fvisibility=hidden -DHIDE_EXPORTS
    ../gcc/libgcc/config/i386/heap-trampoline.c:3:10: fatal error: unistd.h: No such file or directory
        3 | #include <unistd.h>
          |          ^~~~~~~~~~
    compilation terminated.
    make[2]: *** [.../gcc/libgcc/static-object.mk:17: heap-trampoline.o] Error 1
    make[2]: Leaving directory '/tmp/gb/x86_64-pc-linux-gnu/libgcc'
    make[1]: *** [Makefile:13307: all-target-libgcc] Error 2

The change inhibits any heap-based trampoline code.

libgcc/

	* config/aarch64/heap-trampoline.c: Disable when libc is not
	present.
	* config/i386/heap-trampoline.c: Ditto.
2023-10-24 08:35:44 +01:00
GCC Administrator
3b6327461d Daily bump. 2023-10-23 00:16:43 +00:00
Iain Sandoe
6a6d3817af Config,Darwin: Allow for configuring Darwin to use embedded runpath.
Recent Darwin versions place contraints on the use of run paths
specified in environment variables.  This breaks some assumptions
in the GCC build.

This change allows the user to configure a Darwin build to use
'@rpath/libraryname.dylib' in library names and then to add an
embedded runpath to executables (and libraries with dependents).

The embedded runpath is added by default unless the user adds
'-nodefaultrpaths' to the link line.

For an installed compiler, it means that any executable built with
that compiler will reference the runtimes installed with the
compiler (equivalent to hard-coding the library path into the name
of the library).

During build-time configurations  any "-B" entries will be added to
the runpath thus the newly-built libraries will be found by exes.

Since the install name is set in libtool, that decision needs to be
available here (but might also cause dependent ones in Makefiles,
so we need to export a conditional).

This facility is not available for Darwin 8 or earlier, however the
existing environment variable runpath does work there.

We default this on for systems where the external DYLD_LIBRARY_PATH
does not work and off for Darwin 8 or earlier.  For systems that can
use either method, if the value is unset, we use the default (which
is currently DYLD_LIBRARY_PATH).

ChangeLog:

	* configure: Regenerate.
	* configure.ac: Do not add default runpaths to GCC exes
	when we are building -static-libstdc++/-static-libgcc (the
	default).
	* libtool.m4: Add 'enable-darwin-at-runpath'.  Act  on the
	enable flag to alter Darwin libraries to use @rpath names.

gcc/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* config/darwin.h: Handle Darwin rpaths.
	* config/darwin.opt: Handle Darwin rpaths.
	* Makefile.in:  Handle Darwin rpaths.

gcc/ada/ChangeLog:

	* gcc-interface/Makefile.in: Handle Darwin rpaths.

gcc/jit/ChangeLog:
	* Make-lang.in: Handle Darwin rpaths.

libatomic/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libbacktrace/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libgcc/ChangeLog:

	* config/t-slibgcc-darwin: Generate libgcc_s
	with an @rpath name.
	* config.host: Handle Darwin rpaths.

libgfortran/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths

libgm2/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* libm2cor/Makefile.am: Handle Darwin rpaths.
	* libm2cor/Makefile.in: Regenerate.
	* libm2iso/Makefile.am: Handle Darwin rpaths.
	* libm2iso/Makefile.in: Regenerate.
	* libm2log/Makefile.am: Handle Darwin rpaths.
	* libm2log/Makefile.in: Regenerate.
	* libm2min/Makefile.am: Handle Darwin rpaths.
	* libm2min/Makefile.in: Regenerate.
	* libm2pim/Makefile.am: Handle Darwin rpaths.
	* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths

libitm/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libobjc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libphobos/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* libdruntime/Makefile.am: Handle Darwin rpaths.
	* libdruntime/Makefile.in: Regenerate.
	* src/Makefile.am: Handle Darwin rpaths.
	* src/Makefile.in: Regenerate.

libquadmath/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libsanitizer/ChangeLog:

	* asan/Makefile.am: Handle Darwin rpaths.
	* asan/Makefile.in: Regenerate.
	* configure: Regenerate.
	* hwasan/Makefile.am: Handle Darwin rpaths.
	* hwasan/Makefile.in: Regenerate.
	* lsan/Makefile.am: Handle Darwin rpaths.
	* lsan/Makefile.in: Regenerate.
	* tsan/Makefile.am: Handle Darwin rpaths.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.am: Handle Darwin rpaths.
	* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* src/Makefile.am: Handle Darwin rpaths.
	* src/Makefile.in: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

lto-plugin/ChangeLog:
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

zlib/ChangeLog:
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
2023-10-22 19:30:02 +01:00
Andrew Burgess
8abddb187b libgcc: support heap-based trampolines
Add support for heap-based trampolines on x86_64-linux, aarch64-linux,
and x86_64-darwin. Implement the __builtin_nested_func_ptr_created and
__builtin_nested_func_ptr_deleted functions for these targets.

Co-Authored-By: Maxim Blinov <maxim.blinov@embecosm.com>
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

libgcc/ChangeLog:

	* libgcc2.h (__builtin_nested_func_ptr_created): Declare.
	(__builtin_nested_func_ptr_deleted): Declare.
	* libgcc-std.ver.in: Add the new symbols.
	* config/aarch64/heap-trampoline.c: Implement heap-based
	trampolines for aarch64.
	* config/aarch64/t-heap-trampoline: Add rule to build
	config/aarch64/heap-trampoline.c
	* config/i386/heap-trampoline.c: Implement heap-based
	trampolines for x86_64.
	* config/i386/t-heap-trampoline: Add rule to build
	config/i386/heap-trampoline.cc
	* config.host: Handle --enable-heap-trampolines on
	x86_64-*-linux*, aarch64-*-linux*, x86_64-*-darwin*.
2023-10-22 14:01:47 +01:00
GCC Administrator
6f684dd259 Daily bump. 2023-10-21 00:17:36 +00:00
Andrew Stubbs
c7ec7bd1c6 amdgcn: add -march=gfx1030 EXPERIMENTAL
Accept the architecture configure option and resolve build failures.  This is
enough to build binaries, but I've not got a device to test it on, so there
are probably runtime issues to fix.  The cache control instructions might be
unsafe (or too conservative), and the kernel metadata might be off.  Vector
reductions will need to be reworked for RDNA2.  In principle, it would be
better to use wavefrontsize32 for this architecture, but that would mean
switching everything to allow SImode masks, so wavefrontsize64 it is.

The multilib is not included in the default configuration so either configure
--with-arch=gfx1030 or include it in --with-multilib-list=gfx1030,....

The majority of this patch has no effect on other devices, but changing from
using scalar writes for the exit value to vector writes means we don't need
the scalar cache write-back instruction anywhere (which doesn't exist in RDNA2).

gcc/ChangeLog:

	* config.gcc: Allow --with-arch=gfx1030.
	* config/gcn/gcn-hsa.h (NO_XNACK): gfx1030 does not support xnack.
	(ASM_SPEC): gfx1030 needs -mattr=+wavefrontsize64 set.
	* config/gcn/gcn-opts.h (enum processor_type): Add PROCESSOR_GFX1030.
	(TARGET_GFX1030): New.
	(TARGET_RDNA2): New.
	* config/gcn/gcn-valu.md (@dpp_move<mode>): Disable for RDNA2.
	(addc<mode>3<exec_vcc>): Add RDNA2 syntax variant.
	(subc<mode>3<exec_vcc>): Likewise.
	(<convop><mode><vndi>2_exec): Add RDNA2 alternatives.
	(vec_cmp<mode>di): Likewise.
	(vec_cmp<u><mode>di): Likewise.
	(vec_cmp<mode>di_exec): Likewise.
	(vec_cmp<u><mode>di_exec): Likewise.
	(vec_cmp<mode>di_dup): Likewise.
	(vec_cmp<mode>di_dup_exec): Likewise.
	(reduc_<reduc_op>_scal_<mode>): Disable for RDNA2.
	(*<reduc_op>_dpp_shr_<mode>): Likewise.
	(*plus_carry_dpp_shr_<mode>): Likewise.
	(*plus_carry_in_dpp_shr_<mode>): Likewise.
	* config/gcn/gcn.cc (gcn_option_override): Recognise gfx1030.
	(gcn_global_address_p): RDNA2 only allows smaller offsets.
	(gcn_addr_space_legitimate_address_p): Likewise.
	(gcn_omp_device_kind_arch_isa): Recognise gfx1030.
	(gcn_expand_epilogue): Use VGPRs instead of SGPRs.
	(output_file_start): Configure gfx1030.
	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __RDNA2__;
	(ASSEMBLER_DIALECT): New.
	* config/gcn/gcn.md (rdna): New define_attr.
	(enabled): Use "rdna" attribute.
	(gcn_return): Remove s_dcache_wb.
	(addcsi3_scalar): Add RDNA2 syntax variant.
	(addcsi3_scalar_zero): Likewise.
	(addptrdi3): Likewise.
	(mulsi3): v_mul_lo_i32 should be v_mul_lo_u32 on all ISA.
	(*memory_barrier): Add RDNA2 syntax variant.
	(atomic_load<mode>): Add RDNA2 cache control variants, and disable
	scalar atomics for RDNA2.
	(atomic_store<mode>): Likewise.
	(atomic_exchange<mode>): Likewise.
	* config/gcn/gcn.opt (gpu_type): Add gfx1030.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1030): New.
	(main): Recognise -march=gfx1030.
	* config/gcn/t-omp-device: Add gfx1030 isa.

libgcc/ChangeLog:

	* config/gcn/amdgcn_veclib.h (CDNA3_PLUS): Set false for __RDNA2__.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (EF_AMDGPU_MACH_AMDGCN_GFX1030): New.
	(isa_hsa_name): Recognise gfx1030.
	(isa_code): Likewise.
	* team.c (defined): Remove s_endpgm.
2023-10-20 12:40:25 +01:00
Alexandre Oliva
551935d118 Control flow redundancy hardening
This patch introduces an optional hardening pass to catch unexpected
execution flows.  Functions are transformed so that basic blocks set a
bit in an automatic array, and (non-exceptional) function exit edges
check that the bits in the array represent an expected execution path
in the CFG.

Functions with multiple exit edges, or with too many blocks, call an
out-of-line checker builtin implemented in libgcc.  For simpler
functions, the verification is performed in-line.

-fharden-control-flow-redundancy enables the pass for eligible
functions, --param hardcfr-max-blocks sets a block count limit for
functions to be eligible, and --param hardcfr-max-inline-blocks
tunes the "too many blocks" limit for in-line verification.
-fhardcfr-skip-leaf makes leaf functions non-eligible.

Additional -fhardcfr-check-* options are added to enable checking at
exception escape points, before potential sibcalls, hereby dubbed
returning calls, and before noreturn calls and exception raises.  A
notable case is the distinction between noreturn calls expected to
throw and those expected to terminate or loop forever: the default
setting for -fhardcfr-check-noreturn-calls, no-xthrow, performs
checking before the latter, but the former only gets checking in the
exception handler.  GCC can only tell between them by explicit marking
noreturn functions expected to raise with the newly-introduced
expected_throw attribute, and corresponding ECF_XTHROW flag.


for  gcc/ChangeLog

	* tree-core.h (ECF_XTHROW): New macro.
	* tree.cc (set_call_expr): Add expected_throw attribute when
	ECF_XTHROW is set.
	(build_common_builtin_node): Add ECF_XTHROW to
	__cxa_end_cleanup and _Unwind_Resume or _Unwind_SjLj_Resume.
	* calls.cc (flags_from_decl_or_type): Check for expected_throw
	attribute to set ECF_XTHROW.
	* gimple.cc (gimple_build_call_from_tree): Propagate
	ECF_XTHROW from decl flags to gimple call...
	(gimple_call_flags): ... and back.
	* gimple.h (GF_CALL_XTHROW): New gf_mask flag.
	(gimple_call_set_expected_throw): New.
	(gimple_call_expected_throw_p): New.
	* Makefile.in (OBJS): Add gimple-harden-control-flow.o.
	* builtins.def (BUILT_IN___HARDCFR_CHECK): New.
	* common.opt (fharden-control-flow-redundancy): New.
	(-fhardcfr-check-returning-calls): New.
	(-fhardcfr-check-exceptions): New.
	(-fhardcfr-check-noreturn-calls=*): New.
	(Enum hardcfr_check_noreturn_calls): New.
	(fhardcfr-skip-leaf): New.
	* doc/invoke.texi: Document them.
	(hardcfr-max-blocks, hardcfr-max-inline-blocks): New params.
	* flag-types.h (enum hardcfr_noret): New.
	* gimple-harden-control-flow.cc: New.
	* params.opt (-param=hardcfr-max-blocks=): New.
	(-param=hradcfr-max-inline-blocks=): New.
	* passes.def (pass_harden_control_flow_redundancy): Add.
	* tree-pass.h (make_pass_harden_control_flow_redundancy):
	Declare.
	* doc/extend.texi: Document expected_throw attribute.

for  gcc/ada/ChangeLog

	* gcc-interface/trans.cc (gigi): Mark __gnat_reraise_zcx with
	ECF_XTHROW.
	(build_raise_check): Likewise for all rcheck subprograms.

for  gcc/c-family/ChangeLog

	* c-attribs.cc (handle_expected_throw_attribute): New.
	(c_common_attribute_table): Add expected_throw.

for  gcc/cp/ChangeLog

	* decl.cc (push_throw_library_fn): Mark with ECF_XTHROW.
	* except.cc (build_throw): Likewise __cxa_throw,
	_ITM_cxa_throw, __cxa_rethrow.

for  gcc/testsuite/ChangeLog

	* c-c++-common/torture/harden-cfr.c: New.
	* c-c++-common/harden-cfr-noret-never-O0.c: New.
	* c-c++-common/torture/harden-cfr-noret-never.c: New.
	* c-c++-common/torture/harden-cfr-noret-noexcept.c: New.
	* c-c++-common/torture/harden-cfr-noret-nothrow.c: New.
	* c-c++-common/torture/harden-cfr-noret.c: New.
	* c-c++-common/torture/harden-cfr-notail.c: New.
	* c-c++-common/torture/harden-cfr-returning.c: New.
	* c-c++-common/torture/harden-cfr-tail.c: New.
	* c-c++-common/torture/harden-cfr-abrt-always.c: New.
	* c-c++-common/torture/harden-cfr-abrt-never.c: New.
	* c-c++-common/torture/harden-cfr-abrt-no-xthrow.c: New.
	* c-c++-common/torture/harden-cfr-abrt-nothrow.c: New.
	* c-c++-common/torture/harden-cfr-abrt.c: New.
	* c-c++-common/torture/harden-cfr-always.c: New.
	* c-c++-common/torture/harden-cfr-never.c: New.
	* c-c++-common/torture/harden-cfr-no-xthrow.c: New.
	* c-c++-common/torture/harden-cfr-nothrow.c: New.
	* c-c++-common/torture/harden-cfr-bret-always.c: New.
	* c-c++-common/torture/harden-cfr-bret-never.c: New.
	* c-c++-common/torture/harden-cfr-bret-noopt.c: New.
	* c-c++-common/torture/harden-cfr-bret-noret.c: New.
	* c-c++-common/torture/harden-cfr-bret-no-xthrow.c: New.
	* c-c++-common/torture/harden-cfr-bret-nothrow.c: New.
	* c-c++-common/torture/harden-cfr-bret-retcl.c: New.
	* c-c++-common/torture/harden-cfr-bret.c: New.
	* g++.dg/harden-cfr-throw-always-O0.C: New.
	* g++.dg/harden-cfr-throw-returning-O0.C: New.
	* g++.dg/torture/harden-cfr-noret-always-no-nothrow.C: New.
	* g++.dg/torture/harden-cfr-noret-never-no-nothrow.C: New.
	* g++.dg/torture/harden-cfr-noret-no-nothrow.C: New.
	* g++.dg/torture/harden-cfr-throw-always.C: New.
	* g++.dg/torture/harden-cfr-throw-never.C: New.
	* g++.dg/torture/harden-cfr-throw-no-xthrow.C: New.
	* g++.dg/torture/harden-cfr-throw-no-xthrow-expected.C: New.
	* g++.dg/torture/harden-cfr-throw-nothrow.C: New.
	* g++.dg/torture/harden-cfr-throw-nocleanup.C: New.
	* g++.dg/torture/harden-cfr-throw-returning.C: New.
	* g++.dg/torture/harden-cfr-throw.C: New.
	* gcc.dg/torture/harden-cfr-noret-no-nothrow.c: New.
	* gcc.dg/torture/harden-cfr-tail-ub.c: New.
	* gnat.dg/hardcfr.adb: New.

for  libgcc/ChangeLog

	* Makefile.in (LIB2ADD): Add hardcfr.c.
	* hardcfr.c: New.
2023-10-20 07:50:33 -03:00
GCC Administrator
0308461d9d Daily bump. 2023-10-19 00:18:05 +00:00
Georg-Johann Lay
67f7bf78ba LibF7: Implement mul_mant for devices without MUL instruction.
libgcc/config/avr/libf7/
	* libf7-asm.sx (mul_mant): Implement for devices without MUL.
	* asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation.
	* t-libf7 (F7_ASM_FLAGS): Add -g0.
2023-10-18 19:00:09 +02:00
GCC Administrator
fb69acffa9 Daily bump. 2023-10-18 00:17:58 +00:00
Georg-Johann Lay
da65efe433 LibF7: Re-generate f7-renames.h to pick up white-space from f7renames.sh.
libgcc/config/avr/libf7/
	* f7-renames.h: Re-renerate.
2023-10-17 17:19:36 +02:00