Commit Graph

194178 Commits

Author SHA1 Message Date
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
Eric Botcazou
1f03b43fc7 [Ada] Fix dispatching call to primitive function with controlling tagged result
When a dispatching call is made to a primitive function with a controlling
tagged result, the call is dispatching on result and thus must return the
class-wide type of the tagged type to accommodate all possible results.

This was ensured by Expand_Dispatching_Call only in the common case where
the result type is the type of the controlling argument, which does not
cover the case of a primitive function inherited from an ancestor type.

gcc/ada/

	* exp_disp.adb (Expand_Dispatching_Call): Fix detection of calls
	that are dispatching on tagged result.
2022-07-04 07:46:00 +00:00
Doug Rupp
4dab9bed7b [Ada] vx7r2: do not include s-qnx.ads in the kernel and rtp runtimes
Target specific runtime files must be added to a the exclude list so the
files don't automatically get copied to other runtimes.

gcc/ada/

	* Makefile.rtl (ADA_EXCLUDE_SRCS): Add s-qnx.ads.
2022-07-04 07:46:00 +00:00
Eric Botcazou
aa683f5c03 [Ada] Small housekeeping work in Expand_N_Object_Declaration
The local function Rewrite_As_Renaming can be called twice in certain
circumstances, which is both not quite safe and unnecessary, so this
replaces it with a local variable whose value is computed only once.

No functional changes.

gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration) <OK_To_Rename_Ref>: New
	local function.
	<Rewrite_As_Renaming>: Change to a local variable whose value is
	computed once and generate a call to Finalize after this is done.
	Simplify the code creating the renaming at the end.
2022-07-04 07:45:59 +00:00
Doug Rupp
2f94aea27c [Ada] Makefile.rtl: remove references t oVxworks RTP Cert .spec files
gcc/ada/

	* Makefile.rtl (GCC_SPEC_FILES): Remove vxworks cert files.
2022-07-04 07:45:59 +00:00
Piotr Trojanek
e0cd23986e [Ada] Refactor duplicated resolution of Count and Index attributes
Attribute Index, which was added to Ada 2022 by AI12-0143, is resolved
just like attribute Count. However, code duplication rightly triggered a
CodePeer warning.

gcc/ada/

	* sem_attr.adb (Resolve_Attribute): Refactor duplicated code for
	Count and Index attributes.
2022-07-04 07:45:59 +00:00
Eric Botcazou
a521dc3799 [Ada] Use static stack allocation for small string if-expressions
This changes the expanded code generated for if-expressions of 1-dimensional
arrays to create a static temporary on the stack if a small upper bound can
be computed for the length of a subtype covering the result.  Static stack
allocation is preferred over dynamic allocation for code generation purpose.

This also contains a couple of enhancements to the support code for checks,
so as to avoid generating useless checks during the modified expansion.

gcc/ada/

	* checks.adb (Apply_Length_Check_On_Assignment): Return early if
	the Suppress_Assignment_Checks flag is set.
	(Selected_Range_Checks): Deal with conditional expressions.
	* exp_ch4.adb (Too_Large_Length_For_Array): New constant.
	(Expand_Concatenate): Use it in lieu of Too_Large_Max_Length.
	(Expand_N_If_Expression): If the result has a unidimensional array
	type but the dependent expressions have constrained subtypes with
	known bounds, create a static temporary on the stack with a subtype
	covering the result.
	(Get_First_Index_Bounds): Deal with string literals.
	* uintp.ads (Uint_256): New deferred constant.
	* sinfo.ads (Suppress_Assignment_Checks): Document new usage.
2022-07-04 07:45:58 +00:00
Eric Botcazou
0896e2b79a [Ada] Adjust previous change to Rewrite_As_Renaming
gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration.Rewrite_As_Renaming):
	Do not rewrite if the declaration has got constraints.
	* sinfo.ads (Case Expression Alternative): Fix typo.
2022-07-04 07:45:58 +00:00
Eric Botcazou
2cad8a59a8 [Ada] Use static stack allocation for small dynamic string concatenations
This changes the expanded code generated for dynamic concatenations to
use a static array subtype for the temporary created on the stack if a
small upper bound can be computed for the length of the result.  Static
stack allocation is preferred over dynamic allocation for code
generation purposes.

gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration.Rewrite_As_Renaming):
	Be prepared for slices.
	* exp_ch4.adb (Get_First_Index_Bounds): New procedure.
	(Expand_Array_Comparison.Length_Less_Than_4): Call it.
	(Expand_Concatenate): Try to compute a maximum length for
	operands with variable length and a maximum total length at the
	end.  If the concatenation is dynamic, but a sensible maximum
	total length has been computed, use this length to create a
	static array subtype for the temporary and return a slice of it.
2022-07-04 07:45:58 +00:00
Steve Baird
f3451ba8aa [Ada] Enforce deferred constant completion rules
If a constrained subtype is given when a deferred constant is declared,
then the subtype given in the completion is required (at compile time)
to be subject to a statically matching constraint. This rule was not
properly enforced in some cases and constructs that should have been
rejected were incorrectly accepted.

gcc/ada/

	* sem_ch3.adb (Check_Possible_Deferred_Completion): Delete
	Prev_Obj_Def formal parameter.  Reorganize code so that
	statically matching check is also performed in the case where
	the subtype given in the initial declaration is constrained and
	the subtype given in the completion is not.
2022-07-04 07:45:57 +00:00
Bob Duff
4b766285b0 [Ada] Assertions in Einfo.Utils
Add predicates on subtypes E and N.

gcc/ada/

	* einfo-utils.ads, einfo-utils.adb: Add predicates on subtypes E
	and N.  Change some parameters to use the unpredicated subtypes,
	because they sometimes return e.g. Empty.  Note that N_Entity_Id
	has a predicate; Entity_Id does not.
	* exp_tss.adb (Base_Init_Proc): Use Entity_Id instead of E,
	because otherwise we fail the predicate. We shouldn't be
	referring to single-letter names from far away anyway.
	* sem_aux.adb (Is_Derived_Type): Likewise.
	* sem_res.adb (Is_Definite_Access_Type): Use N_Entity_Id for
	predicate.
	* types.ads (Entity_Id): Add comment explaining the difference
	between Entity_Id and N_Entity_Id.
2022-07-04 07:45:57 +00:00
Justin Squirek
78f13b008a [Ada] Tech debt: Remove code duplication
This patch corrects removes some code duplication within the GNAT
compiler.

gcc/ada/

	* exp_util.adb (Remove_Side_Effects): Combine identical
	branches.
	* sem_attr.adb (Analyze_Attribute): Combine identical cases
	Attribute_Has_Same_Storage and Attribute_Overlaps_Storage.
	* sem_prag.adb (Check_Role): Combine E_Out_Parameter case with
	general case for parameters.
	* sem_util.adb (Accessibility_Level): Combine identical
	branches.
	* sprint.adb (Sprint_Node_Actual): Combine cases for
	N_Real_Range_Specification and N_Signed_Integer_Type_Definition.
2022-07-04 07:45:57 +00:00
Justin Squirek
1fde86bba5 [Ada] Single character argument in call to Quote_Argument raises error
This patch corrects an issue in the compiler whereby calling
Quote_Argument with an argument that is of size 1 may lead to a
CONSTRAINT_ERROR raised at runtime due to an undersized buffer.

gcc/ada/

	* libgnat/s-os_lib.adb (Quote_Argument): Modify the result
	buffer size calculation to handle the case where Arg'Length is
	1.
2022-07-04 07:45:56 +00:00
Bob Duff
3319015b0a [Ada] Fix missing error on 'Access of constrained array
For X'Access, the designated subtype of the access type must statically
match the nominal subtype of X.  This patch fixes a bug where the error
was not detected when there is an unrelated declaration of the form "Y :
T := X;", where T is an unconstrained array subtype.

gcc/ada/

	* exp_util.adb (Expand_Subtype_From_Expr): Generate a new
	subtype when Is_Constr_Subt_For_UN_Aliased is True, so the
	Is_Constr_Subt_For_U_Nominal flag will not be set on the
	preexisting subtype.
	* sem_attr.adb, sem_ch3.adb: Minor.
2022-07-04 07:45:56 +00:00
Eric Botcazou
02e41e69d4 [Ada] Do not use front-end build-in-place mechanism for nonlimited types
It was only used in specific cases for controlled types but no longer
provides any significant benefit in practice.

gcc/ada/

	* debug.adb (d.9): Remove usage.
	* exp_ch6.adb (Expand_Simple_Function_Return): Remove redundant
	test on Debug_Flag_Dot_L.
	(Is_Build_In_Place_Result_Type): Return false for nonlimited types.
	(Is_Build_In_Place_Function): Tidy up and remove redundant test on
	Debug_Flag_Dot_L.
2022-07-04 07:45:55 +00:00
Eric Botcazou
c901877fac [Ada] Call-initialize all controlled objects in place
This changes the compiler to build in place almost all objects that need
finalization and are initialized with the result of a function call, thus
saving a pair of Adjust/Finalize calls for the anonymous return object.

gcc/ada/

	* exp_ch3.adb (Expand_N_Object_Declaration): Don't adjust the object
	if the expression is a function call.
	<Rewrite_As_Renaming>: Return true if the object needs finalization
	and is initialized  with the result of a function call returned on
	the secondary stack.
	* exp_ch6.adb (Expand_Ctrl_Function_Call): Add Use_Sec_Stack boolean
	parameter.  Early return if the parent is an object declaration and
	Use_Sec_Stack is false.
	(Expand_Call_Helper): Adjust call to Expand_Ctrl_Function_Call.
	* exp_ch7.adb (Find_Last_Init): Be prepared for initialization still
	present in the object declaration.
	* sem_ch3.adb (Analyze_Object_Declaration): Call the predicates
	Needs_Secondary_Stack and Needs_Finalization to guard the renaming
	optimization.
2022-07-04 07:45:55 +00:00
Bob Duff
eb6e8a7acd [Ada] Add Ada 2022 Key function to sets containers
This patch adds the new Generic_Keys.Key function to the set children
of Ada.Containers.

gcc/ada/

	* libgnat/a-cbhase.ads, libgnat/a-cborse.ads,
	libgnat/a-cihase.ads, libgnat/a-ciorse.ads,
	libgnat/a-cohase.ads, libgnat/a-coorse.ads (Key): New function
	that takes a Container parameter, implemented as an expression
	function, so it is self explanatory (doesn't need a comment).
2022-07-04 07:45:55 +00:00
Vasiliy Fofanov
cac397f3f6 [Ada] Fix length of title underlines.
gcc/ada/

	* doc/gnat_rm/the_gnat_library.rst: Fix length of title
	underlines.
2022-07-04 07:45:54 +00:00
Steve Baird
063c8f4c01 [Ada] Compiler rejects legal allocator in record component constraint expression
In some cases when a legal allocator which defines a new subtype for the
allocated object occurs as part of a record component constraint
expression, the compiler would incorrectly reject the allocator.

gcc/ada/

	* sem_ch4.adb (Analyze_Allocator): After calling Insert_Action
	to insert a subtype declaration associated with an allocator,
	the subtype declaration will usually be analyzed. But not
	always. Add an explicit call to Preanalyze to cope with the
	unusual case. The subtype declaration must be at least
	preanalyzed before the call to Sem_Ch3.Process_Subtype a little
	while later, during which we analyze an identifier that refers
	to the subtype.
2022-07-04 07:45:54 +00:00
Steve Baird
f7c05e8203 [Ada] Avoid unwanted warnings for statically-known-successful assertions
The -gnatwc switch enables warnings for test condition outcomes that are
known at compile time. Such warnings are unlikely to be useful in the
case of an assertion expression (or a subexpression thereof), so do not
generate them in that case.

gcc/ada/

	* sem_warn.adb (Warn_On_Constant_Valid_Condition): Do not
	generate a warning if the expression in question is an assertion
	expression, or a subexpression thereof. But do call
	Test_Comparison so that it can generate warnings for the cases
	that it generates warnings for.
	* sem_prag.ads: Modify Assertion_Expression_Pragma constant so
	that the predicate Sem_Util.In_Assertion_Expression_Pragma
	returns True for the expression of a Compile_Time_Error pragma.
2022-07-04 07:45:54 +00:00
Julien Bortolussi
e7428fff12 [Ada] Add a RM entry for the functional infinite sequences
Modify the RM to take into account the new functional container.

gcc/ada/

	* doc/gnat_rm/the_gnat_library.rst: Add the new entry.
	* gnat_rm.texi: Regenerate.
2022-07-04 07:45:53 +00:00
Eric Botcazou
4030e83c27 [Ada] Give missing error on ambiguous operand of equality operator
When the code responsible for giving errors on ambiguous operands of
comparison and equality operators was moved from the 1st phase (analysis)
to the 2nd phase (resolution) of semantic processing, it was incorrectly
restricted to the operator case, which was valid during the 1st phase but
is not during the 2nd phase.

gcc/ada/

	* sem_res.adb (Resolve_Comparison_Op): Deal with ambiguous operands
	in all cases.
	(Resolve_Equality_Op): Likewise, except for the case of the implicit
	inequality operator created for a user-defined operator that is not
	an intrinsic subprogram.
2022-07-04 07:45:53 +00:00
Bob Duff
a8a1da109e [Ada] Add Ada 2022 features to sets containers
This patch adds some Ada 2022 features to the set children of
Ada.Containers.

gcc/ada/

	* libgnat/a-cbhase.adb, libgnat/a-cbhase.ads,
	libgnat/a-cborse.adb, libgnat/a-cborse.ads,
	libgnat/a-cihase.adb, libgnat/a-cihase.ads,
	libgnat/a-ciorse.adb, libgnat/a-ciorse.ads,
	libgnat/a-cohase.adb, libgnat/a-cohase.ads,
	libgnat/a-conhel.adb, libgnat/a-conhel.ads,
	libgnat/a-coorse.adb, libgnat/a-coorse.ads: Add Has_Element,
	Element, Query_Element, and Next subprograms that take a Set
	parameter. Add Tampering_With_Cursors_Prohibited function. These
	are all new in Ada 2022.
2022-07-04 07:45:53 +00:00
Claire Dross
2e9b2ab3b5 [Ada] Update the documentation of functional containers
Functional containers are now controlled. Update the documentation
accordingly.

gcc/ada/

	* doc/gnat_rm/the_gnat_library.rst: Functional vectors, sets,
	and maps are now controlled.
	* gnat_rm.texi: Regenerate.
2022-07-04 07:45:52 +00:00
Claire Dross
82b63eb0f3 [Ada] Add GNAT specific pragmas to the equivalent Assertion_Policy for -gnata
All assertion pragmas are enabled by default when using -gnata. We need
to add the GNAT specific ones to the list.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Debugging and Assertion Control): Add GNAT specific assertion
	pragmas to the equivalent Assertion_Policy for the -gnata
	option.
	* gnat_ugn.texi: Regenerate.
2022-07-04 07:45:52 +00:00
Justin Squirek
ddd8892527 [Ada] Incorrect accessibility check on return of discriminated type
This patch corrects an error in the compiler whereby the presence of a
call to a function returning a type with an access discriminant within
an expanded loop condition caused the wrong value to be supplied for the
extra- accessibility-of-result actual, thus causing incorrect checks
within the callee at the point of return.

This change also corrects a problem where spurious "null value not
allowed" warnings were generated for tagged type declarations with an
access discriminant specified as "null."

gcc/ada/

	* sem_disp.adb (Most_Descendant_Use_Clause): Remove call to
	deprecated Is_Internal.
	* sem_util.adb (Innermost_Master_Scope_Depth): Use
	Find_Enclosing_Scope instead of Nearest_Dynamic_Scope to avoid
	cases where relevant scopes get skipped leading to an incorrect
	scope depth calculation.
2022-07-04 07:45:52 +00:00
Eric Botcazou
bdd5056736 [Ada] Plug loophole for built-in-place return with limited_with clause
When the result type of a function requiring built-in-place return is
only visible through a limited_with clause, the compiled needs to wait
for the nonlimited view to be available in order to compute whether
the built-in-place return is needed, and this comprises tagging the
function with the Returns_By_Ref flag.

gcc/ada/

	* exp_ch6.adb (Build_In_Place_Formal): Also compute Returns_By_Ref
	for the function if the extra formals were not built initially.
2022-07-04 07:45:51 +00:00
Piotr Trojanek
df69e326b3 [Ada] Fix for resolution of overloaded subprogram for Iterable aspect
When resolving the Iterable aspect we look for a functions that are
declared in the same scope as the annotated type and that have the
required number and types formal parameters. However, we didn't guard
against functions that have no formal parameter at all.

gcc/ada/

	* sem_ch13.adb (Resolve_Iterable_Operation): Add guard to
	prevent crash when the examined function has no formal
	parameters and Etype is called on Empty entity.
2022-07-04 07:45:51 +00:00
Julien Bortolussi
089a4a48ac [Ada] Create new unbounded functional sequence
Add a new unbounded functional sequence. This sequence is indexed by
Big_Positive and so is unbounded from the user and spark points view.
Hower the actually implemented sequence are bounded by Count_Type'Last.

gcc/ada/

	* libgnat/a-cfinse.adb, libgnat/a-cfinse.ads: Implementation
	files of the sequence.
	* Makefile.rtl, impunit.adb: Take into account the add of the
	new files
2022-07-04 07:45:51 +00:00
Eric Botcazou
ad7ed87a43 [Ada] Adjust description of Pure_Function pragma
The current wording can be read as implying that the result of a call
to a pure function does not depend on the context, which is incorrect.
The pragma only guarantees the absence of side effects of such a call.

gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst (Pure_Function):
	Fix ambiguous wording about context dependence.
	* gnat_rm.texi: Regenerate.
2022-07-04 07:45:50 +00:00
Richard Biener
d74d98784a tree-optimization/106055 - issue with autopar
When autopar uses graphites canonicalize_loop_closed_ssa it fails to
check whether propagation is allowed and thus it ends up messing up
abnormal constraints.

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

	PR tree-optimization/106055
	* graphite.cc (canonicalize_loop_closed_ssa): Check whether
	we can propagate.

	* gcc.dg/graphite/pr106055.c: New testcase.
2022-07-04 09:09:45 +02:00
Haochen Jiang
73f942c08d i386: Extend cvtps2pd to memory
gcc/ChangeLog:

	PR target/43618
	* config/i386/sse.md (extendv2sfv2df2): New define_expand.
	(sse2_cvtps2pd_<mask_name>): Change constraint of operands[1].
	(*sse2_cvtps2pd_<mask_name>_1): Rename from extendvsdfv2df2.

gcc/testsuite/ChangeLog:

	PR target/43618
	* gcc.target/i386/pr43618-1.c: New test.
2022-07-04 14:21:53 +08:00
Aldy Hernandez
bbe836bc7c Remove some deprecated irange methods.
Tested on x86-64 Linux.

gcc/ChangeLog:

	* ipa-cp.cc (ipcp_vr_lattice::meet_with_1): Use operator!=.
	* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Same.
	* tree-ssa-loop-unswitch.cc (struct unswitch_predicate): Use set
	with two arguments.
	(find_unswitching_predicates_for_bb): Same.
	* tree-vrp.cc (range_fold_unary_symbolics_p): Same.
	* value-range-equiv.cc (value_range_equiv::equal_p): Use operator==.
	* value-range.cc (irange::equal_p): Rename to...
	(irange::operator==): ...this.
	* value-range.h (irange::set): Remove.
	(irange::operator==): Remove.
	(irange::set_zero): Use set with two arguments.
	* vr-values.cc (vr_values::extract_range_from_binary_expr): Same.
	(vr_values::extract_range_from_unary_expr): Same.
	(check_for_binary_op_overflow): Same.
	(bounds_of_var_in_loop): Same.
2022-07-04 07:58:47 +02:00
GCC Administrator
3731dd0bea Daily bump. 2022-07-04 00:16:19 +00:00
H.J. Lu
f3a5e75cb6 x86: Support 2/4/8 byte constant vector stores
1. Add a predicate for constant vectors which can be converted to integer
constants suitable for constant integer stores.  For a 8-byte constant
vector, the converted 64-bit integer must be valid for store with 64-bit
immediate, which is a 64-bit integer sign-extended from a 32-bit integer.
2. Add a new pattern to allow 2-byte, 4-byte and 8-byte constant vector
stores, like

(set (mem:V2HI (reg:DI 84))
     (const_vector:V2HI [(const_int 0 [0]) (const_int 1 [0x1])]))

3. After reload, convert constant vector stores to constant integer
stores, like

(set (mem:SI (reg:DI 5 di [84]))
     (const_int 65536 [0x10000]))

For

void
foo (short * c)
{
  c[0] = 0;
  c[1] = 1;
}

it generates

	movl	$65536, (%rdi)

instead of

	movl	.LC0(%rip), %eax
	movl	%eax, (%rdi)

gcc/

	PR target/106022
	* config/i386/i386-protos.h (ix86_convert_const_vector_to_integer):
	New.
	* config/i386/i386.cc (ix86_convert_const_vector_to_integer):
	New.
	* config/i386/mmx.md (V_16_32_64): New.
	(*mov<mode>_imm): New patterns for stores with 16-bit, 32-bit
	and 64-bit constant vector.
	* config/i386/predicates.md (x86_64_const_vector_operand): New.

gcc/testsuite/

	PR target/106022
	* gcc.target/i386/pr106022-1.c: New test.
	* gcc.target/i386/pr106022-2.c: Likewise.
	* gcc.target/i386/pr106022-3.c: Likewise.
	* gcc.target/i386/pr106022-4.c: Likewise.
2022-07-03 10:30:07 -07:00
Aldy Hernandez
3ae9def085 Move range allocator code to value-range-storage.*
Now that vrange_storage is in its own file, I think it's prudent to
move all the vrange allocator code there since it's all related.
The users of value-range.h do not need to know the implementation
details of the storage facilities.

Tested and benchmarked on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-cache.cc: Include value-range-storage.h.
	* gimple-range-cache.h (class block_range_cache): Add "class" to
	m_range_allocator.
	* gimple-range-edge.cc
	(gimple_outgoing_range::gimple_outgoing_range): Allocate allocator.
	(gimple_outgoing_range::~gimple_outgoing_range): Free allocator.
	(gimple_outgoing_range::calc_switch_ranges): Dereference allocator.
	* gimple-range-edge.h: Add "class" to m_range_allocator.
	* gimple-range-infer.cc
	(infer_range_manager::infer_range_manager): Allocate allocator.
	(infer_range_manager::~infer_range_manager): Free allocator.
	(infer_range_manager::get_nonzero): Dereference allocator.
	(infer_range_manager::add_range): Same.
	* gimple-range-infer.h (class vrange_allocator): Add "class" to
	m_range_allocator.
	* value-range-storage.h (class vrange_allocator): Move from
	value-range.h.
	(class obstack_vrange_allocator): Same.
	(class ggc_vrange_allocator): Same.
	(vrange_allocator::alloc_vrange): Same.
	(vrange_allocator::alloc_irange): Same.
	* value-range.h (class vrange_allocator): Move to value-range-storage.h.
	(class obstack_vrange_allocator): Same.
	(class ggc_vrange_allocator): Same.
2022-07-03 17:33:23 +02:00
Immad Mir
17f2e2b77b Add myself to write after approval and DCO.
This is text alignment correction for my previous patch.

ChangeLog:
	* MAINTAINERS: add myself.
2022-07-03 14:39:02 +05:30
Immad Mir
21582a7c7d Add myself to write-after-approval and DCO
ChangeLog:
	* MAINTAINERS: Add myself to write after approval and DCO.
2022-07-03 14:28:34 +05:30
Aldy Hernandez
a26f3eb268 Implement class vrange_storage to stream ranges to long term memory.
This patch implements a storage class that will be used to stream out
ranges to long term storage, initially in SSA_NAME_RANGE_INFO, but it
is flexible enough to use with our obstack allocator.  For instance,
in the future we could use it in the ranger cache to save memory.

The current size of range_info_def which is used in
SSA_NAME_RANGE_INFO is 16 bytes.  With this patch, the size of the
slot (irange_storage_slot) will be 24 bytes.  But we'll have the
ability to be able to store up to 5 pairs of sub-ranges if necessary.
If we ever need to save more (say for switches), we could explore a
trailing_wide_ints structure with a pointer to the m_len[N] bits as
Jakub has suggested.

In follow-up patches I will contribute the SSA_NAME_RANGE_INFO changes
as well as changes storing the nonzero bits within an irange.

For reference, the main interface is rather simple:

class vrange_storage
{
public:
  vrange_storage (vrange_allocator *alloc) : m_alloc (alloc) { }
  void *alloc_slot (const vrange &r);
  void free (void *slot);
  void get_vrange (const void *slot, vrange &r, tree type);
  void set_vrange (void *slot, const vrange &r);
  static bool fits_p (const void *slot, const vrange &r);
};

The above class will have the knowledge to stream out the different
ranges we support (currently only irange_storage_slot).  As has been
discussed, the irange storage will use trailing wide ints:

class GTY ((variable_size)) irange_storage_slot
{
<snip>
<snip>
  // This is the maximum number of wide_int's allowed in the trailing
  // ints structure, without going over 16 bytes (128 bits) in the
  // control word that preceeds the HOST_WIDE_INTs in
  // trailing_wide_ints::m_val[].
  static const unsigned MAX_INTS = 12;

  // Maximum number of range pairs we can handle, considering the
  // nonzero bits take one wide_int.
  static const unsigned MAX_PAIRS = (MAX_INTS - 1) / 2;

  trailing_wide_ints<MAX_INTS> m_ints;
};

Tested on x86-64 Linux.

gcc/ChangeLog:

	* Makefile.in (OBJS): Add value-range-storage.o.
	(GTFILES): Add value-range-storage.h.
	* gengtype.cc (open_base_files): Add value-range-storage.h.
	* value-range-storage.cc: New file.
	* value-range-storage.h: New file.
2022-07-03 08:42:32 +02:00
Xi Ruoyao
f150dc1bd1
loongarch: use -mno-check-zero-division as the default for optimized code
Integer division by zero is undefined behavior anyway, and there are
already many platforms where neither the GCC port and the hardware do
anything to trap on division by zero.  So any portable program shall not
rely on SIGFPE on division by zero, in both theory and practice.  As the
result, there is no real reason to cost two additional instructions just
for the trap on division by zero with a new ISA.

One remaining reason to trap on division by zero may be debugging,
especially while -fsanitize=integer-divide-by-zero is not implemented
for LoongArch yet.  To make debugging easier, keep -mcheck-zero-division
as the default for -O0 and -Og, but use -mno-check-zero-division as the
default for all other optimization levels.

Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_check_zero_div_p):
	New static function.
	(loongarch_idiv_insns): Use loongarch_check_zero_div_p instead
	of TARGET_CHECK_ZERO_DIV.
	(loongarch_output_division): Likewise.
	* common/config/loongarch/loongarch-common.cc
	(TARGET_DEFAULT_TARGET_FLAGS): Remove unneeded hook.
	* doc/invoke.texi: Update to match the new behavior.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/20101011-1.c (dg-additional-options):
	add -mcheck-zero-division for LoongArch targets.
2022-07-03 11:03:26 +08:00
Tim Lange
b5c3dd3df3 Use fixed-width types in allocation size tests
The patch changes the types inside the tests for the allocation size
checker to fixed-width types of stdint.h to account for different
architectures with different type widths.

2022-07-03  Tim Lange  <mail@tim-lange.me>

gcc/testsuite/ChangeLog:

	* gcc.dg/analyzer/allocation-size-1.c: Use fixed-length types.
	* gcc.dg/analyzer/allocation-size-2.c: Likewise.
	* gcc.dg/analyzer/allocation-size-3.c: Likewise.
	* gcc.dg/analyzer/allocation-size-4.c: Likewise.
	* gcc.dg/analyzer/allocation-size-5.c: Likewise.
2022-07-03 03:26:05 +02:00
Ian Lance Taylor
d86a20ee8b tree-optimization: only DSE trapping insn if -fdelete-dead-exceptions
gcc/ChangeLog:

	* tree-ssa-dse.cc (dse_optimize_stmt): Only delete a trapping
	statement if -fdelete-dead-exceptions.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/except-1.C: New test.
2022-07-02 17:34:09 -07:00
GCC Administrator
20f0f30522 Daily bump. 2022-07-03 00:16:23 +00:00