Commit Graph

194220 Commits

Author SHA1 Message Date
Piotr Trojanek
5a387a2b8f [Ada] Warn about obsolete uses of renamed Ada 83 packages
Ada 83 packages like Unchecked_Conversion or Text_IO are obsolete since
Ada 95. GNAT now warns about their uses when warnings on obsolescent
featured (Annex J) is active.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Warning Message Control): Update description of switch -gnatwj.
	* gnat_ugn.texi: Regenerate.
	* sem_ch10.adb (Analyze_With_Clause): Warn on WITH clauses for
	obsolete renamed units; in Ada 83 mode do not consider
	predefined renamings to be obsolete.

gcc/testsuite/

	* gnat.dg/renaming1.adb: Update WITH clause.
	* gnat.dg/renaming1.ads: Likewise.
	* gnat.dg/warn29.adb: Likewise.
2022-07-05 08:28:21 +00:00
Eric Botcazou
d2672ffea0 [Ada] Couple of small cleanups for Cloned_Subtype
No functional changes.

gcc/ada/

	* exp_util.adb (Make_Subtype_From_Expr): Do not set field to Empty.
	* sem_util.adb (Visit_Itype): Remove ??? comment.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
a2eaf87ffe [Ada] Remove kludge for validity checks on Long_Float type
This patch reverts a fix for a spurious warning for validity checks on
type Long_Float. This fix was dubious (as it was only affecting
Long_Float and not Float) and apparently is no longer needed.

Cleanup related to improved detection of uninitialised scalar objects.

gcc/ada/

	* sem_attr.adb (Note_Possible_Modification): Revert a
	special-case for validity checks on Long_Float type.
	* snames.ads-tmpl (Name_Attr_Long_Float): Remove name added
	exclusively for the mentioned fix.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
c96dcf0550 [Ada] Remove repeated setting of Never_Set_In_Source
Formal parameters have their flag Never_Set_In_Source set at the
beginning of Process_Formals routine (regardless of the parameter mode).
There is no need to set it again when Process_Formals calls
Set_Formal_Mode (for parameters of mode IN OUT and OUT).

Code cleanup related to improved detection of uninitialised objects;
behaviour is unaffected.

gcc/ada/

	* sem_ch6.adb (Set_Formal_Mode): Remove unnecessary setting of
	Never_Set_In_Source.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
6ba8c078ca [Ada] Reorder processing of default expressions to avoid repeated calls
Code cleanup related to improved detection of uninitialised objects;
semantics is unaffected.

gcc/ada/

	* sem_ch6.adb (Process_Formals): Avoid repeated calls to
	Expression.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
076a6d13d1 [Ada] Remove redundant protection against empty lists
Calls to First on No_List intentionally return Empty node, so explicit
guards against No_List are unnecessary. Code cleanup; semantics is
unaffected.

gcc/ada/

	* exp_code.adb (Setup_Asm_IO_Args): Remove guard against No_List.
	* par_sco.adb (Process_Decisions): Likewise.
	* sem_ch13.adb (Check_Component_List): Likewise.
	* sem_ch6.adb (FCL): Likewise.
2022-07-05 08:28:20 +00:00
Doug Rupp
5709fac357 [Ada] qnx-7.1: ACATS cxag001 failure on qnx - realpath
The implementation of __gnat_full_name uses the CRTL realpath, however
this function returns a null string so use the default implementation
instead.

gcc/ada/

	* cstreams.c (__gnat_full_name) [QNX]: Remove block.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
aba3ce53e5 [Ada] Remove use of a global name buffer when locating a file
Code cleanup; semantics is unaffected.

gcc/ada/

	* osint.adb (Locate_File): Use Name_Find with a parameter and
	not with a global buffer.
2022-07-05 08:28:20 +00:00
Piotr Trojanek
0aa855e5eb [Ada] Reuse Get_Pragma_Arg to handle pragma argument associations
Code cleanup related to looking at pragma Thread_Local_Storage.
Semantics is unaffected.

gcc/ada/

	* exp_ch3.adb (Build_Init_Statements): Reuse Get_Pragma_Arg.
	* exp_prag.adb (Arg_N): Likewise.
2022-07-05 08:28:19 +00:00
Yannick Moy
95e2844ef8 [Ada] Fix spurious error on object renaming with ghost type
Renaming of an object of ghost type leads to a spurious error.  Now
fixed.

gcc/ada/

	* ghost.adb (Is_OK_Ghost_Context): Detect ghost type inside object
	renaming.
2022-07-05 08:28:19 +00:00
Bob Duff
dba077902d [Ada] Misc cleanup related to finalization
This patch cleans up some code issues found while working on
finalization, and adds some debugging aids.

gcc/ada/

	* exp_ch7.adb: Change two constants Is_Protected_Body and
	Is_Prot_Body to be Is_Protected_Subp_Body; these are not true
	for protected bodies, but for protected subprogram bodies.
	(Expand_Cleanup_Actions): No need to search for
	Activation_Chain_Entity; just use Activation_Chain_Entity.
	* sem_ch8.adb (Find_Direct_Name): Use Entyp constant.
	* atree.adb, atree.ads, atree.h, nlists.adb, nlists.ads
	(Parent): Provide nonoverloaded versions of Parent, so that they
	can be easily found in the debugger.
	* debug_a.adb, debug_a.ads: Clarify that we're talking about the
	-gnatda switch; switches are case sensitive.  Print out the
	Chars field if appropriate, which makes it easier to find things
	in the output.
	(Debug_Output_Astring): Simplify. Also fix an off-by-one
	bug ("for I in Vbars'Length .." should have been "for I in
	Vbars'Length + 1 ..").  Before, it was printing Debug_A_Depth +
	1 '|' characters if Debug_A_Depth > Vbars'Length.
2022-07-05 08:28:19 +00:00
Piotr Trojanek
824211e18b [Ada] Remove repeated analysis for pragma Thread_Local_Storage
When analysing pragma Thread_Local_Storage its argument is analysed by
the call to Check_Arg_Is_Library_Level_Local_Name. There is no need to
reanalyse it. Code cleanup; behaviour is not affected.

gcc/ada/

	* sem_prag.adb (Analyze_Pragma): Remove unnecessary call to
	Analyze.
2022-07-05 08:28:19 +00:00
Piotr Trojanek
5c0729d2ed [Ada] Annotate GNAT.Sockets with No_Return aspects
Opportunity for extra annotations spotted while fixing detection of
unreachable code that follows calls to procedures annotated with
No_Return.

gcc/ada/

	* libgnat/g-socket.adb (Raise_Host_Error): Add No_Return aspect.
	(Raise_GAI_Error): Likewise.
	* libgnat/g-socket.ads (Raise_Socket_Error): Likewise.
2022-07-05 08:28:19 +00:00
Piotr Trojanek
dd1c3433aa [Ada] Cleanup repeated code for aggregate constraints checks
Code cleanup related to examining uses of Check_Unset_Reference for
improved detection of uninitialised scalar objects. Semantics is
unaffected.

gcc/ada/

	* sem_util.adb (Aggregate_Constraint_Checks): Fix whitespace;
	refactor repeated code; replace a ??? comment with an
	explanation based on the comment for the routine spec.
2022-07-05 08:28:19 +00:00
Piotr Trojanek
074e8addc5 [Ada] Fix comments mentioning ancient flags related to objects references
Flag May_Be_Modified under go a series of renamings between 1996 and
2002.  It was changed to Not_Assigned, then to Not_Source_Assigned and
finally to Never_Set_In_Source. Fix remaining references in comments.

gcc/ada/

	* sem_util.ads (Note_Possible_Modification): Fix occurrence of
	May_Be_Modified in comment.
	* sem_warn.ads (Check_Unset_Reference): Fix occurrence of
	Not_Assigned in comment.
2022-07-05 08:28:18 +00:00
Yannick Moy
1f85342b42 [Ada] Spurious error on qualified prefix in Pack.Func'Result
When using a qualified name such as Pack.Func as the prefix of a 'Result
attribute reference, the prefix is not fully resolved and may contain a
chain of homonyms. Look for the expected function in the homonym chain
instead of issuing an error if the first one is not the expected one.

gcc/ada/

	* sem_attr.adb (Analyze_Attribute): Take into account the
	possibility of homonyms.
2022-07-05 08:28:18 +00:00
Eric Botcazou
69a70b0acb [Ada] Perform object rewriting as renaming only in the expander
The rewriting as renaming optimization for object declarations is done
partly during analysis, guarded with Expander_Active, and partly during
expansion, so it makes sense to do it entirely during expansion.

This merges the two cases and removes obsolete or unnecessary conditions
guarding the transformation in the process.

gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration): Rewrite as a renaming
	for any nonaliased local object with nominal unconstrained subtype
	originally initialized with the result of a function call that has
	been rewritten as the dereference of a reference to the result.
	* sem_ch3.adb (Analyze_Object_Declaration): Do not do it here
2022-07-05 08:28:18 +00:00
Arnaud Charlet
1d5018955a [Ada] Remove exception propagation during bootstrap
To help the bootstrap path, we want to keep the compiler free from any
exception propagation during bootstrap. This has been broken recently in
various places.

Also introduce a way to more easily detect such breakage via the
-DNO_EXCEPTION_PROPAGATION which can now be used as part of BOOT_CFLAGS.

gcc/ada/

	* exp_imgv.adb (Build_Enumeration_Image_Tables): Also disable
	perfect hash in GNAT_Mode.
	* raise-gcc.c (__gnat_Unwind_RaiseException): Add support for
	disabling exception propagation.
	* sem_eval.adb (Compile_Time_Known_Value): Update comment and
	remove wrong call to Check_Error_Detected.
	* sem_prag.adb (Check_Loop_Pragma_Grouping, Analyze_Pragma):
	Remove exception propagation during bootstrap.
2022-07-05 08:28:18 +00:00
Eric Botcazou
4844a259b4 [Ada] Fix dangling bounds for array result of BIP functions
The implementation of the build-in-place return protocol for functions
whose result type is an unconstrained array type generates dangling
references to local bounds built on the stack for the result as soon as
these bounds are not static.  The reason is that the implementation
treats the return object, either explicitly present in the source or
synthesized by the compiler, as a regular constrained object until very
late in the game, although it needs to be ultimately rewritten as the
renaming of the dereference of an allocator with unconstrained designated
type in order for the bounds to be part of the allocation.

Recently a partial fix was implemented for the case where the result is an
aggregate, by preventing the return object from being expanded after it has
been analyzed.  However, it does not work for the general case of extended
return statements, because the statements therein are still analyzed with
the constrained version of the return object so, after it is changed into
the unconstrained renaming, this yields (sub)type mismatches.

Therefore this change goes the other way around: it rolls back the partial
fix and instead performs the transformation of the return object into the
unconstrained renaming during the expansion of its declaration, in other
words before statements referencing it, if any, are analyzed, thus ensuring
that they see the final version of the object.

gcc/ada/

	* exp_aggr.adb (Expand_Array_Aggregate): Remove obsolete code.
	Delay the expansion of aggregates initializing return objects of
	build-in-place functions.
	* exp_ch3.ads (Ensure_Activation_Chain_And_Master): Delete.
	* exp_ch3.adb (Ensure_Activation_Chain_And_Master): Fold back to...
	(Expand_N_Object_Declaration): ...here.
	Perform the expansion of return objects of build-in-place functions
	here instead of...
	* exp_ch6.ads (Is_Build_In_Place_Return_Object): Declare.
	* exp_ch6.adb (Expand_N_Extended_Return_Statement): ...here.
	(Is_Build_In_Place_Result_Type): Alphabetize.
	(Is_Build_In_Place_Return_Object): New predicate.
	* exp_ch7.adb (Enclosing_Function): Delete.
	(Process_Object_Declaration): Tidy up handling of return objects.
	* sem_ch3.adb (Analyze_Object_Declaration): Do not decorate and
	freeze the actual type if it is the same as the nominal type.
	* sem_ch6.adb: Remove use and with clauses for Exp_Ch3.
	(Analyze_Function_Return): Analyze again all return objects.
	(Create_Extra_Formals): Do not force the definition of an Itype
	if the subprogram is a compilation unit.
2022-07-05 08:28:18 +00:00
Piotr Trojanek
9fde6c7114 [Ada] Remove unnecessary dead code after calls to nonreturning procedures
A new warning about unreachable code that follows calls to procedures
with No_Return would flag some dead defensive code. Comments next to
this code suggest that it was added to please some ancient version of
the compiler, but recent releases of GNAT do not require such a code.

gcc/ada/

	* gnatls.adb (Corresponding_Sdep_Entry): Remove dead return
	statement in defensive path; there is another return statement
	for a normal execution of this routine, so rule Ada RM 6.5(5),
	which requires function to have at least one return statement is
	still satisfied.
	(Gnatls): Remove dead, call to nonreturning Exit_Program after
	Output_License_Information which itself does not return.
	* libgnat/a-exstat.adb (Bad_EO): Remove raise statement that was
	meant to please some ancient version of GNAT.
	* libgnat/g-awk.adb (Raise_With_Info): Likewise.
	* sem_attr.adb (Check_Reference): Remove dead return statement;
	rule Ada RM 6.5(5), which requires function to have at least one
	return statement is still satisfied.
	(Analyze_Attribute): Remove dead exit statement.
	(Check_Reference): Same as above.
	* sem_ch12.adb (Instantiate_Formal_Package): Remove dead raise
	statement; it was inconsistent with other calls to
	Abandon_Instantiation, which are not followed by a raise
	statement.
	* sem_prag.adb (Process_Convention): Remove dead defensive
	assignment.
	(Interrupt_State): Remove dead defensive exit statement.
	(Do_SPARK_Mode): Likewise.
	* sfn_scan.adb (Scan_String): Remove dead defensive assignment.
2022-07-05 08:28:18 +00:00
Piotr Trojanek
684194f4a4 [Ada] Remove return statements after procedure calls that don't return
A new warning about unreachable code that follows calls to procedures
with No_Return would flag many unnecessary return statements. Those
returns statements were applied inconsistently, so this patch is
actually more a style cleanup.

gcc/ada/

	* sem_attr.adb, sem_prag.adb: Remove dead return statements
	after calls to Error_Attr, Error_Pragma, Error_Pragma_Arg and
	Placement_Error. All these calls raise exceptions that are
	handled to gently recover from errors.
2022-07-05 08:28:17 +00:00
Doug Rupp
f608cf03b1 [Ada] Combine system.ads files - vxworks6 constants.
Systemitize Word_Size and Memory_Size declarations rather than hard code
with numerical values or OS specific Long_Integer size.

gcc/ada/

	* libgnat/system-vxworks-ppc-kernel.ads (Word_Size): Compute
	based on Standard'Word_Size.
	(Memory_Size): Compute based on Word_Size.
	* libgnat/system-vxworks-ppc-rtp-smp.ads: Likewise.
	* libgnat/system-vxworks-ppc-rtp.ads: Likewise.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
7b9ae8e806 [Ada] Fix clearly unintentional dead analysis of attribute Code_Address
A new warning about unreachable code that follows calls to procedures
with No_Return would flag a clearly unintentional dead call to
Set_Address_Taken in analysis of Code_Address attribute.

This patch resurrects the dead code, which is worth fixing regardless of
the new warning.

gcc/ada/

	* sem_attr.adb (Analyze_Attribute): Move call to
	Set_Address_Taken so that it is executed when the prefix
	attribute is legal.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
4ba48342a3 [Ada] Cleanup in error about unreachable code
Cleanup only; behaviour is unaffected.

gcc/ada/

	* sem_ch5.adb (Check_Unreachable_Code): Avoid explicit use of
	Sloc; this should also help when we finally use Source_Span for
	prettier error messages.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
21d6ec4579 [Ada] Remove redundant guards in detection of unreachable code
Routine Check_Unreachable_Code is only called on nodes belonging to a
list of statements (and it wouldn't make sense to call it on anything
else).

gcc/ada/

	* sem_ch5.adb (Check_Unreachable_Code): Remove redundant guard;
	the call to Present wasn't needed either.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
948f4bc2dd [Ada] Remove redundant guard for call to List_Length with a No_List
Code cleanup related to a new detection of uninitialised local scalar
objects; semantics is unaffected.

gcc/ada/

	* sem_ch5.adb (Analyze_Block_Statement): Call to List_Length with
	No_List is safe and will return zero.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
70bb3298c2 [Ada] Add RM reference to check for functions without a return statement
Add comment to explain why we have an error and not just a warning.

gcc/ada/

	* sem_ch6.adb (Check_Missing_Return): Add reference to an RM rule.
2022-07-05 08:28:17 +00:00
Piotr Trojanek
5b56017032 [Ada] Remove comment about a long gone formal verification mode
Remove outdated a comment about the very first SPARK experiments
in GNAT.

gcc/ada/

	* sem_ch6.adb (Check_Missing_Return): Remove outdated comment.
2022-07-05 08:28:16 +00:00
Dmitriy Anisimkov
fee24d5cae [Ada] Remove unimplemented convert_addresses declaration
convert_addresses is declared in adaint.h but is never referenced, so
remove it.

gcc/ada/

	* adaint.h (convert_addresses): Remove function declaration.
2022-07-05 08:28:16 +00:00
Doug Rupp
4c1baa0289 [Ada] Remove old vxworks6 from Makefile.rtl
Pre vxworks7 code excepting legacy vxworks6 code is removed from
Makefile.rtl and unused files are deleted.

gcc/ada/

	* Makefile.rtl (*vxworks*): Remove most pre-vxworks7 code.
	* vxworks-arm-link.spec: Remove.
	* vxworks-e500-link.spec: Likewise.
	* vxworks-smp-arm-link.spec: Likewise.
	* vxworks-smp-e500-link.spec: Likewise.
	* vxworks-smp-x86-link.spec: Likewise.
	* libgnat/system-vxworks-arm-rtp-smp.ads: Likewise.
	* libgnat/system-vxworks-arm-rtp.ads: Likewise.
	* libgnat/system-vxworks-arm.ads: Likewise.
	* libgnat/system-vxworks-e500-kernel.ads: Likewise.
	* libgnat/system-vxworks-e500-rtp-smp.ads: Likewise.
	* libgnat/system-vxworks-e500-rtp.ads: Likewise.
	* libgnat/system-vxworks-x86-kernel.ads: Likewise.
	* libgnat/system-vxworks-x86-rtp-smp.ads: Likewise.
	* libgnat/system-vxworks-x86-rtp.ads: Likewise.
2022-07-05 08:28:16 +00:00
Richard Sandiford
76c3041b85 vect: Use sdot for a fallback implementation of usdot
Following a suggestion from Tamar, this patch adds a fallback
implementation of usdot using sdot.  Specifically, for 8-bit
input types:

   acc_2 = DOT_PROD_EXPR <a_unsigned, b_signed, acc_1>;

becomes:

   tmp_1 = DOT_PROD_EXPR <64, b_signed, acc_1>;
   tmp_2 = DOT_PROD_EXPR <64, b_signed, tmp_1>;
   acc_2 = DOT_PROD_EXPR <a_unsigned - 128, b_signed, tmp_2>;

on the basis that (x-128)*y + 64*y + 64*y.  Doing the two 64*y
operations first should give more time for x to be calculated,
on the off chance that that's useful.

gcc/
	* tree-vect-patterns.cc (vect_convert_input): Expect the input
	type to be signed for optab_vector_mixed_sign.  Update the vectype
	at the same time as type.
	(vect_recog_dot_prod_pattern): Update accordingly.  If usdot isn't
	available, try sdot instead.
	* tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): New function.
	(vect_model_reduction_cost): Model the cost of implementing usdot
	using sdot.
	(vectorizable_reduction): Likewise.  Skip target support test
	for lane reductions.
	(vect_emulate_mixed_dot_prod): New function.
	(vect_transform_reduction): Use it to emulate usdot via sdot.

gcc/testsuite/
	* gcc.dg/vect/vect-reduc-dot-9.c: Reduce target requirements
	from i8mm to dotprod.
	* gcc.dg/vect/vect-reduc-dot-10.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-11.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-12.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-13.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-14.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-15.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-16.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-17.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-18.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-19.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-20.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-21.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-22.c: Likewise.
2022-07-05 08:53:10 +01:00
Richard Biener
b55284f4a1 tree-optimization/106182 - LC SSA after CFG cleanup
The testcase shows that when cleaning up the CFG we can end up
with broken LC SSA (for virtual operands with the testcase).  The
case here involves deleting a loop after which it is not enough
to scan the blocks with changed loop depth for SSA uses that need
to be rewritten.  So make fix_loop_sturcture return the sum of
the number of new loops and the number of deleted loops.

	PR tree-optimization/106182
	* loop-init.cc (fix_loop_structure): Return the number
	of newly discovered plus the number of deleted loops.
	* tree-cfgcleanup.cc (repair_loop_structures): Adjust
	variable name.

	* gcc.dg/torture/pr106182.c: New testcase.
2022-07-05 09:28:45 +02:00
GCC Administrator
8467574d8d Daily bump. 2022-07-05 00:16:36 +00:00
Hans-Peter Nilsson
5beddee9f4 gcc.dg/analyzer/allocation-size-1..5.c: Fix for 32-bit newlib targets
See gcc/config/newlib-stdint.h, where targets that have
LONG_TYPE_SIZE == 32, get INT32_TYPE defined to "long int".
INT32_TYPE ends up in the target int32_t.

Thus the tests failed for 32-bit newlib targets due to related
warning messages being matched to "aka int" where the emitted
message for these targets have "aka long int".

Tested cris-elf, committed as obvious.

gcc/testsuite:
	* gcc.dg/analyzer/allocation-size-1.c,
	gcc.dg/analyzer/allocation-size-2.c,
	gcc.dg/analyzer/allocation-size-3.c,
	gcc.dg/analyzer/allocation-size-4.c,
	gcc.dg/analyzer/allocation-size-5.c: Handle int32_t being "long int".
2022-07-05 02:00:21 +02:00
Tobias Burnus
c3297044f0 OpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax
Fortran part to C/C++
commit r13-1002-g03b71406323ddc065b1d7837d8b43b17e4b048b5

gcc/fortran/ChangeLog:

	* gfortran.h (gfc_omp_namelist): Update by creating 'linear' struct,
	move 'linear_op' as 'op' to id and add 'old_modifier' to it.
	* dump-parse-tree.cc (show_omp_namelist): Update accordingly.
	* module.cc (mio_omp_declare_simd): Likewise.
	* trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
	* openmp.cc (resolve_omp_clauses): Likewise; accept new-style
	'val' modifier with do/simd.
	(gfc_match_omp_clauses): Handle OpenMP 5.2 linear clause syntax.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.2): Mark linear-clause change as 'Y'.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/linear-4.c: New test.
	* gfortran.dg/gomp/linear-2.f90: New test.
	* gfortran.dg/gomp/linear-3.f90: New test.
	* gfortran.dg/gomp/linear-4.f90: New test.
	* gfortran.dg/gomp/linear-5.f90: New test.
	* gfortran.dg/gomp/linear-6.f90: New test.
	* gfortran.dg/gomp/linear-7.f90: New test.
	* gfortran.dg/gomp/linear-8.f90: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
2022-07-04 21:50:23 +02:00
Aldy Hernandez
ce8dbe7d83 Misc conversions to vrange.
The following converts a handful of places that were irange centric.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-fold.cc
	(fold_using_range::range_of_ssa_name_with_loop_info): Restrict the
	call to SCEV for irange supported types.
	(fold_using_range::range_of_builtin_int_call): Convert to vrange.
	* gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Same.
	* tree-ssa-dom.cc (cprop_operand): Same.
2022-07-04 20:43:14 +02:00
Roger Sayle
ac4c8f53b0 middle-end: Support ABIs that pass FP values as wider integers.
Sorry for the long delay getting back to this, but after deeper
investigation, it turns out that Jeff Law's tingling spider senses
that the original patch wasn't updating everywhere that was required
were spot on.  Although my nvptx testing showed no problems with -O2,
compiling the same tests with -O0 found several additional assertion
ICEs (exactly where he'd predicted they'd be).

Here's a revised patch that updates five locations (up from the
previous two).  Finding any remaining locations (if any) might be
easier once folks are able to test things on their targets.  This
also implements Jeff's suggestion to factor the common code into
helper routines.

2022-07-04  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR target/104489
	* calls.cc (precompute_register_parameters): Allow promotion
	of floating point values to be passed in wider integer modes
	by calling new convert_float_to_wider_int.
	(expand_call): Allow floating point results to be returned in
	wider integer modes by calling new convert wider_int_to_float.
	* cfgexpand.cc (expand_value_return): Allow backends to promote
	a scalar floating point return value to a wider integer mode
	by calling new convert_float_to_wider_int.
	* expr.cc (convert_float_to_wider_int): New function.
	(convert_wider_int_to_float): Likewise.
	(expand_expr_real_1) <expand_decl_rtl>: Allow backends to promote
	scalar FP PARM_DECLs to wider integer modes, by calling new
	convert_wider_int_to_float.
	* expr.h (convert_modes): Name arguments for improved documentation.
	(convert_float_to_wider_int): Prototype new function here.
	(convert_wider_int_to_float): Likewise.
	* function.cc (assign_parm_setup_stack): Allow floating point
	values to be passed on the stack as wider integer modes by
	calling new convert_wider_int_to_float.
2022-07-04 16:45:47 +01:00
Nick Clifton
fc968115a7 Fix typo in recent code to add stack recursion limit to the Rust demangler.
libiberty
	* rust-demangle.c (demangle_const): Add a missing goto pass_return
	at the end of the function.
2022-07-04 16:31:18 +01:00
Martin Jambor
b110e5283e
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.

I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).

gcc/ChangeLog:

2022-07-01  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/105860
	* tree-sra.cc (build_reconstructed_reference): Start expr
	traversal only just below the outermost union.

gcc/testsuite/ChangeLog:

2022-07-01  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/105860
	* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
	* gcc.dg/tree-ssa/pr105860.c: Likewise.
2022-07-04 17:07:04 +02:00
Richard Biener
3769ad4cce Revert update-ssa assert in vectorizer
The following reverts the just added assert that virtual SSA does not
need updating.  It instead goes for a select whitelist of transforms
known to be prone to difficulties with virtual SSA update.

	* tree-vect-loop-manip.cc (vect_do_peeling): Revert assert
	and update virtual SSA form again.  Assert we do so for
	a known set of transforms only.
	* tree-vectorizer.h (vec_info::any_known_not_updated_vssa): New.
	* tree-vect-stmts.cc (vectorizable_load): When vectorizing
	using load-lanes allow virtual SSA update.
2022-07-04 13:56:45 +02:00
Tobias Burnus
683f118439 OpenMP: Move omp requires checks to libgomp
Handle reverse_offload, unified_address, and unified_shared_memory
requirements in libgomp by saving them alongside the offload table.
When the device lto1 runs, it extracts the data for mkoffload. The
latter than passes the value on to GOMP_offload_register_ver.

lto1 (either the host one, with -flto [+ ENABLE_OFFLOADING], or in the
offload-device lto1) also does the the consistency check is done,
erroring out when the 'omp requires' clause use is inconsistent.

For all in-principle supported devices, if a requirement cannot be fulfilled,
the device is excluded from the (supported) devices list. Currently, none of
those requirements are marked as supported for any of the non-host devices.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_target_data, c_parser_omp_target_update,
	c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Set
	OMP_REQUIRES_TARGET_USED.
	(c_parser_omp_requires): Remove sorry.

gcc/ChangeLog:

	* config/gcn/mkoffload.cc (process_asm): Write '#include <stdint.h>'.
	(process_obj): Pass omp_requires_mask to GOMP_offload_register_ver.
	(main): Ask lto1 to obtain omp_requires_mask and pass it on.
	* config/nvptx/mkoffload.cc (process, main): Likewise.
	* lto-cgraph.cc (omp_requires_to_name): New.
	(input_offload_tables): Save omp_requires_mask.
	(output_offload_tables): Read it, check for consistency,
	save value for mkoffload.
	* omp-low.cc (lower_omp_target): Force output_offloadtables
	call for OMP_REQUIRES_TARGET_USED.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_omp_target_data,
	cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data,
	cp_parser_omp_target_update): Set OMP_REQUIRES_TARGET_USED.
	(cp_parser_omp_requires): Remove sorry.

gcc/fortran/ChangeLog:

	* openmp.cc (gfc_match_omp_requires): Remove sorry.
	* parse.cc (decode_omp_directive): Don't regard 'declare target'
	as target usage for 'omp requires'; add more flags to
	omp_requires_mask.

include/ChangeLog:

	* gomp-constants.h (GOMP_VERSION): Bump to 2.
	(GOMP_REQUIRES_UNIFIED_ADDRESS, GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
	GOMP_REQUIRES_REVERSE_OFFLOAD, GOMP_REQUIRES_TARGET_USED):
	New defines.

libgomp/ChangeLog:

	* libgomp-plugin.h (GOMP_OFFLOAD_get_num_devices): Add
	omp_requires_mask arg.
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Likewise;
	return -1 when device available but omp_requires_mask != 0.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Likewise.
	* oacc-host.c (host_get_num_devices, host_openacc_get_property):
	Update call.
	* oacc-init.c (resolve_device, acc_init_1, acc_shutdown_1,
	goacc_attach_host_thread_to_device, acc_get_num_devices,
	acc_set_device_num, get_property_any): Likewise.
	* target.c (omp_requires_mask): New global var.
	(gomp_requires_to_name): New.
	(GOMP_offload_register_ver): Handle passed omp_requires_mask.
	(gomp_target_init): Handle omp_requires_mask.
	* libgomp.texi (OpenMP 5.0): Update requires impl. status.
	(OpenMP 5.1): Add a missed item.
	(OpenMP 5.2): Mark linear-clause change as supported in C/C++.
	* testsuite/libgomp.c-c++-common/requires-1-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-1.c: New test.
	* testsuite/libgomp.c-c++-common/requires-2-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-2.c: New test.
	* testsuite/libgomp.c-c++-common/requires-3-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-3.c: New test.
	* testsuite/libgomp.c-c++-common/requires-4-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-4.c: New test.
	* testsuite/libgomp.c-c++-common/requires-5-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-5.c: New test.
	* testsuite/libgomp.c-c++-common/requires-6.c: New test.
	* testsuite/libgomp.c-c++-common/requires-7-aux.c: New test.
	* testsuite/libgomp.c-c++-common/requires-7.c: New test.
	* testsuite/libgomp.fortran/requires-1-aux.f90: New test.
	* testsuite/libgomp.fortran/requires-1.f90: New test.

liboffloadmic/ChangeLog:

	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_num_devices):
	Return -1 when device available but omp_requires_mask != 0.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/requires-4.c: Update dg-*.
	* c-c++-common/gomp/reverse-offload-1.c: Likewise.
	* c-c++-common/gomp/target-device-ancestor-2.c: Likewise.
	* c-c++-common/gomp/target-device-ancestor-3.c: Likewise.
	* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.
	* c-c++-common/gomp/target-device-ancestor-5.c: Likewise.
	* gfortran.dg/gomp/target-device-ancestor-3.f90: Likewise.
	* gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise.
	* gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise.
	* gfortran.dg/gomp/target-device-ancestor-2.f90: Likewise. Move
	post-FE checks to ...
	* gfortran.dg/gomp/target-device-ancestor-2a.f90: ... this new file.
	* gfortran.dg/gomp/requires-8.f90: Update as we don't regard
	'declare target' for the 'requires' usage requirement.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-07-04 13:52:02 +02:00
Richard Biener
10b502fb78 Keep virtual SSA up-to-date in vectorizer
The following removes a FIXME where we fail(ed) to keep virtual
SSA up-to-date, patching up the remaining two cases I managed to
trigger.  I've left an assert so that we pick up cases arising
for the cases I wasn't able to trigger.

2022-07-04  Richard Biener  <rguenther@suse.de>

	* tree-vect-loop-manip.cc (vect_do_peeling): Assert that
	no SSA update is needed instead of updating virtual SSA
	form.
	* tree-vect-stmts.cc (vectorizable_load): For hoisted
	invariant load use the loop entry virtual use.
	For emulated gather loads use the virtual use of the
	original stmt like vect_finish_stmt_generation would do.
2022-07-04 12:41:41 +02:00
Martin Liska
88b9d090aa gcc-descr: by default show revision for HEAD
I've made the mistake multiple times while doing a bisection.
One would expect that gcc-descr w/o an argument would print
revision for the current HEAD and not master.
Thus change it.

contrib/ChangeLog:

	* git-descr.sh: By default print revision for HEAD.
2022-07-04 12:27:43 +02:00
Eric Botcazou
104b9875c7 Fix crash on circular array types with -fdump switches
Such questionable arrays types can occur in Ada.

gcc/
	* tree-pretty-print.cc (dump_generic_node) <ARRAY_TYPE>: Add guard
	for direct circularity.
2022-07-04 12:23:37 +02:00
Eric Botcazou
483bd9a028 Use default lower bound for vector types in debug info
Vector types are represented as array types with DW_AT_GNU_vector attribute
in the debug info and a range [0 .. TYPE_VECTOR_SUBPARTS - 1].  Now that's
obviously skewed toward the C family of languages, therefore the attached
patch changes the lower bound to the default for the language of the CU.

gcc/
	* dwarf2out.cc (gen_array_type_die): Use the default lower bound of
	the language for vector types.
2022-07-04 12:20:25 +02:00
Martin Liska
a7ccdfa17e MAINTAINERS: fix alphabetic sorting
ChangeLog:

	* MAINTAINERS: fix sorting of names
2022-07-04 12:16:32 +02:00
Nick Clifton
1a770b01ef Prevent another potential stack overflow issue when demangling a maliciouslt mangled Rust name.
libiberty/
	* rust-demangle.c (demangle_path_maybe_open_generics): Add
	recursion limit.
2022-07-04 11:05:03 +01:00
Aldy Hernandez
4e82205b68 Integrate nonzero bits with irange.
The nonzero bits and integer ranges compliment each other quite well,
and it only makes sense to make the mask a first class citizen in the
irange.  We do a half assed job of keeping ranges and nonzero bits
somewhat in sync in SSA_NAME_RANGE_INFO, and the goal has always
been to integrate them properly.  This patch does that, in preparation
for streaming out full-resolution iranges between passes (think
SSA_NAME_RANGE_INFO).

Having nonzero bits in the irange allows us to get better results from
things like irange::contains_p() and keeping them in the irange allows
us to propagate the bits throughout with the ranger.  This patch
provides the bare infrastructure, without any optimizations to
range-ops, etc.  Those will come as follow-ups.

A few notes:

Legacy SSA_NAME_RANGE_INFO updates the nonzero bits every time a range
is set.  Here instead, we don't update the nonzero bits on a new
range, but calculate it on the fly when irange::get_nonzero_bits() is
called.  The goal is to only store nonzero bits that provide
meaningful information that can't be gleaned from the range itself.
But you can always call get_nonzero_bits() and get the full
information.

Nonzero bits are not supported in legacy mode.  The mask may be set
as a consequence of propagation or reading global ranges, but no
one from legacy land should be querying irange::get_nonzero_bits.  There
is an assert enforcing this.  However, legacy/global set_nonzero_bits()
continue to work as before.  There is no change to legacy behavior.

There is virtually no performance change with this patch, as there are
no consumers.  The next patch I post will be the SSA_NAME_RANGE_INFO
conversion to the new world, in which I will discuss performance
proper.  Hint: I'll be chewing up the time budget we gained with the
vrange conversion.

Tested and benchmarked on x86-64 Linux.

gcc/ChangeLog:

	* value-range-storage.cc (irange_storage_slot::set_irange): Set
	nonzero bits in irange.
	(irange_storage_slot::get_irange): Get nonzero bits from irange.
	* value-range.cc (irange::operator=): Set nonzero bits.
	(irange::irange_set): Same.
	(irange::irange_set_anti_range): Same.
	(irange::set): Same.
	(irange::verify_range): Same.
	(irange::legacy_equal_p): Check nonzero bits.
	(irange::equal_p): Same.
	(irange::contains_p): Handle nonzero bits.
	(irange::irange_union): Same.
	(irange::irange_intersect): Same.
	(irange::dump): Same.
	(irange::set_nonzero_bits): New.
	(irange::get_nonzero_bits): New.
	(irange::intersect_nonzero_bits): New.
	(irange::union_nonzero_bits): New.
	(irange::dump_bitmasks): New.
	* value-range.h (class irange): Add m_nonzero_mask.
	(gt_ggc_mx): Handle nonzero bits.
	(gt_pch_nx): Same.
	(irange::set_undefined): Set nonzero bits.
	(irange::set_varying): Same.
	(irange::normalize_kind): Call set_undefined.
2022-07-04 11:34:20 +02:00
Richard Biener
d2a8986666 Put virtual operands into loop-closed SSA
When attempting to manually update SSA form after high-level loop
transforms such as loop versioning it is helpful when the loop-closed
SSA form includes virtual operands.  While we have the special
rewrite_virtuals_into_loop_closed_ssa function that doesn't
presently scale, invoking update_ssa by itself.  So the following
makes the regular loop-closed SSA form also cover virtual operands.
For users of loop_version this allows to use cheaper
TODO_update_ssa_no_phi, skipping dominance frontier compute
(for the whole function) and iterated dominance frontiers for each
copied def.

	* tree-ssa-loop-manip.h
	(rewrite_virtuals_into_loop_closed_ssa): Remove.
	(rewrite_into_loop_closed_ssa_1): Likewise.
	* tree-ssa-loop-manip.cc (rewrite_into_loop_closed_ssa_1):
	Make static.
	(rewrite_into_loop_closed_ssa): Remove loop overload,
	always rewrite virtuals into LC SSA.
	(check_loop_closed_ssa_bb): Also check virtuals.
	* tree-ssa-dce.cc (remove_dead_phis): Preserve virtual
	LC PHIs when in LC SSA.
	* gimple-loop-jam.cc (fuse_loops): Do not rewrite into
	loop-closed SSA here, but ...
	(tree_loop_unroll_and_jam): ... here once.
	* tree-if-conv.cc (version_loop_for_if_conversion): Use
	the cheaper TODO_update_ssa_no_phi.
	* tree-loop-distribution.cc (version_loop_by_alias_check):
	Likewise.
	* tree-ssa-loop-unswitch.cc (tree_unswitch_single_loop):
	Likewise.
	* tree-vect-loop-manip.cc (vect_loop_versioning): Likewise.
	(tree_unswitch_outer_loop): Do not rewrite virtuals into
	LC ssa.
	* tree-parloops.cc (transform_to_exit_first_loop_alt):
	Likewise.
	(pass_parallelize_loops::execute): After finishing rewrite
	into LC SSA again because we do not maintain it properly.
2022-07-04 10:36:09 +02:00
Eric Botcazou
8c6bef0a33 [Ada] Do not make procedure call with only tag-indeternminate actuals dispatching
The RM 3.9.2(19) clause says that the controlling tag value is statically
determined to be the tag of the tagged type involved.  As a matter of fact,
the call would be made dispatching only as a by-product of the propagation
of the controlling tag value to the tag-indeternminate actuals, but that's
unnecessary and not done in the equivalent case of a procedure call with
both statically tagged and tag-indeternminate actuals.

gcc/ada/

	* sem_disp.adb (Check_Dispatching_Call): Merge the two special cases
	where there are no controlling actuals but tag-indeternminate ones.
2022-07-04 07:46:00 +00:00