gcc.git
4 years agolibstdc++: Prefer double to long double in std::shuffle_order_engine
Jonathan Wakely [Sat, 31 Oct 2020 07:16:47 +0000 (07:16 +0000)]
libstdc++: Prefer double to long double in std::shuffle_order_engine

The transition algorithm for std::shuffle_order_engine uses long double
to ensure that the value (max() - min() + 1) can be accurately
represented, to avoid bias in the shuffling. However, when the base
engine's range is small enough we can avoid slower long double
arithmetic by using double. For example, long double is unnecessary for
any base engine returning 32-bit values.

This makes std::knuth_b::operator() about 15% faster on x86_64, and
probably even more on targets where long double uses soft-float.

libstdc++-v3/ChangeLog:

* include/bits/random.h (independent_bit_engine): Fix typo
in comment.
(shuffle_order_engine): Fix incorrect description in comment.
* include/bits/random.tcc (__representable_as_double
(__p1_representable_as_double): New helper functions.
(shuffle_order_engine::operator()): Use double for calculation
if (max() - min() + 1) is representable as double.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.

4 years agoMove clone_info to summary
Jan Hubicka [Sat, 31 Oct 2020 09:18:06 +0000 (10:18 +0100)]
Move clone_info to summary

* Makefile.in: (OBJS): Add symtab-clones.o
(GTFILES): Add symtab-clones.h
* cgraph.c: Include symtab-clones.h.
(cgraph_edge::resolve_speculation): Fix formating
(cgraph_edge::redirect_call_stmt_to_callee): Update.
(cgraph_update_edges_for_call_stmt): Update
(release_function_body): Fix formating.
(cgraph_node::remove): Fix formating.
(cgraph_node::dump): Fix formating.
(cgraph_node::get_availability): Fix formating.
(cgraph_node::call_for_symbol_thunks_and_aliases): Fix formating.
(set_const_flag_1): Fix formating.
(set_pure_flag_1): Fix formating.
(cgraph_node::can_remove_if_no_direct_calls_p): Fix formating.
(collect_callers_of_node_1): Fix formating.
(clone_of_p): Update.
(cgraph_node::verify_node): Update.
(cgraph_c_finalize): Call clone_info::release ().
* cgraph.h (struct cgraph_clone_info): Move to symtab-clones.h.
(cgraph_node): Remove clone_info.
(symbol_table): Add m_clones.
* cgraphclones.c: Include symtab-clone.h.
(duplicate_thunk_for_node): Update.
(cgraph_node::create_clone): Update.
(cgraph_node::create_virtual_clone): Update.
(cgraph_node::find_replacement): Update.
(cgraph_node::materialize_clone): Update.
* gengtype.c (open_base_files): Include symtab-clones.h.
* ipa-cp.c: Include symtab-clones.h.
(initialize_node_lattices): Update.
(want_remove_some_param_p): Update.
(create_specialized_node): Update.
* ipa-fnsummary.c: Include symtab-clones.h.
(ipa_fn_summary_t::duplicate): Update.
* ipa-modref.c: Include symtab-clones.h.
(update_signature): Update.
* ipa-param-manipulation.c: Include symtab-clones.h.
(ipa_param_body_adjustments::common_initialization): Update.
* ipa-prop.c: Include symtab-clones.h.
(adjust_agg_replacement_values): Update.
(ipcp_get_parm_bits): Update.
(ipcp_update_bits): Update.
(ipcp_update_vr): Update.
* ipa-sra.c: Include symtab-clones.h.
(process_isra_node_results): Update.
(disable_unavailable_parameters): Update.
* lto-cgraph.c: Include symtab-clone.h.
(output_cgraph_opt_summary_p): Update.
(output_node_opt_summary): Update.
(input_node_opt_summary): Update.
* symtab-clones.cc: New file.
* symtab-clones.h: New file.
* tree-inline.c (expand_call_inline): Update.
(update_clone_info): Update.
(tree_function_versioning): Update.

4 years agoHandle fnspec in local ipa-modref
Jan Hubicka [Sat, 31 Oct 2020 07:56:40 +0000 (08:56 +0100)]
Handle fnspec in local ipa-modref

* ipa-modref.c (modref_summary::dump): Dump writes_errno.
(parm_map_for_arg): Break out from ...
(merge_call_side_effects): ... here.
(get_access_for_fnspec): New function.
(process_fnspec): New function.
(analyze_call): Use it.
(analyze_stmt): Update.
(analyze_function): Initialize writes_errno.
(modref_summaries::duplicate): Duplicate writes_errno.
* ipa-modref.h (struct modref_summary): Add writes_errno.
* tree-ssa-alias.c (call_may_clobber_ref_p_1): Check errno.

4 years agolibstdc++: Use double for unordered container load factors [PR 96958]
Jonathan Wakely [Sat, 31 Oct 2020 00:52:57 +0000 (00:52 +0000)]
libstdc++: Use double for unordered container load factors [PR 96958]

My previous commit for this PR changed the types from long double to
double, but didn't change the uses of __builtin_ceill and
__builtin_floorl. It also failed to change the non-inline functions in
src/c++11/hashtable_c++0x.cc. This should fix it properly now.

libstdc++-v3/ChangeLog:

PR libstdc++/96958
* include/bits/hashtable_policy.h (_Prime_rehash_policy)
(_Power2_rehash_policy): Use ceil and floor instead of ceill and
floorl.
* src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy): Likewise.
Use double instead of long double.

4 years agolibstdc++: Don't initialize from *this inside some views [PR97600]
Patrick Palka [Sat, 31 Oct 2020 00:33:19 +0000 (20:33 -0400)]
libstdc++: Don't initialize from *this inside some views [PR97600]

This works around a subtle issue where instantiating the begin()/end()
member of some views (as part of return type deduction) inadvertently
requires computing the satisfaction value of range<foo_view>.

This is problematic because the constraint range<foo_view> requires the
begin()/end() member to be callable.  But it's not callable until we've
deduced its return type, so evaluation of range<foo_view> yields false
at this point.  And if after both members are instantiated (and their
return types deduced) we evaluate range<foo_view> again, this time it
will yield true since the begin()/end() members are now both callable.
This makes the program ill-formed according to [temp.constr.atomic]/3:

  If, at different points in the program, the satisfaction result is
  different for identical atomic constraints and template arguments, the
  program is ill-formed, no diagnostic required.

The views affected by this issue are those whose begin()/end() member
has a placeholder return type and that member initializes an _Iterator
or _Sentinel object from a reference to *this.  The second condition is
relevant because it means explicit conversion functions are considered
during overload resolution (as per [over.match.copy], I think), and
therefore it causes g++ to check the constraints of the conversion
function view_interface<foo_view>::operator bool().  And this conversion
function's constraints indirectly require range<foo_view>.

This issue is observable on trunk only with basic_istream_view (as in
the testcase in the PR).  But a pending patch that makes g++ memoize
constraint satisfaction values indefinitely (it currently invalidates
the satisfaction cache on various events) causes many existing tests for
the other affected views to fail, because range<foo_view> then remains
false for the whole compilation.

This patch works around this issue by adjusting the constructors of the
_Iterator and _Sentinel types of the affected views to take their
foo_view argument by pointer instead of by reference, so that g++ no
longer considers explicit conversion functions when resolving the
direct-initialization inside these views' begin()/end() members.

libstdc++-v3/ChangeLog:

PR libstdc++/97600
* include/std/ranges (basic_istream_view::begin): Initialize
_Iterator from 'this' instead of '*this'.
(basic_istream_view::_Iterator::_Iterator): Adjust constructor
accordingly.
(filter_view::_Iterator::_Iterator): Take a filter_view*
argument instead of a filter_view& argument.
(filter_view::_Sentinel::_Sentinel): Likewise.
(filter_view::begin): Initialize _Iterator from 'this' instead
of '*this'.
(filter_view::end): Likewise.
(transform_view::_Iterator::_Iterator): Take a _Parent* instead
of a _Parent&.
(filter_view::_Iterator::operator+): Adjust accordingly.
(filter_view::_Iterator::operator-): Likewise.
(filter_view::begin): Initialize _Iterator from 'this' instead
of '*this'.
(filter_view::end): Likewise.
(join_view::_Iterator): Take a _Parent* instead of a _Parent&.
(join_view::_Sentinel): Likewise.
(join_view::begin): Initialize _Iterator from 'this' instead of
'*this'.
(join_view::end): Initialize _Sentinel from 'this' instead of
'*this'.
(split_view::_OuterIter): Take a _Parent& instead of a _Parent*.
(split_view::begin): Initialize _OuterIter from 'this' instead
of '*this'.
(split_view::end): Likewise.
* testsuite/std/ranges/97600.cc: New test.

4 years agolibstdc++: Implement P2017R1 "Conditionally borrowed ranges"
Jonathan Wakely [Fri, 30 Oct 2020 18:39:43 +0000 (18:39 +0000)]
libstdc++: Implement P2017R1 "Conditionally borrowed ranges"

This makes some range adaptors model the borrowed_range concept if they
are adapting a borrowed range. This hasn't been added to the C++23
working paper yet, but it has been approved by LWG, and the
recommendation is to treat it as a defect report for C++20 as well.

libstdc++-v3/ChangeLog:

* include/std/ranges (enable_borrowed_view<take_view<T>>)
(enable_borrowed_view<drop_view<T>>)
(enable_borrowed_view<drop_while_view<T>>)
(enable_borrowed_view<reverse_view<T>>)
(enable_borrowed_view<common_view<T>>)
(enable_borrowed_view<elements_view<T>>): Add partial
specializations as per P2017R1.
* testsuite/std/ranges/adaptors/conditionally_borrowed.cc:
New test.

4 years agoPowerPC: Don't assume all targets have GLIBC.
Michael Meissner [Fri, 30 Oct 2020 22:36:25 +0000 (18:36 -0400)]
PowerPC: Don't assume all targets have GLIBC.

gcc/
2020-10-30  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/rs6000.c (glibc_supports_ieee_128bit): New helper
function.
(rs6000_option_override_internal): Call it.

4 years agolibstdc++: Use double for unordered container load factors [PR 96958]
Jonathan Wakely [Fri, 30 Oct 2020 15:14:33 +0000 (15:14 +0000)]
libstdc++: Use double for unordered container load factors [PR 96958]

These calculations were changed to use long double nearly ten years ago
in order to get more precision than float:
https://gcc.gnu.org/pipermail/libstdc++/2011-September/036420.html

However, double should be sufficient, whlie being potentially faster
than long double, and not requiring soft FP calculations for targets
without native long double support.

libstdc++-v3/ChangeLog:

PR libstdc++/96958
* include/bits/hashtable_policy.h (_Prime_rehash_policy)
(_Power2_rehash_policy): Use double instead of long double.

4 years agolibstdc++: Fix some more warnings in test
Jonathan Wakely [Fri, 30 Oct 2020 10:47:25 +0000 (10:47 +0000)]
libstdc++: Fix some more warnings in test

libstdc++-v3/ChangeLog:

* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
Avoid -Wcatch-value warnings.

4 years agoPR libfortran/97581 - clean up size calculation of random generator state
Harald Anlauf [Fri, 30 Oct 2020 19:49:32 +0000 (20:49 +0100)]
PR libfortran/97581 - clean up size calculation of random generator state

The random number generator internal state may be saved to/restored from
an array of integers.  Clean up calculation of needed number of elements
to avoid redefiniton of auxiliary macro SZ.

libgfortran/ChangeLog:

* intrinsics/random.c (SZ_IN_INT_4): Define size of state in int32_t.
(SZ_IN_INT_8): Define size of state in int64_t.
(SZ): Remove.
(random_seed_i4): Use size SZ_IN_INT_4 instead of SZ.
(random_seed_i8): Use size SZ_IN_INT_8 instead of SZ.

4 years agoAdd -fzero-call-used-regs option and zero_call_used_regs function attributes.
qing zhao [Fri, 30 Oct 2020 19:41:38 +0000 (20:41 +0100)]
Add -fzero-call-used-regs option and zero_call_used_regs function attributes.

This new feature causes the compiler to zero a  subset of all call-used
registers at function return.  This is used to increase program security
by either mitigating Return-Oriented Programming (ROP) attacks or
preventing information leakage through registers.

gcc/ChangeLog:

2020-10-30  Qing Zhao  <qing.zhao@oracle.com>
    H.J.Lu  <hjl.tools@gmail.com>

* common.opt: Add new option -fzero-call-used-regs
* config/i386/i386.c (zero_call_used_regno_p): New function.
(zero_call_used_regno_mode): Likewise.
(zero_all_vector_registers): Likewise.
(zero_all_st_registers): Likewise.
(zero_all_mm_registers): Likewise.
(ix86_zero_call_used_regs): Likewise.
(TARGET_ZERO_CALL_USED_REGS): Define.
* df-scan.c (df_epilogue_uses_p): New function.
(df_get_exit_block_use_set): Replace EPILOGUE_USES with
df_epilogue_uses_p.
* df.h (df_epilogue_uses_p): Declare.
* doc/extend.texi: Document the new zero_call_used_regs attribute.
* doc/invoke.texi: Document the new -fzero-call-used-regs option.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (TARGET_ZERO_CALL_USED_REGS): New hook.
* emit-rtl.h (struct rtl_data): New field must_be_zero_on_return.
* flag-types.h (namespace zero_regs_flags): New namespace.
* function.c (gen_call_used_regs_seq): New function.
(class pass_zero_call_used_regs): New class.
(pass_zero_call_used_regs::execute): New function.
(make_pass_zero_call_used_regs): New function.
* optabs.c (expand_asm_reg_clobber_mem_blockage): New function.
* optabs.h (expand_asm_reg_clobber_mem_blockage): Declare.
* opts.c (zero_call_used_regs_opts): New structure array
initialization.
(parse_zero_call_used_regs_options): New function.
(common_handle_option): Handle -fzero-call-used-regs.
* opts.h (zero_call_used_regs_opts): New structure array.
* passes.def: Add new pass pass_zero_call_used_regs.
* recog.c (valid_insn_p): New function.
* recog.h (valid_insn_p): Declare.
* resource.c (init_resource_info): Replace EPILOGUE_USES with
df_epilogue_uses_p.
* target.def (zero_call_used_regs): New hook.
* targhooks.c (default_zero_call_used_regs): New function.
* targhooks.h (default_zero_call_used_regs): Declare.
* tree-pass.h (make_pass_zero_call_used_regs): Declare.

gcc/c-family/ChangeLog:

2020-10-30  Qing Zhao  <qing.zhao@oracle.com>
    H.J.Lu  <hjl.tools@gmail.com>

* c-attribs.c (c_common_attribute_table): Add new attribute
zero_call_used_regs.
(handle_zero_call_used_regs_attribute): New function.

gcc/testsuite/ChangeLog:

2020-10-30  Qing Zhao  <qing.zhao@oracle.com>
    H.J.Lu  <hjl.tools@gmail.com>

* c-c++-common/zero-scratch-regs-1.c: New test.
* c-c++-common/zero-scratch-regs-10.c: New test.
* c-c++-common/zero-scratch-regs-11.c: New test.
* c-c++-common/zero-scratch-regs-2.c: New test.
* c-c++-common/zero-scratch-regs-3.c: New test.
* c-c++-common/zero-scratch-regs-4.c: New test.
* c-c++-common/zero-scratch-regs-5.c: New test.
* c-c++-common/zero-scratch-regs-6.c: New test.
* c-c++-common/zero-scratch-regs-7.c: New test.
* c-c++-common/zero-scratch-regs-8.c: New test.
* c-c++-common/zero-scratch-regs-9.c: New test.
* c-c++-common/zero-scratch-regs-attr-usages.c: New test.
* gcc.target/i386/zero-scratch-regs-1.c: New test.
* gcc.target/i386/zero-scratch-regs-10.c: New test.
* gcc.target/i386/zero-scratch-regs-11.c: New test.
* gcc.target/i386/zero-scratch-regs-12.c: New test.
* gcc.target/i386/zero-scratch-regs-13.c: New test.
* gcc.target/i386/zero-scratch-regs-14.c: New test.
* gcc.target/i386/zero-scratch-regs-15.c: New test.
* gcc.target/i386/zero-scratch-regs-16.c: New test.
* gcc.target/i386/zero-scratch-regs-17.c: New test.
* gcc.target/i386/zero-scratch-regs-18.c: New test.
* gcc.target/i386/zero-scratch-regs-19.c: New test.
* gcc.target/i386/zero-scratch-regs-2.c: New test.
* gcc.target/i386/zero-scratch-regs-20.c: New test.
* gcc.target/i386/zero-scratch-regs-21.c: New test.
* gcc.target/i386/zero-scratch-regs-22.c: New test.
* gcc.target/i386/zero-scratch-regs-23.c: New test.
* gcc.target/i386/zero-scratch-regs-24.c: New test.
* gcc.target/i386/zero-scratch-regs-25.c: New test.
* gcc.target/i386/zero-scratch-regs-26.c: New test.
* gcc.target/i386/zero-scratch-regs-27.c: New test.
* gcc.target/i386/zero-scratch-regs-28.c: New test.
* gcc.target/i386/zero-scratch-regs-29.c: New test.
* gcc.target/i386/zero-scratch-regs-30.c: New test.
* gcc.target/i386/zero-scratch-regs-31.c: New test.
* gcc.target/i386/zero-scratch-regs-3.c: New test.
* gcc.target/i386/zero-scratch-regs-4.c: New test.
* gcc.target/i386/zero-scratch-regs-5.c: New test.
* gcc.target/i386/zero-scratch-regs-6.c: New test.
* gcc.target/i386/zero-scratch-regs-7.c: New test.
* gcc.target/i386/zero-scratch-regs-8.c: New test.
* gcc.target/i386/zero-scratch-regs-9.c: New test.

4 years agoTake insn scratch RA requirements into account in IRA.
Vladimir N. Makarov [Fri, 30 Oct 2020 19:05:22 +0000 (15:05 -0400)]
Take insn scratch RA requirements into account in IRA.

  The patch changes insn scratches which require registers for all
insn alternatives (in other words w/o X constraint in scratch
constraint string).  This is done before IRA staring its work.  LRA
still continue to change the rest scratches (with X constraint and in
insn created during IRA) into pseudos.  As before the patch at the end
of LRA work, spilled scratch pseudos (for which X constraint was
chosen) changed into scratches back.

gcc/ChangeLog:

* lra.c (get_scratch_reg): New function.
(remove_scratches_1): Rename remove_insn_scratches.  Use
ira_remove_insn_scratches and get_scratch_reg.
(remove_scratches): Do not
initialize scratches, scratch_bitmap, and scratch_operand_bitmap.
(lra): Call ira_restore_scratches instead of restore_scratches.
(struct sloc, sloc_t, scratches, scratch_bitmap)
(scratch_operand_bitmap, lra_former_scratch_p)
(lra_former_scratch_operand_p, lra_register_new_scratch_op)
(restore_scratches): Move them to ...
* ira.c: ... here.
(former_scratch_p, former_scratch_operand_p): Rename to
ira_former_scratch_p and ira_former_scratch_operand_p.
(contains_X_constraint_p): New function.
(register_new_scratch_op): Rename to ira_register_new_scratch_op.
Change it to work for IRA and LRA.
(restore_scratches): Rename to ira_restore_scratches.
(get_scratch_reg, ira_remove_insn_scratches): New functions.
(ira): Call ira_remove_scratches if we use LRA.
* ira.h (ira_former_scratch_p, ira_former_scratch_operand_p): New
prototypes.
(ira_register_new_scratch_op, ira_restore_scratches): New prototypes.
(ira_remove_insn_scratches): New prototype.
* lra-int.h (lra_former_scratch_p, lra_former_scratch_operand_p):
Remove prototypes.
(lra_register_new_scratch_op): Ditto.
* lra-constraints.c: Rename lra_former_scratch_p and
lra_former_scratch_p to ira_former_scratch_p and to
ira_former_scratch_p.
* lra-remat.c: Ditto.
* lra-spills.c: Rename lra_former_scratch_p to ira_former_scratch_p.

4 years agoPR middle-end/97556 - ICE on excessively large index into a multidimensional array
Martin Sebor [Fri, 30 Oct 2020 19:04:29 +0000 (13:04 -0600)]
PR middle-end/97556 - ICE on excessively large index into a multidimensional array

gcc/ChangeLog:

PR middle-end/97556
* builtins.c (access_ref::add_offset): Cap offset lower bound
to at most the the upper bound.

gcc/testsuite/ChangeLog:

PR middle-end/97556
* gcc.dg/Warray-bounds-70.c: New test.

4 years agolibstdc++: Fix the default constructor of ranges::__detail::__box
Patrick Palka [Fri, 30 Oct 2020 16:33:13 +0000 (12:33 -0400)]
libstdc++: Fix the default constructor of ranges::__detail::__box

The class template semiregular-box<T> of [range.semi.wrap] is specified
to value-initialize the underlying object whenever its type is default
initializable.  Our primary template for __detail::__box respects this
requirement, but the recently added partial specialization (for types
that are already semiregular) does not.

This patch fixes this issue, and additionally makes the corresponding in
place constructor explicit (as in the primary template).

libstdc++-v3/ChangeLog:

* include/std/ranges (__detail::__box): For the partial
specialization used by types that are already semiregular,
make the default constructor value-initialize the underlying
object instead of default-initializing it.  Make its in place
constructor explicit.
* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
Augment test.

4 years agotestsuite: Avoid TCL errors when rootme or ASAN/TSAN/UBSAN is not avail
Tobias Burnus [Fri, 30 Oct 2020 16:11:20 +0000 (17:11 +0100)]
testsuite: Avoid TCL errors when rootme or ASAN/TSAN/UBSAN is not avail

gcc/testsuite/
* g++.dg/guality/guality.exp: Skip $rootme-based check if unset.
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.
* lib/asan-dg.exp: Don't use $asan_saved_library_path if not set.
* lib/tsan-dg.exp: Don't use $tsan_saved_library_path if not set.
* lib/ubsan-dg.exp: Don't use $ubsan_saved_library_path if not set.

4 years agoFortran: Update omp atomic for OpenMP 5
Tobias Burnus [Fri, 30 Oct 2020 14:57:46 +0000 (15:57 +0100)]
Fortran: Update omp atomic for OpenMP 5

gcc/fortran/ChangeLog:

* dump-parse-tree.c (show_omp_clauses): Handle atomic clauses.
(show_omp_node): Call it for atomic.
* gfortran.h (enum gfc_omp_atomic_op): Add GFC_OMP_ATOMIC_UNSET,
remove GFC_OMP_ATOMIC_SEQ_CST and GFC_OMP_ATOMIC_ACQ_REL.
(enum gfc_omp_memorder): Replace OMP_MEMORDER_LAST by
OMP_MEMORDER_UNSET, add OMP_MEMORDER_SEQ_CST/OMP_MEMORDER_RELAXED.
(gfc_omp_clauses): Add capture and atomic_op.
(gfc_code): remove omp_atomic.
* openmp.c (enum omp_mask1): Add atomic, capture, memorder clauses.
(gfc_match_omp_clauses): Match them.
(OMP_ATOMIC_CLAUSES): Add.
(gfc_match_omp_flush): Update for 'last' to 'unset' change.
(gfc_match_omp_oacc_atomic): Removed and placed content ..
(gfc_match_omp_atomic): ... here. Update for OpenMP 5 clauses.
(gfc_match_oacc_atomic): Match directly here.
(resolve_omp_atomic, gfc_resolve_omp_directive): Update.
* parse.c (parse_omp_oacc_atomic): Update for struct gfc_code changes.
* resolve.c (gfc_resolve_blocks): Update assert.
* st.c (gfc_free_statement): Also call for EXEC_O{ACC,MP}_ATOMIC.
* trans-openmp.c (gfc_trans_omp_atomic): Update.
(gfc_trans_omp_flush): Update for 'last' to 'unset' change.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/atomic-2.f90: New test.
* gfortran.dg/gomp/atomic.f90: New test.

4 years agoFix thunk info WRT PCH
Jan Hubicka [Fri, 30 Oct 2020 13:30:43 +0000 (14:30 +0100)]
Fix thunk info WRT PCH

PR pch/97593
* cgraph.c (cgraph_node::create_thunk): Register thunk as early during
parsing.
* cgraphunit.c (analyze_functions): Call
thunk_info::process_early_thunks.
* symtab-thunks.cc (struct unprocessed_thunk): New struct.
(thunks): New static variable.
(thunk_info::register_early): New member function.
(thunk_info::process_early_thunks): New member function.
* symtab-thunks.h (thunk_info::register_early): Declare.
(thunk_info::process_early_thunks): Declare.

4 years agoDisable TBAA for array descriptors.
Jan Hubicka [Fri, 30 Oct 2020 13:28:23 +0000 (14:28 +0100)]
Disable TBAA for array descriptors.

* trans-types.c: Include alias.h
(gfc_get_array_type_bounds): Set typeless storage.

4 years agotree-optimization/97623 - avoid excessive insert iteration for hoisting
Richard Biener [Fri, 30 Oct 2020 12:32:32 +0000 (13:32 +0100)]
tree-optimization/97623 - avoid excessive insert iteration for hoisting

This avoids requiring insert iteration for back-to-back hoisting
opportunities as seen in the added testcase.  For the PR at hand
this halves the number of insert iterations retaining only
the hard to avoid PRE / hoist insert back-to-backs.

2020-10-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97623
* tree-ssa-pre.c (insert): First do hoist insertion in
a backward walk.

* gcc.dg/tree-ssa/ssa-hoist-7.c: New testcase.

4 years agotree-optimization/97626 - handle SCCs properly in SLP stmt analysis
Richard Biener [Fri, 30 Oct 2020 10:26:18 +0000 (11:26 +0100)]
tree-optimization/97626 - handle SCCs properly in SLP stmt analysis

This makes sure to roll-back the whole SCC when we fail stmt
analysis, otherwise the optimistic visited treatment breaks down
with different entries.  Rollback is easy when tracking additions
to visited in a vector which also makes the whole thing cheaper
than the two hash-sets used before.

2020-10-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97626
* tree-vect-slp.c (vect_slp_analyze_node_operations):
Exchange the lvisited hash-set for a vector, roll back
recursive adds to visited when analysis failed.
(vect_slp_analyze_operations): Likewise.

* gcc.dg/vect/bb-slp-pr97626.c: New testcase.

4 years agoopenmp: Use FIELD_TGT_EMPTY once more
Jakub Jelinek [Fri, 30 Oct 2020 11:03:36 +0000 (12:03 +0100)]
openmp: Use FIELD_TGT_EMPTY once more

2020-10-30  Jakub Jelinek  <jakub@redhat.com>

* target.c (gomp_map_vars_internal): Use FIELD_TGT_EMPTY macro
even in field_tgt_clear initializer.

4 years ago[OpenACC] Elaborate testcases that verify column location information [PR92793]
Thomas Schwinge [Thu, 29 Oct 2020 15:12:38 +0000 (16:12 +0100)]
[OpenACC] Elaborate testcases that verify column location information [PR92793]

After PR92793 commit 9c81750c5bedd7883182ee2684a012c6210ebe1d "Fortran] PR
92793 - fix column used for error diagnostic", commit
d0d0ba20f2345023e9cec2419c9fb9e6cc7098c6 did "Add tests to verify OpenACC
clause locations", later fixed up in PR92901 commit
e6c90dba73291435c244decb9a89c47019cc5a45 to "Fix PR92901: Change test
expectation for C++ in OpenACC test clause-locations.c".

Now, add some more testing to verify/document the status quo.

gcc/testsuite/
PR fortran/92793
* c-c++-common/goacc/clause-locations.c: Rewrite into...
* c-c++-common/goacc/pr92793-1.c: ... this.
* gfortran.dg/goacc/clause-locations.f90: Rewrite into...
* gfortran.dg/goacc/pr92793-1.f90: ... this.

4 years agogcc-changelog: Handle situations like '* tree-vect-slp.c (): '
Martin Liska [Fri, 30 Oct 2020 10:23:11 +0000 (11:23 +0100)]
gcc-changelog: Handle situations like '* tree-vect-slp.c (): '

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Handle empty groups in
file description.
* gcc-changelog/test_email.py: New test.
* gcc-changelog/test_patches.txt: Likewise.

4 years agoAArch64: Add FLAG for float conversion intrinsics [PR94442]
zhengnannan [Fri, 30 Oct 2020 10:22:30 +0000 (10:22 +0000)]
AArch64: Add FLAG for float conversion intrinsics [PR94442]

2020-10-30  Zhiheng Xie  <xiezhiheng@huawei.com>
    Nannan Zheng  <zhengnannan@huawei.com>

gcc/ChangeLog:

* config/aarch64/aarch64-simd-builtins.def: Add proper FLAG
for conversion intrinsics.

4 years agotree-optimization/97633 - fix SLP scheduling of single-node cycles
Richard Biener [Fri, 30 Oct 2020 08:57:02 +0000 (09:57 +0100)]
tree-optimization/97633 - fix SLP scheduling of single-node cycles

This makes sure to update backedges in single-node cycles.

2020-10-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97633
* tree-vect-slp.c (): Update backedges in single-node cycles.
Optimize processing of externals.

* g++.dg/vect/slp-pr97636.cc: New testcase.
* gcc.dg/vect/bb-slp-pr97633.c: Likewise.

4 years agoaarch64: Fix PR96998 and restore code quality in combine
Alex Coplan [Fri, 30 Oct 2020 09:21:31 +0000 (09:21 +0000)]
aarch64: Fix PR96998 and restore code quality in combine

This change fixes a bug in the AArch64 backend. Currently, we accept an
odd sign_extract representation of addresses, but don't accept that same
odd form of address as an LEA.

This is the cause of PR96998. In the testcase given in the PR, combine
produces:

(insn 9 8 10 3 (set (mem:SI (plus:DI (sign_extract:DI (mult:DI (subreg:DI (reg/v:SI 92 [ g ]) 0)
                        (const_int 4 [0x4]))
                    (const_int 34 [0x22])
                    (const_int 0 [0]))
                (reg/f:DI 96)) [3 *i_5+0 S4 A32])
        (asm_operands:SI ("") ("=Q") 0 []
             []
             [] test.c:11)) "test.c":11:5 -1
     (expr_list:REG_DEAD (reg/v:SI 92 [ g ])
        (nil)))

Then LRA reloads the address and we ICE because we fail to recognize the
sign_extract outside the mem:

(insn 33 8 34 3 (set (reg:DI 100)
        (sign_extract:DI (ashift:DI (subreg:DI (reg/v:SI 92 [ g ]) 0)
                (const_int 2 [0x2]))
            (const_int 34 [0x22])
            (const_int 0 [0]))) "test.c":11:5 -1
     (nil))

The aarch64 changes here remove the support for this sign_extract
representation of addresses, fixing PR96998. Now this by itself would
regress code quality, so this change is paired with an improvement to
combine which prevents an extract rtx from being emitted in this case:
we now write the rtx above as a shift of an extend, which allows the
combination to go ahead.

Prior to this, combine.c:make_extraction() identified where we can emit
an ashift of an extend in place of an extraction, but failed to make the
corresponding canonicalization/simplification when presented with a mult
by a power of two. Such a representation is canonical when representing
a left-shifted address inside a mem.

This change remedies this situation. For rtxes such as:

(mult:DI (subreg:DI (reg:SI r) 0) (const_int 2^n))

where the bottom 32 + n bits are valid (the higher-order bits are
undefined) and make_extraction() is being asked to sign_extract the
lower (valid) bits, after the patch, we rewrite this as:

(mult:DI (sign_extend:DI (reg:SI r)) (const_int 2^n))

instead of using a sign_extract.

gcc/ChangeLog:

PR target/96998
* combine.c (make_extraction): Also handle shifts written as
(mult x 2^n), avoid creating an extract rtx for these.
* config/aarch64/aarch64.c (aarch64_is_extend_from_extract): Delete.
(aarch64_classify_index): Remove extract-based address handling.
(aarch64_strip_extend): Likewise.
(aarch64_rtx_arith_op_extract_p): Likewise, remove now-unused parameter.
Update callers...
(aarch64_rtx_costs): ... here.

gcc/testsuite/ChangeLog:

PR target/96998
* gcc.c-torture/compile/pr96998.c: New test.

4 years agoPredefine __ppc and __ppc__ for VxWorks 7
Olivier Hainque [Wed, 28 Oct 2020 18:04:32 +0000 (18:04 +0000)]
Predefine __ppc and __ppc__ for VxWorks 7

Unfortunately, some VxWorks 7r2 system headers rely on a
couple more variations of the predefined macros expected
to characterize a "powerpc" target that we discussed recently.

setjmp.h, for example, relies on __ppc and the absence of
a definition results in "gcc" dejagnu test failures from all
the tests #including that header, which stumble on:

  #error "_JBLEN not set!"

The other case is __ppc__ expected by yvals.h, key to libstdc++.

This change adjusts the VxWorks 7 section of our configuration
to honor those expectations.

2020-10-29  Olivier Hainque  <hainque@adacore.com>

gcc/
* config/rs6000/vxworks.h (TARGET_OS_CPP_BUILTINS): Also
builtin_define __ppc and __ppc__ for VxWorks 7.

4 years agoIntroduce support for vxworks7r2 on x86 and x86_64
Olivier Hainque [Wed, 26 Feb 2020 13:47:43 +0000 (13:47 +0000)]
Introduce support for vxworks7r2 on x86 and x86_64

This change extends the VxWorks support on intel CPUs to
VxWorks7r2 for x86_64 as well as x86, with a "mcmodel=large"
additional multilib for the 64bit configuration.

The support for fPIC is not functional yet for this model,
so we just don't add the corresponding multilib.

We extend the range of CPU families handled by TARGET_OS_CPP_BUILTINS,
accounting for the fact that archs older than PENTIUM4 are
not supported (any more) by VxWorks 7.

As we did for powerpc, we leverage VX_CPU_PREFIX to emit different
forms of definitions for different families of VxWorks as the system
headers's expectations has evolved between Vx 5, 6 and 7.

2020-10-27  Olivier Hainque  <hainque@adacore.com>

gcc/
* config.gcc: Adjust the ix86/x86_64-wrs-vxworks filters
to apply to VxWorks 7 as well.
* config/i386/t-vxworks (MULTILIB_OPTIONS, MULTILIB_DIRNAMES):
Remove the fPIC multilib and add one for the large code model
on x86_64.
* config/i386/vxworks.h: Separate sections for TARGET_VXWORKS7,
other variants and common bits.
(TARGET_OS_CPP_BUILTINS): Augment to support a range of CPU
families. Leverage VX_CPU_PREFIX.
(CC1_SPEC): Add definition.
(STACK_CHECK_PROTECT): Use conditional expression instead of
heavier to read conditioned macro definitions.

libgcc/
* config.host: Adjust the ix86/x86_64-wrs-vxworks filters
to apply to VxWorks 7 as well.

Co-authored-by: Douglas Rupp <rupp@adacore.com>
Co-authored-by: Pat Bernardi <bernardi@adacore.com>
4 years agoopenmp: Fix handling of allocate clause on taskloop
Jakub Jelinek [Fri, 30 Oct 2020 08:18:36 +0000 (09:18 +0100)]
openmp: Fix handling of allocate clause on taskloop

This patch fixes gimplification of allocate clause on taskloop - puts
allocate on inner taskloop only if there is allocate clause, because otherwise
the data sharing clauses are only on the task construct in the construct sandwich.

2020-10-30  Jakub Jelinek  <jakub@redhat.com>

* gimplify.c (gimplify_scan_omp_clauses): Force
OMP_CLAUSE_ALLOCATE_ALLOCATOR into a temporary if it is non-NULL and
non-constant.
(gimplify_omp_for): Only put allocate on inner taskloop if lastprivate
for the same variable is going to be put there, and in that case
if the OMP_CLAUSE_ALLOCATE_ALLOCATOR is non-NULL non-constant, make
the allocator firstprivate on task.

* c-c++-common/gomp/allocate-3.c: New test.

4 years agoopenmp: Handle non-static data members in allocate clause and other C++ allocate...
Jakub Jelinek [Fri, 30 Oct 2020 08:16:45 +0000 (09:16 +0100)]
openmp: Handle non-static data members in allocate clause and other C++ allocate fixes

This allows specification of non-static data members in allocate clause like it
can be specified in other privatization clauses and adds a new testcase that covers
also handling of that clause in templates.

2020-10-30  Jakub Jelinek  <jakub@redhat.com>

* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_ALLOCATE>: Handle
non-static members in methods.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_ALLOCATE.

* c-c++-common/gomp/allocate-1.c (qux): Add another test.
* g++.dg/gomp/allocate-1.C: New test.

4 years agoAdjust gcc.dg/vect/bb-slp-pr65935.c
Richard Biener [Fri, 30 Oct 2020 08:13:24 +0000 (09:13 +0100)]
Adjust gcc.dg/vect/bb-slp-pr65935.c

This adjusts the testcase to allow splitting up the group for
larger vector sizes and thus printing the splat message multiple times.

2020-10-30  Richard Biener  <rguenther@suse.de>

* gcc.dg/vect/bb-slp-pr65935.c: Adjust.

4 years agoPowerPC: Adjust float128/ibm128 warnings.
Michael Meissner [Fri, 30 Oct 2020 02:15:10 +0000 (22:15 -0400)]
PowerPC: Adjust float128/ibm128 warnings.

This patch ccombines two patches:

1) If GLIBC is 2.32 or newer, and the language is C or C++, allow the user to
   change the long double type without having to use -Wno-psabi.

2) Adjust the warnings for intermixing __float128 and __ibm128 to accomidate
   the future change to allow long double to use the IEEE 128-bit format.

gcc/
2020-10-29  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/rs6000.c (rs6000_option_override_internal): Allow
long double type to be changed for C/C++ if glibc 2.32 or newer.
(rs6000_invalid_binary_op): Update error messages about mixing IBM
long double and IEEE 128-bit.

gcc/testsuite/
2020-10-27  Michael Meissner  <meissner@linux.ibm.com>

* gcc.target/powerpc/float128-mix-2.c: New test.
* gcc.target/powerpc/float128-mix-3.c: New test.
* gcc.target/powerpc/float128-mix.c: Update failure messages.

4 years agolibstdc++: AIX xfail for_overwrite.cc testcase
David Edelsohn [Thu, 29 Oct 2020 20:46:53 +0000 (16:46 -0400)]
libstdc++: AIX xfail for_overwrite.cc testcase

The 20_util/unique_ptr/creation/for_overwrite.cc testcase relies on
operator new, which requires special features on AIX.  This patch
disables the testcase.

libstdc++-v3/ChangeLog:

* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: XFAIL on AIX.

4 years agoDaily bump.
GCC Administrator [Fri, 30 Oct 2020 00:16:29 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Fix linker script to remove conflicting patterns
Jonathan Wakely [Thu, 29 Oct 2020 22:47:22 +0000 (22:47 +0000)]
libstdc++: Fix linker script to remove conflicting patterns

This should fix a bootstrap error on Solaris, due to some of the new
symbols matching old patterns as well as new ones.

libstdc++-v3/ChangeLog:

* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten patterns
for old <sstream> symbols some more.

4 years agolibstdc++: Avoid narrowing conversion in subrange constructor
Jonathan Wakely [Thu, 29 Oct 2020 22:47:22 +0000 (22:47 +0000)]
libstdc++: Avoid narrowing conversion in subrange constructor

libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h (subrange::subrange(R&&)): Use
direct-initialization instead of list-initialization, so a
potential narrowing conversion from ranges::size(r) to the
stored size isn't ill-formed.

4 years agolibstdc++: Fix some warnings in headers
Jonathan Wakely [Thu, 29 Oct 2020 22:47:22 +0000 (22:47 +0000)]
libstdc++: Fix some warnings in headers

These are usually suppressed in system headers, but should be fixed
anyway.

libstdc++-v3/ChangeLog:

* include/bits/parse_numbers.h (_Select_int_base): Avoid
narrowing conversion in constant expression.
* include/experimental/buffer (buffer_copy): Avoid narrowing
conversion.
* include/experimental/internet (hash<>::operator()): Do not
use deprecated 'argument_type' member.
* include/std/variant (variant::emplace): Use cast instead
of implicit conversion from size_t to narrower unsigned type.

4 years agolibstdc++: Prevent deprecation warnings from <tr1/shared_ptr>
Jonathan Wakely [Thu, 29 Oct 2020 22:47:22 +0000 (22:47 +0000)]
libstdc++: Prevent deprecation warnings from <tr1/shared_ptr>

libstdc++-v3/ChangeLog:

* include/tr1/shared_ptr.h (__shared_count, __shared_ptr)
(shared_ptr): Add diagnostic pragmas around uses of auto_ptr.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
Adust dg-error line numbers.

4 years agolibstdc++: Avoid warnings in tests
Jonathan Wakely [Thu, 29 Oct 2020 22:47:21 +0000 (22:47 +0000)]
libstdc++: Avoid warnings in tests

This fixes some warnings emitted when testing with warning flags added.
Some of these are only necessary when testing with -Wsystem-headers, but
either way it cleans up the tests to be less noisy under non-default
flags.

libstdc++-v3/ChangeLog:

* testsuite/18_support/96817.cc: Avoid -Wunused warnings.
* testsuite/20_util/any/assign/2.cc: Likewise.
* testsuite/20_util/any/cons/2.cc: Likewise.
* testsuite/20_util/align/1.cc: Avoid -Wsign-compare warning.
* testsuite/20_util/function/65760.cc: Avoid -Wunused warning.
* testsuite/20_util/function/1.cc: Avoid -Wcatch-value warning.
* testsuite/20_util/function/cons/move_target.cc: Avoid -Wunused
warning.
* testsuite/20_util/headers/memory/synopsis.cc: Add exception
specification.
* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Avoid
-Wsign-compare warning.
* testsuite/20_util/tuple/cons/deduction.cc: Avoid -Wunused
warning.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc:
Avoid -Wdeprecated-copy warning.
* testsuite/21_strings/basic_string/56166.cc: Avoid
-Wcatch-value warning.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
Avoid -Wcatch-value warnings.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc:
Prune additional diagnostics.
* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Add exception
specifications.
* testsuite/22_locale/locale/cons/12352.cc: Define sized
delete operators to avoid warnings.
* testsuite/23_containers/deque/modifiers/swap/1.cc: Add
exception specification.
* testsuite/23_containers/forward_list/cons/11.cc: Avoid
-Wdeprecated-copy warning.
* testsuite/23_containers/headers/bitset/synopsis.cc: Add
exception specification.
* testsuite/23_containers/headers/deque/synopsis.cc: Likewise.
* testsuite/23_containers/headers/forward_list/synopsis.cc:
Likewise.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/23_containers/headers/map/synopsis.cc: Likewise.
* testsuite/23_containers/headers/queue/synopsis.cc: Likewise.
* testsuite/23_containers/headers/set/synopsis.cc: Likewise.
* testsuite/23_containers/headers/vector/synopsis.cc: Likewise.
* testsuite/23_containers/list/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/map/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/multimap/modifiers/swap/1.cc:
Likewise.
* testsuite/23_containers/multiset/modifiers/swap/1.cc:
Likewise.
* testsuite/23_containers/set/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/unordered_set/56267-2.cc: Avoid
-Wdeprecated-copy warning.
* testsuite/23_containers/vector/bool/23632.cc: Avoid
-Wempty-body warning.
* testsuite/23_containers/vector/modifiers/swap/1.cc: Add
exception specification.
* testsuite/25_algorithms/heap/moveable2.cc: Fix misplaced
parentheses around arguments.
* testsuite/25_algorithms/sample/1.cc: Use return value.
* testsuite/25_algorithms/search/searcher.cc: Avoid -Wunused
warnings.
* testsuite/27_io/basic_ostream/exceptions/char/9561.cc:
Likewise.
* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc:
Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc: Avoid
-Wsign-compare warning.
* testsuite/experimental/any/assign/2.cc: Avoid -Wunused warnings.
* testsuite/experimental/any/cons/2.cc: Likewise.
* testsuite/experimental/filesystem/operations/remove_all.cc:
Avoid -Wign-compare warning.
* testsuite/experimental/memory/observer_ptr/cons/cons.cc:
Likewise.
* testsuite/experimental/memory_resource/null_memory_resource.cc:
Likewise.
* testsuite/experimental/source_location/1.cc: Avoid -Waddress
warning.
* testsuite/ext/pod_char_traits.cc: Avoid -Wunused warning.
* testsuite/ext/vstring/modifiers/clear/56166.cc: Avoid
-Wcatch-value.
* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
Avoid -Wunused warning.
* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
Likewise.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
Prune additional warnings.
* testsuite/tr1/3_function_objects/function/1.cc: Avoid
-Wcatch-value warning.
* testsuite/util/replacement_memory_operators.h: Define sized
delete to avoid warnings.
* testsuite/util/testsuite_api.h (_NonDefaultConstructible): Add
user-declared assignment operator to stop -Wdeprecated-copy
warnings.
* testsuite/util/testsuite_containers.h: Avoid -Wunused warning.
* testsuite/util/testsuite_iterators.h: Avoid -Wsign-compare
warnings.
* testsuite/util/testsuite_new_operators.h: Define sized deleted.

4 years agoc++: Implement CWG 625: Use of auto as template-arg [PR97479]
Marek Polacek [Mon, 26 Oct 2020 21:35:56 +0000 (17:35 -0400)]
c++: Implement CWG 625: Use of auto as template-arg [PR97479]

This patch implements CWG 625 which prohibits using auto in a template
argument.  A few tests used this construction.  Since this usage was
allowed by the Concepts TS, we only give an error in C++20.

gcc/cp/ChangeLog:

DR 625
PR c++/97479
* parser.c (cp_parser_type_id_1): Reject using auto as
a template-argument in C++20.

gcc/testsuite/ChangeLog:

DR 625
PR c++/97479
* g++.dg/cpp0x/auto3.C: Update dg-error.
* g++.dg/cpp0x/auto9.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-2.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-3.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979.C: Likewise.
* g++.dg/DRs/dr625.C: New test.

4 years agoReplace free with XDELETE.
Asher Gordon [Thu, 29 Oct 2020 21:01:07 +0000 (21:01 +0000)]
Replace free with XDELETE.

gcc/c/ChangeLog:

* c-typeck.c (free_all_tagged_tu_seen_up_to): Replace free
with XDELETE.
(finish_init): Likewise.
(pop_init_level): Likewise.

4 years agoc++: Deducing type from initializer_list<auto> [PR93107]
Marek Polacek [Fri, 16 Oct 2020 15:00:12 +0000 (11:00 -0400)]
c++: Deducing type from initializer_list<auto> [PR93107]

In this testcase we weren't able to deduce b's type:

  template<typename T> void Task() { }
  auto b = { &Task<int> };

because resolve_nondeduced_context doesn't iterate on the {}'s elements.
So make sure to look into {} too.  We don't need to handle nested {}
here.

We could either tweak resolve_nondeduced_context to handle CONSTRUCTORs
or add a _ctor version, but then resolve_nondeduced_context_or_error
would need some changes too -- it'd have to check the result of a call
to r_n_c for each element.

gcc/cp/ChangeLog:

PR c++/93107
* pt.c (do_auto_deduction): Call resolve_nondeduced_context for
the elements of a { } list.

gcc/testsuite/ChangeLog:

PR c++/93107
* g++.dg/cpp0x/initlist-deduce3.C: New test.

4 years agoc++: Reject float <=> enum.
Marek Polacek [Wed, 28 Oct 2020 23:02:29 +0000 (19:02 -0400)]
c++: Reject float <=> enum.

As [depr.arith.conv.enum] says, these are ill-formed.

gcc/cp/ChangeLog:

* typeck.c (do_warn_enum_conversions): Don't warn for SPACESHIP_EXPR.
(cp_build_binary_op): Reject float <=> enum or enum <=> float.  Use
CP_INTEGRAL_TYPE_P instead of INTEGRAL_OR_ENUMERATION_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/enum-conv1.C: Remove unused code.
* g++.dg/cpp2a/spaceship-err5.C: New test.

4 years agoc++: Simplify constraint normalization routines
Patrick Palka [Thu, 29 Oct 2020 18:03:03 +0000 (14:03 -0400)]
c++: Simplify constraint normalization routines

Many of the high-level constraint normalization routines allow the
caller to supply the initial template arguments for normalization, but
in practice all of the callers supply something equivalent to the
identity mapping(*).

This patch hard-codes this prevalent choice of initial template
arguments by making get_normalized_constraints always pass NULL_TREE as
the args to normalize_expression.  This admits some simplifications in
the high-level routines, such as removing their 'args' parameter and
consolidating the two versions of normalize_constraint_expression.

(*): In particular, a set of generic template arguments or NULL_TREE.
In the case of the two-parm version of normalize_constraint_expression,
we were suspiciously using the template arguments of a concept-id when
normalizing the concept-id as a constraint-expression.

gcc/cp/ChangeLog:

* constraint.cc (get_normalized_constraints): Remove 'args'
parameter.  Pass NULL_TREE as the initial template arguments to
normalize_expression.
(get_normalized_constraints_from_info): Remove 'args' parameter
and adjust the call to get_normalized_constraints.
(get_normalized_constraints_from_decl): Remove 'args' local
variable and adjust call to get_normalized_constraints_from_info.
(normalize_concept_definition): Remove 'args' local variable
and adjust call to get_normalized_constraints.
(normalize_constraint_expression): Remove the two-parameter
overload.  Remove 'args' parameter from the three-parameter
overload and update function comment accordingly.  Remove
default argument from 'diag' parameter.  Adjust call to
get_normalized_constraints.
(finish_nested_requirement): Adjust call to
normalize_constraint_expression.
(strictly_subsumes): Remove 'args' parameter.  Adjust call to
get_normalized_constraints_from_info.
(weakly_subsumes): Likewise.
* cp-tree.h (strictly_subsumes): Remove 'args' parameter.
(weakly_subsumes): Likewise.
* pt.c (process_partial_specialization): Adjust call to
strictly_subsumes.
(is_compatible_template_arg): Adjust call to weakly_subsumes.

4 years agoc++: Tolerate empty initial args during normalization [PR97412]
Patrick Palka [Thu, 29 Oct 2020 18:02:59 +0000 (14:02 -0400)]
c++: Tolerate empty initial args during normalization [PR97412]

When normalizing the constraint-expression of a nested-requirement, we
pass NULL_TREE as the initial template arguments for normalization, but
tsubst_argument_pack is not prepared to handle a NULL_TREE args vector.
This causes us to ICE when normalizing a variadic concept as part of a
nested-requirement.

This patch fixes the ICE by guarding the call to tsubst_template_args in
normalize_concept_check appropriately.  This will also enable us to
simplify many of the normalization routines to just pass NULL_TREE
(instead of a set of generic template arguments) as the initial template
arguments.

gcc/cp/ChangeLog:

PR c++/97412
* constraint.cc (normalize_concept_check): Don't call
tsubst_template_args when 'args' is NULL.

gcc/testsuite/ChangeLog:

PR c++/97412
* g++.dg/cpp2a/concepts-variadic2.C: New test.

4 years agoFix some memleaks
Richard Biener [Thu, 29 Oct 2020 16:02:13 +0000 (17:02 +0100)]
Fix some memleaks

This fixes some memleaks, one older, one recently introduced.

2020-10-29  Richard Biener  <rguenther@suse.de>

* tree-ssa-pre.c (compute_avail): Free operands consistently.
* tree-vect-loop.c (vectorizable_phi): Make sure all operand
defs vectors are released.

4 years agoc++: Fix constexpr cleanup error handling.
Jason Merrill [Wed, 28 Oct 2020 21:30:05 +0000 (17:30 -0400)]
c++: Fix constexpr cleanup error handling.

In this testcase, the primary evaluation successfully produces 'true', and
then running one of the cleanups hits a double delete, making the whole
thing not a valid constant expression.  So we were returning 'true' wrapped
in a NOP_EXPR to indicate its non-constancy, but evaluating that again is a
perfectly acceptable constant expression, so we weren't getting the verbose
diagnostic we were looking for.

So if non_constant_p gets set other than for overflow, go back to the
original expression.

With this change, we should never hit the manifestly_const_eval test, and
the is-constant-evaluated1.C test passes without it.

gcc/cp/ChangeLog:

PR c++/97388
* constexpr.c (cxx_eval_outermost_constant_expr): Revert to
original expression if evaluation sets non_constant_p.

gcc/testsuite/ChangeLog:

PR c++/97388
* g++.dg/cpp2a/constexpr-dtor8.C: New test.

4 years agoc++: Fix constexpr dtors vs invisible ref [PR97388]
Jakub Jelinek [Tue, 20 Oct 2020 07:33:20 +0000 (09:33 +0200)]
c++: Fix constexpr dtors vs invisible ref [PR97388]

For arguments passed by invisible reference, in the IL until genericization
we have the source types on the callee side and while on the caller side
we already pass references to the actual argument slot in the caller, we
undo that in cxx_bind_parameters_in_call's
      if (TREE_ADDRESSABLE (type))
        /* Undo convert_for_arg_passing work here.  */
        x = convert_from_reference (x);
This works fine most of the time, except when the type also has constexpr
destructor; in that case the destructor is invoked in the caller and thus
the unsharing we do to make sure that the callee doesn't modify caller's
values is in that case undesirable, it prevents the changes done in the
callee propagating to the caller which should see them for the constexpr
dtor evaluation.

The following patch fixes that.  While it could be perhaps done for all
TREE_ADDRESSABLE types, I don't see the need to change the behavior
if there is no constexpr non-trivial dtor.

Jason: And we need to avoid memoizing the call, because a later equivalent
call also needs to modify its argument.  And we don't need to unshare
constructors when we aren't memoizing the call, because we already unshared
them when evaluating the TARGET_EXPR representing the copy-initialization of
the argument.

2020-10-20  Jakub Jelinek  <jakub@redhat.com>
    Jason Merrill  <jason@redhat.com>

PR c++/97388
* constexpr.c (cxx_bind_parameters_in_call): Set non_constant_args
if the parameter type has a non-trivial destructor.
(cxx_eval_call_expression): Only unshare arguments if we're
memoizing this evaluation.

* g++.dg/cpp2a/constexpr-dtor5.C: New test.
* g++.dg/cpp2a/constexpr-dtor6.C: New test.
* g++.dg/cpp2a/constexpr-dtor7.C: New test.

4 years agoAnnotate vec::copy better for mem stats
Jan Hubicka [Thu, 29 Oct 2020 17:03:29 +0000 (18:03 +0100)]
Annotate vec::copy better for mem stats

* vec.h (vec<T, va_heap, vl_ptr>::copy): Pass mem stat info.

4 years agoAvoid typeless storage in wide-int
Jan Hubicka [Thu, 29 Oct 2020 15:44:48 +0000 (16:44 +0100)]
Avoid typeless storage in wide-int

* wide-int.h (trailing_wide_ints <N>): Turn len to array of structures
so it does not imply typeless storage.
(trailing_wide_ints <N>::operator): update
(trailing_wide_ints <N>::operator []): Update.

4 years agoc++: Diagnose constexpr delete [] new int; and delete new int[N]; [PR95808]
Jakub Jelinek [Thu, 29 Oct 2020 15:27:01 +0000 (16:27 +0100)]
c++: Diagnose constexpr delete [] new int; and delete new int[N]; [PR95808]

This patch diagnoses delete [] new int; and delete new int[1]; in constexpr
contexts by remembering
IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (fun)) & OVL_OP_FLAG_VEC
from the operator new and checking it at operator delete time.

2020-10-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/95808
* cp-tree.h (enum cp_tree_index): Add CPTI_HEAP_VEC_UNINIT_IDENTIFIER
and CPTI_HEAP_VEC_IDENTIFIER.
(heap_vec_uninit_identifier, heap_vec_identifier): Define.
* decl.c (initialize_predefined_identifiers): Initialize those
identifiers.
* constexpr.c (cxx_eval_call_expression): Reject array allocations
deallocated with non-array deallocation or non-array allocations
deallocated with array deallocation.
(non_const_var_error): Handle heap_vec_uninit_identifier and
heap_vec_identifier too.
(cxx_eval_constant_expression): Handle also heap_vec_uninit_identifier
and in that case during initialization replace it with
heap_vec_identifier.
(find_heap_var_refs): Handle heap_vec_uninit_identifier and
heap_vec_identifier too.

* g++.dg/cpp2a/constexpr-new15.C: New test.

4 years agostdbool.h: Update true and false expansions for C2x
Joseph Myers [Thu, 29 Oct 2020 15:05:33 +0000 (15:05 +0000)]
stdbool.h: Update true and false expansions for C2x

C2x has changed the expansions of the true and false macros in
<stdbool.h> so that they have type _Bool (including in #if conditions,
i.e. an unsigned type in that context).  Use the new expansions in
GCC's <stdbool.h> for C2x.

See bug 82272 for related discussion (but this patch does *not*
implement the warning discussed there).

Note that it's possible there may be a further change to make bool,
true and false keywords (there was support in principle for that at
the April WG14 meeting).  But currently these expansions of type _Bool
are what C2x requires and there isn't actually a paper before WG14 at
present that would introduce the new keywords.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/
2020-10-29  Joseph Myers  <joseph@codesourcery.com>

* ginclude/stdbool.h [__STDC_VERSION__ > 201710L] (true, false):
Define with type _Bool.

gcc/testsuite/
2020-10-29  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/c11-bool-1.c, gcc.dg/c2x-bool-1.c, gcc.dg/c99-bool-4.c:
New tests.

4 years agolibstdc++: Improve tests for constexpr algorithms
Jonathan Wakely [Thu, 29 Oct 2020 14:47:18 +0000 (14:47 +0000)]
libstdc++: Improve tests for constexpr algorithms

These tests just return true without checking that the results of the
algorithms. Although it should be safe to assume that the algorithms
behave the same at compile-time as at run-time, we can use these tests
to verify it.

This replaces each 'return true' statement with a condition that depends
on the basic functionality of the algorithm, such as returning an
iterator to the right position.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/all_of/constexpr.cc: Check result of
the algorithm.
* testsuite/25_algorithms/any_of/constexpr.cc: Likewise.
* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
* testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise.
* testsuite/25_algorithms/count/constexpr.cc: Likewise.
* testsuite/25_algorithms/equal/constexpr.cc: Likewise.
* testsuite/25_algorithms/equal_range/constexpr.cc: Likewise.
* testsuite/25_algorithms/fill/constexpr.cc: Likewise.
* testsuite/25_algorithms/find_end/constexpr.cc: Likewise.
* testsuite/25_algorithms/find_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_permutation/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lower_bound/constexpr.cc: Likewise.
* testsuite/25_algorithms/merge/constexpr.cc: Likewise.
* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
* testsuite/25_algorithms/none_of/constexpr.cc: Likewise.
* testsuite/25_algorithms/partition_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/replace_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/reverse/constexpr.cc: Likewise.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/search/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_intersection/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.

4 years agolibstdc++: Allow Lemire's algorithm to be used in more cases
Jonathan Wakely [Thu, 29 Oct 2020 14:47:18 +0000 (14:47 +0000)]
libstdc++: Allow Lemire's algorithm to be used in more cases

This extends the fast path to also work when the URBG's range of
possible values is not the entire range of its result_type. Previously,
the slow path would be used for engines with a uint_fast32_t result type
if that type is actually a typedef for uint64_t rather than uint32_t.
After this change, the generator's result_type is not important, only
the range of possible value that generator can produce. If the
generator's range is exactly UINT64_MAX then the calculation will be
done using 128-bit and 64-bit integers, and if the range is UINT32_MAX
it will be done using 64-bit and 32-bit integers.

In practice, this benefits most of the engines and engine adaptors
defined in [rand.predef] on x86_64-linux and other 64-bit targets. This
is because std::minstd_rand0 and std::mt19937 and others use
uint_fast32_t, which is a typedef for uint64_t.

The code now makes use of the recently-clarified requirement that the
generator's min() and max() functions are usable in constant
expressions (see LWG 2154).

libstdc++-v3/ChangeLog:

* include/bits/uniform_int_dist.h (_Power_of_two): Add
constexpr.
(uniform_int_distribution::_S_nd): Add static_assert to ensure
the wider type is twice as wide as the result type.
(uniform_int_distribution::__generate_impl): Add static_assert
and declare variables as constexpr where appropriate.
(uniform_int_distribution:operator()): Likewise. Only consider
the uniform random bit generator's range of possible results
when deciding whether _S_nd can be used, not the __uctype type.

4 years agolibstdc++: Do not use volatile for __gnu_cxx::rope reference counting
Jonathan Wakely [Thu, 29 Oct 2020 14:47:17 +0000 (14:47 +0000)]
libstdc++: Do not use volatile for __gnu_cxx::rope reference counting

The rope extension uses a volatile variable for its reference count.
This is not only unnecessary for correctness (volatile provides neither
atomicity nor memory visibility, and the variable is only modified while
a lock is held) but it now causes deprecated warnings with
-Wsystem-headers due to the use of ++ and -- operators.

It would be possible to use __gnu_cxx::__exchange_and_add in _M_incr and
_M_decr when __atomic_is_lock_free(sizeof(_RC_t), &_M_ref_count) is
true, rather than locking a mutex. That would probably be a significant
improvement for multi-threaded and single-threaded code (because
__exchange_and_add will use non-atomic ops when possible, and even in MT
code it should be faster than the mutex lock/unlock pair). However,
mixing objects compiled with the old and new code would result in
inconsistent synchronization being used for the reference count.

libstdc++-v3/ChangeLog:

* include/ext/rope (_Refcount_Base::_M_ref_count): Remove
volatile qualifier.
(_Refcount_Base::_M_decr()): Likewise.

4 years agolibstdc++: Make std::function work better with -fno-rtti
Jonathan Wakely [Thu, 29 Oct 2020 14:47:17 +0000 (14:47 +0000)]
libstdc++: Make std::function work better with -fno-rtti

This change allows std::function::target<F>() to work even without RTTI,
using the same approach as std::any. Because we know what the manager
function would be for a given type, we can check if the stored pointer
has the expected address. If it does, we don't need to use RTTI. If it
isn't equal, we still need to do the RTTI check (when RTTI is enabled)
to handle the case where the same function has different addresses in
different shared objects.

This also changes the implementation of the manager function to return a
null pointer result when asked for the type_info of the target object.
This not only avoids a warning with -Wswitch -Wsystem-headers, but also
avoids prevents std::function::target_type() from dereferencing an
uninitialized pointer when the linker keeps an instantiation of the
manager function that was compiled without RTTI.

Finally, this fixes a bug in the non-const overload of function::target
where calling it with a function type F was ill-formed, due to
attempting to use const_cast<F*>(ptr). The standard only allows
const_cast<T*> when T is an object type.  The solution is to use
*const_cast<F**>(&ptr) instead, because F* is an object type even if F
isn't. I've also used _GLIBCXX17_CONSTEXPR in function::target so that
it doesn't bother instantiating anything for types that can never be a
valid target.

libstdc++-v3/ChangeLog:

* include/bits/std_function.h (_Function_handler<void, void>):
Define explicit specialization used for invalid target types.
(_Base_manager::_M_manager) [!__cpp_rtti]: Return null.
(function::target_type()): Check for null pointer.
(function::target()): Define unconditionall. Fix bug with
const_cast of function pointer type.
(function::target() const): Define unconditionally, but
only use RTTI if enabled.
* testsuite/20_util/function/target_no_rtti.cc: New test.

4 years agoSelectively trap if ranger and vr-values disagree on range builtins.
Aldy Hernandez [Thu, 22 Oct 2020 06:39:04 +0000 (08:39 +0200)]
Selectively trap if ranger and vr-values disagree on range builtins.

The UBSAN builtins degrade into PLUS/MINUS/MULT and call
extract_range_from_binary_expr, which as the PR shows, can special
case some symbolics which the ranger doesn't currently handle.

Looking at vr_values::extract_range_builtin(), I see that every single
place where we ask for a range, we bail on non-integers (symbolics,
etc).  That is, with the exception of the UBSAN builtins.

Since this seems to be particular to UBSAN, we could still go with the
original plan of removing the duplicity in ranger vs vr-values, but
leave in the UBSAN builtin handling.  This isn't ideal, as we'd like
to remove all the common code, but I'd be willing to put up with UBSAN
duplication for the time being.

This patch disables the assert on the UBSAN builtins, while still
trapping if any other differences are found between the vr_values and
the ranger versions of builtin range handling.

As a follow-up, once Fedora can test this approach, I'll remove all
the builtin code from extract_range_builtin, with the exception of the
UBSAN stuff (renaming it to extract_range_ubsan_builtin).

Since the builtin code has proven fickle across architectures, I've
tested this with {-m32,-m64,-fsanitize=signed-integer-overflow} on
x86, ppc64le, and aarch64.  I think this should be enough.  If it
isn't, we can revert the patch, and leave the duplicate code until
the next release cycle when hopefully vr_values, evrp, and friends
will all be overhauled.

gcc/ChangeLog:

PR tree-optimization/97505
* vr-values.c (vr_values::extract_range_basic): Enable
trap again for everything except UBSAN builtins.

4 years ago * gcc.dg/pr97596.c: Require int128 effective target.
Jakub Jelinek [Thu, 29 Oct 2020 14:21:32 +0000 (15:21 +0100)]
* gcc.dg/pr97596.c: Require int128 effective target.

4 years agoAdd testcase for PR97596
Andrew MacLeod [Thu, 29 Oct 2020 14:14:10 +0000 (10:14 -0400)]
Add testcase for PR97596

Add testcase

gcc/testsuite
* gcc.dg/pr97596.c: New.

4 years agoc++: Stop (most) function-scope entities having a template header
Nathan Sidwell [Thu, 29 Oct 2020 11:56:27 +0000 (04:56 -0700)]
c++: Stop (most) function-scope entities having a template header

Currently push_template_decl (mostly) decides whether to add a
template header to an entity by seeing if it has DECL_LANG_SPECIFIC.
That might have been a useful predicate at one time, but basing
semantic implications on how we've decided to represent decls is bound
to be brittle.  And indeed it is, as more decls grow a use for
lang-specific.  In particular I discovered that function-scope
VAR_DECLs couild grow lang-specific, and thereby get a template
header.  There's no need for that, and it breaks an invariant modules
was expected.

This patch changes that, and bases the descision on the properties of
the decl.  In particular the only function-scope decl that gets a
template header is an implicit-typedef.

I also cleaned up the behaviour of it building a template-info only to
ignore it.

gcc/cp/
* pt.c (push_template_decl): Do not give function-scope entities
other than implicit typedefs a template header. Do not readd
template info to a redeclared template.

4 years agolibstdc++: Fix memory issue in ranges::lexicographical_compare testcase
Patrick Palka [Thu, 29 Oct 2020 14:11:12 +0000 (10:11 -0400)]
libstdc++: Fix memory issue in ranges::lexicographical_compare testcase

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
(test03): Fix initializing the vector vy with the array y of size 4.

4 years agovect: Fix load costs for SLP permutes
Richard Sandiford [Thu, 29 Oct 2020 13:38:01 +0000 (13:38 +0000)]
vect: Fix load costs for SLP permutes

For the following test case (compiled with load/store lanes
disabled locally):

  void
  f (uint32_t *restrict x, uint8_t *restrict y, int n)
  {
    for (int i = 0; i < n; ++i)
      {
x[i * 2] = x[i * 2] + y[i * 2];
x[i * 2 + 1] = x[i * 2 + 1] + y[i * 2];
      }
  }

we have a redundant no-op permute on the x[] load node:

   node 0x4472350 (max_nunits=8, refcnt=2)
          stmt 0 _5 = *_4;
          stmt 1 _13 = *_12;
          load permutation { 0 1 }

Then, when costing it, we pick a cost of 1, even though we need 4 copies
of the x[] load to match a single y[] load:

   ==> examining statement: _5 = *_4;
   Vectorizing an unaligned access.
   vect_model_load_cost: unaligned supported by hardware.
   vect_model_load_cost: inside_cost = 1, prologue_cost = 0 .

The problem is that the code only considers the permutation for
the first scalar iteration, rather than for all VF iterations.

This patch tries to fix that by making vect_transform_slp_perm_load
calculate the value instead.

gcc/
* tree-vectorizer.h (vect_transform_slp_perm_load): Take an
optional extra parameter.
* tree-vect-slp.c (vect_transform_slp_perm_load): Calculate
the number of loads as well as the number of permutes, taking
the counting loop from...
* tree-vect-stmts.c (vect_model_load_cost): ...here.  Use the
value computed by vect_transform_slp_perm_load for ncopies.

4 years agoLTO: get_section: add new argument
Martin Liska [Wed, 21 Oct 2020 09:11:03 +0000 (11:11 +0200)]
LTO: get_section: add new argument

gcc/ChangeLog:

PR lto/97508
* langhooks.c (lhd_begin_section): Call get_section with
not_existing = true.
* output.h (get_section): Add new argument.
* varasm.c (get_section): Fail when NOT_EXISTING is true
and a section already exists.
* ipa-cp.c (ipcp_write_summary): Remove.
(ipcp_read_summary): Likewise.
* ipa-fnsummary.c (ipa_fn_summary_read): Always read jump
functions summary.
(ipa_fn_summary_write): Always stream it.

4 years agolibstdc++: Correct PR number in ChangeLog entry
Patrick Palka [Thu, 29 Oct 2020 13:27:04 +0000 (09:27 -0400)]
libstdc++: Correct PR number in ChangeLog entry

4 years agoConsistently pass the vector type for scalar SLP cost compute
Richard Biener [Thu, 29 Oct 2020 11:21:41 +0000 (12:21 +0100)]
Consistently pass the vector type for scalar SLP cost compute

This avoids randomly (based on whether the stmt is
SLP_TREE_REPRESENTATIVE and not a pattern stmt) passing a vector
type or NULL to the add_stmt_cost hook for scalar code cost
compute.  For example the x86 backend uses only the vector type to
decide on the scalar computation mode which makes costing off.

So the following explicitely passes the vector type and uses
SLP_TREE_VECTYPE for this purpose.

2020-10-29  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_bb_slp_scalar_cost): Pass
SLP_TREE_VECTYPE to record_stmt_cost.

4 years agolibstdc++: Fix some warnings in headers
Jonathan Wakely [Thu, 29 Oct 2020 11:43:55 +0000 (11:43 +0000)]
libstdc++: Fix some warnings in headers

These are usually suppressed without -Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/hashtable_policy.h (_Local_iterator_base): Cast
value to avoid -Wsign-compare warnings.
* include/bits/regex.h (sub_match::_M_str): Avoid narrowing
conversion.
* include/bits/regex_compiler.tcc (_Compiler::_M_quantifier):
Initialize variable to avoid -Wmaybe-uninitialized warning.
* include/bits/shared_ptr_base.h (_Sp_counted_deleter::_Impl):
Reorder mem-initializer-list to avoid -Wreorder warning.
* include/bits/stl_tree.h (_Rb_tree_impl): Explicitly
initialize base class in copy constructor.
* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
* include/ext/debug_allocator.h: Reorder mem-initializer-list
to avoid -Wreorder warning.
* include/ext/throw_allocator.h (throw_allocator_limit)
(throw_allocator_random): Add user-declared assignment operators
to avoid -Wdeprecated-copy warnings.

4 years agoFix the logic conditioning VX_ENTER/LEAVE_TLS_DTOR
Olivier Hainque [Wed, 28 Oct 2020 11:24:56 +0000 (11:24 +0000)]
Fix the logic conditioning VX_ENTER/LEAVE_TLS_DTOR

Fix a basic #if/#ifdef confusion which leads to improper
choices in some configurations.

2020-10-28  Olivier Hainque  <hainque@adacore.com>

libgcc/
* config/gthr-vxworks-tls.c: Fix preprocessor logic
controlling the definition of VX_ENTER_TLS_DTOR and
VX_LEAVE_TLS_DTOR based on a version major check.

4 years agoFix conditional inclusion guard in gthr-vxworks-thread.c
Olivier Hainque [Wed, 28 Oct 2020 11:16:57 +0000 (11:16 +0000)]
Fix conditional inclusion guard in gthr-vxworks-thread.c

This fixes the name of the macro used to condition the
inclusion of an actual implementation of some of the gthread
support services for VxWorks, to agree with the side
defining that macro based on tests against the targetted
VxWorks version major.

2020-10-28  Olivier Hainque  <hainque@adacore.com>

libgcc/
* config/gthr-vxworks-thread.c: Fix name of macro used
to condition the inclusion of an actual implementation.

4 years agoopts: Sanity check for param names.
Martin Liska [Thu, 29 Oct 2020 10:51:49 +0000 (11:51 +0100)]
opts: Sanity check for param names.

gcc/ChangeLog:

* optc-gen.awk: Check that params start with -param=.
* params.opt: Fix ipa-jump-function-lookups.

4 years agoCSE conversions within sincos
Alexandre Oliva [Thu, 29 Oct 2020 09:30:50 +0000 (06:30 -0300)]
CSE conversions within sincos

On platforms in which Aux_[Real_Type] involves non-NOP conversions
(e.g., between single- and double-precision, or between short float
and float), the conversions before the calls are CSEd too late for
sincos to combine calls.

This patch enables the sincos pass to CSE type casts used as arguments
to eligible calls before looking for other calls using the same
operand.

for  gcc/ChangeLog

* tree-ssa-math-opts.c (sincos_stats): Add conv_removed.
(execute_cse_conv_1): New.
(execute_cse_sincos_1): Call it.  Fix return within
FOR_EACH_IMM_USE_STMT.
(pass_cse_sincos::execute): Report conv_inserted.

for  gcc/testsuite/ChangeLog

* gnat.dg/sin_cos.ads: New.
* gnat.dg/sin_cos.adb: New.
* gcc.dg/sin_cos.c: New.

4 years agolibstdc++: Rename _UniformRandomNumberGenerator parameters
Jonathan Wakely [Thu, 29 Oct 2020 09:09:44 +0000 (09:09 +0000)]
libstdc++: Rename _UniformRandomNumberGenerator parameters

The paper P0346R1 renamed uniform random number generators to
uniform random bit generators, to describe their purpose more
accurately. This makes that same change in one of the relevant
files (but not the others).

libstdc++-v3/ChangeLog:

* include/bits/uniform_int_dist.h (uniform_int_distribution):
Rename _UniformRandomNumberGenerator template parameters to
_UniformRandomBitGenerator, as per P0346R1.

4 years agoEnable GCC to support Intel Key Locker ISA
liuhongt [Thu, 5 Mar 2020 09:36:02 +0000 (17:36 +0800)]
Enable GCC to support Intel Key Locker ISA

gcc/ChangeLog

2018-12-15  Xuepeng Guo  <xuepeng.guo@intel.com>
    Hongyu Wang  <hongyu.wang@intel.com>
    Hongtao Liu  <hongtao.liu@intel.com>

* common/config/i386/cpuinfo.h (get_available_features):
Detect KL, AESKLE and WIDEKL features.
* common/config/i386/i386-common.c
(OPTION_MASK_ISA_KL_SET): New.
(OPTION_MASK_ISA_WIDEKL_SET): Likewise.
(OPTION_MASK_ISA_KL_UNSET): Likewise.
(OPTION_MASK_ISA_WIDEKL_UNSET): Likewise.
(OPTION_MASK_ISA2_AVX2_UNSET): Likewise.
(OPTION_MASK_ISA2_AVX_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE4_2_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE4_1_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE4_UNSET): Likewise.
(OPTION_MASK_ISA2_SSSE3_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE3_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE2_UNSET): Likewise.
(OPTION_MASK_ISA2_SSE_UNSET): Likewise.
(ix86_handle_option): Handle kl and widekl, add dependency chain
for KL and SSE2.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
(FEATURE_KL, FEATURE_AESKLE, FEATURE_WIDEKL): New.
* common/config/i386/i386-isas.h: Add ISA_NAMES_TABLE_ENTRY
for KL, AESKLE and WIDEKL.
* config.gcc: Add keylockerintrin.h.
* doc/invoke.texi: Document new option -mkl and -mwidekl.
* doc/extend.texi: Document kl and widekl.
* config/i386/cpuid.h (bit_KL, bit_AESKLE, bit_WIDEKL): New.
* config/i386/i386-builtin-types.def ((UINT, UINT, V2DI, V2DI, PVOID),
(UINT, UINT, V2DI, PVOID), (VOID, V2DI, V2DI, V2DI, UINT),
(UINT8, PV2DI, V2DI, PCVOID), (UINT8, PV2DI, PCV2DI, PCVOID)): New
function types.
* config/i386/i386-builtin.def: Add
__builtin_ia32_loadiwkey,
__builtin_ia32_aesdec128kl_u8,
__builtin_ia32_aesdec256kl_u8,
__builtin_ia32_aesenc128kl_u8,
__builtin_ia32_aesenc256kl_u8,
__builtin_ia32_aesdecwide128kl_u8,
__builtin_ia32_aesdecwide256kl_u8,
__builtin_ia32_aesencwide128kl_u8,
__builtin_ia32_aesencwide256kl_u8,
__builtin_ia32_encodekey128_u32,
__builtin_ia32_encodekey256_u32.
* config/i386/i386-c.c (ix86_target_macros_internal): Handle
kl and widekl.
* config/i386/i386-options.c (isa2_opts): Add -mkl and -mwidekl.
(ix86_option_override_internal): Handle KL and WIDEKL.
(ix86_valid_target_attribute_inner_p): Add attribute for kl and widekl.
* config/i386/i386-expand.c
(ix86_expand_builtin): Expand Keylocker Builtins.
* config/i386/i386.h (TARGET_KL): New.
(TARGET_KL_P): Likewise.
(TARGET_WIDEKL): Likewise.
(TARGET_WIDEKL_P): Likewise.
(PTA_KL): Likewise.
(PTA_WIDEKL): Likewise.
(PTA_TIGERLAKE): Add PTA_KL, PTA_WIDEKL.
(PTA_ALDERLAKE): Likewise.
* config/i386/i386.opt: Add new option mkl and mwidekl.
* config/i386/keylockerintrin.h: New header file for Keylocker.
* config/i386/immintrin.h: Include keylockerintrin.h.
* config/i386/predicates.md (encodekey128_operation): New
predicate.
(encodekey256_operation): Likewise.
(aeswidekl_operation): Likewise.
* config/i386/sse.md (UNSPECV_LOADIWKEY): New.
(UNSPECV_AESDEC128KLU8): Likewise.
(UNSPECV_AESENC128KLU8): Likewise.
(UNSPECV_AESDEC256KLU8): Likewise.
(UNSPECV_AESENC256KLU8): Likewise.
(UNSPECV_AESDECWIDE128KLU8): Likewise.
(UNSPECV_AESENCWIDE128KLU8): Likewise.
(UNSPECV_AESDECWIDE256KLU8): Likewise.
(UNSPECV_AESENCWIDE256KLU8): Likewise.
(UNSPECV_ENCODEKEY128U32): Likewise.
(UNSPECV_ENCODEKEY256U32): Likewise.
(encodekey128u32): New expander.
(encodekey256u32): Likewise.
(aes<aeswideklvariant>u8): Likewise.
(loadiwkey): New insn pattern.
(*encodekey128u32): Likewise.
(*encodekey256u32): Likewise.
(aes<aesklvariant>u8): Likewise.
(*aes<aeswideklvariant>u8): Likewise.

gcc/testsuite/ChangeLog

* gcc.target/i386/keylocker-aesdec128kl.c: New test.
* gcc.target/i386/keylocker-aesdec256kl.c: Likewise.
* gcc.target/i386/keylocker-aesdecwide128kl.c: Likewise.
* gcc.target/i386/keylocker-aesdecwide256kl.c: Likewise.
* gcc.target/i386/keylocker-aesenc128kl.c: Likewise.
* gcc.target/i386/keylocker-aesencwide128kl.c: Likewise.
* gcc.target/i386/keylocker-aesencwide256kl.c: Likewise.
* gcc.target/i386/keylocker-encodekey128.c: Likewise.
* gcc.target/i386/keylocker-encodekey256.c: Likewise.
* gcc.target/i386/keylocker-loadiwkey.c: Likewise.
* g++.dg/other/i386-2.C: Add -mkl and -mwidekl.
* g++.dg/other/i386-3.C: Likewise.
* gcc.target/i386/sse-12.c: Likewise.
* gcc.target/i386/sse-13.c: Likewise.
* gcc.target/i386/sse-14.c: Likewise.
* gcc.target/i386/sse-22.c: Add kl and widekl.
* gcc.target/i386/sse-23.c: Likewise.
* gcc.target/i386/funcspec-56.inc: Add new target attribute test.

4 years agoMore BB vectorization tweaks
Richard Biener [Thu, 29 Oct 2020 07:48:15 +0000 (08:48 +0100)]
More BB vectorization tweaks

This tweaks the op build from splats to allow loads marked as not
vectorizable.  It also amends some dump prints with the address of
the SLP node or the instance to better be able to debug things.

2020-10-29  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_build_slp_tree_2): Allow splatting
not vectorizable loads.
(vect_build_slp_instance): Amend dumping with address.
(vect_slp_convert_to_external): Likewise.

* gcc.dg/vect/bb-slp-pr65935.c: Adjust.

4 years agoCall infer_non_null() directly when checking for non-null.
Andrew MacLeod [Wed, 28 Oct 2020 20:41:15 +0000 (16:41 -0400)]
Call infer_non_null() directly when checking for non-null.

Simply call infer_non_null directly and avoid uneccessary checks of
the statement being modified.

gcc/
PR tree-optimization/97609
* gimple-range-cache.cc (non_null_ref::process_name): Call
infer_nonnull_range directly instead of infer_value_range.
gcc/testsuite/
* g++.dg/pr97609.C: New.

4 years agolibstdc++: Fix new basic_stringbuf constructor
Jonathan Wakely [Thu, 29 Oct 2020 01:05:03 +0000 (01:05 +0000)]
libstdc++: Fix new basic_stringbuf constructor

libstdc++-v3/ChangeLog:

* include/std/sstream (basic_stringbuf(__string_type&&, openmode)):
Call _M_init_syncbuf to set up get/put areas. Also qualify
std::move.

4 years agolibgo: handle linking to NetBSD's versioned symbols
Nikhil Benesch [Mon, 26 Oct 2020 18:42:08 +0000 (18:42 +0000)]
libgo: handle linking to NetBSD's versioned symbols

On NetBSD, for backwards compatibility, various libc symbols are
renamed to a symbol with a version suffix. For example, this is the
(abbreviated) definition of sigaction:

    int sigaction(...) __asm__ ("__sigaction14")

This poses a challenge for libgo, which attempts to link sigaction by
way of an "//extern" comment:

    //extern sigaction
    func sigaction(...)

This results in a reference to the deprecated compatibility symbol
"sigaction", rather than the desired "__sigaction14" symbol.

This patch introduces a new "//extern-sysinfo" comment to handle this
situation. The new mklinknames.awk script scans a package for these
comments and outputs a "//go:linkname" directive that links the wrapper
to the correct versioned symbol, as determined by parsing the __asm__
annotation on the function's declaration in gen-sysinfo.go.

For now, only the following packages are scanned by mklinknames.awk:

    os
    os/user
    runtime
    syscall

gotools/:
* Makefile.am (check-runtime): Add runtime_linknames.go to
--extrafiles.
* Makefile.in: Regenerate.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/265125

4 years agoDaily bump.
GCC Administrator [Thu, 29 Oct 2020 00:16:50 +0000 (00:16 +0000)]
Daily bump.

4 years agoanalyzer: more non-determinism fixes
David Malcolm [Thu, 29 Oct 2020 00:11:41 +0000 (20:11 -0400)]
analyzer: more non-determinism fixes

gcc/analyzer/ChangeLog:
* program-state.cc (sm_state_map::on_liveness_change): Sort the
leaking svalues before calling on_state_leak.
(program_state::detect_leaks): Likewise when calling
on_svalue_leak.
* region-model-reachability.cc
(reachable_regions::mark_escaped_clusters): Likewise when
calling on_escaped_function.

4 years agoanalyzer: fix false leak diagnostic on offsets from malloc [PR97608]
David Malcolm [Thu, 29 Oct 2020 00:10:39 +0000 (20:10 -0400)]
analyzer: fix false leak diagnostic on offsets from malloc [PR97608]

gcc/analyzer/ChangeLog:
PR analyzer/97608
* region-model-reachability.cc (reachable_regions::handle_sval):
Operands of reachable reversible operations are reachable.

gcc/testsuite/ChangeLog:
PR analyzer/97608
* gcc.dg/analyzer/malloc-1.c (test_42d): New.
* gcc.dg/analyzer/pr97608.c: New test.

4 years agoanalyzer: move svalue and region decls to their own header files
David Malcolm [Thu, 29 Oct 2020 00:09:04 +0000 (20:09 -0400)]
analyzer: move svalue and region decls to their own header files

gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/complexity.o.

gcc/analyzer/ChangeLog:
* analyzer.h (class state_machine): New forward decl.
(class logger): Likewise.
(class visitor): Likewise.
* complexity.cc: New file, taken from svalue.cc.
* complexity.h: New file, taken from region-model.h.
* region-model.h: Include "analyzer/svalue.h" and
"analyzer/region.h".  Move struct complexity to complexity.h.
Move svalue, its subclasses and supporting decls to svalue.h.
Move region, its subclasses and supporting decls to region.h.
* region.cc: Include "analyzer/region.h".
(symbolic_region::symbolic_region): Move here from region-model.h.
* region.h: New file, based on material from region-model.h.
* svalue.cc: Include "analyzer/svalue.h".
(complexity::complexity): Move to complexity.cc.
(complexity::from_pair): Likewise.
* svalue.h: New file, based on material from region-model.h.

4 years agoanalyzer: fix more pointer-printing in logs
David Malcolm [Thu, 29 Oct 2020 00:07:35 +0000 (20:07 -0400)]
analyzer: fix more pointer-printing in logs

gcc/analyzer/ChangeLog:
* program-state.cc (sm_state_map::print): Guard the printing of
the origin pointer with !flag_dump_noaddr.
* region.cc (string_region::dump_to_pp): Likewise for
m_string_cst.

4 years agolibstdc++: Fix linker script
Jonathan Wakely [Wed, 28 Oct 2020 23:10:21 +0000 (23:10 +0000)]
libstdc++: Fix linker script

libstdc++-v3/ChangeLog:

* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Remove duplicate
patterns.
(CXXABI_1.3.13): Restore missing piece.

4 years ago[RS6000] Don't be too clever with dg-do run and dg-do compile
Alan Modra [Wed, 28 Oct 2020 08:33:04 +0000 (19:03 +1030)]
[RS6000] Don't be too clever with dg-do run and dg-do compile

Otherwise some versions of dejagnu go ahead and run the vsx tests
below when they should not.  To best cope with older dejagnu, put
"run" before "compile", the idea being that if the second dg-do always
wins then that won't cause fails.

The altivec tests also need -save-temps for the scan-assembler test to
occur when vms_hw.

* gcc.target/powerpc/vsx-load-element-extend-char.c: Put "dg-do run"
before "dg-do compile", and make them mutually exclusive.
* gcc.target/powerpc/vsx-load-element-extend-int.c: Likewise.
* gcc.target/powerpc/vsx-load-element-extend-longlong.c: Likewise.
* gcc.target/powerpc/vsx-load-element-extend-short.c: Likewise.
* gcc.target/powerpc/vsx-store-element-truncate-char.c: Likewise.
* gcc.target/powerpc/vsx-store-element-truncate-int.c: Likewise.
* gcc.target/powerpc/vsx-store-element-truncate-longlong.c: Likewise.
* gcc.target/powerpc/vsx-store-element-truncate-short.c: Likewise.
* gcc.target/powerpc/altivec-consts.c: Likewise, add -save-temps.
* gcc.target/powerpc/le-altivec-consts.c: Likewise.

4 years ago[RS6000] float128-type-2.c unsupported
Alan Modra [Wed, 28 Oct 2020 05:27:57 +0000 (15:57 +1030)]
[RS6000] float128-type-2.c unsupported

I noticed this test is unsupported on power10 when looking through
test logs.  There seems no reason why that should be the case, ie.
the target test was meant to be powerpc64*-*-linux*.  And that
simplifies down further.

* gcc.target/powerpc/float128-type-1.c: Simplify target test.
* gcc.target/powerpc/float128-type-2.c: Likewise.

4 years agoRe: testsuite: Enable and adjust powerpc fold-vec-extract/insert testcases
Alan Modra [Tue, 27 Oct 2020 23:37:44 +0000 (10:07 +1030)]
Re: testsuite: Enable and adjust powerpc fold-vec-extract/insert testcases

git commit badeac77f552 changed expected number of addi instructions,
causing these fails on powerpc-linux.

gcc.target/powerpc/fold-vec-insert-int-p9.c: \\maddi\\M found 12 times
FAIL: gcc.target/powerpc/fold-vec-insert-int-p9.c scan-assembler-times \\maddi\\M 8
gcc.target/powerpc/fold-vec-extract-char.p9.c: addi found 6 times
FAIL: gcc.target/powerpc/fold-vec-extract-char.p9.c scan-assembler-times addi 3
gcc.target/powerpc/fold-vec-extract-int.p9.c: \\maddi\\M found 6 times
FAIL: gcc.target/powerpc/fold-vec-extract-int.p9.c scan-assembler-times \\maddi\\M 3
gcc.target/powerpc/fold-vec-extract-longlong.p7.c: \\maddi\\M found 6 times
FAIL: gcc.target/powerpc/fold-vec-extract-longlong.p7.c scan-assembler-times \\maddi\\M 4
gcc.target/powerpc/fold-vec-extract-longlong.p8.c: \\maddi\\M found 6 times
FAIL: gcc.target/powerpc/fold-vec-extract-longlong.p8.c scan-assembler-times \\maddi\\M 4
changed by badeac77f552

I'm not at all sure why we are counting addi.  On linux I see
eight in fold-vec-insert-int-p9.c tearing down the stack frame in
function epilogues, and four in
        addi 9,1,16
        lvewx 0,0,9
For aix you have the above four but with a -16 offset.  There are no
stack frames, and you have four addressing stack red-zone as
        addi 9,1,-64

fold-vec-extract-char.p9.c on linux just has epilogue addi, aix has
red-zone addressing.  The same for fold-vec-extract-int.p9.c,
fold-vec-extract-longlong.p7.c and fold-vec-extract-longlong.p8.c.

It seems silly to count addi in a function epilogue, and fragile to
count them in code.  So remove the ilp32 addi checks.

* gcc.target/powerpc/fold-vec-extract-char.p9.c: Don't check addi
count for ilp32.
* gcc.target/powerpc/fold-vec-extract-int.p9.c: Likewise.
* gcc.target/powerpc/fold-vec-extract-longlong.p7.c: Likewise.
* gcc.target/powerpc/fold-vec-extract-longlong.p8.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-int-p9.c: Likewise.

4 years agoc++: Improve the MVP -Wparentheses diagnostic.
Marek Polacek [Wed, 28 Oct 2020 18:45:27 +0000 (14:45 -0400)]
c++: Improve the MVP -Wparentheses diagnostic.

I noticed that declarator->parenthesized is, for this warning, only set
to the opening paren.  But we can easily make it a range and generate
a nicer diagnostic.  Moreover, we can then offer a fix-it hint.

TL;DR: This patch changes

mvp3.C:8:7: warning: unnecessary parentheses in declaration of ā€˜iā€™ [-Wparentheses]
    8 |   int (i);
      |       ^

to

mvp3.C:8:7: warning: unnecessary parentheses in declaration of ā€˜iā€™ [-Wparentheses]
    8 |   int (i);
      |       ^~~
mvp3.C:8:7: note: remove parentheses
    8 |   int (i);
      |       ^~~
      |       - -

Tested by using -fdiagnostics-generate-patch and verifying that the
generated patch DTRT.

gcc/cp/ChangeLog:

* decl.c (grokdeclarator): Offer a fix-it hint for the "unnecessary
parentheses in declaration" warning.
* parser.c (cp_parser_direct_declarator): When setting
declarator->parenthesized, use a location range.

gcc/testsuite/ChangeLog:

* g++.dg/warn/mvp3.C: New test.

4 years agoc++: Deprecate arithmetic convs on different enums [PR97573]
Marek Polacek [Tue, 27 Oct 2020 15:16:50 +0000 (11:16 -0400)]
c++: Deprecate arithmetic convs on different enums [PR97573]

I noticed that C++20 P1120R0 deprecated certain arithmetic conversions
as outlined in [depr.arith.conv.enum], but we don't warn about them.  In
particular, "If one operand is of enumeration type and the other operand
is of a different enumeration type or a floating-point type, this
behavior is deprecated."  These will likely become ill-formed in C++23,
so we should warn by default in C++20.  To this effect, this patch adds
two new warnings (like clang++): -Wdeprecated-enum-enum-conversion and
-Wdeprecated-enum-float-conversion.  They are enabled by default in
C++20.  In older dialects, to enable these warnings you can now use
-Wenum-conversion which I made available in C++ too.  Note that unlike
C, in C++ it is not enabled by -Wextra, because that breaks bootstrap.

We already warn about comparisons of two different enumeration types via
-Wenum-compare, the rest is handled in this patch: we're performing the
usual arithmetic conversions in these contexts:
  - an arithmetic operation,
  - a bitwise operation,
  - a comparison,
  - a conditional operator,
  - a compound assign operator.

Using the spaceship operator as enum <=> real_type is ill-formed but we
don't reject it yet.  We should also address [depr.array.comp] too, but
it's not handled in this patch.

gcc/c-family/ChangeLog:

PR c++/97573
* c-opts.c (c_common_post_options): In C++20, turn on
-Wdeprecated-enum-enum-conversion and
-Wdeprecated-enum-float-conversion.
* c.opt (Wdeprecated-enum-enum-conversion,
Wdeprecated-enum-float-conversion): New options.
(Wenum-conversion): Allow for C++ too.

gcc/cp/ChangeLog:

PR c++/97573
* call.c (build_conditional_expr_1): Warn about the deprecated
enum/real type conversion in C++20.  Also warn about a non-enumerated
and enumerated type in ?: when -Wenum-conversion is on.
* typeck.c (do_warn_enum_conversions): New function.
(cp_build_binary_op): Call it.

gcc/ChangeLog:

PR c++/97573
* doc/invoke.texi: Document -Wdeprecated-enum-enum-conversion
and -Wdeprecated-enum-float-conversion.  -Wenum-conversion is
no longer C/ObjC only.

gcc/testsuite/ChangeLog:

PR c++/97573
* g++.dg/cpp0x/linkage2.C: Add dg-warning.
* g++.dg/parse/attr3.C: Likewise.
* g++.dg/cpp2a/enum-conv1.C: New test.
* g++.dg/cpp2a/enum-conv2.C: New test.
* g++.dg/cpp2a/enum-conv3.C: New test.

4 years agoc++: Prevent warnings for value-dependent exprs [PR96742]
Marek Polacek [Sat, 24 Oct 2020 19:26:27 +0000 (15:26 -0400)]
c++: Prevent warnings for value-dependent exprs [PR96742]

Here, in r11-155, I changed the call to uses_template_parms to
type_dependent_expression_p_push to avoid a crash in C++98 in
value_dependent_expression_p on a non-constant expression.  But that
prompted a host of complaints that we now warn for value-dependent
expressions in templates.  Those warnings are technically valid, but
people still don't want them because they're awkward to avoid.  This
patch uses value_dependent_expression_p or type_dependent_expression_p.
But make sure that we don't ICE in value_dependent_expression_p by
checking potential_constant_expression first.

gcc/cp/ChangeLog:

PR c++/96675
PR c++/96742
* pt.c (tsubst_copy_and_build): Call value_dependent_expression_p or
type_dependent_expression_p instead of type_dependent_expression_p_push.
But only call value_dependent_expression_p for expressions that are
potential_constant_expression.

gcc/testsuite/ChangeLog:

PR c++/96675
PR c++/96742
* g++.dg/warn/Wdiv-by-zero-3.C: Turn dg-warning into dg-bogus.
* g++.dg/warn/Wtautological-compare3.C: New test.
* g++.dg/warn/Wtype-limits5.C: New test.
* g++.old-deja/g++.pt/crash10.C: Remove dg-warning.

4 years agotestsuite: Adjust target requirements for sad-vectorize and signbit.
David Edelsohn [Wed, 28 Oct 2020 18:01:17 +0000 (14:01 -0400)]
testsuite: Adjust target requirements for sad-vectorize and signbit.

More testcases with incorrect target selectors.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/sad-vectorize-1.c: Remove AIX skip.
* gcc.target/powerpc/sad-vectorize-2.c: Remove AIX skip.
* gcc.target/powerpc/sad-vectorize-3.c: Remove target.
Require p9vector_hw.
* gcc.target/powerpc/sad-vectorize-4.c: Remove target.
Require p9vector_hw.
* gcc.target/powerpc/signbit-1.c: Remove target.
Require ppc_float128_sw.
* gcc.target/powerpc/signbit-2.c: Remove target.
Require ppc_float128_sw.
* gcc.target/powerpc/signbit-3.c: Remove target.
Require ppc_float128_sw.

4 years agoc++: Member template function lookup failure [PR94799]
Marek Polacek [Mon, 19 Oct 2020 22:13:42 +0000 (18:13 -0400)]
c++: Member template function lookup failure [PR94799]

My earlier patch for this PR, r11-86, broke pybind11.  That patch
changed cp_parser_class_name to also consider the object expression
scope (parser->context->object_type) to fix parsing of

  p->template A<T>::foo(); // consider p's scope too

Here we reject

  b.operator typename B<T>::type();

because 'typename_p' in cp_parser_class_name uses 'scope', which means
that 'typename_p' will be true for the example above.  Then we create
a TYPENAME_TYPE via make_typename_type, which fails when tsubsting it;
the code basically created 'typename B::B' and then we complain that there
is no member named 'B' in 'A<int>'.  So, when deciding if we should
create a TYPENAME_TYPE, don't consider the object_type scope, like we
did pre-r11-86.

gcc/cp/ChangeLog:

PR c++/94799
* parser.c (cp_parser_class_name): Use parser->scope when
setting typename_p.

gcc/testsuite/ChangeLog:

PR c++/94799
* g++.dg/template/lookup16.C: New test.

4 years agoc++: GCC accepts junk before fold-expression [PR86773]
Marek Polacek [Mon, 26 Oct 2020 19:04:58 +0000 (15:04 -0400)]
c++: GCC accepts junk before fold-expression [PR86773]

Here we accept a bogus expression before a left fold:

Recall that a fold expression looks like:

 fold-expression:
    ( cast-expression fold-operator ... )
    ( ... fold-operator cast-expression )
    ( cast-expression fold-operator ... fold-operator cast-expression )

but here we have

    ( cast-expression ... fold-operator cast-expression )

The best fix seems to just return error_mark_node when we know this code
is invalid, and let the subsequent code report that a ) was expected.

gcc/cp/ChangeLog:

PR c++/86773
* parser.c (cp_parser_fold_expression): Return error_mark_node
if a left fold is preceded by an expression.

gcc/testsuite/ChangeLog:

PR c++/86773
* g++.dg/cpp1z/fold12.C: New test.

4 years agosyscall: don't build libcall_bsd.go on solaris
Ian Lance Taylor [Wed, 28 Oct 2020 18:48:19 +0000 (11:48 -0700)]
syscall: don't build libcall_bsd.go on solaris

This new file was based on master sources that are built for *BSD
but not Solaris

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/266017

4 years agoAArch64: Skip test for pr97535 on ILP32 since it can't express the range.
Tamar Christina [Wed, 28 Oct 2020 19:13:27 +0000 (19:13 +0000)]
AArch64: Skip test for pr97535 on ILP32 since it can't express the range.

I am excluding the test from ILP32 since the goal of the test is to test
truncations of large numbers above INT_MAX.

gcc/testsuite/ChangeLog:

PR target/97535
* gcc.target/aarch64/pr97535.c: Exclude ILP32.

4 years agovalue-range: Give up on POLY_INT_CST ranges [PR97457]
Richard Sandiford [Wed, 28 Oct 2020 19:05:49 +0000 (19:05 +0000)]
value-range: Give up on POLY_INT_CST ranges [PR97457]

This PR shows another problem with calculating value ranges for
POLY_INT_CSTs.  We have:

  ivtmp_76 = ASSERT_EXPR <ivtmp_60, ivtmp_60 > POLY_INT_CST [9, 4294967294]>

where the VQ coefficient is unsigned but is effectively acting
as a negative number.  We wrongly give the POLY_INT_CST the range:

  [9, INT_MAX]

and things go downhill from there: later iterations of the unrolled
epilogue are wrongly removed as dead.

I guess this is the final nail in the coffin for doing VRP on
POLY_INT_CSTs.  For other similarly exotic testcases we could have
overflow for any coefficient, not just those that could be treated
as contextually negative.

Testing TYPE_OVERFLOW_UNDEFINED doesn't seem like an option because we
couldn't handle warn_strict_overflow properly.  At this stage we're
just recording a range that might or might not lead to strict-overflow
assumptions later.

It still feels like we should be able to do something here, but for
now removing the code seems safest.  It's also telling that there
are no testsuite failures on SVE from doing this.

gcc/
PR tree-optimization/97457
* value-range.cc (irange::set): Don't decay POLY_INT_CST ranges
to integer ranges.

gcc/testsuite/
PR tree-optimization/97457
* gcc.dg/vect/pr97457.c: New test.

4 years agoc: Allow omitted parameter names for C2x
Joseph Myers [Wed, 28 Oct 2020 18:57:02 +0000 (18:57 +0000)]
c: Allow omitted parameter names for C2x

C2x allows parameter names to be omitted in function definitions, as
in C++; add support for this feature.  As with other features that
only result in previously rejected code being accepted, this feature
is now accepted as an extension for previous standard versions, with a
pedwarn-if-pedantic that is disabled by -Wno-c11-c2x-compat.  The
logic for avoiding unused-parameter warnings for unnamed parameters is
in code shared between C and C++, so no changes are needed there.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
2020-10-28  Joseph Myers  <joseph@codesourcery.com>

* c-decl.c (store_parm_decls_newstyle): Use pedwarn_c11 not
error_at for omitted parameter name.

gcc/testsuite/
2020-10-28  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/c11-parm-omit-1.c, gcc.dg/c11-parm-omit-2.c,
gcc.dg/c11-parm-omit-3.c, gcc.dg/c11-parm-omit-4.c,
gcc.dg/c2x-parm-omit-1.c, gcc.dg/c2x-parm-omit-2.c,
gcc.dg/c2x-parm-omit-3.c, gcc.dg/c2x-parm-omit-4.c: New tests.
* gcc.dg/noncompile/pr79758.c: Do not expect error for omitted
parameter name.

4 years agolibstdc++: Implement C++20 features for <sstream>
Thomas Rodgers [Wed, 28 Oct 2020 18:52:17 +0000 (11:52 -0700)]
libstdc++: Implement C++20 features for <sstream>

New ctors and ::view() accessor for -
  * basic_stingbuf
  * basic_istringstream
  * basic_ostringstream
  * basic_stringstreamm

New ::get_allocator() accessor for basic_stringbuf.

libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): New symbols.
* configure: Regenerate.
* include/std/sstream:
(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)):
Likewise.
(basic_stringbuf::get_allocator()): New method.
(basic_stringbuf::view()): Likewise.
(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
New constructor.
(basic_istringstream::basic_istringstream(openmode, allocator const&)):
Likewise
(basic_istringstream::view()): New method.
(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
New constructor.
(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
Likewise
(basic_ostringstream::view()): New method.
(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
New constructor.
(basic_stringstream::basic_stringstream(openmode, allocator const&)):
Likewise
(basic_stringstream::view()): New method.
* src/Makefile.in: Add c++20 directory.
* src/Makefile.am: Regenerate.
* src/c++20/Makefile.am: Add makefile for new sub-directory.
* src/c++20/Makefile.in: Generate.
* src/c++20/sstream-inst.cc: New file defining explicit
instantiations for basic_stringbuf, basic_istringstream,
basic_ostringstream, and basic_stringstream member functions
added in C++20.
* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/char/1.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/char/1.cc: Likewise.
* testsuite/27_io/basic_istringstream/view/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/char/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/1.cc: Likewise.

4 years agoc++: Make OMP UDR DECL_LOCAL_DECL_P earlier
Nathan Sidwell [Wed, 28 Oct 2020 18:42:11 +0000 (11:42 -0700)]
c++: Make OMP UDR DECL_LOCAL_DECL_P earlier

I discovered that we were pushing an OMP UDR in a template before
setting DECL_LOCAL_DECL.  This caused the template machinery to give
it some template info.  It doesn't need that, and this changes the
parser to set it earlier.  We have to adjust instantiate_body to not
try and access such a function's non-existant template_info.  The
access checks that we're no longer doing are the same as those we did
on the containing function anyway.  So nothing is lost.

gcc/cp/
* parser.c (cp_parser_omp_declare_reduction): Set
DECL_LOCAL_DECL_P before push_template_decl.
* pt.c (instantiate_body): Nested fns do not have template_info.

4 years agoVSX_EXTRACT fix
Carl Love [Fri, 23 Oct 2020 17:13:55 +0000 (12:13 -0500)]
VSX_EXTRACT fix

2020-10-28  Carl Love  <cel@us.ibm.com>

gcc/

* config/rs6000/vsx.md(xxgenpcvm_<mode>_internal): Remove TARGET_64BIT.

4 years agolibstdc++: Fix arithmetic bug in year_month_weekday conversion [PR96713]
Patrick Palka [Wed, 28 Oct 2020 16:28:08 +0000 (12:28 -0400)]
libstdc++: Fix arithmetic bug in year_month_weekday conversion [PR96713]

The conversion function year_month_weekday::operator sys_days computes
the offset in days from the first weekday of the month with:

 days{(index()-1)*7}
      ^~~~~~~~~~~~~  type 'unsigned'

We want the above to yield -7d when index() is 0u, but our 'days' alias
is based on long instead of int, so the conversion from unsigned to the
underlying type of 'days' instead yields a large positive value.

This patch fixes this by casting the result of index() to int so that
the initializer is sign-extended in the conversion to long.

The added testcase also verifies we do the right thing when index() == 5.

libstdc++-v3/ChangeLog:

PR libstdc++/96713
* include/std/chrono (year_month_weekday::operator sys_days):
Cast the result of index() to int so that the initializer for
days{} is sign-extended when it's converted to the underlying
type.
* testsuite/std/time/year_month_weekday/3.cc: New test.

4 years agodump when SLP analysis fails due to shared vectype mismatch
Richard Biener [Wed, 28 Oct 2020 15:31:06 +0000 (16:31 +0100)]
dump when SLP analysis fails due to shared vectype mismatch

This adds another one.

2020-10-28  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_slp_analyze_node_operations_1): Dump
when shared vectype update fails.