platform/upstream/gcc.git
3 years agoDaily bump.
GCC Administrator [Sun, 2 May 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: C++11 range-for and ovl/lkp_iterator
Jason Merrill [Tue, 2 Mar 2021 21:30:41 +0000 (16:30 -0500)]
c++: C++11 range-for and ovl/lkp_iterator

We can't use C++11 range-based 'for' over a tree directly, because we don't
know what kind of range we want to use it as.  I suppose in some cases we
could guess, but it seems better to tersely make it explicit.  This patch
adds range adaptors ovl_range and lkp_range for use as the range of a
range-for, e.g.

  for (tree fn : lkp_range (fns)) { ... }

This patch also removes the private copy ops from ovl_iterator; it's
necessary for range-for, and these are effectively C++ forward_iterators,
which allow copying, so I don't see a reason to prevent it.  A bit more
would need to be done to make them actually conform as C++11 forward
iterators, but I don't think we particularly want to #include <iterator>
yet.

gcc/cp/ChangeLog:

* cp-tree.h (class ovl_iterator): Allow copying.  Add op==.
(class ovl_range, class lkp_range): New.
* call.c (build_op_call_1, add_candidates): Use them.
(build_op_delete_call, has_trivial_copy_assign_p): Likewise.
(has_trivial_copy_p): Likewise.
* class.c (handle_using_decl, get_basefndecls): Likewise.
(maybe_warn_about_overly_private_class): Likewise.
(warn_hidden, add_implicitly_declared_members): Likewise.
(check_methods, clone_constructors_and_destructors): Likewise.
(type_has_user_nondefault_constructor): Likewise.

3 years agoAdd GTY support for irange.
Aldy Hernandez [Mon, 19 Apr 2021 06:24:11 +0000 (08:24 +0200)]
Add GTY support for irange.

Right now we have GTY support for static storage iranges
(int_range<>).  However, there's no reason why the base
class can't be used with GC, other than it was an oversight.

For that matter, the base class has a pointer to the sub-range
storage, so we can use the same implementation for both.  This
patch does so.

I have also removed the DEFINE_INT_RANGE_GC_STUBS
stuff, and have documented why we need a separate
gt_pch_nx (int_range<1> *&) version.  This has to do with
hash-traits.h, which ipa-prop.c is using to store a value_range.
The header file hash-traits.h is defining an extern of
gt_pch_nx (int_range<1> *&) etc, instead of calling the
more generic (int_range<1> *) which is already available.

It seems suspect that has-traits.h has their own externs
for GC functions, and if someone has a better solution, I'd
be glad to hear it.

gcc/ChangeLog:

* value-range.cc (DEFINE_INT_RANGE_GC_STUBS): Remove.
(gt_pch_nx (int_range<1> *&)): New.
(gt_ggc_mx (int_range<1> *&)): New.
* value-range.h (class irange): Add GTY support for
the base class.

3 years agodoc/options.texi: Fix the description of 'Negative'.
Geng Qi [Wed, 28 Apr 2021 09:24:32 +0000 (17:24 +0800)]
doc/options.texi: Fix the description of 'Negative'.

gcc/ChangeLog:
* doc/options.texi (Negative): Change either or to both and.

3 years agoDaily bump.
GCC Administrator [Sat, 1 May 2021 00:16:28 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Implement P2328 changes to join_view
Patrick Palka [Fri, 30 Apr 2021 22:45:46 +0000 (18:45 -0400)]
libstdc++: Implement P2328 changes to join_view

This implements the wording changes of P2328R0 "join_view should join
all views of ranges".

libstdc++-v3/ChangeLog:

* include/std/ranges (__detail::__non_propating_cache): Define
as per P2328.
(join_view): Remove constraints on the value and reference types
of the wrapped iterator type as per P2328.
(join_view::_Iterator::_M_satisfy): Adjust as per P2328.
(join_view::_Iterator::operator++): Likewise.
(join_view::_M_inner): Use __non_propating_cache as per P2328.
Remove now-redundant use of __maybe_present_t.
* testsuite/std/ranges/adaptors/join.cc: Include <array>.
(test10): New test.

3 years agolibstdc++: Fix inconsistent feature test macros
Jonathan Wakely [Fri, 30 Apr 2021 19:32:05 +0000 (20:32 +0100)]
libstdc++: Fix inconsistent feature test macros

The __cpp_lib_constexpr_string and __cpp_lib_semaphore feature test
macros are not defined consistently in <version> and the relevant header
for the feature.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (__cpp_lib_constexpr_string):
Only define for C++17 and later.
* include/std/version (__cpp_lib_semaphore): Fix condition
to match the one in <semaphore>.

3 years agolibstdc++: Remove GLIBCXX_CHECK_INT64_T checks
Jonathan Wakely [Fri, 30 Apr 2021 14:54:14 +0000 (15:54 +0100)]
libstdc++: Remove GLIBCXX_CHECK_INT64_T checks

This simplifies the definition of std::streamoff by using the predefined
__INT64_TYPE__ macro, instead of the _GLIBCXX_HAVE_INT64_T_LONG,
_GLIBCXX_HAVE_INT64_T_LONG_LONG and _GLIBCXX_HAVE_INT64_T macros defined
by configure.

By using the __INT64_TYPE__ macro (which all of GCC, Clang and Intel
define) we do not need to determine the type of int64_t in configure, we
can just use that type directly.

The background for the change was explained by David Edelsohn:

  Currently the type of streamoff is determined at libstdc++ configure
  time, chosen by the definitions of _GLIBCXX_HAVE_INT64_T_LONG and
  _GLIBCXX_HAVE_INT64_T_LONG_LONG.  For a multilib configuration, the
  difference is encoded in the different multilib header file paths.
  For "FAT" library targets that package 32 bit and 64 bit libraries
  together, G++ also expects a single header file directory hierarchy,
  causing an incorrect value for streamoff in some situations.

And in a subsequent mail:

  Most of the libstdc++ headers are architecture-neutral, OS neutral and
  ABI neutral.  The differences are localized in bits/c++config.h.  And
  most of c++config.h is identical for 32 bit AIX and 64 bit AIX.  The
  only differences that matter are __int128 and __int64_t.

This change removes some of those differences. With the only uses of the
INT64_T configure macros removed, the configure checks themselves can
also be removed.

Co-authored-by: David Edelsohn <dje.gcc@gmail.com>
libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_INT64_T): Delete.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Do not use GLIBCXX_CHECK_INT64_T.
* include/bits/postypes.h: Remove include of <stdint.h> and
definition/undefinition of the __STDC_LIMIT_MACROS and
__STDC_CONSTANT_MACROS macros.
(streamoff): Use __INT64_TYPE__ if defined.

3 years agotestsuite: aarch64: Add fusion tests for FP vml[as] intrinsics
Jonathan Wright [Mon, 15 Feb 2021 23:52:47 +0000 (23:52 +0000)]
testsuite: aarch64: Add fusion tests for FP vml[as] intrinsics

Add compilation tests to make sure that the output of vmla/vmls
floating-point Neon intrinsics (fmul, fadd/fsub) is not fused into
fmla/fmls instructions.

gcc/testsuite/ChangeLog:

2021-02-16  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vmla_float_not_fused.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vmls_float_not_fused.c:
New test.

3 years agoaarch64: Use RTL builtins for FP ml[as][q]_laneq intrinsics
Jonathan Wright [Wed, 17 Feb 2021 13:13:52 +0000 (13:13 +0000)]
aarch64: Use RTL builtins for FP ml[as][q]_laneq intrinsics

Rewrite floating-point vml[as][q]_laneq Neon intrinsics to use RTL
builtins rather than relying on the GCC vector extensions. Using RTL
builtins allows control over the emission of fmla/fmls instructions
(which we don't want here.)

With this commit, the code generated by these intrinsics changes from
a fused multiply-add/subtract instruction to an fmul followed by an
fadd/fsub instruction. If the programmer really wants fmla/fmls
instructions, they can use the vfm[as] intrinsics.

gcc/ChangeLog:

2021-02-17  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add
float_ml[as][q]_laneq builtin generator macros.
* config/aarch64/aarch64-simd.md (mul_laneq<mode>3): Define.
(aarch64_float_mla_laneq<mode>): Define.
(aarch64_float_mls_laneq<mode>): Define.
* config/aarch64/arm_neon.h (vmla_laneq_f32): Use RTL builtin
instead of GCC vector extensions.
(vmlaq_laneq_f32): Likewise.
(vmls_laneq_f32): Likewise.
(vmlsq_laneq_f32): Likewise.

3 years agoaarch64: Use RTL builtins for FP ml[as][q]_lane intrinsics
Jonathan Wright [Tue, 16 Feb 2021 23:59:22 +0000 (23:59 +0000)]
aarch64: Use RTL builtins for FP ml[as][q]_lane intrinsics

Rewrite floating-point vml[as][q]_lane Neon intrinsics to use RTL
builtins rather than relying on the GCC vector extensions. Using RTL
builtins allows control over the emission of fmla/fmls instructions
(which we don't want here.)

With this commit, the code generated by these intrinsics changes from
a fused multiply-add/subtract instruction to an fmul followed by an
fadd/fsub instruction. If the programmer really wants fmla/fmls
instructions, they can use the vfm[as] intrinsics.

gcc/ChangeLog:

2021-02-16  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add
float_ml[as]_lane builtin generator macros.
* config/aarch64/aarch64-simd.md (*aarch64_mul3_elt<mode>):
Rename to...
(mul_lane<mode>3): This, and re-order arguments.
(aarch64_float_mla_lane<mode>): Define.
(aarch64_float_mls_lane<mode>): Define.
* config/aarch64/arm_neon.h (vmla_lane_f32): Use RTL builtin
instead of GCC vector extensions.
(vmlaq_lane_f32): Likewise.
(vmls_lane_f32): Likewise.
(vmlsq_lane_f32): Likewise.

3 years agoaarch64: Use RTL builtins for FP ml[as] intrinsics
Jonathan Wright [Tue, 16 Feb 2021 15:42:36 +0000 (15:42 +0000)]
aarch64: Use RTL builtins for FP ml[as] intrinsics

Rewrite floating-point vml[as][q] Neon intrinsics to use RTL builtins
rather than relying on the GCC vector extensions. Using RTL builtins
allows control over the emission of fmla/fmls instructions (which we
don't want here.)

With this commit, the code generated by these intrinsics changes from
a fused multiply-add/subtract instruction to an fmul followed by an
fadd/fsub instruction. If the programmer really wants fmla/fmls
instructions, they can use the vfm[as] intrinsics.

gcc/ChangeLog:

2021-02-16  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add float_ml[as]
builtin generator macros.
* config/aarch64/aarch64-simd.md (aarch64_float_mla<mode>):
Define.
(aarch64_float_mls<mode>): Define.
* config/aarch64/arm_neon.h (vmla_f32): Use RTL builtin
instead of relying on GCC vector extensions.
(vmla_f64): Likewise.
(vmlaq_f32): Likewise.
(vmlaq_f64): Likewise.
(vmls_f32): Likewise.
(vmls_f64): Likewise.
(vmlsq_f32): Likewise.
(vmlsq_f64): Likewise.
* config/aarch64/iterators.md: Define VDQF_DF mode iterator.

3 years agoaarch64: Use RTL builtins for FP ml[as]_n intrinsics
Jonathan Wright [Mon, 18 Jan 2021 12:42:52 +0000 (12:42 +0000)]
aarch64: Use RTL builtins for FP ml[as]_n intrinsics

Rewrite floating-point vml[as][q]_n Neon intrinsics to use RTL
builtins rather than inline assembly code, allowing for better
scheduling and optimization.

gcc/ChangeLog:

2021-01-18  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add
float_ml[as]_n_builtin generator macros.
* config/aarch64/aarch64-simd.md (*aarch64_mul3_elt_from_dup<mode>):
Rename to...
(mul_n<mode>3): This, and re-order arguments.
(aarch64_float_mla_n<mode>): Define.
(aarch64_float_mls_n<mode>): Define.
* config/aarch64/arm_neon.h (vmla_n_f32): Use RTL builtin
instead of inline asm.
(vmlaq_n_f32): Likewise.
(vmls_n_f32): Likewise.
(vmlsq_n_f32): Likewise.

3 years agoaarch64: Use RTL builtins for vmull[_high]_p8 intrinsics
Jonathan Wright [Thu, 4 Feb 2021 23:00:00 +0000 (23:00 +0000)]
aarch64: Use RTL builtins for vmull[_high]_p8 intrinsics

Rewrite vmull[_high]_p8 Neon intrinsics to use RTL builtins rather
than inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-02-05  Jonathan Wright  <joanthan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add pmull[2]
builtin generator macros.
* config/aarch64/aarch64-simd.md (aarch64_pmullv8qi): Define.
(aarch64_pmull_hiv16qi_insn): Define.
(aarch64_pmull_hiv16qi): Define.
* config/aarch64/arm_neon.h (vmull_high_p8): Use RTL builtin
instead of inline asm.
(vmull_p8): Likewise.

3 years agoAVR cc0 conversion - adjust peepholes
Senthil Kumar Selvaraj [Fri, 30 Apr 2021 16:34:11 +0000 (16:34 +0000)]
AVR cc0 conversion - adjust peepholes

This patch adjusts peepholes to match and generate parallels with
a clobber of REG_CC.

It also sets mov<mode>_insn as the name of the pattern for the split
insn (rather than the define_insn_and_split), so that
avr_2word_insn_p, which looks for CODE_FOR_mov<mode>_insn, works
correctly. This is required for the *cpse.eq peephole to fire, and
also helps generate better code for avr_out_sbxx_branch.

gcc/ChangeLog:

* config/avr/avr.md: Adjust peepholes to match and
generate parallels with clobber of REG_CC.
(mov<mode>_insn): Rename to mov<mode>_insn_split.
(*mov<mode>_insn): Rename to mov<mode>_insn.

3 years agomiddle-end: Disable section anchors for VAR_DECLs if -fdata-sections
David Edelsohn [Thu, 29 Apr 2021 18:44:01 +0000 (14:44 -0400)]
middle-end: Disable section anchors for VAR_DECLs if -fdata-sections

-fdata-sections places data symbols into their own, unique, named sections.
-fsection-anchors create an anchor to access neighboring symbols
within a section.

When both are enabled, a separate section anchor is created for each
symbol, which provides no benefit.

This patch updates the common gating function use_blocks_for_decl_p() to
return false if -fdata-sections is enabled.

gcc/ChangeLog:

* varasm.c (use_blocks_for_decl_p): Don't use section anchors
for VAR_DECLs if -fdata-sections enabled.

3 years agoDefine target hook to emit KFmode constants for libgcc.
Michael Meissner [Fri, 30 Apr 2021 16:32:08 +0000 (12:32 -0400)]
Define target hook to emit KFmode constants for libgcc.

This patch defines a target hook so that the KFmode constants
(__LIBGCC_KF_MAX__, __LIBGCC_KF_MIN__, and __LIBGCC_KF_EPSILON__) needed to
build _divkc3.c in libgcc are defined.  The need for these constants were added
in the April 28th changes to libgcc that added complex division optimizations.

We only define the KFmode constants if IEEE 128-bit floating point is
supported, but long double does not use the IEEE 128-bit format.  If long
double uses the IEEE 128-bit format, it will use TFmode and not KFmode.

gcc/
2021-04-30  Michael Meissner  <meissner@linux.ibm.com>

PR bootstrap/100327
* config/rs6000/rs6000.c
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
(rs6000_libgcc_floating_mode_supported_p): New target hook.

3 years agoRefactor backward threader registry and profitability code into classes.
Aldy Hernandez [Wed, 28 Apr 2021 09:15:11 +0000 (11:15 +0200)]
Refactor backward threader registry and profitability code into classes.

This refactors the registry and the profitability code from the
backwards threader into two separate classes.  It cleans up the code,
and makes it easier for alternate implementations to share code.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (class thread_jumps): Split out code
from here...
(class back_threader_registry): ...to here...
(class back_threader_profitability): ...and here...
(thread_jumps::thread_through_all_blocks): Remove argument.
(back_threader_registry::back_threader_registry): New.
(back_threader_registry::~back_threader_registry): New.
(back_threader_registry::thread_through_all_blocks): New.
(thread_jumps::profitable_jump_thread_path): Move from here...
(back_threader_profitability::profitable_path_p): ...to here.
(thread_jumps::find_taken_edge): New.
(thread_jumps::convert_and_register_current_path): Move...
(back_threader_registry::register_path): ...to here.
(thread_jumps::register_jump_thread_path_if_profitable): Move...
(thread_jumps::maybe_register_path): ...to here.
(thread_jumps::handle_phi): Call find_taken_edge and
maybe_register_path.
(thread_jumps::handle_assignment): Same.
(thread_jumps::fsm_find_control_statement_thread_paths): Remove
tree argument to handle_phi and handle_assignment.
(thread_jumps::find_jump_threads_backwards): Set m_name.  Remove
set of m_speed_p and m_max_threaded_paths.
(pass_thread_jumps::execute): Remove second argument from
find_jump_threads_backwards.
(pass_early_thread_jumps::execute): Same.

3 years agoJump threader refactor.
Aldy Hernandez [Sat, 21 Nov 2020 17:26:21 +0000 (18:26 +0100)]
Jump threader refactor.

This is an overall refactor of the jump threader, both for the low level
bits in tree-ssa-threadupdate.* and the high level bits in
tree-ssa-threadedge.*.

There should be no functional changes.

Some of the benefits of the refactor are:

a) Eliminates some icky global state (for example the x_vr_values hack).

b) Provides some semblance of an API for the threader.

c) Makes it clearer to see what parts are from the high level
threader, and what parts belong in the low level path registry and
BB threading mechanism.

d) Avoids passing a ton of variables around.

e) Provides for easier sharing with the backward threader.

f) Merged simplify stmt code in VRP and DOM as they were nearly
identical.

This has been bootstrapped and regression tested on x86-64 Linux.
Jeff had also been testing this path as part of his Fedora throughout the
off-season.

gcc/ChangeLog:

* tree-ssa-dom.c (class dom_jump_threader_simplifier): New.
(class dom_opt_dom_walker): Initialize some class variables.
(pass_dominator::execute): Pass evrp_range_analyzer and
dom_jump_threader_simplifier to dom_opt_dom_walker.
Adjust for some functions moving into classes.
(simplify_stmt_for_jump_threading): Adjust and move to...
(jump_threader_simplifier::simplify): ...here.
(dom_opt_dom_walker::before_dom_children): Adjust for
m_evrp_range_analyzer.
(dom_opt_dom_walker::after_dom_children): Remove x_vr_values hack.
(test_for_singularity): Place in dom_opt_dom_walker class.
(dom_opt_dom_walker::optimize_stmt): The argument
evrp_range_analyzer is now a class field.
* tree-ssa-threadbackward.c (class thread_jumps): Add m_registry.
(thread_jumps::thread_through_all_blocks): New.
(thread_jumps::convert_and_register_current_path): Use m_registry.
(pass_thread_jumps::execute): Adjust for thread_through_all_blocks
being in the threader class.
(pass_early_thread_jumps::execute): Same.
* tree-ssa-threadedge.c (threadedge_initialize_values): Move...
(jump_threader::jump_threader): ...here.
(threadedge_finalize_values): Move...
(jump_threader::~jump_threader): ...here.
(jump_threader::remove_jump_threads_including): New.
(jump_threader::thread_through_all_blocks): New.
(record_temporary_equivalences_from_phis): Move...
(jump_threader::record_temporary_equivalences_from_phis): ...here.
(record_temporary_equivalences_from_stmts_at_dest): Move...
(jump_threader::record_temporary_equivalences_from_stmts_at_dest):
Here...
(simplify_control_stmt_condition_1): Move to jump_threader class.
(simplify_control_stmt_condition): Move...
(jump_threader::simplify_control_stmt_condition): ...here.
(thread_around_empty_blocks): Move...
(jump_threader::thread_around_empty_blocks): ...here.
(thread_through_normal_block): Move...
(jump_threader::thread_through_normal_block): ...here.
(thread_across_edge): Move...
(jump_threader::thread_across_edge): ...here.
(thread_outgoing_edges): Move...
(jump_threader::thread_outgoing_edges): ...here.
* tree-ssa-threadedge.h: Move externally facing functings...
(class jump_threader): ...here...
(class jump_threader_simplifier): ...and here.
* tree-ssa-threadupdate.c (struct redirection_data): Remove comment.
(jump_thread_path_allocator::jump_thread_path_allocator): New.
(jump_thread_path_allocator::~jump_thread_path_allocator): New.
(jump_thread_path_allocator::allocate_thread_edge): New.
(jump_thread_path_allocator::allocate_thread_path): New.
(jump_thread_path_registry::jump_thread_path_registry): New.
(jump_thread_path_registry::~jump_thread_path_registry): New.
(jump_thread_path_registry::allocate_thread_edge): New.
(jump_thread_path_registry::allocate_thread_path): New.
(dump_jump_thread_path): Make extern.
(debug (const vec<jump_thread_edge *> &path)): New.
(struct removed_edges): Move to tree-ssa-threadupdate.h.
(struct thread_stats_d): Remove.
(remove_ctrl_stmt_and_useless_edges): Make static.
(lookup_redirection_data): Move...
(jump_thread_path_registry::lookup_redirection_data): ...here.
(ssa_redirect_edges): Make static.
(thread_block_1): Move...
(jump_thread_path_registry::thread_block_1): ...here.
(thread_block): Move...
(jump_thread_path_registry::thread_block): ...here.
(thread_through_loop_header):  Move...
(jump_thread_path_registry::thread_through_loop_header): ...here.
(mark_threaded_blocks): Move...
(jump_thread_path_registry::mark_threaded_blocks): ...here.
(debug_path): Move...
(jump_thread_path_registry::debug_path): ...here.
(debug_all_paths): Move...
(jump_thread_path_registry::dump): ..here.
(rewire_first_differing_edge): Move...
(jump_thread_path_registry::rewire_first_differing_edge): ...here.
(adjust_paths_after_duplication): Move...
(jump_thread_path_registry::adjust_paths_after_duplication): ...here.
(duplicate_thread_path): Move...
(jump_thread_path_registry::duplicate_thread_path): ..here.
(remove_jump_threads_including): Move...
(jump_thread_path_registry::remove_jump_threads_including): ...here.
(thread_through_all_blocks): Move to...
(jump_thread_path_registry::thread_through_all_blocks): ...here.
(delete_jump_thread_path): Remove.
(register_jump_thread): Move...
(jump_thread_path_registry::register_jump_thread): ...here.
* tree-ssa-threadupdate.h: Move externally facing functions...
(class jump_thread_path_allocator): ...here...
(class jump_thread_path_registry): ...and here.
(thread_through_all_blocks): Remove.
(struct removed_edges): New.
(register_jump_thread): Remove.
(remove_jump_threads_including): Remove.
(delete_jump_thread_path): Remove.
(remove_ctrl_stmt_and_useless_edges): Remove.
(free_dom_edge_info): New prototype.
* tree-vrp.c: Remove x_vr_values hack.
(class vrp_jump_threader_simplifier): New.
(vrp_jump_threader_simplifier::simplify): New.
(vrp_jump_threader::vrp_jump_threader): Adjust method signature.
Remove m_dummy_cond.
Instantiate m_simplifier and m_threader.
(vrp_jump_threader::thread_through_all_blocks): New.
(vrp_jump_threader::simplify_stmt): Remove.
(vrp_jump_threader::after_dom_children): Do not set m_dummy_cond.
Remove x_vr_values hack.
(execute_vrp): Adjust for thread_through_all_blocks being in a
class.

3 years agolibstdc++: Implement proposed resolution for LWG 3532
Patrick Palka [Fri, 30 Apr 2021 15:05:22 +0000 (11:05 -0400)]
libstdc++: Implement proposed resolution for LWG 3532

libstdc++-v3/ChangeLog:

* include/std/ranges (split_view::_InnerIter::operator++):
Depend on _Base instead of _Vp directly, as per LWG 3532.

3 years agolibstdc++: Implement P2367 changes to avoid some list-initialization
Patrick Palka [Fri, 30 Apr 2021 14:59:20 +0000 (10:59 -0400)]
libstdc++: Implement P2367 changes to avoid some list-initialization

This implements the wording changes of P2367R0 "Remove misuses of
list-initialization from Clause 24", modulo the parts that depend
on P1739R4 which we don't yet implement (due to LWG 3407).

libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h (subrange::subrange): Avoid
list-initialization in delegating constructor.
* include/std/ranges (single_view): Replace implicit guide
with explicit deduction guide that decays its argument.
(_Single::operator()): Avoid CTAD when constructing the
single_view object.
(_Iota::operator()): Avoid list-initialization.
(__detail::__can_filter_view, _Filter::operator()): Likewise.
(__detail::__can_transform_view, _Transform::operator()): Likewise.
(take_view::begin): Likewise.
(__detail::__can_take_view, _Take::operator()): Likewise.
(__detail::__can_take_while_view, _TakeWhile::operator()): Likewise.
(__detail::__can_drop_view, _Drop::operator()): Likewise.
(__detail::__can_drop_while_view, _DropWhile::operator()): Likewise.
(split_view::split_view): Use views::single when initializing
_M_pattern.
(__detail::__can_split_view, _Split::operator()): Avoid
list-initialization.
(_Counted::operator()): Likewise.
* testsuite/std/ranges/p2367.cc: New test.

3 years agolibstdc++: Use std::addressof to avoid ADL for operator& [PR 60497]
Jonathan Wakely [Fri, 30 Apr 2021 13:45:42 +0000 (14:45 +0100)]
libstdc++: Use std::addressof to avoid ADL for operator& [PR 60497]

This is another small step towards avoiding the problems described in PR
60497, by using std::addressof to avoid ADL, so that we don't require
all template arguments to be complete.

libstdc++-v3/ChangeLog:

PR libstdc++/60497
* include/bits/basic_ios.tcc (basic_ios::copyfmt): use
std::addressof.
* include/bits/basic_string.tcc (basic_string::swap)
(basic_string::assign): Likewise.
* include/bits/deque.tcc (deque::operator=(const deque&)):
Likewise.
* include/bits/stl_tree.h (_Rb_tree::operator=(const * _Rb_tree&)):
Likewise.
* include/bits/vector.tcc (vector::operator=(const vector&)):
Likewise.

3 years agolibstdc++: Implement LWG 1203 for rvalue iostreams
Jonathan Wakely [Fri, 30 Apr 2021 13:07:28 +0000 (14:07 +0100)]
libstdc++: Implement LWG 1203 for rvalue iostreams

This implements the resolution of LWG 1203 so that the constraints for
rvalue stream insertion/extraction are simpler, and the return type is
the original rvalue stream type not its base class.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/std/istream (operator>>(Istream&&, x&)): Simplify, as
per LWG 1203.
* include/std/ostream (operator<<(Ostream&&, const x&)):
Likewise.
* testsuite/27_io/basic_istream/extractors_character/char/lwg2499_neg.cc:
Adjust dg-error pattern.
* testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499_neg.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/4.cc: Define
is_extractable trait to replace std::__is_extractable. Make it
work with rvalue streams as well as lvalues, to replace f() and
g() helper functions.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/4.cc:
Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
Define is_insertable trait to replace std::__is_insertable. Make
it work with rvalue streams as well as lvalues, to replace f()
and g() helper functions.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
Likewise.
* testsuite/27_io/filesystem/path/io/dr2989.cc: Prune additional
errors from new constraints.
* testsuite/27_io/rvalue_streams-2.cc: Remove PR 80675 checks,
which are no longer expected to compile.
* testsuite/27_io/rvalue_streams.cc: Adjust existing test.
Verify LWG 1203 changes.

3 years agolibstdc++: Use <sys/socket.h> features conditionally [PR 100285]
Jonathan Wakely [Fri, 30 Apr 2021 13:25:25 +0000 (14:25 +0100)]
libstdc++: Use <sys/socket.h> features conditionally [PR 100285]

This makes the uses of getsockopt and setsockopt in
<experimental/socket> conditional on the availability of <sys/socket.h>.

It also fixes a test to check for <sys/socket.h> instead of <socket.h>.

libstdc++-v3/ChangeLog:

PR libstdc++/100285
* include/experimental/socket (__basic_socket_impl::set_option)
(__basic_socket_impl::get_option) [!_GLIBCXX_HAVE_SYS_SOCKET_H]:
Just set error code.
* testsuite/experimental/net/socket/socket_base.cc: CHeck
for <sys/socket.h> not <socket.h>.

3 years agolibstdc++: Define effective-target for net::ip features [PR 100351]
Jonathan Wakely [Fri, 30 Apr 2021 10:45:07 +0000 (11:45 +0100)]
libstdc++: Define effective-target for net::ip features [PR 100351]

Define a new effective-target keyword so that tests for the Networking
TS <experimental/internet> header can be skipped on targets where none
of it can be usefully defined.

libstdc++-v3/ChangeLog:

PR libstdc++/100180
PR libstdc++/100286
PR libstdc++/100351
* testsuite/experimental/net/internet/address/v4/comparisons.cc:
Use new effective-target keyword.
* testsuite/experimental/net/internet/address/v4/cons.cc:
Likewise.
* testsuite/experimental/net/internet/address/v4/creation.cc:
Likewise.
* testsuite/experimental/net/internet/address/v4/members.cc:
Likewise.
* testsuite/experimental/net/internet/address/v6/members.cc:
Likewise.
* testsuite/experimental/net/internet/resolver/base.cc:
Likewise.
* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
Likewise.
* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
Likewise.
* testsuite/experimental/net/internet/socket/opt.cc:
Likewise.
* testsuite/experimental/net/internet/tcp.cc:
Likewise.
* testsuite/experimental/net/internet/udp.cc:
Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_net_ts_ip):
New proc to check net_ts_ip et.

3 years agogcc/genflags.c: Improve error message
Christophe Lyon [Fri, 30 Apr 2021 12:13:55 +0000 (12:13 +0000)]
gcc/genflags.c: Improve error message

When an iterator cannot be expanded, it is helpful to see the expanded
name which is causing problems.  It would be better to also print the
current iterator value (which couldn't match), but I couldn't find
how.

2021-04-30  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* genflags.c (gen_insn): Print failed expansion string.

3 years agoc++/98032 - add testcase
Richard Biener [Fri, 30 Apr 2021 12:14:48 +0000 (14:14 +0200)]
c++/98032 - add testcase

This adds another testcase for PR95719.

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

PR c++/98032
* g++.dg/pr98032.C: New testcase.

3 years agoUpdate alignment_for_piecewise_move
H.J. Lu [Fri, 30 Apr 2021 11:36:36 +0000 (04:36 -0700)]
Update alignment_for_piecewise_move

alignment_for_piecewise_move is called only with MOVE_MAX_PIECES or
STORE_MAX_PIECES, which are the number of bytes at a time that we
can move or store efficiently.  We should call mode_for_size without
limit to MAX_FIXED_MODE_SIZE, which is an integer expression for the
size in bits of the largest integer machine mode that should actually
be used, may be smaller than MOVE_MAX_PIECES or STORE_MAX_PIECES, which
may use vector.

* expr.c (alignment_for_piecewise_move): Call mode_for_size
without limit to MAX_FIXED_MODE_SIZE.

3 years agoDon't use nullptr return from simplify_gen_subreg
H.J. Lu [Thu, 29 Apr 2021 18:12:09 +0000 (11:12 -0700)]
Don't use nullptr return from simplify_gen_subreg

Check nullptr return from simplify_gen_subreg.  Don't use it if it is
nullptr.

PR middle-end/90773
* builtins.c (builtin_memset_gen_str): Don't use return from
simplify_gen_subreg.

3 years agotree-optimization/96513 - add testcase for fixed bug
Richard Biener [Fri, 30 Apr 2021 09:13:42 +0000 (11:13 +0200)]
tree-optimization/96513 - add testcase for fixed bug

This adds a testcase for a bug that was fixed with the
hybrid SLP detection rewrite.

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

PR tree-optimization/96513
* gcc.dg/torture/pr96513.c: New testcase.

3 years agoi386: Introduce reversed ADC and SBB patterns [PR98060]
Uros Bizjak [Fri, 30 Apr 2021 08:15:26 +0000 (10:15 +0200)]
i386: Introduce reversed ADC and SBB patterns [PR98060]

The compiler is able to merge LTU comparisons with PLUS or MINUS pattern to
form addition with carry (ADC) and subtraction with borrow (SBB) instructions:

op = op + carry [ADC $0, op]
op = op - carry [SBB $0, op]

The patch introduces reversed ADC and SBB insn patterns:

op = op + !carry [SBB $-1, op]
op = op - !carry [ADC $-1, op]

allowing the compiler to also merge GEU comparisons.

2021-04-30  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/
PR target/98060
* config/i386/i386.md (*add<mode>3_carry_0r): New insn pattern.
(*addsi3_carry_zext_0r): Ditto.
(*sub<mode>3_carry_0): Ditto.
(*subsi3_carry_zext_0r): Ditto.
* config/i386/predicates.md (ix86_carry_flag_unset_operator):
New predicate.
* config/i386/i386.c (ix86_rtx_costs) <case PLUS, case MINUS>:
Also consider ix86_carry_flag_unset_operator to calculate
the cost of adc/sbb insn.

gcc/testsuite/

PR target/98060
* gcc.target/i386/pr98060.c: New test.

3 years agomodulo-sched: skip loops with strange register defs [PR100225]
Roman Zhuykov [Fri, 30 Apr 2021 08:08:03 +0000 (11:08 +0300)]
modulo-sched: skip loops with strange register defs [PR100225]

PR84878 fix adds an assertion which can fail, e.g. when stack pointer
is adjusted inside the loop.  We have to prevent it and search earlier
for any 'strange' instruction.  The solution is to skip the whole loop
if using 'note_stores' we found that one of hard registers is in
'df->regular_block_artificial_uses' set.

Also patch properly prohibit not single-set instruction in loop body.

gcc/ChangeLog:

PR rtl-optimization/100225
PR rtl-optimization/84878
* modulo-sched.c (sms_schedule): Use note_stores to skip loops
where we have an instruction which touches (writes) any hard
register from df->regular_block_artificial_uses set.
Allow not-single-set instruction only right before basic block
tail.

gcc/testsuite/ChangeLog:

PR rtl-optimization/100225
PR rtl-optimization/84878
* gcc.dg/pr100225.c: New test.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-c-c++-common/atomic_capture-3.c: New test.

3 years agoRISC-V: For '-march' and '-mabi' options, add 'Negative' property mentions itself.
Geng Qi [Wed, 28 Apr 2021 08:29:33 +0000 (16:29 +0800)]
RISC-V: For '-march' and '-mabi' options, add 'Negative' property mentions itself.

When use multi-lib riscv-tool-chain. A bug is triggered when there are two
'-march' at command line.
riscv64-unknown-elf-gcc -march=rv32gcp -mabi=ilp32f -march=rv32gcpzp64 HelloWorld.c
/lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: /lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/lib/crt0.o: ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/lib/crt0.o
/lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: /lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/crtbegin.o: ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /lhome/gengq/riscv64-linux-ptest/lib/gcc/riscv64-unknown-elf/10.2.0/crtbegin.o
......

This patch fix it. And the DRIVER would prune the extra '-march' and '-mabi'
options and keep only the last one valid.

gcc/ChangeLog:
* config/riscv/riscv.opt (march=,mabi=): Negative itself.

3 years agoRISC-V: Add patterns for builtin overflow.
LevyHsu [Thu, 29 Apr 2021 05:42:04 +0000 (13:42 +0800)]
RISC-V: Add patterns for builtin overflow.

gcc/
* config/riscv/riscv.c (riscv_min_arithmetic_precision): New.
* config/riscv/riscv.h (TARGET_MIN_ARITHMETIC_PRECISION): New.
* config/riscv/riscv.md (addv<mode>4, uaddv<mode>4): New.
(subv<mode>4, usubv<mode>4, mulv<mode>4, umulv<mode>4): New.

3 years agoDaily bump.
GCC Administrator [Fri, 30 Apr 2021 00:16:37 +0000 (00:16 +0000)]
Daily bump.

3 years agomerge ix86- and x86_64-*-* in config.gcc
Alexandre Oliva [Thu, 29 Apr 2021 22:31:32 +0000 (19:31 -0300)]
merge ix86- and x86_64-*-* in config.gcc

Uros observed that i[34567]86-*-* and x86_64-*-* cpu_type-setting
target cases were equivalent.  I've verified that this was the case,
and combined them.

for  gcc/ChangeLog

* config.gcc: Merged x86 and x86_64 cpu_type-setting cases.

3 years agoadd ASM_OUTPUT_MAX_SKIP_ALIGN to i386.h
Alexandre Oliva [Thu, 29 Apr 2021 22:31:30 +0000 (19:31 -0300)]
add ASM_OUTPUT_MAX_SKIP_ALIGN to i386.h

Several i386 align tests expect p2align to be used, but not all
configurations define ASM_OUTPUT_MAX_SKIP_ALIGN, even when
HAVE_GAS_MAX_SKIP_P2ALIGN.

i386.h had an equivalent ASM_OUTPUT_MAX_SKIP_PAD.  I've renamed it and
its uses to the documented _ALIGN spelling, and dropped all redundant
defines elsewhere in gcc/config/i386/.

for  gcc/ChangeLog

* config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Rename to...
(ASM_OUTPUT_MAX_SKIP_ALIGN): ... this.  Enclose in do/while(0).
* config/i386/i386.c: Adjust.
* config/i386/i386.md: Adjust.
* config/i386/darwin.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Drop.
* config/i386/dragonfly.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
* config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
(ASM_OUTPUT_MAX_SKIP_PAD): Likewise.

3 years agoUpdate gcc sv.po.
Joseph Myers [Thu, 29 Apr 2021 20:08:42 +0000 (20:08 +0000)]
Update gcc sv.po.

* sv.po: Update.

3 years agoi386: Optimize carry flag comparisons a bit
Uros Bizjak [Thu, 29 Apr 2021 20:02:00 +0000 (22:02 +0200)]
i386: Optimize carry flag comparisons a bit

In ix86_int_compare, opportunistically swap operands of GTU and LEU comparisons
to emit carry flag comparison, with the expectation that the comparison will
combine to *add<mode>3_carry_0 or *sub<mode>3_carry_0 insn pattern.

Do not use ix86_expand_carry_flag_compare because this function prefers
carry flag comparisons too much - it forces the constants into registers
and/or emits additional arithmetic instructions to convert simple
comparisons into carry flag comparisons - but simply swap operands to
convert GTU and LEU comparisons into GEU and LTU ones.

Also, change the insn predicates of *add<mode>3_carry_0 and
*sub<mode>3_carry_0 insn patterns to allow more combine opportunities
with memory operands.

2021-04-29  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/i386-expand.c (ix86_expand_int_compare):
Swap operands of GTU and LEU comparison to emit carry flag comparison.
* config/i386/i386.md (*add<mode>3_carry_0): Change insn
predicate to allow more combine opportunities with memory operands.
(*sub<mode>3_carry_0): Ditto.

3 years agopreprocessor: Handle digit separators in #line [PR82359]
Joseph Myers [Thu, 29 Apr 2021 19:50:47 +0000 (19:50 +0000)]
preprocessor: Handle digit separators in #line [PR82359]

As reported in bug 82359, the preprocessor does not allow C++ digit
separators in the line number in a #line directive, despite the
standard syntax for that directive using digit-sequence which allows
digit separators.

There is some confusion in that bug about whether C++ is meant to
allow digit separators there or not, but the last comment there
suggests they are meant to be allowed, and the version of digit
separators accepted for C2X at the March meeting explicitly mentions
digit separators in the #line specification to avoid any ambiguity
there.

This patch thus adds code to handle digit separators in the line
number in #line, as part of the preparation for enabling digit
separators in C2X mode.  The code changed does not contain any
conditionals for whether digit separators are supported in the chosen
language version, because that was handled earlier in pp-number lexing
and if they aren't supported they won't appear in the string passed to
that function.  It does however make sure not to allow adjacent digit
separators because those are only handled at a later stage of lexing
at present.  (Problems with how certain source character sequences
involving digit separators that don't actually match the pp-number
syntax get lexed as a pp-number and only diagnosed later, if at all,
are bugs 83873 and 97604, to be addressed separately.)

Making the change in this location will have the effect of allowing
digit separators in the "# <line-number> <file> <flags>" form of
directive as well as #line; I don't think that's a problem.

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

libcpp/
PR preprocessor/82359
* directives.c (strtolinenum): Handle digit separators.

gcc/testsuite/
PR preprocessor/82359
* g++.dg/cpp1y/digit-sep-line.C,
g++.dg/cpp1y/digit-sep-line-neg.C: New tests.

3 years agoc++: Add using-declaration testcase
Jason Merrill [Wed, 30 Dec 2020 18:07:57 +0000 (13:07 -0500)]
c++: Add using-declaration testcase

gcc/testsuite/ChangeLog:

* g++.dg/lookup/using-decl1.C: New test.

3 years agoc++: Use empty field in constexpr eval.
Jason Merrill [Mon, 25 Jan 2021 22:02:57 +0000 (17:02 -0500)]
c++: Use empty field in constexpr eval.

In discussion of PR98463, Jakub noted that cxx_fold_indirect_ref_1 was
bailing out early for empty bases even when we do have fields for them (in
C++17 mode or later).  This corrects that.

gcc/cp/ChangeLog:

* constexpr.c (cxx_fold_indirect_ref_1): Only set *empty_base if we
don't find a field.

3 years agoc++: Fix friend attributes [PR51344]
Jason Merrill [Fri, 5 Feb 2021 15:36:49 +0000 (10:36 -0500)]
c++: Fix friend attributes [PR51344]

51344 was a problem with calling save_template_attributes twice for the same
friend function: once from do_friend and once from grokmethod.  The 2012
patch for the bug avoided creating an infinite loop when this happens, but
it's better to avoid the duplication in the first place.  This also restores
the dependent attributes to the beginning of the attribute list, as
originally intended.  And then apply_late_template_attributes can avoid
copying the non-dependent attributes.

gcc/cp/ChangeLog:

PR c++/51344
* decl2.c (grokfield): Call cplus_decl_attributes for friend.
(save_template_attributes): Use chainon.
* friend.c (do_friend): Remove attrlist parm.
* cp-tree.h (do_friend): Adjust.
* class.c (add_implicitly_declared_members): Adjust.
* decl.c (grokdeclarator): Adjust.
* pt.c (apply_late_template_attributes): Optimize.

3 years agoc++: ICE with anonymous union [PR97974]
Jason Merrill [Sat, 10 Apr 2021 18:00:15 +0000 (14:00 -0400)]
c++: ICE with anonymous union [PR97974]

While working on the GCC 11 patch, it occurred to me that we could move
the errors about invalid members from finish_struct_anon_r to here, so we
properly get a diagnostic in g++.law/union4.C.

gcc/cp/ChangeLog:

PR c++/97974
* class.c (finish_struct_anon_r): Drop complain parm.
Remove non-field diagnostic.
(finish_struct_anon): Adjust.
* decl.c (fixup_anonymous_aggr): Move non-field diagnostic here.

gcc/testsuite/ChangeLog:

PR c++/97974
* g++.old-deja/g++.law/union4.C: Add expected diagnostic.

3 years agoc++: constant expressions are evaluated [PR93314]
Jason Merrill [Wed, 14 Apr 2021 15:24:50 +0000 (11:24 -0400)]
c++: constant expressions are evaluated [PR93314]

My GCC 11 patch for PR93314 turned off cp_unevaluated_operand while
processing an id-expression that names a non-static data member, but the
broader issue is that in general, a constant-expression is evaluated even in
an unevaluated operand.

gcc/cp/ChangeLog:

* cp-tree.h (cp_evaluated): Add reset parm to constructor.
* parser.c (cp_parser_constant_expression): Change
allow_non_constant_p to int.  Use cp_evaluated.
(cp_parser_initializer_clause): Pass 2 to allow_non_constant_p.
* semantics.c (finish_id_expression_1): Don't mess with
cp_unevaluated_operand here.

3 years agoc++: unset COMPOUND_LITERAL_P [PR100079]
Jason Merrill [Thu, 15 Apr 2021 21:04:24 +0000 (17:04 -0400)]
c++: unset COMPOUND_LITERAL_P [PR100079]

Once a CONSTRUCTOR has been digested and used as an initializer, it no
longer represents a compound literal by itself, so we can clear the flag,
letting us use it consistently to distinguish between digested and
undigested initializer-lists.

gcc/cp/ChangeLog:

* cp-tree.h: Clarify comments.
* pt.c (get_template_parm_object): Add assert.
* semantics.c (finish_compound_literal): Clear TREE_HAS_CONSTRUCTOR.
* tree.c (zero_init_expr_p): Check TREE_HAS_CONSTRUCTOR.
* typeck2.c (store_init_value): Likewise.

3 years agoc++: Overeager use of deleted function before ADL [PR68942]
Patrick Palka [Thu, 29 Apr 2021 17:43:00 +0000 (13:43 -0400)]
c++: Overeager use of deleted function before ADL [PR68942]

Here, at template definition time, ordinary name lookup for 'foo(t)'
finds only the deleted function, and so we form a CALL_EXPR thereof.
Later at instantiation time, when initially substituting into this
CALL_EXPR with T=N::A, we end up calling mark_used on this deleted
function (since it's the only function in the overload set), triggering
a bogus "use of deleted function error", before we get to augment the
overload set via ADL.

This patch fixes this issue by using the tf_conv flag to disable
mark_used during the initial substitution into the callee of a
CALL_EXPR when KOENIG_P, since at this point we're still figuring out
which functions are candidates.

gcc/cp/ChangeLog:

PR c++/68942
* pt.c (tsubst_copy_and_build) <case CALL_EXPR>: When KOENIG_P,
set tf_conv during the initial substitution into the function.

gcc/testsuite/ChangeLog:

PR c++/68942
* g++.dg/template/koenig12.C: New test.

3 years agoc++: Add testcase for already fixed PR [PR94102]
Marek Polacek [Thu, 29 Apr 2021 17:30:39 +0000 (13:30 -0400)]
c++: Add testcase for already fixed PR [PR94102]

We correctly accept this testcase since r11-1571.

gcc/testsuite/ChangeLog:

PR c++/94102
* g++.dg/cpp1z/class-deduction87.C: New test.

3 years agoUpdate gcc fr.po.
Joseph Myers [Thu, 29 Apr 2021 16:37:41 +0000 (16:37 +0000)]
Update gcc fr.po.

* fr.po: Update.

3 years agortl-ssa: Fix -fcompare-debug failure [PR100303]
Richard Sandiford [Thu, 29 Apr 2021 16:24:57 +0000 (17:24 +0100)]
rtl-ssa: Fix -fcompare-debug failure [PR100303]

This patch fixes an oversight in the handling of debug instructions
in rtl-ssa.  At the moment (and whether this is a good idea or not
remains to be seen), we maintain a linear RPO sequence of definitions
and non-debug uses.  If a register is defined more than once, we use
a degenerate phi to reestablish a previous definition where necessary.

However, debug instructions shouldn't of course affect codegen,
so we can't create a new definition just for them.  In those situations
we instead hang the debug use off the real definition (meaning that
debug uses do not follow a linear order wrt definitions).  Again,
it remains to be seen whether that's a good idea.

The problem in the PR was that we weren't taking this into account
when increasing (or potentially increasing) the live range of an
existing definition.  We'd create the phi even if it would only
be used by debug instructions.

The patch goes for the simple but inelegant approach of passing
a bool to say whether the use is a debug use or not.  I imagine
this area will need some tweaking based on experience in future.

gcc/
PR rtl-optimization/100303
* rtl-ssa/accesses.cc (function_info::make_use_available): Take a
boolean that indicates whether the use will only be used in
debug instructions.  Treat it in the same way that existing
cross-EBB debug references would be handled if so.
(function_info::make_uses_available): Likewise.
* rtl-ssa/functions.h (function_info::make_uses_available): Update
prototype accordingly.
(function_info::make_uses_available): Likewise.
* fwprop.c (try_fwprop_subst): Update call accordingly.

3 years agoFix nios2 build failure
Jeff Law [Thu, 29 Apr 2021 15:08:56 +0000 (09:08 -0600)]
Fix nios2 build failure

gcc

* config/nios2/nios2-protos.h (nios2_fpu_insn_enabled): Move outside
of RTX_CODE guard.

3 years agoi386: Mark x86 masked load builtins pure [PR100312]
Uros Bizjak [Thu, 29 Apr 2021 14:43:33 +0000 (16:43 +0200)]
i386: Mark x86 masked load builtins pure [PR100312]

Mark x86 AVX and AVX2 masked load builtins pure to enable dead code
elimination and more appropriate alias analysis.

2021-04-29  UroÅ¡ Bizjak  <ubizjak@gmail.com>
    Richard Biener  <rguenther@suse.de>
gcc/
PR target/100312
* config/i386/i386-builtin.def (IX86_BUILTIN_MASKLOADPD)
(IX86_BUILTIN_MASKLOADPS, IX86_BUILTIN_MASKLOADPD256)
(IX86_BUILTIN_MASKLOADPS256, IX86_BUILTIN_MASKLOADD)
(IX86_BUILTIN_MASKLOADQ, IX86_BUILTIN_MASKLOADD256)
(IX86_BUILTIN_MASKLOADQ256): Move from SPECIAL_ARGS
to PURE_ARGS category.
* config/i386/i386-builtins.c (ix86_init_mmx_sse_builtins):
Handle PURE_ARGS category.
* config/i386/i386-expand.c (ix86_expand_builtin): Ditto.

3 years agoAdd parallelism support to gcov for MinGW platforms
Eric Botcazou [Thu, 29 Apr 2021 12:03:09 +0000 (14:03 +0200)]
Add parallelism support to gcov for MinGW platforms

If you attempt a profiled bootstrap on the MinGW platforms with -jN, N > 1,
it miserably fails because of profile mismatches all over the place, the
reason being that gcov has no support for parallelism on these platforms.

libgcc/
* libgcov.h: For the target, define GCOV_LOCKED_WITH_LOCKING
if __MSVCRT__ and, for the host, define it if HOST_HAS_LK_LOCK.
* libgcov-driver.c: Add directives if GCOV_LOCKED_WITH_LOCKING.
gcc/
* configure.ac: Check for the presence of sys/locking.h header and
for whether _LK_LOCK is supported by _locking.
* configure: Regenerate.
* config.in: Likewise.
* gcov-io.h: Define GCOV_LOCKED_WITH_LOCKING if HOST_HAS_LK_LOCK.
* gcov-io.c (gcov_open): Add support for GCOV_LOCKED_WITH_LOCKING.
* system.h: Include <sys/locking.h> if HAVE_SYS_LOCKING_H.

3 years agoi386: Cleanup comparison predicates.
Uros Bizjak [Thu, 29 Apr 2021 13:24:51 +0000 (15:24 +0200)]
i386: Cleanup comparison predicates.

CCCmode is allowed only with GEU and LTU comparison codes.  Also allow
CCGZmode for these two codes.  There is no need to check for trivial FP
comparison operator, ix86_fp_compare_code_to_integer will return
UNKNOWN code for unsupported operators.

2021-04-29  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/predicates.md (fcmov_comparison_operator):
Do not check for trivial FP comparison operator.
<case GEU, case LTU>: Allow CCGZmode.
<case GTU, case LEU>: Do not allow CCCmode.
(ix86_comparison_operator) <case GTU, case LEU>: Allow only CCmode.
(ix86_carry_flag_operator): Match only LTU and UNLT code.
Do not check for trivial FP comparison operator.  Allow CCGZmode.

3 years ago[omp, simt] Handle alternative IV
Tom de Vries [Thu, 1 Oct 2020 16:11:02 +0000 (18:11 +0200)]
[omp, simt] Handle alternative IV

Consider the test-case libgomp.c/pr81778.c added in this commit, with
this core loop (note: CANARY_SIZE set to 0 for simplicity):
...
  int s = 1;
  #pragma omp target simd
  for (int i = N - 1; i > -1; i -= s)
    a[i] = 1;
...
which, given that N is 32, sets a[0..31] to 1.

After omp-expand, this looks like:
...
  <bb 5> :
  simduid.7 = .GOMP_SIMT_ENTER (simduid.7);
  .omp_simt.8 = .GOMP_SIMT_ENTER_ALLOC (simduid.7);
  D.3193 = -s;
  s.9 = s;
  D.3204 = .GOMP_SIMT_LANE ();
  D.3205 = -s.9;
  D.3206 = (int) D.3204;
  D.3207 = D.3205 * D.3206;
  i = D.3207 + 31;
  D.3209 = 0;
  D.3210 = -s.9;
  D.3211 = D.3210 - i;
  D.3210 = -s.9;
  D.3212 = D.3211 / D.3210;
  D.3213 = (unsigned int) D.3212;
  D.3213 = i >= 0 ? D.3213 : 0;

  <bb 19> :
  if (D.3209 < D.3213)
    goto <bb 6>; [87.50%]
  else
    goto <bb 7>; [12.50%]

  <bb 6> :
  a[i] = 1;
  D.3215 = -s.9;
  D.3219 = .GOMP_SIMT_VF ();
  D.3216 = (int) D.3219;
  D.3220 = D.3215 * D.3216;
  i = D.3220 + i;
  D.3209 = D.3209 + 1;
  goto <bb 19>; [100.00%]
...

On nvptx, the first time bb6 is executed, i is in the 0..31 range (depending
on the lane that is executing) at bb entry.

So we have the following sequence:
- a[0..31] is set to 1
- i is updated to -32..-1
- D.3209 is updated to 1 (being 0 initially)
- bb19 is executed, and if condition (D.3209 < D.3213) == (1 < 32) evaluates
  to true
- bb6 is once more executed, which should not happen because all the elements
  that needed to be handled were already handled.
- consequently, elements that should not be written are written
- with CANARY_SIZE == 0, we may run into a libgomp error:
  ...
  libgomp: cuCtxSynchronize error: an illegal memory access was encountered
  ...
  and with CANARY_SIZE unmodified, we run into:
  ...
  Expected 0, got 1 at base[-961]
  Aborted (core dumped)
  ...

The cause of this is as follows:
- because the step s is a variable rather than a constant, an alternative
  IV (D.3209 in our example) is generated in expand_omp_simd, and the
  loop condition is tested in terms of the alternative IV rather than
  the original IV (i in our example).
- the SIMT code in expand_omp_simd works by modifying step and initial value.
- The initial value fd->loop.n1 is loaded into a variable n1, which is
  modified by the SIMT code and then used there-after.
- The step fd->loop.step is loaded into a variable step, which is modified
  by the SIMT code, but afterwards there are uses of both step and
  fd->loop.step.
- There are uses of fd->loop.step in the alternative IV handling code,
  which should use step instead.

Fix this by introducing an additional variable orig_step, which is not
modified by the SIMT code and replacing all remaining uses of fd->loop.step
by either step or orig_step.

Build on x86_64-linux with nvptx accelerator, tested libgomp.

This fixes for-5.c and for-6.c FAILs I'm currently seeing on a quadro m1200
with driver 450.66.

gcc/ChangeLog:

2020-10-02  Tom de Vries  <tdevries@suse.de>

* omp-expand.c (expand_omp_simd): Add step_orig, and replace uses of
fd->loop.step by either step or orig_step.

libgomp/ChangeLog:

2020-10-02  Tom de Vries  <tdevries@suse.de>

* testsuite/libgomp.c/pr81778.c: New test.

3 years agoSmall housekeeping work in SPARC back-end
Eric Botcazou [Thu, 29 Apr 2021 11:34:27 +0000 (13:34 +0200)]
Small housekeeping work in SPARC back-end

gcc/
* config/sparc/sparc.c (gen_load_pcrel_sym): Delete.
(load_got_register): Do the PIC dance here.
(sparc_legitimize_tls_address): Simplify.
(sparc_emit_probe_stack_range): Likewise.
(sparc32_initialize_trampoline): Likewise.
(sparc64_initialize_trampoline): Likewise.
* config/sparc/sparc.md (load_pcrel_sym<P:mode>): Add @ marker.
(probe_stack_range<P:mode>): Likewise.
(flush<P:mode>): Likewise.
(tgd_hi22<P:mode>): Likewise.
(tgd_lo10<P:mode>): Likewise.
(tgd_add<P:mode>): Likewise.
(tgd_call<P:mode>): Likewise.
(tldm_hi22<P:mode>): Likewise.
(tldm_lo10<P:mode>): Likewise.
(tldm_add<P:mode>): Likewise.
(tldm_call<P:mode>): Likewise.
(tldo_hix22<P:mode>): Likewise.
(tldo_lox10<P:mode>): Likewise.
(tldo_add<P:mode>): Likewise.
(tie_hi22<P:mode>): Likewise.
(tie_lo10<P:mode>): Likewise.
(tie_add<P:mode>): Likewise.
(tle_hix22<P:mode>): Likewise.
(tle_lox10<P:mode>): Likewise.
(stack_protect_setsi): Rename to...
(stack_protect_set32): ...this.
(stack_protect_setdi): Rename to...
(stack_protect_set64): ...this.
(stack_protect_set): Adjust calls to above.
(stack_protect_testsi): Rename to...
(stack_protect_test32): ...this.
(stack_protect_testdi): Rename to...
(stack_protect_test64): ...this.
(stack_protect_test): Adjust calls to above.

3 years agoGenerate offset adjusted operation for op_by_pieces operations
H.J. Lu [Mon, 10 Jun 2019 16:57:15 +0000 (09:57 -0700)]
Generate offset adjusted operation for op_by_pieces operations

Add an overlap_op_by_pieces_p target hook for op_by_pieces operations
between two areas of memory to generate one offset adjusted operation
in the smallest integer mode for the remaining bytes on the last piece
operation of a memory region to avoid doing more than one smaller
operations.

Pass the RTL information from the previous iteration to m_constfn in
op_by_pieces operation so that builtin_memset_[read|gen]_str can
generate the new RTL from the previous RTL.

Tested on Linux/x86-64.

gcc/

PR middle-end/90773
* builtins.c (builtin_memcpy_read_str): Add a dummy argument.
(builtin_strncpy_read_str): Likewise.
(builtin_memset_read_str): Add an argument for the previous RTL
information and generate the new RTL from the previous RTL info.
(builtin_memset_gen_str): Likewise.
* builtins.h (builtin_strncpy_read_str): Update the prototype.
(builtin_memset_read_str): Likewise.
* expr.c (by_pieces_ninsns): If targetm.overlap_op_by_pieces_p()
returns true, round up size and alignment to the widest integer
mode for maximum size.
(pieces_addr::adjust): Add a pointer to by_pieces_prev argument
and pass it to m_constfn.
(op_by_pieces_d): Add m_push and m_overlap_op_by_pieces.
(op_by_pieces_d::op_by_pieces_d): Add a bool argument to
initialize m_push.  Initialize m_overlap_op_by_pieces with
targetm.overlap_op_by_pieces_p ().
(op_by_pieces_d::run): Pass the previous RTL information to
pieces_addr::adjust and generate overlapping operations if
m_overlap_op_by_pieces is true.
(PUSHG_P): New.
(move_by_pieces_d::move_by_pieces_d): Updated for op_by_pieces_d
change.
(store_by_pieces_d::store_by_pieces_d): Updated for op_by_pieces_d
change.
(can_store_by_pieces): Use by_pieces_constfn on constfun.
(store_by_pieces): Use by_pieces_constfn on constfun.  Updated
for op_by_pieces_d change.
(clear_by_pieces_1): Add a dummy argument.
(clear_by_pieces): Updated for op_by_pieces_d change.
(compare_by_pieces_d::compare_by_pieces_d): Likewise.
(string_cst_read_str): Add a dummy argument.
* expr.h (by_pieces_constfn): Add a dummy argument.
(by_pieces_prev): New.
* target.def (overlap_op_by_pieces_p): New target hook.
* config/i386/i386.c (TARGET_OVERLAP_OP_BY_PIECES_P): New.
* doc/tm.texi.in: Add TARGET_OVERLAP_OP_BY_PIECES_P.
* doc/tm.texi: Regenerated.

gcc/testsuite/

PR middle-end/90773
* g++.dg/pr90773-1.h: New test.
* g++.dg/pr90773-1a.C: Likewise.
* g++.dg/pr90773-1b.C: Likewise.
* g++.dg/pr90773-1c.C: Likewise.
* g++.dg/pr90773-1d.C: Likewise.
* gcc.target/i386/pr90773-1.c: Likewise.
* gcc.target/i386/pr90773-2.c: Likewise.
* gcc.target/i386/pr90773-3.c: Likewise.
* gcc.target/i386/pr90773-4.c: Likewise.
* gcc.target/i386/pr90773-5.c: Likewise.
* gcc.target/i386/pr90773-6.c: Likewise.
* gcc.target/i386/pr90773-7.c: Likewise.
* gcc.target/i386/pr90773-8.c: Likewise.
* gcc.target/i386/pr90773-9.c: Likewise.
* gcc.target/i386/pr90773-10.c: Likewise.
* gcc.target/i386/pr90773-11.c: Likewise.
* gcc.target/i386/pr90773-12.c: Likewise.
* gcc.target/i386/pr90773-13.c: Likewise.
* gcc.target/i386/pr90773-14.c: Likewise.

3 years agotree-optimization/100253 - fix bogus aligned vectorized loads/stores
Richard Biener [Thu, 29 Apr 2021 09:52:08 +0000 (11:52 +0200)]
tree-optimization/100253 - fix bogus aligned vectorized loads/stores

At some point DR_MISALIGNMENT was supposed to be -1 when the
access was not element aligned.  That's obviously not true at this
point so this adjusts both store and load vectorizing to no longer
assume this which in turn allows simplifying the code.

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

PR tree-optimization/100253
* tree-vect-stmts.c (vectorizable_load): Do not assume
element alignment when DR_MISALIGNMENT is -1.
(vectorizable_store): Likewise.

* g++.dg/pr100253.C: New testcase.

3 years agotestsuite: Remove dg-options from pr100305.c [PR100305]
Jakub Jelinek [Thu, 29 Apr 2021 09:42:08 +0000 (11:42 +0200)]
testsuite: Remove dg-options from pr100305.c [PR100305]

The test FAILs on i?86-linux (due to -Wpsabi warnings).  But, on closer
inspection it seems there is another problem, the dg-options in the testcase
means that the test is compiled with -O0 -O, -O1 -O, -O2 -O, -O3 -O, -Os -O
etc. options, so effectively is tested multiple times with the same options.

Fixed by dropping the dg-options line, then we have -w by default and iterate
over all the optimization levels (including the -O).

2021-04-29  Jakub Jelinek  <jakub@redhat.com>

PR target/100305
* gcc.c-torture/compile/pr100305.c: Remove dg-options.  Add PR line.

3 years agoaarch64: Fix ICE in aarch64_add_offset_1_temporaries [PR100302]
Jakub Jelinek [Thu, 29 Apr 2021 09:34:50 +0000 (11:34 +0200)]
aarch64: Fix ICE in aarch64_add_offset_1_temporaries [PR100302]

In PR94121 I've changed aarch64_add_offset_1 to use absu_hwi instead of
abs_hwi because offset can be HOST_WIDE_INT_MIN.  As can be seen with
the testcase below, aarch64_add_offset_1_temporaries suffers from the same
problem and should be in sync with aarch64_add_offset_1, i.e. for
HOST_WIDE_INT_MIN it needs a temporary.

2021-04-29  Jakub Jelinek  <jakub@redhat.com>

PR target/100302
* config/aarch64/aarch64.c (aarch64_add_offset_1_temporaries): Use
absu_hwi instead of abs_hwi.

* gcc.target/aarch64/sve/pr100302.c: New test.

3 years agoc++: Fix up detach clause vs. data-sharing clause checking [PR100319]
Jakub Jelinek [Thu, 29 Apr 2021 09:11:37 +0000 (11:11 +0200)]
c++: Fix up detach clause vs. data-sharing clause checking [PR100319]

The standard says that "The event-handle will be considered as if it
was specified on a firstprivate clause." which means that it can't
be explicitly specified in some other data-sharing clause.
The checking is implemented correctly for C, but for C++ when detach_seen
is true (i.e. the construct had detach clause) we were comparing
OMP_CLAUSE_DECL (c) with t, which was previously initialized to
OMP_CLAUSE_DECL (c), which means it complained about any explicit
data-sharing clause on the same construct with a detach clause.

Fixed by remembering the detach clause in detach_seen (instead of a boolean
flag) and comparing against its OMP_CLAUSE_DECL.

2021-04-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/100319
* semantics.c (finish_omp_clauses): Fix up check that variable
mentioned in detach clause doesn't appear in data-sharing clauses.

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

3 years agomiddle-end/38474 - speedup PTA constraint solving
Richard Biener [Thu, 29 Apr 2021 06:32:00 +0000 (08:32 +0200)]
middle-end/38474 - speedup PTA constraint solving

In testcases like PR38474 and PR99912 we're seeing very slow
PTA solving.  One can observe an excessive amount of forwarding,
mostly during sd constraint solving.  The way we solve the graph
does not avoid forwarding the same bits through multiple paths,
and especially when such alternate path involves ESCAPED as
intermediate this causes the ESCAPED solution to be expanded
in receivers.

The following adds heuristic to add_graph_edge which adds
forwarding edges but also guards the initial solution forwarding
(which is the expensive part) to detect the case of ESCAPED
receiving the same set and the destination already containing
ESCAPED.

This speeds up the PTA solving process by more than 50%.

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

PR middle-end/38474
* tree-ssa-structalias.c (add_graph_edge): Avoid direct
forwarding when indirect forwarding through ESCAPED
alread happens.

3 years ago[Ada] Eliminate useless 128-bit overflow check for conversion
Eric Botcazou [Mon, 21 Dec 2020 15:22:53 +0000 (16:22 +0100)]
[Ada] Eliminate useless 128-bit overflow check for conversion

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference)
<Attribute_Max_Size_In_Storage_Elements>: Apply the checks for
universal integer contexts only in the default case.
* exp_ch4.adb (Get_Size_For_Range): Move to library level.
(Expand_N_Type_Conversion): If the operand has Universal_Integer
type and the conversion requires an overflow check, try to do an
intermediate conversion to a narrower type.

3 years ago[Ada] Self reference access discriminant
Arnaud Charlet [Tue, 15 Dec 2020 20:36:54 +0000 (15:36 -0500)]
[Ada] Self reference access discriminant

gcc/ada/

* sem_ch3.adb (Check_Anonymous_Access_Component): Factor out
core processing of Check_Anonymous_Access_Components.
(Check_Anonymous_Access_Components): Call
Check_Anonymous_Access_Component.
(Process_Discriminants): Call Check_Anonymous_Access_Component.
* freeze.adb (Freeze_Record_Type): Code cleanups and add more tree
checking to handle changes in sem_ch3.adb.
* sem_ch8.adb (Find_Type): Remove special case for access
discriminant in task types, these are now supported.

3 years ago[Ada] Fix interaction of 128-bit integer types and -gnato2 mode
Eric Botcazou [Sat, 19 Dec 2020 10:55:29 +0000 (11:55 +0100)]
[Ada] Fix interaction of 128-bit integer types and -gnato2 mode

gcc/ada/

* exp_ch4.adb (Expand_Compare_Minimize_Eliminate_Overflow): Remove
entry condition.
(Expand_N_In): Call Minimized_Eliminated_Overflow_Check on the left
operand before doing the special overflow expansion.
(Expand_N_Op_Eq): Likewise.
(Expand_N_Op_Ge): Likewise.
(Expand_N_Op_Gt): Likewise.
(Expand_N_Op_Le): Likewise.
(Expand_N_Op_Lt): Likewise.
(Expand_N_Op_Ne): Likewise.
(Minimized_Eliminated_Overflow_Check): Return False for Minimized
if the size of the type is greater than that of Long_Long_Integer.

3 years ago[Ada] Tree inconsistency between -O0 and -O1
Arnaud Charlet [Thu, 17 Dec 2020 17:23:08 +0000 (18:23 +0100)]
[Ada] Tree inconsistency between -O0 and -O1

gcc/ada/

* exp_ch5.adb (Expand_N_If_Statement): Only perform the
simplification on return True/False for internal nodes when
-fpreserve-control-flow is not set.

3 years ago[Ada] Change rounding mode of 'Machine for static floating point
Eric Botcazou [Sat, 19 Dec 2020 10:46:06 +0000 (11:46 +0100)]
[Ada] Change rounding mode of 'Machine for static floating point

gcc/ada/

* sem_attr.adb (Eval_Attribute) <Attribute_Machine>: Use
Round_Even instead of Round in the call to the Machine routine.

3 years ago[Ada] Error on T'Reduce of when T is not a container
Bob Duff [Fri, 18 Dec 2020 19:59:45 +0000 (14:59 -0500)]
[Ada] Error on T'Reduce of when T is not a container

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Change "$" to "&".
Otherwise, Errout will trip over an uninitialized (invalid)
variable (Error_Msg_Unit_1).

3 years ago[Ada] Fix minor issue in Scan_Decimal_Digits
Eric Botcazou [Fri, 18 Dec 2020 17:49:31 +0000 (18:49 +0100)]
[Ada] Fix minor issue in Scan_Decimal_Digits

gcc/ada/

* libgnat/s-valuer.adb (Scan_Decimal_Digits): Set Extra to zero
when the precision limit is reached by means of trailing zeros
and prevent it from being overwritten later.

3 years ago[Ada] Add colors to GNATprove messages output to a terminal
Yannick Moy [Thu, 17 Dec 2020 08:56:16 +0000 (09:56 +0100)]
[Ada] Add colors to GNATprove messages output to a terminal

gcc/ada/

* errout.adb (Output_Messages): Insert SGR strings where needed.
* erroutc.adb (Output_Message_Txt): Insert SGR strings where
needed in the text of the message itself.
(Output_Msg_Text): Allow for style message not to start
with (style).
* erroutc.ads: Add new constants and functions to control colors
in messages output to the terminal. Add variable Use_SGR_Control
that should be set to True for using SGR color control strings.

3 years ago[Ada] Fix evaluation of expressions in inlined code
Yannick Moy [Wed, 16 Dec 2020 13:37:22 +0000 (14:37 +0100)]
[Ada] Fix evaluation of expressions in inlined code

gcc/ada/

* sem_eval.adb (Check_Non_Static_Context_For_Overflow): Apply
compile-time checking for overflows in non-static contexts
including inlined code.
(Eval_Arithmetic_Op): Use the new procedure.
(Eval_Unary_Op, Eval_Op_Expon): Add call to the new procedure.

3 years ago[Ada] Missing access-to-discriminated conversion check
Justin Squirek [Wed, 16 Dec 2020 07:00:56 +0000 (02:00 -0500)]
[Ada] Missing access-to-discriminated conversion check

gcc/ada/

* checks.adb (Apply_Type_Conversion_Checks): Move out constraint
check generation, and add case for general access types with
constraints.
(Make_Discriminant_Constraint_Check): Created to centralize
generation of constraint checks for stored discriminants.

3 years ago[Ada] Fix internal consistency error with Duration and 32-bit target file
Eric Botcazou [Wed, 16 Dec 2020 14:18:13 +0000 (15:18 +0100)]
[Ada] Fix internal consistency error with Duration and 32-bit target file

gcc/ada/

* gnat1drv.adb (Adjust_Global_Switches): Force a 32-bit Duration
type if the maximum integer size is lower than 64 bits.

3 years ago[Ada] Clean up Makefile.rtl
Arnaud Charlet [Wed, 16 Dec 2020 08:19:40 +0000 (03:19 -0500)]
[Ada] Clean up Makefile.rtl

gcc/ada/

* Makefile.rtl (ADA_EXCLUDE_SRCS): Remove unused files.
(ADA_INCLUDE_SRCS): Remove libgnat/system.ads

3 years ago[Ada] Bad handling of array sliding in aggregate
Arnaud Charlet [Thu, 10 Dec 2020 13:19:55 +0000 (08:19 -0500)]
[Ada] Bad handling of array sliding in aggregate

gcc/ada/

* exp_aggr.adb (Collect_Initialization_Statements): Removed.
(Convert_Aggr_In_Object_Decl, Expand_Array_Aggregate): Fix
creation and insertion of Initialization_Statements.  Do not set
Initialization_Statements when a transient scope is involved.
Move processing of Array_Slice here.  Ensure that an object with
an Array_Slice call gets its array component initialized.  Add
comments.
* exp_ch7.adb: Update comments.
(Store_Actions_In_Scope): Deal properly with an empty list which
might now be generated by Convert_Aggr_In_Object_Decl.
* exp_ch3.adb: Update comments.
(Expand_N_Object_Declaration): Remove processing of Array_Slice.

3 years ago[Ada] Ada 2020 AI12-0401: Renaming of qualified expression of variable
Arnaud Charlet [Mon, 14 Dec 2020 10:10:21 +0000 (05:10 -0500)]
[Ada] Ada 2020 AI12-0401: Renaming of qualified expression of variable

gcc/ada/

* sem_ch8.adb (Analyze_Object_Renaming): Update check for
AI12-0401.

3 years ago[Ada] System.Storage_Elements: cleanup comment
Patrick Bernardi [Wed, 16 Dec 2020 01:44:57 +0000 (20:44 -0500)]
[Ada] System.Storage_Elements: cleanup comment

gcc/ada/

* libgnat/s-stoele.ads (Storage_Offset): Cleanup comment.

3 years ago[Ada] SPARK needs DIC expressions within partial DIC procedures for abstract types
Gary Dismukes [Mon, 14 Dec 2020 20:31:52 +0000 (15:31 -0500)]
[Ada] SPARK needs DIC expressions within partial DIC procedures for abstract types

gcc/ada/

* exp_util.adb (Add_Own_DIC): Relax the suppression of adding a
DIC Check pragma that's done for abstract types by still doing
it in the case where GNATprove_Mode is set.

3 years ago[Ada] Makefile.rtl:ADA_EXCLUDE_SRCS update after some System.GCC unit renames
Joel Brobecker [Tue, 15 Dec 2020 13:58:10 +0000 (08:58 -0500)]
[Ada] Makefile.rtl:ADA_EXCLUDE_SRCS update after some System.GCC unit renames

gcc/ada/

* Makefile.rtl (ADA_EXCLUDE_SRCS): Remove s-gcc.adb, s-gcc.ads,
s-gccdiv.adb, s-gccdiv.ads, s-gccshi.adb and s-gccshi.ads.

3 years ago[Ada] Refine type of a local size variable
Piotr Trojanek [Mon, 14 Dec 2020 13:49:02 +0000 (14:49 +0100)]
[Ada] Refine type of a local size variable

gcc/ada/

* layout.adb (Layout_Type): Refine type of a local variable with
the required size of object from Int to Pos (it is initialized
with 8 and only multiplied by 2); fix unbalanced parens in
comment.

3 years ago[Ada] Couple of minor tweaks to Eval_Fat.Succ
Eric Botcazou [Mon, 14 Dec 2020 22:58:59 +0000 (23:58 +0100)]
[Ada] Couple of minor tweaks to Eval_Fat.Succ

gcc/ada/

* eval_fat.adb (Succ): Use Ureal_Half in a couple of places.

3 years ago[Ada] Crash on predicated constrained out_parameter
Ed Schonberg [Mon, 14 Dec 2020 18:54:28 +0000 (13:54 -0500)]
[Ada] Crash on predicated constrained out_parameter

gcc/ada/

* sem_util.adb (Build_Constrained_Itype): Inhibit the generation
of predicate functions for this Itype, which is created for an
aggregate of a discriminated type. The object to which the
aggregate is assigned, e.g a writable actual parameter, will
apply the predicates if any are inherited from the base type.

3 years ago[Ada] Fix handling of visibility when categorization from pragmas
Piotr Trojanek [Sat, 12 Dec 2020 23:01:24 +0000 (00:01 +0100)]
[Ada] Fix handling of visibility when categorization from pragmas

gcc/ada/

* sem_cat.adb (Set_Categorization_From_Pragmas): Remove special
case for generic child units; remove optimization for empty list
of pragmas; properly restore visibility.

3 years ago[Ada] Extend Find_Related_Context to deal with child instances
Piotr Trojanek [Sat, 12 Dec 2020 22:59:34 +0000 (23:59 +0100)]
[Ada] Extend Find_Related_Context to deal with child instances

gcc/ada/

* sem_elab.adb (Process_SPARK_Instantiation): Fix typo in
comment.
* sem_prag.adb (Find_Related_Context): Add missing reference to
No_Caching in the comment; handle pragmas on compilation units.

3 years ago[Ada] Consistent wording for permissible-vs-allowed prefix
Piotr Trojanek [Mon, 14 Dec 2020 14:25:18 +0000 (15:25 +0100)]
[Ada] Consistent wording for permissible-vs-allowed prefix

gcc/ada/

* doc/gnat_rm/implementation_defined_attributes.rst: Change all
occurrences of "permissible prefix" to "allowed prefix", for
consistency.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Fix static computation of 'Succ for floating point without denormals
Eric Botcazou [Mon, 14 Dec 2020 14:58:49 +0000 (15:58 +0100)]
[Ada] Fix static computation of 'Succ for floating point without denormals

gcc/ada/

* eval_fat.adb (Succ): Add a special case for zero if the type does
not support denormalized numbers.  Always use the canonical formula
in other cases and add commentary throughout the function.

3 years ago[Ada] Reimplement Pred and Succ atttributes for floating-point types
Eric Botcazou [Sun, 13 Dec 2020 22:32:29 +0000 (23:32 +0100)]
[Ada] Reimplement Pred and Succ atttributes for floating-point types

gcc/ada/

* libgnat/s-fatgen.adb: Remove with clause for Interfaces and
use type clauses for Interfaces.Unsigned_{16,32,64}.
(Small16): Remove.
(Small32): Likewise
(Small64): Likewise.
(Small80): Likewise.
(Tiny16): Likewise.
(Tiny32): Likewise.
(Tiny64): Likewise.
(Tiny80): Likewise.
(Siz): Always use 16.
(NR): New constant.
(Rep_Last): Use it in the computation.
(Exp_Factor): Remove special case for 80-bit.
(Sign_Mask): Likewise.
(Finite_Succ): New function implementing the Succ attribute for
finite numbers.
(Pred): Rewrite in terms of Finite_Succ.
(Succ): Likewise.

3 years ago[Ada] Remove obsolete comment
Arnaud Charlet [Mon, 14 Dec 2020 10:25:13 +0000 (05:25 -0500)]
[Ada] Remove obsolete comment

gcc/ada/

* debug_a.adb (Debug_Output_Astring): Remove obsolete comment.

3 years ago[Ada] Spurious error on 'Image
Arnaud Charlet [Sun, 13 Dec 2020 17:58:26 +0000 (12:58 -0500)]
[Ada] Spurious error on 'Image

gcc/ada/

* sem_attr.adb (Check_Image_Type): Protect against empty
Image_Type.

3 years ago[Ada] AI12-0407: Fixups on Big_Integers and Big_Reals
Arnaud Charlet [Fri, 11 Dec 2020 08:57:08 +0000 (03:57 -0500)]
[Ada] AI12-0407: Fixups on Big_Integers and Big_Reals

gcc/ada/

* libgnat/a-nbnbin.ads (From_Universal_Image): New.
(Big_Integer): Update definition.
* libgnat/a-nbnbre.ads, libgnat/a-nbnbre.adb
(From_Universal_Image): New.
(From_String): Remove alternate body, replaced by
From_Universal_Image.
(Big_Real): Update definition.

3 years ago[Ada] Warning for 'Class applied to untagged incomplete type
Gary Dismukes [Fri, 11 Dec 2020 06:01:11 +0000 (01:01 -0500)]
[Ada] Warning for 'Class applied to untagged incomplete type

gcc/ada/

* sem_ch8.adb (Find_Type): Check the No_Obsolescent_Features
restriction for 'Class applied to an untagged incomplete
type (when Ada_Version >= Ada_2005).  Remove disabling of the
warning message for such usage, along with the ??? comment,
which no longer applies (because the -gnatg switch no longer
sets Warn_On_Obsolescent_Feature).

3 years ago[Ada] Fixes in the use of spans for error locations
Yannick Moy [Fri, 11 Dec 2020 10:32:07 +0000 (11:32 +0100)]
[Ada] Fixes in the use of spans for error locations

gcc/ada/

* errout.adb (Error_Msg_NEL): Extract span from node.
(First_And_Last_Nodes): Use spans for subtype indications and
attribute definition clauses.
(Write_Source_Code_Lines): Fix for tabulation characters. Change
output for large spans to skip intermediate lines.
* sem_case.adb (Check_Choice_Set): Report duplicate choice on
the Original_Node for the case.
(Generic_Check_Choices): Set the Original_Node for the rewritten
case, so that the subtree used in spans has the correct
locations.

3 years ago[omp, simt] Fix expand_GOMP_SIMT_*
Tom de Vries [Wed, 28 Apr 2021 14:00:01 +0000 (16:00 +0200)]
[omp, simt] Fix expand_GOMP_SIMT_*

When running the test-case included in this patch using an
nvptx accelerator, it fails in execution.

The problem is that the expansion of GOMP_SIMT_XCHG_BFLY is optimized away
during pass_jump as "trivially dead insns".

This is caused by this code in expand_GOMP_SIMT_XCHG_BFLY:
...
  class expand_operand ops[3];
  create_output_operand (&ops[0], target, mode);
  ...
  expand_insn (targetm.code_for_omp_simt_xchg_bfly, 3, ops);
...
which doesn't guarantee that target is assigned to by the expanded insn.

F.i., if target is:
...
(gdb) call debug_rtx ( target )
(subreg/s/u:QI (reg:SI 40 [ _61 ]) 0)
...
then after expand_insn, we have:
...
(gdb) call debug_rtx ( ops[0].value )
(reg:QI 57)
...

See commit 3af3bec2e4d "internal-fn: Avoid dropping the lhs of some
calls [PR94941]" for a similar problem.

Fix this in the same way, by adding:
...
  if (!rtx_equal_p (target, ops[0].value))
    emit_move_insn (target, ops[0].value);
...
where applicable in the expand_GOMP_SIMT_* functions.

Tested libgomp on x86_64 with nvptx accelerator.

gcc/ChangeLog:

2021-04-28  Tom de Vries  <tdevries@suse.de>

PR target/100232
* internal-fn.c (expand_GOMP_SIMT_ENTER_ALLOC)
(expand_GOMP_SIMT_LAST_LANE, expand_GOMP_SIMT_ORDERED_PRED)
(expand_GOMP_SIMT_VOTE_ANY, expand_GOMP_SIMT_XCHG_BFLY)
(expand_GOMP_SIMT_XCHG_IDX): Ensure target is assigned to.

3 years agotree-optimization/99912 - delete trivially dead stmts during DSE
Richard Biener [Tue, 27 Apr 2021 12:32:27 +0000 (14:32 +0200)]
tree-optimization/99912 - delete trivially dead stmts during DSE

DSE performs a backwards walk over stmts removing stores but it
leaves removing resulting dead SSA defs to later passes.  This
eats into its own alias walking budget if the removed stores kept
loads live.  The following patch adds removal of trivially dead
SSA defs which helps in this situation and reduces the amount of
garbage followup passes need to deal with.

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

PR tree-optimization/99912
* tree-ssa-dse.c (dse_dom_walker::m_need_cfg_cleanup): New.
(dse_dom_walker::todo): Likewise.
(dse_dom_walker::dse_optimize_stmt): Move VDEF check to the
caller.
(dse_dom_walker::before_dom_children): Remove trivially
dead SSA defs and schedule CFG cleanup if we removed all
PHIs in a block.
(pass_dse::execute): Get TODO as computed by the DOM walker
and return it.  Wipe dominator info earlier.

* gcc.dg/pr95580.c: Disable DSE.
* gcc.dg/Wrestrict-8.c: Place a use after each memcpy.
* c-c++-common/ubsan/overflow-negate-3.c: Make asms volatile
to prevent them from being removed.
* c-c++-common/ubsan/overflow-sub-4.c: Likewise.

3 years agoipa/100308 - properly update the callgraph when pruning EH in IPA CP
Richard Biener [Wed, 28 Apr 2021 07:34:03 +0000 (09:34 +0200)]
ipa/100308 - properly update the callgraph when pruning EH in IPA CP

This makes sure to fall into the delete_unreachable_blocks_update_callgraph
handling to remove blocks becoming unreachable when removing EH edges
by tracking blocks to need EH cleanup and doing that after releasing
dominance info.

This fixes an ICE seen with gfortran.dg/gomp/pr88933.f90 when enhancing
DSE.

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

PR ipa/100308
* ipa-prop.c (ipcp_modif_dom_walker::before_dom_children):
Track blocks to cleanup EH in new m_need_eh_cleanup.
(ipcp_modif_dom_walker::cleanup_eh): New.
(ipcp_transform_function): Release dominator info before
doing EH cleanup.

3 years agoPR middle-end/100250 - ICE related to -Wmaybe-uninitialized
Martin Sebor [Thu, 29 Apr 2021 01:11:34 +0000 (19:11 -0600)]
PR middle-end/100250 - ICE related to -Wmaybe-uninitialized

gcc/ChangeLog:

PR middle-end/100250
* attribs.c (attr_access::array_as_string): Avoid dereferencing
a pointer when it's null.

gcc/testsuite/ChangeLog:

PR middle-end/100250
* gcc.dg/uninit-pr100250.c: New test.

3 years agoMove pass free_lang_data to its own file.
Martin Sebor [Thu, 29 Apr 2021 01:01:40 +0000 (19:01 -0600)]
Move pass free_lang_data to its own file.

gcc/ChangeLog:
* Makefile.in (OBJS): Add ipa-free-lang-data.o.
* ipa-free-lang-data.cc: New file.
* tree.c: Move pass free_lang_data to file above.
 (build_array_type_1): Declare extern.
* tree.h (build_array_type_1): Declare.

3 years agoc: C2x changes to function type compatibility
Joseph Myers [Thu, 29 Apr 2021 00:50:35 +0000 (00:50 +0000)]
c: C2x changes to function type compatibility

WG14 N2432, the C2x removal of old-style function definitions, also
changed the function type compatibility rules so that an unprototyped
declaration can be compatible with a non-variadic prototyped
declaration even if some function arguments are changed by the default
argument promotions.  I missed that change in the initial
implementation for GCC of the rest of the N2432 changes, but
discussion on the WG14 reflector in February suggests that this is
indeed an intended change.  Implement this in the C front end.

Note that while this may be of use in some cases for use of pointers
to unprototyped function types as a kind of generic function pointer,
it's *not* possible to call such a function without a prototype
visible, without getting runtime undefined behavior from the
(promoted) type used in the call being incompatible with the
(unpromoted) type in the prototype.

Note also that GCC has a longstanding extension to allow compatibility
of such a prototype with an old-style definition specifying the same
type as in the prototype (which is not valid in ISO C, before
old-style definitions were removed in C2x).

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

gcc/c/
* c-typeck.c (function_types_compatible_p): For C2X, treat
unprototyped function as compatible with non-variadic prototyped
function even if some argument types are changed by the default
argument promotions.

gcc/testsuite/
* gcc.dg/c11-unproto-1.c, gcc.dg/c11-unproto-2.c,
gcc.dg/c2x-unproto-1.c, gcc.dg/c2x-unproto-2.c: New tests.

3 years agoDaily bump.
GCC Administrator [Thu, 29 Apr 2021 00:17:01 +0000 (00:17 +0000)]
Daily bump.

3 years agoFortran/OpenMP: Fix var-list expr parsing with array/dt
Tobias Burnus [Wed, 28 Apr 2021 20:35:06 +0000 (22:35 +0200)]
Fortran/OpenMP: Fix var-list expr parsing with array/dt

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_variable_list): Gobble whitespace before
checking whether a '%' or parenthesis-open follows as next character.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/map-5.f90: New test.