platform/upstream/gcc.git
2 years ago[Ada] Fix missing check on slice with a subtype indication
Piotr Trojanek [Thu, 26 Aug 2021 15:35:27 +0000 (17:35 +0200)]
[Ada] Fix missing check on slice with a subtype indication

gcc/ada/

* sem_res.adb (Resolve_Slice): Handle range given as a subtype
indication.

2 years ago[Ada] Fix handling of 'Image acting as a prefix of a slice in CodePeer
Piotr Trojanek [Tue, 24 Aug 2021 21:58:40 +0000 (23:58 +0200)]
[Ada] Fix handling of 'Image acting as a prefix of a slice in CodePeer

gcc/ada/

* sem_res.adb (Resolve_Slice): Add custom handling of attribute
Image and similar in CodePeer mode. This complements the
existing custom handling of these attributes in
Expand_N_Attribute_Reference.

2 years ago[Ada] Spurious non-variable error on implicitly dereferenced in-mode formal
Justin Squirek [Mon, 19 Jul 2021 18:03:35 +0000 (14:03 -0400)]
[Ada] Spurious non-variable error on implicitly dereferenced in-mode formal

gcc/ada/

* sem_util.adb (Is_Variable): Add check for implicitly
dereferenced access types
(Is_Dependent_Component_Of_Mutable_Object): Set Prefix_Type when
not specified.

2 years ago[Ada] Adjust documentation of -fdump-ada-spec in GNAT UG
Eric Botcazou [Thu, 26 Aug 2021 13:42:05 +0000 (15:42 +0200)]
[Ada] Adjust documentation of -fdump-ada-spec in GNAT UG

gcc/ada/

* doc/gnat_ugn/the_gnat_compilation_model.rst (Binding generation):
Document specific behavior for /include/-ending paths and update.
* gnat_ugn.texi: Regenerate.

2 years ago[Ada] PR ada/102073
Arnaud Charlet [Thu, 26 Aug 2021 13:21:22 +0000 (09:21 -0400)]
[Ada] PR ada/102073

gcc/ada/

PR ada/102073
* socket.c (__gnat_gethostbyaddr, __gnat_inet_pton): Add missing
return statements.

2 years ago[Ada] Crash on allocator in alternative accessibility modes
Justin Squirek [Sat, 14 Aug 2021 11:32:17 +0000 (07:32 -0400)]
[Ada] Crash on allocator in alternative accessibility modes

gcc/ada/

* sem_util.adb (Function_Or_Allocator_Level): Properly handle
direct function calls in the default alternative accessibility
checking mode.

2 years ago[Ada] Entities in E_Loop scopes are not library-level entities
Javier Miranda [Thu, 26 Aug 2021 17:40:14 +0000 (13:40 -0400)]
[Ada] Entities in E_Loop scopes are not library-level entities

gcc/ada/

* sem_util.adb (Is_Library_Level_Entity): Return False for
entities defined in E_Loop scopes. This change is not required
by the frontend; it is required by tools that depend on the
frontend sources.
* einfo-utils.adb (Is_Dynamic_Scope): Code cleanup.

2 years ago[Ada] Spurious accessibility error on renamed expression
Justin Squirek [Wed, 18 Aug 2021 03:12:00 +0000 (23:12 -0400)]
[Ada] Spurious accessibility error on renamed expression

gcc/ada/

* sem_util.adb (Accessibility_Level): Add a case to handle
renamed subprograms in addition to renamed objects.

2 years ago[Ada] VxWorks inconsistent use of return type Fixup
Doug Rupp [Fri, 20 Aug 2021 15:26:58 +0000 (08:26 -0700)]
[Ada] VxWorks inconsistent use of return type Fixup

gcc/ada/

* libgnarl/s-osinte__vxworks.ads (tlsKeyCreate): Return int.
* libgnarl/s-tpopsp__vxworks-rtp.adb (ERROR): Declare from
System.VxWorks.Ext.ERROR.
(Initialize): Declare IERR. Assert it.
* libgnarl/s-tpopsp__vxworks.adb (ERROR): Declare from
System.VxWorks.Ext.ERROR.
(Is_Valid_Task): Declare IERR. Test return.
* libgnarl/s-vxwext__kernel.adb (semDelete): Return STATUS.

2 years ago[Ada] Emit debugging information for TSD object
Eric Botcazou [Mon, 23 Aug 2021 16:16:05 +0000 (18:16 +0200)]
[Ada] Emit debugging information for TSD object

gcc/ada/

* exp_disp.adb (Make_DT): Copy the Needs_Debug_Info flag from the
type onto the TSD object.

2 years ago[Ada] Fix compiler internal error
Steve Baird [Tue, 17 Aug 2021 17:01:11 +0000 (10:01 -0700)]
[Ada] Fix compiler internal error

gcc/ada/

* sem_util.adb (Is_Repeatedly_Evaluated): Handle the case of an
Old attribute reference that occurs within what was originally a
quantified expression but which expansion has transformed into
an Expression_With_Actions.

2 years ago[Ada] Improve checking for invalid index values when accessing array elements
Steve Baird [Mon, 16 Aug 2021 23:41:40 +0000 (16:41 -0700)]
[Ada] Improve checking for invalid index values when accessing array elements

gcc/ada/

* exp_ch4.adb (Expand_N_Indexed_Component): The two improvements
described above.

2 years agoFortran: Avoid var initialization in interfaces [PR54753]
Tobias Burnus [Mon, 4 Oct 2021 07:38:43 +0000 (09:38 +0200)]
Fortran: Avoid var initialization in interfaces [PR54753]

Intent(out) implies deallocation/default initialization; however, it is
pointless to do this for dummy-arguments symbols of procedures which are
inside an INTERFACE block. – This also fixes a bogus error for the attached
included testcase, but fixing the non-interface version still has to be done.

PR fortran/54753

gcc/fortran/ChangeLog:

* resolve.c (can_generate_init, resolve_fl_variable_derived,
resolve_symbol): Only do initialization with intent(out) if not
inside of an interface block.

2 years agoRemove dead code in config/rs6000/vxworks.h
Eric Botcazou [Mon, 4 Oct 2021 07:16:19 +0000 (09:16 +0200)]
Remove dead code in config/rs6000/vxworks.h

These lines were added last year:

/* Initialize library function table.  */
 #undef TARGET_INIT_LIBFUNCS
 #define TARGET_INIT_LIBFUNCS rs6000_vxworks_init_libfuncs

but TARGET_INIT_LIBFUNCS is #undef-ed in config/rs6000/rs6000.c and
rs6000_vxworks_init_libfuncs is nowhere defined in any case.

gcc/
* config/rs6000/vxworks.h (TARGET_INIT_LIBFUNCS): Delete.

2 years agoDaily bump.
GCC Administrator [Mon, 4 Oct 2021 00:16:22 +0000 (00:16 +0000)]
Daily bump.

2 years agoFix for powerpc64 long double complex divide failure
Patrick McGehearty [Sun, 3 Oct 2021 22:07:06 +0000 (18:07 -0400)]
Fix for powerpc64 long double complex divide failure

- - - -

New in version 6: Due to an oversight (i.e. coding error), version 5
changed the use of __LIBGCC_TF_EPSILON__ to __LIBGCC_DF_EPSILON__ but
not the other LIBGCC_TF values. For correct execution of the long
double test case it is necessary to also switch to using
__LIBGCC_DF_MIN__. For consistency we also switch to using
__LIBGCC_DF_MAX__. LDBL_MIN is 2**53 times as larger than DBL_MIN.
The larger value causes the code to switch the order of computation
when it is not optimal, resulting in failure for one of the values
in the cdivchk_ld.c test. Using DBL_MIN does not cause that failure..

There may be opportunity for further refinement of IBM128 format
Long Double complex divide, but that's beyond the scope of this
patch.

- - - -

This revision adds a test in libgcc/libgcc2.c for when
"__LIBGCC_TF_MANT_DIG__ == 106" to use __LIBGCC_DF_EPSILON__ instead
of __LIBGCC_TF_EPSILON__. That is specific to IBM 128-bit format long
doubles where EPSILON is very, very small and 1/EPSILON oveflows to
infinity. This change avoids the overflow without affecting any other
platform. Discussion in the patch is adjusted to reflect this
limitation.

It does not make any changes to .../rs6000/_divkc3.c, leaving it to
use __LIBGCC_KF__*. That means the upstream gcc will not build in
older IBM environments that do not recognize the KF floating point
mode properly. Environments that do not need IBM longdouble support
do build cleanly.

- - - -
This patch addresses the failure of powerpc64 long double complex divide
in native ibm long double format after the patch "Practical improvement
to libgcc complex divide".

The new code uses the following macros which are intended to be mapped
to appropriate values according to the underlying hardware representation.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101104

RBIG     a value near the maximum representation
RMIN     a value near the minimum representation
         (but not in the subnormal range)
RMIN2    a value moderately less than 1
RMINSCAL the inverse of RMIN2
RMAX2    RBIG * RMIN2  - a value to limit scaling to not overflow

When "long double" values were not using the IEEE 128-bit format but
the traditional IBM 128-bit, the previous code used the LDBL values
which caused overflow for RMINSCAL. The new code uses the DBL values.

RBIG  LDBL_MAX = 0x1.fffffffffffff800p+1022
      DBL_MAX  = 0x1.fffffffffffff000p+1022

RMIN  LDBL_MIN = 0x1.0000000000000000p-969
RMIN  DBL_MIN  = 0x1.0000000000000000p-1022

RMIN2 LDBL_EPSILON = 0x0.0000000000001000p-1022 = 0x1.0p-1074
RMIN2 DBL_EPSILON  = 0x1.0000000000000000p-52

\e[ORMINSCAL 1/LDBL_EPSILON = inf (1.0p+1074 does not fit in IBM 128-bit).
         1/DBL_EPSILON  = 0x1.0000000000000000p+52

RMAX2 = RBIG * RMIN2 = 0x1.fffffffffffff800p-52
        RBIG * RMIN2 = 0x1.fffffffffffff000p+970

The MAX and MIN values have only modest changes since the maximum and
minimum values are about the same as for double precision.  The
EPSILON field is considerably different. Due to how very small values
can be represented in the lower 64 bits of the IBM 128-bit floating
point, EPSILON is extremely small, so far beyond the desired value
that inversion of the value overflows and even without the overflow,
the RMAX2 is so small as to eliminate most usage of the test.

The change has been tested on gcc135.fsffrance.org and gains the
expected improvements in accuracy for long double complex divide.

libgcc/
PR target/101104
* libgcc2.c (RMIN2, RMINSCAL, RMAX2):
Use more correct values for native IBM 128-bit.

2 years agocoroutines: Fail with a sorry when presented with a VLA [PR 101765].
Iain Sandoe [Sat, 2 Oct 2021 15:15:38 +0000 (16:15 +0100)]
coroutines: Fail with a sorry when presented with a VLA [PR 101765].

We do not support this yet.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101765

gcc/cp/ChangeLog:

* coroutines.cc (register_local_var_uses): Emit a sorry if
we encounter a VLA in the coroutine local variables.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr101765.C: New test.

2 years agocoroutines: Await expressions are not allowed in handlers [PR 99710].
Iain Sandoe [Sat, 2 Oct 2021 13:43:39 +0000 (14:43 +0100)]
coroutines: Await expressions are not allowed in handlers [PR 99710].

C++20 [expr.await] / 2
An await-expression shall appear only in a potentially-evaluated expression
within the compound-statement of a function-body outside of a handler.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/99710

gcc/cp/ChangeLog:

* coroutines.cc (await_statement_walker): Report an error if
an await expression is found in a handler body.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr99710.C: New test.

2 years agocoroutines: Fix ICE with an invalid await_suspend type [PR100673].
John Eivind Helset [Fri, 21 May 2021 23:53:22 +0000 (01:53 +0200)]
coroutines: Fix ICE with an invalid await_suspend type [PR100673].

The reported ICE occurs when an invalid (non-template) type is found
as the return for an await_suspend.

Fixed by amending build_co_await to ensure that await_suspend return-
type is a template-instantiation before checking to see if it is a
valid coroutine handle type.

Signed-off-by: John Eivind Helset <jehelset@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/100673

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Guard against NULL
await_suspend types.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr100673.C: New test.

2 years agocoroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].
Iain Sandoe [Sat, 2 Oct 2021 12:40:09 +0000 (13:40 +0100)]
coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].

Although it is not immediately evident from the symptoms, the PR is
caused by a variable having a DECL_INITIAL() containing a co_await.
This is not correct, since such expressions have side-effects.

We were marking the overall co_await expression correctly, but if a
consumer of that expression stripped out the underlying co_await_expr
then the latter would not be properly marked.

Fixed by marking both the underlying and any containing await expr
with TREE_SIDE_EFFECTS.  Also mark type-dependent co_await expressions.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101133

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Mark co_await_expr trees
with TREE_SIDE_EFFECTS, also mark any containing expression.
(finish_co_await_expr): Mark type-dependent co_await_expr
trees with TREE_SIDE_EFFECTS.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr101133.C: New test.

2 years agocoroutines: Look through NOPs for awaiter variables [PR 99575].
Iain Sandoe [Sat, 2 Oct 2021 11:44:01 +0000 (12:44 +0100)]
coroutines: Look through NOPs for awaiter variables [PR 99575].

There was a missing STRIP_NOPS which meant that, in some cases,
an awaiter variable could be hidden by a view-convert-expr.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/99575

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Strip NOPs from
candidate awaiter expressions before testing to see
if they need a temporary.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr99575.C: New test.

2 years agooptions: check for CL_OPTIMIZATION only for cl_options.
Martin Liska [Sun, 3 Oct 2021 12:25:11 +0000 (14:25 +0200)]
options: check for CL_OPTIMIZATION only for cl_options.

gcc/ChangeLog:

* toplev.c (toplev::main): Check opt_index if it is a part
of cl_options.

2 years agoDaily bump.
GCC Administrator [Sun, 3 Oct 2021 00:16:17 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Fix typos in std::filesystem code
Jonathan Wakely [Sat, 2 Oct 2021 20:18:19 +0000 (21:18 +0100)]
libstdc++: Fix typos in std::filesystem code

There were a couple of typos in r12-4070 and r12-4071 which don't show
up when building for POSIX targets.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (create_directory): Fix typo in enum name.
* src/filesystem/ops-common.h (__last_system_error): Add
explicit cast to avoid narrowing conversion.
(do_space): Fix type in function name.

2 years ago[PR102563] Do not clobber range in operator_lshift::op1_range.
Aldy Hernandez [Sat, 2 Oct 2021 14:59:26 +0000 (16:59 +0200)]
[PR102563] Do not clobber range in operator_lshift::op1_range.

We're clobbering the final range before we're done calculating it.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/102563
* range-op.cc (operator_lshift::op1_range): Do not clobber
range.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr102563.c: New test.

2 years agocontrib: filter out mmx.md file.
Martin Liska [Sat, 2 Oct 2021 11:30:28 +0000 (13:30 +0200)]
contrib: filter out mmx.md file.

contrib/ChangeLog:

* filter-clang-warnings.py: Filter out -Wtautological-compare
for the file.

2 years agoAdd libgomp.fortran/order-reproducible-*.f90
Tobias Burnus [Sat, 2 Oct 2021 09:29:35 +0000 (11:29 +0200)]
Add libgomp.fortran/order-reproducible-*.f90

libgomp/ChangeLog:

* testsuite/libgomp.fortran/order-reproducible-1.f90: New test
based on libgomp.c-c++-common/order-reproducible-1.c.
* testsuite/libgomp.fortran/order-reproducible-2.f90: Likewise.
* testsuite/libgomp.fortran/my-usleep.c: New test.

2 years agooptions: fix ASAN issue during saving of opt. options
Martin Liska [Sat, 2 Oct 2021 07:31:46 +0000 (09:31 +0200)]
options: fix ASAN issue during saving of opt. options

gcc/ChangeLog:

* toplev.c (toplev::main): save_decoded_options[0] is program
name and so it should be skipped.

2 years agoc-family: Fix bootstrap for targets defining TARGET_FORMAT_TYPES.
Iain Sandoe [Sat, 2 Oct 2021 08:19:24 +0000 (09:19 +0100)]
c-family: Fix bootstrap for targets defining TARGET_FORMAT_TYPES.

A recent improvement in Waddress causes a bootstrap failure on
targets that define TARGET_FORMAT_TYPES since it cannot be NULL
if defined to an address.

There is no default for this target macro, and it would seem no
purpose to defining it to NULL, so the warning appears reasonable.

Fixed by removing the pointless test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/c-family/ChangeLog:

* c-format.c: Remove a test of TARGET_FORMAT_TYPES with
NULL, this is not needed.

2 years agoUse unsigned long long in asm-x86-linux-rdmsr.c
H.J. Lu [Sat, 2 Oct 2021 02:26:08 +0000 (19:26 -0700)]
Use unsigned long long in asm-x86-linux-rdmsr.c

Use unsigned long long for 64-bit integer since unsigned long is 32 bits
for x32.

* gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c (DECLARE_ARGS):
Use unsigned long long for x86-64.

2 years agoDaily bump.
GCC Administrator [Sat, 2 Oct 2021 00:16:31 +0000 (00:16 +0000)]
Daily bump.

2 years ago[PR102546] X << Y being non-zero implies X is also non-zero.
Aldy Hernandez [Fri, 1 Oct 2021 11:05:36 +0000 (13:05 +0200)]
[PR102546] X << Y being non-zero implies X is also non-zero.

This patch teaches this to range-ops.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/102546
* range-op.cc (operator_lshift::op1_range): Teach range-ops that
X << Y is non-zero implies X is also non-zero.

2 years agoaarch64: enable cortex-x2 CPU
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:40:13 +0000 (22:40 +0100)]
aarch64: enable cortex-x2 CPU

Patch is adding 'cortex-x2' to -mcpu command line option.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-X2 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.

2 years agoaarch64: enable cortex-a710 CPU
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:39:53 +0000 (22:39 +0100)]
aarch64: enable cortex-a710 CPU

Patch is adding 'cortex-a710' to -mcpu command line option.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-A710 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.

2 years agoaarch64: enable cortex-a510 CPU
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:39:32 +0000 (22:39 +0100)]
aarch64: enable cortex-a510 CPU

Patch is adding 'cortex-a510' to -mcpu command line option.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-A510 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.

2 years agolibstdc++: Restore printing of assertion messages [PR102100]
Jonathan Wakely [Fri, 1 Oct 2021 14:55:57 +0000 (15:55 +0100)]
libstdc++: Restore printing of assertion messages [PR102100]

My changes for PR 101429 broke the _-replacement_assert function,
because we now always just abort without printing anything. That's
because I added checks for _GLIBCXX_HOSTED and _GLIBCXX_VERBOSE, but the
checks are done before those get defined.

This adds a new macro which is set
by the sed command in include/Makefile, once the HOSTED and VERBOSE
macros have been set by the configure script.

libstdc++-v3/ChangeLog:

PR libstdc++/102100
* include/Makefile.am (c++config.h): Define
_GLIBCXX_VERBOSE_ASSERT based on configure output.
* include/Makefile.in: Regenerate.
* include/bits/c++config: Fix condition for verbose assertions.

2 years agolibstdc++: Reduce header dependencies for C++20 std::erase [PR92546]
Jonathan Wakely [Fri, 1 Oct 2021 19:37:02 +0000 (20:37 +0100)]
libstdc++: Reduce header dependencies for C++20 std::erase [PR92546]

This reduces the preprocessed size of <deque>, <string> and <vector> by
not including <bits/stl_algo.h> for std::remove and std::remove_if.

Also unwrap iterators using __niter_base, to avoid redundant debug mode
checks.

PR libstdc++/92546
* include/bits/erase_if.h (__erase_nodes_if): Use __niter_base to
unwrap debug iterators.
* include/bits/refwrap.h: Do not error if included in C++03.
* include/bits/stl_algo.h (__remove_if): Move to ...
* include/bits/stl_algobase.h (__remove_if): ... here.
* include/std/deque (erase, erase_if): Use __remove_if instead of
remove and remove_if.
* include/std/string (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.

2 years agolibstdc++: Allow stateful allocators in std::list::sort [PR 66742]
Jonathan Wakely [Tue, 25 May 2021 13:33:15 +0000 (14:33 +0100)]
libstdc++: Allow stateful allocators in std::list::sort [PR 66742]

The temporary lists used by std::list::sort are default constructed,
which means they use default constructed allocators. The sort operation
is defined in terms of merge and splice operations, which have undefined
behaviour (and abort) if the allocators do not compare equal. This means
it is not possible to sort a list that uses an allocator that compares
unequal to an default constructed allocator.

The solution is to avoid using temporary std::list objects at all. We do
not need to be able to allocate memory because no nodes are allocated,
only spliced from one list to another. That means the temporary lists
don't need an allocator at all, so whether it would compare equal
doesn't matter.

Instead of temporary std::list objects, we can just use a collection of
_List_node_base objects that nodes can be spliced onto as needed. Those
objects are wrapped in a _Scratch_list type that implements the splicing
and merging operations used by list::sort.

We also don't need to update the list size during the sort, because
sorting doesn't alter the number of nodes. Although we move nodes in and
out of the scratch lists, at the end of the function all nodes are back
in the original std::list and the scratch lists are empty.  So for the
cxx11 ABI we can avoid the _M_size modifications usually done when
splicing nodes.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/66742
* include/bits/list.tcc (list::sort()): Use _Scratch_list
objects for splicing and merging.
(list::sort(StrictWeakOrdering)): Likewise.
* include/bits/stl_list.h (__detail::_Scratch_list): New type.
* src/c++98/list.cc (_List_node_base::_M_transfer): Add
assertion for --enable-libstdcxx-debug library.
* testsuite/23_containers/list/operations/66742.cc: New test.

2 years agolibstdc++: Make std::jthread support pointers to member functions [PR 100612]
Jonathan Wakely [Thu, 20 May 2021 21:36:16 +0000 (22:36 +0100)]
libstdc++: Make std::jthread support pointers to member functions [PR 100612]

This adds a non-standard extension to support initializing a
std::jthread with a pointer to a member function that expects a
stop_token to be added to the arguments. That use case is not supported
by C++20, because the stop_token would get added as the first argument,
which is where the object argument needs to be to invoke a pointer to
member function.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/100612
* include/std/thread (__pmf_expects_stop_token): New variable
template to detect a pointer to member function that needs a
stop_token to be added to the arguments.
(jthread::__S_create): Use __pmf_expects_stop_token.
(jthread::__S_create_pmf): New function.
* testsuite/30_threads/jthread/100612.cc: New test.

2 years agolibstdc++: Add container adaptor constructors taking iterators (P1425R4)
Jonathan Wakely [Thu, 13 May 2021 15:16:26 +0000 (16:16 +0100)]
libstdc++: Add container adaptor constructors taking iterators (P1425R4)

This adds a feature that was recently added to the C++23 working draft.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h
(__cpp_lib_adaptor_iterator_pair_constructor): Define for C++23, as
per P1425R4.
(queue(InputIterator, InputIterator)): Likewise.
(queue(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/bits/stl_stack.h
(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
(stack(InputIterator, InputIterator)): Likewise.
(stack(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/std/version (__cpp_lib_adaptor_iterator_pair_constructor):
Define.
* testsuite/23_containers/queue/cons_from_iters.cc: New test.
* testsuite/23_containers/stack/cons_from_iters.cc: New test.

2 years agolibstdc++: Implement LWG 3506 for std::priority_queue
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3506 for std::priority_queue

The LWG 3506 issue ads allocator-extended versions of the constructors
that take iterator arguments.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h (priority_queue): Add
allocator-extended overloads for constructors taking iterator.
* testsuite/23_containers/priority_queue/lwg3506.cc: New test.

2 years agolibstdc++: Implement LWG 3529 for std::priority_queue
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3529 for std::priority_queue

The LWG 3529 issue changes to use two overloads instead of one with a
default argument, so that the sequence can be initialized directly with
the iterator range when no sequence argument is provided.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h (priority_queue): Construct sequence
from iterators when no sequence argument is present (LWG 3529).
* testsuite/23_containers/priority_queue/lwg3529.cc: New test.

2 years agolibstdc++: Implement LWG 3522 for std::priority_queue
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3522 for std::priority_queue

The LWG 3522 issue constrains all constructors of container adaptors
that have InputIterator parameters.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h (priority_queue): Constrain
constructors with InputIterator parameters (LWG 3522).
* testsuite/23_containers/priority_queue/lwg3522.cc: New test.

2 years agolibstdc++: Implement LWG 3392 for std::ranges::distance
Jonathan Wakely [Tue, 1 Jun 2021 13:22:38 +0000 (14:22 +0100)]
libstdc++: Implement LWG 3392 for std::ranges::distance

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::distance): Split overload
into two (LWG 3392).
* testsuite/24_iterators/range_operations/lwg3392.cc: New test.

2 years agolibstdc++: Remove unary_function base classes from std::thread tests
Jonathan Wakely [Mon, 24 May 2021 17:32:22 +0000 (18:32 +0100)]
libstdc++: Remove unary_function base classes from std::thread tests

std::thread does not care if a function object is adaptable, so there is
no need to derive from the deprecated std::unary_function class in these
tests.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/30_threads/thread/cons/3.cc: Remove derivation from
std::unary_function.
* testsuite/30_threads/thread/cons/4.cc: Likewise.
* testsuite/30_threads/thread/cons/5.cc: Likewise.

2 years agolibstdc++: Remove useless base classes in pb_db tests
Jonathan Wakely [Mon, 24 May 2021 17:27:16 +0000 (18:27 +0100)]
libstdc++: Remove useless base classes in pb_db tests

These function objects do not need to be adaptable, so stop deriving
from deprecated classes. Also the 'inline' keyword is redundant on
member functions defined in the class body.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/ext/pb_ds/example/basic_multimap.cc: Remove
unnecesary derivation from std::unary_function.
* testsuite/ext/pb_ds/example/erase_if.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_illegal_resize.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_initial_size.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_load_set_change.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_mod.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_resize.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_shift_mask.cc: Likewise.
* testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc:
Likewise.
* testsuite/ext/pb_ds/example/ranged_hash.cc: Likewise.
* testsuite/ext/pb_ds/example/store_hash.cc: Likewise.

2 years agolibstdc++: Simplify __throw_out_of_range_fmt for freestanding
Jonathan Wakely [Thu, 20 May 2021 17:13:00 +0000 (18:13 +0100)]
libstdc++: Simplify __throw_out_of_range_fmt for freestanding

There is no point expanding the format string if we're just going to
abort instead of throw an exception. And for freestanding or non-verbose
builds we shouldn't do it either, to reduce the binary size.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* src/c++11/functexcept.cc (__throw_out_of_range_fmt): Do not
expand the format string for freestanding, or non-vebose, or if
we're just going to abort anyway.
* src/c++11/snprintf_lite.cc: Remove unused header and
declaration.

2 years agolibstdc++: Fix narrowing conversion in std::visit
Jonathan Wakely [Thu, 20 May 2021 17:04:16 +0000 (18:04 +0100)]
libstdc++: Fix narrowing conversion in std::visit

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/std/variant (__do_visit): Use variant_npos instead of
literal -1 that requires a narrowing conversion.

2 years agolibstdc++: Avoid unconditional use of errc::not_supported [PR 99327]
Jonathan Wakely [Tue, 11 May 2021 17:47:18 +0000 (18:47 +0100)]
libstdc++: Avoid unconditional use of errc::not_supported [PR 99327]

The errc::not_supported constant is only defined if ENOTSUP is defined,
which is not true for all targets. Many uses of errc::not_supported in
the filesystem library do not actually match the intended meaning of
ENOTSUP described by POSIX. They should be using ENOSYS instead
(i.e. errc::function_not_supported).

This change ensures that appropriate error codes are used by the
filesystem library. The remaining uses of errc::not_supported are
replaced with a call to a new helper function so that an alternative
value will be used on targets that don't support errc::not_supported.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/99327
* src/filesystem/ops-common.h (__unsupported): New function to
return a suitable error code for missing functionality.
(posix::off_t): New typedef.
(posix::*): Set errno to ENOSYS instead of ENOTSUP for no-op
fallback implementations.
(do_copy_file): Replace uses of errc::not_supported.
* src/c++17/fs_ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::hard_link_count)
(fs::last_write_time, fs::permissions, fs::read_symlink):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t.
* src/filesystem/ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::last_write_time)
(fs::permissions, fs::read_symlink, fs::system_complete):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t and enable unconditionally.
* testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.

2 years agolibstdc++: Add utility for creating std::error_code from OS errors
Jonathan Wakely [Wed, 10 Feb 2021 18:00:00 +0000 (18:00 +0000)]
libstdc++: Add utility for creating std::error_code from OS errors

This adds a helper function to encapsulate obtaining an error code for
errors from OS calls. For Windows we want to use GetLastError() and the
system error category, but otherwise just use errno and the generic
error category.

This should not be used to replace existing uses of
ec.assign(errno, generic_category()) because in those cases we really do
want to get the value of errno, not a system-specific error. Only the
cases that currently use GetLastError() are replace by this new
function.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* src/filesystem/ops-common.h (last_error): New helper function.
(filesystem::do_space): Use last_error().
* src/c++17/fs_ops.cc (fs::absolute, fs::create_hard_link)
(fs::equivalent, fs::remove, fs::temp_directory_path): Use
last_error().
* src/filesystem/ops.cc (fs::create_hard_link)
(fs::remove, fs::temp_directory_path): Likewise.

2 years agolibstdc++: Add std::__conditional_t alias template
Jonathan Wakely [Thu, 6 May 2021 15:26:21 +0000 (16:26 +0100)]
libstdc++: Add std::__conditional_t alias template

This change is inspired by the suggestion in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html

The new std::__conditional_t alias template is functionally equivalent
to std::conditional_t but should be more efficient to compile, due to
only ever instantiating two specializations (std::__conditional<true>
and std::__conditional<false>) rather than a new specialization for
every use of std::conditional.

The new alias template is also available in C++11, unlike the C++14
std::conditional_t alias.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/std/type_traits (__conditional): New class template
for internal uses of std::conditional.
(__conditional_t): New alias template to replace conditional_t.
(__and_, __or_, __result_of_memfun, __result_of_memobj): Use
__conditional_t instead of conditional::type.
* include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise.
* include/bits/hashtable.h (_Hashtable): Likewise.
* include/bits/hashtable_policy.h (_Node_iterator, _Insert_base)
(_Local_iterator): Likewise. Replace typedefs with
using-declarations.
* include/bits/move.h (move_if_noexcept): Use __conditional_t.
* include/bits/parse_numbers.h (_Select_int_base): Likewise.
* include/bits/ptr_traits.h (__make_not_void): Likewise.
* include/bits/ranges_algobase.h (__copy_or_move_backward)
(__copy_or_move): Likewise.
* include/bits/ranges_base.h (borrowed_iterator_t): Likewise.
* include/bits/ranges_util.h (borrowed_subrange_t): Likewise.
* include/bits/regex_compiler.h (_BracketMatcher): Use
__conditional_t. Replace typedefs with using-declarations.
* include/bits/shared_ptr_base.h (__shared_count): Use
__conditional_t.
* include/bits/stl_algobase.h (__copy_move, __copy_move_backward):
Likewise.
* include/bits/stl_iterator.h (__detail::__clamp_iter_cat)
(reverse_iterator::iterator_concept)
(__make_move_if_noexcept_iterator)
(iterator_traits<common_iterator<_It, _Sent>>)
(iterator_traits<counted_iterator<_It>>): Likewise.
* include/bits/stl_pair.h (_PCC, pair::operator=): Likewise.
* include/bits/stl_tree.h (_Rb_tree::insert_return_type)
(_Rb_tree::_M_clone_node): Likewise.
* include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)):
Likewise.
* include/bits/uses_allocator.h (__uses_alloc): Likewise.
(__is_uses_allocator_predicate): Likewise.
* include/debug/functions.h (__foreign_iterator_aux2): Likewise.
* include/experimental/any (any::_Manager, __any_caster):
Likewise.
* include/experimental/executor (async_completion): Likewise.
* include/experimental/functional (__boyer_moore_base_t):
Likewise.
* include/std/any (any::_Manager): Likewise.
* include/std/functional (__boyer_moore_base_t): Likewise.
* include/std/ranges (borrowed_iterator_t)
(borrowed_subrange_t, __detail::__maybe_present_t)
(__detail::__maybe_const_t, split_view): Likewise.
* include/std/tuple (__empty_not_final, tuple::operator=):
Likewise.
* include/std/variant (__detail::__variant::__get_t): Likewise.

2 years agolibstdc++: Optimize std::visit for the common case [PR 78113]
Jonathan Wakely [Tue, 4 May 2021 22:31:48 +0000 (23:31 +0100)]
libstdc++: Optimize std::visit for the common case [PR 78113]

GCC does not do a good job of optimizing the table of function pointers
used for variant visitation. This avoids using the table for the common
case of visiting a single variant with a small number of alternative
types. Instead we use:

  switch(v.index())
  {
  case 0: return visitor(get<0>(v));
  case 1: return visitor(get<1>(v));
  ...
  }

It's not quite that simple, because get<1>(v) is ill-formed if the
variant only has one alternative, and similarly for each get<N>.  We
need to ensure each case only applies the visitor if the index is in
range for the actual type we're dealing with, and tell the compiler that
the case is unreachable otherwise. We also need to invoke the visitor
via the __gen_vtable_impl::__visit_invoke function, to handle the raw
visitation cases used to implement std::variant assignments and
comparisons.

Because that gets quite verbose and repetitive, a macro is used to stamp
out the cases.

We also need to handle the valueless_by_exception case, but only for raw
visitation, because std::visit already checks for it before calling
__do_visit.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/78113
* include/std/variant (__do_visit): Use a switch when we have a
single variant with a small number of alternatives.

2 years agolibstdc++: Allow visiting inherited variants [PR 90943]
Jonathan Wakely [Mon, 19 Apr 2021 13:49:12 +0000 (14:49 +0100)]
libstdc++: Allow visiting inherited variants [PR 90943]

Implement the changes from P2162R2 (as a DR for C++17).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/90943
* include/std/variant (__cpp_lib_variant): Update value.
(__detail::__variant::__as): New helpers implementing the
as-variant exposition-only function templates.
(visit, visit<R>): Use __as to upcast the variant parameters.
* include/std/version (__cpp_lib_variant): Update value.
* testsuite/20_util/variant/visit_inherited.cc: New test.

2 years agolibstdc++: Simplify __normal_iterator converting constructor
Jonathan Wakely [Thu, 6 May 2021 12:44:36 +0000 (13:44 +0100)]
libstdc++: Simplify __normal_iterator converting constructor

This uses C++11 features to simplify the definition of the
__normal_iterator constructor that allows converting from iterator to
const_iterator. The previous definition relied on _Container::pointer
which is present in std::vector and std::basic_string, but is not
actually part of the container requirements.

Removing the use of _Container::pointer and defining it in terms of
is_convertible allows __normal_iterator to be used with new container
types which do not define a pointer member. Specifically, this will
allow it to be used in std::basic_stacktrace.

In theory this will enable some conversions which were not previously
permitted, for example __normal_iterator<volatile T*, vector<T>> can
now be converted to __normal_iterator<const volatile T*, vector<T>>.
In practice this doesn't matter because the library never uses such
types.  In any case, allowing those conversions is consistent with
the corresponding constructors of std::reverse_iterator and
std::move_iterator.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (__normal_iterator): Simplify
converting constructor and do not require _Container::pointer.

2 years agolibstdc++: Make move ctor noexcept for fully-dynamic string
Jonathan Wakely [Fri, 30 Apr 2021 14:04:34 +0000 (15:04 +0100)]
libstdc++: Make move ctor noexcept for fully-dynamic string

The move constructor for the "fully-dynamic" COW string is not noexcept,
because it allocates a new empty string rep for the moved-from string.
However, there is no need to do that, because the moved-from string does
not have to be left empty. Instead, implement move construction for the
fully-dynamic case as a reference count increment, so the string is
shared.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/cow_string.h [_GLIBCXX_FULLY_DYNAMIC_STRING]
(basic_string(basic_string&&)): Add noexcept and avoid
allocation, by sharing rep with the rvalue string.

2 years agolibstdc++: Add noexcept to common_iterator proxy operators
Jonathan Wakely [Fri, 30 Apr 2021 13:43:54 +0000 (14:43 +0100)]
libstdc++: Add noexcept to common_iterator proxy operators

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (common_iterator::__arrow_proxy)
(common_iterator::__postfix_proxy): Add noexcept.

2 years agolibstdc++: Use conditional noexcept in std::reverse_iterator [PR 94418]
Jonathan Wakely [Wed, 28 Apr 2021 10:40:47 +0000 (11:40 +0100)]
libstdc++: Use conditional noexcept in std::reverse_iterator [PR 94418]

This adds a noexcept-specifier to each constructor and assignment
operator of std::reverse_iterator so that they are noexcept when the
corresponding operation on the underlying iterator is noexcept.

The std::reverse_iterator class template already requires that the
operations on the underlying type are valid, so we don't need to use the
std::is_nothrow_xxx traits to protect against errors when the expression
isn't even valid. We can just use a noexcept operator to test if the
expression can throw, without the overhead of redundantly checking if
the initialization/assignment would be valid.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/94418
* include/bits/stl_iterator.h (reverse_iterator): Use
conditional noexcept on constructors and assignment operators.
* testsuite/24_iterators/reverse_iterator/noexcept.cc: New test.

2 years agolibstdc++: Do not allocate a zero-size vector<bool> [PR 100153]
Jonathan Wakely [Tue, 20 Apr 2021 15:16:13 +0000 (16:16 +0100)]
libstdc++: Do not allocate a zero-size vector<bool> [PR 100153]

The vector<bool>::shrink_to_fit() implementation will allocate new
storage even if the vector is empty. That then leads to the
end-of-storage pointer being non-null and equal to the _M_start._M_p
pointer, which means that _M_end_addr() has undefined behaviour.

The fix is to stop doing a useless zero-sized allocation in
shrink_to_fit(), so that _M_start._M_p and _M_end_of_storage are both
null after an empty vector shrinks.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/100153
* include/bits/vector.tcc (vector<bool>::_M_shrink_to_fit()):
When size() is zero just deallocate and reset.

2 years agolibstdc++: Implement std::clamp with std::min and std::max [PR 96733]
Jonathan Wakely [Sat, 17 Apr 2021 21:34:09 +0000 (22:34 +0100)]
libstdc++: Implement std::clamp with std::min and std::max [PR 96733]

The compiler doesn't know about the precondition of std::clamp that
(hi < lo) is false, and so can't optimize as well as we'd like. By using
std::min and std::max we help the compiler.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/96733
* include/bits/stl_algo.h (clamp): Use std::min and std::max.

2 years agoAdd/update libgomp.fortran/alloc-*.f90
Tobias Burnus [Fri, 1 Oct 2021 18:02:23 +0000 (20:02 +0200)]
Add/update libgomp.fortran/alloc-*.f90

libgomp/ChangeLog:

* testsuite/libgomp.fortran/alloc-10.f90: Fix alignment check.
* testsuite/libgomp.fortran/alloc-7.f90: Fix array access.
* testsuite/libgomp.fortran/alloc-8.f90: Likewise.
* testsuite/libgomp.fortran/alloc-11.f90: New test for omp_realloc,
based on libgomp.c-c++-common/alloc-9.c.

2 years agoEnhance -Waddress to detect more suspicious expressions [PR102103].
Martin Sebor [Fri, 1 Oct 2021 17:50:25 +0000 (11:50 -0600)]
Enhance -Waddress to detect more suspicious expressions [PR102103].

Resolves:
PR c/102103 - missing warning comparing array address to null

gcc/ChangeLog:

PR c/102103
* doc/invoke.texi (-Waddress): Update.
* gengtype.c (write_types): Avoid -Waddress.
* poly-int.h (POLY_SET_COEFF): Avoid using null.

gcc/c-family/ChangeLog:

PR c/102103
* c-common.c (decl_with_nonnull_addr_p): Handle members.
Check and perform warning suppression.
(c_common_truthvalue_conversion): Enhance warning suppression.

gcc/c/ChangeLog:

PR c/102103
* c-typeck.c (maybe_warn_for_null_address): New function.
(build_binary_op): Call it.

gcc/cp/ChangeLog:

PR c/102103
* typeck.c (warn_for_null_address): Enhance.
(cp_build_binary_op): Call it also for member pointers.

gcc/fortran/ChangeLog:

PR c/102103
* array.c: Remove an unnecessary test.
* trans-array.c: Same.

gcc/testsuite/ChangeLog:

PR c/102103
* g++.dg/cpp0x/constexpr-array-ptr10.C: Suppress a valid warning.
* g++.dg/warn/Wreturn-local-addr-6.C: Correct a cast.
* gcc.dg/Waddress.c: Expect a warning.
* c-c++-common/Waddress-3.c: New test.
* c-c++-common/Waddress-4.c: New test.
* g++.dg/warn/Waddress-5.C: New test.
* g++.dg/warn/Waddress-6.C: New test.
* g++.dg/warn/pr101219.C: Expect a warning.
* gcc.dg/Waddress-3.c: New test.

2 years agoDefault to dwarf version 4 on hppa64-hpux
John David Anglin [Fri, 1 Oct 2021 17:34:09 +0000 (17:34 +0000)]
Default to dwarf version 4 on hppa64-hpux

2021-10-01  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR debug/102373
* config/pa/pa.c (pa_option_override): Default to dwarf version 4
on hppa64-hpux.

2 years agolibiberty: testsuite: add missing format on d-demangle-expected
Luís Ferreira [Fri, 1 Oct 2021 17:26:48 +0000 (13:26 -0400)]
libiberty: testsuite: add missing format on d-demangle-expected

libiberty
* testsuite/d-demangle-expected: Add missing format for new test

2 years agolibsanitizer: Update LOCAL_PATCHES
H.J. Lu [Fri, 1 Oct 2021 16:04:28 +0000 (09:04 -0700)]
libsanitizer: Update LOCAL_PATCHES

* LOCAL_PATCHES: Update to the corresponding revision.

2 years agoUpdate c-c++-common/tsan/atomic_stack.c
H.J. Lu [Mon, 27 Sep 2021 23:25:52 +0000 (16:25 -0700)]
Update c-c++-common/tsan/atomic_stack.c

Print out from __tsan_atomic32_fetch_add was removed by

commit da7a5c09c86c3f639c63ce8843d6f21c915ae1c6
Author: Dmitry Vyukov <dvyukov@google.com>
Date:   Wed Jul 28 16:57:39 2021 +0200

    tsan: don't print __tsan_atomic* functions in report stacks

    Currently __tsan_atomic* functions do FuncEntry/Exit using caller PC
    and then use current PC (pointing to __tsan_atomic* itself) during
    memory access handling. As the result the top function in reports
    involving atomics is __tsan_atomic* and the next frame points to user code.

    Remove FuncEntry/Exit in atomic functions and use caller PC
    during memory access handling. This removes __tsan_atomic*
    from the top of report stacks, so that they point right to user code.

    The motivation for this is performance.
    Some atomic operations are very hot (mostly loads),
    so removing FuncEntry/Exit is beneficial.
    This also reduces thread trace consumption (1 event instead of 3).

    __tsan_atomic* at the top of the stack is not necessary
    and does not add any new information. We already say
    "atomic write of size 4", "__tsan_atomic32_store" does not add
    anything new.

    It also makes reports consistent between atomic and non-atomic
    accesses. For normal accesses we say "previous write" and point
    to user code; for atomics we say "previous atomic write" and now
    also point to user code.

    Reviewed By: vitalybuka

    Differential Revision: https://reviews.llvm.org/D106966

* c-c++-common/tsan/atomic_stack.c: Don't expect print out from
__tsan_atomic32_fetch_add.

2 years agolibsanitizer: Bump asan/tsan versions
H.J. Lu [Mon, 27 Sep 2021 23:11:49 +0000 (16:11 -0700)]
libsanitizer: Bump asan/tsan versions

Bump asan/tsan versions for upstream commits:

commit f1bb30a4956f83e46406d6082e5d376ce65391e0
Author: Vitaly Buka <vitalybuka@google.com>
Date:   Thu Aug 26 10:25:09 2021 -0700

    [sanitizer] No THREADLOCAL in qsort and bsearch

    qsort can reuse qsort_r if available.
    bsearch always passes key as the first comparator argument, so we
    can use it to wrap the original comparator.

    Differential Revision: https://reviews.llvm.org/D108751

commit d77b476c1953bcb0a608b2d6a4f2dd9fe0b43967
Author: Dmitry Vyukov <dvyukov@google.com>
Date:   Mon Aug 2 16:52:53 2021 +0200

    tsan: avoid extra call indirection in unaligned access functions

    Currently unaligned access functions are defined in tsan_interface.cpp
    and do a real call to MemoryAccess. This means we have a real call
    and no read/write constant propagation.

    Unaligned memory access can be quite hot for some programs
    (observed on some compression algorithms with ~90% of unaligned accesses).

    Move them to tsan_interface_inl.h to avoid the additional call
    and enable constant propagation.
    Also reorder the actual store and memory access handling for
    __sanitizer_unaligned_store callbacks to enable tail calling
    in MemoryAccess.

    Depends on D107282.

    Reviewed By: vitalybuka, melver

commit 97795be22f634667ce7a022398c59ccc9f7440eb
Author: Dmitry Vyukov <dvyukov@google.com>
Date:   Fri Jul 30 08:35:11 2021 +0200

    tsan: optimize test-only barrier

    The updated lots_of_threads.c test with 300 threads
    started running for too long on machines with low
    hardware parallelism (e.g. taskset -c 0-1).
    On lots of CPUs it finishes in ~2 secs. But with
    taskset -c 0-1 it runs for hundreds of seconds
    effectively spinning in the barrier in the sleep loop.

    We now have the handy futex API in sanitizer_common.
    Use it instead of the passive spin loop.
    It makes the test run only faster with taskset -c 0-1,
    it runs for ~1.5 secs, while with full parallelism
    it still runs for ~2 secs (but consumes less CPU time).

    Depends on D107131.

    Reviewed By: vitalybuka

2 years agolibsanitizer: Apply local patches
H.J. Lu [Tue, 20 Jul 2021 17:46:51 +0000 (10:46 -0700)]
libsanitizer: Apply local patches

2 years agolibsanitizer: Merge with upstream
H.J. Lu [Mon, 27 Sep 2021 17:43:33 +0000 (10:43 -0700)]
libsanitizer: Merge with upstream

Merged revision: 1c2e5fd66ea27d0c51360ba4e22099124a915562

2 years agoc++: cv-qualified ref introduced by typedef [PR101783]
qingzhe huang [Fri, 1 Oct 2021 14:46:35 +0000 (10:46 -0400)]
c++: cv-qualified ref introduced by typedef [PR101783]

The root cause of this bug is that it considers reference with
cv-qualifiers as an error by generating value for variable "bad_quals".
However, this is not correct for case of typedef. Here I quote spec
[dcl.ref]/1 :
"Cv-qualified references are ill-formed except when the cv-qualifiers
are introduced through the use of a typedef-name ([dcl.typedef],
[temp.param]) or decltype-specifier ([dcl.type.decltype]),
in which case the cv-qualifiers are ignored."

2021-09-30  qingzhe huang  <nickhuang99@hotmail.com>

gcc/cp/ChangeLog:
PR c++/101783
* tree.c (cp_build_qualified_type_real): Exclude typedef from
error.

gcc/testsuite/ChangeLog:
PR c++/101783
* g++.dg/parse/pr101783.C: New test.

2 years agolibstdc++: Define basic_regex::multiline for non-strict modes
Jonathan Wakely [Fri, 1 Oct 2021 13:06:42 +0000 (14:06 +0100)]
libstdc++: Define basic_regex::multiline for non-strict modes

The regex_constants::multiline constant is defined for non-strict C++11
and C++14 modes, on the basis that the feature is a DR (even though it
was really a new feature addition to C++17 and probably shouldn't have
gone through the issues list).

This makes the basic_regex::multiline constant defined consistently with
the regex_constants::multiline one.

For strict C++11 and C++14 mode we don't define them, because multiline
is not a reserved name in those standards.

libstdc++-v3/ChangeLog:

* include/bits/regex.h (basic_regex::multiline): Define for
non-strict C++11 and C++14 modes.
* include/bits/regex_constants.h (regex_constants::multiline):
Add _GLIBCXX_RESOLVE_LIB_DEFECTS comment.

2 years agolibstdc++: Add missing header to test
Jonathan Wakely [Fri, 1 Oct 2021 11:55:53 +0000 (12:55 +0100)]
libstdc++: Add missing header to test

We need to include <iterator> (or one of the containers) to get a
definition for std::begin.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/is_permutation/2.cc: Include <iterator>.

2 years agolibstdc++: Add noexcept to istream_iterator and ostream_iterator
Jonathan Wakely [Thu, 30 Sep 2021 13:39:36 +0000 (14:39 +0100)]
libstdc++: Add noexcept to istream_iterator and ostream_iterator

libstdc++-v3/ChangeLog:

* include/bits/stream_iterator.h (istream_iterator): Add
noexcept to constructors and non-throwing member functions and
friend functions.
(ostream_iterator): Likewise.

2 years agolibstdc++: Fix _ForwardIteratorConcept for __gnu_debug::vector<bool>
Jonathan Wakely [Thu, 30 Sep 2021 10:25:15 +0000 (11:25 +0100)]
libstdc++: Fix _ForwardIteratorConcept for __gnu_debug::vector<bool>

The recent changes to the _GLIBCXX_CONCEPT_CHECKS checks for forward
iterators don't work for vector<bool> iterators in debug mode, because
the _Safe_iterator specializations don't match the special cases I added
for _Bit_iterator and _Bit_const_iterator.

This refactors the _ForwardIteratorReferenceConcept class template to
identify vector<bool> iterators using a new trait, which also works for
debug iterators.

libstdc++-v3/ChangeLog:

* include/bits/boost_concept_check.h (_Is_vector_bool_iterator):
New trait to identify vector<bool> iterators, including debug
ones.
(_ForwardIteratorReferenceConcept): Add default template
argument using _Is_vector_bool_iterator and use it in partial
specialization for the vector<bool> cases.
(_Mutable_ForwardIteratorReferenceConcept): Likewise.
* testsuite/24_iterators/operations/prev_neg.cc: Adjust dg-error
line number.

2 years agolibstdc++: Replace try-catch in std::list::merge to avoid O(N) size
Jonathan Wakely [Wed, 29 Sep 2021 19:46:55 +0000 (20:46 +0100)]
libstdc++: Replace try-catch in std::list::merge to avoid O(N) size

The current std::list::merge code calls size() before starting to merge
any elements, so that the _M_size members can be updated after the merge
finishes. The work is done in a try-block so that the sizes can still be
updated in an exception handler if any element comparison throws.

The _M_size members only exist for the cxx11 ABI, so the initial call to
size() and the try-catch are only needed for that ABI. For the old ABI
the size() call performs an O(N) list traversal to get a value that
isn't even used, and catching exceptions just to rethrow them isn't
needed either.

This refactors the merge functions to remove the try-catch block and use
an RAII type instead. For the cxx11 ABI that type's destructor updates
the list sizes, and for the old ABI it's a no-op.

libstdc++-v3/ChangeLog:

* include/bits/list.tcc (list::merge): Remove call to size() and
try-catch block. Use _Finalize_merge instead.
* include/bits/stl_list.h (list::_Finalize_merge): New
scope guard type to update _M_size members after a merge.

2 years agooptions: fix concat of options.
Martin Liska [Fri, 1 Oct 2021 13:37:59 +0000 (15:37 +0200)]
options: fix concat of options.

PR target/102552

gcc/c-family/ChangeLog:

* c-common.c (parse_optimize_options): decoded_options[0] is
  used for program name, so merged_decoded_options should also
  respect that.

2 years agoaarch64: fix AARCH64_FL_V9 flag value
Przemyslaw Wirkus [Fri, 1 Oct 2021 12:49:51 +0000 (13:49 +0100)]
aarch64: fix AARCH64_FL_V9 flag value

Patch is fixing AARCH64_FL_V9 flag value which is now wrongly set due to
merge error.

gcc/ChangeLog:

* config/aarch64/aarch64.h (AARCH64_FL_V9): Update value.

2 years agoRemove shadowed oracle field.
Aldy Hernandez [Fri, 1 Oct 2021 10:27:55 +0000 (12:27 +0200)]
Remove shadowed oracle field.

The m_oracle field in the path solver was shadowing the base class.
This was causing subtle problems while calculating outgoing edges
between blocks, because the query object being passed did not have an
oracle set.

This should further improve our solving ability.

Tested on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-path.cc (path_range_query::compute_ranges): Use
get_path_oracle.
* gimple-range-path.h (class path_range_query): Remove shadowed
m_oracle field.
(path_range_query::get_path_oracle): New.

2 years agoubsan: Move INT_MIN / -1 instrumentation from -fsanitize=integer-divide-by-zero to...
Jakub Jelinek [Fri, 1 Oct 2021 12:27:32 +0000 (14:27 +0200)]
ubsan: Move INT_MIN / -1 instrumentation from -fsanitize=integer-divide-by-zero to -fsanitize=signed-integer-overflow [PR102515]

As noted by Richi, in clang INT_MIN / -1 is instrumented under
-fsanitize=signed-integer-overflow rather than
-fsanitize=integer-divide-by-zero as we did and doing it in the former
makes more sense, as it is overflow during division rather than division
by zero.
I've verified on godbolt that clang behaved that way since 3.2-ish times or
so when sanitizers were added.
Furthermore, we've been using
-f{,no-}sanitize-recover=integer-divide-by-zero to decide on the float
-fsanitize=float-divide-by-zero instrumentation _abort suffix.
The case where INT_MIN / -1 is instrumented by one sanitizer and
x / 0 by another one when both are enabled is slightly harder if
the -f{,no-}sanitize-recover={integer-divide-by-zero,signed-integer-overflow}
flags differ, then we need to emit both __ubsan_handle_divrem_overflow
and __ubsan_handle_divrem_overflow_abort calls guarded by their respective
checks rather than one guarded by check1 || check2.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>
    Richard Biener  <rguenther@suse.de>

PR sanitizer/102515
gcc/
* doc/invoke.texi (-fsanitize=integer-divide-by-zero): Remove
INT_MIN / -1 division detection from here ...
(-fsanitize=signed-integer-overflow): ... and add it here.
gcc/c-family/
* c-ubsan.c (ubsan_instrument_division): Check the right
flag_sanitize_recover bit, depending on which sanitization
is done.  Sanitize INT_MIN / -1 under SANITIZE_SI_OVERFLOW
rather than SANITIZE_DIVIDE.  If both SANITIZE_SI_OVERFLOW
and SANITIZE_DIVIDE is enabled, neither check is known
to be false and flag_sanitize_recover bits for those two
aren't the same, emit both __ubsan_handle_divrem_overflow
and __ubsan_handle_divrem_overflow_abort calls.
gcc/c/
* c-typeck.c (build_binary_op): Call ubsan_instrument_division
for division even for SANITIZE_SI_OVERFLOW.
gcc/cp/
* typeck.c (cp_build_binary_op): Call ubsan_instrument_division
for division even for SANITIZE_SI_OVERFLOW.
gcc/testsuite/
* c-c++-common/ubsan/div-by-zero-3.c: Use
-fsanitize=signed-integer-overflow instead of
-fsanitize=integer-divide-by-zero.
* c-c++-common/ubsan/div-by-zero-5.c: Likewise.
* c-c++-common/ubsan/div-by-zero-4.c: Likewise.  Add
-fsanitize-undefined-trap-on-error.
* c-c++-common/ubsan/float-div-by-zero-2.c: New test.
* c-c++-common/ubsan/overflow-div-1.c: New test.
* c-c++-common/ubsan/overflow-div-2.c: New test.
* c-c++-common/ubsan/overflow-div-3.c: New test.

2 years agoaarch64: Fix cpymem-size.c test for ILP32
Kyrylo Tkachov [Fri, 1 Oct 2021 11:19:42 +0000 (12:19 +0100)]
aarch64: Fix cpymem-size.c test for ILP32

gcc/testsuite/

* gcc.target/aarch64/cpymem-size.c: Adjust scan for ilp32.

2 years agoaarch64: add armv9-a to -march
Przemyslaw Wirkus [Fri, 1 Oct 2021 09:06:45 +0000 (10:06 +0100)]
aarch64: add armv9-a to -march

gcc/ChangeLog:

* config/aarch64/aarch64-arches.def (AARCH64_ARCH): Added
armv9-a.
* config/aarch64/aarch64.h (AARCH64_FL_V9): New.
(AARCH64_FL_FOR_ARCH9): New flags for Armv9-A.
(AARCH64_ISA_V9): New ISA flag.
* doc/invoke.texi: Update docs.

2 years agoFix bb-slp-pr97709.c after computed goto change
Andrew Pinski [Fri, 1 Oct 2021 09:23:47 +0000 (09:23 +0000)]
Fix bb-slp-pr97709.c after computed goto change

Looks like I tested the change for bb-slp-pr97709.c on an
older tree which did not have the error message so I had
missed one more place where the change was needed.

Anyways committed after testing to make sure the testcase passes
now.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/bb-slp-pr97709.c: Fix for computed goto
pointers.

2 years agoAppend target/optimize attr to the current cmdline.
Martin Liska [Wed, 2 Jun 2021 06:44:37 +0000 (08:44 +0200)]
Append target/optimize attr to the current cmdline.

gcc/c-family/ChangeLog:

* c-common.c (parse_optimize_options): Combine optimize
options with what was provided on the command line.

gcc/ChangeLog:

* toplev.c (toplev::main): Save decoded optimization options.
* toplev.h (save_opt_decoded_options): New.
* doc/extend.texi: Be more clear about optimize and target
attributes.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512er-vrsqrt28ps-3.c: Disable fast math.
* gcc.target/i386/avx512er-vrsqrt28ps-5.c: Likewise.
* gcc.target/i386/attr-optimize.c: New test.

2 years agoFix ICE with stack checking emulation at -O2
Eric Botcazou [Fri, 1 Oct 2021 08:56:45 +0000 (10:56 +0200)]
Fix ICE with stack checking emulation at -O2

On bare-metal platforms, the Ada compiler emulates stack checking (it is
required by the language and tested by ACATS) in the runtime via the
stack_check_libfunc hook of the RTL middle-end.  Calls to the function
are generated as libcalls but they now require a proper function type
at -O2 or above.

gcc/
* explow.c: Include langhooks.h.
(set_stack_check_libfunc): Build a proper function type.

2 years agoFix PR c++/64697 at -O1 or above
Eric Botcazou [Fri, 1 Oct 2021 08:49:34 +0000 (10:49 +0200)]
Fix PR c++/64697 at -O1 or above

The BFD fix eliminates the link failure and working code is generated at
-O0, but _not_ when optimization is enabled because the optimizer changes:

        movq    .refptr._ZTH1s(%rip), %rax
        testq   %rax, %rax
        je      .L2
        call    _ZTH1s

into:

        leaq    _ZTH1s(%rip), %rax
        testq   %rax, %rax
        je      .L2
        call    _ZTH1s

and the leaq now also gets the relocation overflow.  So the fix is to
teach legitimate_pic_address_disp_p to reject the transformation when
the symbol is an external weak function, which yields:

        cmpq    $0, .refptr._ZTH1s(%rip)
        je      .L2
        call    _ZTH1s

and the cmpq keeps a relocation that does not overflow.

gcc/
PR c++/64697
* config/i386/i386.c (legitimate_pic_address_disp_p): For PE-COFF do
not return true for external weak function symbols in medium model.

2 years agoopenmp: Differentiate between order(concurrent) and order(reproducible:concurrent)
Jakub Jelinek [Fri, 1 Oct 2021 08:45:48 +0000 (10:45 +0200)]
openmp: Differentiate between order(concurrent) and order(reproducible:concurrent)

While OpenMP 5.1 implies order(concurrent) is the same thing as
order(reproducible:concurrent), this is going to change in OpenMP 5.2, where
essentially order(concurrent) means nothing is stated on whether it is
reproducible or unconstrained (and is determined by other means, e.g. for/do
with schedule static or runtime with static being selected is implicitly
reproducible, distribute with dist_schedule static is implicitly reproducible,
loop is implicitly reproducible) and when the modifier is specified explicitly,
it overrides the implicit behavior either way.
And, when order(reproducible:concurrent) is used with e.g. schedule(dynamic)
or some other schedule that is by definition not reproducible, it is
implementation's duty to ensure it is reproducible, either by remembering how
it scheduled some loop and then replaying the same schedule when seeing loops
with the same directive/schedule/number of iterations, or by overriding the
schedule to some reproducible one.

This patch doesn't implement the 5.2 wording just yet, but in the FEs
differentiates between the 3 states - no explicit modifier, explicit reproducible
or explicit unconstrainted, so that the middle-end can easily switch any time.
Instead it follows the 5.1 wording where both order(concurrent) (implicit or
explicit) or order(reproducible:concurrent) imply reproducibility.
And, it implements the easier method, when for/do should be reproducible, it
just chooses static schedule.  order(concurrent) implies no OpenMP APIs in the
loop body nor threadprivate vars, so the exact scheduling isn't (easily at least)
observable.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree.h (OMP_CLAUSE_ORDER_REPRODUCIBLE): Define.
* tree-pretty-print.c (dump_omp_clause) <case OMP_CLAUSE_ORDER>: Print
reproducible: for OMP_CLAUSE_ORDER_REPRODUCIBLE.
* omp-general.c (omp_extract_for_data): If OMP_CLAUSE_ORDER is seen
without OMP_CLAUSE_ORDER_UNCONSTRAINED, overwrite sched_kind to
OMP_CLAUSE_SCHEDULE_STATIC.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Also copy
OMP_CLAUSE_ORDER_REPRODUCIBLE.
gcc/c/
* c-parser.c (c_parser_omp_clause_order): Set
OMP_CLAUSE_ORDER_REPRODUCIBLE for explicit reproducible: modifier.
gcc/cp/
* parser.c (cp_parser_omp_clause_order): Set
OMP_CLAUSE_ORDER_REPRODUCIBLE for explicit reproducible: modifier.
gcc/fortran/
* gfortran.h (gfc_omp_clauses): Add order_reproducible bitfield.
* dump-parse-tree.c (show_omp_clauses): Print REPRODUCIBLE: for it.
* openmp.c (gfc_match_omp_clauses): Set order_reproducible for
explicit reproducible: modifier.
* trans-openmp.c (gfc_trans_omp_clauses): Set
OMP_CLAUSE_ORDER_REPRODUCIBLE for order_reproducible.
(gfc_split_omp_clauses): Also copy order_reproducible.
gcc/testsuite/
* gfortran.dg/gomp/order-5.f90: Adjust scan-tree-dump-times regexps.
libgomp/
* testsuite/libgomp.c-c++-common/order-reproducible-1.c: New test.
* testsuite/libgomp.c-c++-common/order-reproducible-2.c: New test.

2 years agoopenmp: Avoid PLT relocations for omp_* symbols in libgomp
Jakub Jelinek [Fri, 1 Oct 2021 08:42:07 +0000 (10:42 +0200)]
openmp: Avoid PLT relocations for omp_* symbols in libgomp

This patch avoids the following relocations:
readelf -Wr libgomp.so.1.0.0 | grep omp_
00000000000470e0  0000020700000007 R_X86_64_JUMP_SLOT     000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0
0000000000047170  000000b800000007 R_X86_64_JUMP_SLOT     000000000000e760 omp_display_env@@OMP_5.1 + 0
00000000000471e0  000000e800000007 R_X86_64_JUMP_SLOT     000000000000f910 omp_get_initial_device@@OMP_4.5 + 0
0000000000047280  0000019500000007 R_X86_64_JUMP_SLOT     0000000000015940 omp_get_active_level@@OMP_3.0 + 0
00000000000472c8  0000020d00000007 R_X86_64_JUMP_SLOT     0000000000035210 omp_get_team_num@@OMP_4.0 + 0
00000000000472f0  0000014700000007 R_X86_64_JUMP_SLOT     0000000000035200 omp_get_num_teams@@OMP_4.0 + 0
by using ialias{,_call,_redirect} macros as needed.

We still have many acc_* PLT relocations, could somebody please fix those?
readelf -Wr libgomp.so.1.0.0 | grep acc_
0000000000046fb8  000001ed00000006 R_X86_64_GLOB_DAT      0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0
0000000000046fd8  000000a400000006 R_X86_64_GLOB_DAT      0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0
0000000000046fe0  000001d100000006 R_X86_64_GLOB_DAT      0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0
0000000000047058  000001dd00000007 R_X86_64_JUMP_SLOT     0000000000031f40 acc_create_async@@OACC_2.5 + 0
0000000000047068  0000011500000007 R_X86_64_JUMP_SLOT     000000000002fc60 acc_get_property@@OACC_2.6 + 0
0000000000047070  000001fb00000007 R_X86_64_JUMP_SLOT     0000000000032ce0 acc_wait_all@@OACC_2.0 + 0
0000000000047080  0000006500000007 R_X86_64_JUMP_SLOT     000000000002f990 acc_on_device@@OACC_2.0 + 0
0000000000047088  000000ae00000007 R_X86_64_JUMP_SLOT     0000000000032140 acc_attach_async@@OACC_2.6 + 0
0000000000047090  0000021900000007 R_X86_64_JUMP_SLOT     000000000002f550 acc_get_device_type@@OACC_2.0 + 0
0000000000047098  000001cb00000007 R_X86_64_JUMP_SLOT     0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0
00000000000470a8  0000005200000007 R_X86_64_JUMP_SLOT     0000000000031f80 acc_copyin@@OACC_2.0 + 0
00000000000470b8  000001ad00000007 R_X86_64_JUMP_SLOT     0000000000032030 acc_delete_finalize@@OACC_2.5 + 0
00000000000470e8  0000010900000007 R_X86_64_JUMP_SLOT     0000000000031f00 acc_create@@OACC_2.0 + 0
00000000000470f8  0000005900000007 R_X86_64_JUMP_SLOT     0000000000032b70 acc_wait_async@@OACC_2.0 + 0
0000000000047110  0000013100000007 R_X86_64_JUMP_SLOT     0000000000032860 acc_async_test@@OACC_2.0 + 0
0000000000047118  000001ff00000007 R_X86_64_JUMP_SLOT     000000000002f720 acc_get_device_num@@OACC_2.0 + 0
0000000000047128  0000019100000007 R_X86_64_JUMP_SLOT     0000000000032020 acc_delete_async@@OACC_2.5 + 0
0000000000047130  000001d200000007 R_X86_64_JUMP_SLOT     000000000002efa0 acc_shutdown@@OACC_2.0 + 0
0000000000047150  000000d000000007 R_X86_64_JUMP_SLOT     0000000000031f00 acc_present_or_create@@OACC_2.0 + 0
0000000000047188  0000019200000007 R_X86_64_JUMP_SLOT     0000000000031910 acc_is_present@@OACC_2.0 + 0
0000000000047190  000001aa00000007 R_X86_64_JUMP_SLOT     000000000002fca0 acc_get_property_string@@OACC_2.6 + 0
00000000000471d0  000001bf00000007 R_X86_64_JUMP_SLOT     0000000000032120 acc_update_self_async@@OACC_2.5 + 0
0000000000047200  0000020500000007 R_X86_64_JUMP_SLOT     0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0
0000000000047208  000000a600000007 R_X86_64_JUMP_SLOT     0000000000031790 acc_deviceptr@@OACC_2.0 + 0
0000000000047218  0000007500000007 R_X86_64_JUMP_SLOT     0000000000032000 acc_delete@@OACC_2.0 + 0
0000000000047238  000001e900000007 R_X86_64_JUMP_SLOT     000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0
0000000000047240  000001f600000007 R_X86_64_JUMP_SLOT     000000000002ef20 acc_init@@OACC_2.0 + 0
0000000000047248  0000018800000007 R_X86_64_JUMP_SLOT     0000000000032060 acc_copyout@@OACC_2.0 + 0
0000000000047258  0000021f00000007 R_X86_64_JUMP_SLOT     0000000000032a80 acc_wait@@OACC_2.0 + 0
0000000000047270  000001bc00000007 R_X86_64_JUMP_SLOT     0000000000032100 acc_update_self@@OACC_2.0 + 0
0000000000047288  0000011400000007 R_X86_64_JUMP_SLOT     0000000000032080 acc_copyout_async@@OACC_2.5 + 0
0000000000047290  0000013d00000007 R_X86_64_JUMP_SLOT     000000000002f850 acc_set_device_num@@OACC_2.0 + 0
00000000000472a8  000000c500000007 R_X86_64_JUMP_SLOT     00000000000320e0 acc_update_device_async@@OACC_2.5 + 0
00000000000472c0  0000014600000007 R_X86_64_JUMP_SLOT     0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0
00000000000472f8  0000006a00000007 R_X86_64_JUMP_SLOT     000000000002f310 acc_get_num_devices@@OACC_2.0 + 0
0000000000047350  0000021700000007 R_X86_64_JUMP_SLOT     0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0
0000000000047360  0000020900000007 R_X86_64_JUMP_SLOT     00000000000320c0 acc_update_device@@OACC_2.0 + 0
0000000000047380  0000008400000007 R_X86_64_JUMP_SLOT     0000000000032950 acc_async_test_all@@OACC_2.0 + 0

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

* affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add
ialias_redirect.
* env.c (handle_omp_display_env): Use ialias_call.
* icv-device.c: Move ialias right below each function.
(omp_get_device_num): Use ialias_call.
* fortran.c (omp_fulfill_event): Add ialias_redirect.
* icv.c (omp_get_active_level): Add ialias_redirect.

2 years agoopenmp: Add alloc_align attribute to omp_aligned_*alloc and testcase for omp_realloc
Jakub Jelinek [Fri, 1 Oct 2021 08:32:10 +0000 (10:32 +0200)]
openmp: Add alloc_align attribute to omp_aligned_*alloc and testcase for omp_realloc

This patch adds alloc_align attribute to omp_aligned_{,c}alloc so that if
the first argument is constant, GCC can assume requested alignment.

Additionally, it adds testsuite coverage for omp_realloc which I haven't
managed to write in the patch from yesterday.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

* omp.h.in (omp_aligned_alloc, omp_aligned_calloc): Add
__alloc_align__ (1) attribute.
* testsuite/libgomp.c-c++-common/alloc-9.c: New test.

2 years agoc++: Fix handling of __thread/thread_local extern vars declared at function scope...
Jakub Jelinek [Fri, 1 Oct 2021 08:30:16 +0000 (10:30 +0200)]
c++: Fix handling of __thread/thread_local extern vars declared at function scope [PR102496]

The introduction of push_local_extern_decl_alias in
r11-3699-g4e62aca0e0520e4ed2532f2d8153581190621c1a
broke tls vars, while the decl they are created for has the tls model
set properly, nothing sets it for the alias that is actually used,
so accesses to it are done as if they were normal variables.
This is then diagnosed at link time if the definition of the extern
vars is __thread/thread_local.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/102496
* name-lookup.c (push_local_extern_decl_alias): Return early even for
tls vars with non-dependent type when processing_template_decl.  For
CP_DECL_THREAD_LOCAL_P vars call set_decl_tls_model on alias.

* g++.dg/tls/pr102496-1.C: New test.
* g++.dg/tls/pr102496-2.C: New test.

2 years agomiddle-end/102518 - avoid invalid GIMPLE during inlining
Richard Biener [Thu, 30 Sep 2021 13:05:53 +0000 (15:05 +0200)]
middle-end/102518 - avoid invalid GIMPLE during inlining

When inlining we have to avoid mapping a non-lvalue parameter
value into a context that prevents the parameter to be a register.
Formerly the register were TREE_ADDRESSABLE but now it can be
just DECL_NOT_GIMPLE_REG_P.

2021-09-30  Richard Biener  <rguenther@suse.de>

PR middle-end/102518
* tree-inline.c (setup_one_parameter): Avoid substituting
an invariant into contexts where a GIMPLE register is not valid.

* gcc.dg/torture/pr102518.c: New testcase.

2 years ago[Ada] Subprogram_Variant in ignored ghost code
Bob Duff [Tue, 17 Aug 2021 15:02:51 +0000 (11:02 -0400)]
[Ada] Subprogram_Variant in ignored ghost code

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Do not call
Check_Subprogram_Variant if the subprogram is an ignored ghost
entity. Otherwise the compiler crashes (in debug builds) or
gives strange error messages (in production builds).

2 years ago[Ada] Empty CUDA_Global procedures when compiling for host
Ghjuvan Lacambre [Mon, 16 Aug 2021 13:28:09 +0000 (15:28 +0200)]
[Ada] Empty CUDA_Global procedures when compiling for host

gcc/ada/

* gnat_cuda.adb (Empty_CUDA_Global_Subprograms): New procedure.
(Expand_CUDA_Package): Call Empty_CUDA_Global_Subprograms.

2 years ago[Ada] Improved checking for invalid index values when accessing array elements
Steve Baird [Thu, 12 Aug 2021 23:55:36 +0000 (16:55 -0700)]
[Ada] Improved checking for invalid index values when accessing array elements

gcc/ada/

* checks.ads: Define a type Dimension_Set. Add an out-mode
parameter of this new type to Generate_Index_Checks so that
callers can know for which dimensions a check was generated. Add
an in-mode parameter of this new type to
Apply_Subscript_Validity_Checks so that callers can indicate
that no check is needed for certain dimensions.
* checks.adb (Generate_Index_Checks): Implement new
Checks_Generated parameter.
(Apply_Subscript_Validity_Checks): Implement new No_Check_Needed
parameter.
* exp_ch4.adb (Expand_N_Indexed_Component): Call
Apply_Subscript_Validity_Checks in more cases than before. This
includes declaring two new local functions,
(Is_Renamed_Variable_Name,
Type_Requires_Subscript_Validity_Checks_For_Reads): To help in
deciding whether to call Apply_Subscript_Validity_Checks.
Adjust to parameter profile changes in Generate_Index_Checks and
Apply_Subscript_Validity_Checks.

2 years ago[Ada] Document rounding mode assumed for dynamic floating-point computations
Eric Botcazou [Fri, 13 Aug 2021 16:32:53 +0000 (18:32 +0200)]
[Ada] Document rounding mode assumed for dynamic floating-point computations

gcc/ada/

* doc/gnat_rm/implementation_defined_characteristics.rst: Document
the rounding mode assumed for dynamic computations as per 3.5.7(16).
* gnat_rm.texi: Regenerate.

2 years ago[Ada] More work on efficiency improvements
Bob Duff [Thu, 12 Aug 2021 20:49:16 +0000 (16:49 -0400)]
[Ada] More work on efficiency improvements

gcc/ada/

* table.ads (Table_Type): Remove "aliased"; no longer needed by
Atree.  Besides it contradicted the comment a few lines above,
"--  Note: We do not make the table components aliased...".
* types.ads: Move type Slot to Atree.
* atree.ads: Move type Slot fromt Types to here.  Move type
Node_Header from Seinfo to here.
* atree.adb: Avoid the need for aliased components of the Slots
table.  Instead of 'Access, use a getter and setter.  Misc
cleanups.
(Print_Statistics): Print statistics about node and entity kind
frequencies. Give 3 digit fractions instead of percentages.
* (Get_Original_Node_Count, Set_Original_Node_Count): Statistics
for calls to Original_Node and Set_Original_Node.
(Original_Node, Set_Original_Node): Gather statistics by calling
the above.
(Print_Field_Statistics): Print Original_Node statistics.
(Update_Kind_Statistics): Remove, and put all statistics
gathering under "if Atree_Statistics_Enabled", which is a flag
generated in Seinfo by Gen_IL.
* gen_il-gen.adb (Compute_Field_Offsets): Choose offsets of
Nkind, Ekind, and Homonym first. This causes a slight efficiency
improvement.  Misc cleanups.  Do not generate Node_Header; it is
now hand-written in Atree.  When choosing the order in which to
assign offsets, weight by the frequency of the node type, so the
more common nodes get their field offsets assigned earlier.  Add
more special cases.
(Compute_Type_Sizes): Remove this and related things.
There was a comment: "At some point we can instrument Atree to
print out accurate size statistics, and remove this code." We
have Atree statistics, so we now remove this code.
(Put_Seinfo): Generate Atree_Statistics_Enabled, which is equal
to Statistics_Enabled. This allows Atree to say "if
Atree_Statistics_Enabled then <gather statistics>" for
efficiency. When Atree_Statistics_Enabled is False, the "if ..."
will be optimized away.
* gen_il-internals.ads (Type_Frequency): New table of kind
frequencies.
* gen_il-internals.adb: Minor comment improvement.
* gen_il-fields.ads: Remove unused subtypes.  Suppress style
checks in the Type_Frequency table.  If we regenerate this
table (see -gnatd.A) we don't want to have to fiddle with
casing.
* impunit.adb: Minor.
* sinfo-utils.adb: Minor.
* debug.adb: Minor comment improvement.

2 years ago[Ada] Add missing guard before call to Interface_Present_In_Ancestor
Eric Botcazou [Thu, 12 Aug 2021 16:12:40 +0000 (18:12 +0200)]
[Ada] Add missing guard before call to Interface_Present_In_Ancestor

gcc/ada/

* sem_type.adb (Specific_Type): Check that the type is tagged
before calling Interface_Present_In_Ancestor on it.

2 years ago[Ada] Add new debug switch -gnatd.8
Eric Botcazou [Thu, 12 Aug 2021 19:45:33 +0000 (21:45 +0200)]
[Ada] Add new debug switch -gnatd.8

gcc/ada/

* debug.adb (d.8): Document usage.
* fe.h (Debug_Flag_Dot_8): Declare.

2 years ago[Ada] Spurious warning about hiding in generic instantiation
Gary Dismukes [Wed, 11 Aug 2021 22:41:28 +0000 (18:41 -0400)]
[Ada] Spurious warning about hiding in generic instantiation

gcc/ada/

* sem_util.adb (Enter_Name): Suppress hiding warning when in an
instance.

2 years ago[Ada] Crash on improper use of GNAT attribute Type_Key
Ed Schonberg [Thu, 12 Aug 2021 14:39:21 +0000 (10:39 -0400)]
[Ada] Crash on improper use of GNAT attribute Type_Key

gcc/ada/

* sem_attr.adb (Analyze_Attribute, case Type_Key): Attribute can
be applied to a formal type.
* sem_ch5.adb (Analyze_Case_Statement): If Extensions_Allowed is
not enabled, verify that the type of the expression is discrete.

2 years ago[Ada] Crash on renaming within declare expression
Justin Squirek [Thu, 12 Aug 2021 12:54:15 +0000 (08:54 -0400)]
[Ada] Crash on renaming within declare expression

gcc/ada/

* exp_dbug.adb (Debug_Renaming_Declaration): Add check for
Entity present for Ren to prevent looking at unanalyzed nodes

2 years ago[Ada] Fix CodePeer warnings
Ghjuvan Lacambre [Thu, 12 Aug 2021 13:05:23 +0000 (15:05 +0200)]
[Ada] Fix CodePeer warnings

gcc/ada/

* atree.adb (Print_Statistics): Help CodePeer see Total as
greater than zero.
* gen_il-gen.adb (One_Comp): Annotate Field_Table as Modified.