Commit graph

200854 commits

Author SHA1 Message Date
Pan Li
e0f2f47117 RISC-V: Support RVV VREINTERPRET from v{u}int*_t to vbool1_t
This patch support the RVV VREINTERPRET from the int to the vbool1_t.  Aka:

vbool1_t __riscv_vreinterpret_xx_xx(v{u}int[8|16|32|64]_t);

These APIs help the users to convert vector LMUL=1 integer to vbool1_t.
According to the RVV intrinsic SPEC as below, the reinterpret intrinsics
only change the types of the underlying contents.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1

For example, given below code.
vbool1_t test_vreinterpret_v_i8m1_b1(vint8m1_t src) {
  return __riscv_vreinterpret_v_i8m1_b1(src);
}

It will generate the assembly code similar as below:
vsetvli a5,zero,e8,m8,ta,ma
vlm.v   v1,0(a1)
vsm.v   v1,0(a0)
ret

The rest intrinsic bool size APIs will be prepared in other PATCH.

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/ChangeLog:

	* config/riscv/genrvv-type-indexer.cc (BOOL_SIZE_LIST): New
	macro.
	(main): Add bool1 to the type indexer.
	* config/riscv/riscv-vector-builtins-functions.def
	(vreinterpret): Register vbool1 interpret function.
	* config/riscv/riscv-vector-builtins-types.def
	(DEF_RVV_BOOL1_INTERPRET_OPS): New macro.
	(vint8m1_t): Add the type to bool1_interpret_ops.
	(vint16m1_t): Ditto.
	(vint32m1_t): Ditto.
	(vint64m1_t): Ditto.
	(vuint8m1_t): Ditto.
	(vuint16m1_t): Ditto.
	(vuint32m1_t): Ditto.
	(vuint64m1_t): Ditto.
	* config/riscv/riscv-vector-builtins.cc
	(DEF_RVV_BOOL1_INTERPRET_OPS): New macro.
	(required_extensions_p): Add bool1 interpret case.
	* config/riscv/riscv-vector-builtins.def
	(bool1_interpret): Add bool1 interpret to base type.
	* config/riscv/vector.md (@vreinterpret<mode>): Add new expand
	with VB dest for vreinterpret.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: New test.
2023-05-17 15:13:37 +08:00
Eugene Rozenfeld
d709841ae0 Disable warnings as errors for STAGEautofeedback.
Compilation during STAGEautofeedback produces additional warnings
since inlining decisions with -fauto-profile are different from
other builds.

This patches disables warnings as errors for STAGEautofeedback.

Tested on x86_64-pc-linux-gnu.

ChangeLog:

	* Makefile.in: Disable warnings as errors for STAGEautofeedback
2023-05-16 20:13:09 -07:00
Jiufu Guo
5eb7d56062 rs6000: use lis;xoris to build constant
For constant C:
If '(c & 0xFFFFFFFF0000FFFFULL) == 0xFFFFFFFF00000000' or say:
32(1) || 1(0) || 15(x) || 16(0), we could use "lis; xoris" to build.

Here N(M) means N continuous bit M, x for M means it is ok for either
1 or 0; '||' means concatenation.

This patch update rs6000_emit_set_long_const to support those constants.

Compare with previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608292.html
This patch updates test function names only.

Bootstrap and regtest pass on ppc64{,le}.

	PR target/106708

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Support building
	constants through "lis; xoris".

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106708.c: Add test function.
2023-05-17 10:13:18 +08:00
GCC Administrator
0d56605751 Daily bump. 2023-05-17 00:17:44 +00:00
Joseph Myers
036b4eb47e c: Remove restrictions on declarations in 'for' loops for C2X
C2X removes a restriction that the only declarations in the
declaration part of a 'for' loop are declarations of objects with
storage class auto or register.  Implement this change, making the
diagnostics into pedwarn_c11 calls instead of errors (as usual for
features added in a new standard version that were invalid code in a
previous version), so now pedwarn-if-pedantic for older standards and
diagnosed also with -Wc11-c2x-compat.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
	* c-decl.cc (check_for_loop_decls): Use pedwarn_c11 for
	diagnostics.

gcc/testsuite/
	* gcc.dg/c11-fordecl-1.c, gcc.dg/c11-fordecl-2.c,
	gcc.dg/c11-fordecl-3.c, gcc.dg/c11-fordecl-4.c,
	gcc.dg/c2x-fordecl-1.c, gcc.dg/c2x-fordecl-2.c,
	gcc.dg/c2x-fordecl-3.c, gcc.dg/c2x-fordecl-4.c: New tests.
	* gcc.dg/c99-fordecl-2.c: Test diagnostic for typedef declaration
	in for loop here.
	* gcc.dg/pr67784-2.c, gcc.dg/pr68320.c, objc.dg/foreach-7.m: Do
	not expect errors for typedef declaration in for loop.
2023-05-16 23:46:02 +00:00
Gaius Mulley
509eef9314 PR modula2/109879 WholeIO.ReadCard and ReadInt should consume leading space
The Read{TYPE} procedures in LongIO, LongWholeIO, RealIO, ShortWholeIO and
WholeIO all require skip space functionality.  A new module TextUtil
is supplied with this functionality and the previous modules have been
changed to call SkipSpaces.

gcc/m2/ChangeLog:

	PR modula2/109879
	* gm2-libs-iso/LongIO.mod (ReadReal): Call SkipSpaces.
	* gm2-libs-iso/LongWholeIO.mod (ReadInt): Call SkipSpaces.
	(ReadCard): Call SkipSpaces.
	* gm2-libs-iso/RealIO.mod (ReadReal): Call SkipSpaces.
	* gm2-libs-iso/ShortWholeIO.mod: (ReadInt): Call SkipSpaces.
	(ReadCard): Call SkipSpaces.
	* gm2-libs-iso/TextIO.mod: Import SkipSpaces.
	* gm2-libs-iso/WholeIO.mod (ReadInt): Call SkipSpaces.
	(ReadCard): Call SkipSpaces.
	* gm2-libs-iso/TextUtil.def: New file.
	* gm2-libs-iso/TextUtil.mod: New file.

libgm2/ChangeLog:

	PR modula2/109879
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* libm2cor/Makefile.in: Regenerate.
	* libm2iso/Makefile.am (M2DEFS): Add TextUtil.def.
	(M2MODS): Add TextUtil.mod.
	* libm2iso/Makefile.in: Regenerate.
	* libm2log/Makefile.in: Regenerate.
	* libm2min/Makefile.in: Regenerate.
	* libm2pim/Makefile.in: Regenerate.

gcc/testsuite/ChangeLog:

	PR modula2/109879
	* gm2/isolib/run/pass/testreadint.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-17 00:18:56 +01:00
Marek Polacek
f25d2de176 c++: -Wdangling-reference not suppressed in template [PR109774]
In check_return_expr, we suppress the -Wdangling-reference warning when
we're sure it would be a false positive.  It wasn't working in a
template, though, because the suppress_warning call was never reached.

	PR c++/109774

gcc/cp/ChangeLog:

	* typeck.cc (check_return_expr): In a template, return only after
	suppressing -Wdangling-reference.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wdangling-reference13.C: New test.
2023-05-16 14:12:57 -04:00
Jonathan Wakely
94a311abf7 libstdc++: Disable cacheline alignment for DJGPP [PR109741]
DJGPP (and maybe other targets) uses MAX_OFILE_ALIGNMENT=16 which means
that globals (and static objects) can't have alignment greater than 16.
This causes an error for the locks defined in src/c++11/shared_ptr.cc
because we try to align them to the cacheline size, to avoid false
sharing.

Add a configure check for the increased alignment, and live with false
sharing where we can't increase the alignment.

libstdc++-v3/ChangeLog:

	PR libstdc++/109741
	* acinclude.m4 (GLIBCXX_CHECK_ALIGNAS_CACHELINE): Define.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_ALIGNAS_CACHELINE.
	* src/c++11/shared_ptr.cc (__gnu_internal::get_mutex): Do not
	align lock table if not supported. use __GCC_DESTRUCTIVE_SIZE
	instead of hardcoded 64.
2023-05-16 18:31:19 +01:00
Patrick Palka
d5e5007c4b c++: desig init in presence of list ctor [PR109871]
add_list_candidates has logic to reject designated initialization of a
non-aggregate type, but this is inadvertently being suppressed if the type
has a list constructor due to the order of case analysis, which in the
below testcase leads to us incorrectly treating the initializer list as if
it's non-designated.  This patch fixes this by making us check for invalid
designated initialization sooner.

	PR c++/109871

gcc/cp/ChangeLog:

	* call.cc (add_list_candidates): Check for invalid designated
	initialization sooner and even for types that have a list
	constructor.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/desig27.C: New test.
2023-05-16 12:39:16 -04:00
“Ajit Kumar Agarwal”
9417b30499 rs6000: Enable REE pass by default
Add ree pass as a default pass for rs6000 target for
O2 and above.

2023-05-16  Ajit Kumar Agarwal  <aagarwa1@linux.ibm.com>

gcc/ChangeLog:

	* common/config/rs6000/rs6000-common.cc: Add REE pass as a
	default rs6000 target pass for O2 and above.
	* doc/invoke.texi: Document -free
2023-05-16 10:49:19 -05:00
Kito Cheng
008cbecf62 RISC-V: Fix wrong select_kind in riscv_compute_multilib
Seems like I screw up bare-metal toolchian multi lib selection during
finxing linux multi-lib selction...

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_compute_multilib):
	Fix wrong select_kind...
2023-05-16 23:29:40 +08:00
Carl Love
38dc1b9145 rs6000: Fix test int_128bit-runnable.c instruction counts
The test reports two failures on Power 10LE:

FAIL: .../int_128bit-runnable.c scan-assembler-times \\\\mvdivsq\\\\M 1
FAIL: .../int_128bit-runnable.c scan-assembler-times \\\\mvextsd2q\\\\M 6

The current counts are :

  vdivsq   3
  vextsd2q 4

The counts changed with commit:

  commit 852b11da11
  Author: Michael Meissner <meissner@linux.ibm.com>
  Date:   Wed Jul 7 21:55:38 2021 -0400

      Generate 128-bit int divide/modulus on power10.

      This patch adds support for the VDIVSQ, VDIVUQ, VMODSQ, and VMODUQ
      instructions to do 128-bit arithmetic.

      2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

The code generation changed significantly.  There are two places where
the vextsd2q is "replaced" by a vdivsq instruction thus increasing the
vdivsq count from 1 to 3.  The first case is:

expected_result = vec_arg1[0]/4;
    10000af8:   60 01 df e8     ld      r6,352(r31)
    10000afc:   68 01 ff e8     ld      r7,360(r31)
    10000b00:   76 fe e9 7c     sradi   r9,r7,63
    10000b04:   67 4b 00 7c     mtvsrdd vs32,0,r9
    10000b08:   02 06 1b 10     vextsd2q v0,v0         <----
    10000b0c:   03 00 40 39     li      r10,3
    10000b10:   00 00 60 39     li      r11,0
    10000b14:   67 00 09 7c     mfvrd   r9,v0
    10000b18:   67 02 08 7c     mfvsrld r8,vs32
    10000b1c:   38 50 08 7d     and     r8,r8,r10
    10000b20:   38 58 29 7d     and     r9,r9,r11
    10000b24:   78 4b 2b 7d     mr      r11,r9
    10000b28:   78 43 0a 7d     mr      r10,r8
    10000b2c:   14 30 4a 7f     addc    r26,r10,r6
    10000b30:   14 39 6b 7f     adde    r27,r11,r7
    10000b34:   46 f0 69 7b     sldi    r9,r27,62
    10000b38:   82 f0 58 7b     srdi    r24,r26,2
    10000b3c:   78 c3 38 7d     or      r24,r9,r24
    10000b40:   74 16 79 7f     sradi   r25,r27,2
    10000b44:   30 00 1f fb     std     r24,48(r31)
    10000b48:   38 00 3f fb     std     r25,56(r31)

To:

   expected_result = vec_arg1[0]/4;
    10000af8:   69 01 1f f4     lxv     vs32,352(r31)
    10000afc:   04 00 20 39     li      r9,4
    10000b00:   00 00 40 39     li      r10,0
    10000b04:   67 4b 2a 7c     mtvsrdd vs33,r10,r9
    10000b08:   0b 09 00 10     vdivsq  v0,v0,v1       <----
    10000b0c:   3d 00 1f f4     stxv    vs32,48(r31)

The second case were a vexts2q instruction is replaced with vdivsq:

From:

  expected_result = arg1/16;
    10000c24:   40 00 df e8     ld      r6,64(r31)
    10000c28:   48 00 ff e8     ld      r7,72(r31)
    10000c2c:   76 fe e9 7c     sradi   r9,r7,63
    10000c30:   67 4b 00 7c     mtvsrdd vs32,0,r9
    10000c34:   02 06 1b 10     vextsd2q v0,v0        <---
    10000c38:   0f 00 40 39     li      r10,15
    10000c3c:   00 00 60 39     li      r11,0
    10000c40:   67 00 09 7c     mfvrd   r9,v0
    10000c44:   67 02 08 7c     mfvsrld r8,vs32
    10000c48:   38 50 08 7d     and     r8,r8,r10
    10000c4c:   38 58 29 7d     and     r9,r9,r11
    10000c50:   78 4b 2b 7d     mr      r11,r9
    10000c54:   78 43 0a 7d     mr      r10,r8
    10000c58:   14 30 ca 7e     addc    r22,r10,r6
    10000c5c:   14 39 eb 7e     adde    r23,r11,r7
    10000c60:   c6 e0 e9 7a     sldi    r9,r23,60
    10000c64:   02 e1 d4 7a     srdi    r20,r22,4
    10000c68:   78 a3 34 7d     or      r20,r9,r20
    10000c6c:   74 26 f5 7e     sradi   r21,r23,4
    10000c70:   30 00 9f fa     std     r20,48(r31)
    10000c74:   38 00 bf fa     std     r21,56(r31)

To:

  expected_result = arg1/16;
    10000be8:   49 00 1f f4     lxv     vs32,64(r31)
    10000bec:   10 00 20 39     li      r9,16
    10000bf0:   00 00 40 39     li      r10,0
    10000bf4:   67 4b 2a 7c     mtvsrdd vs33,r10,r9
    10000bf8:   0b 09 00 10     vdivsq  v0,v0,v1       <---
    10000bfc:   3d 00 1f f4     stxv    vs32,48(r31)

The patch has been tested on Power10LE with no regressions.

gcc/testsuite/
	* gcc.target/powerpc/int_128bit-runnable.c: Update expected
	instruction counts.
2023-05-16 11:28:15 -04:00
Carl Love
66d9ac083c rs6000: Fix test gc.target/powerpc/rs600-fpint.c test options
The test compile option rs6000-*-* is outdated and no longer supported.
The powerpc*-*-* is the defualt, so it doesn't need to be specified.
The dg-options needs to specify an older processor to get the desired
behavior on recent processors, since gfxopt is only off for very old CPUs,
we don't guard stfiwx under it for recent processors and don't want to.

This patch updates the test specifications so the test will run properly on
Power10LE.  Tested on Power10 LE system with no regression test failures.

gcc/testsuite/:
	* gcc.target/powerpc/rs6000-fpint.c: Update dg-options, drop dg-do
	compile specifier.
2023-05-16 11:25:50 -04:00
Gaius Mulley
cf4dcfa672 PR modula2/108344 disable default opening of /dev/tty
This patch changes removes the static initialisation code for KeyBoardLEDs.cc.
The module is only initialised if one of the exported functions is called.
This is useful as the module will access /dev/tty which might not be
available.  TimerHandler.mod has also been changed to disable the scroll
lock LED as a sign of life.

gcc/m2/ChangeLog:

	PR modula2/108344
	* gm2-libs-coroutines/TimerHandler.mod (EnableLED): New constant.
	(Timer): Test EnableLED before switching on the scroll LED.

libgm2/ChangeLog:

	PR modula2/108344
	* libm2cor/KeyBoardLEDs.cc (initialize_module): New function.
	(SwitchScroll): Call initialize_module.
	(SwitchNum): Call initialize_module.
	(SwitchCaps): Call initialize_module.
	(SwitchLEDs): Call initialize_module.
	(M2EXPORT): Remove initialization code.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-16 15:51:53 +01:00
Richard Sandiford
057e537e2a aarch64: Allow moves after tied-register intrinsics (2nd edition)
I missed these two in g:4ff89f10ca0d41f9cfa76 because I was
testing on a system that didn't support big-endian compilation.
Testing on aarch64_be-elf shows no other related failures
(although the overall results are worse than for little-endian).

gcc/testsuite/
	* gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c: Allow mves
	to occur after the intrinsic instruction, rather than requiring
	them to happen before.
	* gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c: Likewise.
2023-05-16 11:54:57 +01:00
Jonathan Wakely
ac3a5bbc62 libstdc++: Stop using TR1 macros in <cctype> and <cfenv>
As with the two commits before this, the _GLIBCXX_USE_C99_CTYPE_TR1 and
_GLIBCXX_USE_C99_FENV_TR1 macros are misleading when they are also used
for <cctype> and <cfenv>, not only for TR1 headers. It is also wrong,
because the configure checks for TR1 use -std=c++98 and a target might
define the C99 features for C++11 but not for C++98.

Add separate configure checks for the <ctype.h> and <fenv.h> features using -std=c++11
for the checks. Use the new macros defined by those checks in the
C++11-specific parts of <cctype>, <cfenv>, and <fenv.h>.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_USE_C99): Check for isblank in C++11
	mode and define _GLIBCXX_USE_C99_CTYPE. Check for <fenv.h>
	functions in C++11 mode and define _GLIBCXX_USE_C99_FENV.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/c_compatibility/fenv.h: Check _GLIBCXX_USE_C99_FENV
	instead of _GLIBCXX_USE_C99_FENV_TR1.
	* include/c_global/cfenv: Likewise.
	* include/c_global/cctype: Check _GLIBCXX_USE_C99_CTYPE instead
	of _GLIBCXX_USE_C99_CTYPE_TR1.
2023-05-16 09:59:19 +01:00
Jonathan Wakely
5baabdb15d libstdc++: Stop using _GLIBCXX_USE_C99_STDINT_TR1 in <cstdint>
The _GLIBCXX_USE_C99_STDINT_TR1 macro (and the comments about it in
acinclude.m4 and config.h) are misleading when it is also used for
<stdint>, not only <tr1/stdint>. It is also wrong, because the
configure checks for TR1 use -std=c++98 and a target might define
uint32_t etc. for C++11 but not for C++98.

Add a separate configure check for the <stdint.h> types using -std=c++11
for the checks. Use the result of that separate check in <cstdint> and
most other places that still depend on the macro (many uses of that
macro have been removed already). The remaining uses of the STDINT_TR1
macro are really for TR1, or are in the src/c++11/compatibility-*.cc
files, where we don't want/need to change the condition they depend on
(if those symbols were only exported when <stdint.h> types were
available for -std=c++98, then that's the condition we should continue
to use for whether to export the compat symbols now).

Make similar changes for the related _GLIBCXX_USE_C99_INTTYPES_TR1 and
_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 macros, adding new macros for
non-TR1 uses.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_USE_C99): Check for <stdint.h> types in
	C++11 mode and define _GLIBCXX_USE_C99_STDINT. Check for
	<inttypes.h> features in C++11 mode and define
	_GLIBCXX_USE_C99_INTTYPES and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/doxygen/user.cfg.in (PREDEFINED): Add new macros.
	* include/bits/chrono.h: Check _GLIBCXX_USE_C99_STDINT instead
	of _GLIBCXX_USE_C99_STDINT_TR1.
	* include/c_compatibility/inttypes.h: Check
	_GLIBCXX_USE_C99_INTTYPES and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T
	instead of _GLIBCXX_USE_C99_INTTYPES_TR1 and
	_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1.
	* include/c_compatibility/stdatomic.h: Check
	_GLIBCXX_USE_C99_STDINT instead of _GLIBCXX_USE_C99_STDINT_TR1.
	* include/c_compatibility/stdint.h: Likewise.
	* include/c_global/cinttypes: Check _GLIBCXX_USE_C99_INTTYPES
	and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T instead of
	_GLIBCXX_USE_C99_INTTYPES_TR1 and
	_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1.
	* include/c_global/cstdint: Check _GLIBCXX_USE_C99_STDINT
	instead of _GLIBCXX_USE_C99_STDINT_TR1.
	* include/std/atomic: Likewise.
	* src/c++11/cow-stdexcept.cc: Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_v3_target_cstdint):
	Likewise.
2023-05-16 09:59:19 +01:00
Jonathan Wakely
0d76fb1582 libstdc++: Stop using _GLIBCXX_USE_C99_COMPLEX_TR1 in <complex>
The _GLIBCXX_USE_C99_COMPLEX_TR1 macro (and the comments about it in
acinclude.m4 and config.h) are misleading when it is also used for
<complex>, not only <tr1/complex>. It is also wrong, because the
configure checks for TR1 use -std=c++98 and a target might define cacos
etc. for C++11 but not for C++98.

Add a separate configure check for the inverse trigonometric functions
that are covered by _GLIBCXX_USE_C99_COMPLEX_TR1, but using -std=c++11
for the checks. Use the result of that separate check in <complex>.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_USE_C99): Check for complex inverse trig
	functions in C++11 mode and define _GLIBCXX_USE_C99_COMPLEX_ARC.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/doxygen/user.cfg.in (PREDEFINED): Add new macro.
	* include/std/complex: Check _GLIBCXX_USE_C99_COMPLEX_ARC
	instead of _GLIBCXX_USE_C99_COMPLEX_TR1.
2023-05-16 09:59:19 +01:00
Jonathan Wakely
bf904527ab libstdc++: Add assertion to debug_allocator test
libstdc++-v3/ChangeLog:

	* testsuite/ext/debug_allocator/check_deallocate_null.cc: Add
	assertion to ensure expected exception is throw.
2023-05-16 09:59:19 +01:00
Jonathan Wakely
151bad4102 libstdc++: Require tzdb support for chrono::zoned_time printer test
libstdc++-v3/ChangeLog:

	* testsuite/libstdc++-prettyprinters/chrono.cc: Only test
	printer for chrono::zoned_time for cx11 ABI and tzdb effective
	target.
2023-05-16 09:59:01 +01:00
Jonathan Wakely
3b7cb33033 libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer
As noted in https://github.com/llvm/llvm-project/issues/62623 there are
no tsan interceptors for some of the new POSIX-1:202x APIs added by
https://austingroupbugs.net/view.php?id=1216 so tsan gives false
positive warnings for try_lock_for on timed mutexes.

Disable the uses of the new pthread_mutex_clocklock API when tsan is
active. This changes the semantics of the try_lock_for functions,
because it can change which clock is used for the wait. This means those
functions might be affected by system clock adjustments when tsan is
used, when they would not be affected otherwise.

Reviewed-by: Thomas Rodgers <trodgers@redhat.com>
Reviewed-by: Mike Crowe <mac@mcrowe.com>

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define
	_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK in terms of _GLIBCXX_TSAN.
	* configure: Regenerate.
2023-05-16 09:59:01 +01:00
Steve Baird
45efdda3ff ada: Add "gnat --help-ada" text for new switches.
The output generated by "gnat --help-ada" should include descriptions for
the newly added -gnatw_s and -gnatw_S switches".

gcc/ada/

	* usage.adb: Generate output text describing the -gnatw_s switch
	(and the corresponding -gnatw_S switch).
2023-05-16 10:30:59 +02:00
Eric Botcazou
9a70dce278 ada: Use accumulator type in expansion of 'Reduce attribute
The current expansion of the 'Reduce attribute uses the resolution type of
the expression for the accumulator. Now this type can be unresolved or set
to a universal type, for example if it is itself the prefix of the 'Image
attribute, and this may yield a spurious type mismatch error in that case.

This changes the expansion to use the accumulator type instead as defined
by the RM 4.5.10 clause, albeit only in the prefixed case for now.

gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Reduce>:
	Use the canonical accumulator type as the type of the accumulator
	in the prefixed case.
2023-05-16 10:30:59 +02:00
Eric Botcazou
e07e6ea692 ada: Fix missing warning on aggregate with iterated component
This happens when the iterated component does not really iterate.

gcc/ada/

	* exp_aggr.adb (Expand_Array_Aggregate): Do not set Warnings_Off on
	the temporary created when in-place expansion is not possible.
2023-05-16 10:30:59 +02:00
Eric Botcazou
5fa02009e4 ada: Fix crash on iterated component in expression function
The problem is that the freeze node generated for the type of a static
subexpression present in the expression function is incorrectly placed
inside instead of outside the function.

gcc/ada/

	* freeze.adb (Freeze_Expression): When the freezing is to be done
	outside the current scope, skip any scope that is an internal loop.
2023-05-16 10:30:58 +02:00
Eric Botcazou
ae334957c7 ada: Fix internal error on 'Image applied to array component
This happens because the array component depends on a discriminant.

gcc/ada/

	* exp_imgv.adb (Rewrite_Object_Image): If the prefix is a component
	that depends on a discriminant, create an actual subtype for it.
2023-05-16 10:30:58 +02:00
Eric Botcazou
5f8a29bd34 ada: Fix internal error on chain of predicated record types
The preanalysis of a predicate set on one of the record types was causing
premature freezing of another record type.

gcc/ada/

	* sem_ch13.adb: Add with and use clauses for Expander.
	(Resolve_Aspect_Expressions) <Aspect_Predicate>: Emulate a
	bona-fide preanalysis setup before calling
	Resolve_Aspect_Expression.
2023-05-16 10:30:58 +02:00
Yannick Moy
8ebdd44318 ada: Update proof of runtime units
Following changes in GNATprove, proofs need to be amended.

gcc/ada/

	* libgnat/s-aridou.adb (Lemma_Div_Pow2): Add assertion.
	* libgnat/s-arit32.adb (Lemma_Abs_Div_Commutation): Simplify.
	* libgnat/s-expmod.adb (Lemma_Exp_Mod): Add assertions.
	(Lemma_Euclidean_Mod): Add body to lemma.
	(Lemma_Mult_Mod): Add assertion.
	* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Modify assertion.
	* libgnat/s-vauspe.ads (Raw_Unsigned_Last_Ghost): Add
	postcondition.
	* libgnat/s-widthi.adb: Use more precise types.
2023-05-16 10:30:58 +02:00
Eric Botcazou
bac7eb85ef ada: Implement inheritance of user-defined literal aspects for untagged types
In Ada 2022, user-defined literal aspects are nonoverridable but the named
subprograms present in them can be overridden, including for untagged types.

gcc/ada/

	* sem_res.adb (Has_Applicable_User_Defined_Literal): Apply the
	same processing for derived untagged types as for tagged types.
	* sem_util.ads (Corresponding_Primitive_Op): Adjust description.
	* sem_util.adb (Corresponding_Primitive_Op): Handle untagged
	types.
2023-05-16 10:30:58 +02:00
Javier Miranda
072861beb9 ada: Spurious error analyzing 'old or 'result in class-wide conditions
gcc/ada/

	* sem_attr.adb
	(Analyze_Attribute_Old_Result): When preanalyzing a class-wide
	condition, search in the scopes stack for the subprogram that has
	the condition. This is required because returning the current
	scope causes reporting spurious errors when the occurrence of the
	attribute is found, for example, in a quantified expression.
2023-05-16 10:30:58 +02:00
Javier Miranda
b979a47416 ada: Spurious error on function returning CPP type
gcc/ada/

	* exp_ch6.adb
	(Needs_BIP_Alloc_Form): Return False for functions with foreign
	convention since we never use build-in-place for such functions.
2023-05-16 10:30:58 +02:00
Piotr Trojanek
b358f011bd ada: Apply range checks to preanalyzed aggregate expressions
When preanalyzing expressions in GNATprove mode, e.g. Pre/Post
contracts, we apply checks, because these expressions will never
be expanded. This didn't happen for aggregate expressions, most
likely because of an oversight.

gcc/ada/

	* sem_util.adb (Aggregate_Constraint_Checks): Don't exit early
	when preanalysing in GNATprove mode. Now the condition is
	consistent with other similar conditions in other code.
2023-05-16 10:30:58 +02:00
Ghjuvan Lacambre
4803e348aa ada: usage.adb: document -gnatyD switch
-gnatyD was documented in the user guide but not in `gnat --help-ada`.

gcc/ada/

	* usage.adb (Usage): Document -gnatyD.
2023-05-16 10:30:58 +02:00
Marc Poulhiès
2ffa7a6840 ada: Fix Ada representation of r_debug and link_map types
Both record types need to have their components 'aliased' to match their
C version. The mismatch could be observed when using LTO:

  warning: type of 'r_debug' does not match original declaration
       [-Wlto-type-mismatch]

  /usr/include/link.h:66:23: note: type 'struct r_debug' should match
  type 'struct  system__traceback__symbolic__module_name__build_...
   ...cache_for_all_modules__r_debug_type'

gcc/ada/

	* libgnat/s-tsmona__linux.adb (link_map, r_debug_type): Add
	'aliased' on all components.
2023-05-16 10:30:57 +02:00
Johannes Kliemann
6c0b94efaa ada: Enable Support_Atomic_Primitives on PPC Linux
gcc/ada/

	* libgnat/system-linux-ppc.ads: Add Support_Atomic_Primitives.
	* libgnat/s-atopri__32.ads: Add 32 bit version of s-atopri.ads.
	* Makefile.rtl: Use s-atopro__32.ads for ppc-linux.
2023-05-16 10:30:57 +02:00
Eric Botcazou
cbf64a8037 ada: Follow-up improvement to implementation of storage models
It avoids to recreate an actual subtype for an explicit dereference.

gcc/ada/

	* sem_util.adb (Get_Actual_Subtype): For an explicit dereference,
	return the Actual_Designated_Subtype if it is present.
	(Get_Actual_Subtype_If_Available): Likewise.
2023-05-16 10:30:57 +02:00
Arnaud Charlet
b54fd57a1b ada: Add tags on style messages
Similar to tags on warnings [-gnatwx], we add tags on style messages
[-gnatyx] when -gnatw.d is enabled.

gcc/ada/

	* errout.ads: Update comment.
	* errout.adb (Skip_Msg_Insertion_Warning): Update to take e.g.
	-gnatyM into account.
	* erroutc.adb (Get_Warning_Option, Get_Warning_Tag)
	(Prescan_Message): Add support for Style tags.
	* par-ch5.adb, par-ch6.adb, par-ch7.adb, par-endh.adb,
	par-util.adb, style.adb, styleg.adb: Set tag on all style
	messages.
2023-05-16 10:30:57 +02:00
Tom Tromey
387e147cf5 ada: Fix typo in "pattern"
I found a couple of spots using the typo "patterm" rather than the
correct "pattern".

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Switches_for_gnatbind): Fix typo.
	* libgnat/g-spipat.ads: Fix typo.
	* gnat_ugn.texi: Regenerate.
2023-05-16 10:30:57 +02:00
Eric Botcazou
ca4bff3a3d ada: Adjust semantics and implementation of storage models
This makes the following adjustments to the semantics and implementation of
storage models in the compiler:

  1. By-copy semantics in subprogram calls: when an object accessed with a
     nonnative storage model is passed as an actual parameter in a call to
     a subprogram, an intermediate copy made on the host is passed instead.

  2. More generally, any additional temporary required on the host by the
     semantics of nonnative storage models is now created by the front-end
     instead of the code generator.

  3. All the temporaries created on the host for nonnative storage models
     are allocated on the secondary stack instead of the primary stack.

As a result, this should simplify the implementation in code generators.

gcc/ada/

	* exp_aggr.adb (Build_Assignment_With_Temporary): Adjust comment
	and fix type of second parameter. Create the temporary on the
	secondary stack by calling Build_Temporary_On_Secondary_Stack.
	(Convert_Array_Aggr_In_Allocator): Adjust formatting.
	(Expand_Array_Aggregate): Likewise.
	* exp_ch4.adb (Expand_N_Allocator): Set Actual_Designated_Subtype
	on the dereference in the initialization for all composite types.
	* exp_ch5.adb (Expand_N_Assignment_Statement): Create a temporary
	on the host for an assignment between nonnative storage models.
	Suppress more checks when Suppress_Assignment_Checks is set.
	* exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Deal with actuals
	that are dereferences with an Actual_Designated_Subtype. Add
	support for nonnative storage models.
	(Expand_Actuals): Create a copy if the actual is a dereference
	with a nonnative storage model.
	* exp_util.ads (Build_Temporary_On_Secondary_Stack): Declare.
	* exp_util.adb (Build_Temporary_On_Secondary_Stack): New function.
	* sem_ch5.adb (Analyze_Assignment.Set_Assignment_Type): Do not
	build an actual subtype for dereferences with an
	Actual_Designated_Subtype
	* sinfo.ads (Actual_Designated_Subtype): Adjust documentation.
	(Suppress_Assignment_Checks): Likewise.
2023-05-16 10:30:57 +02:00
Piotr Trojanek
c637076413 ada: Build invariant procedure while freezing in GNATprove mode
Invariant procedure bodies are created either by expansion of freezing
nodes (but only in ordinary compilation mode) or at the end of package
private declarations (but not for with private types in the type
derivation chain).

In GNATprove mode we didn't create invariant procedure bodies in
lightweight expansion, so we didn't create them at all when there were
private types in the type derivation chain.

This patch copies the relevant freezing part from ordinary to
lightweight expansion. This obviously involves code duplication,
but it seems better to duplicate whole sections that work properly
instead of small pieces that are incomplete. There are other pieces
of freezing that are similarly duplicated, so this patch doesn't make
the code substantially worse.

gcc/ada/

	* exp_spark.adb (SPARK_Freeze_Type): Copy whole handling of DIC
	and Type_Invariant from Freeze_Type.
2023-05-16 10:30:57 +02:00
Richard Kenner
66152ecdae ada: Get name from entity if that's what's passed to Subprogram_Name
gcc/ada/

	* sem_util.adb (Subprogram_Name): If what's passed is already an
	entity, use that for the name.
2023-05-16 10:30:57 +02:00
Eric Botcazou
5c6e261645 ada: Document examples of No_Dependence restriction for code generation
gcc/ada/

	* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst
	(No_Dependence): Give examples of new No_Dependence restrictions.
	* gnat_rm.texi: Regenerate.
2023-05-16 10:30:56 +02:00
Arnaud Charlet
05c1e15f9f ada: Bad handling of ASCII with -gnatyn
ASCII is special cased but this wasn't taking into account all cases
such as Standard.ASCII.

gcc/ada/

	* snames.ads-tmpl (Name_ASCII): New.
	* style.adb (Check_Identifier): Fix handling of ASCII.
2023-05-16 10:30:56 +02:00
Eric Botcazou
4b8f39b21e ada: Introduce Cannot_Be_Superflat flag on N_Range nodes
The support of superflat arrays in the language generates an overhead that
the code generator attempts to minimize, but it cannot handle too complex
cases and it would be helpful if the front-end could lend a hand.

This change introduces the Cannot_Be_Superflat flag on N_Range nodes for
this purpose, and sets it on the result of string concatenations when it
is guaranteed to be nonnull.

gcc/ada/

	* gen_il-fields.ads (Opt_Field_Enum): Add Cannot_Be_Superflat.
	* gen_il-gen-gen_nodes.adb (N_Range): Add Cannot_Be_Superflat as
	semantical flag and change Includes_Infinities to semantical.
	* sinfo.ads (Cannot_Be_Superflat): Document it for N_Range.
	* exp_ch4.adb (Expand_Concatenate): Set Cannot_Be_Superflat on the
	range of the result if the result cannot be null.
2023-05-16 10:30:56 +02:00
Richard Kenner
b92d0c4564 ada: Change Present_Expr field type to Uint
We want the field to be initialized to No_Uint because we want to be
able to test in GNAT LLVM whether we've already set it so we can be
sure we only set it once.

gcc/ada/

	* gen_il-gen-gen_nodes.adb (Present_Expr): Type is now Uint.
2023-05-16 10:30:56 +02:00
Yannick Moy
913794b1cb ada: Simplify dramatically ghost code for proof of System.Arith_Double
Using Inline_For_Proof annotation on key expression functions makes
it possible to remove hundreds of lines of ghost code that were
previously needed to guide provers.

gcc/ada/

	* libgnat/s-aridou.adb (Big3, Is_Mult_Decomposition)
	(Is_Scaled_Mult_Decomposition): Add annotation for inlining.
	(Double_Divide, Scaled_Divide): Simplify and remove ghost code.
	(Prove_Multiplication): Add calls to lemmas to make proof go
	through.
	* libgnat/s-aridou.ads (Big, In_Double_Int_Range): Add annotation
	for inlining.
2023-05-16 10:30:56 +02:00
Yannick Moy
fd0f8d2486 ada: Add intermediate assertions for proof of Super_Tail
Proof of Superbounded internal unit requires a little more help.

gcc/ada/

	* libgnat/a-strsup.adb: Add intermediate assertions.
2023-05-16 10:30:56 +02:00
Arnaud Charlet
24917325ce ada: Missing dependency with -gnatc
When using -gnatc, dependencies on preprocessor and config files
were not recorded.

gcc/ada/

	* gnat1drv.adb: Ensure all dependencies are recorded even when not
	generating code.
2023-05-16 10:30:56 +02:00
Yannick Moy
04606c1229 ada: Set Loop_Variant assertion policy to Ignore in both
Set Loop_Variant assertion policy to Ignore in both.

gcc/ada/

	* libgnat/a-strsup.adb: Set assertion policy for Loop_Variant.
2023-05-16 10:30:56 +02:00
Marc Poulhiès
3c09e25e2c ada: Trivial refactoring in Instantiate_*_Body
Factor out Par_Vis/Install_Parent/Par_Installed in Instantiate_Package_Body
and Instantiate_Subprogram_Body.

gcc/ada/

	* sem_ch12.adb (Instantiate_Package_Body): Simplify if/then/else.
	(Instantiate_Subprogram_Body): Likewise.
2023-05-16 10:30:56 +02:00