platform/upstream/gcc.git
2 years agoImprove backward threading with switches.
Aldy Hernandez [Thu, 28 Oct 2021 09:44:13 +0000 (11:44 +0200)]
Improve backward threading with switches.

We've been essentially using find_taken_edge_switch_expr() in the
backward threader, but this is suboptimal because said function only
works with singletons.  VRP has a much smarter find_case_label_range
that works with ranges.

Tested on x86-64 Linux with:

a) Bootstrap & regtests.

b) Verifying we get more threads than before.

c) Asserting that the new code catches everything the old one
code caught (over a set of bootstrap .ii files).

gcc/ChangeLog:

* tree-ssa-threadbackward.c
(back_threader::find_taken_edge_switch): Use find_case_label_range
instead of find_taken_edge.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp106.c: Adjust for threading.
* gcc.dg/tree-ssa/vrp113.c: Same.

2 years agoMake back_threader_registry inherit from back_jt_path_registry.
Aldy Hernandez [Wed, 27 Oct 2021 19:31:35 +0000 (21:31 +0200)]
Make back_threader_registry inherit from back_jt_path_registry.

When a class's only purpose is to expose the methods of its only
member, it's really a derived class ;-).

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (class back_threader_registry):
Inherit from back_jt_path_registry.
(back_threader_registry::thread_through_all_blocks): Remove.
(back_threader_registry::register_path): Remove
m_lowlevel_registry prefix.

2 years agomiddle-end/57245 - honor -frounding-math in real truncation
Richard Biener [Wed, 27 Oct 2021 12:27:40 +0000 (14:27 +0200)]
middle-end/57245 - honor -frounding-math in real truncation

The following honors -frounding-math when converting a FP constant
to another FP type.

2021-10-27  Richard Biener  <rguenther@suse.de>

PR middle-end/57245
* fold-const.c (fold_convert_const_real_from_real): Honor
-frounding-math if the conversion is not exact.
* simplify-rtx.c (simplify_const_unary_operation): Do not
simplify FLOAT_TRUNCATE with sign dependent rounding.

* gcc.dg/torture/fp-double-convert-float-1.c: New testcase.

2 years agotree-optimization/102949 - fix base object alignment
Richard Biener [Thu, 28 Oct 2021 08:07:40 +0000 (10:07 +0200)]
tree-optimization/102949 - fix base object alignment

This fixes fallout of g:4703182a06b831a9 where we now silently fail
to force alignment of a base object.  The fix is to look at the
dr_info of the group leader to be consistent with alignment analysis.

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

PR tree-optimization/102949
* tree-vect-stmts.c (ensure_base_align): Look at the
dr_info of a group leader and assert we are looking at
one with analyzed alignment.

2 years agors6000: Fix ICE of vect cost related to V1TI [PR102767]
Kewen Lin [Thu, 28 Oct 2021 06:11:56 +0000 (01:11 -0500)]
rs6000: Fix ICE of vect cost related to V1TI [PR102767]

As PR102767 shows, the commit r12-3482 exposed one ICE in function
rs6000_builtin_vectorization_cost.  We claims V1TI supports
movmisalign on rs6000 (See define_expand "movmisalign<mode>"), so
it return true in rs6000_builtin_support_vector_misalignment for
misalign 8.  Later in the cost querying function
rs6000_builtin_vectorization_cost, we don't have the arms to handle
the V1TI input under (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN).

The proposed fix is to add the consideration for V1TI, simply make
it as the cost for doubleword which is apparently bigger than the
cost of scalar, won't have the vectorization to happen, just to
keep consistency and avoid ICE.  Another thought is to not support
movmisalign for V1TI, but it sounds like a bad idea since it doesn't
match the reality.

Note that this patch also fixes up the wrong indentations around.

gcc/ChangeLog:

PR target/102767
* config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider
V1T1 mode for unaligned load and store.

gcc/testsuite/ChangeLog:

PR target/102767
* gcc.target/powerpc/ppc-fortran/pr102767.f90: New file.

2 years agoRISC-V: Fix wrong predicator for zero_extendsidi2_internal pattern
Kito Cheng [Wed, 27 Oct 2021 16:27:39 +0000 (00:27 +0800)]
RISC-V: Fix wrong predicator for zero_extendsidi2_internal pattern

We're wrongly guard zero_extendsidi2_internal pattern both ZBA and ZBB,
only ZBA provide zero_extendsidi2 instruction.

gcc/ChangeLog

* config/riscv/riscv.md (zero_extendsidi2_internal): Allow ZBB
use this pattern.

2 years agoRISC-V: Handle zi* extension correctly for arch-canonicalize script
Kito Cheng [Wed, 27 Oct 2021 15:41:17 +0000 (23:41 +0800)]
RISC-V: Handle zi* extension correctly for arch-canonicalize script

Canonical order for z-prefixed extension are rely on the canonical order of
single letter extension, however we didn't put i into the list before,
so when we put zicsr or zifencei it will got exception.

gcc/ChangeLog:

* config/riscv/arch-canonicalize (CANONICAL_ORDER): Add `i` to
CANONICAL_ORDER.

2 years agohardened conditionals
Alexandre Oliva [Thu, 28 Oct 2021 03:51:02 +0000 (00:51 -0300)]
hardened conditionals

This patch introduces optional passes to harden conditionals used in
branches, and in computing boolean expressions, by adding redundant
tests of the reversed conditions, and trapping in case of unexpected
results.  Though in abstract machines the redundant tests should never
fail, CPUs may be led to misbehave under certain kinds of attacks,
such as of power deprivation, and these tests reduce the likelihood of
going too far down an unexpected execution path.

for  gcc/ChangeLog

* common.opt (fharden-compares): New.
(fharden-conditional-branches): New.
* doc/invoke.texi: Document new options.
* gimple-harden-conditionals.cc: New.
* Makefile.in (OBJS): Build it.
* passes.def: Add new passes.
* tree-pass.h (make_pass_harden_compares): Declare.
(make_pass_harden_conditional_branches): Declare.

for  gcc/ada/ChangeLog

* doc/gnat_rm/security_hardening_features.rst
(Hardened Conditionals): New.

for  gcc/testsuite/ChangeLog

* c-c++-common/torture/harden-comp.c: New.
* c-c++-common/torture/harden-cond.c: New.

2 years agors6000: Fold xxsel to vsel since they have same semantics
Xionghu Luo [Thu, 28 Oct 2021 02:22:39 +0000 (21:22 -0500)]
rs6000: Fold xxsel to vsel since they have same semantics

Fold xxsel to vsel like xxperm/vperm to avoid duplicate code.

gcc/ChangeLog:

2021-10-28  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/94613
* config/rs6000/altivec.md: Add vsx register constraints.
* config/rs6000/vsx.md (vsx_xxsel<mode>): Delete.
(vsx_xxsel<mode>2): Likewise.
(vsx_xxsel<mode>3): Likewise.
(vsx_xxsel<mode>4): Likewise.

gcc/testsuite/ChangeLog:

2021-10-28  Xionghu Luo  <luoxhu@linux.ibm.com>

* gcc.target/powerpc/builtins-1.c: Adjust.

2 years agors6000: Fix wrong code generation for vec_sel [PR94613]
Xionghu Luo [Thu, 28 Oct 2021 02:21:20 +0000 (21:21 -0500)]
rs6000: Fix wrong code generation for vec_sel [PR94613]

The vsel instruction is a bit-wise select instruction.  Using an
IF_THEN_ELSE to express it in RTL is wrong and leads to wrong code
being generated in the combine pass.  Per element selection is a
subset of per bit-wise selection,with the patch the pattern is
written using bit operations.  But there are 8 different patterns
to define "op0 := (op1 & ~op3) | (op2 & op3)":

(~op3&op1) | (op3&op2),
(~op3&op1) | (op2&op3),
(op3&op2) | (~op3&op1),
(op2&op3) | (~op3&op1),
(op1&~op3) | (op3&op2),
(op1&~op3) | (op2&op3),
(op3&op2) | (op1&~op3),
(op2&op3) | (op1&~op3),

The latter 4 cases does not follow canonicalisation rules, non-canonical
RTL is invalid RTL in vregs pass.  Secondly, combine pass will swap
(op1&~op3) to (~op3&op1) by commutative canonical, which could reduce
it to the FIRST 4 patterns, but it won't swap (op2&op3) | (~op3&op1) to
(~op3&op1) | (op2&op3), so this patch handles it with 4 patterns with
different NOT op3 position and check equality inside it.

Tested pass on P7, P8 and P9.

gcc/ChangeLog:

2021-10-28  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/94613
* config/rs6000/altivec.md (*altivec_vsel<mode>): Change to ...
(altivec_vsel<mode>): ... this and update define.
(*altivec_vsel<mode>_uns): Delete.
(altivec_vsel<mode>2): New define_insn.
(altivec_vsel<mode>3): Likewise.
(altivec_vsel<mode>4): Likewise.
* config/rs6000/rs6000-call.c (altivec_expand_vec_sel_builtin): New.
(altivec_expand_builtin): Call altivec_expand_vec_sel_builtin to expand
vel_sel.
* config/rs6000/rs6000.c (rs6000_emit_vector_cond_expr): Use bit-wise
selection instead of per element.
* config/rs6000/vector.md:
* config/rs6000/vsx.md (*vsx_xxsel<mode>): Change to ...
(vsx_xxsel<mode>): ... this and update define.
(*vsx_xxsel<mode>_uns): Delete.
(vsx_xxsel<mode>2): New define_insn.
(vsx_xxsel<mode>3): Likewise.
(vsx_xxsel<mode>4): Likewise.

gcc/testsuite/ChangeLog:

2021-10-28  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/94613
* gcc.target/powerpc/pr94613.c: New test.

2 years agoAVX512FP16: Optimize _Float16 reciprocal for div and sqrt
Hongyu Wang [Mon, 25 Oct 2021 09:00:46 +0000 (17:00 +0800)]
AVX512FP16: Optimize _Float16 reciprocal for div and sqrt

For _Float16 type, add insn and expanders to optimize x / y to
x * rcp (y), and x / sqrt (y) to x * rsqrt (y).
As Half float only have minor precision difference between div and
mul * rcp, there is no need for Newton-Rhapson approximation.

gcc/ChangeLog:

* config/i386/i386.c (use_rsqrt_p): Add mode parameter, enable
  HFmode rsqrt without TARGET_SSE_MATH.
(ix86_optab_supported_p): Refactor rint, adjust floor, ceil,
btrunc condition to be restricted by -ftrapping-math, adjust
use_rsqrt_p function call.
* config/i386/i386.md (rcphf2): New define_insn.
(rsqrthf2): Likewise.
* config/i386/sse.md (div<mode>3): Change VF2H to VF2.
(div<mode>3): New expander for HF mode.
(rsqrt<mode>2): Likewise.
(*avx512fp16_vmrcpv8hf2): New define_insn for rpad pass.
(*avx512fp16_vmrsqrtv8hf2): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512fp16-recip-1.c: New test.
* gcc.target/i386/avx512fp16-recip-2.c: Ditto.
* gcc.target/i386/pr102464.c: Add -fno-trapping-math.

2 years agoDaily bump.
GCC Administrator [Thu, 28 Oct 2021 00:16:39 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: Delete unused decl in intrinsic.h
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 22:08:57 +0000 (00:08 +0200)]
Fortran: Delete unused decl in intrinsic.h

gcc/fortran/ChangeLog:

* intrinsic.h (gfc_check_sum, gfc_resolve_atan2d, gfc_resolve_kill,
gfc_resolve_kill_sub): Delete declaration.

2 years agoFortran: Delete unused decl in trans-types.h
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 20:52:00 +0000 (22:52 +0200)]
Fortran: Delete unused decl in trans-types.h

gcc/fortran/ChangeLog:

* trans-types.h (gfc_convert_function_code): Delete.

2 years agoFortran: Delete unused decl in trans-stmt.h
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 20:43:26 +0000 (22:43 +0200)]
Fortran: Delete unused decl in trans-stmt.h

gcc/fortran/ChangeLog:

* trans-stmt.h (gfc_trans_deallocate_array): Delete.

2 years agoFortran: make some trans-array functions static
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:57:43 +0000 (21:57 +0200)]
Fortran: make some trans-array functions static

gcc/fortran/ChangeLog:

* trans-array.c (gfc_trans_scalarized_loop_end): Make static.
* trans-array.h (gfc_trans_scalarized_loop_end,
gfc_conv_tmp_ref, gfc_conv_array_transpose): Delete declaration.

2 years agoFortran: make some constructor* functions static
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:22:11 +0000 (21:22 +0200)]
Fortran: make some constructor* functions static

gfc_constructor_expr_foreach and gfc_constructor_swap were just stubs.

gcc/fortran/ChangeLog:

* constructor.c (gfc_constructor_get_base): Make static.
(gfc_constructor_expr_foreach, gfc_constructor_swap): Delete.
* constructor.h (gfc_constructor_get_base): Remove declaration.
(gfc_constructor_expr_foreach, gfc_constructor_swap): Delete.

2 years agoFortran: make some match* functions static
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:05:35 +0000 (21:05 +0200)]
Fortran: make some match* functions static

gfc_match_small_int_expr was unused, delete it.
gfc_match_gcc_unroll should use gfc_match_small_literal_int and then
gfc_match_small_int can be deleted since it will be unused.

gcc/fortran/ChangeLog:

* decl.c (gfc_match_old_kind_spec, set_com_block_bind_c,
set_verify_bind_c_sym, set_verify_bind_c_com_block,
get_bind_c_idents, gfc_match_suffix, gfc_get_type_attr_spec,
check_extended_derived_type): Make static.
(gfc_match_gcc_unroll): Add comment.
* match.c (gfc_match_small_int_expr): Delete definition.
* match.h (gfc_match_small_int_expr): Delete declaration.
(gfc_match_name_C, gfc_match_old_kind_spec, set_com_block_bind_c,
set_verify_bind_c_sym, set_verify_bind_c_com_block,
get_bind_c_idents, gfc_match_suffix,
gfc_get_type_attr_spec): Delete declaration.

2 years agoFortran: make some trans* functions static
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:04:44 +0000 (21:04 +0200)]
Fortran: make some trans* functions static

This makes some trans* functions static and deletes declarations of
functions that either do not exist anymore like gfc_get_function_decl
or that are unused like gfc_check_any_c_kind.

gcc/fortran/ChangeLog:

* expr.c (is_non_empty_structure_constructor): Make static.
* gfortran.h (gfc_check_any_c_kind): Delete.
* match.c (gfc_match_label): Make static.
* match.h (gfc_match_label): Delete declaration.
* scanner.c (file_changes_cur, file_changes_count,
file_changes_allocated): Make static.
* trans-expr.c (gfc_get_character_len): Make static.
(gfc_class_len_or_zero_get): Make static.
(VTAB_GET_FIELD_GEN): Undefine.
(gfc_get_class_array_ref): Make static.
(gfc_finish_interface_mapping): Make static.
* trans-types.c (gfc_check_any_c_kind): Delete.
(pfunc_type_node, dtype_type_node, gfc_get_ppc_type): Make static.
* trans-types.h (gfc_get_ppc_type): Delete declaration.
* trans.c (gfc_msg_wrong_return): Delete.
* trans.h (gfc_class_len_or_zero_get, gfc_class_vtab_extends_get,
gfc_vptr_extends_get, gfc_get_class_array_ref, gfc_get_character_len,
gfc_finish_interface_mapping, gfc_msg_wrong_return,
gfc_get_function_decl): Delete declaration.

2 years agolibffi: Update LOCAL_PATCHES
H.J. Lu [Wed, 27 Oct 2021 18:40:50 +0000 (11:40 -0700)]
libffi: Update LOCAL_PATCHES

Add

commit 90205f67e465ae7dfcf733c2b2b177ca7ff68da0
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Mon Oct 25 23:29:26 2021 +0000

    rs6000: Fix bootstrap (libffi)

    This fixes bootstrap for the current problems building libffi.

to LOCAL_PATCHES.

* LOCAL_PATCHES: Add commit 90454a90082.

2 years agoDarwin, config: Amend for Darwin 21 / macOS 12.
Saagar Jha [Tue, 15 Jun 2021 11:08:23 +0000 (04:08 -0700)]
Darwin, config: Amend for Darwin 21 / macOS 12.

It seems that the OS major version is now tracking the kernel
major version - 9.  Minor version has been set to kerne
min - 1.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Saagar Jha <saagar@saagarjha.com>
gcc/ChangeLog:

* config.gcc: Adjust for Darwin21.
* config/darwin-c.c (macosx_version_as_macro): Likewise.
* config/darwin-driver.c (validate_macosx_version_min):
Likewise.
(darwin_find_version_from_kernel): Likewise.

2 years agoKill known equivalences before a new assignment in the path solver.
Aldy Hernandez [Wed, 27 Oct 2021 16:22:16 +0000 (18:22 +0200)]
Kill known equivalences before a new assignment in the path solver.

Every time we have a killing statement, we must also kill the relations
seen so far.  This is similar to what we did for the equivs inherent in
PHIs along a path.

Tested on x86-64 and ppc64le Linux.

gcc/ChangeLog:

* gimple-range-path.cc
(path_range_query::range_defined_in_block): Call killing_def.

2 years agoReorder relation calculating code in the path solver.
Aldy Hernandez [Wed, 27 Oct 2021 16:22:29 +0000 (18:22 +0200)]
Reorder relation calculating code in the path solver.

Enabling the fully resolving threader triggers various relation
ordering issues that have previously been dormant because the VRP
hybrid threader (forward threader based) never gives us long enough
paths for this to matter.  The new threader spares no punches in
finding non-obvious paths, so getting the relations right is
paramount.

This patch fixes a couple oversights that have gone undetected.

First, some background.  There are 3 types of relations along a path:

a) Relations inherent in a PHI.
b) Relations as a side-effect of evaluating a statement.
c) Outgoing relations between blocks in a path.

We must calculate these in their proper order, otherwise we can run
into ordering issues.  The current ordering is wrong, as we
precalculate PHIs for _all_ blocks before anything else, and then
proceed to register the relations throughout the path.  Also, we fail
to realize that a PHI whose argument is also defined in the PHIs block
cannot be registered as an equivalence without causing more ordering
issues.

This patch fixes all the problems described above.  With it we get a
handful more net threads, but most importantly, we disallow some
threads that were wrong.

Tested on x86-64 and ppc64le Linux on the usual regstrap, plus by
comparing the different thread counts before and after this patch.

gcc/ChangeLog:

* gimple-range-fold.cc (fold_using_range::range_of_range_op): Dump
operands as well as relation.
* gimple-range-path.cc
(path_range_query::compute_ranges_in_block): Compute PHI relations
first.  Compute outgoing relations at the end.
(path_range_query::compute_ranges): Remove call to compute_relations.
(path_range_query::compute_relations): Remove.
(path_range_query::maybe_register_phi_relation): New.
(path_range_query::compute_phi_relations): Abstract out
registering one PHI relation to...
(path_range_query::compute_outgoing_relations): ...here.
* gimple-range-path.h (class path_range_query): Remove
compute_relations.
Add maybe_register_phi_relation.

2 years agoKill second order relations in the path solver.
Aldy Hernandez [Wed, 27 Oct 2021 14:24:53 +0000 (16:24 +0200)]
Kill second order relations in the path solver.

My upcoming work replacing the VRP threaders with a fully resolving
backward threader has tripped over various corner cases in the path
sensitive relation oracle.  This patch kills second order relations when
we kill a relation.

Tested on x86-64 and ppc64le Linux.

Co-authored-by: Andrew MacLeod <amacleod@redhat.com>
gcc/ChangeLog:

* value-relation.cc (path_oracle::killing_def): Kill second
order relations.

2 years agoFix warnings building linux-atomic.c and fptr.c on hppa64-linux
John David Anglin [Wed, 27 Oct 2021 18:00:36 +0000 (18:00 +0000)]
Fix warnings building linux-atomic.c and fptr.c on hppa64-linux

The file fptr.c is specific to 32-bit hppa-linux and should not be
included in LIB2ADD on hppa64-linux.

There is a builtin type mismatch in linux-atomic.c using the type
long long unsigned int for 64-bit atomic operations on hppa64-linux.

2021-10-27  John David Anglin  <danglin@gcc.gnu.org>

libgcc/ChangeLog:

* config.host (hppa*64*-*-linux*): Don't add pa/t-linux to
tmake_file.
* config/pa/linux-atomic.c: Define u8, u16 and u64 types.
Use them in FETCH_AND_OP_2, OP_AND_FETCH_2, COMPARE_AND_SWAP_2,
SYNC_LOCK_TEST_AND_SET_2 and SYNC_LOCK_RELEASE_1 macros.
* config/pa/t-linux64 (LIB1ASMSRC): New define.
(LIB1ASMFUNCS): Revise.
(HOST_LIBGCC2_CFLAGS): Add "-DLINUX=1".

2 years agoFix a typo.
Martin Sebor [Wed, 27 Oct 2021 15:39:03 +0000 (09:39 -0600)]
Fix a typo.

gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-90.c: Fix a typo.

2 years agoipa-cp: Use profile counters (or not) based on local availability
Martin Jambor [Wed, 27 Oct 2021 12:49:02 +0000 (14:49 +0200)]
ipa-cp: Use profile counters (or not) based on local availability

This is a follow-up small patch to address Honza's review of my
previous patch to select saner profile count to base heuristics on.
Currently the IPA-CP heuristics switch to PGO-mode only if there are
PGO counters available for any part of the call graph.  This change
makes it to switch to the PGO mode only if any of the incoming edges
bringing in the constant in question had any ipa-quality counts on
them.  Consequently, if a part of the program is built with
-fprofile-use and another part without, IPA-CP will use
estimated-frequency-based heuristics for the latter.

I still wonder whether this should only happen with
flag_profile_partial_training on.  It seems like we're behaving as if
it was always on.

gcc/ChangeLog:

2021-10-18  Martin Jambor  <mjambor@suse.cz>

* ipa-cp.c (good_cloning_opportunity_p): Decide whether to use
profile feedback depending on their local availability.

2 years agoipa-cp: Select saner profile count to base heuristics on
Martin Jambor [Wed, 27 Oct 2021 12:49:01 +0000 (14:49 +0200)]
ipa-cp: Select saner profile count to base heuristics on

When profile feedback is available, IPA-CP takes the count of the
hottest node and then evaluates all call contexts relative to it.
This means that typically almost no clones for specialized contexts
are ever created because the maximum is some special function, called
from everywhere (that is likely to get inlined anyway) and all the
examined edges look cold compared to it.

This patch changes the selection.  It simply sorts counts of all edges
eligible for cloning in a vector and then picks the count in 90th
percentile (the actual number is configurable via a parameter).

I also tried more complex approaches which were summing the counts and
picking the edge which together with all hotter edges accounted for a
given portion of the total sum of all edge counts.  But first it was
not apparently clear to me that they make more logical sense that the
simple method and practically I always also had to ignore a few
percent of the hottest edges with really extreme counts (looking at
bash and python).  And when I had to do that anyway, it seemed simpler
to just "ignore" more and take the first non-ignored count as the
base.

Nevertheless, if people think some more sophisticated method should be
used anyway, I am willing to be persuaded.  But this patch is a clear
improvement over the current situation.

gcc/ChangeLog:

2021-10-26  Martin Jambor  <mjambor@suse.cz>

* params.opt (param_ipa_cp_profile_count_base): New parameter.
* doc/invoke.texi (Optimize Options): Add entry for
ipa-cp-profile-count-base.
* ipa-cp.c (max_count): Replace with base_count, replace all
occurrences too, unless otherwise stated.
(ipcp_cloning_candidate_p): identify mostly-directly called
functions based on their counts, not max_count.
(compare_edge_profile_counts): New function.
(ipcp_propagate_stage): Instead of setting max_count, find the
appropriate edge count in a sorted vector of counts of eligible
edges and make it the base_count.

2 years agoipa-cp: Fix updating of profile counts and self-gen value evaluation
Martin Jambor [Wed, 27 Oct 2021 12:49:01 +0000 (14:49 +0200)]
ipa-cp: Fix updating of profile counts and self-gen value evaluation

IPA-CP does not do a reasonable job when it is updating profile counts
after it has created clones of recursive functions.  This patch
addresses that by:

1. Only updating counts for special-context clones.  When a clone is
created for all contexts, the original is going to be dead and the
cgraph machinery has copied counts to the new node which is the right
thing to do.  Therefore updating counts has been moved from
create_specialized_node to decide_about_value and
decide_whether_version_node.

2. The current profile updating code artificially increased the assumed
old count when the sum of counts of incoming edges to both the
original and new node were bigger than the count of the original
node.  This always happened when self-recursive edge from the clone
was also redirected to the clone because both the original edge and
its clone had original high counts.  This clutch was removed and
replaced by the next point.

3. When cloning also redirects a self-recursive clone to the clone
itself, new logic has been added to divide the counts brought by such
recursive edges between the original node and the clone.  This is
impossible to do well without special knowledge about the function and
which non-recursive entry calls are responsible for what portion of
recursion depth, so the approach taken is rather crude.

For local nodes, we detect the case when the original node is never
called (in the training run at least) with another value and if so,
steal all its counts like if it was dead.  If that is not the case, we
try to divide the count brought by recursive edges (or rather not
brought by direct edges) proportionally to the counts brought by
non-recursive edges - but with artificial limits in place so that we
do not take too many or too few, because that was happening with
detrimental effect in mcf_r.

4. When cloning creates extra clones for values brought by a formerly
self-recursive edge with an arithmetic pass-through jump function on
it, such as it does in exchange2_r, all such clones are processed at
once rather than one after another.  The counts of all such nodes are
distributed evenly (modulo even-formerly-non-recursive-edges) and the
whole situation is then fixed up so that the edge counts fit.  This is
what new function update_counts_for_self_gen_clones does.

5. When values brought by a formerly self-recursive edge with an
arithmetic pass-through jump function on it are evaluated by
heuristics which assumes vast majority of node counts are result of
recursive calls and so we simply divide those with the number of
clones there would be if we created another one.

6. The mechanisms in init_caller_stats and gather_caller_stats and
get_info_about_necessary_edges was enhanced to gather data required
for the above and a missing check not to count dead incoming edges was
also added.

gcc/ChangeLog:

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

* ipa-cp.c (struct caller_statistics): New fields rec_count_sum,
n_nonrec_calls and itself, document all fields.
(init_caller_stats): Initialize the above new fields.
(gather_caller_stats): Gather self-recursive counts and calls number.
(get_info_about_necessary_edges): Gather counts of self-recursive and
other edges bringing in the requested value separately.
(dump_profile_updates): Rework to dump info about a single node only.
(lenient_count_portion_handling): New function.
(struct gather_other_count_struct): New type.
(gather_count_of_non_rec_edges): New function.
(struct desc_incoming_count_struct): New type.
(analyze_clone_icoming_counts): New function.
(adjust_clone_incoming_counts): Likewise.
(update_counts_for_self_gen_clones): Likewise.
(update_profiling_info): Rewritten.
(update_specialized_profile): Adjust call to dump_profile_updates.
(create_specialized_node): Do not update profiling info.
(decide_about_value): New parameter self_gen_clones, either push new
clones into it or updat their profile counts.  For self-recursively
generated values, use a portion of the node count instead of count
from self-recursive edges to estimate goodness.
(decide_whether_version_node): Gather clones for self-generated values
in a new vector, update their profiles at once at the end.

2 years agoRefactor try_vectorize_loop_1
Richard Biener [Wed, 27 Oct 2021 08:35:24 +0000 (10:35 +0200)]
Refactor try_vectorize_loop_1

This refactors epilogue loop handling in try_vectorize_loop_1 to not
suggest we're analyzing those there by splitting out the transform
phase which then can handle the epilogues.

2021-10-27  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.c (vect_transform_loops): New function,
split out from ...
(try_vectorize_loop_1): ... here.  Simplify as epilogues
are now fully handled in the split part.

2 years agoFortran: Fix 'select rank' for allocatables/pointers
Tobias Burnus [Wed, 27 Oct 2021 08:59:27 +0000 (10:59 +0200)]
Fortran: Fix 'select rank' for allocatables/pointers

gcc/fortran/ChangeLog:

* trans-stmt.c (gfc_trans_select_rank_cases): Fix condition
for allocatables/pointers.

gcc/testsuite/ChangeLog:

* gfortran.dg/PR93963.f90: Extend testcase by scan-tree-dump test.

2 years agotestsuite: Fix up gcc.dg/pr102897.c testcase [PR102897]
Jakub Jelinek [Wed, 27 Oct 2021 07:41:38 +0000 (09:41 +0200)]
testsuite: Fix up gcc.dg/pr102897.c testcase [PR102897]

The testcase FAILs on i686-linux due to:
FAIL: gcc.dg/pr102897.c (test for excess errors)
Excess errors:
.../gcc/gcc/testsuite/gcc.dg/pr102897.c:11:1: warning: MMX vector return without MMX enabled changes the ABI [-Wpsabi]
.../gcc/gcc/testsuite/gcc.dg/pr102897.c:10:10: warning: MMX vector argument without MMX enabled changes the ABI [-Wpsabi]
Fixed by adding -Wno-psabi.

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/102897
* gcc.dg/pr102897.c: Add -Wno-psabi to dg-options.

2 years agoopenmp: Document that non-rect loops are not supported in Fortran yet
Jakub Jelinek [Wed, 27 Oct 2021 07:24:46 +0000 (09:24 +0200)]
openmp: Document that non-rect loops are not supported in Fortran yet

I've found we claim to support non-rectangular loops, but don't actually
support those in Fortran, as can be seen on:
  integer i, j
  !$omp parallel do collapse(2)
  do i = 0, 10
    do j = 0, i
    end do
  end do
end
To support this, the Fortran FE needs to allow the valid forms of
non-rectangular loops and disallow others, so mainly it needs its
updated version of c-omp.c c_omp_check_loop_iv etc., plus for non-rectangular
lb or ub expressions emit a TREE_VEC instead of normal expression as the C/C++ FE
do, plus testsuite coverage.

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

* libgomp.texi (OpenMP 5.0): Mention that Non-rectangular loop nests
aren't implemented for Fortran yet.

2 years agoopenmp: Allow non-rectangular loops with pointer iterators
Jakub Jelinek [Wed, 27 Oct 2021 07:22:07 +0000 (09:22 +0200)]
openmp: Allow non-rectangular loops with pointer iterators

This patch handles pointer iterators for non-rectangular loops.  They are
more limited than integral iterators of non-rectangular loops, in particular
only var-outer, var-outer + a2, a2 + var-outer or var-outer - a2 can appear
in lb or ub where a2 is some integral loop invariant expression, so no e.g.
multiplication etc.

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

gcc/
* omp-expand.c (expand_omp_for_init_counts): Handle non-rectangular
iterators with pointer types.
(expand_omp_for_init_vars, extract_omp_for_update_vars): Likewise.
gcc/c-family/
* c-omp.c (c_omp_check_loop_iv_r): Don't clear 3rd bit for
POINTER_PLUS_EXPR.
(c_omp_check_nonrect_loop_iv): Handle POINTER_PLUS_EXPR.
(c_omp_check_loop_iv): Set kind even if the iterator is non-integral.
gcc/testsuite/
* c-c++-common/gomp/loop-8.c: New test.
* c-c++-common/gomp/loop-9.c: New test.
libgomp/
* testsuite/libgomp.c/loop-26.c: New test.
* testsuite/libgomp.c/loop-27.c: New test.

2 years agoopenmp: Don't reject some valid initializers or conditions of non-rectangular loops...
Jakub Jelinek [Wed, 27 Oct 2021 07:16:48 +0000 (09:16 +0200)]
openmp: Don't reject some valid initializers or conditions of non-rectangular loops [PR102854]

In C++, if an iterator has or might have (e.g. dependent type) class type we
remember the original init expressions and check those separately for presence
of iterators, because for class iterators we turn those into expressions that
always do contain reference to the current iterator.  But this resulted in
rejecting valid non-rectangular loop where the dependent type is later instantiated
to an integral type.

Non-rectangular loops with class random access iterators remain broken, that is something
to be fixed incrementally.

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/102854
gcc/c-family/
* c-common.h (c_omp_check_loop_iv_exprs): Add enum tree_code argument.
* c-omp.c (c_omp_check_loop_iv_r): For trees other than decls,
TREE_VEC, PLUS_EXPR, MINUS_EXPR, MULT_EXPR, POINTER_PLUS_EXPR or
conversions temporarily clear the 3rd bit from d->kind while walking
subtrees.
(c_omp_check_loop_iv_exprs): Add CODE argument.  Or in 4 into data.kind
if possibly non-rectangular.
gcc/cp/
* semantics.c (handle_omp_for_class_iterator,
finish_omp_for): Adjust c_omp_check_loop_iv_exprs caller.
gcc/testsuite/
* g++.dg/gomp/loop-3.C: Don't expect some errors.
* g++.dg/gomp/loop-7.C: New test.

2 years agoc++: Reject addresses of immediate functions in constexpr vars inside of immediate...
Jakub Jelinek [Wed, 27 Oct 2021 07:08:19 +0000 (09:08 +0200)]
c++: Reject addresses of immediate functions in constexpr vars inside of immediate functions or consteval if [PR102753]

Another thing that wasn't in the previous patch, but I'm wondering whether we don't
handle it incorrectly.  constexpr.c has:
  /* Check that immediate invocation does not return an expression referencing
     any immediate function decls.  They need to be allowed while parsing
     immediate functions, but can't leak outside of them.  */
  if (is_consteval
      && t != r
      && (current_function_decl == NULL_TREE
          || !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
as condition for the discovery of embedded immediate FUNCTION_DECLs
(or now PTRMEM_CSTs).  If I remove the && (current... ..._decl))
then g++.dg/cpp2a/consteval7.C's
struct S { int b; int (*c) (); };
consteval S baz () { return { 5, foo }; }
consteval int qux () { S s = baz (); return s.b + s.c (); }
consteval int quux () { constexpr S s = baz (); return s.b + s.c (); }
quux line fails, but based on
http://eel.is/c++draft/expr.const#11
I wonder if it shouldn't fail (clang++ -std=c++20 rejects it),
and be only accepted without the constexpr keyword before S s.
Also wonder about e.g.
consteval int foo () { return 42; }

consteval int
bar ()
{
  auto fn1 = foo;  // This must be ok
  constexpr auto fn2 = foo; // Isn't this an error?
  return fn1 () + fn2 ();
}

constexpr int
baz ()
{
  if consteval {
    auto fn1 = foo; // This must be ok
    constexpr auto fn2 = foo; // Isn't this an error?
    return fn1 () + fn2 ();
  }
  return 0;
}

auto a = bar ();

static_assert (bar () == 84);
static_assert (baz () == 84);
(again, clang++ -std=c++20 rejects the fn2 = foo; case,
but doesn't implement consteval if, so can't test the other one).
For taking address of an immediate function or method if it is taken
outside of immediate function context we already have diagnostics
about it, but shouldn't the immediate FUNCTION_DECL discovery in
cxx_eval_outermost_constant_expression be instead guarded with something
like
  if (is_consteval || in_immediate_context ())
and be done regardless of whether t != r?

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/102753
* constexpr.c (cxx_eval_outermost_constant_expr): Perform
find_immediate_fndecl discovery if is_consteval or
in_immediate_context () rather than if is_consteval, t != r
and not in immediate function's body.

* g++.dg/cpp2a/consteval7.C: Expect diagnostics on quux.
* g++.dg/cpp2a/consteval24.C: New test.
* g++.dg/cpp23/consteval-if12.C: New test.

2 years agoc++: Diagnose taking address of an immediate member function [PR102753]
Jakub Jelinek [Wed, 27 Oct 2021 07:03:28 +0000 (09:03 +0200)]
c++: Diagnose taking address of an immediate member function [PR102753]

The consteval20.C testcase ICEs, because while we have in cp_build_addr_expr_1
diagnostics for taking address of an immediate function (and as an exception
deal with build_address from immediate invocation), I forgot to diagnose
taking address of a member function which is done in a different place.
I hope (s.*&S::foo) () is not an immediate invocation like
(*&foo) () is not, so this patch just diagnoses taking address of a member
function when not in immediate context.

On Mon, Oct 18, 2021 at 12:42:00PM -0400, Jason Merrill wrote:
> > --- gcc/cp/typeck.c.jj      2021-10-05 09:53:55.382734051 +0200
> > +++ gcc/cp/typeck.c 2021-10-15 19:28:38.034213437 +0200
> > @@ -6773,9 +6773,21 @@ cp_build_addr_expr_1 (tree arg, bool str
> >         return error_mark_node;
> >       }
> > +   if (TREE_CODE (t) == FUNCTION_DECL
> > +       && DECL_IMMEDIATE_FUNCTION_P (t)
> > +       && cp_unevaluated_operand == 0
> > +       && (current_function_decl == NULL_TREE
> > +           || !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
>
> This doesn't cover some of the other cases of immediate context; we should
> probably factor most of immediate_invocation_p out into a function called
> something like in_immediate_context and use it here, and in several other
> places as well.

You're right, I've done that for the two spots in cp_build_addr_expr_1
and added testsuite coverage for where it changed behavior.
While doing that I've discovered further issues.

One is that we weren't diagnosing PMFs referring to immediate methods
returned from immediate functions (either directly or embedded in
aggregates).  I'm not sure if it can only appear as PTRMEM_CST which
I've handled (cp_walk_subtree only walks the type and not the
PTRMEM_CST_MEMBER) or something else.

Another issue is that while default arg in immediate function
containing &immediate_fn works properly, if it is immediate_fn
instead, we were incorrectly rejecting it.
I've handled this in build_over_call, though with this usage
in_consteval_if_p is slightly misnamed, it stands for in consteval
if or some other reason why we are currently in immediate function context.
Though, that flag alone can't be all the reasons for being in immediate
function contexts, as I've tried the other reasons can't be handled in such
a bool and need to be tested too.

2021-10-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/102753
* cp-tree.h (saved_scope): Document that consteval_if_p member
is also set while processing immediate invocation.
(in_immediate_context): Declare.
* call.c (in_immediate_context): New function.
(immediate_invocation_p): Use it.
(struct in_consteval_if_p_temp_override): New class.
(build_over_call): Temporarily set in_consteval_if_p for processing
immediate invocation arguments.
* typeck.c (cp_build_addr_expr_1): Diagnose taking address of
an immediate method.  Use t instead of TREE_OPERAND (arg, 1).
Use in_immediate_context function.
* constexpr.c (find_immediate_fndecl): Handle PTRMEM_CST
which refers to immediate function decl.

* g++.dg/cpp2a/consteval13.C: Don't expect errors.
* g++.dg/cpp2a/consteval20.C: New test.
* g++.dg/cpp2a/consteval21.C: New test.
* g++.dg/cpp2a/consteval22.C: New test.
* g++.dg/cpp2a/consteval23.C: New test.
* g++.dg/cpp23/consteval-if11.C: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 27 Oct 2021 00:16:33 +0000 (00:16 +0000)]
Daily bump.

2 years agocompiler: permit compiler directives in parenthesized groups
Ian Lance Taylor [Tue, 26 Oct 2021 17:50:40 +0000 (10:50 -0700)]
compiler: permit compiler directives in parenthesized groups

The original compiler directive support was only for //line at the
start of a line and for //go: comments before function declarations.
When support was added for //go:notinheap for types and //go:embed for
variables the code did not adapt to permit spaces before the comment
or to permit the comments in var() or type() groups.  This change
corrects those omissions.

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

2 years agoImprove/correct detection of overlapping aggregates [PR102238, PR102919].
Martin Sebor [Tue, 26 Oct 2021 20:40:33 +0000 (14:40 -0600)]
Improve/correct detection of overlapping aggregates [PR102238, PR102919].

Resolves:
PR tree-optimization/102238 - alias_offset in gimple-ssa-sprintf.c is broken
PR tree-optimization/102919 - spurious -Wrestrict warning for sprintf into the same member array as argument plus offset

gcc/ChangeLog:

PR tree-optimization/102238
PR tree-optimization/102919
* gimple-ssa-sprintf.c (get_string_length): Add an argument.
(array_elt_at_offset): Move to pointer-query.
(set_aggregate_size_and_offset): New function.
(field_at_offset):  Move to pointer-query.
(get_origin_and_offset): Rename...
(get_origin_and_offset_r): this.  Add an argument.  Make aggregate
handling more robust.
(get_origin_and_offset): New.
(alias_offset): Add an argument.
(format_string): Use subobject size determined by get_origin_and_offset.
* pointer-query.cc (field_at_offset): Move from gimple-ssa-sprintf.c.
Improve/correct handling of aggregates.
(array_elt_at_offset): Same.
* pointer-query.h (field_at_offset): Declare.
(array_elt_at_offset): Declare.

gcc/testsuite/ChangeLog:

PR tree-optimization/102238
PR tree-optimization/102919
* gcc.dg/tree-ssa/builtin-sprintf-warn-23.c: Remove warnings.
* gcc.dg/Wrestrict-23.c: New test.

2 years agoMake full use of context-sensitive ranges in access warnings.
Martin Sebor [Tue, 26 Oct 2021 20:38:11 +0000 (14:38 -0600)]
Make full use of context-sensitive ranges in access warnings.

gcc/ChangeLog:

* builtins.c (check_strncat_sizes): Pass access_data ctor additional
arguments.
(expand_builtin_memcmp): Move code to gimple-ssa-warn-access.cc.
(expand_builtin_fork_or_exec): Same.
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Pass
compute_objsize additional arguments.
(inbounds_memaccess_p): Same.
(array_bounds_checker::check_array_bounds): Add an assert.  Stash
statement in a member.
(check_array_bounds_dom_walker::before_dom_children): Same.
* gimple-array-bounds.h (array_bounds_checker::m_stmt): New member.
* gimple-ssa-sprintf.c (get_destination_size): Add an argument.
(handle_printf_call): Pass a new argument.
* gimple-ssa-warn-access.cc (get_size_range): Add an argument.
(check_access): Add an argument and pass it along to callees.
(check_read_access): Make a member function.
(pass_waccess::check_strcat): Pass access_data ctor additional
arguments.
(pass_waccess::check_strncat): Same.
(pass_waccess::check_stxcpy): Same.
(pass_waccess::check_stxncpy): Same.
(pass_waccess::check_strncmp): Same.
(pass_waccess::check_read_access): Same.
(pass_waccess::check_builtin): Same.
(pass_waccess::maybe_check_access_sizes): Same.
(pass_waccess::maybe_check_dealloc_call): Same.
* gimple-ssa-warn-access.h (check_read_access): Declare a new
member function.
* pointer-query.cc (compute_objsize_r): Add an argument.
(gimple_call_return_array): Same.
(gimple_call_alloc_size): Same.
(access_ref::access_ref): Same.
(access_ref::get_ref): Same.
(pointer_query::get_ref): Same.
(handle_min_max_size): Pass an arguments to callees.
(handle_array_ref): Add an argument.
(handle_mem_ref): Same.
(compute_objsize): Same.
* pointer-query.h (struct access_ref): Adjust signatures.
(struct access_data): Same.
(gimple_call_alloc_size): Add an argument.
(gimple_parm_array_size): Same.
(compute_objsize): Same.
* tree-ssa-strlen.c (strlen_pass::adjust_last_stmt): Pass an additional
argument to compute_objsize.
(strlen_pass::maybe_warn_overflow): Same.
(maybe_diag_stxncpy_trunc): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overflow-22.c: Correct typos.
* gcc.dg/Wstringop-overflow-81.c: New test.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/capacity/1.cc: Also suppress
-Wstringop-overread.
* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: Same.

2 years agoDetect overflow by atomic functions [PR102453].
Martin Sebor [Tue, 26 Oct 2021 20:34:16 +0000 (14:34 -0600)]
Detect overflow by atomic functions [PR102453].

Resolves:
PR middle-end/102453 - buffer overflow by atomic built-ins not diagnosed

gcc/ChangeLog:

PR middle-end/102453
* gimple-ssa-warn-access.cc (pass_waccess::check_atomic_builtin): New.
(pass_waccess::check_atomic_builtin): Call it.

gcc/testsuite/ChangeLog:

PR middle-end/102453
* gcc.dg/Warray-bounds-90.c: New test.
* gcc.dg/Wstringop-overflow-77.c: New test.
* gcc.dg/Wstringop-overflow-78.c: New test.
* gcc.dg/Wstringop-overflow-79.c: New test.
* gcc.dg/Wstringop-overflow-80.c: New test.
* c-c++-common/gomp/atomic-4.c: Avoid an out-of-bounds access.

2 years agoFixup MAINTAINERS file
Jeff Law [Tue, 26 Oct 2021 20:27:02 +0000 (16:27 -0400)]
Fixup MAINTAINERS file

/
* MAINTAINERS: Fix up Maciej's entries.

2 years agoFortran: error recovery on invalid code with SELECT TYPE
Harald Anlauf [Tue, 26 Oct 2021 20:22:36 +0000 (22:22 +0200)]
Fortran: error recovery on invalid code with SELECT TYPE

gcc/testsuite/ChangeLog:

PR fortran/86551
* gfortran.dg/pr86551.f90: New test to verify that PR86551 remains
fixed.

2 years agoFortran: [PDT] KIND and LEN type parameters are mutually exclusive
Harald Anlauf [Tue, 26 Oct 2021 20:14:19 +0000 (22:14 +0200)]
Fortran: [PDT] KIND and LEN type parameters are mutually exclusive

gcc/fortran/ChangeLog:

PR fortran/102956
* symbol.c (gfc_check_conflict): Add conflict check for PDT KIND
and LEN type parameters.

gcc/testsuite/ChangeLog:

PR fortran/102956
* gfortran.dg/pdt_32.f03: New test.

2 years ago[PR102842] Consider all outputs in generation of matching reloads
Vladimir N. Makarov [Tue, 26 Oct 2021 18:03:42 +0000 (14:03 -0400)]
[PR102842] Consider all outputs in generation of matching reloads

Without considering all output insn operands (not only processed
before), in rare cases LRA can use the same hard register for
different outputs of the insn on different assignment subpasses.  The
patch fixes the problem.

gcc/ChangeLog:

PR rtl-optimization/102842
* lra-constraints.c (match_reload): Ignore out in checking values
of outs.
(curr_insn_transform): Collect outputs before doing reloads of operands.

gcc/testsuite/ChangeLog:

PR rtl-optimization/102842
* g++.target/arm/pr102842.C: New test.

2 years agoFortran: do not restrict PDT KIND and LEN type parameters to default integer
Harald Anlauf [Tue, 26 Oct 2021 18:54:41 +0000 (20:54 +0200)]
Fortran: do not restrict PDT KIND and LEN type parameters to default integer

gcc/fortran/ChangeLog:

PR fortran/102917
* decl.c (match_attr_spec): Remove invalid integer kind checks on
KIND and LEN attributes of PDTs.

gcc/testsuite/ChangeLog:

PR fortran/102917
* gfortran.dg/pdt_4.f03: Adjust testcase.

2 years agoFortran: error recovery on initializing invalid derived type array component
Harald Anlauf [Tue, 26 Oct 2021 18:51:46 +0000 (20:51 +0200)]
Fortran: error recovery on initializing invalid derived type array component

gcc/fortran/ChangeLog:

PR fortran/102816
* resolve.c (resolve_structure_cons): Reject invalid array spec of
a DT component referenced in a structure constructor.

gcc/testsuite/ChangeLog:

PR fortran/102816
* gfortran.dg/pr102816.f90: New test.

2 years agoc++tools: Fix memory leak
Jonathan Wakely [Thu, 21 Oct 2021 21:32:23 +0000 (22:32 +0100)]
c++tools: Fix memory leak

The allocated memory is not freed when returning early due to an error.

c++tools/ChangeLog:

* resolver.cc (module_resolver::read_tuple_file): Use unique_ptr
to ensure memory is freed before returning.

2 years agors6000: Fixes for tests including only <x86intrin.h>
Paul A. Clarke [Mon, 25 Oct 2021 20:18:33 +0000 (15:18 -0500)]
rs6000: Fixes for tests including only <x86intrin.h>

Tests which only include <x86intrin.h> expect many other include files
to be brought in, but not enough are.

Try to increase compatibility with x86 headers by:
- Create new immintrin.h, including the analogous subset of intrinsics
  headers available for powerpc.
- Create new x86gprintrin.h, serving exclusively as the umbrella for
  bmiintrin.h and bmi2intrin.h.
- Modify x86intrin.h:
  - Include new immintrin.h.
  - Remove mmintrin.h, xmmintrin.h, emmintrin.h, now included indirectly
    from immintrin.h.
  - Remove bmiintrin.h, bmi2intrin.h, now included indirectly from
    x86gprintrin.h (which is now included from immintrin.h).

Add the new files to gcc/config.gcc.

Also, fix up the testcase that provoked PR102719, which requires
Power8 vector support.

Fixes commit 29fb1e831bf1c25e4574bf2f98a9f534e5c67665.

2021-10-25  Paul A. Clarke  <pc@us.ibm.com>

gcc
PR target/102719
* config/rs6000/x86intrin.h: Move some included headers to new
headers.  Include new immintrin.h instead of those headers.
* config/rs6000/immintrin.h: New.
* config/rs6000/x86gprintrin.h: New.
* config.gcc (powerpc*-*-*): Add new headers to extra_headers.

gcc/testsuite
* gcc.target/powerpc/pr78102.c: Fix dg directives to require Power8
vector support.  Also, add -DNO_WARN_X86_INTRINSICS.

2 years agoc++: P2360R0: Extend init-stmt to allow alias-decl [PR102617]
Marek Polacek [Thu, 21 Oct 2021 15:10:02 +0000 (11:10 -0400)]
c++: P2360R0: Extend init-stmt to allow alias-decl [PR102617]

The following patch implements C++23 P2360R0.  This proposal merely
extends init-statement to contain alias-declaration.  init-statement
is used in if/for/switch.  It also removes the unsightly duplication
of code by calling cp_parser_init_statement twice.

PR c++/102617

gcc/cp/ChangeLog:

* parser.c (cp_parser_for): Maybe call cp_parser_init_statement
twice.  Warn about range-based for loops with initializer here.
(cp_parser_init_statement): Don't duplicate code.  Allow
alias-declaration in init-statement.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/init-stmt1.C: New test.
* g++.dg/cpp23/init-stmt2.C: New test.

2 years agoMAINTAINERS: Add myself as a VAX port maintainer
Maciej W. Rozycki [Tue, 26 Oct 2021 15:17:25 +0000 (16:17 +0100)]
MAINTAINERS: Add myself as a VAX port maintainer

* MAINTAINERS (CPU Port Maintainers): Add myself as a VAX port
maintainer.

2 years agoFix broken use of alloca in C interoperability testcase
Sandra Loosemore [Mon, 25 Oct 2021 18:08:28 +0000 (11:08 -0700)]
Fix broken use of alloca in C interoperability testcase

2021-10-25  Sandra Loosemore  <sandra@codesourcery.com>

gcc/testsuite/

PR testsuite/102910
* gfortran.dg/c-interop/cf-descriptor-5-c.c: Use a static buffer
instead of alloca.

2 years agotestsuite: i386: Fix gcc.target/i386/avx512f-pr96891-3.c on Solaris [PR102834]
Rainer Orth [Tue, 26 Oct 2021 12:30:07 +0000 (14:30 +0200)]
testsuite: i386: Fix gcc.target/i386/avx512f-pr96891-3.c on Solaris [PR102834]

gcc.target/i386/avx512f-pr96891-3.c currently FAILs on 32-bit Solaris/x86:

FAIL: gcc.target/i386/avx512f-pr96891-3.c scan-assembler-times
(?n)vpcmp[bwdq][ \\\\t]*\\\\\$7 4

There are only 3 instances of the expected pattern because Solaris/x86
defaults to -mno-stv.  Fixed by compiling with -mstv and
-mno-stackrealign.  Tested on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR testsuite/102834
* gcc.target/i386/avx512f-pr96891-3.c: Add -mstv -mno-stackrealign
to dg-options.

2 years agotestsuite: i386: Fix gcc.target/i386/avx512fp16-trunchf.c on Solaris [PR102835]
Rainer Orth [Tue, 26 Oct 2021 12:23:06 +0000 (14:23 +0200)]
testsuite: i386: Fix gcc.target/i386/avx512fp16-trunchf.c on Solaris [PR102835]

The gcc.target/i386/avx512fp16-trunchf.c test FAILs on 32-bit Solaris/x86:

FAIL: gcc.target/i386/avx512fp16-trunchf.c scan-assembler-times vcvttsh2si[
\\\\t]+[^{\\n]*(?:%xmm[0-9]|\\\\(%esp\\\\))+, %eax(?:\\n|[ \\\\t]+#) 3
FAIL: gcc.target/i386/avx512fp16-trunchf.c scan-assembler-times
vcvttsh2usi[ \\\\t]+[^{\\n]*(?:%xmm[0-9]|\\\\(%esp\\\\))+, %eax(?:\\n|[
\\\\t]+#) 2

This happens because Solaris defaults to -fno-omit-frame-pointer, so it
uses %ebp instead of the expected %esp.  As Hongyu Wang suggested in the
PR, this can be fixed by accepting both forms, which this patch does.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR testsuite/102835
* gcc.target/i386/avx512fp16-trunchf.c: Allow for %esp instead of
%ebp.

2 years agotestsuite: i386: Fix gcc.target/i386/pieces-memset-1.c etc. on Solaris [PR102836]
Rainer Orth [Tue, 26 Oct 2021 12:15:24 +0000 (14:15 +0200)]
testsuite: i386: Fix gcc.target/i386/pieces-memset-1.c etc. on Solaris [PR102836]

Several of the gcc.target/i386/pieces-memset-*.c tests FAIL on 32-bit
Solaris/x86:

FAIL: gcc.target/i386/pieces-memset-1.c scan-assembler-not %[re]bp
FAIL: gcc.target/i386/pieces-memset-4.c scan-assembler-not %[re]bp
FAIL: gcc.target/i386/pieces-memset-41.c scan-assembler-not %[re]bp
FAIL: gcc.target/i386/pieces-memset-7.c scan-assembler-not %[re]bp
FAIL: gcc.target/i386/pieces-memset-8.c scan-assembler-not %[re]bp
FAIL: gcc.target/i386/pr90773-1.c scan-assembler-times movq[\\\\t
]+7\\\\(%[^,]+\\\\), 1
FAIL: gcc.target/i386/pr90773-1.c scan-assembler-times movq[\\\\t
]+\\\\(%[^,]+\\\\), 1

Fixed by compiling with -mno-stackrealign.  Tested on
i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR testsuite/102836
* gcc.target/i386/pieces-memset-1.c: Add -mno-stackrealign to
dg-options.
* gcc.target/i386/pieces-memset-4.c: Likewise.
* gcc.target/i386/pieces-memset-7.c: Likewise.
* gcc.target/i386/pieces-memset-8.c: Likewise.
* gcc.target/i386/pieces-memset-41.c: Likewise.
* gcc.target/i386/pr90773-1.c: Likewise.

2 years agolibstdc++: Fix 28_regex/basic_regex/84110.cc on Solaris
Rainer Orth [Tue, 26 Oct 2021 12:07:57 +0000 (14:07 +0200)]
libstdc++: Fix 28_regex/basic_regex/84110.cc on Solaris

28_regex/basic_regex/84110.cc currently FAILs on Solaris:

FAIL: 28_regex/basic_regex/84110.cc (test for excess errors)
UNRESOLVED: 28_regex/basic_regex/84110.cc compilation failed to produce executable

Excess errors:
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc:14: error: reference to 'extended' is ambiguous

The issue is seen in the full output:

/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc: In function â€˜void test01()’:
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc:14: error: reference to â€˜extended’ is ambiguous
In file included from /var/gcc/regression/master/11.4-gcc-gas/build/gcc/include-fixed/math.h:391,
                 from /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/cmath:45,
                 from /vol/gcc/src/hg/master/local/libstdc++-v3/include/precompiled/stdc++.h:41:
/usr/include/floatingpoint.h:73: note: candidates are: â€˜typedef unsigned int extended [3]’

Fixed by disambiguating extended.  Tested on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* testsuite/28_regex/basic_regex/84110.cc (test01)
[__cpp_exceptions]: Disambiguate extended.

2 years agolibstdc++: Fix 17_intro/names.cc on Solaris
Rainer Orth [Tue, 26 Oct 2021 12:00:18 +0000 (14:00 +0200)]
libstdc++: Fix 17_intro/names.cc on Solaris

17_intro/names.cc and experimental/names.cc currently FAIL on Solaris

FAIL: 17_intro/names.cc (test for excess errors)
FAIL: experimental/names.cc (test for excess errors)

Excess errors:
/usr/include/sys/timespec_util.h:22: error: expected ')' before ';' token
/usr/include/stdlib.h:157: error: expected unqualified-id before '[' token
/usr/include/stdlib.h:157: error: expected ')' before '[' token

<sys/timespec_util.h> has

extern int timespeccompare(const struct timespec *l, const struct timespec *r);

while <stdlib.h> has

typedef struct drand48_data {
        unsigned int _initialised;
        unsigned short int x[3];
        unsigned short int a[3];
        unsigned int c;
        unsigned short lastx[3];
} drand48_data;

both of which are broken by defining r resp. x to ( in the testcase.

Fixed by undoing the defines.  Tested on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* testsuite/17_intro/names.cc [__sun__] (r, x): Undef.

2 years agotestsuite: i386: Use -fomit-frame-pointer for gcc.target/i386/pr100704-1.c etc.
Rainer Orth [Tue, 26 Oct 2021 11:51:36 +0000 (13:51 +0200)]
testsuite: i386: Use -fomit-frame-pointer for gcc.target/i386/pr100704-1.c etc.

gcc.target/i386/pr100704-[12].c currently FAIL on 64-bit Solaris/x86:

FAIL: gcc.target/i386/pr100704-1.c scan-assembler-not pushq
FAIL: gcc.target/i386/pr100704-2.c scan-assembler-not pushq

Fixed by compiling with -fomit-frame-pointer.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/pr100704-1.c: Add -fomit-frame-pointer to
dg-options.
* gcc.target/i386/pr100704-2.c: Likewise.

2 years agoUnify offset and byte_offset for vect_create_addr_base_for_vector_ref
Richard Biener [Tue, 26 Oct 2021 10:31:09 +0000 (12:31 +0200)]
Unify offset and byte_offset for vect_create_addr_base_for_vector_ref

Now that both are measured in bytes we can unify the two parameters.

2021-10-26  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_create_addr_base_for_vector_ref):
Remove byte_offset parameter.
(vect_create_data_ref_ptr): Likewise.
* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Likewise.
(vect_create_data_ref_ptr): Likewise.
* tree-vect-stmts.c (vectorizable_store): Adjust.
(vectorizable_load): Likewise.

2 years agoMove negative stride bias out of dr_misalignment
Richard Biener [Mon, 25 Oct 2021 11:39:07 +0000 (13:39 +0200)]
Move negative stride bias out of dr_misalignment

This moves applying of a bias for negative stride accesses out of
dr_misalignment in favor of a more general optional offset argument.
The negative bias is now computed by get_load_store_type and applied
accordingly to determine the alignment support scheme.  Likewise
the peeling/versioning code is adjusted albeit that still assumes
we'll end up with VMAT_CONTIGUOUS_DOWN or VMAT_CONTIGUOUS_REVERSE
but at least when not so (VMAT_STRIDED_SLP is one possibility) then
get_load_store_type will _not_ falsely report an aligned access but
instead an access with known misalignment.

This fixes PR96109.

2021-10-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96109
* tree-vectorizer.h (dr_misalignment): Add optional offset
parameter.
* tree-vect-data-refs.c (dr_misalignment): Likewise.  Remove
offset applied for negative stride accesses.
(vect_enhance_data_refs_alignment): Compute negative stride
access offset and pass it to dr_misalignment.
* tree-vect-stmts.c (get_negative_load_store_type): Pass
negative offset to dr_misalignment.
(get_group_load_store_type): Likewise.
(get_load_store_type): Likewise.
(vectorizable_store): Remove asserts about alignment.
(vectorizable_load): Likewise.

2 years agoforwprop: Remove incorrect assertion [PR102897]
Kewen Lin [Tue, 26 Oct 2021 09:09:38 +0000 (04:09 -0500)]
forwprop: Remove incorrect assertion [PR102897]

As PR102897 shows, there is one incorrect assertion in function
simplify_permutation, which is based on the wrong assumption that
all cases with op2_type == tgt_type are handled previously, the
proposed fix is to remove the assertion.

gcc/ChangeLog:

PR tree-optimization/102897
* tree-ssa-forwprop.c (simplify_permutation): Remove a wrong assertion.

gcc/testsuite/ChangeLog:

* gcc.dg/pr102897.c: New test.

2 years agoTurn vect_create_addr_base_for_vector_ref offset into a byte offset
Richard Biener [Tue, 26 Oct 2021 08:52:44 +0000 (10:52 +0200)]
Turn vect_create_addr_base_for_vector_ref offset into a byte offset

This changes the offset in elements for vect_create_addr_base_for_vector_ref
and vect_create_data_ref_ptr to an offset in bytes, easing a following
refactoring.

2021-10-26  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Take offset in bytes.
(vect_create_data_ref_ptr): Likewise.
* tree-vect-loop-manip.c (get_misalign_in_elems): Multiply
offset by element size.
(vect_create_cond_for_align_checks): Likewise.
* tree-vect-stmts.c (get_negative_load_store_type): Likewise.
(vectorizable_load): Remove duplicate leftover from merge
conflict.

2 years agoFortran: Fix character(len=cst) dummies with bind(C) [PR102885]
Tobias Burnus [Tue, 26 Oct 2021 08:53:53 +0000 (10:53 +0200)]
Fortran: Fix character(len=cst) dummies with bind(C) [PR102885]

PR fortran/102885

gcc/fortran/ChangeLog:

* trans-decl.c (gfc_conv_cfi_to_gfc): Properly handle nonconstant
character lenghts.

gcc/testsuite/ChangeLog:

* gfortran.dg/lto/bind-c-char_0.f90: New test.

2 years agox86_64: Implement V1TI mode shifts/rotates by a constant
Roger Sayle [Tue, 26 Oct 2021 07:33:41 +0000 (08:33 +0100)]
x86_64: Implement V1TI mode shifts/rotates by a constant

This patch provides RTL expanders to implement logical shifts and
rotates of 128-bit values (stored in vector integer registers) by
constant bit counts.  Previously, GCC would transfer these values
to a pair of integer registers (TImode) via memory to perform the
operation, then transfer the result back via memory.  Instead these
operations are now expanded using (between 1 and 5) SSE2 vector
instructions.

Logical shifts by multiples of 8 can be implemented using x86_64's
pslldq/psrldq instruction:
ashl_8: pslldq  $1, %xmm0
        ret
lshr_32:
psrldq  $4, %xmm0
        ret

Logical shifts by greater than 64 can use pslldq/psrldq $8, followed
by a psllq/psrlq for the remaining bits:
ashl_111:
        pslldq  $8, %xmm0
        psllq   $47, %xmm0
        ret
lshr_127:
        psrldq  $8, %xmm0
        psrlq   $63, %xmm0
        ret

The remaining logical shifts make use of the following idiom:
ashl_1:
        movdqa  %xmm0, %xmm1
        psllq   $1, %xmm0
        pslldq  $8, %xmm1
        psrlq   $63, %xmm1
        por     %xmm1, %xmm0
        ret
lshr_15:
        movdqa  %xmm0, %xmm1
        psrlq   $15, %xmm0
        psrldq  $8, %xmm1
        psllq   $49, %xmm1
        por     %xmm1, %xmm0
        ret

Rotates by multiples of 32 can use x86_64's pshufd:
rotr_32:
        pshufd  $57, %xmm0, %xmm0
        ret
rotr_64:
        pshufd  $78, %xmm0, %xmm0
        ret
rotr_96:
        pshufd  $147, %xmm0, %xmm0
        ret

Rotates by multiples of 8 (other than multiples of 32) can make
use of both pslldq and psrldq, followed by por:
rotr_8:
        movdqa  %xmm0, %xmm1
        psrldq  $1, %xmm0
        pslldq  $15, %xmm1
        por     %xmm1, %xmm0
        ret
rotr_112:
        movdqa  %xmm0, %xmm1
        psrldq  $14, %xmm0
        pslldq  $2, %xmm1
        por     %xmm1, %xmm0
        ret

And the remaining rotates use one or two pshufd, followed by a
psrld/pslld/por sequence:
rotr_1:
        movdqa  %xmm0, %xmm1
        pshufd  $57, %xmm0, %xmm0
        psrld   $1, %xmm1
        pslld   $31, %xmm0
        por     %xmm1, %xmm0
        ret
rotr_63:
        pshufd  $78, %xmm0, %xmm1
        pshufd  $57, %xmm0, %xmm0
        pslld   $1, %xmm1
        psrld   $31, %xmm0
        por     %xmm1, %xmm0
        ret
rotr_111:
        pshufd  $147, %xmm0, %xmm1
        pslld   $17, %xmm0
        psrld   $15, %xmm1
        por     %xmm1, %xmm0
        ret

The new test case, sse2-v1ti-shift.c, is a run-time check to confirm that
the results of V1TImode shifts/rotates by constants, exactly match the
expected results of TImode operations, for various input test vectors.

2021-10-26  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-expand.c (ix86_expand_v1ti_shift): New helper
function to expand V1TI mode logical shifts by integer constants.
(ix86_expand_v1ti_rotate): New helper function to expand V1TI
mode rotations by integer constants.
* config/i386/i386-protos.h (ix86_expand_v1ti_shift,
ix86_expand_v1ti_rotate): Prototype new functions here.
* config/i386/sse.md (ashlv1ti3, lshrv1ti3, rotlv1ti3, rotrv1ti3):
New TARGET_SSE2 expanders to implement V1TI shifts and rotations.

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-v1ti-shift.c: New test case.

2 years ago[PR testsuite/102857] Tweak ssa-dom-thread-7.c for aarch64.
Aldy Hernandez [Sat, 23 Oct 2021 06:59:24 +0000 (08:59 +0200)]
[PR testsuite/102857] Tweak ssa-dom-thread-7.c for aarch64.

First, ssa-dom-thread-7 was looking at a dump file that was not
being generated.  This probably happened in the detangling of the VRP
threader from VRP, and I didn't notice because the test came back as
with UNRESOLVED instead of FAIL.

Second, aarch64 gets far more threads than other architectures (20
versus 12).  The difference is sufficiently different to make the
regex awkward.

We already have special casing for aarch64 in other parts of this
test, so perhaps it's simplest to have an arch specific test
for the thread3 count.

I don't know perhaps there's a better way.  I wake up with chills in
the middle of the night thinking about this test ;-).

Tested on x86-64 Linux and aarch64 Linux.

gcc/testsuite/ChangeLog:

PR testsuite/102857
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Add -fdump-tree-vrp2-stats.
Tweak for aarch64.

2 years agoAvoid threading circular paths.
Aldy Hernandez [Wed, 20 Oct 2021 16:52:45 +0000 (18:52 +0200)]
Avoid threading circular paths.

The backward threader keeps a hash of visited blocks to avoid crossing
the same block twice.  Interestingly, we haven't been checking it for
the final block out of the path.  This may be inherited from the old
code, as it was simple enough that it didn't matter.  With the
upcoming changes enabling the fully resolving threader, it gets
tripped often enough to cause wrong code to be generated.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::maybe_register_path):
Avoid threading circular paths.

2 years agoAttempt to resolve all incoming paths to a PHI.
Aldy Hernandez [Wed, 20 Oct 2021 05:29:59 +0000 (07:29 +0200)]
Attempt to resolve all incoming paths to a PHI.

The code that threads incoming paths to a PHI is duplicating what we
do generically in find_paths_to_names.  This shortcoming is actually
one of the reasons we aren't threading all possible paths into a PHI.
For example, we give up after finding one threadable path, but some
PHIs have multiple threadable paths:

      // x_5 = PHI <10(4), 20(5), ...>
      // if (x_5 > 5)

Addressing this not only fixes the oversight, but simplifies the
PHI handling code, since we can consider the PHI fully resolved upon
return.

Interestingly, for ssa-thread-12.c the main thread everything was
hinging on was unreachable.  With this patch, we call
maybe_register_path() earlier.  In doing so, the solver realizes
that any path starting with 4->8 is unreachable and can be avoided.
This caused the cascade of threadable paths that depended on this
to no longer happen.  Since threadable paths in thread[34] was the only
thing this test was testing, there's no longer anything to test.  Neat!

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::resolve_phi):
Attempt to resolve all incoming paths to a PHI.
(back_threader::resolve_def): Always return true for PHIs.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr21090.c: Adjust for threading.
* gcc.dg/tree-ssa/ssa-thread-12.c: Removed.

2 years agoTry to resolve paths in threader without looking further back.
Aldy Hernandez [Wed, 20 Oct 2021 05:29:25 +0000 (07:29 +0200)]
Try to resolve paths in threader without looking further back.

Sometimes we can solve a candidate path without having to recurse
further back.  This can mostly happen in fully resolving mode, because
we can ask the ranger what the range on entry to the path is, but
there's no reason this can't always apply.  This one-liner removes
the fully-resolving restriction.

I'm tickled pink to see how many things we now get quite early
in the compilation.  I actually had to disable jump threading entirely
for a few tests because the early threader was catching things
disturbingly early.  Also, as Richi predicted, I saw a lot of pre-VRP
cleanups happening.

I was going to commit this as obvious, but I think the test changes
merit discussion.

We've been playing games with gcc.dg/tree-ssa/ssa-thread-11.c for quite
some time.  Every time a threading pass gets smarter, we push the
check further down the pipeline.  We've officially run out of dumb
threading passes to disable ;-).  In the last year we've gone up from a
handful of threads, to 34 threads with the current combination of
options.  I doubt this is testing anything useful anymore, so I've
removed it.

Similarly for gcc.dg/tree-ssa/ssa-dom-thread-4.c.  We used to thread 3
jump threads, but they were disallowed because of loop rotation.  Then
we started catching more jump threads in VRP2 threading so we tested
there.  With this patch though, we triple the number of threads found
from 11 to 31.  I believe this test has outlived its usefulness, and
I've removed it.  Note that even though we have these outrageous
possibilities for this test, the block copier ultimately chops them
down (23 survive though).

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::find_paths_to_names):
Always try to resolve path without looking back.
* tree-ssa-threadupdate.c (dump_jump_thread): Indidicate whether
edge is a back edge.

gcc/testsuite/ChangeLog:

* gcc.dg/graphite/scop-dsyr2k-2.c: Adjust for jump threading changes.
* gcc.dg/graphite/scop-dsyr2k.c: Same.
* gcc.dg/graphite/scop-dsyrk-2.c: Same.
* gcc.dg/graphite/scop-dsyrk.c: Same.
* gcc.dg/tree-ssa/pr20701.c: Same.
* gcc.dg/tree-ssa/pr20702.c: Same.
* gcc.dg/tree-ssa/pr21086.c: Same.
* gcc.dg/tree-ssa/pr25382.c: Same.
* gcc.dg/tree-ssa/pr58480.c: Same.
* gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Same.
* gcc.dg/tree-ssa/vrp08.c: Same.
* gcc.dg/tree-ssa/vrp55.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Removed.
* gcc.dg/tree-ssa/ssa-thread-11.c: Removed.
* gcc.dg/uninit-pr89230-1.c: xfail.

2 years agovect: Don't update inits for simd_lane_access DRs [PR102789]
Kewen Lin [Tue, 26 Oct 2021 02:05:02 +0000 (21:05 -0500)]
vect: Don't update inits for simd_lane_access DRs [PR102789]

As PR102789 shows, when vectorizer does some peelings for alignment
in prologues, function vect_update_inits_of_drs would update the
inits of some drs.  But as the failed case, we shouldn't update the
dr for simd_lane_access, it has the fixed-length storage mainly for
the main loop, the update can make the access out of bound and access
the unexpected element.

gcc/ChangeLog:

PR tree-optimization/102789
* tree-vect-loop-manip.c (vect_update_inits_of_drs): Do not
update inits of simd_lane_access.

2 years agoDaily bump.
GCC Administrator [Tue, 26 Oct 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agoMove vrp_simplify_cond_using_ranges into the simplifier.
Andrew MacLeod [Mon, 25 Oct 2021 22:04:06 +0000 (18:04 -0400)]
Move vrp_simplify_cond_using_ranges into the simplifier.

This static VRP routine does a simplification with casted conditions.  Add it
to the general simplfier, and continue to invoke if from the VRP folder.

* tree-vrp.c (vrp_simplify_cond_using_ranges): Add return type and
move to vr-values.c.
(simplify_casted_conds): Move to vrp_folder class.
(execute_vrp): Call via vrp_folder now.
* vr-values.c (simplify_cond_using_ranges_1): Call simplify_casted_cond.
(simplify_using_ranges::simplify_casted_cond): Relocate from tree-vrp.c.
* vr-values.h (simplify_casted_cond): Add prototype.

2 years agoFold all statements in Ranger VRP.
Andrew MacLeod [Wed, 20 Oct 2021 17:37:29 +0000 (13:37 -0400)]
Fold all statements in Ranger VRP.

Until now, ranger VRP has only simplified statements with ranges.  This patch
enables us to fold all statements.

gcc/
* tree-vrp.c (rvrp_folder::fold_stmt): If simplification fails, try
to fold anyway.

gcc/testsuite/
* gcc.dg/tree-ssa/vrp98.c: Disable evrp for vrp1 test.
* gcc.dg/tree-ssa/vrp98-1.c: New. Test for folding in evrp.

2 years agors6000: Fix bootstrap (libffi)
Segher Boessenkool [Mon, 25 Oct 2021 23:29:26 +0000 (23:29 +0000)]
rs6000: Fix bootstrap (libffi)

This fixes bootstrap for the current problems building libffi.

2021-10-25  Segher Boessenkool  <segher@kernel.crashing.org>

libffi/
* src/powerpc/linux64.S: Enable AltiVec insns.
* src/powerpc/linux64_closure.S: Ditto.

2 years agors6000: Fix missing "externs" in smmintrin.h
Paul A. Clarke [Mon, 25 Oct 2021 20:17:28 +0000 (15:17 -0500)]
rs6000: Fix missing "externs" in smmintrin.h

Inline functions defined in smmintrin.h need "extern" as part of their
declaration, otherwise instances of those functions are created in the
objects which include them.

Fixes commits:
acd4b9103c1a30c833de4eee31fb69c3ff13cd77
9d352c68e8c8b642a36a6bcfc7f6b5dba11ac748
bd9a8737d478f7f1d01a9d5f1cc4309ffbb53103
5f500715438761f59de5fb992267748c5d4dc4b6
eaa93a0f3d9f67c8cbc1dc849ea6feba432ff412
29fb1e831bf1c25e4574bf2f98a9f534e5c67665

2021-10-25  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_testz_si128): Add "extern" to
function signature.
(_mm_testc_si128): Likewise.
(_mm_testnzc_si128): Likewise.
(_mm_blend_ps): Likewise.
(_mm_blendv_ps): Likewise.
(_mm_blend_pd): Likewise.
(_mm_blendv_pd): Likewise.
(_mm_ceil_pd): Likewise.
(_mm_ceil_sd): Likewise.
(_mm_ceil_ps): Likewise.
(_mm_ceil_ss): Likewise.
(_mm_floor_pd): Likewise.
(_mm_floor_sd): Likewise.
(_mm_floor_ps): Likewise.
(_mm_floor_ss): Likewise.
(_mm_minpos_epu16): Likewise.
(_mm_mul_epi32): Likewise.
(_mm_cvtepi8_epi16): Likewise.
(_mm_packus_epi32): Likewise.
(_mm_cmpgt_epi64): Likewise.

2 years agolibgomp.oacc-c-c++-common/loop-gwv-2.c: Use __builtin_alloca
Tobias Burnus [Mon, 25 Oct 2021 18:40:13 +0000 (20:40 +0200)]
libgomp.oacc-c-c++-common/loop-gwv-2.c: Use __builtin_alloca

Some systems do not have <alloca.h> but provide alloca differently, e.g.
via stdlib.h. Do it like other testcases do and use __builtin_alloca.

libgomp/ChangeLog:

PR testsuite/102910
* testsuite/libgomp.oacc-c-c++-common/loop-gwv-2.c: Use __builtin_alloca
instead of #include <alloca.h> + alloca.

2 years agoConstant fold/simplify SS_ASHIFT and US_ASHIFT in simplify-rtx.c
Roger Sayle [Mon, 25 Oct 2021 15:16:11 +0000 (16:16 +0100)]
Constant fold/simplify SS_ASHIFT and US_ASHIFT in simplify-rtx.c

This patch adds compile-time evaluation of signed saturating left shift
(SS_ASHIFT) and unsigned saturating left shift (US_ASHIFT) to simplify-rtx's
simplify_const_binary_operation.  US_ASHIFT saturates to the maximum
unsigned value on overflow (which occurs when the shift is greater than
the leading zero count), while SS_ASHIFT saturates on overflow to the
maximum signed value for positive arguments, and the minimum signed value
for negative arguments (which occurs when the shift count is greater than
the number of leading redundant sign bits, clrsb).  This suggests
some additional simplifications that this patch implements in
simplify_binary_operation_1; us_ashift:HI of 0xffff remains 0xffff
(much like any ashift of 0x0000 remains 0x0000), and ss_ashift:HI of
0x7fff remains 0x7ffff, and of 0x8000 remains 0x8000.

Conveniently the bfin backend provides instructions/built-ins that allow
this functionality to be tested.  The two functions below

short stest_sat_max() { return __builtin_bfin_shl_fr1x16(10000,8); }
short stest_sat_min() { return __builtin_bfin_shl_fr1x16(-10000,8); }

previously on bfin-elf with -O2 generated:

_stest_sat_max:
        nop;
        nop;
        R0 = 10000 (X);
        R0 = R0 << 8 (V,S);
        rts;

_stest_sat_min:
        nop;
        nop;
        R0 = -10000 (X);
        R0 = R0 << 8 (V,S);
        rts;

With this patch, bfin-elf now generates:

_stest_sat_max:
        nop;
        nop;
        nop;
        R0 = 32767 (X);
        rts;

_stest_sat_min:
        nop;
        nop;
        nop;
        R0 = -32768 (X);
        rts;

2021-10-25  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* simplify-rtx.c (simplify_binary_operation_1) [SS_ASHIFT]: Simplify
shifts of the mode's smin_value and smax_value when the bit count
operand doesn't have side-effects.
[US_ASHIFT]: Likewise, simplify shifts of the mode's umax_value
when the bit count operand doesn't have side-effects.
(simplify_const_binary_operation) [SS_ASHIFT, US_ASHIFT]: Perform
compile-time evaluation of saturating left shifts with constant
arguments.

gcc/testsuite/ChangeLog
* gcc.target/bfin/ssashift-1.c: New test case.

2 years ago[Ada] Remove gnatfind and gnatxref
Arnaud Charlet [Sat, 16 Oct 2021 16:58:20 +0000 (12:58 -0400)]
[Ada] Remove gnatfind and gnatxref

gcc/ada/

* gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Remove
gnatfind and gnatxref.

2 years ago[Ada] Spurious error on user-defined literal and operator
Ed Schonberg [Tue, 14 Sep 2021 00:14:56 +0000 (20:14 -0400)]
[Ada] Spurious error on user-defined literal and operator

gcc/ada/

* sem_ch4.adb (Has_Possible_Literal_Aspects): If analysis of an
operator node fails to find  a possible interpretation, and one
of its operands is a literal or a named number, assign to the
node the corresponding class type (Any_Integer, Any_String,
etc).
(Operator_Check): Call it before emitting a type error.
* sem_res.adb (Has_Applicable_User_Defined_Literal): Given a
literal and a type, determine whether the type has a
user_defined aspect that can apply to the literal, and rewrite
the node as call to the corresponding function. Most of the code
was previously in procedure Resolve.
(Try_User_Defined_Literal): Check operands of a predefined
operator that fails to resolve, and apply
Has_Applicable_User_Defined_Literal to literal operands if any,
to find if a conversion will allow the operator to resolve
properly.
(Resolve): Call the above when a literal or an operator with a
literal operand fails to resolve.

2 years ago[Ada] Follow-on cleanups for Uint fields
Bob Duff [Fri, 22 Oct 2021 16:00:38 +0000 (12:00 -0400)]
[Ada] Follow-on cleanups for Uint fields

gcc/ada/

* freeze.adb (Freeze_Fixed_Point_Type): Remove
previously-inserted test for Uint_0; no longer needed.
* gen_il-gen.ads: Improve comments.
* repinfo.adb (Rep_Value): Use Ubool type for B.
* repinfo.ads (Node_Ref): Use Unegative type.
(Node_Ref_Or_Val): Document that values of this type can be
No_Uint.
* exp_disp.adb (Make_Disp_Requeue_Body): Minor comment fix.
* sem_ch3.adb: Likewise.
* sem_ch8.adb: Likewise.
* sinfo-utils.adb (End_Location): End_Span can never be No_Uint,
so remove the "if No (L)" test.
* uintp.adb (Image_String): Use "for ... of" loop.
* uintp.ads (Unegative): New type for negative integers.  We
give it a long name (unlike Unat and Upos) because it is rarely
used.

2 years ago[Ada] Change format of the ?? warning insertion sequence
Etienne Servais [Tue, 19 Oct 2021 16:00:56 +0000 (18:00 +0200)]
[Ada] Change format of the ?? warning insertion sequence

gcc/ada/

* errout.adb (Skip_Msg_Insertion_Warning): Adapt and format as
Erroutc.Prescan_Message.Parse_Message_Class.
(Warn_Insertion): Adapt to new format.
* errout.ads: Update documentation.
* erroutc.adb (Get_Warning_Tag): Adapt to new format.
(Prescan_Message): Introduce Parse_Message_Class function.
(Validate_Specific_Warnings): Update ?W? to ?.w?.
* erroutc.ads: Update type and documentation.
* checks.adb (Validity_Check_Range): Update ?X? to ?.x?.
* exp_ch11.adb (Possible_Local_Raise): Update ?X? to ?.x?.
(Warn_If_No_Local_Raise): Likewise.
(Warn_If_No_Propagation): Likewise.
(Warn_No_Exception_Propagation_Active): Likewise.
* exp_ch4.adb (Expand_N_Allocator): Attach warning message to
-gnatw_a.
* exp_prag.adb (Expand_Pragma_Check): Update ?A? to ?.a?.
* exp_util.adb (Activate_Atomic_Synchronization): Update ?N? to
?.n?.
(Add_Invariant_Check): Update ?L? to ?.l?.
* freeze.adb (Check_Suspicious_Modulus): Update ?M? to ?.m?.
(Freeze_Entity): Update ?T? to ?.t?, ?Z? to ?.z?.
* par-util.adb (Warn_If_Standard_Redefinition): Update ?K? to
?.k?.
* sem_attr.adb (Min_Max): Update ?U? to ?.u?.
* sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Update ?V?
to ?.v?.
(Adjust_Record_For_Reverse_Bit_Order_Ada_95): Update ?V? to ?.v?.
(Component_Size_Case): Update ?S? to ?.s?.
(Analyze_Record_Representation_Clause): Update ?S? to ?.s? and
?C? to ?.c?.
(Add_Call): Update ?L? to ?.l?.
(Component_Order_Check): Attach warning message to -gnatw_r.
(Check_Component_List): Update ?H? to ?.h?.
(Set_Biased): Update ?B? to ?.b?.
* sem_ch3.adb (Modular_Type_Declaration): Update ?M? to ?.m?.
* sem_ch4.adb (Analyze_Mod): Update ?M? to ?.m?.
(Analyze_Quantified_Expression): Update ?T? to ?.t?.
* sem_ch6.adb (Check_Conformance): Attach warning message to
-gnatw_p.
(List_Inherited_Pre_Post_Aspects): Update ?L? to ?.l?.
* sem_ch7.adb (Unit_Requires_Body_Info): Update ?Y? to ?.y?.
* sem_ch8.adb (Analyze_Object_Renaming): Update ?R? to ?.r?.
* sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): Attach
warning message to -gnatw_c.
* sem_res.adb (Check_Argument_Order): Update ?P? to ?.p?.
(Resolve_Comparison_Op): Update ?U? to ?.u?.
(Resolve_Range): Update ?U? to ?.u?.
(Resolve_Short_Circuit): Update ?A? to ?.a?.
(Resolve_Unary_Op): Update ?M? to ?.m?.
* sem_util.adb (Check_Result_And_Post_State): Update ?T? to ?.t?.
* sem_warn.adb (Output_Unused_Warnings_Off_Warnings): Update ?W?
to ?.w?.
* warnsw.ads: Update documentation for -gnatw_c.

2 years ago[Ada] Fix a comment
Bob Duff [Thu, 21 Oct 2021 13:54:13 +0000 (09:54 -0400)]
[Ada] Fix a comment

gcc/ada/

* inline.adb (Establish_Actual_Mapping_For_Inlined_Call): Fix
comment.

2 years ago[Ada] Fix bugs in Base_Type_Only (etc.) fields
Bob Duff [Wed, 20 Oct 2021 20:55:38 +0000 (16:55 -0400)]
[Ada] Fix bugs in Base_Type_Only (etc.) fields

gcc/ada/

* gen_il-gen.adb (Put_Seinfo): Generate type
Seinfo.Type_Only_Enum based on type
Gen_IL.Internals.Type_Only_Enum. Automatically generating a copy
of the type will help keep them in sync.  (Note that there are
no Ada compiler packages imported into Gen_IL.)  Add a Type_Only
field to Field_Descriptor, so this information is available in
the Ada compiler (as opposed to just in the Gen_IL "compiler").
(One_Comp): Add initialization of the Type_Only field of
Field_Descriptor.
* gen_il-internals.ads (Image): Image function for
Type_Only_Enum.
* atree.ads (Node_To_Fetch_From): New function to compute which
node to fetch from, based on the Type_Only aspect.
* atree.adb (Get_Field_Value): Call Node_To_Fetch_From.
* treepr.adb (Print_Entity_Field): Call Node_To_Fetch_From.
(Print_Node_Field): Assert.
* sinfo-utils.adb (Walk_Sinfo_Fields,
Walk_Sinfo_Fields_Pairwise): Asserts.

2 years ago[Ada] Simplify iteration of record components when expanding equality
Piotr Trojanek [Mon, 11 Oct 2021 12:09:42 +0000 (14:09 +0200)]
[Ada] Simplify iteration of record components when expanding equality

gcc/ada/

* exp_ch4.adb (Expand_Composite_Equality): Fix style.
(Element_To_Compare): Simplify loop.
(Expand_Record_Equality): Adapt calls to Element_To_Compare.

2 years ago[Ada] Relax INOX restrictions when casing on composite value.
Steve Baird [Fri, 15 Oct 2021 22:23:34 +0000 (15:23 -0700)]
[Ada] Relax INOX restrictions when casing on composite value.

gcc/ada/

* sem_case.adb (Composite_Case_Ops.Box_Value_Required): A new
function which takes a component type and returns a Boolean.
Returns True for the cases which were formerly forbidden as
components (these checks were formerly performed in the
now-deleted procedure
Check_Composite_Case_Selector.Check_Component_Subtype).
(Composite_Case_Ops.Normalized_Case_Expr_Type): Hoist this
function out of the Array_Case_Ops package because it has been
generalized to also do the analogous thing in the case of a
discriminated type.
(Composite_Case_Ops.Scalar_Part_Count): Return 0 if
Box_Value_Required returns True for the given type/subtype.
(Composite_Case_Ops.Choice_Analysis.Choice_Analysis.Component_Bounds_Info.
Traverse_Discrete_Parts): Return without doing anything if
Box_Value_Required returns True for the given type/subtype.
(Composite_Case_Ops.Choice_Analysis.Parse_Choice.Traverse_Choice):
If Box_Value_Required yields True for a given component type,
then check that the value of that component in a choice
expression is indeed a box (in which case the component is
ignored).
* doc/gnat_rm/implementation_defined_pragmas.rst: Update
documentation.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Update the inactive GMP variant of Big_Integers
Piotr Trojanek [Tue, 19 Oct 2021 15:31:26 +0000 (17:31 +0200)]
[Ada] Update the inactive GMP variant of Big_Integers

gcc/ada/

* libgnat/a-nbnbin__gmp.adb (From_String): Fix predicate
mismatch between subprogram declaration and body.

2 years ago[Ada] Make Declaration_Node return nondeclarations in fewer cases
Bob Duff [Mon, 6 Sep 2021 17:01:04 +0000 (13:01 -0400)]
[Ada] Make Declaration_Node return nondeclarations in fewer cases

gcc/ada/

* einfo-utils.adb (Declaration_Node): Avoid returning the
following node kinds: N_Assignment_Statement, N_Integer_Literal,
N_Procedure_Call_Statement, N_Subtype_Indication, and
N_Type_Conversion.  Assert that the result is in N_Is_Decl or
empty.
* gen_il-gen-gen_nodes.adb (N_Is_Decl): Modify to match the
things that Declaration_Node can return.

2 years ago[Ada] Global contracts on expression functions in Ada.Strings.Superbounded
Piotr Trojanek [Tue, 27 Jul 2021 14:06:30 +0000 (16:06 +0200)]
[Ada] Global contracts on expression functions in Ada.Strings.Superbounded

gcc/ada/

* libgnat/a-strsup.ads (Super_Length, Super_Element,
Super_Slice): Add Global contracts.

2 years ago[Ada] Simplify detection of a parent interface equality
Piotr Trojanek [Fri, 8 Oct 2021 12:45:51 +0000 (14:45 +0200)]
[Ada] Simplify detection of a parent interface equality

gcc/ada/

* exp_ch3.adb (Predefined_Primitive_Bodies): Simplify detection
of existing equality operator.

2 years ago[Ada] Remove redundant guard in expansion of dispatching calls
Piotr Trojanek [Fri, 8 Oct 2021 12:37:52 +0000 (14:37 +0200)]
[Ada] Remove redundant guard in expansion of dispatching calls

gcc/ada/

* exp_ch3.adb (Predefined_Primitive_Bodies): Remove redundant
conditions related to interface types.

2 years ago[Ada] Do not expect execv to return 0
Piotr Trojanek [Thu, 15 Apr 2021 21:22:32 +0000 (23:22 +0200)]
[Ada] Do not expect execv to return 0

gcc/ada/

* adaint.c (__gnat_portable_spawn): Do not expect execv to
return 0.
(__gnat_portable_no_block_spawn): Likewise.

2 years ago[Ada] Initialize variable to Empty
Ghjuvan Lacambre [Wed, 20 Oct 2021 09:56:09 +0000 (11:56 +0200)]
[Ada] Initialize variable to Empty

gcc/ada/

* sem_ch8.adb (Analyze_Subprogram_Renaming): Set New_S to Empty.

2 years ago[Ada] Reference in Unbounded_String is almost never null
Piotr Trojanek [Tue, 15 Jun 2021 21:32:51 +0000 (23:32 +0200)]
[Ada] Reference in Unbounded_String is almost never null

gcc/ada/

* libgnat/a-strunb.ads (Unbounded_String): Reference is never
null.
* libgnat/a-strunb.adb (Finalize): Copy reference while it needs
to be deallocated.

2 years ago[Ada] Don't expect enumeration literals to be renamings
Piotr Trojanek [Wed, 20 Oct 2021 07:46:38 +0000 (09:46 +0200)]
[Ada] Don't expect enumeration literals to be renamings

gcc/ada/

* lib-xref.adb (Get_Through_Renamings): Exit loop when an
enumeration literal is found.

2 years ago[Ada] Shutdown codepeer message
Arnaud Charlet [Tue, 19 Oct 2021 16:44:17 +0000 (12:44 -0400)]
[Ada] Shutdown codepeer message

gcc/ada/

* libgnat/s-widthu.adb: Add pragma Annotate.

2 years ago[Ada] Ada 2022: Class-wide types and formal abstract subprograms
Javier Miranda [Sat, 4 Sep 2021 17:11:34 +0000 (13:11 -0400)]
[Ada] Ada 2022: Class-wide types and formal abstract subprograms

gcc/ada/

* sem_ch8.adb (Build_Class_Wide_Wrapper): Previous version split
in two subprograms to factorize its functionality:
Find_Suitable_Candidate, and Build_Class_Wide_Wrapper. These
routines are also placed in the new subprogram
Handle_Instance_With_Class_Wide_Type.
(Handle_Instance_With_Class_Wide_Type): New subprogram that
encapsulates all the code that handles instantiations with
class-wide types.
(Analyze_Subprogram_Renaming): Adjust code to invoke the new
nested subprogram Handle_Instance_With_Class_Wide_Type; adjust
documentation.

2 years ago[Ada] Renamed_Or_Alias cleanup
Bob Duff [Fri, 10 Sep 2021 15:18:47 +0000 (11:18 -0400)]
[Ada] Renamed_Or_Alias cleanup

gcc/ada/

* einfo-utils.ads, einfo-utils.adb (Alias, Set_Alias,
Renamed_Entity, Set_Renamed_Entity, Renamed_Object,
Set_Renamed_Object): Add assertions that reflect how these are
supposed to be used and what they are supposed to return.
(Renamed_Entity_Or_Object): New getter.
(Set_Renamed_Object_Of_Possibly_Void): Setter that allows N to
be E_Void.
* checks.adb (Ensure_Valid): Use Renamed_Entity_Or_Object
because this is called for both cases.
* exp_dbug.adb (Debug_Renaming_Declaration): Use
Renamed_Entity_Or_Object because this is called for both cases.
Add assertions.
* exp_util.adb (Possible_Bit_Aligned_Component): Likewise.
* freeze.adb (Freeze_All_Ent): Likewise.
* sem_ch5.adb (Within_Function): Likewise.
* exp_attr.adb (Calculate_Header_Size): Call Renamed_Entity
instead of Renamed_Object.
* exp_ch11.adb (Expand_N_Raise_Statement): Likewise.
* repinfo.adb (Find_Declaration): Likewise.
* sem_ch10.adb (Same_Unit, Process_Spec_Clauses,
Analyze_With_Clause, Install_Parents): Likewise.
* sem_ch12.adb (Build_Local_Package, Needs_Body_Instantiated,
Build_Subprogram_Renaming, Check_Formal_Package_Instance,
Check_Generic_Actuals, In_Enclosing_Instance,
Denotes_Formal_Package, Process_Nested_Formal,
Check_Initialized_Types, Map_Formal_Package_Entities,
Restore_Nested_Formal): Likewise.
* sem_ch6.adb (Report_Conflict): Likewise.
* sem_ch8.adb (Analyze_Exception_Renaming,
Analyze_Generic_Renaming, Analyze_Package_Renaming,
Is_Primitive_Operator_In_Use, Declared_In_Actual,
Note_Redundant_Use): Likewise.
* sem_warn.adb (Find_Package_Renaming): Likewise.
* sem_elab.adb (Ultimate_Variable): Call Renamed_Object instead
of Renamed_Entity.
* exp_ch6.adb (Get_Function_Id): Call
Set_Renamed_Object_Of_Possibly_Void, because the defining
identifer is still E_Void at this point.
* sem_util.adb (Function_Call_Or_Allocator_Level): Likewise.
Remove redundant (unreachable) code.
(Is_Object_Renaming, Is_Valid_Renaming): Call Renamed_Object
instead of Renamed_Entity.
(Get_Fullest_View): Call Renamed_Entity instead of
Renamed_Object.
(Copy_Node_With_Replacement): Call
Set_Renamed_Object_Of_Possibly_Void because the defining entity
is sometimes E_Void.
* exp_ch5.adb (Expand_N_Assignment_Statement): Protect a call to
Renamed_Object with Is_Object to avoid assertion failure.
* einfo.ads: Minor comment fixes.
* inline.adb: Minor comment fixes.
* tbuild.ads: Minor comment fixes.

2 years ago[Ada] Remove more uses of exception propagation during bootstrap
Arnaud Charlet [Tue, 19 Oct 2021 07:40:32 +0000 (03:40 -0400)]
[Ada] Remove more uses of exception propagation during bootstrap

gcc/ada/

* sem_ch13.adb (Build_Discrete_Static_Predicate): Remove use of
exception propagation since this code is exercised during the
bootstrap.

2 years ago[Ada] Issue error on invalid use of Ghost inside pragma Predicate
Yannick Moy [Fri, 15 Oct 2021 13:06:34 +0000 (15:06 +0200)]
[Ada] Issue error on invalid use of Ghost inside pragma Predicate

gcc/ada/

* sem_ch13.adb (Freeze_Entity_Checks): Perform same check on
predicate expression inside pragma as inside aspect.
* sem_util.adb (Is_Current_Instance): Recognize possible
occurrence of subtype as current instance inside the pragma
Predicate.

2 years ago[Ada] Fix deleted Compile_Time warnings causing crashes
Ghjuvan Lacambre [Mon, 18 Oct 2021 13:34:42 +0000 (15:34 +0200)]
[Ada] Fix deleted Compile_Time warnings causing crashes

gcc/ada/

* erroutc.adb (Count_Compile_Time_Pragma_Warnings): Don't count
deleted warnings.