197426 Commits

Author SHA1 Message Date
Tobias Burnus
e0b95c2e8b libgomp.texi: List GCN's 'gfx803' under OpenMP Context Selectors
libgomp/ChangeLog:

	* libgomp.texi (OpenMP Context Selectors): Add 'gfx803' to gcn's isa.
2022-11-30 11:23:41 +01:00
Paul-Antoine Arras
1fd508744e amdgcn: Support AMD-specific 'isa' traits in OpenMP context selectors
Add support for gfx803 as an alias for fiji.
Add test cases for all supported 'isa' values.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_omp_device_kind_arch_isa): Add gfx803.
	* config/gcn/t-omp-device: Add gfx803.

libgomp/ChangeLog:

	* testsuite/libgomp.c/declare-variant-4-fiji.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx803.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx900.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx906.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx908.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx90a.c: New test.
	* testsuite/libgomp.c/declare-variant-4.h: New header file.
2022-11-30 10:51:42 +01:00
Alexandre Oliva
a1b5cdf381 [PR107304] note test's ifunc requirement
The test uses target_clones, that requires ifunc support.


for  gcc/testsuite/ChangeLog

	PR target/107304
	* gcc.target/i386/pr107304.c: dg-require ifunc support.
2022-11-30 04:55:11 -03:00
Lulu Cheng
f57ff18957 LoongArch: Optimize the implementation of stack check.
The old stack check was performed before the stack was dropped,
which would cause the detection tool to report a memory leak.

The current stack check scheme is as follows:

'-fstack-clash-protection':
1. When the frame->total_size is smaller than the guard page size,
   the stack is dropped according to the original scheme, and there
   is no need to perform stack detection in the prologue.
2. When frame->total_size is greater than or equal to guard page size,
   the first step to drop the stack is to drop the space required by
   the caller-save registers. This space needs to save the caller-save
   registers, so an implicit stack check is performed.
   So just need to check the rest of the stack space.

'-fstack-check':
There is no one-time stack drop and then page-by-page detection as
described in the document. It is also the same as
'-fstack-clash-protection', which is detected immediately after page drop.

It is judged that when frame->total_size is not 0, only the size required
to save the s register is dropped for the first stack down.

The test cases are referenced from aarch64.

gcc/ChangeLog:

	* config/loongarch/linux.h (STACK_CHECK_MOVING_SP):
	Define this macro to 1.
	* config/loongarch/loongarch.cc (STACK_CLASH_PROTECTION_GUARD_SIZE):
	Size of guard page.
	(loongarch_first_stack_step): Return the size of the first drop stack
	according to whether stack checking is performed.
	(loongarch_emit_probe_stack_range): Adjust the method of stack checking in prologue.
	(loongarch_output_probe_stack_range): Delete useless code.
	(loongarch_expand_prologue): Adjust the method of stack checking in prologue.
	(loongarch_option_override_internal): Enforce that interval is the same
	size as size so the mid-end does the right thing.
	* config/loongarch/loongarch.h (STACK_CLASH_MAX_UNROLL_PAGES):
	New macro decide whether to loop stack detection.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp:
	* gcc.target/loongarch/stack-check-alloca-1.c: New test.
	* gcc.target/loongarch/stack-check-alloca-2.c: New test.
	* gcc.target/loongarch/stack-check-alloca-3.c: New test.
	* gcc.target/loongarch/stack-check-alloca-4.c: New test.
	* gcc.target/loongarch/stack-check-alloca-5.c: New test.
	* gcc.target/loongarch/stack-check-alloca-6.c: New test.
	* gcc.target/loongarch/stack-check-alloca.h: New test.
	* gcc.target/loongarch/stack-check-cfa-1.c: New test.
	* gcc.target/loongarch/stack-check-cfa-2.c: New test.
	* gcc.target/loongarch/stack-check-prologue-1.c: New test.
	* gcc.target/loongarch/stack-check-prologue-2.c: New test.
	* gcc.target/loongarch/stack-check-prologue-3.c: New test.
	* gcc.target/loongarch/stack-check-prologue-4.c: New test.
	* gcc.target/loongarch/stack-check-prologue-5.c: New test.
	* gcc.target/loongarch/stack-check-prologue-6.c: New test.
	* gcc.target/loongarch/stack-check-prologue-7.c: New test.
	* gcc.target/loongarch/stack-check-prologue.h: New test.
2022-11-30 11:11:34 +08:00
David Malcolm
84046b192e analyzer: move stdio known fns to sm-file.cc
gcc/analyzer/ChangeLog:
	* region-model-impl-calls.cc (class kf_fgets): Move to sm-file.cc.
	(kf_fgets::impl_call_pre): Likewise.
	(class kf_fread): Likewise.
	(kf_fread::impl_call_pre): Likewise.
	(class kf_getchar): Likewise.
	(class kf_stdio_output_fn): Likewise.
	(register_known_functions): Move registration of
	BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC,
	BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
	BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
	BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR,
	BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS,
	BUILT_IN_PUTS_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF,
	"getchar", "fgets", "fgets_unlocked", and "fread" to
	register_known_file_functions.
	* sm-file.cc (class kf_stdio_output_fn): Move here from
	region-model-impl-calls.cc.
	(class kf_fgets): Likewise.
	(class kf_fread): Likewise.
	(class kf_getchar): Likewise.
	(register_known_file_functions): Move registration of
	BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC,
	BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
	BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
	BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR,
	BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS,
	BUILT_IN_PUTS_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF,
	"fgets", "fgets_unlocked", "fread", and "getchar" to here from
	register_known_functions.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-29 19:56:27 -05:00
David Malcolm
78a17f4452 analyzer work on issues with flex-generated lexers [PR103546]
PR analyzer/103546 tracks various false positives seen on
flex-generated lexers.

Whilst investigating them, I noticed an ICE with
-fanalyzer-call-summaries due to attempting to store sm-state
for an UNKNOWN svalue, which this patch fixes.

This patch also provides known_function implementations of all of the
external functions called by the lexer, reducing the number of false
positives.

The patch doesn't eliminate all false positives, but adds integration
tests to try to establish a baseline from which the remaining false
positives can be fixed.

gcc/analyzer/ChangeLog:
	PR analyzer/103546
	* analyzer.h (register_known_file_functions): New decl.
	* program-state.cc (sm_state_map::replay_call_summary): Rejct
	attempts to store sm-state for caller_sval that can't have
	associated state.
	* region-model-impl-calls.cc (register_known_functions): Call
	register_known_file_functions.
	* sm-fd.cc (class kf_isatty): New.
	(register_known_fd_functions): Register it.
	* sm-file.cc (class kf_ferror): New.
	(class kf_fileno): New.
	(class kf_getc): New.
	(register_known_file_functions): New.

gcc/ChangeLog:
	PR analyzer/103546
	* doc/invoke.texi (Static Analyzer Options): Add isatty, ferror,
	fileno, and getc to the list of functions known to the analyzer.

gcc/testsuite/ChangeLog:
	PR analyzer/103546
	* gcc.dg/analyzer/ferror-1.c: New test.
	* gcc.dg/analyzer/fileno-1.c: New test.
	* gcc.dg/analyzer/flex-with-call-summaries.c: New test.
	* gcc.dg/analyzer/flex-without-call-summaries.c: New test.
	* gcc.dg/analyzer/getc-1.c: New test.
	* gcc.dg/analyzer/isatty-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-29 19:56:27 -05:00
David Malcolm
3a32fb2eaa analyzer: fix folding of '(PTR + 0) => PTR' [PR105784]
gcc/analyzer/ChangeLog:
	PR analyzer/105784
	* region-model-manager.cc
	(region_model_manager::maybe_fold_binop): For POINTER_PLUS_EXPR,
	PLUS_EXPR and MINUS_EXPR, eliminate requirement that the final
	type matches that of arg0 in favor of a cast.

gcc/testsuite/ChangeLog:
	PR analyzer/105784
	* gcc.dg/analyzer/torture/fold-ptr-arith-pr105784.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-29 19:56:27 -05:00
Patrick Palka
000e986312 c++: ICE with <=> of incompatible pointers [PR107542]
In a SFINAE context composite_pointer_type returns error_mark_node if
the given pointer types are incompatible.  But the SPACESHIP_EXPR case
of cp_build_binary_op wasn't prepared for this error_mark_node result,
which led to an ICE (from spaceship_comp_cat) for the below testcase.
(In a non-SFINAE context composite_pointer_type issues a permerror and
returns cv void* in this case, so this ICE seems specific to SFINAE.)

	PR c++/107542

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_binary_op): In the SPACESHIP_EXPR case,
	handle an error_mark_node result type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/spaceship-sfinae2.C: New test.
2022-11-29 19:25:37 -05:00
GCC Administrator
9b37746385 Daily bump. 2022-11-30 00:17:59 +00:00
Ian Lance Taylor
b6c6a3d64f syscall, runtime: always call XSI strerror_r
This does the right thing for either glibc or musl on GNU/Linux.

Based on patch by Sören Tempel.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/454176
2022-11-29 16:09:13 -08:00
Harald Anlauf
3832c6f7e6 Fortran: intrinsic MERGE shall use all its arguments [PR107874]
gcc/fortran/ChangeLog:

	PR fortran/107874
	* simplify.cc (gfc_simplify_merge): When simplifying MERGE with a
	constant scalar MASK, ensure that arguments TSOURCE and FSOURCE are
	either constant or will be evaluated.
	* trans-intrinsic.cc (gfc_conv_intrinsic_merge): Evaluate arguments
	before generating conditional expression.

gcc/testsuite/ChangeLog:

	PR fortran/107874
	* gfortran.dg/merge_init_expr_2.f90: Adjust code to the corrected
	simplification.
	* gfortran.dg/merge_1.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2022-11-29 19:11:10 +01:00
Jonathan Wakely
cca06f0d6d libstdc++: Avoid bogus warning in std::vector::insert [PR107852]
GCC assumes that any global variable might be modified by operator new,
and so in the testcase for this PR all data members get reloaded after
allocating new storage. By making local copies of the _M_start and
_M_finish members we avoid that, and then the compiler has enough info
to remove the dead branches that trigger bogus -Warray-bounds warnings.

libstdc++-v3/ChangeLog:

	PR libstdc++/107852
	PR libstdc++/106199
	PR libstdc++/100366
	* include/bits/vector.tcc (vector::_M_fill_insert): Copy
	_M_start and _M_finish members before allocating.
	(vector::_M_default_append): Likewise.
	(vector::_M_range_insert): Likewise.
2022-11-29 17:01:32 +00:00
Jonathan Wakely
81cf0354d5 libstdc++: Remove unnecessary tag dispatching in std::vector
There's no need to call a _M_xxx_dispatch function with a
statically-known __false_type tag, we can just directly call the
function that should be dispatched to. This will compile a tiny bit
faster and save a function call with optimization or inlining turned
off.

Also add the always_inline attribute to the __iterator_category helper
used for dispatching on the iterator category.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator_base_types.h (__iterator_category):
	Add always_inline attribute.
	* include/bits/stl_vector.h (assign(Iter, Iter)): Call
	_M_assign_aux directly, instead of _M_assign_dispatch.
	(insert(const_iterator, Iter, Iter)): Call _M_range_insert
	directly instead of _M_insert_dispatch.
2022-11-29 16:01:08 +00:00
Jonathan Wakely
0ded30b361 libstdc++: Do not use __used or __packed as identifiers
These names (and __unused) are defined as macros by newlib.

libstdc++-v3/ChangeLog:

	* include/std/format: Rename all variables called __used or
	__packed.
	* testsuite/17_intro/badnames.cc: Add no_pch options.
	* testsuite/17_intro/names.cc: Check __packed, __unused and
	__used.
2022-11-29 15:32:50 +00:00
Patrick Palka
36cabc257d c++: explicit specialization and trailing requirements [PR107864]
Here we're crashing when using the explicit specialization of the
function template g with trailing requirements ultimately because
earlier decls_match (called indirectly from register_specialization) for
for the explicit specialization returned false since the template has
trailing requirements whereas the specialization doesn't.

In r12-2230-gddd25bd1a7c8f4, we fixed a similar issue concerning template
requirements instead of trailing requirements.  We could extend that fix
to ignore trailing requirement mismatches for explicit specializations
as well, but it seems cleaner to just propagate constraints from the
specialized template to the specialization when declaring an explicit
specialization so that decls_match will naturally return true in this
case.  And it looks like determine_specialization already does this,
albeit inconsistently (only when specializing a non-template member
function of a class template as in cpp2a/concepts-explicit-spec4.C).

So this patch makes determine_specialization consistently propagate
constraints from the specialized template to the specialization, which
in turn lets us get rid of the function_requirements_equivalent_p special
case added by r12-2230.

	PR c++/107864

gcc/cp/ChangeLog:

	* decl.cc (function_requirements_equivalent_p): Don't check
	DECL_TEMPLATE_SPECIALIZATION.
	* pt.cc (determine_specialization): Propagate constraints when
	specializing a function template too.  Simplify by using
	add_outermost_template_args.

gcc/testsuite/ChangeLog:

	* g++.dg/concepts/explicit-spec1a.C: New test.
2022-11-29 09:55:21 -05:00
Richard Biener
fd8dd6c038 tree-optimization/107852 - missed optimization with PHIs
The following deals with the situation where we have

<bb 2> [local count: 1073741824]:
_5 = bytes.D.25336._M_impl.D.24643._M_start;
_6 = bytes.D.25336._M_impl.D.24643._M_finish;
pretmp_66 = bytes.D.25336._M_impl.D.24643._M_end_of_storage;
if (_5 != _6)
  goto <bb 3>; [70.00%]
else
  goto <bb 4>; [30.00%]

...

<bb 6> [local count: 329045359]:
_89 = operator new (4);
_43 = bytes.D.25336._M_impl.D.24643._M_start;
_Num_44 = _137 - _43;
if (_Num_44 != 0)

but fail to see that _137 is equal to _5 and thus eventually _Num_44
is zero if not operator new would possibly clobber the global
bytes variable.

The following resolves this in value-numbering by using the
predicated values for _5 == _6 recorded for the dominating
condition.

	PR tree-optimization/107852
	* tree-ssa-sccvn.cc (visit_phi): Use equivalences recorded
	as predicated values to elide more redundant PHIs.

	* gcc.dg/tree-ssa/ssa-fre-101.c: New testcase.
2022-11-29 14:30:35 +01:00
Richard Biener
063ba138ea tree-optimization/106995 - if-conversion and vanishing loops
When we version loops for vectorization during if-conversion it
can happen that either loop vanishes because we run some VN and
CFG cleanup.  If the to-be vectorized part vanishes we already
redirect the versioning condition to the original loop.  The following
does the same in case the original loop vanishes as happened
for the testcase in the bug in the past (but no longer).

	PR tree-optimization/106995
	* tree-if-conv.cc (pass_if_conversion::execute): Also redirect the
	versioning condition to the original loop if this very loop
	vanished during CFG cleanup.
2022-11-29 12:59:23 +01:00
Eric Botcazou
ffabce8490 Couple of testsuite adjustments
gcc/testsuite/
	* gcc.dg/ipa/iinline-attr.c: XFAIL on SPARC.
	* gcc.dg/signbit-2.c: Replace vect_int selector by vect_shift.
2022-11-29 11:46:31 +01:00
Eric Botcazou
1ad898d827 Fix PR ada/107810
This just makes the pattern matching more robust.

gcc/testsuite/
	PR ada/107810
	* gnat.dg/unchecked_convert9.adb: Adjust pattern.
2022-11-29 11:46:31 +01:00
Richard Biener
9948daa4fd tree-optimization/107898 - ICE with -Walloca-larger-than
The following avoids ICEing with a mismatched prototype for alloca
and -Walloca-larger-than using irange for checks which doesn't
like mismatched types.

	PR tree-optimization/107898
	* gimple-ssa-warn-alloca.cc (alloca_call_type): Check
	the type of the alloca argument is compatible with size_t
	before querying ranges.
2022-11-29 10:25:39 +01:00
Richard Biener
5894a81796 ipa/107897 - avoid property verification ICE after error
The target clone pass is the only small IPA pass that doesn't disable
itself after errors but has properties whose verification can fail
because we cut off build SSA passes after errors.

	PR ipa/107897
	* multiple_target.cc (pass_target_clone::gate): Disable
	after errors.
2022-11-29 10:25:39 +01:00
Martin Liska
e161040732 re-run configure
gcc/ChangeLog:

	* configure: Regenerate.
2022-11-29 09:33:59 +01:00
YunQiang Su
4d08c674b0 gcc/configure.ac: fix AC_DEFINE ENABLE_MULTIARCH
Description section was missing in AC_DEFINE(ENABLE_MULTIARCH, 1).
It makes autoheader fail.

Thanks Lulu Cheng points it out.

gcc/ChangeLog:

	* configure.ac: add description for
	AC_DEFINE(ENABLE_MULTIARCH, 1)
2022-11-29 11:15:07 +08:00
GCC Administrator
b774853514 Daily bump. 2022-11-29 00:18:09 +00:00
Jason Merrill
2b0ae7fb91 c++: simple-requirement starting with 'typename' [PR101733]
Usually a requirement starting with 'typename' is a type-requirement, but it
might be a simple-requirement such as a functional cast to a typename-type.

	PR c++/101733

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_requirement): Parse tentatively for the
	'typename' case.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires32.C: New test.
2022-11-28 15:51:53 -05:00
Jason Merrill
297bbe2d0d c++: be more strict about 'concept bool'
Some clang folks mailed me asking about being less permissive about
'concept bool', so let's bump it up from pedwarn to permerror.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_decl_specifier_seq): Change 'concept bool'
	diagnostic from pedwarn to permerror.
2022-11-28 15:50:43 -05:00
Andrew Pinski
47d81b1b89 Fix comment for (A / (1 << B)) -> (A >> B).
There was a small typo where Also was done
twice. The second also should have been
handled. This fixes that.

Committed as obvious after a build.

gcc/ChangeLog:

	* match.pd ((A / (1 << B)) -> (A >> B).):
	Fix comment.
2022-11-28 20:13:19 +00:00
Sinan
940d5b5699 riscv: improve cost model for loading 64bit constant in rv32
The motivation of this patch is to correct the wrong estimation of the number of instructions needed for loading a 64bit constant in rv32 in the current cost model(riscv_interger_cost). According to the current implementation, if a constant requires more than 3 instructions(riscv_const_insn and riscv_legitimate_constant_p), then the constant will be put into constant pool when expanding gimple to rtl(legitimate_constant_p hook and emit_move_insn). So the inaccurate cost model leads to the suboptimal codegen in rv32 and the wrong estimation part could be corrected through this fix.

e.g. the current codegen for loading 0x839290001 in rv32

  lui     a5,%hi(.LC0)
  lw      a0,%lo(.LC0)(a5)
  lw      a1,%lo(.LC0+4)(a5)
.LC0:
  .word   958988289
  .word   8

output after this patch

  li a0,958988288
  addi a0,a0,1
  li a1,8

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_build_integer): Improve some cases
	of loading 64bit constants for rv32.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rv32-load-64bit-constant.c: New test.
2022-11-28 12:43:20 -07:00
Maciej W. Rozycki
868fc62791 RISC-V: Avoid redundant sign-extension for SImode SGE, SGEU, SLE, SLEU
We produce inefficient code for some synthesized SImode conditional set
operations (i.e. ones that are not directly implemented in hardware) on
RV64.  For example a piece of C code like this:

int
sleu (unsigned int x, unsigned int y)
{
  return x <= y;
}

gets compiled (at `-O2') to this:

sleu:
	sgtu	a0,a0,a1	# 9	[c=4 l=4]  *sgtu_disi
	xori	a0,a0,1		# 10	[c=4 l=4]  *xorsi3_internal/1
	andi	a0,a0,1		# 16	[c=4 l=4]  anddi3/1
	ret			# 25	[c=0 l=4]  simple_return

or (at `-O1') to this:

sleu:
	sgtu	a0,a0,a1	# 9	[c=4 l=4]  *sgtu_disi
	xori	a0,a0,1		# 10	[c=4 l=4]  *xorsi3_internal/1
	sext.w	a0,a0		# 16	[c=4 l=4]  extendsidi2/0
	ret			# 24	[c=0 l=4]  simple_return

This is because the middle end expands a SLEU operation missing from
RISC-V hardware into a sequence of a SImode SGTU operation followed by
an explicit SImode XORI operation with immediate 1.  And while the SGTU
machine instruction (alias SLTU with the input operands swapped) gives a
properly sign-extended 32-bit result which is valid both as a SImode or
a DImode operand the middle end does not see that through a SImode XORI
operation, because we tell the middle end that the RISC-V target (unlike
MIPS) may hold values in DImode integer registers that are valid for
SImode operations even if not properly sign-extended.

However the RISC-V psABI requires that 32-bit function arguments and
results passed in 64-bit integer registers be properly sign-extended, so
this is explicitly done at the conclusion of the function.

Fix this by making the backend use a sequence of a DImode SGTU operation
followed by a SImode SEQZ operation instead.  The latter operation is
known by the middle end to produce a properly sign-extended 32-bit
result and therefore combine gets rid of the sign-extension operation
that follows and actually folds it into the very same XORI machine
operation resulting in:

sleu:
	sgtu	a0,a0,a1	# 9	[c=4 l=4]  *sgtu_didi
	xori	a0,a0,1		# 16	[c=4 l=4]  xordi3/1
	ret			# 25	[c=0 l=4]  simple_return

instead (although the SEQZ alias SLTIU against immediate 1 machine
instruction would equally do and is actually retained at `-O0').  This
is handled analogously for the remaining synthesized operations of this
kind, i.e. `SLE', `SGEU', and `SGE'.

	gcc/
	* config/riscv/riscv.cc (riscv_emit_int_order_test): Use EQ 0
	rather that XOR 1 for LE and LEU operations.

	gcc/testsuite/
	* gcc.target/riscv/sge.c: New test.
	* gcc.target/riscv/sgeu.c: New test.
	* gcc.target/riscv/sle.c: New test.
	* gcc.target/riscv/sleu.c: New test.
2022-11-28 19:36:15 +00:00
Harald Anlauf
07b9bcc1d1 Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819]
gcc/fortran/ChangeLog:

	PR fortran/107819
	* trans-stmt.cc (gfc_conv_elemental_dependencies): In checking for
	elemental dependencies, treat dummy argument with VALUE attribute
	as implicitly having intent(in).

gcc/testsuite/ChangeLog:

	PR fortran/107819
	* gfortran.dg/elemental_dependency_7.f90: New test.
2022-11-28 19:53:53 +01:00
Richard Biener
2200b70546 tree-optimization/107896 - allow v2si to dimode unpacks
The following avoids ICEing for V2SI -> DImode vec_unpacks_lo.

	PR tree-optimization/107896
	* tree-vect-stmts.cc (supportable_widening_operation):
	Handle non-vector mode intermediate mode.
2022-11-28 19:41:24 +01:00
François Dumont
26aff453bf libstdc++: [_GLIBCXX_INLINE_VERSION] Adapt dg-error message
libstdc++-v3/ChangeLog

	* testsuite/20_util/function/cons/70692.cc: Adapt dg-error message.
2022-11-28 18:55:07 +01:00
Frolov Daniil
aa353bd9a0 Support %b, %B for -Wformat-overflow (sprintf, snprintf)
gcc/ChangeLog:

	* gimple-ssa-sprintf.cc (fmtresult::type_max_digits): Handle
	base == 2.
	(tree_digits): Likewise.
	(format_integer): Likewise.
	(parse_directive): Add cases for %b and %B directives.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wformat-overflow1.c: New test.
2022-11-28 12:35:13 -05:00
Jonathan Wakely
75e562d2c4 libstdc++: Fix src/c++17/memory_resource for H8 targets [PR107801]
This fixes compilation failures for H8 multilibs. For the normal
multilib (ILP16L32?), the chunk struct does not have the expected size,
because uint32_t is type long and has alignment 4 (by default). This
forces sizeof(chunk) to be 12 instead of the expected 10. We can fix
that by using bitset::size_type instead of uint32_t, so that we only use
a 16-bit size when size_t and pointers are 16-bit types.

For the I32LP16 multilibs that use -mint32 int is wider than size_t
and so arithmetic expressions involving size_t promote to int. This
means we need some explicit casts back to size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/107801
	* src/c++17/memory_resource.cc (chunk::_M_bytes): Change type
	from uint32_t to bitset::size_type. Adjust static assertion.
	(__pool_resource::_Pool::replenish): Cast to size_t after
	multiplication instead of before.
	(__pool_resource::_M_alloc_pools): Ensure both arguments to
	std::max have type size_t.
2022-11-28 16:57:36 +00:00
Jonathan Wakely
a7b97a1f6b libstdc++: Fix std::string_view for I32LP16 targets
For H8/300 with -msx -mn -mint32 the type of (_M_len - __pos) is int,
because int is wider than size_t so the operands are promoted.

libstdc++-v3/ChangeLog:

	* include/std/string_view (basic_string_view::copy) Use explicit
	template argument for call to std::min<size_t>.
	(basic_string_view::substr): Likewise.
2022-11-28 16:57:36 +00:00
Jonathan Wakely
7b79fa9309 libstdc++: Fix _Hash_bytes for I16LP32 targets [PR107885]
For H8/300 size_t is 32 bits wide, but (unsigned char)buf[2] << 16
promotes to int which is only 16 bits wide. The shift is then undefined.
This fixes it by converting to size_t before shifting.

libstdc++-v3/ChangeLog:

	PR libstdc++/107885
	* libsupc++/hash_bytes.cc (_Hash_bytes): Convert to size_t
	instead of implicit integer promotion to 16 bits.
2022-11-28 16:57:35 +00:00
Fei Gao
f7a41b5cfd RISC-V: fix stack access before allocation.
In current riscv stack frame allocation, 2 steps are used. The first step allocates memories at least for callee saved GPRs and FPRs, and the second step allocates the rest if stack size is greater than signed 12-bit range. But it's observed in some cases, like gcc.target/riscv/stack_frame.c in my patch, callee saved FPRs fail to be included in the first step allocation, so we get generated instructions like this:

	li	t0,-16384
	addi	sp,sp,-48
	addi	t0,t0,752
	...
	fsw	fs4,-4(sp) #issue here of accessing before allocation
	...
	add	sp,sp,t0

"fsw	fs4,-4(sp)" has issue here of accessing stack before allocation. Although "add	sp,sp,t0" reserves later the memory for fs4, it exposes a risk when an interrupt comes in between "fsw	fs4,-4(sp)" and "add	sp,sp,t0", resulting in a corruption in the stack storing fs4 after interrupt context saving and a failure to get the correct value of fs4 later.

This patch fixes issue above, adapts testcases identified in regression tests, and add a new testcase for the change.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_first_stack_step): Fix computation
	of MIN_FIRST_STEP to cover FP save area too.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr93304.c: Adapt testcase for the change, constrain
	match to assembly instructions only.
	* gcc.target/riscv/rvv/base/spill-11.c: Adapt testcase for the change.
	* gcc.target/riscv/stack_frame.c: New test.
2022-11-28 11:33:23 -05:00
Torbjörn SVENSSON
d30e98b54d c++: Allow module name to be a single letter on Windows
On Windows, the ':' character is special and when the module name is
a single character, like 'A', then the flatname would be (for
example) 'A:Foo'. On Windows, 'A:Foo' is treated as an absolute
path by the module loader and is likely not found.

Without this patch, the test case pr98944_c.C fails with:

In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_b.C:7:1,
of module A:Foo, imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:
A:Internals: error: header module expected, module 'A:Internals' found
A:Internals: error: failed to read compiled module: Bad file data
A:Internals: note: compiled module file is 'gcm.cache/A-Internals.gcm'
In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:8:
A:Foo: error: failed to read compiled module: Bad import dependency
A:Foo: note: compiled module file is 'gcm.cache/A-Foo.gcm'
A:Foo: fatal error: returning to the gate for a mechanical issue
compilation terminated.

gcc/cp/ChangeLog:

	* module.cc: On Windows, 'A:Foo' is supposed to be a module
	and not a path.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-11-28 16:49:31 +01:00
Jonathan Wakely
c775e2b81f libstdc++: Replace non-ASCII character in comment
This has an unnecessary UTF-8 non-breaking space.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc:
	Replace non-ASCII character.
2022-11-28 15:22:40 +00:00
Jonathan Wakely
8a47132063 libstdc++: Prune versioned namespace from testsuite output
This means we don't need to use "(__8::)?" in dg-prune-output
directives.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
	Simplify dg-prune-output pattern.
	* testsuite/lib/prune.exp (libstdc++-dg-prune): Prune "::__8".
2022-11-28 15:03:15 +00:00
Jonathan Wakely
a64775a0ed libstdc++: Make 16-bit std::subtract_with_carry_engine work [PR107466]
This implements the proposed resolution of LWG 3809, so that
std::subtract_with_carry_engine can be used with a 16-bit result_type.
Currently this produces a narrowing error when instantiating the
std::linear_congruential_engine to create the initial state. It also
truncates the default_seed constant when passing it as a result_type
argument.

Change the type of the constant to uint_least32_t and pass 0u when the
default_seed should be used.

libstdc++-v3/ChangeLog:

	PR libstdc++/107466
	* include/bits/random.h (subtract_with_carry_engine): Use 32-bit
	type for default seed. Use 0u as default argument for
	subtract_with_carry_engine(result_type) constructor and
	seed(result_type) member function.
	* include/bits/random.tcc (subtract_with_carry_engine): Use
	32-bit type for default seed and engine used for initial state.
	* testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc:
	New test.
2022-11-28 15:02:04 +00:00
Eric Botcazou
be7ea14551 ada: Adjust runtime library and User's Guide to PIE default on Linux
gcc/ada/

	* libgnat/g-traceb.ads: Minor tweaks in the commentary.
	(Executable_Load_Address): New function.
	* doc/gnat_ugn/gnat_and_program_execution.rst (Non-Symbolic
	Traceback): Adjust to PIE default on Linux.
	(Symbolic Traceback): Likewise.
	* doc/gnat_ugn/gnat_utility_programs.rst (gnatsymbolize): Likewise.
	* gnat_ugn.texi: Regenerate.
2022-11-28 13:02:32 +01:00
Joel Brobecker
81885f5cca ada: doc/share/conf.py: Switch the HTML documentation to using the RTD theme
This commit adjust the sphinx configuration to use the "Read The Docs"
theme, which has the advantage of allowing the navigation bar
(containing among other things a search bar, and the TOC) to stay
fixed while scrolling the contents of the page being read. This is
particularly useful to allow access to those features while reading
a long page, for instance.

gcc/ada/

	* doc/share/conf.py (extensions): Add 'sphinx_rtd_theme'.
	(html_theme): Set to 'sphinx_rtd_theme'.
2022-11-28 13:02:32 +01:00
Claire Dross
80ad275cf1 ada: Annotate GNAT.Source_Info with an abstract state
So it can be used safely from SPARK code. The abstract state represents
the source code information that is accessed by the functions defined
in Source_Info. It is volatile as it is updated asyncronously when
moving in the code.

gcc/ada/

	* libgnat/g-souinf.ads (Source_Code_Information): Add a new
	volatile abstract state and add it in the global contract of all
	functions defined in Source_Info.
2022-11-28 13:02:31 +01:00
Eric Botcazou
e75d06f9bf ada: Fix internal error on conversion as in/out actual with -gnatVa
The problem is that the regular expansion of the conversion around the
call to the subprogram is disabled by the expansion of the validity check
around the same call, as documented in Expand_Actuals:

  --  This case is given higher priority because the subsequent check
  --  for type conversion may add an extra copy of the variable and
  --  prevent proper value propagation back in the original object.

Now the two mechanisms need to cooperate in order for the code to compile.

gcc/ada/

	* exp_ch6.adb (Expand_Actuals.Add_Call_By_Copy_Code): Deal with a
	reference to a validation variable in the actual.
	(Expand_Actuals.Add_Validation_Call_By_Copy_Code): Minor tweak.
	(Expand_Actuals): Call Add_Validation_Call_By_Copy_Code directly
	only if Add_Call_By_Copy_Code is not to be invoked.
2022-11-28 13:02:31 +01:00
Eric Botcazou
f2b30a724e ada: Add PIE support to backtraces on Linux
gcc/ada/

	* adaint.c [Linux]: Include <link.h>.
	(__gnat_get_executable_load_address) [Linux]: Enable.
2022-11-28 13:02:31 +01:00
Yannick Moy
83e8d37fe3 ada: Implement change to SPARK RM rule on state refinement
SPARK RM 7.1.4(4) does not mandate anymore that a package with abstract
states has a completing body, unless the package state is mentioned in
Part_Of specifications. Implement that change.

gcc/ada/

	* sem_prag.adb (Check_Part_Of_Abstract_State): Add verification
	related to use of Part_Of, so that constituents in private childs
	that refer to state in a sibling or parent unit force that unit to
	have a body.
	* sem_util.adb (Check_State_Refinements): Drop the requirement to
	have always a package body for state refinement, when the package
	state is mentioned in no Part_Of specification.
	* sem_ch3.adb (Analyze_Declarations): Refresh SPARK refs in comment.
	* sem_ch7.adb (Analyze_Package_Declaration): Likewise.
2022-11-28 13:02:31 +01:00
Richard Biener
2b293a949c tree-optimization/107493 - SCEV analysis with conversions
This shows another case where trying to validate conversions during
the CHREC SCC analysis fails because said analysis assumes we are
converting a complete SCC.  Like the constraint on the initial
conversion seen restrict all conversions handled to sign-changes.

	PR tree-optimization/107493
	* tree-scalar-evolution.cc (scev_dfs::follow_ssa_edge_expr):
	Only handle no-op and sign-changing conversions.

	* gcc.dg/torture/pr107493.c: New testcase.
2022-11-28 11:17:03 +01:00
Tobias Burnus
9fa67f1c12 gcn: Fix __builtin_gcn_first_call_this_thread_p
Contrary naive expectation, unspec_volatile (via prologue_use) did not
prevent the cprop pass (at -O2) to remove the access to the s[0:1]
(PRIVATE_SEGMENT_BUFFER_ARG) register as the volatile got just put on
the preceeding pseudoregister.  Solution: Use gen_rtx_USE instead.
Additionally, this patch removes (gen_)prologue_use_di as it is then no
longer used.

Finally, as we already do bit manipulation, instead of using the full
64bit side - and then just keeping the value of 's0', just move directly
to use only s1 of s[0:1] and do the bit manipulations there, generating
more readable assembly code and better matching the '#else' branch.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_expand_builtin_1): Work on s1 instead
	of s[0:1] and use USE to prevent removal of setting that register.
	* config/gcn/gcn.md (prologue_use_di): Remove.
2022-11-28 11:11:43 +01:00
Tobias Burnus
091b6dbc48 OpenMP/Fortran: Permit end-clause on directive
gcc/fortran/ChangeLog:

	* openmp.cc (OMP_DO_CLAUSES, OMP_SCOPE_CLAUSES,
	OMP_SECTIONS_CLAUSES): Add 'nowait'.
	(OMP_SINGLE_CLAUSES): Add 'nowait' and 'copyprivate'.
	(gfc_match_omp_distribute_parallel_do,
	gfc_match_omp_distribute_parallel_do_simd,
	gfc_match_omp_parallel_do,
	gfc_match_omp_parallel_do_simd,
	gfc_match_omp_parallel_sections,
	gfc_match_omp_teams_distribute_parallel_do,
	gfc_match_omp_teams_distribute_parallel_do_simd): Disallow 'nowait'.
	(gfc_match_omp_workshare): Match 'nowait' clause.
	(gfc_match_omp_end_single): Use clause matcher for 'nowait'.
	(resolve_omp_clauses): Reject 'nowait' + 'copyprivate'.
	* parse.cc (decode_omp_directive): Break too long line.
	(parse_omp_do, parse_omp_structured_block): Diagnose duplicated
	'nowait' clause.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.2): Mark end-directive as Y.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/copyprivate-1.f90: New test.
	* gfortran.dg/gomp/copyprivate-2.f90: New test.
	* gfortran.dg/gomp/nowait-2.f90: Move dg-error tests ...
	* gfortran.dg/gomp/nowait-4.f90: ... to this new file.
	* gfortran.dg/gomp/nowait-5.f90: New test.
	* gfortran.dg/gomp/nowait-6.f90: New test.
	* gfortran.dg/gomp/nowait-7.f90: New test.
	* gfortran.dg/gomp/nowait-8.f90: New test.
2022-11-28 11:10:31 +01:00