Commit graph

195756 commits

Author SHA1 Message Date
Jonathan Wakely
f1b51f68f8 libstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626]
This allows the library to switch to freestanding mode when compiling
with the -ffreestanding flag. This means you don't need a separate
libstdc++ build configured with --disable-hosted-libstdcxx in order to
compile for a freestanding environment.

The testsuite support files cannot be compiled for freestanding, so add
-fno-freestanding to override any -ffreestanding in the test flags.

libstdc++-v3/ChangeLog:

	PR libstdc++/103626
	* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Define _GLIBCXX_HOSTED
	to __STDC_HOSTED__ for non-freestanding installations.
	* configure: Regenerate.
	* include/Makefile.am (${host_builddir}/c++config.h): Adjust
	grep pattern.
	* include/Makefile.in: Regenerate.
	* testsuite/lib/libstdc++.exp (v3-build_support): Use
	-fno-freestanding.
	* testsuite/libstdc++-abi/abi.exp: Likewise.
2022-10-03 15:43:48 +01:00
Rainer Orth
77d0627c24 libsanitizer: Fix Solaris 11.3 compilation of sanitizer_procmaps_solaris.cpp [PR105531]
The latest libsanitizer import broke Solaris 11.3 bootstrap again, due
to an oversight of mine.  A fix has been committed upstream

	https://reviews.llvm.org/D133556

This patch cherry-picks it.  Tested on Solaris 11.3 and 11.4, SPARC and
x86.

2022-09-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libsanitizer:
	PR sanitizer/105531
	* sanitizer_common/sanitizer_procmaps_solaris.cpp: Cherry-pick
	llvm-project revision 1cd4d63fb9ab0f04c7151911dde0d58b673823de.
2022-10-03 16:28:46 +02:00
Andrew Stubbs
48960b6897 vect: while_ult for integer masks
Add a vector length parameter needed by amdgcn without breaking aarch64.

All amdgcn vector masks are DImode, regardless of vector length, so we can't
tell what length is implied simply from the operator mode.  (Even if we used
different integer modes there's no mode small enough to differenciate a 2 or
4 lane mask).  Without knowing the intended length we end up using a mask with
too many lanes enabled, which leads to undefined behaviour..

The extra operand is not added for vector mask types so AArch64 does not need
to be adjusted.

gcc/ChangeLog:

	* config/gcn/gcn-valu.md (while_ultsidi): Limit mask length using
	operand 3.
	* doc/md.texi (while_ult): Document new operand 3 usage.
	* internal-fn.cc (expand_while_optab_fn): Set operand 3 when lhs_type
	maps to a non-vector mode.
2022-10-03 15:25:27 +01:00
Andrew MacLeod
f41d1b39a6 Don't process undefined range.
No need to continue processing an undefined range.

	gcc/
	PR tree-optimization/107109
	* range-op.cc (adjust_op1_for_overflow): Don't process undefined.
	gcc/testsuite/
	* gcc.dg/pr107109.c: New.
2022-10-03 10:02:34 -04:00
Christophe Lyon
06aa66af7d arm: Add missing early clobber to MVE vrev64q_m patterns
Like the non-predicated vrev64q patterns, mve_vrev64q_m_<supf><mode>
and mve_vrev64q_m_f<mode> need an early clobber constraint, otherwise
we can generate an unpredictable instruction:

Warning: 64-bit element size and same destination and source operands makes instruction UNPREDICTABLE
when calling vrevq64_m* with the same first and second arguments.

OK for trunk?

Thanks,

Christophe

gcc/ChangeLog:

	* config/arm/mve.md (mve_vrev64q_m_<supf><mode>): Add early
	clobber.
	(mve_vrev64q_m_f<mode>): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/intrinsics/vrev64q_m_s16-clobber.c: New test.
2022-10-03 15:13:10 +02:00
Joseph Myers
53acc10ee8 c: Adjust LDBL_EPSILON for C2x for IBM long double
C2x changes the <float.h> definition of *_EPSILON to apply only to
normalized numbers.  The effect is that LDBL_EPSILON for IBM long
double becomes 0x1p-105L instead of 0x1p-1074L.

There is a reasonable case for considering this a defect fix - it
originated from the issue reporting process (DR#467), though it ended
up being resolved by a paper (N2326) for C2x rather than through the
issue process, and code using *_EPSILON often needs to override the
pre-C2x value of LDBL_EPSILON and use something on the order of
magnitude of the C2x value instead.  However, I've followed the
conservative approach of only making the change for C2x and not for
previous standard versions (and not for C++, which doesn't have the
C2x changes in this area).

The testcases added are intended to be valid for all long double
formats.  The C11 one is based on
gcc.target/powerpc/rs6000-ldouble-2.c (and when we move to a C2x
default, gcc.target/powerpc/rs6000-ldouble-2.c will need an
appropriate option added to keep using an older language version).

Tested with no regressions for cross to powerpc-linux-gnu.

gcc/c-family/
	* c-cppbuiltin.cc (builtin_define_float_constants): Do not
	special-case __*_EPSILON__ setting for IBM long double for C2x.

gcc/testsuite/
	* gcc.dg/c11-float-7.c, gcc.dg/c2x-float-12.c: New tests.
2022-10-03 13:10:42 +00:00
Jonathan Wakely
866263a5fe libstdc++: Fix tests broken by C++23 P2266R3 "Simpler implicit move"
In C++23 mode these tests started to FAIL because an rvalue reference
parameter can no longer be bound to an lvalue reference return type. As
confirmed by Ville (who added these tests) the problem overloads are not
intended to be called, and only exist to verify that they don't
interfere with the intended behaviour. This changes the function bodies
to just throw, so that the tests will fail if the function is called.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
	Change body of unused operator<< overload to throw if called.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
	Likewise.
2022-10-03 12:45:05 +01:00
Aldy Hernandez
c0129d6b2a Do not pessimize range in set_nonzero_bits.
Currently if we have a range of [0,0] and we set the nonzero bits to
1, the current code pessimizes the range to [0,1] because it assumes
the range is [1,1] plus the possibility of 0.  This fixes the
oversight.

gcc/ChangeLog:

	* value-range.cc (irange::set_nonzero_bits): Do not pessimize range.
	(range_tests_nonzero_bits): New test.
2022-10-03 13:06:25 +02:00
Aldy Hernandez
7f6f1f521f Avoid comparing ranges when sub-ranges is 0.
There is nothing else to compare when the number of sub-ranges is 0.

gcc/ChangeLog:

	* value-range.cc (irange::operator==): Early bail on m_num_ranges
	equal to 0.
2022-10-03 13:06:25 +02:00
Aldy Hernandez
8e1de8d2db Do not compare nonzero masks for varying.
There is no need to compare nonzero masks when comparing two VARYING
ranges, as they are always the same when range types are the same.

gcc/ChangeLog:

	* value-range.cc (irange::legacy_equal_p): Remove nonozero mask
	check when comparing VR_VARYING ranges.
2022-10-03 13:06:25 +02:00
Aldy Hernandez
b90d1b5086 Do not compare incompatible ranges in ipa-prop.
gcc/ChangeLog:

	* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Do not compare
	incompatible ranges in ipa-prop.
2022-10-03 13:06:25 +02:00
Francois-Xavier Coudert
31d7c8bc26 Fortran: fix testcases
Remove unreliable test for IEEE_FMA(), which fails on powerpc.
Adjust stop codes for modes_1.f90.

2022-10-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

gcc/testsuite/

	PR fortran/107062
	* gfortran.dg/ieee/fma_1.f90: Fix test.
	* gfortran.dg/ieee/modes_1.f90: Fix test.
2022-10-03 09:26:45 +02:00
François Dumont
4347fea9c2 libstdc++: Fix gdb pretty printers when dealing with std::string
Since revision 33b43b0d8c std::string and other
similar typedef are ambiguous from a gdb point of view because it matches both
std::basic_string<char> and std::__cxx11::basic_string<char> symbols. For those
typedef add a workaround to accept the substitution as long as the same regardless
of __cxx11 namespace.

Also avoid to register printers for types in std::__cxx11::__8:: namespace, there is
no such symbols.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (Printer.add_version): Do not add version
	namespace for __cxx11 symbols.
	(add_one_template_type_printer): Likewise.
	(add_one_type_printer): Likewise.
	(FilteringTypePrinter._recognizer.recognize): Add a workaround for std::string & al
	ambiguous typedef matching both std:: and std::__cxx11:: symbols.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Remove obsolete
	\#define _GLIBCXX_USE_CXX11_ABI 0.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise. Adapt test to accept
	std::__cxx11::list.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/80276.cc: Likewise and remove xfail for c++20
	and debug mode.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
2022-10-03 07:01:10 +02:00
GCC Administrator
4223101506 Daily bump. 2022-10-03 00:17:44 +00:00
Jakub Jelinek
d01bd0b0f3 tree-cfg: Fix a verification diagnostic typo [PR107121]
Obvious typo in diagnostics.

2022-10-02  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/107121
	* tree-cfg.cc (verify_gimple_call): Fix a typo in diagnostics,
	DEFFERED_INIT -> DEFERRED_INIT.
2022-10-02 16:42:32 +02:00
Olivier Hainque
b83b13331a Adjust LIBGCC2_INCLUDES for VxWorks and augment comment
Investigating the reasons for libgcc build failures in a canadian
context, orthogonally to the recent update of vxcrtstuff, exposed
interesting differences in the way include search paths are managed
between a regular Linux->VxWorks cross build and a canadian setup
building a Windows->VxWorks toolchain in a Linux environment.

This change augments the comment attached to LIBGCC2_INCLUDE in
libgcc/config/t-vxworks to better describe the parameters at play.

It also adjusts the addition of options for gcc/include and
gcc/include-fixed to minimize the actual differences for libgcc
in the two kinds of configurations.

2022-03-06  Olivier Hainque  <hainque@adacore.com>

libgcc/
	* config/t-vxworks (LIBGCC2_INCLUDE): Augment comment.  Move
	-I options for gcc/include and gcc/include-fixed at the end
	and make them -isystem.
2022-10-02 09:33:00 +00:00
Marc Poulhiès
2f26f5b584 Define GCC_DRIVER_HOST_INITIALIZATION for VxWorks targets
We need to perform static links by default on VxWorks, where the use
of shared libraries involves unusual steps compared to standard native
systems.

This has to be conveyed before the lang_specific_driver code gets
invoked (in particular for g++), so specs aren't available.

This change defines the GCC_DRIVER_HOST_INITIALIZATION macro for
VxWorks, to insert a -static option in case the user hasn't provided any
explicit indication on the command line of the kind of link desired.

While a HOST macro doesn't seem appropriate to control a target OS
driven behavior, this matches other uses and won't conflict as VxWorks
is not supported on any of the other configurations using this macro.

gcc/
	* config/vxworks-driver.cc: New.
	* config.gcc (*vxworks*): Add vxworks-driver.o in extra_gcc_objs.
	* config/t-vxworks: Add vxworks-driver.o.
	* config/vxworks.h (GCC_DRIVER_HOST_INITIALIZATION): New.
2022-10-02 09:25:39 +00:00
Olivier Hainque
372044a67e Prevent secondary warning from diagnostic tweak in gthr-vxworks.h
Within gthr-vxworks.h, we prevent C++ errors from missing
declarations in some system headers by prepending their inclusion
with a

    #pragma GCC diagnostic ignored "-Wstrict-prototypes"

But Wstrict-prototypes is internally registered as valid for
C/ObjC only, not C++, and this trick in turn triggers a Wpragma
warning with -Wsystem-headers.

This change just arranges to ignore the secondary warning locally.

2021-02-03  Olivier Hainque  <hainque@adacore.com>

	* config/gthr-vxworks.h: Prevent Wpragma warning for the
	pragma diagnostics on Wstrict-prototypes.
2022-10-02 09:13:14 +00:00
Olivier Hainque
6ed7eee30f Refine guard for vxworks crtstuff spec
Working on the reintroduction of shared libraries support
(and of modules depending on shared libraries) exposed a few
test failures of simple c++ constructor tests on arm-vxworks7r2.

Investigation revealed that we were not linking the
crtstuff objects as needed from a compiler configured not to
have shared libs support, because of the ENABLE_SHARED_LIBGCC
guard in this piece of vxworks.h:

  /* Setup the crtstuff begin/end we might need for dwarf EH registration
     and/or INITFINI_ARRAY support for shared libs.  */

  #if (HAVE_INITFINI_ARRAY_SUPPORT && defined(ENABLE_SHARED_LIBGCC)) \
      || (DWARF2_UNWIND_INFO && !defined(CONFIG_SJLJ_EXCEPTIONS))
  #define VX_CRTBEGIN_SPEC "%{!shared:vx_crtbegin.o%s;:vx_crtbeginS.o%s}"

crtstuff initfini array support is meant to be leveraged for
constructors regardless of whether the compiler also happens to be
configured with shared library support, so the guard on ENABLE_SHARED_LIBGCC
here is inappropriate.

This change just removes it,

2022-09-30  Olivier Hainque <hainque@adacore.com>

gcc/
	* config/vxworks.h (VX_CRTBEGIN_SPEC, VX_CRTEND_SPEC): If
	HAVE_INITFINI_ARRAY_SUPPORT, pick crtstuff objects regardless
	of ENABLE_SHARED_LIBGCC.
2022-10-02 09:12:34 +00:00
GCC Administrator
3290dcf149 Daily bump. 2022-10-02 00:18:17 +00:00
José Rui Faustino de Sousa
5299155bb8 Fortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]
gcc/fortran/ChangeLog:

	PR fortran/100040
	PR fortran/100029
	* trans-expr.cc (gfc_conv_class_to_class): Add code to have
	assumed-rank arrays recognized as full arrays and fix the type
	of the array assignment.
	(gfc_conv_procedure_call): Change order of code blocks such that
	the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs
	first.

gcc/testsuite/ChangeLog:

	PR fortran/100029
	* gfortran.dg/PR100029.f90: New test.

	PR fortran/100040
	* gfortran.dg/PR100040.f90: New test.
2022-10-01 20:09:08 +02:00
Patrick Palka
c051060ade c++: make some cp_trait_kind switch statements exhaustive
This replaces the unreachable default case in some cp_trait_kind
switches with an exhaustive listing of the trait codes that we don't
expect to see, so that when adding a new trait we'll get a helpful
-Wswitch warning if we forget to handle the new trait in a relevant
switch.

gcc/cp/ChangeLog:

	* semantics.cc (trait_expr_value): Make cp_trait_kind switch
	statement exhaustive.
	(finish_trait_expr): Likewise.
	(finish_trait_type): Likewise.
2022-10-01 12:21:36 -04:00
Stafford Horne
ca01d25269 or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS
This was found when testing buildroot with linuxthreads enabled.  In
this case, the build passes --disable-tls to the toolchain during
configuration.  After building the OpenRISC toolchain it was still
generating TLS code sequences and causing linker failures such as:

 ..../or1k-buildroot-linux-uclibc-gcc -o gpsd-3.24/gpsctl .... -lusb-1.0 -lm -lrt -lnsl
 ..../ld: ..../sysroot/usr/lib/libusb-1.0.so: undefined reference to `__tls_get_addr'

This patch fixes this by disabling tls for the OpenRISC target when requested
via --disable-tls.

gcc/ChangeLog:

	* config/or1k/or1k.cc (TARGET_HAVE_TLS): Only define if
	HAVE_AS_TLS is defined.

Tested-by: Yann E. MORIN <yann.morin@orange.com>
2022-10-01 10:58:01 +01:00
Julian Brown
153ca019b7 OpenACC: Fix struct-component-kind-1.c test
This patch is a minimal fix for the recently-added
struct-component-kind-1.c test (which is currently failing to emit one
of the errors it expects in scan output). This fragment was erroneously
omitted from the second version of the patch posted previously:

  https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602504.html

2022-10-01  Julian Brown  <julian@codesourcery.com>

gcc/
	* gimplify.cc (omp_group_base): Fix IF_PRESENT (no_create)
	handling.
2022-10-01 09:40:17 +00:00
Jeff Law
2555071c95 Improve Z flag handling on H8
This patch improves handling of the Z bit in the status register in a
variety of ways to improve either the code size or code speed on various
H8 subtargets.

For example, we can test the zero/nonzero status of the upper byte of a
16 bit register using mov.b, we can move the Z or an inverted Z into a
QImode register profitably on some subtargets.  We can move Z or an
inverted Z into the sign bit on the H8/SX profitably, etc.

gcc/

	* config/h8300/h8300.md (HSI2): New iterator.
	(eqne_invert): Similarly.
	* config/h8300/testcompare.md (testhi_upper_z): New pattern.
	(cmpqi_z, cmphi_z, cmpsi_z): Likewise.
	(store_z_qi, store_z_i_qi, store_z_hi, store_z_hi_sb): New
	define_insn_and_splits and/or define_insns.
	(store_z_hi_neg, store_z_hi_and, store_z_<mode>): Likewise.
	(store_z_<mode>_neg, store_z_<mode>_and, store_z): Likewise.
2022-10-01 00:49:55 -04:00
Jason Merrill
dd9c8f644f c++: loop through array CONSTRUCTOR
I noticed that we were ignoring all the special rules for when to use a
simple INIT_EXPR for array initialization from a CONSTRUCTOR, because
split_nonconstant_init_1 was also passing 1 to the from_array parameter.
Arguably that's the real bug, but I think we can be flexible.

The test that I noticed this with no longer fails without it.

gcc/cp/ChangeLog:

	* init.cc (build_vec_init): Clear from_array for CONSTRUCTOR
	initializer.
2022-09-30 23:45:08 -04:00
Jason Merrill
f8cb417d6a c++: cast split_nonconstant_init return val to void
We were already converting the result of expand_vec_init_expr to void; we
need to do the same for split_nonconstant_init.

The test that I noticed this with no longer fails without it.

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_genericize_init): Also convert the result of
	split_nonconstant_init to void.
2022-09-30 23:45:08 -04:00
Jeff Law
aa360fbf68 Install correct patch version.
gcc/
	* tree-ssa-dom.cc (record_edge_info): Install correct version of
	patch.
2022-09-30 20:48:30 -04:00
Eugene Rozenfeld
c3cb74aee2 Emit discriminators for inlined call sites.
This change is based on commit 9fa26998a63d4b22b637ed8702520819e408a694
by Dehao Chen in vendors/google/heads/gcc-4_8.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

	* dwarf2out.cc (add_call_src_coords_attributes): Emit discriminators for inlined call sites.
2022-09-30 17:35:39 -07:00
GCC Administrator
3a221b73d0 Daily bump. 2022-10-01 00:18:00 +00:00
Jeff Law
1214196da7 More gimple const/copy propagation opportunities
While investigating a benchmark for optimization opportunities I came across single block loop which either iterates precisely once or forever.    This is an interesting scenario as we can ignore the infinite looping path and treat any PHI nodes as degenerates.  So more concretely let's consider this trivial testcase:

volatile void abort (void);

void
foo(int a)
{
 int b = 0;

 while (1)
   {
     if (!a)
       break;
     b = 1;
   }

 if (b != 0)
   abort ();
}

Quick analysis shows that b's initial value is 0 and its value only changes if we enter an infinite loop.  So if we get to the test b != 0, the only possible value b could have would be 0 and the test and its true arm can be eliminated.

The DOM3 dump looks something like this:

;;   basic block 2, loop depth 0, count 118111600 (estimated locally), maybe hot
;;    prev block 0, next block 3, flags: (NEW, VISITED)
;;    pred:       ENTRY [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)
;;    succ:       3 [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)

;;   basic block 3, loop depth 1, count 1073741824 (estimated locally), maybe hot
;;    prev block 2, next block 4, flags: (NEW, VISITED)
;;    pred:       2 [always]  count:118111600 (estimated locally) (FALLTHRU,EXECUTABLE)
;;                3 [89.0% (guessed)]  count:955630224 (estimated locally) (FALSE_VALUE,EXECUTABLE)
  # b_1 = PHI <0(2), 1(3)>
  if (a_3(D) == 0)
    goto <bb 4>; [11.00%]
  else
    goto <bb 3>; [89.00%]
;;    succ:       4 [11.0% (guessed)]  count:118111600 (estimated locally) (TRUE_VALUE,EXECUTABLE)
;;                3 [89.0% (guessed)]  count:955630224 (estimated locally) (FALSE_VALUE,EXECUTABLE)

;;   basic block 4, loop depth 0, count 118111600 (estimated locally), maybe hot
;;    prev block 3, next block 5, flags: (NEW, VISITED)
;;    pred:       3 [11.0% (guessed)]  count:118111600 (estimated locally) (TRUE_VALUE,EXECUTABLE)
  if (b_1 != 0)
    goto <bb 5>; [0.00%]
  else
    goto <bb 6>; [100.00%]
;;    succ:       5 [never]  count:0 (precise) (TRUE_VALUE,EXECUTABLE)
;;                6 [always]  count:118111600 (estimated locally) (FALSE_VALUE,EXECUTABLE)

This is a good representative of what the benchmark code looks like.

The primary effect we want to capture is to realize that the test if (b_1 != 0) is always false and optimize it accordingly.

In the benchmark, this opportunity is well hidden until after the loop optimizers have completed, so the first chance to capture this case is in DOM3.  Furthermore, DOM wants loops normalized with latch blocks/edges.  So instead of bb3 looping back to itself, there's an intermediate empty block during DOM.

I originally thought this was likely to only affect the benchmark.  But when I instrumented the optimization and bootstrapped GCC, much to my surprise there were several hundred similar cases identified in GCC itself.  So it's not as benchmark specific as I'd initially feared.

Anyway, detecting this in DOM is pretty simple.   We detect the infinite loop, including the latch block.  Once we've done that, we walk the PHI nodes and attach equivalences to the appropriate outgoing edge.   That's all we need to do as the rest of DOM is already prepared to handle equivalences on edges.

gcc/
	* tree-ssa-dom.cc (single_block_loop_p): New function.
	(record_edge_info): Also record equivalences for the outgoing
	edge of a single block loop where the condition is an invariant.

gcc/testsuite/
	* gcc.dg/infinite-loop.c: New test.
2022-09-30 19:31:33 -04:00
Jeff Law
89b5a316cf Minor cleanup/prep in DOM
It's a bit weird that free_dom_edge_info leaves a dangling pointer in e->aux.
Not sure what I was thinking.

There's two callers.  One wipes e->aux immediately after the call, the other
attaches a newly created object immediately after the call.  So we can wipe
e->aux within the call and simplify one of the two call sites.

This is preparatory work for a minor optimization where we want to detect
another class of edge equivalences in DOM (until something better is available)
and either attach them an existing edge_info structure or create a new one if
one doesn't currently exist for a given edge.

gcc/
	* tree-ssa-dom.cc (free_dom_edge_info): Clear e->aux too.
	(free_all_edge_infos): Do not clear e->aux here.
2022-09-30 19:04:43 -04:00
H.J. Lu
2002c54cb7 Document -fexcess-precision=16 in target.def
* target.def (TARGET_C_EXCESS_PRECISION): Document
	-fexcess-precision=16.
2022-09-30 15:53:43 -07:00
Palmer Dabbelt
4dcd340eba
Document -fexcess-precision=16 in tm.texi
I just happened to stuble on this one while trying to sort out the
RISC-V bits.

gcc/ChangeLog

	* doc/tm.texi (TARGET_C_EXCESS_PRECISION): Add 16.
2022-09-30 15:24:12 -07:00
Palmer Dabbelt
75c0899493
RISC-V: Support -fexcess-precision=16
This fixes f19a327077 ("Support -fexcess-precision=16 which will enable
FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 when backend supports _Float16.") on
RISC-V targets.

gcc/ChangeLog

	PR target/106815
	* config/riscv/riscv.cc (riscv_excess_precision): Add support
	for EXCESS_PRECISION_TYPE_FLOAT16.
2022-09-30 15:21:04 -07:00
Jonathan Wakely
789ddef1cf libstdc++: Remove <sstream> dependency from std::bitset::to_ulong() test
There's no need to use a stringstream to test the to_ulong() member.
This will allow the test to be used in freestanding mode.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/bitset/access/to_ulong.cc: Construct bitset
	from binary literal instead of using stringstream.
2022-09-30 21:52:02 +01:00
Jonathan Wakely
1c12a3cfdf libstdc++: Optimize operator>> for std::bitset
We can improve performance by using a char buffer instead of
basic_string. The loop bound already means we can't overflow the buffer,
and we don't need to keep writing a null character after every character
written to the buffer.

We could just use basic_string::resize(N) to zero-init the whole string,
then overwrite those chars. But that zero-init of all N chars would be
wasted in the case where we are writing to a bitset<N> with large N, but
only end up extracting one or two chars from the stream.

With this change we just use buffer of uninitialized chars.  For a
small-ish bitset (currently <= 256) we can improve performance further
by using alloca instead of the heap.

libstdc++-v3/ChangeLog:

	* include/std/bitset (operator>>): Use a simple buffer instead
	of std::basic_string.
2022-09-30 21:52:02 +01:00
Jonathan Wakely
4eb46f453c libstdc++: Remove non-standard public members in std::bitset
This makes _M_copy_from_ptr, _M_copy_from_string and _M_copy_to_string
private, and declares operator<< and operator>> as friends.

Also remove the historical _M_copy_from_string and _M_copy_to_string
overloads. Those were used before DR 396 was implemented but are
not needed now. There are no tests or docs describing them, so I don't
think we intend to support them as extensions.

libstdc++-v3/ChangeLog:

	* include/std/bitset (_M_copy_from_ptr, _M_copy_from_string)
	(_M_copy_to_string): Change access to private.
	(_M_copy_from_string(const basic_string&, size_t, size_t)):
	Remove.
	(_M_copy_to_string(const basic_string&)): Remove.
2022-09-30 21:52:02 +01:00
Jonathan Wakely
7069d03ba4 libstdc++: Fix broken dg-prune-output
The new pattern in the dg-prune-output directive doesn't work. Instead
of a messy regex full of leaning toothpicks, just match on the
diagnostic text instead of the header paths.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/bind/ref_neg.cc: Fix dg-prune-output
	directive.
2022-09-30 21:28:34 +01:00
Jakub Jelinek
61786edf7a arm, csky: Fix C++ ICEs with _Float16 and __fp16 [PR107080]
On Fri, Sep 30, 2022 at 09:54:49AM -0400, Jason Merrill wrote:
> > Note, there is one further problem on aarch64/arm, types with HFmode
> > (_Float16 and __fp16) are there mangled as Dh (which is standard
> > Itanium mangling:
> >                   ::= Dh # IEEE 754r half-precision floating point (16 bits)
> >                   ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
> > so in theory is also ok, but DF16_ is more specific.  Should we just
> > change Dh to DF16_ in those backends, or should __fp16 there be distinct
> > type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
>
> You argued for keeping __float128 separate from _Float128, does the same
> argument not apply to this case?

Actually, they already were distinct types that just mangled the same.
So the same issue that had to be solved on i?86, ia64 and rs6000 for
_Float64x vs. long double is a problem on arm and aarch64 with _Float16
vs. __fp16.
The following patch fixes it for arm after aarch64 has been changed
already before.

> > And there is csky, which mangles __fp16 (but only if type's name is __fp16,
> > not _Float16) as __fp16, that looks clearly invalid to me as it isn't
> > valid in the mangling grammar.  So perhaps just nuke csky's mangle_type
> > and have it mangled as DF16_ by the generic code?

And seems even on csky __fp16 is distinct type from _Float16 (which is a
good thing for consistency, these 3 targets are the only ones that have
__fp16 type), so instead the patch handles it the same as on arm/aarch64,
Dh mangling for __fp16 and DF16_ for _Float16.

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107080
	* config/arm/arm.cc (arm_mangle_type): Mangle just __fp16 as Dh
	and _Float16 as DF16_.
	* config/csky/csky.cc (csky_init_builtins): Fix a comment typo.
	(csky_mangle_type): Mangle __fp16 as Dh and _Float16 as DF16_
	rather than mangling __fp16 as __fp16.

	* g++.target/arm/pr107080.C: New test.
2022-09-30 21:55:39 +02:00
Lewis Hyatt
b52b99b62d diagnostics: Fix virtual location for -Wuninitialized [PR69543]
Warnings issued for -Wuninitialized have been using the spelling location of
the problematic usage, discarding any information on the location of the macro
expansion point if such usage was in a macro. This makes the warnings
impossible to control reliably with #pragma GCC diagnostic, and also discards
useful context in the diagnostic output. There seems to be no need to discard
the virtual location information, so this patch fixes that.

PR69543 was mostly about _Pragma issues which have been fixed for many years
now. The PR remains open because two of the testcases added in response to it
still have xfails, but those xfails have nothing to do with _Pragma and rather
just with the issue fixed by this patch, so the PR can be closed now as well.

The other testcase modified here, pragma-diagnostic-2.c, was explicitly
testing for the undesirable behavior that was xfailed in pr69543-3.c. I have
adjusted that and also added a new testcase verifying all 3 types of warning
that come from tree-ssa-uninit.cc get the proper location information now.

gcc/ChangeLog:

	PR preprocessor/69543
	* tree-ssa-uninit.cc (warn_uninit): Stop stripping macro tracking
	information away from the diagnostic location.
	(maybe_warn_read_write_only): Likewise.
	(maybe_warn_operand): Likewise.

gcc/testsuite/ChangeLog:

	PR preprocessor/69543
	* c-c++-common/pr69543-3.c: Remove xfail.
	* c-c++-common/pr69543-4.c: Likewise.
	* gcc.dg/cpp/pragma-diagnostic-2.c: Adjust test for new behavior.
	* c-c++-common/pragma-diag-16.c: New test.
2022-09-30 14:10:00 -04:00
Jakub Jelinek
e564021e4c aarch64: Fix C++ ICEs with _Float16 and __fp16 [PR107080]
On Fri, Sep 30, 2022 at 09:54:49AM -0400, Jason Merrill wrote:
> > Note, there is one further problem on aarch64/arm, types with HFmode
> > (_Float16 and __fp16) are there mangled as Dh (which is standard
> > Itanium mangling:
> >                   ::= Dh # IEEE 754r half-precision floating point (16 bits)
> >                   ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
> > so in theory is also ok, but DF16_ is more specific.  Should we just
> > change Dh to DF16_ in those backends, or should __fp16 there be distinct
> > type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
>
> You argued for keeping __float128 separate from _Float128, does the same
> argument not apply to this case?

Actually, they already were distinct types that just mangled the same.
So the same issue that had to be solved on i?86, ia64 and rs6000 for
_Float64x vs. long double is a problem on arm and aarch64 with _Float16
vs. __fp16.
The following patch fixes it so far for aarch64.

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107080
	* config/aarch64/aarch64.cc (aarch64_mangle_type): Mangle just __fp16
	as Dh and _Float16 as DF16_.

	* g++.target/aarch64/pr107080.C: New test.
2022-09-30 19:52:49 +02:00
Jakub Jelinek
a6d8c61a49 i386, rs6000, ia64, s390: Fix C++ ICEs with _Float64x or _Float128 [PR107080]
The following testcase ICEs on x86 as well as ppc64le (the latter
with -mabi=ieeelongdouble), because _Float64x there isn't mangled as
DF64x but e or u9__ieee128 instead.
Those are the mangling that should be used for the non-standard
types with the same mode or for long double, but not for _Float64x.
All the 4 mangle_type targhook implementations start with
type = TYPE_MAIN_VARIANT (type);
so I think it is cleanest to handle it the same in all and return NULL
before the switches on mode or whatever other tests.
s390 doesn't actually have a bug, but while I was there, having
type = TYPE_MAIN_VARIANT (type);
if (TYPE_MAIN_VARIANT (type) == long_double_type_node)
looked useless to me.

Note, there is one further problem on aarch64/arm, types with HFmode
(_Float16 and __fp16) are there mangled as Dh (which is standard
Itanium mangling:
                 ::= Dh # IEEE 754r half-precision floating point (16 bits)
                 ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
so in theory is also ok, but DF16_ is more specific.  Should we just
change Dh to DF16_ in those backends, or should __fp16 there be distinct
type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
And there is csky, which mangles __fp16 (but only if type's name is __fp16,
not _Float16) as __fp16, that looks clearly invalid to me as it isn't
valid in the mangling grammar.  So perhaps just nuke csky's mangle_type
and have it mangled as DF16_ by the generic code?

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107080
	* config/i386/i386.cc (ix86_mangle_type): Always return NULL
	for float128_type_node or float64x_type_node, don't check
	float128t_type_node later on.
	* config/ia64/ia64.cc (ia64_mangle_type): Always return NULL
	for float128_type_node or float64x_type_node.
	* config/rs6000/rs6000.cc (rs6000_mangle_type): Likewise.
	Don't check float128_type_node later on.
	* config/s390/s390.cc (s390_mangle_type): Don't use
	TYPE_MAIN_VARIANT on type which was set to TYPE_MAIN_VARIANT
	a few lines earlier.

	* g++.dg/cpp23/ext-floating11.C: New test.
2022-09-30 18:41:15 +02:00
Torbjörn SVENSSON
fe8264bb9b testsuite: Windows paths use \ and not /
libstdc++-v3/ChangeLog:

	* testsuite/20_util/bind/ref_neg.cc: Prune Windows paths too.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:33:06 +02:00
Torbjörn SVENSSON
5fb71366da testsuite: Only run test on target if VMA == LMA
Checking that the triplet matches arm*-*-eabi (or msp430-*-*) is not
enough to know if the execution will enter an endless loop, or if it
will give a meaningful result. As the execution test only work when
VMA and LMA are equal, make sure that this condition is met.

gcc/ChangeLog:

	* doc/sourcebuild.texi: Document new vma_equals_lma effective
	target check.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_vma_equals_lma): New.
	* c-c++-common/torture/attr-noinit-1.c: Requre VMA == LMA to run.
	* c-c++-common/torture/attr-noinit-2.c: Likewise.
	* c-c++-common/torture/attr-noinit-3.c: Likewise.
	* c-c++-common/torture/attr-persistent-1.c: Likewise.
	* c-c++-common/torture/attr-persistent-3.c: Likewise.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:28:46 +02:00
Torbjörn SVENSSON
86291da005 testsuite: Do not prefix linker script with "-Wl,"
The linker script should not be prefixed with "-Wl," - it's not an
input file and does not interfere with the new dump output filename
strategy.

gcc/testsuite/ChangeLog:

	* lib/gcc-defs.exp: Do not prefix linker script with "-Wl,".

Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 18:24:46 +02:00
Jiawei
32f86f2b54 RISC-V: Add '-m[no]-csr-check' option in gcc.
Add -m[no]-csr-check option in gcc part, when enable -mcsr-check option,
it will add csr-check in .option section and pass this to assembler.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_file_start): New .option.
	* config/riscv/riscv.opt: New options.
	* doc/invoke.texi: New definations.
2022-09-30 23:09:16 +08:00
Patrick Palka
1e2c124d71 c++: streamline built-in trait addition process
Adding a new built-in trait currently involves manual boilerplate
consisting of defining an rid enumerator for the identifier as well as a
corresponding cp_trait_kind enumerator and handling them in various switch
statements, the exact set of which depends on whether the proposed trait
yields (and thus is recognized as) a type or an expression.

To streamline the process, this patch adds a central cp-trait.def file
that tabulates the essential details about each built-in trait (whether
it yields a type or an expression, its code, its spelling and its arity)
and uses this file to automate away the manual boilerplate.  It also
migrates all the existing C++-specific built-in traits to use this
approach.

After this change, adding a new built-in trait just entails declaring
it in cp-trait.def and defining its behavior in finish_trait_expr/type
(and handling it in diagnose_trait_expr, if it's an expression-yielding
trait).

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_reswords): Use cp/cp-trait.def to handle
	C++ traits.
	* c-common.h (enum rid): Likewise.

gcc/cp/ChangeLog:

	* constraint.cc (diagnose_trait_expr): Likewise.
	* cp-objcp-common.cc (names_builtin_p): Likewise.
	* cp-tree.h (enum cp_trait_kind): Likewise.
	* cxx-pretty-print.cc (pp_cxx_trait): Likewise.
	* parser.cc (cp_keyword_starts_decl_specifier_p): Likewise.
	(cp_parser_primary_expression): Likewise.
	(cp_parser_trait): Likewise.
	(cp_parser_simple_type_specifier): Likewise.
	* cp-trait.def: New file.
2022-09-30 11:06:54 -04:00
Torbjörn SVENSSON
3bb2d70d38 testsuite: Colon is reserved on Windows
The ':' is reserved in filenames on Windows.

Without this patch, the test case failes with:
.../ben-1_a.C:4:8: error: failed to write compiled module: Invalid argument
.../ben-1_a.C:4:8: note: compiled module file is 'partitions/module:import.mod'

gcc/testsuite:

	* g++.dg/modules/ben-1.map: Replace the colon with dash.
	* g++.dg/modules/ben-1_a.C: Likewise

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-30 15:54:50 +02:00
Arsen Arsenović
57707f38f2 libstdc++: Add missing <bits/stl_algobase.h> include to <bitset>
libstdc++-v3/ChangeLog:

	* include/std/bitset: Include <bits/stl_algobase.h>.
2022-09-30 14:43:19 +01:00