Commit Graph

178107 Commits

Author SHA1 Message Date
Harald Anlauf
f2151227df PR fortran/95980 - ICE on using sync images with -fcheck=bounds
In SELECT TYPE, the argument may be an incorrectly specified unlimited
polymorphic variable.  Avoid a NULL pointer dereference for clean error
recovery.

gcc/fortran/
	PR fortran/95980
	* match.c (copy_ts_from_selector_to_associate, build_class_sym):
	Distinguish between unlimited polymorphic and ordinary variables
	to avoid NULL pointer dereference.
	* resolve.c (resolve_select_type):
	Distinguish between unlimited polymorphic and ordinary variables
	to avoid NULL pointer dereference.
2020-07-06 19:00:10 +02:00
Harald Anlauf
824084e72e PR fortran/95709 - ICE in gfc_resolve_code, at fortran/resolve.c:11807
The legacy "assigned GOTO" accepts only scalar integer variables.
Check for proper arguments.

gcc/fortran/
	PR fortran/95709
	* resolve.c (gfc_resolve_code): Check for valid arguments to
	assigned GOTO.
2020-07-06 18:52:39 +02:00
Jonathan Wakely
0e5abeb0cb libstdc++: Fix -Wmismatched-tags warnings (PR 96063)
libstdc++-v3/ChangeLog:

	* include/bits/fs_dir.h: Use consistent tag in class-head.
	* include/bits/localefwd.h: Likwise.
	* include/bits/regex.h: Likwise.
	* include/bits/stl_map.h: Likwise.
	* include/bits/stl_multimap.h: Likwise.
	* include/bits/stl_multiset.h: Likwise.
	* include/bits/stl_set.h: Likwise.
	* include/std/complex: Likwise.
	* include/std/functional: Likwise.
	* include/std/future: Likwise.
	* include/std/system_error: Likwise.
	* include/std/thread: Likwise.
	* include/std/tuple: Likwise.
	* include/std/type_traits: Likwise.
	* include/std/valarray: Likwise.
2020-07-06 17:12:29 +01:00
Jonathan Wakely
92414bb6b0 c++: Allow empty-declaration in C++11 and later (PR 96068)
Since C++11 a semim-colon on its own at namespace scope is not invalid,
so do not give a pedantic diagnostic about it.

gcc/cp/ChangeLog:

	PR c++/96068
	* parser.c (cp_parser_toplevel_declaration): Only do pedwarn for
	empty-declaration in C++98.

gcc/testsuite/ChangeLog:

	* g++.old-deja/g++.bugs/900404_04.C: Add c++98_only selector to
	dg-error for extra ';'.
	* g++.old-deja/g++.law/missed-error2.C: Likewise.
2020-07-06 17:12:23 +01:00
Richard Biener
dccbf1e2a6 tree-optimization/96075 - fix bogus misalignment calculation
This fixes bogus misalignment calculation for negative steps
since an assertion a previous comment indicated no longer holds:

      /* DR_STEP(dr) is the same as -TYPE_SIZE of the scalar type,
         otherwise we wouldn't be here.  */

Thus the following replaces DR_STEP by -TYPE_SIZE.

2020-07-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/96075
	* tree-vect-data-refs.c (vect_compute_data_ref_alignment): Use
	TYPE_SIZE_UNIT of the vector component type instead of DR_STEP
	for the misalignment calculation for negative step.

	* gcc.dg/vect/slp-46.c: New testcase.
2020-07-06 16:30:18 +02:00
Piotr Trojanek
a9e48b0d47 [Ada] Avoid forced loading of System.Priority in CodePeer mode
gcc/ada/

	* checks.adb (Apply_Scalar_Range_Check): Use Is_RTE.
2020-07-06 07:35:34 -04:00
Bob Duff
90a1abf304 [Ada] Time_IO.Image: Allow printing the time zone
gcc/ada/

	* libgnat/g-catiio.ads: Document newly supported format.  Add
	ISO_Time constant, for convenience.
	* libgnat/g-catiio.adb (Image_Helper): New helper function to do
	all the formatting work, called by the two exported Image
	functions.  Add support for "%:::z" here. Add a Time_Zone
	parameter used by the "%:::z" processing. This parameter is not
	used for the actual time zone computations; local time is always
	used for that, for ease of implementation reasons.  It would
	make sense to use Append throughout this function, but that's a
	cleanup for another day.
	(Image): Modify these to pass the local time zone, or the
	specified time zone, as appropriate.
2020-07-06 07:35:33 -04:00
Bob Duff
d868231706 [Ada] Time_IO.Value: Allow subseconds and time zones together
gcc/ada/

	* libgnat/g-catiio.ads: Change the regular expression that
	documents the allowed format to match what ISO-8601 allows.
	* libgnat/g-catiio.adb (Scan_Subsecond): Rewrite so it doesn't
	assume the subsecond comes last.
	(Parse_ISO_8601): Parse an optional subsecond, followed by an
	optional time zone, rather than making these alternatives to
	each other.
2020-07-06 07:35:32 -04:00
Bob Duff
bf8467d806 [Ada] Clean up GNAT.Calendar.Time_IO.Value
gcc/ada/

	* libgnat/g-catiio.adb (Parse_ISO_8601): Minor cleanups:

	Give some objects clearer names.
	Make some objects more local to where they are used.

	Remove some validity checks that can't fail, because some of
	the variables tested have been moved so they're not visible here.
	Anyway, Wrong_Syntax is about errors in the input, not data
	validity.

	Use Time_Zone_Seen instead of Local_Sign = ' ' to determine
	that a time zone indication was seen.

	We don't need to distinguish two different kinds of
	syntax error (End_Of_Source_Reached and Wrong_Syntax),
	so use Wrong_Syntax always.

	Remove comment, "Certain scanning scenarios may handle
	this exception on their own."; there are no such scenarios.
2020-07-06 07:35:31 -04:00
Bob Duff
b1e78e8577 [Ada] Implement Time_IO.Image with Time_Zone
gcc/ada/

	* libgnat/g-catiio.ads, libgnat/g-catiio.adb (Image): New
	function. It might seem like the local-time Image should be
	implemented in terms of the Time_Zone Image, but that would be
	far harder to implement, so we do it the other way around.
2020-07-06 07:35:26 -04:00
Thomas Quinot
58d94a32b4 [Ada] Use Stream_Element_Arrays internally for secure hash computations
gcc/ada/

	* libgnat/g-sechas.ads, libgnat/g-sechas.adb: Refactor to use
	Stream_Element_Array as the internal buffer type.
	* libgnat/g-shshco.adb: Adjust to use Stream_Element_Offset
	instead of Integer as the index in the internal state buffer.
2020-07-06 07:35:24 -04:00
Gary Dismukes
aaa3a67535 [Ada] Various typo fixes and reformatting of comments
gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst, errout.ads,
	erroutc.adb, exp_ch4.adb, exp_ch6.adb, freeze.adb: Comment
	rewording/reformatting/typo fixes.  Replace "ie." with "that is"
	in comment; "can not" -> "cannot", and remove an extraneous
	underscore in another comment.
	* gnat_rm.texi, gnat_ugn.texi: Regenerate.
2020-07-06 07:35:23 -04:00
Javier Miranda
0fc1b4ad1d [Ada] Ada2020: AI12-0198 potentially unevaluated array components
gcc/ada/

	* sem_util.ads (Interval_Lists.Aggregate_Intervals): New
	subprogram.
	* sem_util.adb (Has_Null_Others_Choice,
	Non_Static_Or_Null_Range, Interval_Lists.Aggregate_Intervals):
	New subprograms.
	(Is_Potentially_Unevaluated): Adding support to detect
	potentially unevaluated components of array aggregates.
2020-07-06 07:35:21 -04:00
Bob Duff
49665da2e5 [Ada] Correct time zone in GNAT.Calendar.Time_IO.Value
gcc/ada/

	* libgnat/g-catiio.adb (Parse_ISO_8601): New name for
	Parse_ISO_8861_UTC.  8601 is the correct ISO standard number.
	Also, "UTC" was confusing. All Time values are represented in
	UTC, but the ISO 8601 date strings include a time zone.

	If a time zone was specified, call
	Ada.Calendar.Formatting.Time_Of instead of
	GNAT.Calendar.Time_Of, because the latter adjusts to the current
	time zone, whereas we want to use (just) the time zone specified
	in the ISO string.  This allows us to pass Time_Zone instead to
	Time_Of, instead of adjusting by Local_Disp by hand.

	If no time zone was specified, call GNAT.Calendar.Time_Of as
	before.

	Use expanded names to clarify which Time_Of is being called.
	Remove redundant comment, and move nonredundant part of the
	commment to the spec.
	(Value): Minor: use "not in" instead of "or else".
	* libgnat/g-catiio.ads: Comment moved here. Correct the ISO
	standard number.
	* libgnat/g-calend.adb: Add ??? comments.
	* libgnat/a-calend.ads, libgnat/a-calend.adb: Update obsolete
	comments regarding the representation of type Time. Move the
	information about the epoch (year 2150) to the spec, and avoid
	uttering "2150" more than once.
	* libgnat/a-catizo.ads (Time_Offset): Add comment.
2020-07-06 07:35:17 -04:00
Ed Schonberg
e3bf5e2ef3 [Ada] Crash on derived type with rep. clause and renamed discriminant
gcc/ada/

	* exp_ch5.adb (Find_Component): If the target type is a derived
	record type and the required component is a discriminant that is
	renamed in the derived type declaration, use the name of the
	original discriminant to locate the intended target component.
2020-07-06 07:35:12 -04:00
Justin Squirek
ce16f54f6e [Ada] Hang on generic declaration with ambiguous formal package
gcc/ada/

	* sem_ch12.adb (Analyze_Associations): Add check for errors on
	the generic formal before continuing with instantiation.
2020-07-06 07:35:10 -04:00
Arnaud Charlet
90d8163d9b [Ada] AI12-0366 Changes to Big_Integer and Big_Real
gcc/ada/

	* libgnat/a-nbnbin.ads, libgnat/a-nbnbin.adb,
	libgnat/a-nbnbin__gmp.adb: Use more Valid_Big_Integer.
2020-07-06 07:35:09 -04:00
Piotr Trojanek
cf7cdde51a [Ada] Fix typo in comment of Get_Index_Subtype
gcc/ada/

	* exp_util.ads (Get_Index_Subtype): Fix duplicate "Last".
2020-07-06 07:35:08 -04:00
Ed Schonberg
befc919fde [Ada] There is no Expressions field in N_Delta_Aggregate node
gcc/ada/

	* sinfo.ads: Indicate that Field 1 of an N_Delta_Aggregate is
	unused. Previously it was erroneously labelled as holding an
	Expressions list, in analogy with other aggregate constructs,
	but there are no Expressions attached to this node syntactically
	or semantically.
2020-07-06 07:35:07 -04:00
Piotr Trojanek
f0e6256fd3 [Ada] Fix evaluation of Enum_Rep applied to imported constant
gcc/ada/

	* sem_attr.adb (Eval_Attribute): Check if constant has an
	initialization expression.
2020-07-06 07:35:06 -04:00
Piotr Trojanek
8f892a98cc [Ada] Set range checks flag on 'Update for GNATprove in expansion
gcc/ada/

	* exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Apply
	scalar range checks.
	* sem_attr.adb (Resolve_Attribute): Do not set scalar range
	checks when resolving attribute Update.
2020-07-06 07:35:05 -04:00
Gary Dismukes
977b168196 [Ada] Predicates and the current instance of a subtype (AI12-0068)
gcc/ada/

	* sem_attr.adb (Analyze_Attribute, Attribute_Constrained): Issue
	a warning if the attribute prefix is a current instance
	reference within an aspect of a type or subtype.
	(Address_Checks): Replace test of Is_Object (Ent) with
	Is_Object_Reference (P) so that testing for current instances
	will be done.
	(Eval_Attribute): Add test for current instance reference, to
	ensure that we still fold array attributes when current
	instances are involved, since value prefixes are allowed for
	array attributes, and will now be excluded by
	Is_Object_Reference.
	* sem_util.ads (Is_Current_Instance_Reference_In_Type_Aspect):
	New exported query function.
	* sem_util.adb (Is_Object_Reference): Return False for the case
	where N is a current instance reference within an
	aspect_specification of a type or subtype (basically if the
	reference occurs within a predicate, invariant, or DIC aspect
	expression).
	(Is_Current_Instance_Reference_In_Type_Aspect): New function
	that tests whether a node is a reference to a current instance
	formal of a predicate, invariant, or
	Default_Initial_Condition (DIC) subprogram.
2020-07-06 07:35:04 -04:00
Ed Schonberg
07ac6d8aad [Ada] Visibility error with aggregate in Declare_Expression
gcc/ada/

	* sem_res.adb (Resolve_Declare_Expression): New subprogram, to
	install the scope holding local declarations of the expression,
	before completing its resolution.
	(Resolve): For an Expression_With_Actions that comes from a
	source occurrence of a Declare_Expression, call new subprogram.
2020-07-06 07:35:03 -04:00
Piotr Trojanek
114efadf43 [Ada] Simplify implicit loading of Tasking_State in GNATprove_Mode
gcc/ada/

	* sem_attr.adb (Analyze_Attribute): Reuse SPARK_Implicit_Load.
2020-07-06 07:35:01 -04:00
Piotr Trojanek
a34da56b26 [Ada] Crash when an exception handler is executed with -gnatdk
gcc/ada/

	* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Propagate
	exception when switch -gnatdk is used and no previous errors are
	present.
	* sem_eval.adb (Compile_Time_Known_Value, Is_In_Range):
	Likewise.
	* sem_warn.adb (Operand_Has_Warnings_Suppressed): Likewise.
2020-07-06 07:35:00 -04:00
Richard Kenner
3e6bb105d3 [Ada] Refine use of access types in unnesting
gcc/ada/

	* exp_unst.adb (Needs_Fat_Pointer): Don't check for formal.
	(Unnest_Subprogram): Use 'Unchecked_Access instead of 'Access
	when populating activation record.
2020-07-06 07:34:59 -04:00
Eric Botcazou
f5b65fab88 [Ada] Fix bad interaction between Unchecked_Conversion and limited type
gcc/ada/

	* exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Rename parameter
	from Bit_Packed_Array to Force.
	(Expand_Actuals): Do not apply BIP processing if the subprogram
	is intrinsic.  Adjust calls to Add_Simple_Call_By_Copy_Code and
	add one for In parameters whose actual is a CPP constructor call.
2020-07-06 07:34:58 -04:00
Eric Botcazou
c54077e453 [Ada] Remove obsolete code in Eval_Attribute
gcc/ada/

	* sem_attr.adb (Eval_Attribute): Do not apply range checks in
	the case of 'Pos applied to an integer type here.
2020-07-06 07:34:57 -04:00
Ed Schonberg
776afaf7fe [Ada] Crash on declaration with aggregate for unchecked union
gcc/ada/

	* sem_ch3.adb (Analyze_Object_Declaration): If the type is an
	Unchecked_Union, and the expression is an aggregate. complete
	the analysis and resolution of the aggregate, and treat like a
	regular object declaration, instead of as a renaming
	declarattion.
2020-07-06 07:34:56 -04:00
Eric Botcazou
e2d87663af [Ada] Small cleanup throughout Exp_Ch9
gcc/ada/

	* exp_ch9.adb (Is_Potentially_Large_Family): Add documentation.
	(Actual_Index_Expression): Use Entry_Index_Type.
	(Build_Entry_Count_Expression): Likewise.
	(Build_Find_Body_Index): Likewise.
	(Collect_Entry_Families): Likewise. Use directly the bounds of
	the index type to find out whether the family is large.
	(Entry_Index_Expression): Likewise.
2020-07-06 07:34:55 -04:00
Piotr Trojanek
eddd728f5f [Ada] Remove special case for processing null range in GNATprove
gcc/ada/

	* sem_res.adb (Resolve_Range): Resolve both low and high bounds
	with the range type.
2020-07-06 07:34:54 -04:00
Arnaud Charlet
f0c6bd6039 [Ada] AI12-0376 Relax RM 13.1(10) rule wrt primitive operations
gcc/ada/

	* aspects.ads (Is_Representation_Aspect):
	Default_Component_Value is a representation aspect.
	* sem_ch13.adb (Check_Aspect_Too_Late, Rep_Item_Too_Late): Relax
	RM 13.1(10) rule wrt primitive operations for Ada 202x.
2020-07-06 07:34:53 -04:00
Eric Botcazou
2fedcc18cb [Ada] Improve run-time performance for large initialized allocators
gcc/ada/

	* exp_aggr.adb (Aggr_Assignment_OK_For_Backend): Move to library
	level and use a new predicate Is_OK_Aggregate to recognize the
	aggregates suitable for direct assignment by the back-end.
	(Convert_Array_Aggr_In_Allocator): If neither in CodePeer mode nor
	generating C code, generate a direct assignment instead of further
	expanding if Aggr_Assignment_OK_For_Backend returns true.
2020-07-06 07:34:52 -04:00
Gary Dismukes
60e010e7f3 [Ada] Wording problems with predicates (AI12-0099)
gcc/ada/

	* sem_aux.adb: Add a with clause for Nlists.
	(Nearest_Ancestor): Test for the case of concurrent
	types (testing for both Is_Concurrent_Type and
	Is_Concurrent_Record_Type), and return the first ancestor in the
	Interfaces list if present (otherwise will return Empty if no
	interfaces).
	* sem_ch13.adb (Build_Predicate_Functions): Add a ??? comment
	about missing handling for adding predicates when they can be
	inherited from multiple progenitors.
2020-07-06 07:34:51 -04:00
Arnaud Charlet
37e43fe13e [Ada] Default_Initial_Condition check done after extended return with init
gcc/ada/

	* par-ch6.adb (P_Return_Object_Declaration): Set
	Has_Init_Expression flag.
2020-07-06 07:34:50 -04:00
Roger Sayle
e6f323372e nvptx: Add support for vadd.add and vsub.add instructions.
The following patch adds support for three-input addition instructions to
the nvptx backend.  The PTX ISA's "vadd.u32.u32.u32.add d, a, b, c"
instruction effectively implements 32-bit d = a+b+c, and the
"vsub.u32.u32.u32 d,a,b,c" instruction that provides 32-bit d = (a-b)+c.
The hope is that these mnemonics help ptxas generate the low-level
hardware's IADD3 instruction.

2020-07-06  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog:
	* config/nvptx/nvptx.md (*vadd_addsi4): New instruction.
	(*vsub_addsi4): New instruction.

gcc/testsuite/ChangeLog:
	* gcc.target/nvptx/vadd_add.c: New test.
	* gcc.target/nvptx/vsub_add.c: New test.
2020-07-06 07:46:52 +01:00
Hans-Peter Nilsson
cf2bfc7c80 cris: New peephole2 movulsr + test-case.
Combine likes to change a zero-extension / and + shift as seen
in the test-case source to a logical shift followed by an and of
the shifted mask, like:
 lsrq 1,r0
 and.d 0x7f,r0

This was observed in the hot loop of coremark crcu16 and crcu32,
when doing other changes affecting instruction selection.  While
fixable by other means (like instruction costs or combine
patches), I wanted to break this out from those "other means".
The similarity to extant peephole optimizations is not
deliberate.

I noticed some paths to other peephole2 test-cases have changed
due to moves and renaming, so I updated them.

gcc:
	* config/cris/cris.md (movulsr): New peephole2.

gcc/testsuite:
	* gcc.target/cris/peep2-movulsr.c: New test.
2020-07-06 02:38:53 +02:00
Hans-Peter Nilsson
1e98f06028 cris: Correct gcc_assert for atomic_fetch_op pattern
Yet another misnumbering of operands: the asserted non-overlap
would be the only benign operands overlap.  "Suddenly" exposed
by g++.dg/cpp0x/pr81325.C when testing unrelated changes
affecting register allocation.

To wit, operands 2 and 1 are the only ones that are safe for
overlap, it's only that it doesn't seem to make much sense to
write the address of the atomic data as the atomic data.

gcc:
	* config/cris/sync.md ("cris_atomic_fetch_<atomic_op_name><mode>_1"):
	Correct gcc_assert of overlapping operands.
2020-07-06 02:35:54 +02:00
GCC Administrator
df66f280ec Daily bump. 2020-07-06 00:16:29 +00:00
Hans-Peter Nilsson
9596eccb9c cris: update recent patterns. Simplify cris_select_cc_mode.
The code in cris_select_cc_mode for selecting CC_NZmode was
partly inconsistent with the comment and partly seemed
ambiguous.  I couldn't find a reason why I qualified selection
of CC_NZmode on the setting operation once a matching user was
spotted, so I just removed that.  The cris.c update was due to
observing the new test-case failing; the CC_NZmode compare
wasn't eliminated.

The recently re-instated adds/addu/subs/subu/bound patterns are
rewritten to replace the use of match_operator with iterators.

gcc:
	* config/cris/cris.c (cris_select_cc_mode): Always return
	CC_NZmode for matching comparisons.  Clarify comments.
	* config/cris/cris-modes.def: Clarify mode comment.
	* config/cris/cris.md (plusminus, plusminusumin, plusumin): New
	code iterators.
	(addsub, addsubbo, nd): New code iterator attributes.
	("*<addsub><su>qihi"): Rename from "*extopqihi".  Use code
	iterator constructs instead of match_operator constructs.
	("*<addsubbo><su><nd><mode>si<setnz>"): Similar from
	"*extop<mode>si<setnz>".
	("*add<su>qihi_swap"): Similar from "*addxqihi_swap".
	("*<addsubbo><su><nd><mode>si<setnz>_swap"): Similar from
	"*extop<mode>si<setnz>_swap".

gcc/testsuite:
	* gcc.target/cris/pr93372-39.c: New test.
2020-07-06 01:17:54 +02:00
Hans-Peter Nilsson
65f8403f1a cris.md: Reinstate add/sub with extend
When cleaning out the multitude of patterns with unknown
coverage, this one went the way of the bathwater.  It's use is
barely common enough to mark when diffing libgcc, and has a
minimal impact on performance-testsuites.  Anyway, reinstated
with a couple of test-cases.  It's suboptimal of gcc-core not to
make use of the SImode pattern when performing HImode; see the
FIXME (which is actually also reinstated).

This version uses match_operator, for continuity but will be
replaced with a version making use of iterators (like it does
for the mode).

gcc:
	* config/cris/cris.md ("*extopqihi", "*extop<mode>si<setnz>_swap")
	("*extop<mode>si<setnz>", "*addxqihi_swap"): Reinstate.

gcc/testsuite:
	* gcc.target/cris/pr93372-36.c, gcc.target/cris/pr93372-37.c,
	gcc.target/cris/pr93372-38.c: New tests.
2020-07-06 01:17:25 +02:00
Thomas Koenig
cc9a922928 Test global identifiers against what is specified interfaces.
Apart from calling gfc_compare_interfaces to check interfaces against
global identifiers, this also sets and check a few sym->error flags
to avoid duplicate error messages.  I thought about issuing errors
on mismatched interfaces, but when the procedure is not invoked,
a warning should be enough to alert the user.

gcc/fortran/ChangeLog:

	PR fortran/27318
	* frontend-passes.c (check_against_globals): New function.
	(gfc_check_externals): Split; also invoke check_against_globals
	via gfc_traverse_ns.
	(gfc_check_externals0): Recursive part formerly in
	gfc_check_externals.
	* resolve.c (resolve_global_procedure): Set sym->error on
	interface mismatch.
	* symbol.c (ambiguous_symbol): Check for, and set sym->error.

gcc/testsuite/ChangeLog:

	PR fortran/27318
	* gfortran.dg/error_recovery_1.f90: Adjust test case.
	* gfortran.dg/use_15.f90: Likewise.
	* gfortran.dg/interface_47.f90: New test.
2020-07-05 20:13:41 +02:00
GCC Administrator
706e6f613d Daily bump. 2020-07-05 00:16:21 +00:00
Iain Sandoe
98fcd2513a coroutines, testsuite: Rename a test, NFC.
The test was committed with a placeholder name, this
renames it as described in the PR.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr9xxxx-mismatched-traits-and-promise-prev.C: Moved to...
	* g++.dg/coroutines/pr94760-mismatched-traits-and-promise-prev.C: ...here.
2020-07-04 19:01:03 +01:00
GCC Administrator
b991c83463 Daily bump. 2020-07-04 00:16:26 +00:00
Eric Botcazou
e362a89765 Extend store merging to STRING_CST
The GIMPLE store merging pass doesn't merge STRING_CSTs in the general
case, although they are accepted by native_encode_expr; the reason is
that the pass only works with integral modes, i.e. with chunks whose
size is a power of two.

There are two possible ways of extending it to handle STRING_CSTs:
1) lift the condition of integral modes and treat STRING_CSTs as
other _CST nodes but with arbitrary size; 2) implement a specific
and separate handling for STRING_CSTs.

The attached patch implements 2) for the following reasons: on the
one hand, even in Ada where character strings are first-class citizens,
cases where merging STRING_CSTs with other *_CST nodes would be possible
are quite rare in practice; on the other hand, string concatenations
happen more naturally and frequently thanks to the "&" operator, giving
rise to merging opportunities.

gcc/ChangeLog:
	* gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that
	were initially created for the assignment of a variable-sized
	object and whose source is now a string constant.
	* gimple-ssa-store-merging.c (struct merged_store_group): Document
	STRING_CST for rhs_code field.
	Add string_concatenation boolean field.
	(merged_store_group::merged_store_group): Initialize it as well as
	bit_insertion here.
	(merged_store_group::do_merge): Set it upon seeing a STRING_CST.
	Also set bit_insertion here upon seeing a BIT_INSERT_EXPR.
	(merged_store_group::apply_stores): Clear it for small regions.
	Do not create a power-of-2-sized buffer if it is still true.
	And do not set bit_insertion here again.
	(encode_tree_to_bitpos): Deal with BLKmode for the expression.
	(merged_store_group::can_be_merged_into): Deal with STRING_CST.
	(imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion
	to true after changing MEM_REF stores into BIT_INSERT_EXPR stores.
	(count_multiple_uses): Return 0 for STRING_CST.
	(split_group): Do not split the group for a string concatenation.
	(imm_store_chain_info::output_merged_store): Constify and rename
	some local variables.  Build an array type as destination type
	for a string concatenation, as well as a zero mask, and call
	build_string to build the source.
	(lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR.
	(pass_store_merging::process_store): Accept STRING_CST on the RHS.
	* gimple.h (gimple_call_alloca_for_var_p): New accessor function.
	* gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var.
	* tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY.

gcc/testsuite/ChangeLog:
	* gnat.dg/opt87.adb: New test.
	* gnat.dg/opt87_pkg.ads: New helper.
	* gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:31:04 +02:00
Martin Jambor
b9a15a8325 ipa-sra: Avoid transitive splits with type mismatches (PR 96040)
PR 96040 revealed IPA-SRA, when checking whether an intended split is
the same as the one in a called function does not also check if the
types match and the transformation code does not handle any resulting
type mismatches.  This patch simply avoids the the split in the case
of mismatches, so that we do not have to be careful about invalid
floating-point values being passed in floating point registers and
related issues.

gcc/ChangeLog:

2020-07-03  Martin Jambor  <mjambor@suse.cz>

	PR ipa/96040
	* ipa-sra.c (all_callee_accesses_present_p): Do not accept type
	mismatched accesses.

gcc/testsuite/ChangeLog:

2020-07-03  Martin Jambor  <mjambor@suse.cz>

	PR ipa/96040
	* gcc.dg/ipa/pr96040.c: New test.
2020-07-03 17:37:33 +02:00
Thomas Schwinge
e7f3f7fe08 [OpenACC] Revert always-copyfrom behavior for 'GOMP_MAP_FORCE_FROM' in 'libgomp/oacc-mem.c:goacc_exit_data_internal'
As done for 'GOMP_MAP_FROM', also for 'GOMP_MAP_FORCE_FROM' we should only
'gomp_copy_dev2host' if 'n->refcount == 0'.

This had gotten altered in commit 378da98fcc
(r279621) "OpenACC reference count overhaul".

	libgomp/
	* oacc-mem.c (goacc_exit_data_internal): Revert always-copyfrom
	behavior for 'GOMP_MAP_FORCE_FROM'.
	* testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: Adjust XFAIL.
2020-07-03 17:14:40 +02:00
Thomas Schwinge
995aba5867 [OpenACC] Remove (unused) 'GOMP_MAP_ALWAYS_FROM' handling from 'libgomp/oacc-mem.c:goacc_exit_data_internal'
This had gotten added in commit 378da98fcc
(r279621) "OpenACC reference count overhaul", but it doesn't have any use in
OpenACC.

	libgomp/
	* oacc-mem.c (goacc_exit_data_internal): Remove
	'GOMP_MAP_ALWAYS_FROM' handling.
2020-07-03 17:14:21 +02:00
Roger Sayle
ce0f842492 [PATCH] nvptx: Add support for popcount and widening multiply instructions
2020-07-01  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog:
	* config/nvptx/nvptx.md (popcount<mode>2): New instructions.
	(mulhishi3, mulsidi3, umulhisi3, umulsidi3): New instructions.

gcc/testsuite/ChangeLog:
	* gcc.target/nvptx/popc-1.c: New test.
	* gcc.target/nvptx/popc-2.c: New test.
	* gcc.target/nvptx/popc-3.c: New test.
	* gcc.target/nvptx/mul-wide.c: New test.
	* gcc.target/nvptx/umul-wide.c: New test.
2020-07-03 12:56:29 +01:00