Commit Graph

182984 Commits

Author SHA1 Message Date
GCC Administrator
ef1f8ee67d Daily bump. 2021-01-19 00:16:35 +00:00
Jeff Law
9a3ab93ceb [committed] Minor fix to pr41445-7 testcase
gcc/testsuite
	* gcc.dg/debug/dwarf2/pr41445-7.c: Fix expected output.
2021-01-18 16:05:06 -07:00
Ian Lance Taylor
bfde774667 libbacktrace: don't fail tests if dwz fails
* Makefile.am (%_dwz): If dwz fails, use uncompressed debug info.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2021-01-18 14:45:57 -08:00
Ian Lance Taylor
325e70b47c libbacktrace: use correct directory/filename for DWARF 5
PR debug/98716
	* dwarf.c (read_v2_paths): Allocate zero entry for dirs and
	filenames.
	(read_line_program): Remove parameter u, change caller.  Don't
	subtract one from dirs and filenames index.
	(read_function_entry): Don't subtract one from filenames index.
2021-01-18 14:43:00 -08:00
Vladimir N. Makarov
a89c5d3539 [PR97847] IRA: Skip abnormal critical edge splitting
PPC64 can generate jumps with clobbered pseudo-regs and a BB with
such jump can have abnormal output edges.  IRA hits an assert when trying
to split abnormal critical edge to deal with asm goto output reloads
later.  The patch just skips splitting abnormal edges.  It is assumed
that asm-goto with output reloads can not be in BB with output abnormal edges.

gcc/ChangeLog:

	PR target/97847
	* ira.c (ira): Skip abnormal critical edge splitting.
2021-01-18 16:47:15 -05:00
Patrick Palka
32b6e917ac c++: Add CTAD + pack expansion testcase
After r11-6614 made cp_walk_subtrees walk into the template of a CTAD
placeholder, we now correctly accept the below testcase.  We used to
reject it because find_parameter_packs_r would fail to find the
parameter pack Ts inside the CTAD placeholder within the pack expansion.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction77.C: New test.
2021-01-18 16:41:46 -05:00
Jakub Jelinek
9675ccd64e widening_mul: Fix up signed multiplication overflow check handling [PR98727]
I forgot one line, which means that if the second operand of the multiplication
isn't constant, it would be just the same as the first one.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98727
	* tree-ssa-math-opts.c (match_arith_overflow): Fix up computation of
	second .MUL_OVERFLOW operand for signed multiplication with overflow
	checking if the second operand of multiplication is not constant.

	* gcc.c-torture/execute/pr98727.c: New test.
2021-01-18 19:13:44 +01:00
David Edelsohn
f56e14101b aix: document dwarf 4 default (and TPF default)
gcc/ChangeLog:

	* doc/invoke.texi (-gdwarf): TPF defaults to version 2 and AIX
	defaults to version 4.
2021-01-18 13:12:17 -05:00
John David Anglin
76c1dd15e4 Skip asm goto tests on hppa*-*-*.
gcc/testsuite/ChangeLog:

	PR testsuite/97987
	* gcc.c-torture/compile/asmgoto-2.c: Skip on hppa.
	* gcc.c-torture/compile/asmgoto-5.c: Likewise.
2021-01-18 15:45:47 +00:00
John David Anglin
66cbe54960 Avoid no-stack-protector-attr fails on hppa*-*-*.
gcc/testsuite/ChangeLog:

	* g++.dg/no-stack-protector-attr-3.C: Don't compile on hppa*-*-*.
	* g++.dg/no-stack-protector-attr.C: Likewise.
2021-01-18 15:38:40 +00:00
David Malcolm
c7e276b869 analyzer: use "malloc" attribute
In dce6c58db8 msebor extended the
"malloc" attribute to support user-defined allocator/deallocator
pairs.

This patch extends the "malloc" checker within -fanalyzer to use
these attributes.  It is based on an earlier patch:
  'RFC: add "deallocated_by" attribute for use by analyzer'
    https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555544.html
which added a different attribute.  The patch needed a lot of reworking
to support multiple deallocators per allocator.

My hope was that this would provide a minimal level of markup that would
support library-checking without requiring lots of further markup.
I attempted to use this to detect a memory leak within a Linux
driver (CVE-2019-19078), by adding the attribute to mark these fns:
extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
extern void usb_free_urb(struct urb *urb);
where there is a leak of a "urb" on an error-handling path.
Unfortunately I ran into the problem that there are various other fns
that take "struct urb *" and the analyzer conservatively assumes that a
urb passed to them might or might not be freed and thus stops tracking
state for them.

Hence this will only detect issues for the simplest cases (without
adding another attribute).

gcc/analyzer/ChangeLog:
	* analyzer.h (is_std_named_call_p): New decl.
	* diagnostic-manager.cc (path_builder::get_sm): New.
	(state_change_event_creator::state_change_event_creator): Add "pb"
	param.
	(state_change_event_creator::on_global_state_change): Don't consider
	state changes affecting other state_machines.
	(state_change_event_creator::on_state_change): Likewise.
	(state_change_event_creator::m_pb): New field.
	(diagnostic_manager::add_events_for_eedge): Pass pb to visitor
	ctor.
	* region-model-impl-calls.cc
	(region_model::impl_deallocation_call): New.
	* region-model.cc: Include "attribs.h".
	(region_model::on_call_post): Handle fndecls referenced by
	__attribute__((deallocated_by(FOO))).
	* region-model.h (region_model::impl_deallocation_call): New decl.
	* sm-malloc.cc: Include "stringpool.h" and "attribs.h".  Add
	leading comment.
	(class api): Delete.
	(enum resource_state): Update comment for change from api to
	deallocator and deallocator_set.
	(allocation_state::allocation_state): Drop api param.  Add
	"deallocators" and "deallocator".
	(allocation_state::m_api): Drop field in favor of...
	(allocation_state::m_deallocators): New field.
	(allocation_state::m_deallocator): New field.
	(enum wording): Add WORDING_DEALLOCATED.
	(struct deallocator): New.
	(struct standard_deallocator): New.
	(struct custom_deallocator): New.
	(struct deallocator_set): New.
	(struct custom_deallocator_set): New.
	(struct standard_deallocator_set): New.
	(struct deallocator_set_map_traits): New.
	(malloc_state_machine::m_malloc): Drop field
	(malloc_state_machine::m_scalar_new): Likewise.
	(malloc_state_machine::m_vector_new): Likewise.
	(malloc_state_machine::m_free): New field
	(malloc_state_machine::m_scalar_delete): Likewise.
	(malloc_state_machine::m_vector_delete): Likewise.
	(malloc_state_machine::deallocator_map_t): New typedef.
	(malloc_state_machine::m_deallocator_map): New field.
	(malloc_state_machine::deallocator_set_cache_t): New typedef.
	(malloc_state_machine::m_custom_deallocator_set_cache): New field.
	(malloc_state_machine::custom_deallocator_set_map_t): New typedef.
	(malloc_state_machine::m_custom_deallocator_set_map): New field.
	(malloc_state_machine::m_dynamic_sets): New field.
	(malloc_state_machine::m_dynamic_deallocators): New field.
	(api::api): Delete.
	(deallocator::deallocator): New ctor.
	(deallocator::hash): New.
	(deallocator::dump_to_pp): New.
	(deallocator::cmp): New.
	(deallocator::cmp_ptr_ptr): New.
	(standard_deallocator::standard_deallocator): New ctor.
	(deallocator_set::deallocator_set): New ctor.
	(deallocator_set::dump): New.
	(custom_deallocator_set::custom_deallocator_set): New ctor.
	(custom_deallocator_set::contains_p): New.
	(custom_deallocator_set::maybe_get_single): New.
	(custom_deallocator_set::dump_to_pp): New.
	(standard_deallocator_set::standard_deallocator_set): New ctor.
	(standard_deallocator_set::contains_p): New.
	(standard_deallocator_set::maybe_get_single): New.
	(standard_deallocator_set::dump_to_pp): New.
	(start_p): New.
	(class mismatching_deallocation): Update for conversion from api
	to deallocator_set and deallocator.
	(double_free::emit): Use %qs.
	(class use_after_free): Update for conversion from api to
	deallocator_set and deallocator.
	(malloc_leak::describe_state_change): Only emit "allocated here" on
	a start->nonnull transition, rather than on other transitions to
	nonnull.
	(allocation_state::dump_to_pp): Update for conversion from api to
	deallocator_set.
	(allocation_state::get_nonnull): Likewise.
	(malloc_state_machine::malloc_state_machine): Likewise.
	(malloc_state_machine::~malloc_state_machine): New.
	(malloc_state_machine::add_state): Update for conversion from api
	to deallocator_set.
	(malloc_state_machine::get_or_create_custom_deallocator_set): New.
	(malloc_state_machine::maybe_create_custom_deallocator_set): New.
	(malloc_state_machine::get_or_create_deallocator): New.
	(malloc_state_machine::on_stmt): Update for conversion from api
	to deallocator_set.  Handle "__attribute__((malloc(FOO)))", and
	the special attribute set on FOO.
	(malloc_state_machine::on_allocator_call): Update for conversion
	from api to deallocator_set.  Add "returns_nonnull" param and use
	it to affect which state to transition to.
	(malloc_state_machine::on_deallocator_call): Update for conversion
	from api to deallocator_set.

gcc/ChangeLog:
	* attribs.h (fndecl_dealloc_argno): New decl.
	* builtins.c (call_dealloc_argno): Split out second half of
	function into...
	(fndecl_dealloc_argno): New.
	* doc/extend.texi (Common Function Attributes): Document the
	interaction between the analyzer and the malloc attribute.
	* doc/invoke.texi (Static Analyzer Options): Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/attr-malloc-1.c: New test.
	* gcc.dg/analyzer/attr-malloc-2.c: New test.
	* gcc.dg/analyzer/attr-malloc-4.c: New test.
	* gcc.dg/analyzer/attr-malloc-5.c: New test.
	* gcc.dg/analyzer/attr-malloc-6.c: New test.
	* gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c: New test.
	* gcc.dg/analyzer/attr-malloc-misuses.c: New test.
2021-01-18 09:24:46 -05:00
Jonathan Wakely
ec153f96f8 libstdc++: Only test writing to wostream if supported [PR 98725]
libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* testsuite/20_util/unique_ptr/io/lwg2948.cc:  Do not try to
	write to a wide character stream if wide character support is
	disabled in the library.
2021-01-18 14:23:13 +00:00
Richard Biener
e393f03b1a testsuite/97494 - adjust gcc.dg/vect/slp-11b.c
Support for loop SLP splitting exposed that slp-11b.c has
folding that breaks SLP discovery which isn't what was intended
when the testcase was written.  The following makes it SLP-able
and "only" run into the issue that a load permutation is required.

And tries to adjust the target selectors accordingly.

2021-01-18  Richard Biener  <rguenther@suse.de>

	PR testsuite/97494
	* gcc.dg/vect/slp-11b.c: Adjust.
2021-01-18 15:20:31 +01:00
Andreas Schwab
b8c3f5196e libgomp: enable linux-futex on riscv64
Regtested on riscv64-suse-linux.

libgomp/
	* configure.tgt (riscv64*-*-linux*): Add linux to config_path.
2021-01-18 15:13:48 +01:00
Christophe Lyon
acdc49fabf [arm,testsuite]: Fix options for vceqz_p64.c and vceqzq_p64.c
These two tests need:
dg-require-effective-target arm_crypto_ok
dg-add-options arm_crypto
because they use intrinsics that need -mfpu=crypto-neon-fp-armv8.

2021-01-18  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/testsuite/
	PR target/71233
	* gcc.target/arm/simd/vceqz_p64.c: Use arm_crypto options.
	* gcc.target/arm/simd/vceqzq_p64.c: Likewise.
2021-01-18 13:59:54 +00:00
Richard Biener
104304cd24 testsuite/97299 - fix test condition of gcc.dg/vect/slp-reduc-3.c
This avoids looking for permute optimization when SLP cannot be applied.

2021-01-18  Richard Biener  <rguenther@suse.de>

	PR testsuite/97299
	* gcc.dg/vect/slp-reduc-3.c: Guard VEC_PERM_EXPR scan.
2021-01-18 14:52:12 +01:00
Jonathan Wakely
a81d2f1e41 libstdc++: Fix narrow char test to use stringbuf not wstringbuf
This seems to be a copy & paste error.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_stringstream/cons/char/1.cc: Use
	stringbuf not wstringbuf.
2021-01-18 12:45:10 +00:00
Jakub Jelinek
2e43880dbd libstd++: : Add workaround for as Error: file number less than one error [PR98708]
As mentioned in the PR, since the switch to DWARF5 by default instead of
DWARF4, gcc fails to build when configured against recent binutils.

The problem is that cxx11-ios_failure* is built in separate steps,
-S compilation (with -g -O2) followed by some sed and followed by
-c -g -O2 -g0 assembly.  When gcc is configured against recent binutils
and DWARF5 is the default, we emit .file 0 "..." directive on which the
assembler then fails (unless --gdwarf-5 is passed to it, but we don't want
that generally because on the other side older assemblers don't like -g*
passed to it when invoked on *.s file with compiler generated debug info.

I hope the bug will be fixed soon on the binutils side, but it would be nice
to have a workaround.

The following patch is one of the possibilities, another one is to do that
but add configure check for whether it is needed,
essentially
echo 'int main () { return 0; }' > conftest.c
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -g0 -c conftest.s -o conftest.o
and if the last command fails, we need that -gno-as-loc-support.
Or yet another option would be I think do a different check, whether
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -c conftest.s -o conftest.o
works and if yes, don't add the -g0 to cxx11-ios_failure*.s assembly.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98708
	* src/c++11/Makefile.am (cxx11-ios_failure-lt.s, cxx11-ios_failure.s):
	Compile with -gno-as-loc-support.
	* src/c++11/Makefile.in: Regenerated.
2021-01-18 11:29:26 +01:00
Sebastian Huber
0f951b3dd3 RTEMS: Fix libgomp build
libgomp/

	* config/rtems/sem.h (gomp_sem_getcount): New function.
2021-01-18 07:24:56 +01:00
Jakub Jelinek
d3b41bde96 libgomp: Don't access gomp_sem_t as int using atomics unconditionally
This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel.  rtems for now
remains broken.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	* config/linux/sem.h (gomp_sem_getcount): New function.
	* config/posix/sem.h (gomp_sem_getcount): New function.
	* config/posix/sem.c (gomp_sem_getcount): New function.
	* config/accel/sem.h (gomp_sem_getcount): New function.
	* task.c (task_fulfilled_p): Use gomp_sem_getcount.
	(omp_fulfill_event): Likewise.
2021-01-18 07:18:46 +01:00
David Edelsohn
994fb69ac1 testsuite: powerpc fold-vec and sse updates.
Recent code generation changes have affected the count of some instructions.
This patch updates the instruction count for fold-vec-extract on P7 and P8.

Also, some of SSE emulation intrinsics only work on LE systems.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/fold-vec-extract-char.p7.c: Adjust addi count.
	* gcc.target/powerpc/fold-vec-extract-double.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-float.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-float.p8.c: Same.
	* gcc.target/powerpc/fold-vec-extract-int.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-int.p8.c: Same.
	* gcc.target/powerpc/fold-vec-extract-short.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-short.p8.c: Same.
	* gcc.target/powerpc/sse-andnps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse-movhps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse-movlps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse2-andnpd-1.c: Restrict to LE.
2021-01-17 23:59:26 -05:00
Jerry DeLisle
4905f40401 Fix ChangeLog entries. 2021-01-17 18:27:02 -08:00
GCC Administrator
4c9bcd5c81 Daily bump. 2021-01-18 00:16:27 +00:00
David Edelsohn
b654d23a47 testsuite: Skip DWARF 5 testcases on AIX.
AIX does not support DWARF 5.

This patch skips the DWARF 5-specific testcases.

gcc/testsuite/ChangeLog:

	* g++.dg/debug/dwarf2/inline-ns-2.C: Skip on AIX.
	* g++.dg/debug/dwarf2/inline-var-2.C: Skip on AIX.
	* g++.dg/debug/dwarf2/inline-var-3.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp11.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp14.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp17.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp20.C: Skip on AIX.
	* gcc.dg/debug/dwarf2/inline6.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/lang-c11.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/pr41445-7.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/pr41445-8.c: Skip on AIX.
2021-01-17 18:27:35 -05:00
David Edelsohn
56b5d13e27 aix: default to DWARF 4.
GCC now defaults to DWARF 5.  AIX only supports DWARF 4 (3.5).

This patch overrides the default DWARF version to 4 unless explicitly
stated.

gcc/ChangeLog:

	* config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Override
	dwarf_version to 4.
	* config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Same.
2021-01-17 18:10:00 -05:00
Martin Sebor
192105b6a2 Avoid assuming SSA_NAME_IDENTIFIER is nonnull.
gcc/c-family/ChangeLog:

	* c-pretty-print.c (c_pretty_printer::primary_expression): Don't
	assume SSA_NAME_IDENTIFIER evaluates to nonzero.
2021-01-17 15:27:08 -07:00
Martin Jambor
0f4c8f517b ipa: Adjust cgraph verifier to materialization on demand (PR 98222)
after switching to materialization of clones on demand, the verifier
can happen to see edges leading to a clone of a materialized clone.
This means its clone_of is NULL and former_clone_of needs to be
checked in order to verify that the callee is a clone of the original
decl, which it did not do and reported edges to pointing to a wrong
place.

Fixed with the following patch, which has been pre-approved by Honza.
Bootstrapped and tested on x86_64-linux, pushed to master.

Martin

gcc/ChangeLog:

2021-01-15  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98222
	* cgraph.c (clone_of_p): Check also former_clone_of as we climb
	the clone tree.

gcc/testsuite/ChangeLog:

2021-01-15  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98222
	* gcc.dg/ipa/pr98222.c: New test.
2021-01-17 22:32:11 +01:00
Mark Wielaard
3804e937b0 Default to DWARF5
gcc/ChangeLog:

	* common.opt (gdwarf-): Init(5).
	* doc/invoke.texi (-gdwarf): Document default to 5.
2021-01-17 01:36:39 +01:00
GCC Administrator
59cf67d1cf Daily bump. 2021-01-17 00:16:23 +00:00
Jakub Jelinek
a2960a04d5 testsuite: Fix up a testcase to find the right ISO_Fortran_binding.h.
2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Include
	../../../libgfortran/ISO_Fortran_binding.h rather than
	ISO_Fortran_binding.h.
2021-01-16 22:52:43 +01:00
Kwok Cheung Yeung
a6d22fb21c openmp: Add support for the OpenMP 5.0 task detach clause
2021-01-16  Kwok Cheung Yeung  <kcy@codesourcery.com>

	gcc/
	* builtin-types.def
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
	to...
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
	...this.  Add extra argument.
	* gimplify.c (omp_default_clause): Ensure that event handle is
	firstprivate in a task region.
	(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DETACH.
	(gimplify_adjust_omp_clauses): Likewise.
	* omp-builtins.def (BUILT_IN_GOMP_TASK): Change function type to
	BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR.
	* omp-expand.c (expand_task_call): Add GOMP_TASK_FLAG_DETACH to flags
	if detach clause specified.  Add detach argument when generating
	call to	GOMP_task.
	* omp-low.c (scan_sharing_clauses): Setup data environment for detach
	clause.
	(finish_taskreg_scan): Move field for variable containing the event
	handle to the front of the struct.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DETACH.  Fix
	ordering.
	* tree-nested.c (convert_nonlocal_omp_clauses): Handle
	OMP_CLAUSE_DETACH clause.
	(convert_local_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_DETACH.
	* tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_DETACH.
	Fix ordering.
	(omp_clause_code_name): Add entry for OMP_CLAUSE_DETACH.  Fix
	ordering.
	(walk_tree_1): Handle OMP_CLAUSE_DETACH.

	gcc/c-family/
	* c-pragma.h (pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DETACH.
	Redefine PRAGMA_OACC_CLAUSE_DETACH.

	gcc/c/
	* c-parser.c (c_parser_omp_clause_detach): New.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause.
	(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
	* c-typeck.c (c_finish_omp_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH
	clause.  Prevent use of detach with mergeable and overriding the
	data sharing mode of the event handle.

	gcc/cp/
	* parser.c (cp_parser_omp_clause_detach): New.
	(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH.
	(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
	* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	Prevent use of detach with mergeable and overriding the	data sharing
	mode of the event handle.

	gcc/fortran/
	* dump-parse-tree.c (show_omp_clauses): Handle detach clause.
	* frontend-passes.c (gfc_code_walker): Walk detach expression.
	* gfortran.h (struct gfc_omp_clauses): Add detach field.
	(gfc_c_intptr_kind): New.
	* openmp.c (gfc_free_omp_clauses): Free detach clause.
	(gfc_match_omp_detach): New.
	(enum omp_mask1): Add OMP_CLAUSE_DETACH.
	(enum omp_mask2): Remove OMP_CLAUSE_DETACH.
	(gfc_match_omp_clauses): Handle OMP_CLAUSE_DETACH for OpenMP.
	(OMP_TASK_CLAUSES): Add OMP_CLAUSE_DETACH.
	(resolve_omp_clauses): Prevent use of detach with mergeable and
	overriding the data sharing mode of the event handle.
	* trans-openmp.c (gfc_trans_omp_clauses): Handle detach clause.
	* trans-types.c (gfc_c_intptr_kind): New.
	(gfc_init_kinds): Initialize gfc_c_intptr_kind.
	* types.def
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
	to...
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
	...this.  Add extra argument.

	gcc/testsuite/
	* c-c++-common/gomp/task-detach-1.c: New.
	* g++.dg/gomp/task-detach-1.C: New.
	* gcc.dg/gomp/task-detach-1.c: New.
	* gfortran.dg/gomp/task-detach-1.f90: New.

	include/
	* gomp-constants.h (GOMP_TASK_FLAG_DETACH): New.

	libgomp/
	* fortran.c (omp_fulfill_event_): New.
	* libgomp.h (struct gomp_task): Add detach and completion_sem fields.
	(struct gomp_team): Add task_detach_queue and task_detach_count
	fields.
	* libgomp.map (OMP_5.0.1): Add omp_fulfill_event and omp_fulfill_event_.
	* libgomp_g.h (GOMP_task): Add extra argument.
	* omp.h.in (enum omp_event_handle_t): New.
	(omp_fulfill_event): New.
	* omp_lib.f90.in (omp_event_handle_kind): New.
	(omp_fulfill_event): New.
	* omp_lib.h.in (omp_event_handle_kind): New.
	(omp_fulfill_event): Declare.
	* priority_queue.c (priority_tree_find): New.
	(priority_list_find): New.
	(priority_queue_find): New.
	* priority_queue.h (priority_queue_predicate): New.
	(priority_queue_find): New.
	* task.c (gomp_init_task): Initialize detach field.
	(task_fulfilled_p): New.
	(GOMP_task): Add detach argument.  Ignore detach argument if
	GOMP_TASK_FLAG_DETACH not set in flags.  Initialize completion_sem
	field.	Copy address of completion_sem into detach argument and
	into the start of the data record.  Wait for detach event if task
	not deferred.
	(gomp_barrier_handle_tasks): Queue tasks with unfulfilled events.
	Remove completed tasks and requeue dependent tasks.
	(omp_fulfill_event): New.
	* team.c (gomp_new_team): Initialize task_detach_queue and
	task_detach_count fields.
	(free_team): Free task_detach_queue field.
	* testsuite/libgomp.c-c++-common/task-detach-1.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-2.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-3.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-4.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-5.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-6.c: New testcase.
	* testsuite/libgomp.fortran/task-detach-1.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-2.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-3.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-4.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-5.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-6.f90: New testcase.
2021-01-16 12:58:13 -08:00
Sebastian Huber
5e5d56919d RTEMS: Add -mcustom-fpu-cfg=fph2 multilib
This multilib supports Nios II configurations with the "Nios II Floating
Point Hardware 2 Component".

gcc/

	* config/nios2/t-rtems: Reset all MULTILIB_* variables.  Shorten
	multilib directory names.  Use MULTILIB_REQUIRED instead of
	MULTILIB_EXCEPTIONS.  Add -mhw-mul -mhw-mulx -mhw-div
	-mcustom-fpu-cfg=fph2 multilib.
2021-01-16 17:54:28 +01:00
Sebastian Huber
42f4e23992 nios2: Add -mcustom-fpu-cfg=fph2
The new -mcustom-fpu-cfg=fph2 option variant is useful to build a
multilib for the "Nios II Floating Point Hardware 2 Component":

https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_nios2_custom_instruction.pdf

Directly using the corresponding -mcustom-insn=N options for this
floating-point unit leads to a combinatorial explosion in the potential
count of multilibs which may break the build.

gcc/

	* config/nios2/nios2.c (NIOS2_FPU_CONFIG_NUM): Adjust value.
	(nios2_init_fpu_configs): Provide register values for new
	-mcustom-fpu-cfg=fph2 option variant.
	* doc/invoke.texi (-mcustom-fpu-cfg=fph2): Document new option
	variant.
2021-01-16 17:54:27 +01:00
Sebastian Huber
7e02426ba0 nios2: Remove custom instruction warnings
Do not warn if custom instructions are not used due to missing
optimization flags.  This prevents build errors with -Werror which
cannot be disabled via a dedicated warning option.

One reason to remove these warnings is to enable a multilib for the
"Nios II Floating Point Hardware 2 Component".  For example, the
libatomic target library in GCC is built with -Werror and the warnings
removed by this patch resulted in errors like:

cc1: error: switch '-mcustom-fmins' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-fmaxs' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-round' has no effect unless '-fno-math-errno' is specified [-Werror]

gcc/

	* config/nios2/nios2.c (nios2_custom_check_insns): Remove
	custom instruction warnings.
2021-01-16 17:54:27 +01:00
Jakub Jelinek
e2559c3945 match.pd: Optimize ((cst << x) & 1) [PR96669]
While we had a ((1 << x) & 1) != 0 to x == 0 optimization already,
this patch adds ((cst << x) & 1) optimization too, this time the
second constant must be 1 though, not some power of two, but the first
one can be any constant.  If it is even, the result is false, if it is
odd, the result is x == 0.

2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96669
	* match.pd ((CST << x) & 1 -> x == 0): New simplification.

	* gcc.dg/tree-ssa/pr96669-1.c: Adjust regexp.
	* gcc.dg/tree-ssa/pr96669-2.c: New test.
2021-01-16 09:21:52 +01:00
Jakub Jelinek
b673e7547f cd_dce: Return TODO_update_address_taken from last cd_dce [PR96271]
On the following testcase, handle_builtin_memcmp in the strlen pass folds
the memcmp into comparison of two MEM_REFs.  But nothing triggers updating
of addressable vars afterwards, so even when the parameters are no longer
address taken, we force the parameters to stack and back anyway.

This patch causes TODO_update_address_taken to happen right before last forwprop
pass (at the end of last cd_dce), so after strlen1 too.

2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96271
	* passes.def: Pass false argument to first two pass_cd_dce
	instances and true to last instance.  Add comment that
	last instance rewrites no longer addressed locals.
	* tree-ssa-dce.c (pass_cd_dce): Add update_address_taken_p member and
	initialize it.
	(pass_cd_dce::set_pass_param): New method.
	(pass_cd_dce::execute): Return TODO_update_address_taken from
	last cd_dce instance.

	* gcc.target/i386/pr96271.c: New test.
2021-01-16 09:20:29 +01:00
H.J. Lu
2c356f221b libstdc++-v3: Add -fcf-protection=none to -march=i486
-fcf-protection is automatically enabled in libstdc++ on Linux/x86.
Starting from

commit 77d372abec
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 14 05:56:46 2021 -0800

    x86: Error on -fcf-protection with incompatible target

GCC issues an error on -fcf-protection with incompatible target:

... -fcf-protection ... libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc  -m32   -O2 -g0 -fno-exceptions -fno-asynchronous-unwind-tables -march=i486 ...
cc1plus: error: '-fcf-protection' is not compatible with this target
FAIL: 29_atomics/atomic_flag/test_and_set/explicit-hle.cc (test for excess errors)

Add -fcf-protection=none to -march=i486 to compile explicit-hle.cc.

	* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc:
	Add -fcf-protection=none to -march=i486.
2021-01-15 17:37:20 -08:00
GCC Administrator
2f7f0d32e7 Daily bump. 2021-01-16 00:16:29 +00:00
Carl Love
f1ad419ebf rs6000, vector integer multiply/divide/modulo instructions
2021-01-15  Carl Love  <cel@us.ibm.com>

gcc/ChangeLog:
	* config/rs6000/altivec.h (vec_mulh, vec_div, vec_dive, vec_mod):
	New defines.
	* config/rs6000/altivec.md (VIlong): Move define to file vsx.md.
	* config/rs6000/rs6000-builtin.def (DIVES_V4SI, DIVES_V2DI,
	DIVEU_V4SI, DIVEU_V2DI, DIVS_V4SI, DIVS_V2DI, DIVU_V4SI,
	DIVU_V2DI, MODS_V2DI, MODS_V4SI, MODU_V2DI, MODU_V4SI,
	MULHS_V2DI, MULHS_V4SI, MULHU_V2DI, MULHU_V4SI, MULLD_V2DI):
	Add builtin define.
	(MULH, DIVE, MOD):  Add new BU_P10_OVERLOAD_2 definitions.
	* config/rs6000/rs6000-call.c (VSX_BUILTIN_VEC_DIV,
	VSX_BUILTIN_VEC_DIVE, P10_BUILTIN_VEC_MOD, P10_BUILTIN_VEC_MULH):
	New overloaded definitions.
	(builtin_function_type) [P10V_BUILTIN_DIVEU_V4SI,
	P10V_BUILTIN_DIVEU_V2DI, P10V_BUILTIN_DIVU_V4SI,
	P10V_BUILTIN_DIVU_V2DI, P10V_BUILTIN_MODU_V2DI,
	P10V_BUILTIN_MODU_V4SI, P10V_BUILTIN_MULHU_V2DI,
	P10V_BUILTIN_MULHU_V4SI]: Add case
	statement for builtins.
	* config/rs6000/rs6000.md (bits): Add new attribute sizes V4SI, V2DI.
	* config/rs6000/vsx.md (VIlong): Moved from config/rs6000/altivec.md.
	(UNSPEC_VDIVES, UNSPEC_VDIVEU): New unspec definitions.
	(vsx_mul_v2di): Add if TARGET_POWER10 statement.
	(vsx_udiv_v2di): Add if TARGET_POWER10 statement.
	(dives_<mode>, diveu_<mode>, div<mode>3, uvdiv<mode>3,
	mods_<mode>, modu_<mode>, mulhs_<mode>, mulhu_<mode>, mulv2di3):
	Add define_insn, mode is VIlong.
	* doc/extend.texi (vec_mulh, vec_mul, vec_div, vec_dive, vec_mod):
	Add builtin descriptions.

gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/builtins-1-p10-runnable.c: New test file.
2021-01-15 17:31:12 -06:00
Eric Botcazou
c029fcb568 Reset force_source_line in final.c
Unlike the other global variables, it is not reset at the beginning of a
function so can leak into the next one.

gcc/ChangeLog:
	* final.c (final_start_function_1): Reset force_source_line.
2021-01-15 22:53:27 +01:00
Jerry DeLisle
b90e4a9741 fortran: Fixes a bug in ISO_Fortran_binding.c.
libgfortran/ChangeLog:

	* runtime/ISO_Fortran_binding.c (CFI_establish): Fixed signed
	  char arrays. Signed char or uint8_t arrays would cause
	  crashes unless an element size is specified.

gcc/testsuite/ChangeLog:

	* gfortran.dg/iso_fortran_binding_uint8_array.f90: New test.
	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: New test.
2021-01-15 13:48:42 -08:00
Nathan Sidwell
9beb6d88ef c++: Fix qualified array-type construction [PR 98538]
This was an assert that was too picky.  The reason I had to alter
array construction was that on stream in, we cannot dynamically determine
a type's dependentness.  Thus on stream out of the 'problematic' types,
we save the dependentness for reconstruction.  Fortunately the paths into
cp_build_qualified_type_real from streamin with arrays do have the array's
dependentess set as needed.

	PR c++/98538
	gcc/cp/
	* tree.c (cp_build_qualified_type_real): Propagate an array's
	dependentness to the copy, if known.
	gcc/testsuite/
	* g++.dg/template/pr98538.C: New.
2021-01-15 12:45:18 -08:00
Nathan Sidwell
e1efa6af61 preprocessor: Make quoting : [PR 95253]
I missed some testsuite fall out with my patch to fix mkdeps file
mangling.

	PR preprocessor/95253
	gcc/testsuite/
	* g++.dg/modules/dep-1_a.C: Adjust expected output.
	* g++.dg/modules/dep-1_b.C: Likewise.
	* g++.dg/modules/dep-2.C: Likewise.
2021-01-15 12:44:52 -08:00
Jakub Jelinek
0425f4c1b6 match.pd: Generalize the PR64309 simplifications [PR96669]
The following patch generalizes the PR64309 simplifications, so that instead
of working only with constants 1 and 1 it works with any two power of two
constants, and works also for right shift (in that case it rules out the
first one being negative, as it is arithmetic shift then).

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96669
	* match.pd (((1 << A) & 1) != 0 -> A == 0,
	((1 << A) & 1) == 0 -> A != 0): Generalize for 1s replaced by
	possibly different power of two constants and to right shift too.

	* gcc.dg/tree-ssa/pr96669-1.c: New test.
2021-01-15 21:12:14 +01:00
Jakub Jelinek
5c046034e3 match.pd: Optimize (x < 0) ^ (y < 0) to (x ^ y) < 0 etc. [PR96681]
This patch simplifies comparisons that test the sign bit xored together.
If the comparisons are both < 0 or both >= 0, then we should xor the operands
together and compare the result to < 0, if the comparisons are different,
we should compare to >= 0.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96681
	* match.pd ((x < 0) ^ (y < 0) to (x ^ y) < 0): New simplification.
	((x >= 0) ^ (y >= 0) to (x ^ y) < 0): Likewise.
	((x < 0) ^ (y >= 0) to (x ^ y) >= 0): Likewise.
	((x >= 0) ^ (y < 0) to (x ^ y) >= 0): Likewise.

	* gcc.dg/tree-ssa/pr96681.c: New test.
2021-01-15 21:10:44 +01:00
Alexandre Oliva
e63c2161d0 drop -dumpbase-ext from producer string
The -dumpbase and -dumpdir options are excluded from the producer
string output in debug information, but -dumpbase-ext was not.  This
patch excludes it as well.


for  gcc/ChangeLog

	* opts.c (gen_command_line_string): Exclude -dumpbase-ext.
2021-01-15 16:22:54 -03:00
Jason Merrill
d75199f782 c++: Avoid redundant copy in {} init [PR98642]
Here, initializing from { } implies a call to the default constructor for
base.  We were then seeing that we're initializing a base subobject, so we
tried to copy the result of that call.  This is clearly wrong; we should
initialize the base directly from its default constructor.

This patch does a lot of refactoring of unsafe_copy_elision_p and adds
make_safe_copy_elision that will also try to do the base constructor
rewriting from the last patch.

gcc/cp/ChangeLog:

	PR c++/98642
	* call.c (unsafe_return_slot_p): Return int.
	(init_by_return_slot_p): Split out from...
	(unsafe_copy_elision_p): ...here.
	(unsafe_copy_elision_p_opt): New name for old meaning.
	(build_over_call): Adjust.
	(make_safe_copy_elision): New.
	* typeck2.c (split_nonconstant_init_1): Elide copy from safe
	list-initialization.
	* cp-tree.h: Adjust.

gcc/testsuite/ChangeLog:

	PR c++/98642
	* g++.dg/cpp1z/elide5.C: New test.
2021-01-15 13:57:01 -05:00
Jason Merrill
424deca72b c++: Fix copy elision for base initialization
While working on PR98642 I noticed that in this testcase we were eliding the
copy, calling the complete default constructor to initialize the B base
subobject, and therefore wrongly initializing the non-existent A subobject
of B.  The test doesn't care whether the copy is elided or not, but checks
that we are actually calling a base constructor for B.

The patch preserves the elision, but changes the initializer to call the
base constructor instead of the complete constructor.

gcc/cp/ChangeLog:

	* call.c (base_ctor_for, make_base_init_ok): New.
	(build_over_call): Use make_base_init_ok.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/elide4.C: New test.
2021-01-15 13:57:01 -05:00
Tamar Christina
ad26034338 AArch64: Add NEON, SVE and SVE2 RTL patterns for Multiply, FMS and FMA.
This adds implementation for the optabs for complex operations.  With this the
following C code:

  void g (float complex a[restrict N], float complex b[restrict N],
	  float complex c[restrict N])
  {
    for (int i=0; i < N; i++)
      c[i] =  a[i] * b[i];
  }

generates

NEON:

g:
        movi    v3.4s, 0
        mov     x3, 0
        .p2align 3,,7
.L2:
        mov     v0.16b, v3.16b
        ldr     q2, [x1, x3]
        ldr     q1, [x0, x3]
        fcmla   v0.4s, v1.4s, v2.4s, #0
        fcmla   v0.4s, v1.4s, v2.4s, #90
        str     q0, [x2, x3]
        add     x3, x3, 16
        cmp     x3, 1600
        bne     .L2
        ret

SVE:

g:
        mov     x3, 0
        mov     x4, 400
        ptrue   p1.b, all
        whilelo p0.s, xzr, x4
        mov     z3.s, #0
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        fcmla   z0.s, p1/m, z1.s, z2.s, #0
        fcmla   z0.s, p1/m, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

SVE2 (with int instead of float)
g:
        mov     x3, 0
        mov     x4, 400
        mov     z3.b, #0
        whilelo p0.s, xzr, x4
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        cmla    z0.s, z1.s, z2.s, #0
        cmla    z0.s, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
	* config/aarch64/iterators.md (UNSPEC_FCMUL,
	UNSPEC_FCMUL180, UNSPEC_FCMLA_CONJ, UNSPEC_FCMLA180_CONJ,
	UNSPEC_CMLA_CONJ, UNSPEC_CMLA180_CONJ, UNSPEC_CMUL, UNSPEC_CMUL180,
	FCMLA_OP, FCMUL_OP, conj_op, rotsplit1, rotsplit2, fcmac1, sve_rot1,
	sve_rot2, SVE2_INT_CMLA_OP, SVE2_INT_CMUL_OP, SVE2_INT_CADD_OP): New.
	(rot): Add UNSPEC_FCMUL, UNSPEC_FCMUL180.
	(rot_op): Renamed to conj_op.
	* config/aarch64/aarch64-sve.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
	* config/aarch64/aarch64-sve2.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
2021-01-15 18:50:27 +00:00
Jason Merrill
cd09079cfd c++: Fix list-init of array of no-copy type [PR63707]
build_vec_init_elt models initialization from some arbitrary object of the
type, i.e. copy, but in the case of list-initialization we don't do a copy
from the elements, we initialize them directly.

gcc/cp/ChangeLog:

	PR c++/63707
	* tree.c (build_vec_init_expr): Don't call build_vec_init_elt
	if we got a CONSTRUCTOR.

gcc/testsuite/ChangeLog:

	PR c++/63707
	* g++.dg/cpp0x/initlist-array13.C: New test.
2021-01-15 13:38:14 -05:00