platform/upstream/gcc.git
2 years agotestsuite: Mark extra warnings for default_packed
Dimitar Dimitrov [Sat, 14 May 2022 18:40:11 +0000 (21:40 +0300)]
testsuite: Mark extra warnings for default_packed

If the target uses packed structs by default, there are no trailing
padding bytes allocated.  Hence extra warnings are emitted.

gcc/testsuite/ChangeLog:

* gcc.dg/Warray-bounds-48-novec.c: Add expected warnings
if target packs the structs by default.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoDaily bump.
GCC Administrator [Sat, 21 May 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.

2 years agotestsuite: add missing dg-require-effective-target fpic
Marc Poulhiès [Thu, 31 Mar 2022 13:50:35 +0000 (13:50 +0000)]
testsuite: add missing dg-require-effective-target fpic

Require effective target fpic for newly added test.

gcc/testsuite/
* g++.dg/ext/visibility/visibility-local-extern1.C: Add missing
dg-require-effective-target fpic.

2 years agolibstdc++: Reduce <random> test iterations for simulators
Jonathan Wakely [Fri, 20 May 2022 14:44:25 +0000 (15:44 +0100)]
libstdc++: Reduce <random> test iterations for simulators

Some of these tests take several minutes on a simulator like cris-elf,
so we can conditionally run fewer iterations. The testDiscreteDist
helper already supports custom sizes so we just need to make use of that
when { target simulator } matches.

The relevant code is sufficiently tested on other targets, so we're not
losing anything by only running a small number of iterators for sims.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc:
Run fewer iterations for simulator targets.
* testsuite/26_numerics/random/binomial_distribution/operators/values.cc:
Likewise.
* testsuite/26_numerics/random/discrete_distribution/operators/values.cc:
Likewise.
* testsuite/26_numerics/random/geometric_distribution/operators/values.cc:
Likewise.
* testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc:
Likewise.
* testsuite/26_numerics/random/poisson_distribution/operators/values.cc:
Likewise.
* testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc:
Likewise.

2 years agoAArch64: Improve rotate patterns
Wilco Dijkstra [Wed, 18 May 2022 15:06:57 +0000 (16:06 +0100)]
AArch64: Improve rotate patterns

Improve and generalize rotate patterns. Rotates by more than half the
bitwidth of a register are canonicalized to rotate left. Many existing
shift patterns don't handle this case correctly, so add rotate left to
the shift iterator and convert rotate left into ror during assembly
output. Add missing zero_extend patterns for shifted BIC, ORN and EON.

gcc/
* config/aarch64/aarch64.md
(and_<SHIFT:optab><mode>3_compare0): Support rotate left.
(and_<SHIFT:optab>si3_compare0_uxtw): Likewise.
(<LOGICAL:optab>_<SHIFT:optab><mode>3): Likewise.
(<LOGICAL:optab>_<SHIFT:optab>si3_uxtw): Likewise.
(one_cmpl_<optab><mode>2): Likewise.
(<LOGICAL:optab>_one_cmpl_<SHIFT:optab><mode>3): Likewise.
(<LOGICAL:optab>_one_cmpl_<SHIFT:optab>sidi_uxtw): New pattern.
(eor_one_cmpl_<SHIFT:optab><mode>3_alt): Support rotate left.
(eor_one_cmpl_<SHIFT:optab>sidi3_alt_ze): Likewise.
(and_one_cmpl_<SHIFT:optab><mode>3_compare0): Likewise.
(and_one_cmpl_<SHIFT:optab>si3_compare0_uxtw): Likewise.
(and_one_cmpl_<SHIFT:optab><mode>3_compare0_no_reuse): Likewise.
(and_<SHIFT:optab><mode>3nr_compare0): Likewise.
(*<optab>si3_insn_uxtw): Use SHIFT_no_rotate.
(rolsi3_insn_uxtw): New pattern.
* config/aarch64/iterators.md (SHIFT): Add rotate left.
(SHIFT_no_rotate): Add new iterator.
(SHIFT:shift): Print rotate left as ror.
(is_rotl): Add test for left rotate.

gcc/testsuite/
* gcc.target/aarch64/ror_2.c: New test.
* gcc.target/aarch64/ror_3.c: New test.

2 years agoAArch64: Cleanup CPU option processing code
Wilco Dijkstra [Wed, 18 May 2022 15:02:12 +0000 (16:02 +0100)]
AArch64: Cleanup CPU option processing code

The --with-cpu/--with-arch configure option processing not only checks valid
arguments but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask.
This isn't used however since a --with-cpu is translated into a -mcpu option
which is processed as if written on the command-line (so TARGET_CPU_DEFAULT
is never accessed).

So remove all the complex processing and bitmask, and just validate the
option. Fix a bug that always reports valid architecture extensions as invalid.
As a result the CPU processing in aarch64.c can be simplified.

gcc/
* config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch
processing.  Add support for architectural extensions.
* config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove
AARCH64_CPU_DEFAULT_FLAGS.
(TARGET_CPU_NBITS): Remove.
(TARGET_CPU_MASK): Remove.
* config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define.
(get_tune_cpu): Assert CPU is always valid.
(get_arch): Assert architecture is always valid.
(aarch64_override_options): Cleanup CPU selection code and simplify logic.
(aarch64_option_restore): Remove unnecessary checks on tune.

2 years agoUse "final" and "override" directly, rather than via macros
David Malcolm [Fri, 20 May 2022 14:05:54 +0000 (10:05 -0400)]
Use "final" and "override" directly, rather than via macros

As of GCC 11 onwards we have required a C++11 compiler, such as GCC 4.8
or later.  On the assumption that any such compiler correctly implements
"final" and "override", this patch updates the source tree to stop using
the FINAL and OVERRIDE macros from ansidecl.h, in favor of simply using
"final" and "override" directly.

libcpp/ChangeLog:
* lex.cc: Replace uses of "FINAL" and "OVERRIDE" with "final" and
"override".

gcc/analyzer/ChangeLog:
* analyzer-pass.cc: Replace uses of "FINAL" and "OVERRIDE" with
"final" and "override".
* call-info.h: Likewise.
* checker-path.h: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* feasible-graph.h: Likewise.
* pending-diagnostic.h: Likewise.
* region-model-impl-calls.cc: Likewise.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* region.h: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* state-purge.h: Likewise.
* store.cc: Likewise.
* store.h: Likewise.
* supergraph.h: Likewise.
* svalue.h: Likewise.
* trimmed-graph.h: Likewise.
* varargs.cc: Likewise.

gcc/c-family/ChangeLog:
* c-format.cc: Replace uses of "FINAL" and "OVERRIDE" with "final"
and "override".
* c-pretty-print.h: Likewise.

gcc/cp/ChangeLog:
* cxx-pretty-print.h: Replace uses of "FINAL" and "OVERRIDE" with
"final" and "override".
* error.cc: Likewise.

gcc/jit/ChangeLog:
* jit-playback.h: Replace uses of "FINAL" and "OVERRIDE" with
"final" and "override".
* jit-recording.cc: Likewise.
* jit-recording.h: Likewise.

gcc/ChangeLog:
* config/aarch64/aarch64-sve-builtins-base.cc: Replace uses of
"FINAL" and "OVERRIDE" with "final" and "override".
* config/aarch64/aarch64-sve-builtins-functions.h: Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.cc: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise.
* diagnostic-path.h: Likewise.
* digraph.cc: Likewise.
* gcc-rich-location.h: Likewise.
* gimple-array-bounds.cc: Likewise.
* gimple-loop-versioning.cc: Likewise.
* gimple-range-cache.cc: Likewise.
* gimple-range-cache.h: Likewise.
* gimple-range-fold.cc: Likewise.
* gimple-range-fold.h: Likewise.
* gimple-range-tests.cc: Likewise.
* gimple-range.h: Likewise.
* gimple-ssa-evrp.cc: Likewise.
* input.cc: Likewise.
* json.h: Likewise.
* read-rtl-function.cc: Likewise.
* tree-complex.cc: Likewise.
* tree-diagnostic-path.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* tree-ssa-copy.cc: Likewise.
* tree-vrp.cc: Likewise.
* value-query.h: Likewise.
* vr-values.h: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agolibgomp: Add new runtime routines omp_target_memcpy_async and omp_target_memcpy_rect_...
Marcel Vollweiler [Fri, 20 May 2022 09:08:36 +0000 (02:08 -0700)]
libgomp: Add new runtime routines omp_target_memcpy_async and omp_target_memcpy_rect_async

This patch adds two new OpenMP runtime routines: omp_target_memcpy_async and
omp_target_memcpy_rect_async. Both functions are introduced in OpenMP 5.1 as
asynchronous variants of omp_target_memcpy and omp_target_memcpy_rect.

In contrast to the synchronous variants, the asynchronous functions have two
additional function parameters to allow the specification of task dependences:

int depobj_count
omp_depend_t *depobj_list

integer(c_int), value :: depobj_count
integer(omp_depend_kind), optional :: depobj_list(*)

The implementation splits the synchronous functions into two parts: (a) check
and (b) copy. Then (a) is used in the asynchronous functions for the sequential
part, and the actual copy process (b) is executed in a new created task. The
sequential part (a) takes into account the requirements for the return values:

"The routine returns zero if successful. Otherwise, it returns a non-zero
value." (omp_target_memcpy_async, OpenMP 5.1 spec, section 3.8.7)

"An application can determine the number of inclusive dimensions supported by an
implementation by passing NULL pointers (or C_NULL_PTR, for Fortran) for both
dst and src. The routine returns the number of dimensions supported by the
implementation for the specified device numbers. No copy operation is
performed." (omp_target_memcpy_rect_async, OpenMP 5.1 spec, section 3.8.8)

Due to asynchronicity an error is thrown if the asynchronous memcpy is not
successful (in contrast to the synchronous functions which use a return
value unequal to zero).

gcc/ChangeLog:

* omp-low.cc (omp_runtime_api_call): Added target_memcpy_async and
target_memcpy_rect_async to omp_runtime_apis array.

libgomp/ChangeLog:

* libgomp.map: Added omp_target_memcpy_async and
omp_target_memcpy_rect_async.
* libgomp.texi: Both functions are now supported.
* omp.h.in: Added omp_target_memcpy_async and
omp_target_memcpy_rect_async.
* omp_lib.f90.in: Added interfaces for both new functions.
* omp_lib.h.in: Likewise.
* target.c (ialias_redirect): Added for GOMP_task.
(omp_target_memcpy): Restructured into check and copy part.
(omp_target_memcpy_check): New helper function for omp_target_memcpy and
omp_target_memcpy_async that checks requirements.
(omp_target_memcpy_copy): New helper function for omp_target_memcpy and
omp_target_memcpy_async that performs the memcpy.
(omp_target_memcpy_async_helper): New helper function that is used in
omp_target_memcpy_async for the asynchronous task.
(omp_target_memcpy_async): Added.
(omp_target_memcpy_rect): Restructured into check and copy part.
(omp_target_memcpy_rect_check): New helper function for
omp_target_memcpy_rect and omp_target_memcpy_rect_async that checks
requirements.
(omp_target_memcpy_rect_copy): New helper function for
omp_target_memcpy_rect and omp_target_memcpy_rect_async that performs
the memcpy.
(omp_target_memcpy_rect_async_helper): New helper function that is used
in omp_target_memcpy_rect_async for the asynchronous task.
(omp_target_memcpy_rect_async): Added.
* task.c (ialias): Added for GOMP_task.
* testsuite/libgomp.c-c++-common/target-memcpy-async-1.c: New test.
* testsuite/libgomp.c-c++-common/target-memcpy-async-2.c: New test.
* testsuite/libgomp.c-c++-common/target-memcpy-rect-async-1.c: New test.
* testsuite/libgomp.c-c++-common/target-memcpy-rect-async-2.c: New test.
* testsuite/libgomp.fortran/target-memcpy-async-1.f90: New test.
* testsuite/libgomp.fortran/target-memcpy-async-2.f90: New test.
* testsuite/libgomp.fortran/target-memcpy-rect-async-1.f90: New test.
* testsuite/libgomp.fortran/target-memcpy-rect-async-2.f90: New test.

2 years agolibgcc: use __builtin_clz and __builtin_ctz in libbid
Christophe Lyon [Thu, 5 May 2022 08:25:14 +0000 (09:25 +0100)]
libgcc: use __builtin_clz and __builtin_ctz in libbid

This patch replaces libbid's implementations of clz and ctz for 32 and
64 bits inputs which used several masks, and switches to the
corresponding builtins. This will provide a better implementation,
especially on targets with clz/ctz instructions.

2022-05-06  Christophe Lyon  <christophe.lyon@arm.com>

libgcc/config/libbid/ChangeLog:

* bid_binarydecimal.c (CLZ32_MASK16): Delete.
(CLZ32_MASK8): Delete.
(CLZ32_MASK4): Delete.
(CLZ32_MASK2): Delete.
(CLZ32_MASK1): Delete.
(clz32_nz): Use __builtin_clz.
(ctz32_1bit): Delete.
(ctz32): Use __builtin_ctz.
(CLZ64_MASK32): Delete.
(CLZ64_MASK16): Delete.
(CLZ64_MASK8): Delete.
(CLZ64_MASK4): Delete.
(CLZ64_MASK2): Delete.
(CLZ64_MASK1): Delete.
(clz64_nz): Use __builtin_clzl.
(ctz64_1bit): Delete.
(ctz64): Use __builtin_ctzl.

2 years agolibgcc: Add support for HF mode (aka _Float16) in libbid
Christophe Lyon [Wed, 4 May 2022 15:13:35 +0000 (16:13 +0100)]
libgcc: Add support for HF mode (aka _Float16) in libbid

This patch adds support for trunc and extend operations between HF
mode (_Float16) and Decimal Floating Point formats (_Decimal32,
_Decimal64 and _Decimal128).

For simplicity we rely on the implicit conversions inserted by the
compiler between HF and SD/DF/TF modes.  The existing bid*_to_binary*
and binary*_to_bid* functions are non-trivial and at this stage it is
not clear if there is a performance-critical use case involving _Float16
and _Decimal* formats.

The patch also adds two executable tests, to make sure the right
functions are called, available (link phase) and functional.

Tested on aarch64 and x86_64. The number of symbol matches in the
testcases includes the .global XXX to avoid having to match different
call instructions for different targets.

2022-05-04  Christophe Lyon  <christophe.lyon@arm.com>

libgcc/ChangeLog:

* Makefile.in (D32PBIT_FUNCS): Add _hf_to_sd and _sd_to_hf.
(D64PBIT_FUNCS): Add _hf_to_dd and _dd_to_hf.
(D128PBIT_FUNCS): Add _hf_to_td _td_to_hf.

libgcc/config/libbid/ChangeLog:

* bid_gcc_intrinsics.h (LIBGCC2_HAS_HF_MODE): Define according to
__LIBGCC_HAS_HF_MODE__.
(BID_HAS_HF_MODE): Define.
(HFtype): Define.
(__bid_extendhfsd): New prototype.
(__bid_extendhfdd): Likewise.
(__bid_extendhftd): Likewise.
(__bid_truncsdhf): Likewise.
(__bid_truncddhf): Likewise.
(__bid_trunctdhf): Likewise.
* _dd_to_hf.c: New file.
* _hf_to_dd.c: New file.
* _hf_to_sd.c: New file.
* _hf_to_td.c: New file.
* _sd_to_hf.c: New file.
* _td_to_hf.c: New file.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/convert-dfp-2.c: New test.
* gcc.dg/torture/convert-dfp.c: New test.

2 years agotestsuite: Add C++ unwinding tests with Decimal Floating-Point
Christophe Lyon [Tue, 3 May 2022 16:14:25 +0000 (17:14 +0100)]
testsuite: Add C++ unwinding tests with Decimal Floating-Point

These tests exercise exception handling with Decimal Floating-Point
type.

dfp-1.C and dfp-2.C check that thrown objects of such types are
properly caught, whether when using C++ classes (decimalXX) or via GCC
mode attributes.

dfp-saves-aarch64.C checks that such objects are properly restored,
and has to use the mode attribute trick because objects of decimalXX
class type cannot be assigned to a register variable.

2022-05-03  Christophe Lyon  <christophe.lyon@arm.com>

gcc/testsuite/
* g++.dg/eh/dfp-1.C: New test.
* g++.dg/eh/dfp-2.C: New test.
* g++.dg/eh/dfp-saves-aarch64.C: New test.

2 years agotestsuite: enable more BID DFP tests for AArch64
Christophe Lyon [Fri, 22 Apr 2022 16:14:56 +0000 (17:14 +0100)]
testsuite: enable more BID DFP tests for AArch64

Some tests for the BID format are currently restricted to i?86 and
x86_64, but they also pass on AArch64, so this patch enables them.

Since all these tests are related to the BID format, it seems useful
to introduce a new effective-target (dfp_bid) instead of adding
aarch64 to the current target list.

2022-04-28  Christophe Lyon  <christophe.lyon@arm.com>

gcc/
* doc/sourcebuild.texi (Decimal floating point attributes): Document
dfp_bid effective-target.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_dfp_bid): New.
* gcc.dg/dfp/bid-non-canonical-d128-1.c: Use dfp_bid
effective-target.
* gcc.dg/dfp/bid-non-canonical-d128-2.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d128-3.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d128-4.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d32-1.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d32-2.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d64-1.c: Likewise.
* gcc.dg/dfp/bid-non-canonical-d64-2.c: Likewise.

2 years agotestsuite: Add new tests for DFP under aarch64/aapcs64
Christophe Lyon [Wed, 30 Mar 2022 17:24:27 +0000 (18:24 +0100)]
testsuite: Add new tests for DFP under aarch64/aapcs64

This patch copies all existing tests involving float/double/long
double types and replaces them with _Decimal32/_Decimal64/_Decimal128.
I thought it would be clearer/easier to maintain to do it this way
rather than adding tests for DFP types in the existing testcases,
except for func-ret-1.c and func-ret-3.c.

This makes sure all cases tested for traditional floating-point are
equally tested for decimal floating-point.

The patch also adds a test involving loading DFP values from memory.

2022-03-31  Christophe Lyon  <christophe.lyon@arm.com>

gcc/testsuite/
* gcc.target/aarch64/aapcs64/aapcs64.exp: Support new dfp*.c tests.
* gcc.target/aarch64/aapcs64/func-ret-1.c: Add DFP tests.
* gcc.target/aarch64/aapcs64/func-ret-3.c: Add DFP tests.
* gcc.target/aarch64/aapcs64/type-def.h: Add DFP types.
* gcc.target/aarch64/aapcs64/dfp-1.c: New test.
* gcc.target/aarch64/aapcs64/ice_dfp_5.c: New test.
* gcc.target/aarch64/aapcs64/test_align_dfp-1.c: New test.
* gcc.target/aarch64/aapcs64/test_align_dfp-4.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_1.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_10.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_11.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_12.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_13.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_14.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_15.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_16.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_17.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_18.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_19.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_2.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_20.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_21.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_22.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_23.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_24.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_25.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_26.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_27.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_3.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_5.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_6.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_7.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_8.c: New test.
* gcc.target/aarch64/aapcs64/test_dfp_9.c: New test.
* gcc.target/aarch64/aapcs64/test_quad_double_dfp.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-1.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-10.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-11.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-12.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-13.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-14.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-16.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-2.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-3.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-4.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-5.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-6.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-8.c: New test.
* gcc.target/aarch64/aapcs64/va_arg_dfp-9.c: New test.

2 years agotestsuite:: Fix pr39986.c testcase for AArch64
Christophe Lyon [Fri, 25 Mar 2022 09:20:06 +0000 (09:20 +0000)]
testsuite:: Fix pr39986.c testcase for AArch64

The testcase in c-c++-common/dfp/pr39986.c detects if DFP constants
are correctly emitted in the assembly.  However, AArch64 uses .word
instead of the expected .long directive. With this patch, we now
accept both.

2022-03-31  Christophe Lyon <christophe.lyon@arm.com>

gcc/testsuite/
* c-c++-common/dfp/pr39986.c: Accept .word directive.

2 years agolibgcc: enable DFP for AArch64
Christophe Lyon [Wed, 23 Mar 2022 15:25:16 +0000 (15:25 +0000)]
libgcc: enable DFP for AArch64

DFP support on AArch64 relies on libgcc, so enable its DFP routines
for all AArch64 targets.

2022-03-31  Christophe Lyon  <christophe.lyon@arm.com>

libgcc/
* config.host: Add t-dfprules to AArch64 targets.

2 years agolibgcc: Enable XF mode conversions to/from DFP modes only if supported
Christophe Lyon [Wed, 23 Mar 2022 15:26:14 +0000 (15:26 +0000)]
libgcc: Enable XF mode conversions to/from DFP modes only if supported

Some targets do not support XF mode (eg AArch64), so don't build the
corresponding to/from DFP modes convertion routines if
__LIBGCC_HAS_XF_MODE__ is not defined.

2022-03-31  Christophe Lyon  <christophe.lyon@arm.com>

libgcc/config/libbid/
* _dd_to_xf.c: Check __LIBGCC_HAS_XF_MODE__.
* _sd_to_xf.c: Likewise.
* _td_to_xf.c: Likewise.
* _xf_to_dd.c: Likewise.
* _xf_to_sd.c: Likewise.
* _xf_to_td.c: Likewise.

2 years agoaarch64: Add backend support for DFP
Christophe Lyon [Fri, 11 Mar 2022 16:21:02 +0000 (16:21 +0000)]
aarch64: Add backend support for DFP

This patch updates the aarch64 backend as needed to support DFP modes
(SD, DD and TD).

Changes v1->v2:

* Drop support for DFP modes in
  aarch64_gen_{load||store}[wb]_pair as these are only used in
  prologue/epilogue where DFP modes are not used.  Drop the
  changes to the corresponding patterns in aarch64.md, and
  useless GPF_PAIR iterator.

* In aarch64_reinterpret_float_as_int, handle DDmode the same way
  as DFmode (needed in case the representation of the
  floating-point value can be loaded using mov/movk.

* In aarch64_float_const_zero_rtx_p, reject constants with DFP
  mode: when X is zero, the callers want to emit either '0' or
  'zr' depending on the context, which is not the way 0.0 is
  represented in DFP mode (in particular fmov d0, #0 is not right
  for DFP).

* In aarch64_legitimate_constant_p, accept DFP

2022-03-31  Christophe Lyon  <christophe.lyon@arm.com>

gcc/
* config/aarch64/aarch64.cc
(aarch64_split_128bit_move): Handle DFP modes.
(aarch64_mode_valid_for_sched_fusion_p): Likewise.
(aarch64_classify_address): Likewise.
(aarch64_legitimize_address_displacement): Likewise.
(aarch64_reinterpret_float_as_int): Likewise.
(aarch64_float_const_zero_rtx_p): Likewise.
(aarch64_can_const_movi_rtx_p): Likewise.
(aarch64_anchor_offset): Likewise.
(aarch64_secondary_reload): Likewise.
(aarch64_rtx_costs): Likewise.
(aarch64_legitimate_constant_p): Likewise.
(aarch64_gimplify_va_arg_expr): Likewise.
(aapcs_vfp_sub_candidate): Likewise.
(aarch64_vfp_is_call_or_return_candidate): Likewise.
(aarch64_output_scalar_simd_mov_immediate): Likewise.
(aarch64_gen_adjusted_ldpstp): Likewise.
(aarch64_scalar_mode_supported_p): Accept DFP modes if enabled.
* config/aarch64/aarch64.md
(movsf_aarch64): Use SFD iterator and rename into
mov<mode>_aarch64.
(movdf_aarch64): Use DFD iterator and rename into
mov<mode>_aarch64.
(movtf_aarch64): Use TFD iterator and rename into
mov<mode>_aarch64.
(split pattern for move TF mode): Use TFD iterator.
* config/aarch64/iterators.md
(GPF_TF_F16_MOV): Add DFP modes.
(SFD, DFD, TFD): New iterators.
(GPF_TF): Add DFP modes.
(TX, DX, DX2): Likewise.

2 years agoaarch64: Enable DFP (Decimal Floating-point) (BID format)
Christophe Lyon [Wed, 9 Mar 2022 14:27:10 +0000 (14:27 +0000)]
aarch64: Enable DFP (Decimal Floating-point) (BID format)

This patch enables DFP support on aarch64, by updating config/dfp.m4
and regenerating the involved configure scripts.
We enable the BID format.

2022-03-31  Christophe Lyon  <christophe.lyon@arm.com>

config/
* dfp.m4: Add aarch64 support.
gcc/
* configure: Regenerate.
libdecnumber/
* configure: Regenerate.
libgcc/
* configure: Regenerate.

2 years agoDisable snapshots from gcc-9
Richard Biener [Fri, 20 May 2022 07:11:55 +0000 (09:11 +0200)]
Disable snapshots from gcc-9

GCC 9 nears its end.

2022-05-20  Richard Biener  <rguenther@suse.de>

maintainer-scripts/
* crontab: Disable snapshots from the gcc-9 branch.

2 years agoDaily bump.
GCC Administrator [Fri, 20 May 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Avoid including <cstdint> for std::char_traits
Jonathan Wakely [Thu, 19 May 2022 11:50:28 +0000 (12:50 +0100)]
libstdc++: Avoid including <cstdint> for std::char_traits

We should prefer the __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__
macros, if available, so that we don't need all of <cstdint> in every
header that uses std::char_traits.

libstdc++-v3/ChangeLog:

* include/bits/char_traits.h: Only include <cstdint> when
necessary.
* include/std/stacktrace: Use __UINTPTR_TYPE__ instead of
uintptr_t.
* src/c++11/cow-stdexcept.cc: Include <stdint.h>.
* src/c++17/floating_to_chars.cc: Likewise.
* testsuite/20_util/assume_aligned/1.cc: Include <cstdint>.
* testsuite/20_util/assume_aligned/3.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/array.cc: Likewise.

2 years agolibstdc++: Only include <ext/atomicity.h> for COW string
Jonathan Wakely [Thu, 19 May 2022 11:54:41 +0000 (12:54 +0100)]
libstdc++: Only include <ext/atomicity.h> for COW string

Since the COW std::string was moved to its own header, we don't need the
atomic dispatch helpers in the definition of std::__cxx11::string. Move
the inclusion of the <ext/atomicity.h> header to <bits/cow_string.h>
where it's needed.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Do not include <ext/atomicity.h>
here.
* include/bits/cow_string.h: Include it here.

2 years agolibstdc++: Ensure pmr aliases work without <memory_resource>
Jonathan Wakely [Thu, 19 May 2022 22:38:23 +0000 (23:38 +0100)]
libstdc++: Ensure pmr aliases work without <memory_resource>

Currently the alias templates for std::pmr::vector, std::pmr::string
etc. are defined using a forward declaration for polymorphic_allocator.
This means you can't actually use the alias templates unless you also
include <memory_resource>. The rationale for that is that it's a fairly
large header, and most users don't need it. This isn't uncontroversial
though, and LWG 3681 questions whether it's even conforming.

This change adds a new <bits/memory_resource.h> header with the minimum
needed to use polymorphic_allocator and the std::pmr container aliases.
Including <memory_resource> is still necessary to use the program-wide
resource objects, or the pool resources or monotonic buffer resource.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/memory_resource.h: New file.
* include/std/deque: Include <bits/memory_resource.h>.
* include/std/forward_list: Likewise.
* include/std/list: Likewise.
* include/std/map: Likewise.
* include/std/memory_resource (pmr::memory_resource): Move to
new <bits/memory_resource.h> header.
(pmr::polymorphic_allocator): Likewise.
* include/std/regex: Likewise.
* include/std/set: Likewise.
* include/std/stacktrace: Likewise.
* include/std/string: Likewise.
* include/std/unordered_map: Likewise.
* include/std/unordered_set: Likewise.
* include/std/vector: Likewise.
* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
Remove <memory_resource> header and check construction.
* testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/forward_list/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/list/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/map/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/set/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/unordered_map/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_set/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/vector/pmr_typedefs.cc: Likewise.
* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-tuple.C: Qualify function to avoid ADL
finding std::make_tuple.

2 years agoPR middle-end/98865: Expand X*Y as X&-Y when Y is [0,1].
Roger Sayle [Thu, 19 May 2022 16:54:38 +0000 (17:54 +0100)]
PR middle-end/98865: Expand X*Y as X&-Y when Y is [0,1].

The patch is a revised solution for PR middle-end/98865 incorporating
the feedback/suggestions from Richard Biener's review here:
https://gcc.gnu.org/pipermail/gcc-patches/2022-May/593928.html
Most significantly, this patch now performs the transformation/optimization
during RTL expansion, where the target's rtx_costs can be used to determine
whether the original multiplication (that may potentially be implemented by
a shift or lea) is cheaper than a negation and a bit-wise and.

Previously the expression (x>>63)*y would be compiled with -O2 as
        shrq    $63, %rdi
        movq    %rdi, %rax
        imulq   %rsi, %rax

but with this patch now produces:
        sarq    $63, %rdi
        movq    %rdi, %rax
        andq    %rsi, %rax

Likewise the expression (x>>63)*135 [that appears in a hot-spot of the
Botan AES-128 benchmark] was previously:

        shrq    $63, %rdi
        leaq    (%rdi,%rdi,8), %rdx
        movq    %rdx, %rax
        salq    $4, %rax
        subq    %rdx, %rax

now becomes:
        movq    %rdi, %rax
        sarq    $63, %rax
        andl    $135, %eax

2022-05-19  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR middle-end/98865
* expr.cc (expand_expr_real_2) [MULT_EXPR]:  Expand X*Y as X&Y
when both X and Y are [0, 1], X*Y as X&-Y when Y is [0,1] and
likewise X*Y as -X&Y when X is [0,1] using tree_nonzero_bits.

gcc/testsuite/ChangeLog
PR middle-end/98865
* gcc.target/i386/pr98865.c: New test case.

2 years ago[PATCH, rs6000] Remove the (no longer used) BTC defines.
Will Schmidt [Mon, 9 May 2022 22:05:50 +0000 (17:05 -0500)]
[PATCH, rs6000] Remove the (no longer used) BTC defines.

These defines are no longer used once the rs6000 built-in
reworks were completed.   Time to remove them.

There was a reference to RS6000_BTC_SPECIAL in a TODO comment
in rs6000-builtins.def.  That comment remains, but I have updated
the comment to refer to "SPECIAL" processing, instead of having it
refer directly to the _BTC_SPECIAL macro.

2022-05-18  Will Schmidt  <will_schmidt@vnet.ibm.com>

gcc/
* config/rs6000/rs6000-builtins.def: Rephrase
to remove RS6000_BTC_SPECIAL from comment.
* config/rs6000/rs6000.h (RS6000_BTC_UNARY, RS6000_BTC_BINARY,
RS6000_BTC_TERNARY, RS6000_BTC_QUATERNARY,
RS6000_BTC_QUINARY, RS6000_BTC_SENARY, RS6000_BTC_OPND_MASK,
RS6000_BTC_SPECIAL, RS6000_BTC_PREDICATE, RS6000_BTC_ABS,
RS6000_BTC_DST, RS6000_BTC_TYPE_MASK, RS6000_BTC_MISC,
RS6000_BTC_CONST, RS6000_BTC_PURE, RS6000_BTC_FP,
RS6000_BTC_QUAD, RS6000_BTC_PAIR, RS6000_BTC_QUADPAIR,
RS6000_BTC_ATTR_MASK, RS6000_BTC_SPR, RS6000_BTC_VOID,
RS6000_BTC_CR, RS6000_BTC_OVERLOADED, RS6000_BTC_GIMPLE,
RS6000_BTC_MISC_MASK, RS6000_BTC_MEM, RS6000_BTC_SAT,
RS6000_BTM_ALWAYS): Delete.

2 years agolibstdc++: Implement LWG 3683 for pmr::polymorphic_allocator
Jonathan Wakely [Thu, 19 May 2022 12:26:49 +0000 (13:26 +0100)]
libstdc++: Implement LWG 3683 for pmr::polymorphic_allocator

This issue has recently been moved to Tentatively Ready, and seems
uncontroversial. This allows equality comparison with types that are
convertible to pmr::polymorphic_allocator, which fail deduction for the
existing equality operator.

libstdc++-v3/ChangeLog:

* include/std/memory_resource (polymorphic_allocator): Add
non-template equality operator, as proposed for LWG 3683.
* testsuite/20_util/polymorphic_allocator/lwg3683.cc: New test.

2 years agoFix OMP CAS expansion with separate condition
Richard Biener [Fri, 13 May 2022 10:07:58 +0000 (12:07 +0200)]
Fix OMP CAS expansion with separate condition

When forcing the condition to be split out from COND_EXPRs I see
a runtime failure of libgomp.fortran/atomic-19.f90 which can be
reduced to

  !$omp atomic update, compare, capture
  if (x == 69_2 - r) x = 6_8
    v = x

being miscompiled, the difference being

-  _13 = .ATOMIC_COMPARE_EXCHANGE (_9, _10, _11, 4, 0, 0);
-  _14 = IMAGPART_EXPR <_13>;
-  _15 = REALPART_EXPR <_13>;
-  _16 = _14 != 0 ? _11 : _15;
-  _2 = (integer(kind=4)) _16;
-  v_17 = _2;
+  _14 = .ATOMIC_COMPARE_EXCHANGE (_10, _11, _12, 4, 0, 0);
+  _15 = IMAGPART_EXPR <_14>;
+  _16 = REALPART_EXPR <_14>;
+  _2 = (logical(kind=1)) _15;
+  _3 = (integer(kind=4)) _16;
+  v_17 = _3;

where one can see a missing COND_EXPR.  It seems to be a latent
issue to me given the code can be exercised, it just maybe misses
a 'need_new' testcase combined with 'cond_stmt'.  Appearantly
the if (cond_stmt) code is just to avoid creating a temporary
(and possibly to preserve the condition compute if used elsewhere
since the original stmt is going to be deleted).  The following
makes the failure go away for me in my patched tree and it
also survives libgomp and gomp testing in an unpatched tree.

2022-05-13  Richard Biener  <rguenther@suse.de>

* omp-expand.cc (expand_omp_atomic_cas): Do not short-cut
computation of the new value.

2 years agoRemove get_or_alloc_expression_id
Richard Biener [Thu, 19 May 2022 13:23:32 +0000 (15:23 +0200)]
Remove get_or_alloc_expression_id

This function is no longer needed.

2022-05-19  Richard Biener  <rguenther@suse.de>

* tree-ssa-pre.cc (get_or_alloc_expression_id): Remove.
(add_to_value): Use get_expression_id.
(bitmap_insert_into_set): Likewise.
(bitmap_value_insert_into_set): Likewise.

2 years ago[Ada] Avoid copy operation for returns involving function calls
Eric Botcazou [Tue, 12 Apr 2022 21:34:48 +0000 (23:34 +0200)]
[Ada] Avoid copy operation for returns involving function calls

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Constant>: Deal with
a constant related to a return in a function specially.
* gcc-interface/trans.cc (Call_to_gnu): Use return slot optimization
if the target is a return object.
(gnat_to_gnu) <N_Object_Declaration>: Deal with a constant related
to a return in a function specially.

2 years ago[Ada] Do not give warnings for compiler-generated entities by default
Eric Botcazou [Wed, 23 Mar 2022 13:46:28 +0000 (14:46 +0100)]
[Ada] Do not give warnings for compiler-generated entities by default

The rationale is that these entities are almost always the result of
expansion activities in the front-end, over which the user has very
limited control.  These warnings can be restored by means of -gnatD.

gcc/ada/

* gcc-interface/utils.cc (gnat_pushdecl): Also set TREE_NO_WARNING
on the decl if Comes_From_Source is false for the associated node.

2 years ago[Ada] Small housekeeping work in gnat_gimplify_expr
Eric Botcazou [Wed, 23 Mar 2022 13:35:40 +0000 (14:35 +0100)]
[Ada] Small housekeeping work in gnat_gimplify_expr

This alphabetizes the large switch statement, removes a useless nested
switch statement, an artificial fall through and adds a default return.

No functional changes.

gcc/ada/

* gcc-interface/trans.cc (gnat_gimplify_expr): Tidy up.

2 years ago[Ada] Add support for "simd" function attribute
Eric Botcazou [Fri, 18 Mar 2022 10:16:06 +0000 (11:16 +0100)]
[Ada] Add support for "simd" function attribute

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Function>: Also call
process_attributes for built-in functions.
(prepend_one_attribute_pragma): Deal with "simd" attribute.
* gcc-interface/utils.cc (handle_simd_attribute): New function.
(gnat_internal_attribute_table): Add entry for "simd" attribute.

2 years ago[Ada] Fix internal error on unchecked union with component clauses (2)
Eric Botcazou [Wed, 2 Mar 2022 16:28:14 +0000 (17:28 +0100)]
[Ada] Fix internal error on unchecked union with component clauses (2)

The issue arises when the unchecked union contains both a fixed part and
a variant part, and is subject to a full representation clause covering
all the components in all the variants, when the component clauses do not
align the variant boundaries with byte boundaries consistently.

gcc/ada/

* gcc-interface/decl.cc (components_to_record): Use NULL recursively
as P_GNU_REP_LIST for the innermost variant level in the unchecked
union case with a fixed part.

2 years ago[Ada] Do not set Current_Error_Node to a node without location
Eric Botcazou [Sat, 19 Feb 2022 11:20:50 +0000 (12:20 +0100)]
[Ada] Do not set Current_Error_Node to a node without location

The message "No source file position information available" is displayed
in the bugbox when Current_Error_Node has no location, which is useless.

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Do not set Current_Error_Node
to a node without location.

2 years ago[Ada] Fix internal error on semi-circular record types
Eric Botcazou [Wed, 16 Feb 2022 17:07:26 +0000 (18:07 +0100)]
[Ada] Fix internal error on semi-circular record types

The front-end properly computes a linear elaboration order for them, but
there was a loophole in the handling of the delayed case.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Access_Subtype>: And
skip the elaboration of the designated subtype when that of its base
type has been delayed.

2 years ago[Ada] Fix for internal error on semi-circular record aggregate
Eric Botcazou [Thu, 10 Feb 2022 11:37:56 +0000 (12:37 +0100)]
[Ada] Fix for internal error on semi-circular record aggregate

This creates a couple of record subtypes pointing to each other through
access subtypes, and we break the circularity at the latter subtypes.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: If
it is a special subtype designated by an access subtype, then defer
the completion of incomplete types.

2 years ago[Ada] Adjust copyright line
Eric Botcazou [Tue, 8 Feb 2022 20:18:58 +0000 (21:18 +0100)]
[Ada] Adjust copyright line

gcc/ada/

* gcc-interface/ada-tree.h, gcc-interface/ada.h,
gcc-interface/gadaint.h, gcc-interface/targtyps.cc: Adjust
copyright line.

2 years ago[Ada] Preserve unchecked conversion of string constant
Eric Botcazou [Sun, 16 Jan 2022 13:09:20 +0000 (14:09 +0100)]
[Ada] Preserve unchecked conversion of string constant

This makes it possible to pass the result to a C function directly.

gcc/ada/

* gcc-interface/utils.cc (unchecked_convert): Do not fold a string
constant if the target type is pointer to character.

2 years ago[Ada] Remove redundant marking of illegal pragma with error posted
Piotr Trojanek [Sat, 16 Apr 2022 12:38:54 +0000 (14:38 +0200)]
[Ada] Remove redundant marking of illegal pragma with error posted

We flag illegal pragma Elaborate with a call to Error_Msg on the pragma
argument, which in turn calls Set_Error_Posted on the enclosing
statement, i.e. on the pragma itself. The explicit call to
Set_Error_Posted on the pragma itself was redundant.

Cleanup related to handling of illegal code when detecting uninitialized
scalar objects.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Remove redundant call to
Set_Error_Posted.

2 years ago[Ada] Fix continuation message without a prior error
Piotr Trojanek [Fri, 15 Apr 2022 08:44:37 +0000 (10:44 +0200)]
[Ada] Fix continuation message without a prior error

When resolution of an expanded name fails, we call routine
Error_Missing_With_Of_Known_Unit which emits an error continuation
message (i.e. an error string starting with \\). However, for error
continuations to work properly there must be some prior error, because
continuation itself doesn't set flags like Serious_Errors_Detected.

Without these flags the problematic statement is not marked with
Error_Posted, which in turn is needed to prevent cascaded errors.

In particular, when unresolved procedure call uses a direct name or an
extended name with an unknown prefix, e.g.:

  Unknown (1, 2, 3);
  Unknown.Call (1, 2, 3);

then the N_Procedure_Call statements are marked with Error_Posted. But
when a call uses an extended name with a known prefix we failed to flag
the N_Procedure_Call with Error_Posted.

Found while improving the robustness of a feature that detects
uninitialized scalar objects.

gcc/ada/

* sem_ch8.adb (Find_Expanded_Name): Emit a main error message
before adding a continuation with the call to
Error_Missing_With_Of_Known_Unit.

2 years ago[Ada] Mark Requires_Transient_Scope as Inline
Eric Botcazou [Fri, 15 Apr 2022 06:48:30 +0000 (08:48 +0200)]
[Ada] Mark Requires_Transient_Scope as Inline

The predicate is now a simple disjunction of two other predicates.

gcc/ada/

* sem_util.ads (Requires_Transient_Scope): Add pragma Inline.

2 years ago[Ada] Avoid internal compiler error for illegal Predicate_Failure aspect spec
Steve Baird [Thu, 14 Apr 2022 20:24:15 +0000 (13:24 -0700)]
[Ada] Avoid internal compiler error for illegal Predicate_Failure aspect spec

gcc/ada/

* sem_ch13.adb (Build_Predicate_Functions): If a semantic error
has been detected then ignore Predicate_Failure aspect
specifications in the same way as is done for CodePeer and
SPARK. This avoids an internal compiler error if
Ancestor_Predicate_Function_Called is True but Result_Expr is
not an N_And_Then node (and is therefore unsuitable as an
argument in a call to Left_Opnd).

2 years ago[Ada] Fix spurious violations of No_Secondary_Stack restriction
Eric Botcazou [Thu, 14 Apr 2022 15:31:44 +0000 (17:31 +0200)]
[Ada] Fix spurious violations of No_Secondary_Stack restriction

Now that finalization and return on the secondary stack are decoupled, the
transient scopes created because of the former need not necessarily manage
the secondary stack and trigger a violation of the associated restriction.

gcc/ada/

* exp_ch7.adb (Wrap_Transient_Declaration): Propagate Uses_Sec_Stack
to enclosing function if it does not return on the secondary stack.
* exp_ch6.adb (Expand_Call_Helper): Call Establish_Transient_Scope
with Manage_Sec_Stack set to True only when necessary.
* sem_res.adb (Resolve_Call): Likewise.
(Resolve_Entry_Call): Likewise.

2 years ago[Ada] Ignore Predicate_Failure in CodePeer mode
Daniel Mercier [Thu, 14 Apr 2022 15:36:17 +0000 (17:36 +0200)]
[Ada] Ignore Predicate_Failure in CodePeer mode

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function): Ignore predicate
failure in CodePeer mode.

2 years ago[Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows
Arnaud Charlet [Thu, 14 Apr 2022 11:13:39 +0000 (11:13 +0000)]
[Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows

This is needed in particular by GNAT LLVM builds.

gcc/ada/

* raise-gcc.c: Fix compilation with -DSTANDALONE under windows.

2 years ago[Ada] Preserve and reuse original type in Narrow_Large_Operation
Eric Botcazou [Thu, 14 Apr 2022 11:08:38 +0000 (13:08 +0200)]
[Ada] Preserve and reuse original type in Narrow_Large_Operation

Instead of using that of Original_Node (N) after rewriting, which does not
work if N had previously been rewritten.

gcc/ada/

* exp_ch4.adb (Narrow_Large_Operation): Preserve and reuse Etype.

2 years ago[Ada] Wrong interface dynamic dispatch via access parameter
Javier Miranda [Wed, 13 Apr 2022 16:27:59 +0000 (16:27 +0000)]
[Ada] Wrong interface dynamic dispatch via access parameter

When the prefix of an Access attribute is an explicit dereference of an
access parameter (or a renaming of such a dereference, or a subcomponent
of such a dereference), the context is a general access type to a
class-wide interface type, and an accessibility check must be generated,
the frontend silently skips generating an implicit type conversion to
force the displacement of the pointer to reference the secondary
dispatch table.

gcc/ada/

* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): New
subprogram which factorizes code.
(Expand_N_Attribute_Reference): Call the new subprogram to add
the missing implicit interface type conversion.

2 years ago[Ada] Ignore Predicate_Failure in GNATprove mode
Piotr Trojanek [Wed, 13 Apr 2022 19:39:38 +0000 (21:39 +0200)]
[Ada] Ignore Predicate_Failure in GNATprove mode

In GNATprove mode we are don't want predicate failure to pollute the
predicate expression extracted from the predicate function.

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function): Ignore predicate
failure in GNATprove mode.

2 years ago[Ada] Fix bug in handling of Predicate_Failure aspect
Steve Baird [Tue, 5 Apr 2022 00:52:11 +0000 (17:52 -0700)]
[Ada] Fix bug in handling of Predicate_Failure aspect

The run-time behavior of the Ada 2022 Predicate_Failure aspect was
incorrectly implemented. This could cause incorrect exception messages
at execution time in the case of a predicate check failure, as
demonstrated by ACATS test C324006. In addition, a new attribute
(Predicate_Expression) is defined in order to improve the FE/SPARK
interface.

gcc/ada/

* einfo-utils.ads, einfo-utils.adb: Delete Predicate_Function_M
function and Set_Predicate_Function_M procedure.
* einfo.ads: Delete comments for Is_Predicate_Function_M and
Predicate_Function_M functions. Add comment for new
Predicate_Expression function. Update comment describing
predicate functions.
* exp_util.ads, exp_util.adb (Make_Predicate_Call): Replace Mem
formal parameter with Static_Mem and Dynamic_Mem formals.
(Make_Predicate_Check): Delete Add_Failure_Expression and call
to it.
* exp_ch4.adb (Expand_N_In.Predicate_Check): Update
Make_Predicate_Call call to match profile change.
* gen_il-fields.ads: Delete Is_Predicate_Function_M field, add
Predicate_Expression field.
* gen_il-gen-gen_entities.adb: Delete Is_Predicate_Function_M
use, add Predicate_Expression use.
* sem_ch13.adb (Build_Predicate_Functions): Rename as singular,
not plural; we no longer build a Predicate_M function. Delete
Predicate_M references. Add new Boolean parameter for predicate
functions when needed. Restructure body of generated predicate
functions to implement required Predicate_Failure behavior and
to set new Predicate_Expression attribute. Remove special
treatment of raise expressions within predicate expressions.
* sem_util.ads (Predicate_Failure_Expression,
Predicate_Function_Needs_Membership_Parameter): New functions.
* sem_util.adb (Is_Current_Instance): Fix bugs which caused
wrong result.
(Is_Current_Instance_Reference_In_Type_Aspect): Delete
Is_Predicate_Function_M reference.
(Predicate_Failure_Expression): New function.
(Propagate_Predicate_Attributes): Delete Is_Predicate_Function_M
references.

2 years ago[Ada] Avoid copy operation for returns involving function calls
Eric Botcazou [Tue, 12 Apr 2022 19:56:35 +0000 (21:56 +0200)]
[Ada] Avoid copy operation for returns involving function calls

The underlying issue is that the front-end does not create transient scopes
for return statements, so objects copied for these statements can never be
finalized properly.

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Adjust comment.
(Expand_Simple_Function_Return): For the case of a type which needs
finalization and is returned on the primary stack, do not create a
copy if the expression originates from a function call.
* exp_ch7.adb (Transient Scope Management): Adjust comment.
* exp_util.ads (Is_Related_To_Func_Return): Add WARNING line.
* fe.h (Is_Related_To_Func_Return): Declare.

2 years ago[Ada] Fix invalid expanded code for entry families
Piotr Trojanek [Tue, 12 Apr 2022 20:22:40 +0000 (22:22 +0200)]
[Ada] Fix invalid expanded code for entry families

Expansion of entry families created a slightly illegal AST with
Elsif_Parts being an empty list. Cleanup uncovered by the work on
detection of uninitialized scalars.

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove empty Elsif_Parts
from the constructed IF statement.

2 years ago[Ada] Cleanup expansion of protected entry families
Piotr Trojanek [Tue, 12 Apr 2022 19:46:36 +0000 (21:46 +0200)]
[Ada] Cleanup expansion of protected entry families

Expansion of entry families contained a condition that was always true.
Cleanup related to detection of uninitialized scalar objects (which
uncovered that expansion of entry families creates a slightly illegal
AST with Elsif_Parts being an empty list).

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove IF statement whose
condition was true-by-construction; remove excessive assertion
(since the call to Elsif_Parts will check that Nod is present
and it is an if-statement).

2 years ago[Ada] Remove remaining references to gnatfind/gnatxref
Arnaud Charlet [Tue, 12 Apr 2022 09:29:31 +0000 (09:29 +0000)]
[Ada] Remove remaining references to gnatfind/gnatxref

gcc/ada/

* gnat1drv.adb, gnatcmd.adb: Remove references to gnatfind/xref.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst,
doc/gnat_ugn/the_gnat_compilation_model.rst: Ditto.
* gnat_ugn.texi: Regenerate.
* gnatfind.adb, gnatxref.adb, xr_tabls.adb, xr_tabls.ads,
xref_lib.adb, xref_lib.ads: Removed, no longer used.

2 years ago[Ada] Fix proof of runtime unit a-strfix and a-strsup
Claire Dross [Tue, 12 Apr 2022 08:57:31 +0000 (10:57 +0200)]
[Ada] Fix proof of runtime unit a-strfix and a-strsup

Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

* libgnat/a-strfix.adb: Add assertions.
* libgnat/a-strsup.adb: Idem.

2 years ago[Ada] Support Ada 2022 null array aggregates
Ed Schonberg [Fri, 8 Apr 2022 17:48:10 +0000 (10:48 -0700)]
[Ada] Support Ada 2022 null array aggregates

Add support for Ada 2022's "[]" null array aggregates (thanks to Ed
Schonberg for producing most of this patch).

gcc/ada/

* erroutc.ads: Fix a single-character typo in a comment.
* exp_aggr.adb: Fix a single-character typo in a comment.
Replace several pairs of calls to Low_Bound and
High_Bound (which do not handle an identifier that denotes a
scalar subtype) with corresponding calls to Get_Index_Bounds
(which does handle that case).
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Set the
Component_Associations attribute of a null array aggregate to
New_List.
* sem_aggr.ads: New visible function
Is_Null_Array_Aggregate_High_Bound.
* sem_aggr.adb (Is_Null_Array_Aggregate_High_Bound,
Is_Null_Aggregate, Resolve_Null_Array_Aggregate): New functions.
(Resolve_Aggregate): Recognize null array aggregates (using
Is_Null_Aggregate) and, when one is recognized, resolve
it (using Resolve_Null_Array_Aggregate).  Avoid calling
Array_Aggr_Subtype for a null array aggregate; the needed
subtype is built in Resolve_Null_Array_Aggregate. Do not
incorrectly flag a null aggregate (after it is transformed by
expansion) as being both positional and named.
* sem_attr.adb (Eval_Attribute): Special treatment for null
array aggregate high bounds to avoid incorrectly flagging
something like Integer'Pred (Integer'First) as an illegal static
expression.
* sem_eval.adb (Out_Of_Range): Special treatment for null array
aggregate high bounds to avoid incorrectly flagging something
like Integer'Pred (Integer'First) as an illegal static
expression.

2 years ago[Ada] Further adapt proof of double arithmetic runtime unit
Yannick Moy [Mon, 11 Apr 2022 15:56:01 +0000 (15:56 +0000)]
[Ada] Further adapt proof of double arithmetic runtime unit

After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

* libgnat/s-aridou.adb (Lemma_Abs_Range,
Lemma_Double_Shift_Left, Lemma_Shift_Left): New lemmas.
(Double_Divide): Add ghost code.
(Lemma_Concat_Definition, Lemma_Double_Shift_Left,
Lemma_Shift_Left, Lemma_Shift_Right): Define or complete lemmas.
(Scaled_Divide): Add ghost code.

2 years ago[Ada] Improve optimization of "=" on bit-packed arrays
Bob Duff [Thu, 7 Apr 2022 17:23:20 +0000 (13:23 -0400)]
[Ada] Improve optimization of "=" on bit-packed arrays

This patch fixes a performance regression, introduced by a previous bug
fix.  That fix had the unintended side effect of removing the
optimization in cases where the two operands are of two different
compiler-generated modular types.

gcc/ada/

* exp_pakd.adb (Expand_Packed_Eq): Replace the check for *same*
modular type, with a check for any modular type, and assert that
the two types have the same modulus and so on.
* exp_pakd.ads: Minor comment improvements.

2 years ago[Ada] Casing style on record components
Bob Duff [Thu, 7 Apr 2022 14:59:32 +0000 (10:59 -0400)]
[Ada] Casing style on record components

This patch fixes a bug where the -gnatyr switch fails to detect
incorrect casing of record components.

gcc/ada/

* style.adb (Check_Identifier): Deal with the case where a
record component definition has been transformed; we want to
warn if the original came from source.
* libgnat/s-objrea.ads, libgnat/s-objrea.adb: Fix casing of MF
to be consistent.
* uname.adb: Fix casing of Chars to be consistent.
* sem_util.ads: Minor comment fix.

2 years ago[Ada] Get rid of secondary stack for controlled components
Eric Botcazou [Sat, 9 Apr 2022 22:47:48 +0000 (00:47 +0200)]
[Ada] Get rid of secondary stack for controlled components

This eliminates the use of the secondary stack to return composite types
with controlled components from functions, by exposing the return slot of
these functions through the support interface of memory pools, much like
for the secondary stack itself.  This is piggybacked on the support of a
specific intrinsic function by the code generator, and can be disabled if
this support is not available, as well with the -gnatd_r debug switch.

The change also streamlines a bit the implementation by consistently using
the Needs_Finalization predicate, or its derivatives, in various places.

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-retsta.
* debug.adb (d_r): Document usage.
* exp_ch4.adb (Expand_N_Allocato): Deal with the return stack pool.
* exp_ch6.adb (Expand_Simple_Function_Return): Replace calls to
Requires_Transient_Scope with Returns_On_Secondary_Stack.  Deal
with types that need finalization returned on the primary stack,
use CW_Or_Needs_Finalization for those returned on the secondary.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Return early
for the return stack pool.
(Remove_Side_Effects): Call CW_Or_Needs_Finalization.
* fe.h (Requires_Transient_Scope): Delete.
(Returns_On_Secondary_Stack): Declare.
* gnat1drv.adb (Adjust_Global_Switches): Set Back_End_Return_Slot
to False when generating C code or if -gnatd_r is specified.
* opt.ads (Back_End_Return_Slot): New boolean variable.
* rtsfind.ads (RTU_Id): Add System_Return_Stack.
(RE_Id): Add RE_RS_Allocate and RE_RS_Pool.
(RE_Unit_Table): Add entries for RE_RS_Allocate and RE_RS_Pool.
* sem_util.ads (CW_Or_Has_Controlled_Part): Delete.
(CW_Or_Needs_Finalization): Declare.
(Requires_Transient_Scope): Adjust description.
(Returns_On_Secondary_Stack): Declare.
* sem_util.adb (Compute_Returns_By_Ref): Set Returns_By_Ref on types
which need finalization if they are returned on the secondary stack.
(CW_Or_Has_Controlled_Part): Rename to...
(CW_Or_Needs_Finalization): ...this.
(Requires_Transient_Scope): Move bulk of implementation to...
(Returns_On_Secondary_Stack): ...here.  Return true for types which
need finalization only if the back-end return slot is not supported.
* libgnat/s-retsta.ads: New file.
* gcc-interface/ada-builtin-types.def (BT_FN_PTR_SSIZE): Define.
* gcc-interface/ada-builtins.def (return_slot): Likewise.
* gcc-interface/ada-tree.h (BUILT_IN_RETURN_SLOT): Likewise.
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Replace call to
Requires_Transient_Scope with Returns_On_Secondary_Stack.
* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return by invisible reference, skip the copy if the source
is the same as the destination.
* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Deal with
the return stack pool.

2 years ago[Ada] Small housekeeping work continued
Eric Botcazou [Sat, 2 Apr 2022 21:26:57 +0000 (23:26 +0200)]
[Ada] Small housekeeping work continued

No functional changes.

gcc/ada/

* gcc-interface/trans.cc: Fix formatting issues in comments.
(Subprogram_Body_to_gnu): Tidy up.
(Exception_Handler_to_gnu_gcc): Rename into...
(Exception_Handler_to_gnu): ...this.
(gnat_to_gnu) <N_Exception_Handler>: Adjust to above renaming.

2 years ago[Ada] Small housekeeping work
Eric Botcazou [Thu, 31 Mar 2022 20:38:54 +0000 (22:38 +0200)]
[Ada] Small housekeeping work

No functional changes.

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Rename a couple
of local variables and use Is_Generic_Subprogram predicate.
(process_decls): Likewise.

2 years ago[Ada] Do not override inlining heuristics for expression functions at -Os
Eric Botcazou [Thu, 27 Jan 2022 16:18:28 +0000 (17:18 +0100)]
[Ada] Do not override inlining heuristics for expression functions at -Os

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Do not deal with
inlining heuristics for expression functions here but...
* gcc-interface/decl.cc (inline_status_for_subprog): ...here instead
and do not override them at -Os.

2 years ago[Ada] Remove dead code for scope entity having E_Subprogram_Body kind
Piotr Trojanek [Thu, 3 Feb 2022 14:11:26 +0000 (15:11 +0100)]
[Ada] Remove dead code for scope entity having E_Subprogram_Body kind

In GNAT AST the Scope field always points to the semantic scope (e.g.
subprogram) and never to syntactic scope (e.g. subprogram body).

Cleanup related to handling of circular access-to-record types.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity): Remove dead code
which expected Scope to return E_Subprogram_Body entity.

2 years agoPR105647 Update pr105169* so it does not fail on powerpc64le
Giuliano Belinassi [Wed, 18 May 2022 19:16:48 +0000 (16:16 -0300)]
PR105647 Update pr105169* so it does not fail on powerpc64le

On powerpc64le, the tests related to pr105169 failed because the
.localentry was not on a power of two address due to the extra nop
instruction taking one byte and thus moving its position one byte
further. Generating two nops instead moves .localentry to a valid
position.

gcc/testsuite/ChangeLog
2022-05-18  Giuliano Belinassi  <gbelinassi@suse.de>

PR target/105647
* g++.dg/modules/pr105169_a.C: Change -fpatchable-function-entry to 2.
* g++.dg/modules/pr105169_b.C: Likewise.

2 years agoanalyzer: update docs about -fanalyzer-checker=taint
David Malcolm [Thu, 19 May 2022 12:50:54 +0000 (08:50 -0400)]
analyzer: update docs about -fanalyzer-checker=taint

gcc/ChangeLog:
* doc/invoke.texi (-fanalyzer-checker=): Add
-Wanalyzer-va-list-leak and -Wanalyzer-va-list-use-after-va-end to
the list of analyzer warnings disabled by
-fanalyzer-checker=taint.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agocfgexpand: Yet another spot with debug insns references to global vars without varpoo...
Jakub Jelinek [Thu, 19 May 2022 09:58:15 +0000 (11:58 +0200)]
cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630]

This is similar to the earlier patch to avoid having MEM_EXPRs
referencing global vars without varpool nodes, but this time
the difference is that during gimplification some hashing
actually created DECL_RTLs for the n VAR_DECL and the previous
change was in the if above this when DECL_RTL is NULL and we are
considering creating it.

The following patch drops on the floor references to vars where
we've optimized away the varpool node even when it has DECL_RTL.

Bootstrapped/regtested on x86_64-linux and i686-linux, plus
bootstrapped on those without the cfgexpand.cc change, reapplied
it and rebuilt stage3 cc1/cc1plus, the resulting cc1/cc1plus
binaries on both targets were identical except for the 16-byte
executable_checksum (I've done the second bootstraps in the same
directory as the first one after moving the previous one elsewhere,
so pathnames were the same, just checksum hasn't been regenerated).
So, at least on those binaries this patch doesn't affect debug info
at all.

2022-05-19  Jakub Jelinek  <jakub@redhat.com>

PR debug/105630
* cfgexpand.cc (expand_debug_expr): For VAR_DECL, punt for
global vars without symtab node even when they have DECL_RTL
set.

* gcc.dg/pr105630.c: New test.

2 years agopointer-query: Fix ICE with non-pointer param [PR105635]
Jakub Jelinek [Thu, 19 May 2022 09:56:21 +0000 (11:56 +0200)]
pointer-query: Fix ICE with non-pointer param [PR105635]

The gimple_parm_array_size function comment talks about pointe parameters
but doesn't actually verify it, it checks whether an attribute is present
on the function and then just uses TREE_TYPE (TREE_TYPE (var)) which
assumes a pointer type (or in theory could work for ARRAY_TYPE but
c-family languages which only have that attribute will never have ARRAY_TYPE
parameters; and for VECTOR_TYPE/COMPLEX_TYPE it would mean something quite
different).

So, this patch punts early if var doesn't have pointer/reference type.

2022-05-19  Jakub Jelinek  <jakub@redhat.com>

PR c/105635
* pointer-query.cc (gimple_parm_array_size): Return NULL if var
doesn't have pointer or reference type.

* gcc.dg/pr105635.c: New test.

2 years agocompiler: traverse expressions when exporting constants
Julia Lapenko [Mon, 16 May 2022 07:37:49 +0000 (10:37 +0300)]
compiler: traverse expressions when exporting constants

When exporting a constant A that is expressed through a constant
B from another package, it is necessary to traverse an expression
representing the constant A to generate a sequence of type casts
from the constant B. Current implementation doesn't collect types
of constants contained in such expressions. This change fetches
these types.

Fixes golang/go#51291

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405976

2 years agoDaily bump.
GCC Administrator [Thu, 19 May 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.

2 years agoc: Implement new -Wenum-int-mismatch warning [PR105131]
Marek Polacek [Fri, 1 Apr 2022 20:55:58 +0000 (16:55 -0400)]
c: Implement new -Wenum-int-mismatch warning [PR105131]

In C, an enumerated type is compatible with char, a signed integer type,
or an unsigned integer type (6.7.2.2/5).  Therefore this code compiles:

  enum E { l = -1, z = 0, g = 1 };
  int foo(void);
  enum E foo(void) { return z; }

if the underlying type of 'enum E' is 'int' (if not, we emit an error).
This is different for typedefs, where C11 permits typedefs to be
redeclared to the same type, but not to compatible types.  In C++, the
code above is invalid.

It seems desirable to emit a warning in the C case, because it is
probably a mistake and definitely a portability error, given that the
choice of the underlying type is implementation-defined.

To that end, this patch implements a new -Wenum-int-mismatch warning.
Conveniently, we already have comptypes_check_enum_int to detect such
mismatches.  This warning is enabled by either -Wall or -Wc++-compat.

PR c/105131

gcc/c-family/ChangeLog:

* c.opt (Wenum-int-mismatch): New.

gcc/c/ChangeLog:

* c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type
mismatches.
* c-tree.h (comptypes_check_enum_int): Declare.
* c-typeck.cc (comptypes): No longer static.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wenum-int-mismatch.

gcc/testsuite/ChangeLog:

* gcc.dg/Wenum-int-mismatch-1.c: New test.
* gcc.dg/Wenum-int-mismatch-2.c: New test.
* gcc.dg/Wenum-int-mismatch-3.c: New test.
* gcc.dg/Wenum-int-mismatch-4.c: New test.
* gcc.dg/Wenum-int-mismatch-5.c: New test.

2 years agoRevert move of g++.dg/pr69667.C
Paul A. Clarke [Wed, 18 May 2022 20:45:56 +0000 (15:45 -0500)]
Revert move of g++.dg/pr69667.C

Commit eccbd7fcee5bbfc47731e8de83c44eee2e3dcc4b moved the subject file to
g++.target/powerpc.  Unfortunately, test g++.dg/tsan/pr88018.C includes
"../pr69667.C".

Revert the move of this file.

Commit 14e678a2c4a76433fd4029568d28530c921e11ee relaxed some DejaGnu
directives in g++.dg/tsan/pr88018.C, given its more restrictive environment
within g++.target/powerpc.  Revert these changes in that file as well.

2022-05-18  Paul A. Clarke  <pc@us.ibm.com>

gcc/testsuite
PR target/105620
* g++.target/powerpc/pr69667.C: Move to ...
* g++.dg/pr69667.C: here. Also, revert recent dg directives changes.

2 years agox86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK
Uros Bizjak [Wed, 18 May 2022 18:03:26 +0000 (20:03 +0200)]
x86: Fix -fsplit-stack feature detection via  TARGET_CAN_SPLIT_STACK

Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack
is only supported on glibc targets. However, this original commit
required some fixups. As part of the fixup, the changes to the
gnu-user-common.h and gnu.h were partially reverted in commit
60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK
to be defined for non-glibc targets even though -fsplit-stack is
actually not supported and attempting to use it causes a runtime error.

This causes gcc internal code, such as ./gcc/go/gospec.c to not
correctly detect that -fsplit-stack is not supported and thus causes
gccgo to fail compilation on non-glibc targets.

This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the
default libc is glibc. It is presently unclear to me if there is a
better way to detect glibc at pre-processor time.

The proposed changes have been tested on x86 and x86_64 Alpine Linux
(which uses musl libc) and fix compilation of gccgo for this target.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
gcc/ChangeLog:

* config/i386/gnu-user-common.h (defined): Only define
TARGET_CAN_SPLIT_STACK for glibc targets.
* config/i386/gnu.h (defined): Ditto.

2 years agoCorrect ix86_rtx_cost for multi-word multiplication.
Roger Sayle [Wed, 18 May 2022 15:23:01 +0000 (16:23 +0100)]
Correct ix86_rtx_cost for multi-word multiplication.

This is the i386 backend specific piece of my revised patch for
PR middle-end/98865, where Richard Biener has suggested that I perform
the desired transformation during RTL expansion where the backend can
control whether it is profitable to convert a multiplication into a
bit-wise AND and a negation.  This works well for x86_64, but alas
exposes a latent bug with -m32, where a DImode multiplication incorrectly
appears to be cheaper than negdi2+anddi3(!?).  The fix to ix86_rtx_costs
is to report that a DImode (multi-word) multiplication actually requires
three SImode multiplications and two SImode additions.  This also corrects
the cost of TImode multiplication on TARGET_64BIT.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.cc (ix86_rtx_costs) [MULT]: When mode size
is wider than word_mode, a multiplication costs three word_mode
multiplications and two word_mode additions.

2 years agoAvoid andn and generate shorter not;and with -Oz on x86.
Roger Sayle [Wed, 18 May 2022 15:13:17 +0000 (16:13 +0100)]
Avoid andn and generate shorter not;and with -Oz on x86.

The x86 instruction encoding for SImode andn is longer than the
equivalent notl/andl sequence when the source for the not operand
is the same register as the destination.  This patch adds post_reload
splitters to i386.md to avoid "-mbmi" (which enables andn) increasing
code size with "-Oz".

One minor subtlety with this patch is that the splitter for
*andn_si_ccno swaps the order of operands (match_dup 2 and match_dup 3)
as memory operands need to appear first in *test<mode>_1 patterns.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.md (define_split):  Split *andsi_1
and *andn_si_ccno after reload with -Oz.

gcc/testsuite/ChangeLog
* gcc.target/i386/bmi-andn-3.c: New test case.

2 years agoc, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]
Marek Polacek [Sat, 7 May 2022 20:15:49 +0000 (16:15 -0400)]
c, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]

This PR complains that we emit the "enumeration value not handled in
switch" warning even though the enumerator was marked with the
[[maybe_unused]] attribute.

I couldn't just check TREE_USED, because the enumerator could have been
used earlier in the function, which doesn't play well with the
c_do_switch_warnings warning.  Instead, I had to check the attributes on
the CONST_DECL.  This is easy since the TYPE_VALUES of an enum type are
now consistent between C and C++, both of which store the CONST_DECL in
its TREE_VALUE.

PR c++/105497

gcc/c-family/ChangeLog:

* c-warn.cc (c_do_switch_warnings): Don't warn about unhandled
enumerator when it was marked with attribute unused.

gcc/testsuite/ChangeLog:

* c-c++-common/Wswitch-1.c: New test.
* g++.dg/warn/Wswitch-4.C: New test.

2 years agoc++: fix SIGFPE with -Wclass-memaccess [PR105634]
Marek Polacek [Tue, 17 May 2022 19:13:58 +0000 (15:13 -0400)]
c++: fix SIGFPE with -Wclass-memaccess [PR105634]

Here we crash because we attempt to % by 0.  Thus fixed.
While at it, I've moved the -Wclass-memaccess tests into warn/.
I've checked that the # of expected passes is the same before/after
the move.

PR c++/105634

gcc/cp/ChangeLog:

* call.cc (maybe_warn_class_memaccess): Avoid % by zero.

gcc/testsuite/ChangeLog:

* g++.dg/Wclass-memaccess-2.C: Moved to...
* g++.dg/warn/Wclass-memaccess-2.C: ...here.
* g++.dg/Wclass-memaccess-3.C: Moved to...
* g++.dg/warn/Wclass-memaccess-3.C: ...here.
* g++.dg/Wclass-memaccess-4.C: Moved to...
* g++.dg/warn/Wclass-memaccess-4.C: ...here.
* g++.dg/Wclass-memaccess-5.C: Moved to...
* g++.dg/warn/Wclass-memaccess-5.C: ...here.
* g++.dg/Wclass-memaccess-6.C: Moved to...
* g++.dg/warn/Wclass-memaccess-6.C: ...here.
* g++.dg/Wclass-memaccess.C: Moved to...
* g++.dg/warn/Wclass-memaccess.C: ...here.
* g++.dg/warn/Wclass-memaccess-7.C: New test.

2 years agoReduce usage of limited_with clauses with -fdump-ada-spec
Eric Botcazou [Wed, 18 May 2022 14:27:55 +0000 (16:27 +0200)]
Reduce usage of limited_with clauses with -fdump-ada-spec

The problem is that subtypes are not part of the limited view of a package
so we need to use types in conjunction with limited_with clauses, which is
not always desirable as this yields less portable Ada bindings.  The patch
also contains a small enhancement for complex floating-point types.

gcc/c-family/
* c-ada-spec.cc (dump_ada_node) <COMPLEX_TYPE>: Deal with usual
floating-point complex types.
<POINTER_TYPE>: Do not use limited_with clause if the designated
type is a scalar type.

2 years agotestsuite/rs6000: Move pr83660.C to g++.target
Kewen Lin [Wed, 18 May 2022 14:08:10 +0000 (09:08 -0500)]
testsuite/rs6000: Move pr83660.C to g++.target

Move pr83660.C to g++.target.  As comment #3 of PR83660,
rename it to c isn't one option.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr83660.C: Moved to...
* g++.target/powerpc/pr83660.C: ...here.

2 years agographite: Extend SCoP detection dump output
Frederik Harwath [Wed, 18 May 2022 05:59:42 +0000 (07:59 +0200)]
graphite: Extend SCoP detection dump output

Extend dump output to make understanding why Graphite rejects to
include a loop in a SCoP easier (for GCC developers).

gcc/ChangeLog:

* graphite-scop-detection.cc (scop_detection::can_represent_loop):
Output reason for failure to dump file.
(scop_detection::harmful_loop_in_region): Likewise.
(scop_detection::graphite_can_represent_expr): Likewise.
(scop_detection::stmt_has_simple_data_refs_p): Likewise.
(scop_detection::stmt_simple_for_scop_p): Likewise.
(print_sese_loop_numbers): New function.
(scop_detection::add_scop): Use from here.

gcc/testsuite/ChangeLog:

* gcc.dg/graphite/scop-22a.c: New test.

2 years agodemangler: Reorganize for module demangling
Nathan Sidwell [Tue, 8 Mar 2022 18:53:39 +0000 (10:53 -0800)]
demangler: Reorganize for module demangling

Module demangling requires some changes in how substitutions are
handled.  This adjusts things to make that possible.

libiberty/
* cp-demangle.c (d_name): Add SUBSTABLE parameter,
push substitution if requested. Adjust unscoped name handling.
(d_prefix): Reorder main loop. Adjust all calls.
(d_unqualified_name): Add SCOPE parameter, create qualified
name here. Adjust all calls.
(cplus_demangle_type): Do not handle 'S' here, leave all
to d_class_enum_type.
(d_class_enum_type): Add SUBSTABLE parameter.

2 years ago'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'
Thomas Schwinge [Fri, 29 Apr 2022 08:44:12 +0000 (10:44 +0200)]
'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'

include/
* cuda/cuda.h (enum CUjit_option): Add
'CU_JIT_GENERATE_DEBUG_INFO', 'CU_JIT_GENERATE_LINE_INFO'.
(enum CUlimit): Add 'CU_LIMIT_STACK_SIZE',
'CU_LIMIT_MALLOC_HEAP_SIZE'.
(cuCtxSetLimit, cuGetErrorName): Add.

2 years ago'include/cuda/cuda.h': For C++, wrap in 'extern "C"'
Thomas Schwinge [Fri, 29 Apr 2022 08:33:15 +0000 (10:33 +0200)]
'include/cuda/cuda.h': For C++, wrap in 'extern "C"'

include/
* cuda/cuda.h: For C++, wrap in 'extern "C"'.

2 years agoOpenMP: Add Fortran support for inoutset depend-kind
Tobias Burnus [Wed, 18 May 2022 10:04:21 +0000 (12:04 +0200)]
OpenMP: Add Fortran support for inoutset depend-kind

Fortran additions to the C/C++ + ME/libgomp commit
r13-556-g2c16eb3157f86ae561468c540caf8eb326106b5f

gcc/fortran/ChangeLog:

* gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET.
(gfc_omp_clauses): Enlarge ENUM_BITFIELD.
* dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle
'inoutset' depend modifier.
* openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj):
Likewise.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1): Set 'inoutset' to Y.
(OpenMP Context Selectors): Add missing comma.
* testsuite/libgomp.fortran/depend-5.f90: Add inoutset test.
* testsuite/libgomp.fortran/depend-6.f90: Likewise.
* testsuite/libgomp.fortran/depend-7.f90: Likewise.
* testsuite/libgomp.fortran/depend-inoutset-1.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/all-memory-1.f90: Add inoutset test.
* gfortran.dg/gomp/all-memory-2.f90: Likewise.
* gfortran.dg/gomp/depobj-1.f90: Likewise.
* gfortran.dg/gomp/depobj-2.f90: Likewise.

2 years ago[Ada] Fix proof of runtime unit s-imageu
Claire Dross [Mon, 11 Apr 2022 12:10:49 +0000 (14:10 +0200)]
[Ada] Fix proof of runtime unit s-imageu

Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

* libgnat/s-imageu.adb (Set_Image_Unsigned): Change assertion.

2 years ago[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp
Doug Rupp [Fri, 8 Apr 2022 21:12:24 +0000 (14:12 -0700)]
[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp

Fix compilation warning. The code was using a cast to struct sigcontext
*, which doesn't exist. It worked by accident.

gcc/ada/

* sigtramp-qnx.c: Change struct sigcontext * to mcontext_t *.

2 years ago[Ada] arm-qnx-7.1: stack-checking and sigtramp implementation
Doug Rupp [Fri, 8 Apr 2022 18:28:48 +0000 (11:28 -0700)]
[Ada] arm-qnx-7.1: stack-checking and sigtramp implementation

Rewrite and base on VxWorks RTP implementation.

gcc/ada/

* sigtramp-arm-qnx.c: Rewrite.

2 years ago[Ada] Adapt proof of double arithmetic runtime unit
Yannick Moy [Fri, 8 Apr 2022 15:24:49 +0000 (15:24 +0000)]
[Ada] Adapt proof of double arithmetic runtime unit

After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

* libgnat/s-aridou.adb (Big3): Change return type.
(Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive): Reorder
alphabetically.
(Lemma_Concat_Definition, Lemma_Double_Big_2xxsingle): New
lemmas.
(Double_Divide, Scaled_Divide): Add assertions.

2 years ago[Ada] Fix proof of runtime unit s-valeu
Claire Dross [Fri, 8 Apr 2022 14:38:47 +0000 (16:38 +0200)]
[Ada] Fix proof of runtime unit s-valeu

Update to provers caused some proof regressions.  Fix the proof by
changing ghost code.

gcc/ada/

* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.

2 years ago[Ada] Make sure output variable is always initialized
Kévin Le Gouguec [Thu, 7 Apr 2022 15:43:34 +0000 (17:43 +0200)]
[Ada] Make sure output variable is always initialized

gcc/ada/

* libgnat/s-dwalin.adb (Read_Aranges_Header): Initialize output
parameter in case we return early.

2 years ago[Ada] Disable Vet calls when container checks are disabled
Bob Duff [Thu, 7 Apr 2022 16:58:56 +0000 (12:58 -0400)]
[Ada] Disable Vet calls when container checks are disabled

Calls to various Vet functions are used throughout the containers
packages to check internal consistency. This patch improves efficiency
by disabling these calls when Container_Checks are suppressed.

gcc/ada/

* libgnat/a-crbtgo.ads, libgnat/a-rbtgbo.ads,
libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
libgnat/a-cbhase.adb, libgnat/a-cdlili.adb,
libgnat/a-cfdlli.adb, libgnat/a-cfhama.adb,
libgnat/a-cfhase.adb, libgnat/a-cidlli.adb,
libgnat/a-cihama.adb, libgnat/a-cihase.adb,
libgnat/a-cohama.adb, libgnat/a-cohase.adb,
libgnat/a-crbtgo.adb, libgnat/a-crdlli.adb, libgnat/a-rbtgbo.adb
(Vet): Make the Vet functions do nothing when
Container_Checks'Enabled is False, and inline them, so the calls
disappear when optimizing.

2 years ago[Ada] arm-qnx-7.1: undefined reference to fma* symbols
Doug Rupp [Thu, 7 Apr 2022 18:08:56 +0000 (11:08 -0700)]
[Ada] arm-qnx-7.1: undefined reference to fma* symbols

Configure the arm-qnx runtime packages to avoid generating these
symbols.

gcc/ada/

* Makefile.rtl (arm-qnx): Use default (non-fma) target pair.

2 years ago[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts
Kévin Le Gouguec [Thu, 7 Apr 2022 08:51:51 +0000 (10:51 +0200)]
[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts

Currently, a 64-bit gnatsymbolize fails to output line numbers and
accurate symbol names when run on 32-bit executables (and vice-versa).
This is because a couple of spots in System.Dwarf_Lines expect the
Address_Size found in the DWARF data to match the host Address'Size.

This patch corrects that assumption.

gcc/ada/

* libgnat/s-dwalin.adb (Aranges_Lookup, Enable_Cache): Adapt to
changes in the signature of Read_Aranges_*.
(Debug_Info_Lookup): Do not control address size read from
DWARF.
(Read_Aranges_Header): Do not control address size read from
DWARF; return this size.
(Read_Aranges_Entry): Use the size returned by
Read_Aranges_Header.

2 years ago[Ada] Improve error messages for occurrence of GNAT extensions without -gnatX
Gary Dismukes [Wed, 6 Apr 2022 00:20:10 +0000 (20:20 -0400)]
[Ada] Improve error messages for occurrence of GNAT extensions without -gnatX

The error message issued for use of GNAT extension features without
specifying -gnatX (or pragma Extensions_Allowed) was confusing in the
presence of a pragma specifying a language version (such as "pragma
Ada_2022;"), because the pragma supersedes the switch.  The message is
improved by testing for use of such a pragma, plus use of pragma
Extensions_Allowed is now suggested, and several cases are changed to
call the common error procedure for flagging uses of extension features.

gcc/ada/

* errout.ads (Error_Msg_GNAT_Extension): Add formal Loc and
revise comment.
* errout.adb (Error_Msg_GNAT_Extension): Condition message on
the flag Ada_Version_Pragma, and add suggestion to use of pragma
Extensions_Allowed in messages.
* par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch11.adb,
par-ch12.adb: Add actual Token_Ptr on calls to
Error_Msg_GNAT_Extension.
* par-ch4.adb: Change Error_Msg to Error_Msg_GNAT_Extension for
error calls related to use of extension features.
* sem_ch13.adb: Likewise.

2 years ago[Ada] Fix Ada-QNX task priority conversion
Johannes Kliemann [Tue, 5 Apr 2022 16:25:43 +0000 (16:25 +0000)]
[Ada] Fix Ada-QNX task priority conversion

The conversion between OS and Ada priorties should be done in the wider
Interfaces.C.int type rather than Any_Priority otherwise
Constraint_Error will be raised when coverting Any_Priority'Last to int.

gcc/ada/

* libgnarl/s-osinte__qnx.adb (To_Target_Priority): Perform
arithmetic in int.

2 years ago[Ada] Use specific predicate before manipulating BIP_Alloc_Form
Eric Botcazou [Mon, 28 Mar 2022 19:16:24 +0000 (21:16 +0200)]
[Ada] Use specific predicate before manipulating BIP_Alloc_Form

For the sake of consistency with other similar manipulations.

gcc/ada/

* exp_ch7.adb (Build_BIP_Cleanup_Stmts): Use Needs_BIP_Alloc_Form.

2 years ago[Ada] Crash building VSS with compiler built with assertions
Javier Miranda [Fri, 1 Apr 2022 22:12:05 +0000 (22:12 +0000)]
[Ada] Crash building VSS with compiler built with assertions

When a tagged type T has aspect String_Literal, a derived type defines a
null extension T2, and the context to resolve the use of an object of
type T2 where the string literal is applicable is a class-wide type the
frontend crashes trying to evaluate if the object is a null extension.
This problem does not reproduce when the compiler is built with
assertions disabled.

gcc/ada/

* sem_ch6.adb (Find_Corresponding_Spec): Avoid calling
Is_Null_Extension with a class-wide type entity.
(Overrides_Visible_Function): Handle alias entities.
* sem_res.adb (Has_Applicable_User_Defined_Literal): Conversion
not needed if the result type of the call is class-wide or if
the result type matches the context type.
* sem_util.ads (Is_Null_Extension): Adding documentation.
(Is_Null_Extension_Of): Adding documentation.
* sem_util.adb (Is_Null_Extension): Adding assertion.
(Is_Null_Extension_Of): Adding assertions.

2 years ago[Ada] Ada2022: AI12-0143 Index attribute for entry families
Javier Miranda [Fri, 1 Apr 2022 20:06:27 +0000 (20:06 +0000)]
[Ada] Ada2022: AI12-0143 Index attribute for entry families

gcc/ada/

* snames.ads-tmpl (Name_Index): New attribute name.
(Attribute_Id): Adding Attribute_Index as regular attribute.
* sem_attr.adb (Attribute_22): Adding Attribute_Index as Ada
2022 attribute.
(Analyze_Index_Attribute): Check that 'Index appears in a
pre-/postcondition aspect or pragma associated with an entry
family.
(Analyze_Attribute): Adding semantic analysis for 'Index.
(Eval_Attribute): Register 'Index as can never be folded.
(Resolve_Attribute): Resolve attribute 'Index.
* sem_ch9.adb (Check_Wrong_Attribute_In_Postconditions): New
subprogram.
(Analyze_Requeue): Check that the requeue target shall not have
an applicable specific or class-wide postcondition which
includes an Index attribute reference.
* exp_attr.adb (Expand_N_Attribute_Reference): Transform
attribute Index into a renaming of the second formal of the
wrapper built for an entry family that has contract cases.
* einfo.ads (Is_Entry_Wrapper): Complete documentation.

2 years ago[Ada] Fix proof of runtime units
Yannick Moy [Mon, 4 Apr 2022 15:38:57 +0000 (17:38 +0200)]
[Ada] Fix proof of runtime units

Update to latest version of Why3 caused some proof regressions.
Fix the proof by changing ghost code.

gcc/ada/

* libgnat/s-imagei.adb (Set_Digits): Add assertion.
* libgnat/s-imgboo.adb (Image_Boolean): Add assertions.
* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertion.

2 years ago[Ada] Errors missed on ACATS test B650007
Arnaud Charlet [Sat, 2 Apr 2022 17:29:09 +0000 (17:29 +0000)]
[Ada] Errors missed on ACATS test B650007

This ACATS test shows that we need to call Is_Immutably_Limited_Type
in Analyze_Function_Return and also that we have a latent bug in
Is_Immutably_Limited_Type which shouldn't look through private types.

gcc/ada/

* sem_aux.adb (Is_Immutably_Limited_Type): Do not look through
private types as per RM 7.5(8.1).
* sem_ch6.adb (Analyze_Function_Return): Use
Is_Immutably_Limited_Type as per RM 6.5(5.10).

2 years ago[Ada] Fix the parsing for delta aggregate
Marc Poulhiès [Mon, 4 Apr 2022 12:09:45 +0000 (14:09 +0200)]
[Ada] Fix the parsing for delta aggregate

In Ada 2022, delta aggregate must use parentheses not square brackets
except array delta aggregates.

gcc/ada/

* gen_il-gen-gen_nodes.adb (Gen_IL.Gen.Gen_Nodes): Add
Is_Homogeneous_Aggregate field for N_Delta_Aggregate nodes.
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Minor reformatting.
* sem_aggr.adb (Resolve_Delta_Aggregate): Reject square brackets
for record aggregate.
(Resolve_Record_Aggregate): Uniformise error message.