Commit Graph

184918 Commits

Author SHA1 Message Date
Tobias Burnus
dee371fdd4 libgfortran/intrinsics/chmod.c: Silence unused var warning
libgfortran/ChangeLog:

	* intrinsics/chmod.c (chmod_internal): Only declare mode_mask var
	if HAVE_UMASK.
2021-05-05 11:48:48 +02:00
Robin Dapp
3db6989aba testsuite: Add s390 to gcc.dg/vect/slp-21.c
On s390 we vectorize 4 statements using SLP.  Add s390*-*-* to the
appropriate dg-finals.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/slp-21.c: Add s390.
2021-05-05 10:26:08 +02:00
Piotr Trojanek
d24ef4e609 [Ada] Fix expansion of attributes Input/Output for unchecked union types
gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference): Fix expansion of
	attributes Input and Output for unchecked unions.
	* sem_case.ads: Fix typo "disriminant" and refill comment.
2021-05-05 04:19:06 -04:00
Piotr Trojanek
8adc8d9b7c [Ada] Reuse Has_Defaulted_Discriminants where possible
gcc/ada/

	* exp_attr.adb, exp_ch9.adb, sem_ch3.adb: Reuse
	Has_Defaulted_Discriminants.
	* sem_ch4.adb (Analyze_Allocator): Reuse
	Has_Defaulted_Discriminants (after reordering conjuncts); remove
	redundant IF statement, whose condition is implied by
	Has_Defaulted_Discriminants.
	* sem_util.adb (Has_Defaulted_Discriminants): Has_Discriminants
	implies that the First_Discriminant is present.
	(Is_Fully_Initialized_Type): Reuse Has_Defaulted_Discriminants.
2021-05-05 04:19:06 -04:00
Justin Squirek
0053d7291e [Ada] Incorrect accessibility level on actual in procedure call
gcc/ada/

	* exp_ch6.adb (Expand_Call_Helper): Add condition to check for
	expanded actuals and remove dead code.
2021-05-05 04:19:05 -04:00
Piotr Trojanek
e02f9af5b2 [Ada] Detect unchecked union subcomponents in nested variant parts
gcc/ada/

	* exp_ch4.adb (Has_Unconstrained_UU_Component): Rewrite to
	follow the Ada RM grammar.
2021-05-05 04:19:05 -04:00
Piotr Trojanek
c3870f3bcf [Ada] Refine types of variables with call to Scope as their initial values
gcc/ada/

	* exp_ch4.adb (User_Defined_Primitive_Equality_Op): Refine type
	of a local variable.
	* exp_dbug.adb (Scope_Contains): Refine all types from Node_Id
	to Entity_Id; rename parameters to match those of the
	Scope_Within routine (which is similar but not the same); also,
	simplify an OR ELSE into a membership test.
2021-05-05 04:19:05 -04:00
Piotr Trojanek
43f69ac8b2 [Ada] Detect unchecked union components with fully qualified names
gcc/ada/

	* exp_ch4.adb (Component_Is_Unconstrained_UU): Detect both
	qualified and unqualified names of unchecked union components.
2021-05-05 04:19:04 -04:00
Piotr Trojanek
7faaabcc48 [Ada] Remove redundant checks for empty lists
gcc/ada/

	* exp_ch4.adb (Variant_Is_Unconstrained_UU): Remove redundant
	check for empty list.
	* exp_disp.adb (Find_Entry_Index): Simplify by removing
	redundant check and counting from zero; fix type of a local
	variable.
	* sem_ch12.adb (Save_Global_Descendant): Remove an unnecessary
	special-case for empty lists.
2021-05-05 04:19:04 -04:00
Piotr Trojanek
a119897355 [Ada] Cleanup a statically true condition in expanded raise statement
gcc/ada/

	* exp_ch4.adb (Apply_Accessibility_Check): Skip a statically
	true condition in expanded raise statement.
2021-05-05 04:19:04 -04:00
Bob Duff
67207bd6e6 [Ada] Fix s-os_lib.adb so vectorizing compilation works
gcc/ada/

	* libgnat/s-os_lib.adb (Missed_Drive_Letter): Simplify the code.
2021-05-05 04:19:03 -04:00
Ed Schonberg
680b9610ad [Ada] Spurious warning on useless assignment with target name
gcc/ada/

	* sem_ch5.adb (Analyze_Assignment): Do not emit the warning that
	a previous value of the target object is useless if the
	right-hand side of the assignment includes target names.
2021-05-05 04:19:03 -04:00
Eric Botcazou
5ebae75fbc [Ada] Do not use hash function for enumeration Value with trampolines
gcc/ada/

	* exp_imgv.adb: Add with/use clauses for Targparm.
	(Build_Enumeration_Image_Tables): Set type of Threshold to Nat and
	initialize it to Nat'Last if the type is local and the target does
	not support descriptors.  Adjust Threshold_For_Size similarly.
	(Expand_Value_Attribute): Minor tweaks.
2021-05-05 04:19:03 -04:00
Ghjuvan Lacambre
8b7b626376 [Ada] Move Build_And_Insert_CUDA_Initialization to expansion phase
gcc/ada/

	* exp_ch7.adb (Expand_N_Package_Body): Add CUDA init call.
	* sem_ch7.adb (Analyze_Package_Body_Helper): Remove CUDA init
	call.
2021-05-05 04:19:02 -04:00
Ghjuvan Lacambre
d2b075f3de [Ada] Don't emit style errors when parens are required
gcc/ada/

	* par-ch5.adb (P_Condition): Check if expression is declare
	expression.
2021-05-05 04:19:02 -04:00
Piotr Trojanek
5d0e32b0e4 [Ada] Simplify GNATmake by reusing GNAT.Ctrl_C
gcc/ada/

	* make.adb (Make): Use GNAT.Ctrl_C.Install_Handler instead of a
	custom imported procedure.
2021-05-05 04:19:02 -04:00
Eric Botcazou
003241bcae [Ada] Small cleanup in the Expand_Image_Attribute procedure
gcc/ada/

	* exp_imgv.adb (Is_User_Defined_Enumeration_Type): Delete.
	(Expand_Image_Attribute): Move inline expansion into normal flow of
	control, move down declarations and remove superfluous processing.
2021-05-05 04:19:01 -04:00
Piotr Trojanek
8c9f315a98 [Ada] Qualify internal access-to-subprogram types as not null
gcc/ada/

	* libgnat/g-alleve.adb (Bit_Operation): Now a not-null type.
	* libgnat/g-sechas.adb (Fill_Buffer_Access): Likewise.
	* libgnat/s-dwalin.adb (Callback): Likewise.
2021-05-05 04:19:01 -04:00
Ghjuvan Lacambre
41b8c20731 [Ada] Remove commented code
gcc/ada/

	* exp_util.adb (Is_Possibly_Unaligned_Object): Remove commented
	code.
2021-05-05 04:19:01 -04:00
Ed Schonberg
052a00e894 [Ada] Handle defaults in declare_expressions in postconditions
gcc/ada/

	* sem_ch3.adb (Find_Type_Of_Object):  When In_Spec_Expression is
	set and the object declaration generates a subtype indication,
	build the corresponding subtype declaration and place it in tree
	without the use of Insert_Actions, which is disabled in this
	context.
2021-05-05 04:19:01 -04:00
Eric Botcazou
0bfcf0b33d [Ada] Use inline expansion of Image for standard boolean by default
gcc/ada/

	* debug.adb (d_x): Document extended usage.
	* exp_imgv.adb (Expand_Standard_Boolean_Image): New procedure.
	(Expand_Image_Attribute): Call it to expand in line the attribute
	for standard boolean by default.
2021-05-05 04:19:00 -04:00
Eric Botcazou
15de3bc0b4 [Ada] Use inline expansion of Image for enumeration types by default
gcc/ada/

	* debug.adb (d_x): Document new usage.
	* exp_imgv.adb (Expand_User_Defined_Enumeration_Image): Add Typ
	parameter and use it throughout the processing.
	(Expand_Image_Attribute): Retrieve the underlying type of the
	prefix and use the inline expansion for user-defined enumeration
	types with a literal string by default.
2021-05-05 04:19:00 -04:00
Eric Botcazou
3a46d0ed6e [Ada] Tweak implementation of System.Double_Real.Split
gcc/ada/

	* libgnat/s-dorepr.adb (Split): Declare a per-size temporary.
	Add pragma Annotate.
2021-05-05 04:19:00 -04:00
Piotr Trojanek
1c3e11c029 [Ada] Remove redundant explicit calls to UI_From_Int in comparisons
gcc/ada/

	* exp_ch4.adb, sem_ch13.adb, sem_eval.adb, sem_res.adb: Remove
	redundant calls to UI_From_Int.
2021-05-05 04:18:59 -04:00
Eric Botcazou
3e4ea94b01 [Ada] Adjust expansion of perfect hash function for Value
gcc/ada/

	* exp_imgv.ads (Build_Enumeration_Image_Tables): Adjust comment.
	* exp_imgv.adb (Build_Enumeration_Image_Tables): Add the
	declaration nodes of the 4 tables to the declaration list of the
	function body.
2021-05-05 04:18:59 -04:00
Piotr Trojanek
c11207d345 [Ada] Speed up enumeration'Value with perfect hash function
gcc/ada/

	* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imagen, s-imen16,
	s-imen32, s-imenu8, s-pehage, s-valuen, s-vaen16, s-vaen32 and
	s-vaenu8.  Remove s-imenne, s-imgenu and s-valenu.
	* debug.adb (d_h): Document new usage.
	* einfo.ads (Lit_Hash): New attribute for enumeration types.
	(Set_Lit_Hash): Declare.
	* einfo.adb (Lit_Hash): New function.
	(Set_Lit_Hash): New procedure.
	(Write_Field21_Name): Print Lit_Hash for Enumeration_Kind.
	* exp_imgv.ads (Build_Enumeration_Image_Tables): Fix description
	and document the hash function and its tables.
	* exp_imgv.adb: Add with/use clauses for Debug.  Add with clause
	for System.Perfect_Hash_Generators.
	(Append_Table_To): New helper routine.
	(Build_Enumeration_Image_Tables): Call it to build the tables.
	In the main unit, register the literals with the hash generator.
	If they are sufficiently many and -gnatd_h is not passed, generate
	a perfect hash function and its tables; otherwise, generate a dummy
	hash function.  For the other units, generate only the declaration.
	In all cases, set Lit_Hash to the entity of the function, if any.
	(Expand_Value_Attribute): Pass the 'Unrestricted_Access of Lit_Hash,
	if any, as third argument to the Value_Enumeration_NN function.
	* gnat1drv.adb (Adjust_Global_Switches): force simpler implementation
	of 'Value in CodePeer_Mode.
	* lib.ads (Synchronize_Serial_Number): Add SN parameter.
	* lib.adb (Synchronize_Serial_Number): Assert that it is larger than
	the serial number of the current unit and set the latter to it only
	in this case.
	* rtsfind.ads (RTU_Id): Add System_Img_Enum_8, System_Img_Enum_16,
	System_Img_Enum_32, System_Val_Enum_8, System_Val_Enum_16 and
	System_Val_Enum_32.  Remove System_Img_Enum, System_Img_Enum_New
	and System_Val_Enum.
	* sem_attr.adb (Analyze_Access_Attribute): Do not flag a compiler
	generated Unrestricted_Access attribute as illegal in a declare
	expression.
	(RE_Unit_Table): Adjust to above changes.
	* libgnat/g-heasor.ads: Add pragma Compiler_Unit_Warning.
	* libgnat/g-table.ads: Likewise.
	* libgnat/g-pehage.ads: Add with clause and local renaming for
	System.Perfect_Hash_Generators.
	(Optimization): Turn into derived type.
	(Verbose): Turn into renaming.
	(Too_Many_Tries): Likewise.
	(Table_Name): Move to System.Perfect_Hash_Generators.
	(Define): Likewise.
	(Value): Likewise.
	* libgnat/g-pehage.adb: Remove with clause for Ada.Directories,
	GNAT.Heap_Sort_G and GNAT.Table.  Move bulk of implementation
	to System.Perfect_Hash_Generators, only keep the output part.
	* libgnat/s-imagen.ads: New generic unit.
	* libgnat/s-imagen.adb: New body.
	* libgnat/s-imen16.ads: New unit.
	* libgnat/s-imen32.ads: Likewise.
	* libgnat/s-imenu8.ads: Likewise.
	* libgnat/s-imenne.ads: Adjust description.
	* libgnat/s-imgenu.ads: Delete.
	* libgnat/s-imgenu.adb: Likewise.
	* libgnat/s-pehage.ads: New unit from GNAT.Perfect_Hash_Generators.
	* libgnat/s-pehage.adb: New body from GNAT.Perfect_Hash_Generators.
	* libgnat/s-valuen.ads: New generic unit.
	* libgnat/s-valuen.adb: New body.
	* libgnat/s-vaen16.ads: New unit.
	* libgnat/s-vaen32.ads: Likewise.
	* libgnat/s-vaenu8.ads: Likewise.
	* libgnat/s-valenu.ads: Delete.
	* libgnat/s-valenu.adb: Likewise.
	* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-pehage.o.
	(GNATBIND_OBJS): Remove s-imgenu.o.
2021-05-05 04:18:59 -04:00
Piotr Trojanek
78a4cb56a0 [Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error
gcc/ada/

	* sem_util.ads (Apply_Compile_Time_Constraint_Error): Remove
	parameter Rep from the function spec and "and if the flag Rep is
	set" from the comment.
	* sem_util.adb (Apply_Compile_Time_Constraint_Error): Remove
	parameter Rep.
2021-05-05 04:18:59 -04:00
Ed Schonberg
d478013953 [Ada] Ongoing work for AI12-0212: container aggregates
gcc/ada/

	* sem_aggr.adb (Resolve_Indexed_Aggregate): For indexed
	aggregates with component associations verify that if there is
	more than one component association then all the choices are
	static, that the set of choices define a continuous sequence of
	values, and that if loop specfications appear, they do not
	include iterator filters or key expressions.
2021-05-05 04:18:58 -04:00
Eric Botcazou
ec80b41655 [Ada] Implement tiered support for floating-point output operations
gcc/ada/

	* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-dourea, s-imager,
	s-imgflt, s-imglfl and s-imgllf.
	(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorks]: Use s-dorepr__fma.adb.
	(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorksAE]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [Aarch64/VxWorks]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [Aarch64/QNX]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [Aarch64/FreeBSD]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [PowerPC/Linux]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [Aarch64/Linux]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [IA-64/Linux]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [IA-64/HP-UX]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [RISC-V/Linux]: Likewise.
	(LIBGNAT_TARGET_PAIRS) [PowerPC/Darwin]: Likewise.
	* exp_attr.adb (Expand_N_Attribute_Reference) [Attribute_Fore]: Use
	Fixed suffix and Long_Float type.
	* exp_imgv.adb (Expand_Image_Attribute): For floating-point types,
	use the routine of the corresponding root type.  For ordinary fixed
	point types, use Fixed suffix and Long_Float type.
	(Expand_Value_Attribute): Revert latest change for Long_Long_Float.
	* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Remove libgnat units
	g-hesora.o and s-imgenu.o, add g-heasor.o, g-table.o and s-pehage.o.
	(GNATBIND_OBJS): Remove libgnat unit s-imgenu.o.
	* rtsfind.ads (RTU_Id): Add System_Img_Flt, System_Img_LFlt and
	System_Img_LLF.  Remove System_Img_Real.
	(RE_Id): Rename RE_Fore_Real to RE_Fore_Fixed.  Add RE_Image_Float,
	RE_Image_Long_Float and RE_Image_Long_Long_Float.  Rename
	RE_Image_Ordinary_Fixed_Point to RE_Image_Fixed.
	(RE_Unit_Table): Adjust to above changes.
	* libgnat/a-nbnbre.adb (Fixed_Conversions): Use Long_Float instead
	of Long_Long_Float.
	* libgnat/a-textio.ads (Field): Remove obsolete comment.
	* libgnat/a-ticoau.ads (Aux): Adjust ancestor package.
	* libgnat/a-ticoau.adb: Remove with/use clause for System.Img_Real.
	(Puts): Call Aux.Set_Image instead of Set_Image_Real.
	* libgnat/a-ticoio.adb: Add with/use clauses for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Scalar_Float): Add third actual parameter.
	(Scalar_Long_Float): Likewise.
	(Scalar_Long_Long_Float): Likewise.
	* libgnat/a-tifiio.adb: Add with/use clauses for System.Img_LFlt
	and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
	Long_Long_Float with Long_Float throughout.
	* libgnat/a-tifiio__128.adb: Likewise.
	* libgnat/a-tiflau.ads: Add Set_Image formal parameter.
	* libgnat/a-tiflau.adb: Add with/use clause for System.Img_Util,
	remove the one for System.Img_Real.
	(Put): Call Set_Image instead of Set_Image_Real.
	(Puts): Likewise.
	* libgnat/a-tiflio.adb: Add with/use clause for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Aux_Float): Add third actual parameter.
	(Aux_Long_Float): Likewise.
	(Aux_Long_Long_Float): Likewise.
	* libgnat/a-witeio.ads (Field): Remove obsolete comment.
	* libgnat/a-wtcoau.ads (Aux): Adjust ancestor package.
	* libgnat/a-wtcoau.adb: Remove with/use clause for System.Img_Real.
	(Puts): Call Aux.Set_Image instead of Set_Image_Real.
	* libgnat/a-wtcoio.adb: Add with/use clauses for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Scalar_Float): Add third actual parameter.
	(Scalar_Long_Float): Likewise.
	(Scalar_Long_Long_Float): Likewise.
	* libgnat/a-wtfiio.adb: Add with/use clauses for System.Img_LFlt
	and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
	Long_Long_Float with Long_Float throughout.
	* libgnat/a-wtfiio__128.adb: Likewise.
	* libgnat/a-wtflau.ads: Add Set_Image formal parameter.
	* libgnat/a-wtflau.adb: Add with/use clause for System.Img_Util,
	remove the one for System.Img_Real.
	(Put): Call Set_Image instead of Set_Image_Real.
	(Puts): Likewise.
	* libgnat/a-wtflio.adb: Add with/use clause for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Aux_Float): Add third actual parameter.
	(Aux_Long_Float): Likewise.
	(Aux_Long_Long_Float): Likewise.
	* libgnat/a-ztexio.ads (Field): Remove obsolete comment.
	* libgnat/a-ztcoau.ads (Aux): Adjust ancestor package.
	* libgnat/a-ztcoau.adb: Remove with/use clause for System.Img_Real.
	(Puts): Call Aux.Set_Image instead of Set_Image_Real.
	* libgnat/a-ztcoio.adb: Add with/use clauses for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Scalar_Float): Add third actual parameter.
	(Scalar_Long_Float): Likewise.
	(Scalar_Long_Long_Float): Likewise.
	* libgnat/a-ztfiio.adb: Add with/use clauses for System.Img_LFlt
	and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
	Long_Long_Float with Long_Float throughout.
	* libgnat/a-ztfiio__128.adb: Likewise.
	* libgnat/a-ztflau.ads: Add Set_Image formal parameter.
	* libgnat/a-ztflau.adb: Add with/use clause for System.Img_Util,
	remove the one for System.Img_Real.
	(Put): Call Set_Image instead of Set_Image_Real.
	(Puts): Likewise.
	* libgnat/a-ztflio.adb: Add with/use clause for System.Img_Flt,
	System.Img_LFlt and System.Img_LLF.
	(Aux_Float): Add third actual parameter.
	(Aux_Long_Float): Likewise.
	(Aux_Long_Long_Float): Likewise.
	* libgnat/s-dorepr.adb: New file.
	* libgnat/s-dorepr__fma.adb: Likewise.
	* libgnat/s-dourea.ads: Likewise.
	* libgnat/s-dourea.adb: Likewise.
	* libgnat/s-forrea.ads (Fore_Real): Rename into...
	(Fore_Fixed): ...this and take Long_Float parameters.
	* libgnat/s-forrea.adb (Fore_Real): Likewise.
	(Fore_Fixed): Likewise.
	* libgnat/s-imgrea.ads: Move to...
	(Set_Image_Real): Turn into mere renaming.
	* libgnat/s-imager.ads: ...here.
	(Image_Ordinary_Fixed_Point): Turn into...
	(Image_Fixed_Point): ...this.
	* libgnat/s-imgrea.adb: Add pragma No_Body.  Move to...
	* libgnat/s-imager.adb: ...here.
	(Image_Ordinary_Fixed_Point): Turn into...
	(Image_Fixed_Point): ...this.
	(Is_Negative): Replace Long_Long_Float with Num.
	(Set_Image_Real): Likewise.  Use Double_T instead of single Num
	throughout the algorithm.
	* libgnat/s-imgflt.ads: New file.
	* libgnat/s-imglfl.ads: Likewise.
	* libgnat/s-imgllf.ads: Likewise.
	* libgnat/s-imagef.ads: Adjust comment.
	* libgnat/s-imguti.ads (Max_Real_Image_Length): New named number.
	* libgnat/s-powflt.ads (Maxpow): Adjust.
	(Powten): Turn into an exact table of double Float.
	* libgnat/s-powlfl.ads (Maxpow): Adjust.
	(Powten): Turn into an exact table of double Long_Float.
	* libgnat/s-powllf.ads (Maxpow): Adjust.
	(Powten): Turn into an exact table of double Long_Long_Float.
	* libgnat/s-valrea.ads: Change order of formal parameters.
	* libgnat/s-valrea.adb: Add with clause for System.Double_Real.
	(Double_Real): New instantiation.
	(Fast2Sum): Delete.
	(Large_Powten): New function.
	(Integer_to_Real): Use Quick_Two_Sum instead of Fast2Sum.  Convert
	the value to Double_T.  Do the scaling in Double_T for base 10.
	* libgnat/s-valflt.ads: Remove with/use clasue for Interfaces,
	add it for System.Unsigned_Types.  Use Unsigned.
	* libgnat/s-vallfl.ads: Remove with/use clasue for Interfaces,
	add it for System.Unsigned_Types.  Use Long_Unsigned.
	* libgnat/s-valllf.ads: Remove with/use clasue for Interfaces,
	add it for System.Unsigned_Types.  Use Long_Long_Unsigned.
2021-05-05 04:18:58 -04:00
Piotr Trojanek
ab3de94f09 [Ada] Set constraint error on real division just like on integer division
gcc/ada/

	* sem_eval.adb (Eval_Arithmetic_Op): Call
	Set_Raises_Constraint_Error on real division by zero just like
	it is called for integer division by zero earlier in this
	routine.
2021-05-05 04:18:58 -04:00
Piotr Trojanek
61b54320da [Ada] Remove redundant check in iteration over formal parameters
gcc/ada/

	* freeze.adb (Build_Renamed_Body): Simplify IF and WHILE
	statements with the same condition.
2021-05-05 04:18:58 -04:00
Piotr Trojanek
5e54a5cff4 [Ada] Refactor repeated call to Next when pretty-printing if-expressions
gcc/ada/

	* pprint.adb (Expr_Name): Introduce local constants to make the
	code more readable and avoid repeated calls to Next to reach the
	ELSE part of an if-expression.
2021-05-05 04:18:57 -04:00
Tobias Burnus
af4e4d35f0 g++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]
gcc/testsuite/
	PR testsuite/100422
	* g++.dg/gomp/clause-3.C: Use 'reduction(&:..)' instead of '...(&&:..)'.
2021-05-05 10:11:47 +02:00
Richard Biener
d846f225c2 tree-optimization/79333 - fold stmts following SSA edges in VN
This makes sure to follow SSA edges when folding eliminated stmts.
This reaps the same benefit as forwprop folding all stmts, not
waiting for one to produce copysign in the new testcase.

2021-05-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79333
	* tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt):
	Fold stmt following SSA edges.

	* gcc.dg/tree-ssa/ssa-fre-94.c: New testcase.
	* gcc.dg/graphite/fuse-1.c: Adjust.
	* gcc.dg/pr43864-4.c: Likewise.
2021-05-05 09:11:32 +02:00
Richard Biener
8ebf6b9995 middle-end/100394 - avoid DSE/DCE of pure call that throws
There is -fdelete-dead-exceptions now and we're tracking
nothrow and const/pure bits separately and I do remember that
const or pure does _not_ imply nothrow.

Now, in the light of the PR100382 fix which added a
stmt_unremovable_because_of_non_call_eh_p guard to DSEs "DCE"
I wondered how -fdelete-dead-exceptions applies to calls and
whether stmt_unremovable_because_of_non_call_eh_p doing

  return (fun->can_throw_non_call_exceptions
          && !fun->can_delete_dead_exceptions
          && stmt_could_throw_p (fun, stmt));

really should conditionalize itself on
fun->can_throw_non_call_exceptions.  In fact DCE happily elides
pure function calls that throw without a LHS (probably a
consistency bug).  The following testcase shows this:

int x, y;
int __attribute__((pure,noinline)) foo () { if (x) throw 1; return y; }

int main()
{
  int a[2];
  x = 1;
  try {
    int res = foo ();
    a[0] = res;
  } catch (...) {
      return 0;
  }
  return 1;
}

note that if you wrap foo () into another noinline
wrap_foo () { foo (); return 1; } function then we need to make
sure to not DCE this call either even though it only throws
externally.

2021-05-03  Richard Biener  <rguenther@suse.de>

	PR middle-end/100394
	* calls.c (expand_call): Preserve possibly throwing calls.
	* cfgexpand.c (expand_call_stmt): When a call can throw signal
	RTL expansion there are side-effects.
	* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Simplify,
	mark all possibly throwing stmts necessary unless we can elide
	dead EH.
	* tree-ssa-dse.c (pass_dse::execute): Preserve exceptions unless
	-fdelete-dead-exceptions.
	* tree.h (DECL_PURE_P): Add note about exceptions.

	* g++.dg/torture/pr100382.C: New testcase.
2021-05-05 09:11:23 +02:00
Tom Tromey
61d48b1e2b libcc1: avoid a call to c_str
This is a trivial change to libcc1 to avoid an explicit call to c_str.
Passing by const reference is slightly less wordy.

libcc1

	* compiler.cc (make_regexp): Take const std::string.
	(cc1_plugin::compiler_triplet_regexp::find): Update.
2021-05-05 00:08:52 -06:00
Tom Tromey
96deddca2e libcc1: avoid extra string copies
PR c/94669 points out that a couple of spots in libcc1 take a
std::string where a reference would do.  This changes these spots to
take a const char *, to reduce the number of copies.

libcc1

	PR c/94669
	* compiler.hh (compiler_driver_filename): Take const char *.
	(compiler_triplet_regexp): Likewise.
2021-05-05 00:08:34 -06:00
Tom Tromey
8fdffa48c5 libcc1: use variadic templates for callbacks
This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions.  This is how I had wanted it to work from the very
beginning, and is possible now with C++11.

I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.

libcc1

	* rpc.hh (argument_wrapper) <get>: Replace cast operator.
	(argument_wrapper<T *>) <get>: Likewise.
	(unmarshall): Add std::tuple overloads.
	(callback): Remove.
	(class invoker): New.
	* libcp1plugin.cc (plugin_init): Update.
	* libcp1.cc (libcp1::add_callbacks): Update.
	* libcc1plugin.cc (plugin_init): Update.
	* libcc1.cc (libcc1::add_callbacks): Update.
	* connection.cc (cc1_plugin::connection::do_wait): Update.
2021-05-05 00:06:18 -06:00
Tom Tromey
ee75ca6b72 libcc1: fix a memory leak
libcc1 has a memory leak when calling fork_exec -- it allocates a new
vector of arguments, but then does not free it anywhere.  This patch
changes this code to use std::vector instead.

Note that the previous code tried to avoid bad_alloc.  I don't believe
this is very important.  For one thing, plenty of other allocations do
not bother with this.

libcc1

	* gdbctx.hh (do_compile): Use std::vector.
2021-05-05 00:06:18 -06:00
Tom Tromey
a8deb8323b libcc1: share the GCC interface code
Both the C and C++ side of the GDB plugin in libcc1 share a lot of
code relating to the base GCC interface.  It was all copy-and-pasted,
but is essentially identical between the two.  This is by design, as
the base GCC API is intended to be shared.

This patch merges the implementations into base_gdb_plugin, which was
introduced earlier for this purpose.

libcc1

	* libcp1.cc (libcp1): Change parameters.  Update.
	(libcp1_set_verbose, libcp1_set_arguments)
	(libcp1_set_triplet_regexp, libcp1_set_driver_filename)
	(libcp1_set_source_file, libcp1_set_print_callback, fork_exec)
	(libcp1_compile, libcp1_destroy, vtable): Remove.
	(libcp1::add_callbacks): New method, extracted from
	libcp1_compile.
	(gcc_c_fe_context): Update.
	* libcc1.cc (libcc1): Change parameters.  Update.
	(libcc1_set_verbose, libcc1_set_arguments)
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
	(libcc1_set_source_file, libcc1_set_print_callback, fork_exec)
	(libcc1_compile, libcc1_destroy, vtable): Remove.
	(libcc1::add_callbacks): New method, extracted from
	libcc1_compile.
	(gcc_c_fe_context): Update.
	* gdbctx.hh (base_gdb_plugin): Change parameters.
	(~base_gdb_plugin): New.
	<add_callbacks>: New virtual method.
	<plugin_name, fe_version, compiler_name, vtable>: New members.
	(get_self, do_set_verbose, do_set_arguments)
	(do_set_triplet_regexp, do_set_driver_filename)
	(do_set_arguments_v0, do_set_source_file, do_set_print_callback)
	(fork_exec, do_compile, do_compile_v0, do_destroy): New methods.
2021-05-05 00:06:18 -06:00
Tom Tromey
b65c0bcbe1 libcc1: use GCC_FE_VERSION_1 in C++ plugin
The C++ plugin defaults to version 0 of the base compiler API.
However, this is a mistake -- version 1 was introduced before the C++
API was even implemented.  This switches the default to version 1.
Note that the compiler-side plugin will accept this version, so it
should remain compatible.

libcc1

	* libcp1.cc (vtable): Use GCC_FE_VERSION_1.
2021-05-05 00:06:18 -06:00
Tom Tromey
1a51cb2990 libcc1: share GDB plugin code
The two GDB plugins in libcc1 share a fair amount of code.  This was
done by copy-and-paste, though in reality the underlying code is
nearly identical.

libcc1

	* libcp1.cc (struct libcp1): Derive from base_gdb_plugin.  Remove
	shared code.
	(class libcp1_connection): Remove.
	(rpc): Remove.
	(libcp1_set_verbose, libcp1_compile): Update.
	(cp_call_binding_oracle, cp_call_symbol_address)
	(cp_call_enter_scope, cp_call_leave_scope): Update.
	* libcc1.cc (struct libcc1): Derive from base_gdb_plugin.  Remove
	shared code.
	(class libcc1_connection): Remove.
	(c_call_binding_oracle, c_call_symbol_address): Update.
	(rpc): Remove.
	(libcc1_set_verbose, libcc1_compile): Update.
	* gdbctx.hh: New file.
2021-05-05 00:06:17 -06:00
Tom Tromey
0624823260 libcc1: share basic context code
Both plugins in libcc1 share a fair amount of boilerplate.  They both
share error-emission code, context management code, and tree GC code.
This patch unifies these two bodies of code, avoiding needless
duplication.

libcc1

	* libcc1plugin.cc: Move code to context.cc.
	* libcp1plugin.cc: Move code to context.cc.
	* context.hh: New file.
	* context.cc: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (AM_CPPFLAGS): Add more gcc flags.
	(CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): Update.
	(libcc1plugin_la_SOURCES): Add context.hh, context.cc.
	(libcp1plugin_la_SOURCES): Likewise.
2021-05-05 00:06:17 -06:00
Tom Tromey
0ed83e1d03 libcc1: use static_assert
This changes one spot in libcc1 to use static_assert rather than the
old-style array declaration.

libcc1

	* libcp1plugin.cc: Use static assert.
2021-05-05 00:06:17 -06:00
Tom Tromey
7c4e5d5eaa libcc1: use foreach
This changes libcc1 to ues foreach in a couple of spots.

libcc1

	* libcp1plugin.cc (plugin_context::mark): Use foreach.
	* libcc1plugin.cc (plugin_context::mark): Use foreach.
2021-05-05 00:06:17 -06:00
Tom Tromey
1d9c972601 libcc1: unify compiler handling
Both libcc1 plugins have nearly identical copies of code to find the
underlying compiler.  This seemed wasteful to me, so this patch
unifies the copies.

Two minor API changes were needed.

First, the old code used a back-link from the compiler object to the
plugin object to check the 'verbose' setting.  This patch adds a
'verbose' setting directly to the compiler object instead.

Second, the 'find' method implicitly knew which compiler base name
("gcc" or "g++") to use.  This patch makes this a parameter that is
passed in by the plugin.

libcc1

	* libcp1.cc (compiler, compiler_triplet_regexp)
	(compiler_driver_filename): Remove.
	(libcp1::libcp1): Update.
	(make_regexp, libcp1::compiler::find)
	(libcp1::compiler_triplet_regexp::find)
	(libcp1::compiler_driver_filename::find): Remove.
	(libcp1_set_verbose, libcp1_set_arguments)
	(libcp1_set_triplet_regexp, libcp1_set_driver_filename): Update.
	* libcc1.cc (compiler, compiler_triplet_regexp)
	(compiler_driver_filename): Remove.
	(libcc1::libcc1): Update.
	(make_regexp, libcc1::compiler::find)
	(libcc1::compiler_triplet_regexp::find)
	(libcc1::compiler_driver_filename::find): Remove.
	(libcc1_set_verbose, libcc1_set_arguments)
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename): Update.
	* compiler.cc: New file.
	* compiler.hh: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (libcc1_la_SOURCES): Add compiler.hh, compiler.cc.
2021-05-05 00:06:17 -06:00
Tom Tromey
30c9604c2c libcc1: use unique_ptr more
This changes libcc1 to use unique_ptr in a few more places, removing
some manual memory management.

libcc1

	* libcp1.cc (struct libcp1) <connection, compilerp>: Use
	unique_ptr.
	(~libcp1): Remove.
	(libcp1_compile, libcp1_set_triplet_regexp)
	(libcp1_set_driver_filename): Update.
	* libcc1.cc (struct libcc1) <connection, compilerp>: Use
	unique_ptr.
	(~libcc1): Remove.
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
	(libcc1_compile): Update.
2021-05-05 00:06:17 -06:00
Tom Tromey
0f237df286 libcc1: add more uses of 'deleter'
This changes libcc1 to use the 'deleter' template in a few more
places.  The template and basic specializations are moved to a new
header, then some unmarshall functions are changed to use this code.
This change avoids the need to repeat cleanup code in the
unmarshallers.

libcc1

	* rpc.hh (deleter): Move template and some specializations to
	deleter.hh.
	(argument_wrapper<const T *>): Use cc1_plugin::unique_ptr.
	* marshall.cc (cc1_plugin::unmarshall): Use
	cc1_plugin::unique_ptr.
	* marshall-cp.hh (deleter): New specializations.
	(unmarshall): Use cc1_plugin::unique_ptr.
	* deleter.hh: New file.
2021-05-05 00:06:17 -06:00
Tom Tromey
0d5a0b9af5 libcc1: add deleter objects
This adds deleter objects for various kinds of protocol pointers to
libcc1.  Existing specializations of argument_wrapper are then
replaced with a single specialization that handles all pointer types
via the appropriate deleter.  The result here is a bit nicer because
the argument_wrapper boilerplate code is completely shared, leaving
just the memory-management detail to the particular specializations.

libcc1

	* rpc.hh (struct deleter): New template class and
	specializations.
	(argument_wrapper): Remove specializations.  Add specialization
	for any pointer type.
2021-05-05 00:06:17 -06:00
Tom Tromey
e702c60e65 libcc1: use std::vector when building function types
This changes libcc1 to use std::vector in the code that builds
function types.  This avoids some explicit memory management.

libcc1

	* libcp1plugin.cc (plugin_build_function_type): Use std::vector.
	* libcc1plugin.cc (plugin_build_function_type): Use std::vector.
2021-05-05 00:06:16 -06:00