From dc6866b033b1b85f690bf32c0dae7d787cbf58f0 Mon Sep 17 00:00:00 2001 From: Jan-Benedict Glaw Date: Tue, 29 Jun 2021 09:23:07 +0200 Subject: pdp11: Fix signednedd warnings, remove "register" keywords gcc/ChangeLog: * config/pdp11/pdp11.h (ASM_OUTPUT_SKIP): Fix signedness warning. * config/pdp11/pdp11.c (pdp11_asm_print_operand_punct_valid_p): Remove "register" keyword. (pdp11_initial_elimination_offset) Remove unused variable. (pdp11_cmp_length) Ditto. (pdp11_insn_cost): Ditto, and fix signedness warning. --- gcc/config/pdp11/pdp11.c | 27 ++++++++++++--------------- gcc/config/pdp11/pdp11.h | 10 ++++++---- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'gcc') diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index b663b43..4cab3ae 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -829,12 +829,12 @@ pdp11_asm_print_operand_punct_valid_p (unsigned char c) } void -print_operand_address (FILE *file, register rtx addr) +print_operand_address (FILE *file, rtx addr) { - register rtx breg; + rtx breg; rtx offset; int again = 0; - + retry: switch (GET_CODE (addr)) @@ -1160,12 +1160,11 @@ pdp11_addr_cost (rtx addr, machine_mode mode, addr_space_t as ATTRIBUTE_UNUSED, static int pdp11_insn_cost (rtx_insn *insn, bool speed) { - int base_cost, i; + int base_cost; rtx pat, set, dest, src, src2; machine_mode mode; - const char *fmt; enum rtx_code op; - + if (recog_memoized (insn) < 0) return 0; @@ -1462,24 +1461,24 @@ bool pushpop_regeq (rtx op, int regno) { rtx addr; - + /* False if not memory reference. */ if (GET_CODE (op) != MEM) return FALSE; - + /* Get the address of the memory reference. */ addr = XEXP (op, 0); if (GET_CODE (addr) == MEM) addr = XEXP (addr, 0); - + switch (GET_CODE (addr)) { case PRE_DEC: case POST_INC: case PRE_MODIFY: case POST_MODIFY: - return REGNO (XEXP (addr, 0)) == regno; + return REGNO (XEXP (addr, 0)) == (unsigned) regno; default: return FALSE; } @@ -1771,8 +1770,7 @@ int pdp11_initial_elimination_offset (int from, int to) { /* Get the size of the register save area. */ - int spoff; - + if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM) return get_frame_size (); else if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM) @@ -2106,15 +2104,14 @@ pdp11_cmp_length (rtx *operands, int words) { rtx inops[2]; rtx exops[4][2]; - rtx lb[1]; int i, len = 0; if (!reload_completed) return 2; - + inops[0] = operands[0]; inops[1] = operands[1]; - + pdp11_expand_operands (inops, exops, 2, words, NULL, big); for (i = 0; i < words; i++) diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index a21ae64..9bc5e08 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -618,10 +618,12 @@ extern int current_first_parm_offset; fprintf (FILE, "\t.even\n") #define ASM_OUTPUT_SKIP(FILE,SIZE) \ - if (TARGET_DEC_ASM) \ - fprintf (FILE, "\t.blkb\t%o\n", (SIZE) & 0xffff); \ - else \ - fprintf (FILE, "\t.=.+ %#o\n", (SIZE) & 0xffff); + do { \ + if (TARGET_DEC_ASM) \ + fprintf (FILE, "\t.blkb\t%o\n", (int) ((SIZE) & 0xffff)); \ + else \ + fprintf (FILE, "\t.=.+ %#o\n", (int) ((SIZE) & 0xffff)); \ + } while (0) /* This says how to output an assembler line to define a global common symbol. */ -- cgit v1.1 From c01760bc548ba79bc9ac15168b27fe7aabcb19ae Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 29 Jun 2021 09:33:24 +0200 Subject: tree-optimization/101242 - fix reverse graph entry detection This avoids detecting random unrelated nodes as possible entries to not backwards reachable regions of the SLP graph. Instead explicitely add the problematic nodes. This temporary XFAILs gcc.dg/vect/pr67790.c until I get the permute propagation adjusted to when it needs more than one optimistic iteration. 2021-06-29 Richard Biener PR tree-optimization/101242 * tree-vect-slp.c (vect_slp_build_vertices): Force-add PHIs with not represented initial values as leafs. * gcc.dg/vect/bb-slp-pr101242.c: New testcase. * gcc.dg/vect/pr67790.c: XFAIL scan for zero VEC_PERM_EXPR. --- gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c | 38 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/pr67790.c | 2 +- gcc/tree-vect-slp.c | 24 +++++++++--------- 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c (limited to 'gcc') diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c new file mode 100644 index 0000000..d885446 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +typedef struct { + double real; + double imag; +} complex; +typedef struct { + complex e[3][3]; +} su3_matrix; +su3_matrix check_su3_c; +double check_su3_ar, check_su3_ari, check_su3_max; +int arireturn(); +int check_su3() { + check_su3_ar = check_su3_c.e[0][0].real * check_su3_c.e[1][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[1][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[1][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[1][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[1][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[1][2].imag; + check_su3_max = check_su3_c.e[0][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[2][2].imag; + check_su3_ari = check_su3_ar; + if (check_su3_ari) + check_su3_max = check_su3_c.e[1][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[1][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[1][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[1][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[1][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[1][2].imag * check_su3_c.e[2][2].imag; + if (check_su3_max) + arireturn(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr67790.c b/gcc/testsuite/gcc.dg/vect/pr67790.c index 32eacd9..0555d41 100644 --- a/gcc/testsuite/gcc.dg/vect/pr67790.c +++ b/gcc/testsuite/gcc.dg/vect/pr67790.c @@ -38,4 +38,4 @@ int main() } /* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail *-*-* } } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 5401dbe..63b6e6a 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3499,13 +3499,21 @@ vect_slp_build_vertices (hash_set &visited, slp_tree node, vertices.safe_push (slpg_vertex (node)); bool leaf = true; + bool force_leaf = false; FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child) if (child) { leaf = false; vect_slp_build_vertices (visited, child, vertices, leafs); } - if (leaf) + else + force_leaf = true; + /* Since SLP discovery works along use-def edges all cycles have an + entry - but there's the exception of cycles where we do not handle + the entry explicitely (but with a NULL SLP node), like some reductions + and inductions. Force those SLP PHIs to act as leafs to make them + backwards reachable. */ + if (leaf || force_leaf) leafs.safe_push (node->vertex); } @@ -3519,18 +3527,8 @@ vect_slp_build_vertices (vec_info *info, vec &vertices, unsigned i; slp_instance instance; FOR_EACH_VEC_ELT (info->slp_instances, i, instance) - { - unsigned n_v = vertices.length (); - unsigned n_l = leafs.length (); - vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, - leafs); - /* If we added vertices but no entries to the reverse graph we've - added a cycle that is not backwards-reachable. Push the entry - to mimic as leaf then. */ - if (vertices.length () > n_v - && leafs.length () == n_l) - leafs.safe_push (SLP_INSTANCE_TREE (instance)->vertex); - } + vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, + leafs); } /* Apply (reverse) bijectite PERM to VEC. */ -- cgit v1.1 From 53fd7544aff6d0a18869017cb9bb921a7f5dcd04 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 29 Jun 2021 11:24:38 +0200 Subject: match.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when sanitizing [PR101210] When we have (intptr_t) x == cst where x has REFERENCE_TYPE, this optimization creates x == cst out of it where cst has REFERENCE_TYPE. If it is done in GENERIC folding, it can results in ubsan failures where the INTEGER_CST with REFERENCE_TYPE is instrumented. Fixed by deferring it to GIMPLE folding in this case. 2021-06-29 Jakub Jelinek PR c++/101210 * match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't perform the optimization in GENERIC when sanitizing and x has a reference type. * g++.dg/ubsan/pr101210.C: New test. --- gcc/match.pd | 7 ++++++- gcc/testsuite/g++.dg/ubsan/pr101210.C | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ubsan/pr101210.C (limited to 'gcc') diff --git a/gcc/match.pd b/gcc/match.pd index 39fb57e..8205271 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5124,7 +5124,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp (convert @0) INTEGER_CST@1) (if (((POINTER_TYPE_P (TREE_TYPE (@0)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))) - && INTEGRAL_TYPE_P (TREE_TYPE (@1))) + && INTEGRAL_TYPE_P (TREE_TYPE (@1)) + /* Don't perform this optimization in GENERIC if @0 has reference + type when sanitizing. See PR101210. */ + && !(GENERIC + && TREE_CODE (TREE_TYPE (@0)) == REFERENCE_TYPE + && (flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT)))) || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@1))))) diff --git a/gcc/testsuite/g++.dg/ubsan/pr101210.C b/gcc/testsuite/g++.dg/ubsan/pr101210.C new file mode 100644 index 0000000..955b820 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr101210.C @@ -0,0 +1,13 @@ +// PR c++/101210 +// { dg-do run } +// { dg-options "-fsanitize=null,alignment -fno-sanitize-recover=null,alignment" } + +int v[2]; +int +main () +{ + int x; + int &y = x; + v[0] = reinterpret_cast<__INTPTR_TYPE__>(&y) == 0; + v[1] = reinterpret_cast<__INTPTR_TYPE__>(&y) == 1; +} -- cgit v1.1 From 2dfc0f2203e875621f4aeb2e2496aaeb9a2dc05b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 29 Jun 2021 11:30:23 +0200 Subject: Refactor SLP permute opt propagation This rewrites the SLP permute opt propagation to elide the visited bit for an incoming permute of -1 as well as allowing the initial propagation to take more than one iteration before starting on materialization. As we still lack propagation in the reverse direction I've added gcc.dg/vect/bb-slp-71.c and a stopgap to restrict "any" permute handling to the supported cases. 2021-06-29 Richard Biener * tree-vect-slp.c (slpg_vertex::visited): Remove. (vect_slp_perms_eq): Handle -1 permutes. (vect_optimize_slp): Rewrite permute propagation. * gcc.dg/vect/pr67790.c: Un-XFAIL. * gcc.dg/vect/bb-slp-71.c: New testcase. --- gcc/testsuite/gcc.dg/vect/bb-slp-71.c | 32 ++++++++ gcc/testsuite/gcc.dg/vect/pr67790.c | 2 +- gcc/tree-vect-slp.c | 140 +++++++++++++++++++++------------- 3 files changed, 120 insertions(+), 54 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-71.c (limited to 'gcc') diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-71.c b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c new file mode 100644 index 0000000..6816511 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +#include "tree-vect.h" + +int a[4], b[4]; + +void __attribute__((noipa)) +foo(int x, int y) +{ + int tem0 = x + 1; + int tem1 = y + 2; + int tem2 = x + 3; + int tem3 = y + 4; + a[0] = tem0 + b[1]; + a[1] = tem1 + b[0]; + a[2] = tem2 + b[2]; + a[3] = tem3 + b[3]; +} + +int main() +{ + check_vect (); + + b[0] = 10; + b[1] = 14; + b[2] = 18; + b[3] = 22; + foo (-1, -3); + if (a[0] != 14 || a[1] != 9 || a[2] != 20 || a[3] != 23) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr67790.c b/gcc/testsuite/gcc.dg/vect/pr67790.c index 0555d41..32eacd9 100644 --- a/gcc/testsuite/gcc.dg/vect/pr67790.c +++ b/gcc/testsuite/gcc.dg/vect/pr67790.c @@ -38,4 +38,4 @@ int main() } /* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 63b6e6a..524bfaa 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3470,12 +3470,11 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) struct slpg_vertex { slpg_vertex (slp_tree node_) - : node (node_), visited (0), perm_out (0), materialize (0) {} + : node (node_), perm_out (-1), materialize (0) {} int get_perm_in () const { return materialize ? materialize : perm_out; } slp_tree node; - unsigned visited : 1; /* The permutation on the outgoing lanes (towards SLP parents). */ int perm_out; /* The permutation that is applied by this node. perm_out is @@ -3567,7 +3566,8 @@ vect_slp_perms_eq (const vec > &perms, int perm_a, int perm_b) { return (perm_a == perm_b - || (perms[perm_a].length () == perms[perm_b].length () + || (perm_a != -1 && perm_b != -1 + && perms[perm_a].length () == perms[perm_b].length () && memcmp (&perms[perm_a][0], &perms[perm_b][0], sizeof (unsigned) * perms[perm_a].length ()) == 0)); } @@ -3614,7 +3614,7 @@ vect_optimize_slp (vec_info *vinfo) /* Leafs do not change across iterations. Note leafs also double as entries to the reverse graph. */ if (!slpg->vertices[idx].succ) - vertices[idx].visited = 1; + vertices[idx].perm_out = 0; /* Loads are the only thing generating permutes. */ if (!SLP_TREE_LOAD_PERMUTATION (node).exists ()) continue; @@ -3668,12 +3668,17 @@ vect_optimize_slp (vec_info *vinfo) /* Propagate permutes along the graph and compute materialization points. */ bool changed; + bool do_materialization = false; unsigned iteration = 0; do { changed = false; ++iteration; + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "SLP optimize iteration %d\n", iteration); + for (i = vertices.length (); i > 0 ; --i) { int idx = ipo[i-1]; @@ -3685,19 +3690,21 @@ vect_optimize_slp (vec_info *vinfo) || SLP_TREE_DEF_TYPE (node) == vect_constant_def) continue; - vertices[idx].visited = 1; - /* We still eventually have failed backedge SLP nodes in the graph, those are only cancelled when analyzing operations. Simply treat them as transparent ops, propagating permutes through them. */ if (SLP_TREE_DEF_TYPE (node) == vect_internal_def) { - /* We do not handle stores with a permutation. */ + /* We do not handle stores with a permutation, so all + incoming permutes must have been materialized. */ stmt_vec_info rep = SLP_TREE_REPRESENTATIVE (node); if (STMT_VINFO_DATA_REF (rep) && DR_IS_WRITE (STMT_VINFO_DATA_REF (rep))) - continue; + { + vertices[idx].perm_out = 0; + continue; + } /* We cannot move a permute across an operation that is not independent on lanes. Note this is an explicit negative list since that's much shorter than the respective @@ -3710,63 +3717,82 @@ vect_optimize_slp (vec_info *vinfo) case CFN_COMPLEX_MUL: case CFN_COMPLEX_MUL_CONJ: case CFN_VEC_ADDSUB: + vertices[idx].perm_out = 0; continue; default:; } } - int perm = -1; - for (graph_edge *succ = slpg->vertices[idx].succ; - succ; succ = succ->succ_next) - { - int succ_idx = succ->dest; - /* Handle unvisited nodes optimistically. */ - /* ??? But for constants once we want to handle non-bijective - permutes we have to verify the permute, when unifying lanes, - will not unify different constants. For example see - gcc.dg/vect/bb-slp-14.c for a case that would break. */ - if (!vertices[succ_idx].visited) - continue; - int succ_perm = vertices[succ_idx].perm_out; - if (perm == -1) - perm = succ_perm; - else if (succ_perm == 0) - { - perm = 0; - break; - } - else if (!vect_slp_perms_eq (perms, perm, succ_perm)) - { - perm = 0; - break; - } - } - - if (perm == -1) + int perm; + if (!slpg->vertices[idx].succ) /* Pick up pre-computed leaf values. */ perm = vertices[idx].perm_out; - else if (!vect_slp_perms_eq (perms, perm, - vertices[idx].get_perm_in ())) + else { - if (iteration > 1) - /* Make sure we eventually converge. */ - gcc_checking_assert (perm == 0); - if (perm == 0) + perm = -1; + bool all_constant = true; + for (graph_edge *succ = slpg->vertices[idx].succ; + succ; succ = succ->succ_next) { - vertices[idx].perm_out = 0; - vertices[idx].materialize = 0; + int succ_idx = succ->dest; + slp_tree succ_node = vertices[succ_idx].node; + if (SLP_TREE_DEF_TYPE (succ_node) != vect_external_def + && SLP_TREE_DEF_TYPE (succ_node) != vect_constant_def) + all_constant = false; + int succ_perm = vertices[succ_idx].perm_out; + /* Handle unvisited (and constant) nodes optimistically. */ + /* ??? But for constants once we want to handle + non-bijective permutes we have to verify the permute, + when unifying lanes, will not unify different constants. + For example see gcc.dg/vect/bb-slp-14.c for a case + that would break. */ + if (succ_perm == -1) + continue; + if (perm == -1) + perm = succ_perm; + else if (succ_perm == 0) + { + perm = 0; + break; + } + else if (!vect_slp_perms_eq (perms, perm, succ_perm)) + { + perm = 0; + break; + } + } + /* We still lack a forward propagation of materializations + and thus only allow "any" permutes on constant or external + nodes which we handle during materialization by looking + at SLP children. So avoid having internal "any" permutes + for now, see gcc.dg/vect/bb-slp-71.c for a testcase that + breaks when removing this restriction. */ + if (perm == -1 && all_constant) + perm = 0; + + if (!vect_slp_perms_eq (perms, perm, + vertices[idx].get_perm_in ())) + { + /* Make sure we eventually converge. */ + gcc_checking_assert (vertices[idx].get_perm_in () == -1 + || perm == 0); + if (perm == 0) + { + vertices[idx].perm_out = 0; + vertices[idx].materialize = 0; + } + if (!vertices[idx].materialize) + vertices[idx].perm_out = perm; + changed = true; } - if (!vertices[idx].materialize) - vertices[idx].perm_out = perm; - changed = true; } - if (perm == 0) + /* Elide pruning at materialization points in the first + iteration phase. */ + if (!do_materialization) continue; - /* Elide pruning at materialization points in the first - iteration so every node was visited once at least. */ - if (iteration == 1) + if (perm == 0 || perm == -1) continue; /* Decide on permute materialization. Look whether there's @@ -3784,8 +3810,8 @@ vect_optimize_slp (vec_info *vinfo) for (graph_edge *pred = slpg->vertices[idx].pred; pred; pred = pred->pred_next) { - gcc_checking_assert (vertices[pred->src].visited); int pred_perm = vertices[pred->src].get_perm_in (); + gcc_checking_assert (pred_perm != -1); if (!vect_slp_perms_eq (perms, perm, pred_perm)) { all_preds_permuted = false; @@ -3800,8 +3826,16 @@ vect_optimize_slp (vec_info *vinfo) vertices[idx].perm_out = 0; } } + + /* If the initial propagation converged, switch on materialization + and re-propagate. */ + if (!changed && !do_materialization) + { + do_materialization = true; + changed = true; + } } - while (changed || iteration == 1); + while (changed); /* Materialize. */ for (i = 0; i < vertices.length (); ++i) -- cgit v1.1 From d479ddc0d9854905d03a3290b203a5dcb8db07eb Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 29 Jun 2021 14:40:43 +0200 Subject: doc/invoke.texi: Sort flags in 'C Language Options' As discussed during the review of '[Patch] Add 'default' to -foffload=; document that flag [PR67300]'. gcc/ChangeLog: * doc/invoke.texi (C Language Options): Sort options alphabetically in optlist and also the description itself. Remove leftover -fallow-single-precision from and add missing -fgnu-tm to the optlist. --- gcc/doc/invoke.texi | 253 ++++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 127 deletions(-) (limited to 'gcc') diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2dc6a21..bf52909 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -197,17 +197,16 @@ in the following sections. @item C Language Options @xref{C Dialect Options,,Options Controlling C Dialect}. -@gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol --fpermitted-flt-eval-methods=@var{standard} @gol --aux-info @var{filename} -fallow-parameterless-variadic-functions @gol --fno-asm -fno-builtin -fno-builtin-@var{function} -fgimple@gol --fhosted -ffreestanding @gol +@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol +-fallow-parameterless-variadic-functions -fno-asm @gol +-fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol +-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol +-flax-vector-conversions -fms-extensions @gol -fopenacc -fopenacc-dim=@var{geom} @gol -fopenmp -fopenmp-simd @gol --fms-extensions -fplan9-extensions -fsso-struct=@var{endianness} @gol --fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol --fsigned-bitfields -fsigned-char @gol --funsigned-bitfields -funsigned-char} +-fpermitted-flt-eval-methods=@var{standard} @gol +-fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol +-fsigned-char -funsigned-char -fsso-struct=@var{endianness}} @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @@ -2449,50 +2448,6 @@ and will almost certainly change in incompatible ways in future releases. @end table -@item -fgnu89-inline -@opindex fgnu89-inline -The option @option{-fgnu89-inline} tells GCC to use the traditional -GNU semantics for @code{inline} functions when in C99 mode. -@xref{Inline,,An Inline Function is As Fast As a Macro}. -Using this option is roughly equivalent to adding the -@code{gnu_inline} function attribute to all inline functions -(@pxref{Function Attributes}). - -The option @option{-fno-gnu89-inline} explicitly tells GCC to use the -C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it -specifies the default behavior). -This option is not supported in @option{-std=c90} or -@option{-std=gnu90} mode. - -The preprocessor macros @code{__GNUC_GNU_INLINE__} and -@code{__GNUC_STDC_INLINE__} may be used to check which semantics are -in effect for @code{inline} functions. @xref{Common Predefined -Macros,,,cpp,The C Preprocessor}. - -@item -fpermitted-flt-eval-methods=@var{style} -@opindex fpermitted-flt-eval-methods -@opindex fpermitted-flt-eval-methods=c11 -@opindex fpermitted-flt-eval-methods=ts-18661-3 -ISO/IEC TS 18661-3 defines new permissible values for -@code{FLT_EVAL_METHOD} that indicate that operations and constants with -a semantic type that is an interchange or extended format should be -evaluated to the precision and range of that type. These new values are -a superset of those permitted under C99/C11, which does not specify the -meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code -conforming to C11 may not have been written expecting the possibility of -the new values. - -@option{-fpermitted-flt-eval-methods} specifies whether the compiler -should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, -or the extended set of values specified in ISO/IEC TS 18661-3. - -@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. - -The default when in a standards compliant mode (@option{-std=c11} or similar) -is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU -dialect (@option{-std=gnu11} or similar) is -@option{-fpermitted-flt-eval-methods=ts-18661-3}. - @item -aux-info @var{filename} @opindex aux-info Output to the given filename prototyped declarations for all functions @@ -2573,6 +2528,25 @@ built-in functions selectively when using @option{-fno-builtin} or #define strcpy(d, s) __builtin_strcpy ((d), (s)) @end smallexample +@item -fcond-mismatch +@opindex fcond-mismatch +Allow conditional expressions with mismatched types in the second and +third arguments. The value of such an expression is void. This option +is not supported for C++. + +@item -ffreestanding +@opindex ffreestanding +@cindex hosted environment + +Assert that compilation targets a freestanding environment. This +implies @option{-fno-builtin}. A freestanding environment +is one in which the standard library may not exist, and program startup may +not necessarily be at @code{main}. The most obvious example is an OS kernel. +This is equivalent to @option{-fno-hosted}. + +@xref{Standards,,Language Standards Supported by GCC}, for details of +freestanding and hosted environments. + @item -fgimple @opindex fgimple @@ -2580,6 +2554,42 @@ Enable parsing of function definitions marked with @code{__GIMPLE}. This is an experimental feature that allows unit testing of GIMPLE passes. +@item -fgnu-tm +@opindex fgnu-tm +When the option @option{-fgnu-tm} is specified, the compiler +generates code for the Linux variant of Intel's current Transactional +Memory ABI specification document (Revision 1.1, May 6 2009). This is +an experimental feature whose interface may change in future versions +of GCC, as the official specification changes. Please note that not +all architectures are supported for this feature. + +For more information on GCC's support for transactional memory, +@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU +Transactional Memory Library}. + +Note that the transactional memory feature is not supported with +non-call exceptions (@option{-fnon-call-exceptions}). + +@item -fgnu89-inline +@opindex fgnu89-inline +The option @option{-fgnu89-inline} tells GCC to use the traditional +GNU semantics for @code{inline} functions when in C99 mode. +@xref{Inline,,An Inline Function is As Fast As a Macro}. +Using this option is roughly equivalent to adding the +@code{gnu_inline} function attribute to all inline functions +(@pxref{Function Attributes}). + +The option @option{-fno-gnu89-inline} explicitly tells GCC to use the +C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it +specifies the default behavior). +This option is not supported in @option{-std=c90} or +@option{-std=gnu90} mode. + +The preprocessor macros @code{__GNUC_GNU_INLINE__} and +@code{__GNUC_STDC_INLINE__} may be used to check which semantics are +in effect for @code{inline} functions. @xref{Common Predefined +Macros,,,cpp,The C Preprocessor}. + @item -fhosted @opindex fhosted @cindex hosted environment @@ -2590,18 +2600,32 @@ entire standard library is available, and in which @code{main} has a return type of @code{int}. Examples are nearly everything except a kernel. This is equivalent to @option{-fno-freestanding}. -@item -ffreestanding -@opindex ffreestanding -@cindex hosted environment +@item -flax-vector-conversions +@opindex flax-vector-conversions +Allow implicit conversions between vectors with differing numbers of +elements and/or incompatible element types. This option should not be +used for new code. -Assert that compilation targets a freestanding environment. This -implies @option{-fno-builtin}. A freestanding environment -is one in which the standard library may not exist, and program startup may -not necessarily be at @code{main}. The most obvious example is an OS kernel. -This is equivalent to @option{-fno-hosted}. +@item -fms-extensions +@opindex fms-extensions +Accept some non-standard constructs used in Microsoft header files. -@xref{Standards,,Language Standards Supported by GCC}, for details of -freestanding and hosted environments. +In C++ code, this allows member names in structures to be similar +to previous types declarations. + +@smallexample +typedef int UOW; +struct ABC @{ + UOW UOW; +@}; +@end smallexample + +Some cases of unnamed fields in structures and unions are only +accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union +fields within structs/unions}, for details. + +Note that this option is off for all targets except for x86 +targets using ms-abi. @item -fopenacc @opindex fopenacc @@ -2640,42 +2664,29 @@ Enable handling of OpenMP's SIMD directives with @code{#pragma omp} in C/C++ and @code{!$omp} in Fortran. Other OpenMP directives are ignored. -@item -fgnu-tm -@opindex fgnu-tm -When the option @option{-fgnu-tm} is specified, the compiler -generates code for the Linux variant of Intel's current Transactional -Memory ABI specification document (Revision 1.1, May 6 2009). This is -an experimental feature whose interface may change in future versions -of GCC, as the official specification changes. Please note that not -all architectures are supported for this feature. - -For more information on GCC's support for transactional memory, -@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU -Transactional Memory Library}. - -Note that the transactional memory feature is not supported with -non-call exceptions (@option{-fnon-call-exceptions}). - -@item -fms-extensions -@opindex fms-extensions -Accept some non-standard constructs used in Microsoft header files. - -In C++ code, this allows member names in structures to be similar -to previous types declarations. +@item -fpermitted-flt-eval-methods=@var{style} +@opindex fpermitted-flt-eval-methods +@opindex fpermitted-flt-eval-methods=c11 +@opindex fpermitted-flt-eval-methods=ts-18661-3 +ISO/IEC TS 18661-3 defines new permissible values for +@code{FLT_EVAL_METHOD} that indicate that operations and constants with +a semantic type that is an interchange or extended format should be +evaluated to the precision and range of that type. These new values are +a superset of those permitted under C99/C11, which does not specify the +meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code +conforming to C11 may not have been written expecting the possibility of +the new values. -@smallexample -typedef int UOW; -struct ABC @{ - UOW UOW; -@}; -@end smallexample +@option{-fpermitted-flt-eval-methods} specifies whether the compiler +should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, +or the extended set of values specified in ISO/IEC TS 18661-3. -Some cases of unnamed fields in structures and unions are only -accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union -fields within structs/unions}, for details. +@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. -Note that this option is off for all targets except for x86 -targets using ms-abi. +The default when in a standards compliant mode (@option{-std=c11} or similar) +is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU +dialect (@option{-std=gnu11} or similar) is +@option{-fpermitted-flt-eval-methods=ts-18661-3}. @item -fplan9-extensions @opindex fplan9-extensions @@ -2688,17 +2699,26 @@ fields declared using a typedef. @xref{Unnamed Fields,,Unnamed struct/union fields within structs/unions}, for details. This is only supported for C, not C++. -@item -fcond-mismatch -@opindex fcond-mismatch -Allow conditional expressions with mismatched types in the second and -third arguments. The value of such an expression is void. This option -is not supported for C++. +@item -fsigned-bitfields +@itemx -funsigned-bitfields +@itemx -fno-signed-bitfields +@itemx -fno-unsigned-bitfields +@opindex fsigned-bitfields +@opindex funsigned-bitfields +@opindex fno-signed-bitfields +@opindex fno-unsigned-bitfields +These options control whether a bit-field is signed or unsigned, when the +declaration does not use either @code{signed} or @code{unsigned}. By +default, such a bit-field is signed, because this is consistent: the +basic integer types such as @code{int} are signed types. -@item -flax-vector-conversions -@opindex flax-vector-conversions -Allow implicit conversions between vectors with differing numbers of -elements and/or incompatible element types. This option should not be -used for new code. +@item -fsigned-char +@opindex fsigned-char +Let the type @code{char} be signed, like @code{signed char}. + +Note that this is equivalent to @option{-fno-unsigned-char}, which is +the negative form of @option{-funsigned-char}. Likewise, the option +@option{-fno-signed-char} is equivalent to @option{-funsigned-char}. @item -funsigned-char @opindex funsigned-char @@ -2719,27 +2739,6 @@ The type @code{char} is always a distinct type from each of @code{signed char} or @code{unsigned char}, even though its behavior is always just like one of those two. -@item -fsigned-char -@opindex fsigned-char -Let the type @code{char} be signed, like @code{signed char}. - -Note that this is equivalent to @option{-fno-unsigned-char}, which is -the negative form of @option{-funsigned-char}. Likewise, the option -@option{-fno-signed-char} is equivalent to @option{-funsigned-char}. - -@item -fsigned-bitfields -@itemx -funsigned-bitfields -@itemx -fno-signed-bitfields -@itemx -fno-unsigned-bitfields -@opindex fsigned-bitfields -@opindex funsigned-bitfields -@opindex fno-signed-bitfields -@opindex fno-unsigned-bitfields -These options control whether a bit-field is signed or unsigned, when the -declaration does not use either @code{signed} or @code{unsigned}. By -default, such a bit-field is signed, because this is consistent: the -basic integer types such as @code{int} are signed types. - @item -fsso-struct=@var{endianness} @opindex fsso-struct Set the default scalar storage order of structures and unions to the -- cgit v1.1 From 33c4e466243f2d0459d9a4d0cadc1b38a3741f3e Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 29 Jun 2021 15:58:21 +0200 Subject: Add 'default' to -foffload=; document that flag [PR67300] As -foffload={options,targets,targets=options} is very convoluted, it has been split into -foffload=targets (supporting the old syntax for backward compatibilty) and -foffload-options={options,target=options}. Only the new syntax is documented. Additionally, -foffload=default is supported, which can reset the devices after -foffload=disable / -foffload=targets to the default, if needed. gcc/ChangeLog: PR other/67300 * common.opt (-foffload=): Update description. (-foffload-options=): New. * doc/invoke.texi (C Language Options): Document -foffload and -foffload-options. * gcc.c (check_offload_target_name): New, split off from handle_foffload_option. (check_foffload_target_names): New. (handle_foffload_option): Handle -foffload=default. (driver_handle_option): Update for -foffload-options. * lto-opts.c (lto_write_options): Use -foffload-options instead of -foffload. * lto-wrapper.c (merge_and_complain, append_offload_options): Likewise. * opts.c (common_handle_option): Likewise. libgomp/ChangeLog: PR other/67300 * testsuite/libgomp.c-c++-common/reduction-16.c: Replace -foffload=nvptx-none= by -foffload-options=nvptx-none= to avoid disabling other offload targets. * testsuite/libgomp.c-c++-common/reduction-5.c: Likewise. * testsuite/libgomp.c-c++-common/reduction-6.c: Likewise. * testsuite/libgomp.c/target-44.c: Likewise. --- gcc/common.opt | 10 ++++- gcc/doc/invoke.texi | 41 ++++++++++++++++++ gcc/gcc.c | 121 ++++++++++++++++++++++++++++++++++++++++++---------- gcc/lto-opts.c | 3 +- gcc/lto-wrapper.c | 10 ++--- gcc/opts.c | 2 +- 6 files changed, 154 insertions(+), 33 deletions(-) (limited to 'gcc') diff --git a/gcc/common.opt b/gcc/common.opt index 1dd4456..eaee74c 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2100,9 +2100,15 @@ fnon-call-exceptions Common Var(flag_non_call_exceptions) Optimization Support synchronous non-call exceptions. +; -foffload= is documented +; -foffload== is supported for backward compatibility foffload= -Common Driver Joined MissingArgError(options or targets missing after %qs) --foffload== Specify offloading targets and options for them. +Driver Joined MissingArgError(targets missing after %qs) +-foffload= Specify offloading targets + +foffload-options= +Common Driver Joined MissingArgError(options or targets=options missing after %qs) +-foffload== Specify options for the offloading targets foffload-abi= Common Joined RejectNegative Enum(offload_abi) Var(flag_offload_abi) Init(OFFLOAD_ABI_UNSET) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index bf52909..a9fd5fd 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -202,6 +202,7 @@ in the following sections. -fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol -flax-vector-conversions -fms-extensions @gol +-foffload=@var{arg} -foffload-options=@var{arg} @gol -fopenacc -fopenacc-dim=@var{geom} @gol -fopenmp -fopenmp-simd @gol -fpermitted-flt-eval-methods=@var{standard} @gol @@ -2627,6 +2628,46 @@ fields within structs/unions}, for details. Note that this option is off for all targets except for x86 targets using ms-abi. +@item -foffload=disable +@itemx -foffload=default +@itemx -foffload=@var{target-list} +@opindex foffload +@cindex Offloading targets +@cindex OpenACC offloading targets +@cindex OpenMP offloading targets +Specify for which OpenMP and OpenACC offload targets code should be generated. +The default behavior, equivalent to @option{-foffload=default}, is to generate +code for all supported offload targets. The @option{-foffload=disable} form +generates code only for the host fallback, while +@option{-foffload=@var{target-list}} generates code only for the specified +comma-separated list of offload targets. + +Offload targets are specified in GCC's internal target-triplet format. You can +run the compiler with @option{-v} to show the list of configured offload targets +under @code{OFFLOAD_TARGET_NAMES}. + +@item -foffload-options=@var{options} +@itemx -foffload-options=@var{target-triplet-list}=@var{options} +@opindex foffload +@cindex Offloading options +@cindex OpenACC offloading options +@cindex OpenMP offloading options + +With @option{-foffload-options=@var{options}}, GCC passes the specified +@var{options} to the compilers for all enabled offloading targets. You can +specify options that apply only to a specific target or targets by using +the @option{-foffload-options=@var{target-list}=@var{options}} form. The +@var{target-list} is a comma-separated list in the same format as for the +@option{-foffload=} option. + +Typical command lines are + +@smallexample +-foffload-options=-lgfortran -foffload-options=-lm +-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic +-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm +@end smallexample + @item -fopenacc @opindex fopenacc @cindex OpenACC accelerator programming diff --git a/gcc/gcc.c b/gcc/gcc.c index af28640..df9b219 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -3977,6 +3977,84 @@ driver_wrong_lang_callback (const struct cl_decoded_option *decoded, static const char *spec_lang = 0; static int last_language_n_infiles; + +/* Check that GCC is configured to support the offload target. */ + +static bool +check_offload_target_name (const char *target, ptrdiff_t len) +{ + const char *n, *c = OFFLOAD_TARGETS; + while (c) + { + n = strchr (c, ','); + if (n == NULL) + n = strchr (c, '\0'); + if (len == n - c && strncmp (target, c, n - c) == 0) + break; + c = *n ? n + 1 : NULL; + } + if (!c) + { + char *s; + auto_vec candidates; + char *cand = (char *) alloca (strlen (OFFLOAD_TARGETS) + 1); + c = OFFLOAD_TARGETS; + while (c) + { + n = strchr (c, ','); + if (n == NULL) + n = strchr (c, '\0'); + strncpy (cand, c, n - c); + cand[n - c] = '\0'; + candidates.safe_push (cand); + c = *n ? n + 1 : NULL; + } + error ("GCC is not configured to support %q.*s as offload target", + len, target); + const char *hint = candidates_list_and_hint (target, s, candidates); + if (hint) + inform (UNKNOWN_LOCATION, + "valid offload targets are: %s; did you mean %qs?", s, hint); + else + inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s); + XDELETEVEC (s); + return false; + } + return true; +} + +/* Sanity check for -foffload-options. */ + +static void +check_foffload_target_names (const char *arg) +{ + const char *cur, *next, *end; + /* If option argument starts with '-' then no target is specified and we + do not need to parse it. */ + if (arg[0] == '-') + return; + end = strchr (arg, '='); + if (end == NULL) + { + error ("%<=%>options missing after %<-foffload-options=%>target"); + return; + } + + cur = arg; + while (cur < end) + { + next = strchr (cur, ','); + if (next == NULL) + next = end; + next = (next > end) ? end : next; + + /* Retain non-supported targets after printing an error as those will not + be processed; each enabled target only processes its triplet. */ + check_offload_target_name (cur, next - cur); + cur = next + 1; + } +} + /* Parse -foffload option argument. */ static void @@ -4006,34 +4084,25 @@ handle_foffload_option (const char *arg) memcpy (target, cur, next - cur); target[next - cur] = '\0'; - /* If 'disable' is passed to the option, stop parsing the option and clean - the list of offload targets. */ - if (strcmp (target, "disable") == 0) + /* Reset offloading list and continue. */ + if (strcmp (target, "default") == 0) { free (offload_targets); - offload_targets = xstrdup (""); - break; + offload_targets = NULL; + goto next_item; } - /* Check that GCC is configured to support the offload target. */ - c = OFFLOAD_TARGETS; - while (c) + /* If 'disable' is passed to the option, clean the list of + offload targets and return, even if more targets follow. + Likewise if GCC is not configured to support that offload target. */ + if (strcmp (target, "disable") == 0 + || !check_offload_target_name (target, next - cur)) { - n = strchr (c, ','); - if (n == NULL) - n = strchr (c, '\0'); - - if (next - cur == n - c && strncmp (target, c, n - c) == 0) - break; - - c = *n ? n + 1 : NULL; + free (offload_targets); + offload_targets = xstrdup (""); + return; } - if (!c) - fatal_error (input_location, - "GCC is not configured to support %s as offload target", - target); - if (!offload_targets) { offload_targets = target; @@ -4067,7 +4136,7 @@ handle_foffload_option (const char *arg) memcpy (offload_targets + offload_targets_len, target, next - cur + 1); } } - +next_item: cur = next + 1; XDELETEVEC (target); } @@ -4499,8 +4568,16 @@ driver_handle_option (struct gcc_options *opts, flag_wpa = ""; break; + case OPT_foffload_options_: + check_foffload_target_names (arg); + break; + case OPT_foffload_: handle_foffload_option (arg); + if (arg[0] == '-' || NULL != strchr (arg, '=')) + save_switch (concat ("-foffload-options=", arg, NULL), + 0, NULL, validated, true); + do_save = false; break; default: diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index 6dd55b6..9496b3c 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -174,7 +174,8 @@ lto_write_options (void) We do not need those. The only exception is -foffload option, if we write it in offload_lto section. Also drop all diagnostic options. */ if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) - && (!lto_stream_offload_p || option->opt_index != OPT_foffload_)) + && (!lto_stream_offload_p + || option->opt_index != OPT_foffload_options_)) continue; for (j = 0; j < option->canonical_option_num_elements; ++j) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 1c26439..aae48af 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -453,7 +453,7 @@ merge_and_complain (vec decoded_options, break; - case OPT_foffload_: + case OPT_foffload_options_: decoded_options.safe_push (*foption); break; @@ -833,7 +833,7 @@ append_offload_options (obstack *argv_obstack, const char *target, unsigned argc; cl_decoded_option *option = &options[i]; - if (option->opt_index != OPT_foffload_) + if (option->opt_index != OPT_foffload_options_) continue; /* If option argument starts with '-' then no target is specified. That @@ -844,11 +844,7 @@ append_offload_options (obstack *argv_obstack, const char *target, else { opts = strchr (option->arg, '='); - /* If there are offload targets specified, but no actual options, - there is nothing to do here. */ - if (!opts) - continue; - + gcc_assert (opts); cur = option->arg; while (cur < opts) diff --git a/gcc/opts.c b/gcc/opts.c index 66262c5..f159bb3 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2724,7 +2724,7 @@ common_handle_option (struct gcc_options *opts, /* Deferred. */ break; - case OPT_foffload_: + case OPT_foffload_options_: /* Deferred. */ break; -- cgit v1.1 From 6df6055d5c666e669890ff8572df2353e341a534 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 29 Jun 2021 15:26:29 +0200 Subject: Add forward propagation to SLP "any" permutes This adds a forward propagation phase to the permute optimization machinery which allows us to handle "any" permute for all kinds of nodes. To match previous behavior cost-wise we still do not allow non-external/constant nodes to be duplicated for multiple permutes and this is ensured during propagation itself. 2021-06-29 Richard Biener * tree-vect-slp.c (vect_optimize_slp): Forward propagate to "any" permute nodes and relax "any" permute proapgation during iterative backward propagation. --- gcc/tree-vect-slp.c | 81 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 18 deletions(-) (limited to 'gcc') diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 524bfaa..9155af4 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3729,16 +3729,11 @@ vect_optimize_slp (vec_info *vinfo) perm = vertices[idx].perm_out; else { - perm = -1; - bool all_constant = true; + perm = vertices[idx].get_perm_in (); for (graph_edge *succ = slpg->vertices[idx].succ; succ; succ = succ->succ_next) { int succ_idx = succ->dest; - slp_tree succ_node = vertices[succ_idx].node; - if (SLP_TREE_DEF_TYPE (succ_node) != vect_external_def - && SLP_TREE_DEF_TYPE (succ_node) != vect_constant_def) - all_constant = false; int succ_perm = vertices[succ_idx].perm_out; /* Handle unvisited (and constant) nodes optimistically. */ /* ??? But for constants once we want to handle @@ -3750,25 +3745,34 @@ vect_optimize_slp (vec_info *vinfo) continue; if (perm == -1) perm = succ_perm; - else if (succ_perm == 0) + else if (succ_perm == 0 + || !vect_slp_perms_eq (perms, perm, succ_perm)) { perm = 0; break; } - else if (!vect_slp_perms_eq (perms, perm, succ_perm)) + } + + /* If this is a node we do not want to eventually unshare + but it can be permuted at will, verify all users have + the same permutations registered and otherwise drop to + zero. */ + if (perm == -1 + && SLP_TREE_DEF_TYPE (node) != vect_external_def + && SLP_TREE_DEF_TYPE (node) != vect_constant_def) + { + int preds_perm = -1; + for (graph_edge *pred = slpg->vertices[idx].pred; + pred; pred = pred->pred_next) { - perm = 0; - break; + int pred_perm = vertices[pred->src].get_perm_in (); + if (preds_perm == -1) + preds_perm = pred_perm; + else if (!vect_slp_perms_eq (perms, + pred_perm, preds_perm)) + perm = 0; } } - /* We still lack a forward propagation of materializations - and thus only allow "any" permutes on constant or external - nodes which we handle during materialization by looking - at SLP children. So avoid having internal "any" permutes - for now, see gcc.dg/vect/bb-slp-71.c for a testcase that - breaks when removing this restriction. */ - if (perm == -1 && all_constant) - perm = 0; if (!vect_slp_perms_eq (perms, perm, vertices[idx].get_perm_in ())) @@ -3836,6 +3840,47 @@ vect_optimize_slp (vec_info *vinfo) } } while (changed); + statistics_counter_event (cfun, "SLP optimize perm iterations", iteration); + + /* Compute pre-order. */ + auto_vec heads; + heads.reserve (vinfo->slp_instances.length ()); + for (slp_instance inst : vinfo->slp_instances) + heads.quick_push (SLP_INSTANCE_TREE (inst)->vertex); + auto_vec po; + graphds_dfs (slpg, &heads[0], heads.length (), &po, true, NULL, NULL); + + /* Propagate materialized permutes to "any" permute nodes. For heads + ending up as "any" (reductions with just invariants), set them to + no permute. */ + for (int idx : heads) + if (vertices[idx].perm_out == -1) + vertices[idx].perm_out = 0; + for (i = po.length (); i > 0; --i) + { + int idx = po[i-1]; + int perm_in = vertices[idx].get_perm_in (); + slp_tree node = vertices[idx].node; + if (SLP_TREE_DEF_TYPE (node) == vect_external_def + || SLP_TREE_DEF_TYPE (node) == vect_constant_def) + continue; + gcc_assert (perm_in != -1); + for (graph_edge *succ = slpg->vertices[idx].succ; + succ; succ = succ->succ_next) + { + slp_tree succ_node = vertices[succ->dest].node; + if (SLP_TREE_DEF_TYPE (succ_node) == vect_external_def + || SLP_TREE_DEF_TYPE (succ_node) == vect_constant_def) + continue; + if (vertices[succ->dest].perm_out == -1) + vertices[succ->dest].perm_out = perm_in; + else + /* Propagation should have ensured that all preds have the same + permutation. */ + gcc_assert (vect_slp_perms_eq (perms, perm_in, + vertices[succ->dest].perm_out)); + } + } /* Materialize. */ for (i = 0; i < vertices.length (); ++i) -- cgit v1.1 From 10215ba9d7848b858d3c2103807222675028225a Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Wed, 7 Apr 2021 10:16:55 +0200 Subject: [Ada] Consistently use Validated_View for Valid_Scalars on records gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Explicitly use Validated_View for record objects. --- gcc/ada/exp_attr.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 400398d..d19ae1f 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -7460,7 +7460,7 @@ package body Exp_Attr is (Build_Record_VS_Func (Attr => N, Formal_Typ => Ptyp, - Rec_Typ => Val_Typ), + Rec_Typ => Validated_View (Ptyp)), Loc), Parameter_Associations => New_List (Pref)); end if; -- cgit v1.1 From 997d3894fbd931e4dfa210a809175d7c2dc73b4b Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Wed, 7 Apr 2021 07:52:07 -0400 Subject: [Ada] Fix bug in node/entity kind numbers in sinfo/einfo.h gcc/ada/ * gen_il-gen.adb (Put_C_Type_And_Subtypes): Put the correct numbers. * gen_il-internals.ads, gen_il-internals.adb: (Pos): Remove this function. It was assuming that the order of the enumeration literals in Type_Enum is the same as the order of the generated types Node_Kind and Entity_Kind, which is not true. --- gcc/ada/gen_il-gen.adb | 11 +++++++++-- gcc/ada/gen_il-internals.adb | 12 ------------ gcc/ada/gen_il-internals.ads | 8 ++++---- 3 files changed, 13 insertions(+), 18 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb index 6b48e8e..6a61117 100644 --- a/gcc/ada/gen_il-gen.adb +++ b/gcc/ada/gen_il-gen.adb @@ -2930,9 +2930,15 @@ package body Gen_IL.Gen is procedure Put_C_Type_And_Subtypes (S : in out Sink; Root : Root_Type) is + Cur_Pos : Root_Nat := 0; + -- Current Node_Kind'Pos or Entity_Kind'Pos to be printed + procedure Put_Enum_Lit (T : Node_Or_Entity_Type); -- Print out the #define corresponding to the Ada enumeration literal -- for T in Node_Kind and Entity_Kind (i.e. concrete types). + -- This looks like "#define Some_Kind ", where Some_Kind + -- is the Node_Kind or Entity_Kind enumeration literal, and + -- is Node_Kind'Pos or Entity_Kind'Pos of that literal. procedure Put_Kind_Subtype (T : Node_Or_Entity_Type); -- Print out the SUBTYPE macro call corresponding to an abstract @@ -2941,7 +2947,8 @@ package body Gen_IL.Gen is procedure Put_Enum_Lit (T : Node_Or_Entity_Type) is begin if T in Concrete_Type then - Put (S, "#define " & Image (T) & " " & Image (Pos (T)) & "" & LF); + Put (S, "#define " & Image (T) & " " & Image (Cur_Pos) & LF); + Cur_Pos := Cur_Pos + 1; end if; end Put_Enum_Lit; @@ -2961,7 +2968,7 @@ package body Gen_IL.Gen is Iterate_Types (Root, Pre => Put_Enum_Lit'Access); Put (S, "#define Number_" & Node_Or_Entity (Root) & "_Kinds " & - Image (Pos (Last_Concrete (Root)) + 1) & "" & LF & LF); + Image (Cur_Pos) & "" & LF & LF); Iterate_Types (Root, Pre => Put_Kind_Subtype'Access); diff --git a/gcc/ada/gen_il-internals.adb b/gcc/ada/gen_il-internals.adb index 59a142d..d77fe7a 100644 --- a/gcc/ada/gen_il-internals.adb +++ b/gcc/ada/gen_il-internals.adb @@ -477,16 +477,4 @@ package body Gen_IL.Internals is Put (S, "-- End type hierarchy for " & N_Or_E & LF & LF); end Put_Type_Hierarchy; - --------- - -- Pos -- - --------- - - function Pos (T : Concrete_Type) return Root_Nat is - First : constant Concrete_Type := - (if T in Concrete_Node then Concrete_Node'First - else Concrete_Entity'First); - begin - return Type_Enum'Pos (T) - Type_Enum'Pos (First); - end Pos; - end Gen_IL.Internals; diff --git a/gcc/ada/gen_il-internals.ads b/gcc/ada/gen_il-internals.ads index 8d13e80..9c5779b 100644 --- a/gcc/ada/gen_il-internals.ads +++ b/gcc/ada/gen_il-internals.ads @@ -202,7 +202,10 @@ package Gen_IL.Internals is Nil'Access); -- Iterate top-down on the type hierarchy. Call Pre and Post before and -- after walking child types. Note that this ignores union types, because - -- they are nonhierarchical. + -- they are nonhierarchical. The order in which concrete types are visited + -- matches the order of the generated enumeration types Node_Kind and + -- Entity_Kind, which is not the same as the order of the Type_Enum + -- type in Gen_IL.Types. function Is_Descendant (Ancestor, Descendant : Node_Or_Entity_Type) return Boolean; @@ -212,9 +215,6 @@ package Gen_IL.Internals is procedure Put_Type_Hierarchy (S : in out Sink; Root : Root_Type); - function Pos (T : Concrete_Type) return Root_Nat; - -- Return Node_Kind'Pos (T) or Entity_Kind'Pos (T) - ---------------- type Field_Desc is record -- cgit v1.1 From bb456e80c186ff703bbee22097d86d1f9b6d8623 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 7 Apr 2021 08:15:13 -0400 Subject: [Ada] Factor out many fields in entities gcc/ada/ * gen_il-gen-gen_entities.adb (Record_Field_Kind, Allocatable_Kind): Add new abstract kinds. (Constant_Or_Variable_Kind): Likewise. (E_Constant, E_Variable, E_Loop_Parameter): Use them. (E_Discriminant, E_Component): Likewise. * gen_il-types.ads (type Opt_Type_Enum): Add them. --- gcc/ada/gen_il-gen-gen_entities.adb | 117 ++++++++++++------------------------ gcc/ada/gen_il-types.ads | 3 + 2 files changed, 42 insertions(+), 78 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index 9fe9012..f5040b2 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -242,8 +242,8 @@ begin -- Gen_IL.Gen.Gen_Entities -- The initial Ekind value for a newly created entity. Also used as the -- Ekind for Standard_Void_Type, a type entity in Standard used as a -- dummy type for the return type of a procedure (the reason we create - -- this type is to share the circuits for performing overload resolution - -- on calls). + -- this type is to share the circuits for performing overload + -- resolution on calls). (Sm (Alignment, Uint), Sm (Contract, Node_Id), Sm (Is_Elaboration_Warnings_OK_Id, Flag), @@ -254,7 +254,9 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Current_Value, Node_Id), -- setter only Sm (Has_Predicates, Flag), -- setter only Sm (Initialization_Statements, Node_Id), -- setter only - Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), -- setter only + Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), + -- setter only + Sm (Package_Instantiation, Node_Id), -- setter only Sm (Related_Expression, Node_Id), -- setter only @@ -302,17 +304,10 @@ begin -- Gen_IL.Gen.Gen_Entities (Sm (Current_Value, Node_Id), Sm (Renamed_Or_Alias, Node_Id))); - Cc (E_Component, Object_Kind, - -- Components of a record declaration, private declarations of - -- protected objects. + Ab (Record_Field_Kind, Object_Kind, (Sm (Component_Bit_Offset, Uint), Sm (Component_Clause, Node_Id), Sm (Corresponding_Record_Component, Node_Id), - Sm (Discriminant_Checking_Func, Node_Id), - Sm (DT_Entry_Count, Uint, - Pre => "Is_Tag (N)"), - Sm (DT_Offset_To_Top_Func, Node_Id, - Pre => "Is_Tag (N)"), Sm (Entry_Formal, Node_Id), Sm (Esize, Uint), Sm (Interface_Name, Node_Id), @@ -320,114 +315,80 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Normalized_First_Bit, Uint), Sm (Normalized_Position, Uint), Sm (Normalized_Position_Max, Uint), - Sm (Original_Record_Component, Node_Id), + Sm (Original_Record_Component, Node_Id))); + + Cc (E_Component, Record_Field_Kind, + -- Components of a record declaration, private declarations of + -- protected objects. + (Sm (Discriminant_Checking_Func, Node_Id), + Sm (DT_Entry_Count, Uint, + Pre => "Is_Tag (N)"), + Sm (DT_Offset_To_Top_Func, Node_Id, + Pre => "Is_Tag (N)"), Sm (Prival, Node_Id, Pre => "Is_Protected_Component (N)"), Sm (Related_Type, Node_Id))); - Cc (E_Constant, Object_Kind, - -- Constants created by an object declaration with a constant keyword + Ab (Allocatable_Kind, Object_Kind, (Sm (Activation_Record_Component, Node_Id), - Sm (Actual_Subtype, Node_Id), Sm (Alignment, Uint), + Sm (Esize, Uint), + Sm (Interface_Name, Node_Id), + Sm (Is_Finalized_Transient, Flag), + Sm (Is_Ignored_Transient, Flag), + Sm (Linker_Section_Pragma, Node_Id), + Sm (Related_Expression, Node_Id), + Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + + Ab (Constant_Or_Variable_Kind, Allocatable_Kind, + (Sm (Actual_Subtype, Node_Id), Sm (BIP_Initialization_Call, Node_Id), Sm (Contract, Node_Id), Sm (Discriminal_Link, Node_Id), Sm (Encapsulating_State, Node_Id), - Sm (Esize, Uint), Sm (Extra_Accessibility, Node_Id), - Sm (Full_View, Node_Id), Sm (Initialization_Statements, Node_Id), - Sm (Interface_Name, Node_Id), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), Sm (Last_Aggregate_Assignment, Node_Id), - Sm (Linker_Section_Pragma, Node_Id), Sm (Optimize_Alignment_Space, Flag), Sm (Optimize_Alignment_Time, Flag), Sm (Prival_Link, Node_Id), - Sm (Related_Expression, Node_Id), Sm (Related_Type, Node_Id), Sm (Return_Statement, Node_Id), Sm (Size_Check_Code, Node_Id), Sm (SPARK_Pragma, Node_Id), - Sm (SPARK_Pragma_Inherited, Flag), - Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + Sm (SPARK_Pragma_Inherited, Flag))); + + Cc (E_Constant, Constant_Or_Variable_Kind, + -- Constants created by an object declaration with a constant keyword + (Sm (Full_View, Node_Id))); - Cc (E_Discriminant, Object_Kind, + Cc (E_Discriminant, Record_Field_Kind, -- A discriminant, created by the use of a discriminant in a type -- declaration. - (Sm (Component_Bit_Offset, Uint), - Sm (Component_Clause, Node_Id), - Sm (Corresponding_Discriminant, Node_Id), - Sm (Corresponding_Record_Component, Node_Id), + (Sm (Corresponding_Discriminant, Node_Id), Sm (CR_Discriminant, Node_Id), Sm (Discriminal, Node_Id), Sm (Discriminant_Default_Value, Node_Id), Sm (Discriminant_Number, Uint), - Sm (Entry_Formal, Node_Id), - Sm (Esize, Uint), - Sm (Interface_Name, Node_Id), - Sm (Is_Completely_Hidden, Flag), - Sm (Linker_Section_Pragma, Node_Id), - Sm (Normalized_First_Bit, Uint), - Sm (Normalized_Position, Uint), - Sm (Normalized_Position_Max, Uint), - Sm (Original_Record_Component, Node_Id))); + Sm (Is_Completely_Hidden, Flag))); - Cc (E_Loop_Parameter, Object_Kind, - -- A loop parameter created by a for loop - (Sm (Activation_Record_Component, Node_Id), - Sm (Alignment, Uint), - Sm (Esize, Uint), - Sm (Interface_Name, Node_Id), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), - Sm (Linker_Section_Pragma, Node_Id), - Sm (Related_Expression, Node_Id), - Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + Cc (E_Loop_Parameter, Allocatable_Kind); + -- A loop parameter created by a for loop - Cc (E_Variable, Object_Kind, + Cc (E_Variable, Constant_Or_Variable_Kind, -- Variables created by an object declaration with no constant keyword - (Sm (Activation_Record_Component, Node_Id), - Sm (Actual_Subtype, Node_Id), - Sm (Alignment, Uint), - Sm (Anonymous_Designated_Type, Node_Id), - Sm (BIP_Initialization_Call, Node_Id), - Sm (Contract, Node_Id), + (Sm (Anonymous_Designated_Type, Node_Id), Sm (Debug_Renaming_Link, Node_Id), - Sm (Discriminal_Link, Node_Id), - Sm (Encapsulating_State, Node_Id), - Sm (Esize, Uint), - Sm (Extra_Accessibility, Node_Id), Sm (Extra_Constrained, Node_Id), Sm (Has_Initial_Value, Flag), Sm (Hiding_Loop_Variable, Node_Id), - Sm (Initialization_Statements, Node_Id), - Sm (Interface_Name, Node_Id), - Sm (Is_Elaboration_Checks_OK_Id, Flag), - Sm (Is_Elaboration_Warnings_OK_Id, Flag), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), - Sm (Last_Aggregate_Assignment, Node_Id), Sm (Last_Assignment, Node_Id), - Sm (Linker_Section_Pragma, Node_Id), Sm (OK_To_Rename, Flag), - Sm (Optimize_Alignment_Space, Flag), - Sm (Optimize_Alignment_Time, Flag), Sm (Part_Of_Constituents, Elist_Id), Sm (Part_Of_References, Elist_Id), - Sm (Prival_Link, Node_Id), - Sm (Related_Expression, Node_Id), - Sm (Related_Type, Node_Id), - Sm (Return_Statement, Node_Id), Sm (Shared_Var_Procs_Instance, Node_Id), - Sm (Size_Check_Code, Node_Id), - Sm (SPARK_Pragma, Node_Id), - Sm (SPARK_Pragma_Inherited, Flag), - Sm (Status_Flag_Or_Transient_Decl, Node_Id), Sm (Suppress_Initialization, Flag), Sm (Unset_Reference, Node_Id), Sm (Validated_Object, Node_Id))); diff --git a/gcc/ada/gen_il-types.ads b/gcc/ada/gen_il-types.ads index 482d01d..6850411 100644 --- a/gcc/ada/gen_il-types.ads +++ b/gcc/ada/gen_il-types.ads @@ -124,6 +124,7 @@ package Gen_IL.Types is Access_Subprogram_Kind, Access_Protected_Kind, Aggregate_Kind, + Allocatable_Kind, Anonymous_Access_Kind, Array_Kind, Assignable_Kind, @@ -131,6 +132,7 @@ package Gen_IL.Types is Composite_Kind, Concurrent_Kind, Concurrent_Body_Kind, + Constant_Or_Variable_Kind, Decimal_Fixed_Point_Kind, Digits_Kind, Discrete_Kind, @@ -158,6 +160,7 @@ package Gen_IL.Types is Protected_Kind, Real_Kind, Record_Kind, + Record_Field_Kind, Scalar_Kind, Subprogram_Kind, Signed_Integer_Kind, -- cgit v1.1 From d94afa43f7c21c9625fd636903f490cc474b444d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 7 Apr 2021 18:23:44 +0200 Subject: [Ada] Ignore again errors when running gen_il-main gcc/ada/ * Make-generated.in (ada/stamp-gen_il): Ignore errors from running gen_il-main. --- gcc/ada/Make-generated.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/Make-generated.in b/gcc/ada/Make-generated.in index 129909b..7d452b8 100644 --- a/gcc/ada/Make-generated.in +++ b/gcc/ada/Make-generated.in @@ -18,7 +18,9 @@ GEN_IL_FLAGS = -gnata -gnat2012 -gnatw.g -gnatyg -gnatU $(GEN_IL_INCLUDES) ada/seinfo_tables.ads ada/seinfo_tables.adb ada/sinfo.h ada/einfo.h ada/nmake.ads ada/nmake.adb ada/seinfo.ads ada/sinfo-nodes.ads ada/sinfo-nodes.adb ada/einfo-entities.ads ada/einfo-entities.adb: ada/stamp-gen_il ; @true ada/stamp-gen_il: $(fsrcdir)/ada/gen_il* $(MKDIR) ada/gen_il - cd ada/gen_il ; gnatmake -q -g $(GEN_IL_FLAGS) gen_il-main ; ./gen_il-main + cd ada/gen_il; gnatmake -q -g $(GEN_IL_FLAGS) gen_il-main + # Ignore errors to work around finalization issues in older compilers + - cd ada/gen_il; ./gen_il-main $(fsrcdir)/../move-if-change ada/gen_il/seinfo_tables.ads ada/seinfo_tables.ads $(fsrcdir)/../move-if-change ada/gen_il/seinfo_tables.adb ada/seinfo_tables.adb $(fsrcdir)/../move-if-change ada/gen_il/sinfo.h ada/sinfo.h -- cgit v1.1 From d23455ce238122c20c4fa81fa55eeb9ad1d938ee Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 6 Apr 2021 13:10:40 +0200 Subject: [Ada] Rewrite Validated_View in recursive style gcc/ada/ * sem_util.ads (Validated_View): Fix style in comment. * sem_util.adb (Validated_View): Rewrite in recursive style. --- gcc/ada/sem_util.adb | 44 +++++++++++++++++++------------------------- gcc/ada/sem_util.ads | 2 +- 2 files changed, 20 insertions(+), 26 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 479bb14..169825e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -29471,42 +29471,36 @@ package body Sem_Util is -------------------- function Validated_View (Typ : Entity_Id) return Entity_Id is - Continue : Boolean; - Val_Typ : Entity_Id; - begin - Continue := True; - Val_Typ := Base_Type (Typ); - -- Obtain the full view of the input type by stripping away concurrency, -- derivations, and privacy. - while Continue loop - Continue := False; - - if Is_Concurrent_Type (Val_Typ) then - if Present (Corresponding_Record_Type (Val_Typ)) then - Continue := True; - Val_Typ := Corresponding_Record_Type (Val_Typ); + if Is_Base_Type (Typ) then + if Is_Concurrent_Type (Typ) then + if Present (Corresponding_Record_Type (Typ)) then + return Corresponding_Record_Type (Typ); + else + return Typ; end if; - elsif Is_Derived_Type (Val_Typ) then - Continue := True; - Val_Typ := Etype (Val_Typ); + elsif Is_Derived_Type (Typ) then + return Validated_View (Etype (Typ)); - elsif Is_Private_Type (Val_Typ) then - if Present (Underlying_Full_View (Val_Typ)) then - Continue := True; - Val_Typ := Underlying_Full_View (Val_Typ); + elsif Is_Private_Type (Typ) then + if Present (Underlying_Full_View (Typ)) then + return Validated_View (Underlying_Full_View (Typ)); - elsif Present (Full_View (Val_Typ)) then - Continue := True; - Val_Typ := Full_View (Val_Typ); + elsif Present (Full_View (Typ)) then + return Validated_View (Full_View (Typ)); + else + return Typ; end if; end if; - end loop; - return Val_Typ; + return Typ; + else + return Validated_View (Base_Type (Typ)); + end if; end Validated_View; ----------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index a1ed43c..f9db80e 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -3290,7 +3290,7 @@ package Sem_Util is function Validated_View (Typ : Entity_Id) return Entity_Id; -- Obtain the "validated view" of arbitrary type Typ which is suitable for - -- verification by attributes 'Valid_Scalars. This view is the type itself + -- verification by attribute 'Valid_Scalars. This view is the type itself -- or its full view while stripping away concurrency, derivations, and -- privacy. -- cgit v1.1 From 0bc7cf47c1266f9ae510c70833b5691c693c769f Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Wed, 7 Apr 2021 09:05:06 +0200 Subject: [Ada] Add some OS constants to control keepalive on TCP connections gcc/ada/ * s-oscons-tmplt.c: Add some OS constants. --- gcc/ada/s-oscons-tmplt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc') diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 25a4df0..d42e663 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -1501,6 +1501,21 @@ CNS(MSG_Forced_Flags, "") #endif CND(TCP_NODELAY, "Do not coalesce packets") +#ifndef TCP_KEEPCNT +# define TCP_KEEPCNT -1 +#endif +CND(TCP_KEEPCNT, "Maximum number of keepalive probes") + +#ifndef TCP_KEEPIDLE +# define TCP_KEEPIDLE -1 +#endif +CND(TCP_KEEPIDLE, "Idle time before TCP starts sending keepalive probes") + +#ifndef TCP_KEEPINTVL +# define TCP_KEEPINTVL -1 +#endif +CND(TCP_KEEPINTVL, "Time between individual keepalive probes") + #ifndef SO_REUSEADDR # define SO_REUSEADDR -1 #endif -- cgit v1.1 From b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Fri, 9 Apr 2021 08:56:23 -0400 Subject: [Ada] tech debt: clean up Component_Size gcc/ada/ * einfo.ads (Component_Bit_Offset, Component_Size): Update documentation: Repinfo is the package where these negative values are documented. * einfo-utils.adb (Known_Component_Size, Known_Static_Component_Size, Unknown_Component_Size): Remove calls to Implementation_Base_Type, because Component_Size is an Impl_Base_Type_Only field (see Gen_Entities). * sem_ch13.ads, sem_ch13.adb (Check_Size): Do not set Esize and RM_Size. This is unnecessary in the case of Size. For Component_Size, it is wrong, because we would be setting the Esize and RM_Size of the component type. --- gcc/ada/einfo-utils.adb | 10 ++++------ gcc/ada/einfo.ads | 7 ++++--- gcc/ada/sem_ch13.adb | 4 ---- gcc/ada/sem_ch13.ads | 3 +-- 4 files changed, 9 insertions(+), 15 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 0641862..02ccef1 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -515,8 +515,8 @@ package body Einfo.Utils is function Known_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) /= Uint_0 - and then Component_Size (Implementation_Base_Type (E)) /= No_Uint; + return Component_Size (E) /= Uint_0 + and then Component_Size (E) /= No_Uint; end Known_Component_Size; function Known_Esize (E : Entity_Id) return B is @@ -556,7 +556,7 @@ package body Einfo.Utils is function Known_Static_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) > Uint_0; + return Component_Size (E) > Uint_0; end Known_Static_Component_Size; function Known_Static_Esize (E : Entity_Id) return B is @@ -604,9 +604,7 @@ package body Einfo.Utils is function Unknown_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) = Uint_0 - or else - Component_Size (Implementation_Base_Type (E)) = No_Uint; + return not Known_Component_Size (E); end Unknown_Component_Size; function Unknown_Esize (E : Entity_Id) return B is diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 4c5a2da..5298998 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -669,7 +669,7 @@ package Einfo is -- this field is always set. A negative value is used to represent -- a value which is not known at compile time, and must be computed -- at run-time (this happens if fields of a record have variable --- lengths). See package Layout for details of these values. +-- lengths). See package Repinfo for details of these values. -- -- Note: Component_Bit_Offset is redundant with respect to the fields -- Normalized_First_Bit and Normalized_Position, and could in principle @@ -691,8 +691,9 @@ package Einfo is -- by the front end in package Layout, or by the backend. A negative -- value is used to represent a value which is not known at compile -- time, and must be computed at run-time (this happens if the type --- of the component has a variable length size). See package Layout --- for details of these values. +-- of the component has a variable length size). See package Repinfo +-- for details of these values. Component_Size can also be negative in +-- an illegal program that says e.g. "for T'Component_Size use -8;". -- Component_Type [implementation base type only] -- Defined in array types and string types. References component type. diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index cfcbe14..76dac2c 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -12479,8 +12479,6 @@ package body Sem_Ch13 is else Size_Too_Small_Error (Asiz); - Set_Esize (T, Asiz); - Set_RM_Size (T, Asiz); end if; end; @@ -12518,8 +12516,6 @@ package body Sem_Ch13 is if Siz < M then Size_Too_Small_Error (M); - Set_Esize (T, M); - Set_RM_Size (T, M); else Biased := True; end if; diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads index 3869f92..7579812 100644 --- a/gcc/ada/sem_ch13.ads +++ b/gcc/ada/sem_ch13.ads @@ -125,8 +125,7 @@ package Sem_Ch13 is -- set if the type is not currently biased, but biasing it is the only -- way to meet the requirement. If the type is currently biased, then -- this biased size is used in the initial check, and Biased is False. - -- If the size is too small, and an error message is given, then both - -- Esize and RM_Size are reset to the allowed minimum value in T. + -- For a Component_Size clause, T is the component type. function Has_Compatible_Representation (Target_Type, Operand_Type : Entity_Id) return Boolean; -- cgit v1.1 From 1a9d13fff60c845a258d1e6607d42290db45e5e7 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 9 Apr 2021 13:29:44 +0200 Subject: [Ada] Further adjustment and optimization of System.Value_N gcc/ada/ * rtsfind.ads (RE_Id): Change RE_Valid_Enumeration_Value_NN into RE_Valid_Value_Enumeration_NN. (RE_Unit_Table): Adjust to above renaming. * exp_imgv.adb (Expand_Valid_Value_Attribute): Likewise. * libgnat/s-valuen.ads (Invalid): Remove. (Value_Enumeration_Pos): Move to... * libgnat/s-valuen.adb (Value_Enumeration_Pos): ...here. Return -1 instead of Invalid. (Value_Enumeration): Compare against 0 instead of Invalid. (Valid_Enumeration_Value): Likewise. Rename to... (Valid_Value_Enumeration): ...this. * libgnat/s-vaenu8.ads (Valid_Enumeration_Value_8): Rename into... (Valid_Value_Enumeration_8): ...this. * libgnat/s-vaen16.ads (Valid_Enumeration_Value_16): Rename into... (Valid_Value_Enumeration_16): ...this. * libgnat/s-vaen32.ads (Valid_Enumeration_Value_32): Rename into... (Valid_Value_Enumeration_32): ...this. --- gcc/ada/exp_imgv.adb | 8 ++++---- gcc/ada/libgnat/s-vaen16.ads | 4 ++-- gcc/ada/libgnat/s-vaen32.ads | 4 ++-- gcc/ada/libgnat/s-vaenu8.ads | 4 ++-- gcc/ada/libgnat/s-valuen.adb | 49 ++++++++++++++++++++++++++++---------------- gcc/ada/libgnat/s-valuen.ads | 14 +------------ gcc/ada/rtsfind.ads | 12 +++++------ 7 files changed, 48 insertions(+), 47 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb index 38ee11e..6e17a5c 100644 --- a/gcc/ada/exp_imgv.adb +++ b/gcc/ada/exp_imgv.adb @@ -1439,17 +1439,17 @@ package body Exp_Imgv is begin -- Generate: - -- Valid_Enumeration_Value _NN + -- Valid_Value_Enumeration_NN -- (typS, typN'Address, typH'Unrestricted_Access, Num, X) Ttyp := Component_Type (Etype (Lit_Indexes (Rtyp))); if Ttyp = Standard_Integer_8 then - Func := RE_Valid_Enumeration_Value_8; + Func := RE_Valid_Value_Enumeration_8; elsif Ttyp = Standard_Integer_16 then - Func := RE_Valid_Enumeration_Value_16; + Func := RE_Valid_Value_Enumeration_16; else - Func := RE_Valid_Enumeration_Value_32; + Func := RE_Valid_Value_Enumeration_32; end if; Prepend_To (Args, diff --git a/gcc/ada/libgnat/s-vaen16.ads b/gcc/ada/libgnat/s-vaen16.ads index 86cdaa1..6ea6071 100644 --- a/gcc/ada/libgnat/s-vaen16.ads +++ b/gcc/ada/libgnat/s-vaen16.ads @@ -49,13 +49,13 @@ package System.Val_Enum_16 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_16 + function Valid_Value_Enumeration_16 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_16; diff --git a/gcc/ada/libgnat/s-vaen32.ads b/gcc/ada/libgnat/s-vaen32.ads index 0dead07..e1a7644 100644 --- a/gcc/ada/libgnat/s-vaen32.ads +++ b/gcc/ada/libgnat/s-vaen32.ads @@ -49,13 +49,13 @@ package System.Val_Enum_32 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_32 + function Valid_Value_Enumeration_32 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_32; diff --git a/gcc/ada/libgnat/s-vaenu8.ads b/gcc/ada/libgnat/s-vaenu8.ads index db0b360..395a969 100644 --- a/gcc/ada/libgnat/s-vaenu8.ads +++ b/gcc/ada/libgnat/s-vaenu8.ads @@ -49,13 +49,13 @@ package System.Val_Enum_8 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_8 + function Valid_Value_Enumeration_8 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_8; diff --git a/gcc/ada/libgnat/s-valuen.adb b/gcc/ada/libgnat/s-valuen.adb index 7b72bc6..ef613a2 100644 --- a/gcc/ada/libgnat/s-valuen.adb +++ b/gcc/ada/libgnat/s-valuen.adb @@ -35,6 +35,16 @@ with System.Val_Util; use System.Val_Util; package body System.Value_N is + function Value_Enumeration_Pos + (Names : String; + Indexes : System.Address; + Hash : Hash_Function_Ptr; + Num : Natural; + Str : String) + return Integer with Pure_Function; + -- Same as Value_Enumeration, except returns negative if Value_Enumeration + -- would raise Constraint_Error. + --------------------------- -- Value_Enumeration_Pos -- --------------------------- @@ -98,9 +108,25 @@ package body System.Value_N is end if; end; - return Invalid; + return -1; end Value_Enumeration_Pos; + ----------------------------- + -- Valid_Value_Enumeration -- + ----------------------------- + + function Valid_Value_Enumeration + (Names : String; + Indexes : System.Address; + Hash : Hash_Function_Ptr; + Num : Natural; + Str : String) + return Boolean + is + begin + return Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str) >= 0; + end Valid_Value_Enumeration; + ----------------------- -- Value_Enumeration -- ----------------------- @@ -115,28 +141,15 @@ package body System.Value_N is is Result : constant Integer := Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str); + begin - if Result = Invalid then + -- The comparison eliminates the need for a range check on return + + if Result < 0 then Bad_Value (Str); else return Result; end if; end Value_Enumeration; - ----------------------------- - -- Valid_Enumeration_Value -- - ----------------------------- - - function Valid_Enumeration_Value - (Names : String; - Indexes : System.Address; - Hash : Hash_Function_Ptr; - Num : Natural; - Str : String) - return Boolean - is - begin - return Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str) /= Invalid; - end Valid_Enumeration_Value; - end System.Value_N; diff --git a/gcc/ada/libgnat/s-valuen.ads b/gcc/ada/libgnat/s-valuen.ads index 7ef0539..db8ad1d 100644 --- a/gcc/ada/libgnat/s-valuen.ads +++ b/gcc/ada/libgnat/s-valuen.ads @@ -67,7 +67,7 @@ package System.Value_N is -- If the image is found in Names, then the corresponding Pos value is -- returned. If not, Constraint_Error is raised. - function Valid_Enumeration_Value + function Valid_Value_Enumeration (Names : String; Indexes : System.Address; Hash : Hash_Function_Ptr; @@ -79,16 +79,4 @@ package System.Value_N is -- raise Constraint_Error. The parameters have the same meaning as for -- Value_Enumeration. - Invalid : constant Integer := -1; - - function Value_Enumeration_Pos - (Names : String; - Indexes : System.Address; - Hash : Hash_Function_Ptr; - Num : Natural; - Str : String) - return Integer with Pure_Function; - -- Same as Value_Enumeration, except returns Invalid if Value_Enumeration - -- would raise Constraint_Error. - end System.Value_N; diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads index df51477..ad84e9e 100644 --- a/gcc/ada/rtsfind.ads +++ b/gcc/ada/rtsfind.ads @@ -2040,9 +2040,9 @@ package Rtsfind is RE_Value_Enumeration_16, -- System.Val_Enum_16 RE_Value_Enumeration_32, -- System.Val_Enum_32 - RE_Valid_Enumeration_Value_8, -- System.Val_Enum_8 - RE_Valid_Enumeration_Value_16, -- System.Val_Enum_16 - RE_Valid_Enumeration_Value_32, -- System.Val_Enum_32 + RE_Valid_Value_Enumeration_8, -- System.Val_Enum_8 + RE_Valid_Value_Enumeration_16, -- System.Val_Enum_16 + RE_Valid_Value_Enumeration_32, -- System.Val_Enum_32 RE_Value_Fixed32, -- System_Val_Fixed_32 @@ -3731,11 +3731,11 @@ package Rtsfind is RE_Value_Enumeration_32 => System_Val_Enum_32, - RE_Valid_Enumeration_Value_8 => System_Val_Enum_8, + RE_Valid_Value_Enumeration_8 => System_Val_Enum_8, - RE_Valid_Enumeration_Value_16 => System_Val_Enum_16, + RE_Valid_Value_Enumeration_16 => System_Val_Enum_16, - RE_Valid_Enumeration_Value_32 => System_Val_Enum_32, + RE_Valid_Value_Enumeration_32 => System_Val_Enum_32, RE_Value_Fixed32 => System_Val_Fixed_32, -- cgit v1.1 From 568d3d4656c347012eb7dd2f008845505eab3ca8 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 10 Apr 2021 19:17:54 +0200 Subject: [Ada] Fix old typo in comment gcc/ada/ * repinfo-input.adb (Read_JSON_Stream): Fix typo. --- gcc/ada/repinfo-input.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/repinfo-input.adb b/gcc/ada/repinfo-input.adb index 6463563..106c43c 100644 --- a/gcc/ada/repinfo-input.adb +++ b/gcc/ada/repinfo-input.adb @@ -215,7 +215,7 @@ package body Repinfo.Input is J_COMMA, J_COLON, J_EOF); - -- JSON Token kind. Note that in ECMA 404 there is no notion of integer. + -- JSON token kind. Note that in ECMA 404 there is no notion of integer. -- Only numbers are supported. In our implementation we return J_INTEGER -- if there is no decimal part in the number. The semantic is that this -- is a J_NUMBER token that might be represented as an integer. Special -- cgit v1.1 From 898edf758e03a6cc31219405a667c75b67a726ca Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Fri, 9 Apr 2021 14:53:56 -0400 Subject: [Ada] tech debt: Parent (Empty) is not allowed gcc/ada/ * atree.adb, atree.ads (Parent, Set_Parent): Assert node is Present. (Copy_Parent, Parent_Kind): New helper routines. * gen_il-gen.adb: Add with clause. * nlists.adb (Parent): Assert Parent of list is Present. * aspects.adb, checks.adb, exp_aggr.adb, exp_ch6.adb, exp_util.adb, lib-xref-spark_specific.adb, osint.ads, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb, sem_dim.adb, sem_prag.adb, sem_res.adb, sem_util.adb, treepr.adb: Do not call Parent and Set_Parent on the Empty node. * libgnat/a-stwiun__shared.adb, libgnat/a-stzunb__shared.adb: Minor: Fix typos in comments. * einfo.ads: Minor comment update. * sinfo-utils.ads, sinfo-utils.adb (Parent_Kind, Copy_Parent): New functions. --- gcc/ada/aspects.adb | 5 +++++ gcc/ada/atree.adb | 18 +++++++++--------- gcc/ada/atree.ads | 14 +++++++------- gcc/ada/checks.adb | 4 ++++ gcc/ada/einfo.ads | 6 +++--- gcc/ada/exp_aggr.adb | 4 ++-- gcc/ada/exp_ch6.adb | 4 +++- gcc/ada/exp_util.adb | 6 ++++-- gcc/ada/gen_il-gen.adb | 1 + gcc/ada/lib-xref-spark_specific.adb | 4 ++++ gcc/ada/libgnat/a-stwiun__shared.adb | 2 +- gcc/ada/libgnat/a-stzunb__shared.adb | 2 +- gcc/ada/nlists.adb | 11 ++++++----- gcc/ada/osint.ads | 6 +++--- gcc/ada/sem_ch12.adb | 11 +++++++---- gcc/ada/sem_ch13.adb | 6 ++++-- gcc/ada/sem_ch3.adb | 8 ++++---- gcc/ada/sem_ch6.adb | 2 +- gcc/ada/sem_dim.adb | 20 ++++++++++++-------- gcc/ada/sem_prag.adb | 14 ++++++++++---- gcc/ada/sem_res.adb | 5 +++-- gcc/ada/sem_util.adb | 15 ++++++++------- gcc/ada/sinfo-utils.adb | 23 +++++++++++++++++++++++ gcc/ada/sinfo-utils.ads | 12 ++++++++++++ gcc/ada/treepr.adb | 2 +- 25 files changed, 138 insertions(+), 67 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb index 22ae9c4..a6e4f28 100644 --- a/gcc/ada/aspects.adb +++ b/gcc/ada/aspects.adb @@ -241,6 +241,10 @@ package body Aspects is -- find the declaration node where the aspects reside. This is usually -- the parent or the parent of the parent. + if No (Parent (Owner)) then + return Empty; + end if; + Decl := Parent (Owner); if not Permits_Aspect_Specifications (Decl) then Decl := Parent (Decl); @@ -488,6 +492,7 @@ package body Aspects is function Permits_Aspect_Specifications (N : Node_Id) return Boolean is begin + pragma Assert (Present (N)); return Has_Aspect_Specifications_Flag (Nkind (N)); end Permits_Aspect_Specifications; diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb index be03c97..33cde5a 100644 --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -1232,7 +1232,9 @@ package body Atree is if Field in Node_Range then New_N := Union_Id (Copy_Separate_Tree (Node_Id (Field))); - if Parent (Node_Id (Field)) = Source then + if Present (Node_Id (Field)) + and then Parent (Node_Id (Field)) = Source + then Set_Parent (Node_Id (New_N), New_Id); end if; @@ -1801,16 +1803,14 @@ package body Atree is end if; end Paren_Count; - ------------ - -- Parent -- - ------------ - - function Parent (N : Node_Id) return Node_Id is + function Parent (N : Node_Or_Entity_Id) return Node_Or_Entity_Id is begin + pragma Assert (Atree.Present (N)); + if Is_List_Member (N) then return Parent (List_Containing (N)); else - return Node_Id (Link (N)); + return Node_Or_Entity_Id (Link (N)); end if; end Parent; @@ -2126,9 +2126,9 @@ package body Atree is -- Set_Parent -- ---------------- - procedure Set_Parent (N : Node_Id; Val : Node_Id) is + procedure Set_Parent (N : Node_Or_Entity_Id; Val : Node_Or_Entity_Id) is begin - pragma Assert (not Locked); + pragma Assert (Atree.Present (N)); pragma Assert (not In_List (N)); Set_Link (N, Union_Id (Val)); end Set_Parent; diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads index 3522753..0995b94 100644 --- a/gcc/ada/atree.ads +++ b/gcc/ada/atree.ads @@ -414,34 +414,34 @@ package Atree is -- The following functions return the contents of the indicated field of -- the node referenced by the argument, which is a Node_Id. - function No (N : Node_Id) return Boolean; + function No (N : Node_Id) return Boolean; pragma Inline (No); -- Tests given Id for equality with the Empty node. This allows notations -- like "if No (Variant_Part)" as opposed to "if Variant_Part = Empty". - function Parent (N : Node_Id) return Node_Id; + function Parent (N : Node_Or_Entity_Id) return Node_Or_Entity_Id; pragma Inline (Parent); -- Returns the parent of a node if the node is not a list member, or else -- the parent of the list containing the node if the node is a list member. - function Paren_Count (N : Node_Id) return Nat; + function Paren_Count (N : Node_Id) return Nat; pragma Inline (Paren_Count); -- Number of parentheses that surround an expression - function Present (N : Node_Id) return Boolean; + function Present (N : Node_Id) return Boolean; pragma Inline (Present); -- Tests given Id for inequality with the Empty node. This allows notations -- like "if Present (Statement)" as opposed to "if Statement /= Empty". - procedure Set_Original_Node (N : Node_Id; Val : Node_Id); + procedure Set_Original_Node (N : Node_Id; Val : Node_Id); pragma Inline (Set_Original_Node); -- Note that this routine is used only in very peculiar cases. In normal -- cases, the Original_Node link is set by calls to Rewrite. - procedure Set_Parent (N : Node_Id; Val : Node_Id); + procedure Set_Parent (N : Node_Or_Entity_Id; Val : Node_Or_Entity_Id); pragma Inline (Set_Parent); - procedure Set_Paren_Count (N : Node_Id; Val : Nat); + procedure Set_Paren_Count (N : Node_Id; Val : Nat); pragma Inline (Set_Paren_Count); --------------------------- diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 907641f..1a39a82 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -2713,6 +2713,10 @@ package body Checks is Subp_Spec := Parent (Subp); + if No (Subp_Spec) then + return; + end if; + if Nkind (Subp_Spec) = N_Defining_Program_Unit_Name then Subp_Spec := Parent (Subp_Spec); end if; diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 5298998..70b93b3 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -5088,9 +5088,9 @@ package Einfo is -- Applicable attributes by entity kind -- ------------------------------------------ - -- In the conversion to variable-sized nodes and entities, which is an - -- ongoing project, a number of discrepancies were noticed. They are - -- documented in comments, and marked with "$$$". + -- In the conversion to variable-sized nodes and entities, a number of + -- discrepancies were noticed. They are documented in comments, and marked + -- with "$$$". -- E_Abstract_State -- Refinement_Constituents diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 2e772ed..85e2abb 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1920,7 +1920,7 @@ package body Exp_Aggr is function Gen_Loop (L, H : Node_Id; Expr : Node_Id) return List_Id is Is_Iterated_Component : constant Boolean := - Nkind (Parent (Expr)) = N_Iterated_Component_Association; + Parent_Kind (Expr) = N_Iterated_Component_Association; L_J : Node_Id; @@ -2436,7 +2436,7 @@ package body Exp_Aggr is Expr := Get_Assoc_Expr (Others_Assoc); Dup_Expr := New_Copy_Tree (Expr); - Set_Parent (Dup_Expr, Parent (Expr)); + Copy_Parent (To => Dup_Expr, From => Expr); Set_Loop_Actions (Others_Assoc, New_List); Append_List diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index cd972e1..b81216f 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3589,7 +3589,9 @@ package body Exp_Ch6 is Ren_Root := Alias (Ren_Root); end if; - if Present (Original_Node (Parent (Parent (Ren_Root)))) then + if Present (Parent (Ren_Root)) + and then Present (Original_Node (Parent (Parent (Ren_Root)))) + then Ren_Decl := Original_Node (Parent (Parent (Ren_Root))); if Nkind (Ren_Decl) = N_Subprogram_Renaming_Declaration then diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index d02e587..270242d 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -12277,7 +12277,9 @@ package body Exp_Util is -- Local variables - Context : constant Node_Id := Parent (Ref); + Context : constant Node_Id := + (if No (Ref) then Empty else Parent (Ref)); + Loc : constant Source_Ptr := Sloc (Ref); Ref_Id : Entity_Id; Result : Traverse_Result; @@ -13493,7 +13495,7 @@ package body Exp_Util is -- modification of that variable within the loop may incorrectly -- affect the execution of the loop. - elsif Nkind (Parent (Parent (N))) = N_Loop_Parameter_Specification + elsif Parent_Kind (Parent (N)) = N_Loop_Parameter_Specification and then Within_In_Parameter (Prefix (N)) and then Variable_Ref then diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb index 6a61117..0f3698e 100644 --- a/gcc/ada/gen_il-gen.adb +++ b/gcc/ada/gen_il-gen.adb @@ -2329,6 +2329,7 @@ package body Gen_IL.Gen is Put (B, "with Nlists; use Nlists;" & LF); Put (B, "pragma Warnings (Off);" & LF); Put (B, "with Einfo.Utils; use Einfo.Utils;" & LF); + Put (B, "with Sinfo.Utils; use Sinfo.Utils;" & LF); Put (B, "pragma Warnings (On);" & LF); Put (B, LF & "package body Sinfo.Nodes is" & LF & LF); diff --git a/gcc/ada/lib-xref-spark_specific.adb b/gcc/ada/lib-xref-spark_specific.adb index 723b7a8..1905f23 100644 --- a/gcc/ada/lib-xref-spark_specific.adb +++ b/gcc/ada/lib-xref-spark_specific.adb @@ -187,6 +187,10 @@ package body SPARK_Specific is | Generic_Subprogram_Kind | Subprogram_Kind then + if No (Unit_Declaration_Node (N)) then + return Empty; + end if; + Context := Parent (Unit_Declaration_Node (N)); -- If this was a library-level subprogram then replace Context with diff --git a/gcc/ada/libgnat/a-stwiun__shared.adb b/gcc/ada/libgnat/a-stwiun__shared.adb index f293684..1d0521c 100644 --- a/gcc/ada/libgnat/a-stwiun__shared.adb +++ b/gcc/ada/libgnat/a-stwiun__shared.adb @@ -76,7 +76,7 @@ package body Ada.Strings.Wide_Unbounded is Reference (Empty_Shared_Wide_String'Access); DR := Empty_Shared_Wide_String'Access; - -- Left string is empty, return Rigth string + -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); diff --git a/gcc/ada/libgnat/a-stzunb__shared.adb b/gcc/ada/libgnat/a-stzunb__shared.adb index 17d27d6..99a545e 100644 --- a/gcc/ada/libgnat/a-stzunb__shared.adb +++ b/gcc/ada/libgnat/a-stzunb__shared.adb @@ -76,7 +76,7 @@ package body Ada.Strings.Wide_Wide_Unbounded is Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; - -- Left string is empty, return Rigth string + -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); diff --git a/gcc/ada/nlists.adb b/gcc/ada/nlists.adb index 821c0ab..7339c17 100644 --- a/gcc/ada/nlists.adb +++ b/gcc/ada/nlists.adb @@ -27,11 +27,11 @@ -- file must be properly reflected in the corresponding C header a-nlists.h with Alloc; -with Atree; use Atree; -with Debug; use Debug; -with Output; use Output; -with Sinfo; use Sinfo; -with Sinfo.Nodes; use Sinfo.Nodes; +with Atree; use Atree; +with Debug; use Debug; +with Output; use Output; +with Sinfo; use Sinfo; +with Sinfo.Nodes; use Sinfo.Nodes; with Table; package body Nlists is @@ -1015,6 +1015,7 @@ package body Nlists is function Parent (List : List_Id) return Node_Or_Entity_Id is begin + pragma Assert (Present (List)); pragma Assert (List <= Lists.Last); return Lists.Table (List).Parent; end Parent; diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index f481812..f1a9f84 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -716,9 +716,9 @@ private File_Names : File_Name_Array_Ptr := new File_Name_Array (1 .. Int (Argument_Count) + 2); -- As arguments are scanned, file names are stored in this array. The - -- strings do not have terminating NUL files. The array is extensible, - -- because when using project files, there may be more files than - -- arguments on the command line. + -- strings do not have terminating NULs. The array is extensible, because + -- when using project files, there may be more files than arguments on the + -- command line. type File_Index_Array is array (Int range <>) of Int; type File_Index_Array_Ptr is access File_Index_Array; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 9ccc5c5..893854d 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -11258,7 +11258,8 @@ package body Sem_Ch12 is A_Gen_Obj : constant Entity_Id := Defining_Identifier (Analyzed_Formal); Acc_Def : Node_Id := Empty; - Act_Assoc : constant Node_Id := Parent (Actual); + Act_Assoc : constant Node_Id := + (if No (Actual) then Empty else Parent (Actual)); Actual_Decl : Node_Id := Empty; Decl_Node : Node_Id; Def : Node_Id; @@ -11289,7 +11290,7 @@ package body Sem_Ch12 is Error_Msg_N ("duplicate instantiation of generic parameter", Actual); end if; - Set_Parent (List, Parent (Actual)); + Set_Parent (List, Act_Assoc); -- OUT present @@ -11654,7 +11655,9 @@ package body Sem_Ch12 is end if; end if; - if Nkind (Actual) in N_Has_Entity then + if Nkind (Actual) in N_Has_Entity + and then Present (Entity (Actual)) + then Actual_Decl := Parent (Entity (Actual)); end if; @@ -16339,7 +16342,7 @@ package body Sem_Ch12 is -- global in the current generic it must be preserved for its -- instantiation. - if Nkind (Parent (Typ)) = N_Subtype_Declaration + if Parent_Kind (Typ) = N_Subtype_Declaration and then Present (Generic_Parent_Type (Parent (Typ))) then Typ := Base_Type (Typ); diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 76dac2c..d7667f2 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -10652,7 +10652,7 @@ package body Sem_Ch13 is -- in particular, it has no type. Err : Boolean; - -- Set False if error + -- Set True if error -- On entry to this procedure, Entity (Ident) contains a copy of the -- original expression from the aspect, saved for this purpose, and @@ -10786,7 +10786,9 @@ package body Sem_Ch13 is -- Indicate that the expression comes from an aspect specification, -- which is used in subsequent analysis even if expansion is off. - Set_Parent (End_Decl_Expr, ASN); + if Present (End_Decl_Expr) then + Set_Parent (End_Decl_Expr, ASN); + end if; -- In a generic context the original aspect expressions have not -- been preanalyzed, so do it now. There are no conformance checks diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 594e08e..98cbef4 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6189,7 +6189,7 @@ package body Sem_Ch3 is -- the master_id associated with an anonymous access to task type -- component (see Expand_N_Full_Type_Declaration.Build_Master) - Set_Parent (Element_Type, Parent (T)); + Copy_Parent (To => Element_Type, From => T); -- Ada 2005 (AI-230): In case of components that are anonymous access -- types the level of accessibility depends on the enclosing type @@ -10361,7 +10361,7 @@ package body Sem_Ch3 is if Discrim_Present then null; - elsif Nkind (Parent (Parent (Def))) = N_Component_Declaration + elsif Parent_Kind (Parent (Def)) = N_Component_Declaration and then Has_Per_Object_Constraint (Defining_Identifier (Parent (Parent (Def)))) then @@ -22391,10 +22391,10 @@ package body Sem_Ch3 is Final_Storage_Only := not Is_Controlled (T); - -- Ada 2005: Check whether an explicit Limited is present in a derived + -- Ada 2005: Check whether an explicit "limited" is present in a derived -- type declaration. - if Nkind (Parent (Def)) = N_Derived_Type_Definition + if Parent_Kind (Def) = N_Derived_Type_Definition and then Limited_Present (Parent (Def)) then Set_Is_Limited_Record (T); diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index d37f295..7b4b288 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -11709,7 +11709,7 @@ package body Sem_Ch6 is if Inside_Freezing_Actions = 0 and then Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) - and then Nkind (Parent (E)) = N_Private_Extension_Declaration + and then Parent_Kind (E) = N_Private_Extension_Declaration and then Nkind (Parent (S)) = N_Full_Type_Declaration and then Full_View (Defining_Identifier (Parent (E))) = Defining_Identifier (Parent (S)) diff --git a/gcc/ada/sem_dim.adb b/gcc/ada/sem_dim.adb index a52b58a..b303229 100644 --- a/gcc/ada/sem_dim.adb +++ b/gcc/ada/sem_dim.adb @@ -3765,16 +3765,20 @@ package body Sem_Dim is --------------- function System_Of (E : Entity_Id) return System_Type is - Type_Decl : constant Node_Id := Parent (E); - begin - -- Look for Type_Decl in System_Table + if Present (E) then + declare + Type_Decl : constant Node_Id := Parent (E); + begin + -- Look for Type_Decl in System_Table - for Dim_Sys in 1 .. System_Table.Last loop - if Type_Decl = System_Table.Table (Dim_Sys).Type_Decl then - return System_Table.Table (Dim_Sys); - end if; - end loop; + for Dim_Sys in 1 .. System_Table.Last loop + if Type_Decl = System_Table.Table (Dim_Sys).Type_Decl then + return System_Table.Table (Dim_Sys); + end if; + end loop; + end; + end if; return Null_System; end System_Of; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index ea0a5bb..14351b3 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -9257,7 +9257,9 @@ package body Sem_Prag is -- just the same scope). If the pragma comes from an aspect -- specification we know that it is part of the declaration. - elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N) + elsif (No (Unit_Declaration_Node (Def_Id)) + or else Parent (Unit_Declaration_Node (Def_Id)) /= + Parent (N)) and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux and then not From_Aspect_Specification (N) then @@ -9848,7 +9850,7 @@ package body Sem_Prag is -- inlineable either. elsif Is_Generic_Instance (Subp) - or else Nkind (Parent (Parent (Subp))) = N_Subprogram_Declaration + or else Parent_Kind (Parent (Subp)) = N_Subprogram_Declaration then null; @@ -9894,7 +9896,11 @@ package body Sem_Prag is if In_Same_Source_Unit (Subp, Inner_Subp) then Set_Inline_Flags (Inner_Subp); - Decl := Parent (Parent (Inner_Subp)); + if Present (Parent (Inner_Subp)) then + Decl := Parent (Parent (Inner_Subp)); + else + Decl := Empty; + end if; if Nkind (Decl) = N_Subprogram_Declaration and then Present (Corresponding_Body (Decl)) @@ -30892,7 +30898,7 @@ package body Sem_Prag is -- Follow subprogram renaming chain if Is_Subprogram (Def_Id) - and then Nkind (Parent (Declaration_Node (Def_Id))) = + and then Parent_Kind (Declaration_Node (Def_Id)) = N_Subprogram_Renaming_Declaration and then Present (Alias (Def_Id)) then diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index be09453..e639fab 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -9162,8 +9162,9 @@ package body Sem_Res is return; end if; - if Nkind (Parent (N)) = N_Indexed_Component - or else Nkind (Parent (Parent (N))) = N_Indexed_Component + if Present (Parent (N)) + and then (Nkind (Parent (N)) = N_Indexed_Component + or else Nkind (Parent (Parent (N))) = N_Indexed_Component) then Result_Type := Base_Type (Typ); end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 169825e..8a4a98b 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2027,7 +2027,7 @@ package body Sem_Util is -- the original constraint from its component declaration. Sel := Entity (Selector_Name (N)); - if Nkind (Parent (Sel)) /= N_Component_Declaration then + if Parent_Kind (Sel) /= N_Component_Declaration then return Empty; end if; end if; @@ -6366,8 +6366,8 @@ package body Sem_Util is Is_Type_In_Pkg := Is_Package_Or_Generic_Package (B_Scope) and then - Nkind (Parent (Declaration_Node (First_Subtype (T)))) /= - N_Package_Body; + Parent_Kind (Declaration_Node (First_Subtype (T))) /= + N_Package_Body; while Present (Id) loop @@ -6385,8 +6385,8 @@ package body Sem_Util is and then (Is_Type_In_Pkg or else Is_Derived_Type (B_Type) or else Is_Primitive (Id)) - and then Nkind (Parent (Parent (Id))) - not in N_Formal_Subprogram_Declaration + and then Parent_Kind (Parent (Id)) + not in N_Formal_Subprogram_Declaration then Is_Prim := False; @@ -20042,7 +20042,8 @@ package body Sem_Util is function Is_Renamed_Entry (Proc_Nam : Entity_Id) return Boolean is Orig_Node : Node_Id := Empty; - Subp_Decl : Node_Id := Parent (Parent (Proc_Nam)); + Subp_Decl : Node_Id := + (if No (Parent (Proc_Nam)) then Empty else Parent (Parent (Proc_Nam))); function Is_Entry (Nam : Node_Id) return Boolean; -- Determine whether Nam is an entry. Traverse selectors if there are @@ -27072,7 +27073,7 @@ package body Sem_Util is -- or an exception handler). We skip this if Cond is True, since the -- capturing of values from conditional tests handles this ok. - if Cond then + if Cond or else No (N) then return True; end if; diff --git a/gcc/ada/sinfo-utils.adb b/gcc/ada/sinfo-utils.adb index f9db669..7f9bb89 100644 --- a/gcc/ada/sinfo-utils.adb +++ b/gcc/ada/sinfo-utils.adb @@ -137,6 +137,29 @@ package body Sinfo.Utils is Write_Eol; end Node_Debug_Output; + ------------------------------- + -- Parent-related operations -- + ------------------------------- + + procedure Copy_Parent (To, From : Node_Or_Entity_Id) is + begin + if Atree.Present (To) and Atree.Present (From) then + Atree.Set_Parent (To, Atree.Parent (From)); + else + pragma Assert + (if Atree.Present (To) then Atree.No (Atree.Parent (To))); + end if; + end Copy_Parent; + + function Parent_Kind (N : Node_Id) return Node_Kind is + begin + if Atree.No (N) then + return N_Empty; + else + return Nkind (Atree.Parent (N)); + end if; + end Parent_Kind; + ------------------------- -- Iterator Procedures -- ------------------------- diff --git a/gcc/ada/sinfo-utils.ads b/gcc/ada/sinfo-utils.ads index ab8e528..2023e67 100644 --- a/gcc/ada/sinfo-utils.ads +++ b/gcc/ada/sinfo-utils.ads @@ -27,6 +27,18 @@ with Sinfo.Nodes; use Sinfo.Nodes; package Sinfo.Utils is + ------------------------------- + -- Parent-related operations -- + ------------------------------- + + procedure Copy_Parent (To, From : Node_Or_Entity_Id); + -- Does Set_Parent (To, Parent (From)), except that if To or From are + -- empty, does nothing. If From is empty but To is not, then Parent (To) + -- should already be Empty. + + function Parent_Kind (N : Node_Id) return Node_Kind; + -- Same as Nkind (Parent (N)), except if N is Empty, return N_Empty + ------------------------- -- Iterator Procedures -- ------------------------- diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index 519242e..ff4ff84 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -412,7 +412,7 @@ package body Treepr is return Nlists.Parent (List_Id (N)); when Node_Range => - return Atree.Parent (Node_Or_Entity_Id (N)); + return Parent (Node_Or_Entity_Id (N)); when others => Write_Int (Int (N)); -- cgit v1.1 From 7aaf662001871e1c3a87fdd9b662329c6a2e8d60 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 8 Apr 2021 09:42:28 +0200 Subject: [Ada] Accept arrays and scalars as type views that can be validated gcc/ada/ * exp_attr.adb (Build_Array_VS_Func): Restore uses of Validated_View. (Build_Record_VS_Func): Likewise. (Expand_N_Attribute_Reference): Likewise. * sem_util.adb (Validated_View): Behave as an identity function for arrays and scalars. --- gcc/ada/exp_attr.adb | 8 ++++---- gcc/ada/sem_util.adb | 57 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 23 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index d19ae1f..2e1cb85 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -248,7 +248,7 @@ package body Exp_Attr is is Loc : constant Source_Ptr := Sloc (Attr); Comp_Typ : constant Entity_Id := - Get_Fullest_View (Component_Type (Array_Typ)); + Validated_View (Component_Type (Array_Typ)); function Validate_Component (Obj_Id : Entity_Id; @@ -535,7 +535,7 @@ package body Exp_Attr is is Field_Id : constant Entity_Id := Defining_Entity (Field); Field_Nam : constant Name_Id := Chars (Field_Id); - Field_Typ : constant Entity_Id := Get_Fullest_View (Etype (Field_Id)); + Field_Typ : constant Entity_Id := Validated_View (Etype (Field_Id)); Attr_Nam : Name_Id; begin @@ -7396,7 +7396,7 @@ package body Exp_Attr is ------------------- when Attribute_Valid_Scalars => Valid_Scalars : declare - Val_Typ : constant Entity_Id := Get_Fullest_View (Ptyp); + Val_Typ : constant Entity_Id := Validated_View (Ptyp); Expr : Node_Id; begin @@ -7460,7 +7460,7 @@ package body Exp_Attr is (Build_Record_VS_Func (Attr => N, Formal_Typ => Ptyp, - Rec_Typ => Validated_View (Ptyp)), + Rec_Typ => Val_Typ), Loc), Parameter_Associations => New_List (Pref)); end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 8a4a98b..f723781 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -29473,34 +29473,53 @@ package body Sem_Util is function Validated_View (Typ : Entity_Id) return Entity_Id is begin + -- Scalar types can be always validated. In fast, switiching to the base + -- type would drop the range constraints and force validation to use a + -- larger type than necessary. + + if Is_Scalar_Type (Typ) then + return Typ; + + -- Array types can be validated even when they are derived, because + -- validation only requires their bounds and component types to be + -- accessible. In fact, switching to the parent type would pollute + -- expansion of attribute Valid_Scalars with unnecessary conversion + -- that might not be eliminated by the frontend. + + elsif Is_Array_Type (Typ) then + return Typ; + + -- For other types, in particular for record subtypes, we switch to the + -- base type. + + elsif not Is_Base_Type (Typ) then + return Validated_View (Base_Type (Typ)); + -- Obtain the full view of the input type by stripping away concurrency, -- derivations, and privacy. - if Is_Base_Type (Typ) then - if Is_Concurrent_Type (Typ) then - if Present (Corresponding_Record_Type (Typ)) then - return Corresponding_Record_Type (Typ); - else - return Typ; - end if; + elsif Is_Concurrent_Type (Typ) then + if Present (Corresponding_Record_Type (Typ)) then + return Corresponding_Record_Type (Typ); + else + return Typ; + end if; - elsif Is_Derived_Type (Typ) then - return Validated_View (Etype (Typ)); + elsif Is_Derived_Type (Typ) then + return Validated_View (Etype (Typ)); - elsif Is_Private_Type (Typ) then - if Present (Underlying_Full_View (Typ)) then - return Validated_View (Underlying_Full_View (Typ)); + elsif Is_Private_Type (Typ) then + if Present (Underlying_Full_View (Typ)) then + return Validated_View (Underlying_Full_View (Typ)); - elsif Present (Full_View (Typ)) then - return Validated_View (Full_View (Typ)); - else - return Typ; - end if; + elsif Present (Full_View (Typ)) then + return Validated_View (Full_View (Typ)); + else + return Typ; end if; - return Typ; else - return Validated_View (Base_Type (Typ)); + return Typ; end if; end Validated_View; -- cgit v1.1 From 430d508058bfe1c88c582a2256ff4dc3854c369d Mon Sep 17 00:00:00 2001 From: Doug Rupp Date: Wed, 31 Mar 2021 10:29:37 -0700 Subject: [Ada] vx7-shared-libs - x86_64-vx7r2 (gnat runtime) gcc/ada/ * Makefile.rtl: Add a new ifeq for vx7r2 shared gnatlib. --- gcc/ada/Makefile.rtl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index f626c5d..0b84612 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1200,13 +1200,6 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks vxworksspe vxworks7% vxworks7spe GCC_SPEC_FILES+=vxworks-cert-$(ARCH_STR)-link.spec GCC_SPEC_FILES+=vxworks-smp-$(ARCH_STR)-link.spec endif - - ifeq ($(strip $(filter-out vxworks7r2 powerpc64 rtp rtp-smp, $(target_os) $(target_cpu) $(THREAD_KIND))),) - # Shared libraries are only supported on PowerPC64, VxWorks7r2 - # ATM. Also this is disabled for kernel runtimes. - GNATLIB_SHARED = gnatlib-shared-dual - LIBRARY_VERSION := $(LIB_VERSION) - endif endif # PowerPC and e500v2 VxWorks 653 @@ -2973,6 +2966,13 @@ ifeq ($(strip $(filter-out linux%,$(target_os))),) g-sercom.adb Date: Mon, 12 Apr 2021 17:20:33 -0400 Subject: [Ada] Overriding errors on renamings and instances overriding predefined operators gcc/ada/ * sem_ch6.ads (Can_Override_Operator): Function declaration moved from package body to package spec. * sem_ch6.adb (Check_Overriding_Indicator): Now use test of whether the subprogram's Chars is an operator name, to handle cases of function instances whose entity is N_Defining_Identifier rather than N_Defining_Operator_Symbol. (Can_Override_Operator): Function declaration moved to package spec. Now use test of whether the subprogram's Chars is an operator name, to handle cases of function instances whose entity is N_Defining_Identifier rather than N_Defining_Operator_Symbol. * sem_ch8.adb (Analyze_Renamed_Subprogram): Check for possibility of an overridden predefined operator, and suppress the "not overriding" message in that case. --- gcc/ada/sem_ch6.adb | 12 +++++++----- gcc/ada/sem_ch6.ads | 3 +++ gcc/ada/sem_ch8.adb | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 7b4b288..c361acc 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -132,9 +132,6 @@ package body Sem_Ch6 is -- Does all the real work of Analyze_Subprogram_Body. This is split out so -- that we can use RETURN but not skip the debug output at the end. - function Can_Override_Operator (Subp : Entity_Id) return Boolean; - -- Returns true if Subp can override a predefined operator. - procedure Check_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; @@ -7321,7 +7318,7 @@ package body Sem_Ch6 is -- predefined signature, because we know already that there is no -- explicit overridden operation. - elsif Nkind (Subp) = N_Defining_Operator_Symbol then + elsif Chars (Subp) in Any_Operator_Name then if Must_Not_Override (Spec) then -- If this is not a primitive or a protected subprogram, then @@ -8313,7 +8310,12 @@ package body Sem_Ch6 is Typ : Entity_Id; begin - if Nkind (Subp) /= N_Defining_Operator_Symbol then + -- Return False if not an operator. We test the name rather than testing + -- that the Nkind is N_Defining_Operator_Symbol, because there are cases + -- where an operator entity can be an N_Defining_Identifier (such as for + -- function instantiations). + + if Chars (Subp) not in Any_Operator_Name then return False; else diff --git a/gcc/ada/sem_ch6.ads b/gcc/ada/sem_ch6.ads index 9579582..4afcf36 100644 --- a/gcc/ada/sem_ch6.ads +++ b/gcc/ada/sem_ch6.ads @@ -51,6 +51,9 @@ package Sem_Ch6 is -- and body declarations. Returns the defining entity for the -- specification N. + function Can_Override_Operator (Subp : Entity_Id) return Boolean; + -- Returns true if Subp can override a predefined operator + procedure Check_Conventions (Typ : Entity_Id); -- Ada 2005 (AI-430): Check that the conventions of all inherited and -- overridden dispatching operations of type Typ are consistent with their diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 1c68eed..aa33c50 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -3299,7 +3299,9 @@ package body Sem_Ch8 is Style.Missing_Overriding (N, Rename_Spec); end if; - elsif Must_Override (Specification (N)) then + elsif Must_Override (Specification (N)) + and then not Can_Override_Operator (Rename_Spec) + then Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec); end if; -- cgit v1.1 From 32638d4975f2768b25732f87b4708360117ef0fd Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 6 Apr 2021 13:10:01 +0200 Subject: [Ada] Simplify detection of local types gcc/ada/ * sem_ch3.adb (Is_Local_Type): Simplify by reusing Scope_Within. --- gcc/ada/sem_ch3.adb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 98cbef4..70e1dfd 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -19133,21 +19133,8 @@ package body Sem_Ch3 is ------------------- function Is_Local_Type (Typ : Entity_Id) return Boolean is - Scop : Entity_Id; - begin - Scop := Scope (Typ); - while Present (Scop) - and then Scop /= Standard_Standard - loop - if Scop = Scope (Current_Scope) then - return True; - end if; - - Scop := Scope (Scop); - end loop; - - return False; + return Scope_Within (Inner => Typ, Outer => Scope (Current_Scope)); end Is_Local_Type; -- Start of processing for Is_Visible_Component -- cgit v1.1 From 3307a681fe6883008495d686f3b357dcbfb9537c Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Mon, 12 Apr 2021 16:56:23 +0200 Subject: [Ada] More robust guard against cascaded errors with overlapping actuals gcc/ada/ * sem_warn.adb (Warn_On_Overlapping_Actuals): Prevent cascaded errors once for the subprogram call, not for every pair of actual parameters. --- gcc/ada/sem_warn.adb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 23f2771..9e337f9 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -3729,6 +3729,11 @@ package body Sem_Warn is if Nkind (N) not in N_Subprogram_Call | N_Entry_Call_Statement then return; + + -- Guard against previous errors + + elsif Error_Posted (N) then + return; end if; -- If a call C has two or more parameters of mode in out or out that are @@ -3800,10 +3805,9 @@ package body Sem_Warn is and then Is_Composite_Type (Etype (Form1))) then - -- Guard against previous errors + -- Guard against previous errors - if Error_Posted (N) - or else No (Etype (Act1)) + if No (Etype (Act1)) or else No (Etype (Act2)) then null; -- cgit v1.1 From df3636e013f276a0d1fde5b6da1f504b748696db Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 8 Apr 2021 21:17:33 +0200 Subject: [Ada] Reuse Is_Subprogram_Or_Entry where possible gcc/ada/ * freeze.adb (Freeze_All): Simplify by reusing Is_Subprogram_Or_Entry. * sem_ch11.adb (Analyze_Handled_Statement): Likewise. --- gcc/ada/freeze.adb | 2 +- gcc/ada/sem_ch11.adb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 3ea4a99..81e0e87 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2179,7 +2179,7 @@ package body Freeze is elsif Is_Concurrent_Type (E) then Item := First_Entity (E); while Present (Item) loop - if (Is_Entry (Item) or else Is_Subprogram (Item)) + if Is_Subprogram_Or_Entry (Item) and then not Default_Expressions_Processed (Item) then Process_Default_Expressions (Item, After); diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index 5a2c6a6..2af65ae 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -435,7 +435,7 @@ package body Sem_Ch11 is -- postcondition, since in that case there are no source references, and -- we need to preserve deferred references from the enclosing scope. - if ((Is_Subprogram (Current_Scope) or else Is_Entry (Current_Scope)) + if (Is_Subprogram_Or_Entry (Current_Scope) and then Chars (Current_Scope) /= Name_uPostconditions) or else Ekind (Current_Scope) in E_Block | E_Task_Type then -- cgit v1.1 From afea7b3dc2c85604167debac55cc736689b994ad Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 8 Apr 2021 21:19:54 +0200 Subject: [Ada] Remove redundant check for empty list gcc/ada/ * sem_ch3.adb (Analyze_Declarations): Remove explicit check for missing, because a subsequent call to Is_Empty_List will detect them anyway. --- gcc/ada/sem_ch3.adb | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 70e1dfd..7dfb5c8 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2758,7 +2758,6 @@ package body Sem_Ch3 is Resolve_Aspects; elsif L /= Visible_Declarations (Parent (L)) - or else No (Private_Declarations (Parent (L))) or else Is_Empty_List (Private_Declarations (Parent (L))) then Adjust_Decl; -- cgit v1.1 From bd881d83c11fa1d8779e076708ef72be6fc2dbe7 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 6 Apr 2021 13:11:09 +0200 Subject: [Ada] Fix style in Get_Fullest_View gcc/ada/ * sem_util.ads (Get_Fullest_View): Refill comment; remove extra extra after period. * sem_util.adb (Get_Fullest_View): Fix style. --- gcc/ada/sem_util.adb | 12 ++++++++---- gcc/ada/sem_util.ads | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index f723781..0d50952 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -10772,22 +10772,26 @@ package body Sem_Util is when E_Class_Wide_Type => return Get_Fullest_View (Root_Type (E), Include_PAT); - when E_Class_Wide_Subtype => + when E_Class_Wide_Subtype => if Present (Equivalent_Type (E)) then return Get_Fullest_View (Equivalent_Type (E), Include_PAT); elsif Present (Cloned_Subtype (E)) then return Get_Fullest_View (Cloned_Subtype (E), Include_PAT); end if; - when E_Protected_Type | E_Protected_Subtype - | E_Task_Type | E_Task_Subtype => + when E_Protected_Subtype + | E_Protected_Type + | E_Task_Subtype + | E_Task_Type + => if Present (Corresponding_Record_Type (E)) then return Get_Fullest_View (Corresponding_Record_Type (E), Include_PAT); end if; when E_Access_Protected_Subprogram_Type - | E_Anonymous_Access_Protected_Subprogram_Type => + | E_Anonymous_Access_Protected_Subprogram_Type + => if Present (Equivalent_Type (E)) then return Get_Fullest_View (Equivalent_Type (E), Include_PAT); end if; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index f9db80e..10375ff 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1328,9 +1328,9 @@ package Sem_Util is function Get_Fullest_View (E : Entity_Id; Include_PAT : Boolean := True) return Entity_Id; - -- Get the fullest possible view of E, looking through private, - -- limited, packed array and other implementation types. If Include_PAT - -- is False, don't look inside packed array types. + -- Get the fullest possible view of E, looking through private, limited, + -- packed array and other implementation types. If Include_PAT is False, + -- don't look inside packed array types. function Has_Access_Values (T : Entity_Id) return Boolean; -- Returns true if the underlying type of T is an access type, or has a -- cgit v1.1 From 23a5c0fe8abc2f823be049a991eafe36fd31f5d7 Mon Sep 17 00:00:00 2001 From: Claire Dross Date: Mon, 12 Apr 2021 09:48:48 +0200 Subject: [Ada] Disable Pre/Post in formal containers gcc/ada/ * libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable pre and postconditions. * libgnat/a-cfhama.ads: Likewise. * libgnat/a-cfhase.ads: Likewise. * libgnat/a-cfinve.ads: Likewise. * libgnat/a-cforma.ads: Likewise. * libgnat/a-cforse.ads: Likewise. * libgnat/a-cofove.ads: Likewise. --- gcc/ada/libgnat/a-cfdlli.ads | 5 +++++ gcc/ada/libgnat/a-cfhama.ads | 5 +++++ gcc/ada/libgnat/a-cfhase.ads | 5 +++++ gcc/ada/libgnat/a-cfinve.ads | 5 +++++ gcc/ada/libgnat/a-cforma.ads | 5 +++++ gcc/ada/libgnat/a-cforse.ads | 5 +++++ gcc/ada/libgnat/a-cofove.ads | 5 +++++ 7 files changed, 35 insertions(+) (limited to 'gcc') diff --git a/gcc/ada/libgnat/a-cfdlli.ads b/gcc/ada/libgnat/a-cfdlli.ads index d3bc3ba..e3a2de6 100644 --- a/gcc/ada/libgnat/a-cfdlli.ads +++ b/gcc/ada/libgnat/a-cfdlli.ads @@ -39,6 +39,11 @@ generic package Ada.Containers.Formal_Doubly_Linked_Lists with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type List (Capacity : Count_Type) is private with diff --git a/gcc/ada/libgnat/a-cfhama.ads b/gcc/ada/libgnat/a-cfhama.ads index 9ccd9c2..e9b0268 100644 --- a/gcc/ada/libgnat/a-cfhama.ads +++ b/gcc/ada/libgnat/a-cfhama.ads @@ -64,6 +64,11 @@ generic package Ada.Containers.Formal_Hashed_Maps with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type Map (Capacity : Count_Type; Modulus : Hash_Type) is private with diff --git a/gcc/ada/libgnat/a-cfhase.ads b/gcc/ada/libgnat/a-cfhase.ads index 47aaf0d..5d57863 100644 --- a/gcc/ada/libgnat/a-cfhase.ads +++ b/gcc/ada/libgnat/a-cfhase.ads @@ -62,6 +62,11 @@ generic package Ada.Containers.Formal_Hashed_Sets with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type Set (Capacity : Count_Type; Modulus : Hash_Type) is private with diff --git a/gcc/ada/libgnat/a-cfinve.ads b/gcc/ada/libgnat/a-cfinve.ads index a8aeaa2..37dde92 100644 --- a/gcc/ada/libgnat/a-cfinve.ads +++ b/gcc/ada/libgnat/a-cfinve.ads @@ -55,6 +55,11 @@ generic package Ada.Containers.Formal_Indefinite_Vectors with SPARK_Mode => On is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); subtype Extended_Index is Index_Type'Base diff --git a/gcc/ada/libgnat/a-cforma.ads b/gcc/ada/libgnat/a-cforma.ads index 4e17978..d32727e 100644 --- a/gcc/ada/libgnat/a-cforma.ads +++ b/gcc/ada/libgnat/a-cforma.ads @@ -63,6 +63,11 @@ generic package Ada.Containers.Formal_Ordered_Maps with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); function Equivalent_Keys (Left, Right : Key_Type) return Boolean with diff --git a/gcc/ada/libgnat/a-cforse.ads b/gcc/ada/libgnat/a-cforse.ads index 61a93a3..12d2d3c 100644 --- a/gcc/ada/libgnat/a-cforse.ads +++ b/gcc/ada/libgnat/a-cforse.ads @@ -59,6 +59,11 @@ generic package Ada.Containers.Formal_Ordered_Sets with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); function Equivalent_Elements (Left, Right : Element_Type) return Boolean diff --git a/gcc/ada/libgnat/a-cofove.ads b/gcc/ada/libgnat/a-cofove.ads index 217032f..61115dd 100644 --- a/gcc/ada/libgnat/a-cofove.ads +++ b/gcc/ada/libgnat/a-cofove.ads @@ -45,6 +45,11 @@ generic package Ada.Containers.Formal_Vectors with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); subtype Extended_Index is Index_Type'Base -- cgit v1.1 From b75d2a509265580e72dff963a8bdff52bb6a1a21 Mon Sep 17 00:00:00 2001 From: Doug Rupp Date: Mon, 12 Apr 2021 12:03:48 -0700 Subject: [Ada] vx7-shared-libs: Unused variable __gnat_user_int_connect gcc/ada/ * Makefile.rtl (x86_64-vx7r2) [EXTRA_GNATRTL_TASKING_OBJS]: Move i-vxinco.o out of RTP runtime. --- gcc/ada/Makefile.rtl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 0b84612..ff46200 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1457,12 +1457,12 @@ ifeq ($(strip $(filter-out %86 x86_64 wrs vxworks vxworks7%,$(target_cpu) $(targ endif endif - EXTRA_GNATRTL_NONTASKING_OBJS += i-vxwork.o i-vxwoio.o + EXTRA_GNATRTL_NONTASKING_OBJS += i-vxinco.o i-vxwork.o i-vxwoio.o endif endif EXTRA_GNATRTL_NONTASKING_OBJS += s-stchop.o - EXTRA_GNATRTL_TASKING_OBJS += i-vxinco.o s-vxwork.o s-vxwext.o + EXTRA_GNATRTL_TASKING_OBJS += s-vxwork.o s-vxwext.o EXTRA_LIBGNAT_OBJS+=vx_stack_info.o -- cgit v1.1 From 793543254a6e94055e701499b7e9c8c1d3830061 Mon Sep 17 00:00:00 2001 From: Patrick Bernardi Date: Wed, 14 Apr 2021 13:50:57 +1000 Subject: [Ada] Ensure System.Tasking.Debug.Known_Tasks component access is atomic gcc/ada/ * libgnarl/s-tasdeb.ads (Known_Tasks): Add Atomic_Components aspect. --- gcc/ada/libgnarl/s-tasdeb.ads | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/libgnarl/s-tasdeb.ads b/gcc/ada/libgnarl/s-tasdeb.ads index 3e8a8d8..eebb2a9 100644 --- a/gcc/ada/libgnarl/s-tasdeb.ads +++ b/gcc/ada/libgnarl/s-tasdeb.ads @@ -65,9 +65,11 @@ package System.Tasking.Debug is -- General GDB support -- ------------------------- - Known_Tasks : array (0 .. 999) of Task_Id := (others => null); + Known_Tasks : array (0 .. 999) of Task_Id := (others => null) + with Atomic_Components; -- Global array of tasks read by gdb, and updated by Create_Task and - -- Finalize_TCB + -- Finalize_TCB. Ensure access to its components is atomic to allow + -- lock-free concurrent access. Debug_Event_Activating : constant := 1; Debug_Event_Run : constant := 2; -- cgit v1.1 From 8d1427a932f241891f054e55c5d3710ef7d0f303 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 15 Apr 2021 14:17:48 +0200 Subject: [Ada] Remove a special case for forking-for-expect from ordinary spawn gcc/ada/ * adaint.c (__gnat_portable_spawn): Revert change that introduced setting of __gnat_in_child_after_fork. --- gcc/ada/adaint.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 7770300..b2d4de6 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2423,7 +2423,6 @@ __gnat_portable_spawn (char *args[] ATTRIBUTE_UNUSED) if (pid == 0) { /* The child. */ - __gnat_in_child_after_fork = 1; if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0) _exit (1); } -- cgit v1.1 From 339bf0a2a972fe0655dfa3b6508312e748d4fbcc Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 15 Apr 2021 17:22:46 +0200 Subject: [Ada] Small tweak in a couple of comments gcc/ada/ * sem_ch12.adb (Freeze_Subprogram_Body): Add missing "freeze". (Install_Body): Likewise. --- gcc/ada/sem_ch12.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 893854d..339bb42 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -9106,7 +9106,7 @@ package body Sem_Ch12 is -- Handle the following case: -- -- package Parent_Inst is new ... - -- Parent_Inst [] + -- freeze Parent_Inst [] -- -- procedure P ... -- this body freezes Parent_Inst -- @@ -9942,7 +9942,7 @@ package body Sem_Ch12 is -- Handle the following case: -- package Parent_Inst is new ... - -- Parent_Inst [] + -- freeze Parent_Inst [] -- procedure P ... -- this body freezes Parent_Inst -- cgit v1.1 From 38b57d67e85df1636c5e4300defe337e28878412 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 15 Apr 2021 18:00:52 +0200 Subject: [Ada] Remove an obsolete variant of Adjust_Name_Case used only by SPARK gcc/ada/ * errout.ads (Adjust_Name_Case): Remove obsolete and now unused variant. * errout.adb (Adjust_Name_Case): Likewise; fix variant that uses a custom buffer to also use it for names in Standard_Location. --- gcc/ada/errout.adb | 7 +------ gcc/ada/errout.ads | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index f643c8d..8fd2076 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -3402,7 +3402,7 @@ package body Errout is -- For standard locations, always use mixed case if Loc <= No_Location then - Set_Casing (Mixed_Case); + Set_Casing (Buf, Mixed_Case); else -- Determine if the reference we are dealing with corresponds to @@ -3440,11 +3440,6 @@ package body Errout is end; end Adjust_Name_Case; - procedure Adjust_Name_Case (Loc : Source_Ptr) is - begin - Adjust_Name_Case (Global_Name_Buffer, Loc); - end Adjust_Name_Case; - --------------------------- -- Set_Identifier_Casing -- --------------------------- diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index 904c87d..b0cbd82 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -985,10 +985,6 @@ package Errout is -- the name at that source location, we copy the casing from the source, -- otherwise we set appropriate default casing. - procedure Adjust_Name_Case (Loc : Source_Ptr); - -- Uses Buf => Global_Name_Buffer. There are no calls to this in the - -- compiler, but it is called in SPARK 2014. - procedure Set_Identifier_Casing (Identifier_Name : System.Address; File_Name : System.Address); -- cgit v1.1 From a671959b7640b1b02c924292959f2cbe1574536a Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Fri, 16 Apr 2021 12:52:50 -0400 Subject: [Ada] Crash on limited array object with address clause gcc/ada/ * exp_aggr.adb (Convert_Aggr_In_Object_Decl): After expansion of the aggregate, the expression can be removed from the declaration, except if the object is class-wide, in which case the aggregate provides the actual type. In other cases the presence of the expression may lead to spurious freezing issue. * exp_ch3.adb (Expand_N_Object_Declaration): If the expression in the declaration is an aggregate with delayed expansion (as is the case for objects of a limited type, or a subsequent address specification) the aggregate must be resolved at this point. This resolution must not include expansion, because the expansion of the enclosing declaration will construct the necessary aggregate expansion. --- gcc/ada/exp_aggr.adb | 9 +++++++++ gcc/ada/exp_ch3.adb | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 85e2abb..56ec1be 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4437,6 +4437,15 @@ package body Exp_Aggr is end; Set_No_Initialization (N); + + -- After expansion the expression can be removed from the declaration + -- except if the object is class-wide, in which case the aggregate + -- provides the actual type. + + if not Is_Class_Wide_Type (Etype (Obj)) then + Set_Expression (N, Empty); + end if; + Initialize_Discriminants (N, Typ); end Convert_Aggr_In_Object_Decl; diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 6a8b330..4dbaadd 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -30,6 +30,7 @@ with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Errout; use Errout; +with Expander; use Expander; with Exp_Aggr; use Exp_Aggr; with Exp_Atag; use Exp_Atag; with Exp_Ch4; use Exp_Ch4; @@ -6985,12 +6986,16 @@ package body Exp_Ch3 is -- happen when the aggregate is limited and the declared object -- has a following address clause; it happens also when generating -- C code for an aggregate that has an alignment or address clause - -- (see Analyze_Object_Declaration). + -- (see Analyze_Object_Declaration). Resolution is done without + -- expansion because it will take place when the declaration + -- itself is expanded. if (Is_Limited_Type (Typ) or else Modify_Tree_For_C) and then not Analyzed (Expr) then + Expander_Mode_Save_And_Set (False); Resolve (Expr, Typ); + Expander_Mode_Restore; end if; Convert_Aggr_In_Object_Decl (N); -- cgit v1.1 From bfe2554f052b11ecf07d93cb04137f3fca5c6e6d Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Sun, 18 Apr 2021 09:45:04 -0400 Subject: [Ada] Fix the -gnatyr switch so it works in record rep clauses gcc/ada/ * sem_ch13.adb (Analyze_Record_Representation_Clause): Call Set_Entity_With_Checks instead of Set_Entity, so we perform the check for correct casing. * style.adb (Check_Identifier): Minor comment improvement. Cleanup overly complicated code. --- gcc/ada/sem_ch13.adb | 2 +- gcc/ada/style.adb | 50 ++++++++++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 29 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index d7667f2..dcd5954 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -8561,7 +8561,7 @@ package body Sem_Ch13 is Generate_Reference (Comp, Component_Name (CC), Set_Ref => False); - Set_Entity (Component_Name (CC), Comp); + Set_Entity_With_Checks (Component_Name (CC), Comp); -- Update Fbit and Lbit to the actual bit number diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb index a34d3e0..1409cc6 100644 --- a/gcc/ada/style.adb +++ b/gcc/ada/style.adb @@ -136,48 +136,42 @@ package body Style is Tref := Source_Text (Get_Source_File_Index (Sref)); Tdef := Source_Text (Get_Source_File_Index (Sdef)); - -- Ignore operator name case completely. This also catches the - -- case of where one is an operator and the other is not. This - -- is a phenomenon from rewriting of operators as functions, - -- and is to be ignored. + -- Ignore case of operator names. This also catches the case + -- where one is an operator and the other is not. This is a + -- phenomenon from rewriting of operators as functions, and is + -- to be ignored. if Tref (Sref) = '"' or else Tdef (Sdef) = '"' then return; else - while Tref (Sref) = Tdef (Sdef) loop + loop + -- If end of identifiers, all done. Note that they are the + -- same length. - -- If end of identifier, all done + pragma Assert + (Identifier_Char (Tref (Sref)) = + Identifier_Char (Tdef (Sdef))); if not Identifier_Char (Tref (Sref)) then return; - - -- Otherwise loop continues - - else - Sref := Sref + 1; - Sdef := Sdef + 1; end if; - end loop; - -- Fall through loop when mismatch between identifiers - -- If either identifier is not terminated, error. + -- Case mismatch - if Identifier_Char (Tref (Sref)) - or else - Identifier_Char (Tdef (Sdef)) - then - Error_Msg_Node_1 := Def; - Error_Msg_Sloc := Sloc (Def); - Error_Msg -- CODEFIX - ("(style) bad casing of & declared#", Sref, Ref); - return; + if Tref (Sref) /= Tdef (Sdef) then + Error_Msg_Node_1 := Def; + Error_Msg_Sloc := Sloc (Def); + Error_Msg -- CODEFIX + ("(style) bad casing of & declared#", Sref, Ref); + return; + end if; - -- Else end of identifiers, and they match + Sref := Sref + 1; + Sdef := Sdef + 1; + end loop; - else - return; - end if; + pragma Assert (False); end if; end if; -- cgit v1.1 From 16a0b3b4abb10d0b03877f606f13863401bbd77f Mon Sep 17 00:00:00 2001 From: Aleksandra Pasek Date: Wed, 14 Apr 2021 10:44:04 -0400 Subject: [Ada] Add support for Aarch64 in System.Object_Reader gcc/ada/ * libgnat/s-objrea.adb (EM_AARCH64): New Constant. (Initialize): Handle EM_AARCH64 case. (Read_Address): Handle AARCH64 case. * libgnat/s-objrea.ads (Object_Arch): Add AARCH64 record component. --- gcc/ada/libgnat/s-objrea.adb | 7 ++++++- gcc/ada/libgnat/s-objrea.ads | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb index b5ca32f..9dd8c1f 100644 --- a/gcc/ada/libgnat/s-objrea.adb +++ b/gcc/ada/libgnat/s-objrea.adb @@ -78,6 +78,7 @@ package body System.Object_Reader is EM_SPARCV9 : constant := 43; -- SPARC v9 64-bit EM_IA_64 : constant := 50; -- Intel Merced EM_X86_64 : constant := 62; -- AMD x86-64 architecture + EM_AARCH64 : constant := 183; -- Aarch64 EN_NIDENT : constant := 16; @@ -648,6 +649,9 @@ package body System.Object_Reader is when EM_ARM => Res.Arch := ARM; + when EM_AARCH64 => + Res.Arch := AARCH64; + when others => raise Format_Error with "unrecognized architecture"; end case; @@ -2038,7 +2042,8 @@ package body System.Object_Reader is Address_32 := Read (S); return uint64 (Address_32); - when IA64 + when AARCH64 + | IA64 | PPC64 | SPARC64 | x86_64 diff --git a/gcc/ada/libgnat/s-objrea.ads b/gcc/ada/libgnat/s-objrea.ads index 28dabf5..a83ca53 100644 --- a/gcc/ada/libgnat/s-objrea.ads +++ b/gcc/ada/libgnat/s-objrea.ads @@ -120,9 +120,12 @@ package System.Object_Reader is PPC64, -- 64-bit PowerPC - ARM); + ARM, -- 32-bit ARM + AARCH64); + -- 64-bit ARM + ------------------ -- Target types -- ------------------ -- cgit v1.1 From c8cb547e601f1e271243817ee6325221ba1135a3 Mon Sep 17 00:00:00 2001 From: Boris Yakobowski Date: Mon, 19 Apr 2021 12:17:07 +0200 Subject: [Ada] Do not catch 'N mod -1' in CodePeer_Mode gcc/ada/ * exp_ch4.adb (Expand_N_Op_Mod): Remove special case for mod -1 in CodePeer_Mode. --- gcc/ada/exp_ch4.adb | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc') diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 9c585e7..a9fc2705 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -9626,6 +9626,7 @@ package body Exp_Ch4 is if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi)) and then ((not LOK) or else (Llo = LLB)) + and then not CodePeer_Mode then Rewrite (N, Make_If_Expression (Loc, -- cgit v1.1 From ba4b83c3e3bd44448a85e3771b91ae39421d9dd7 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 20 Apr 2021 10:53:06 +0200 Subject: [Ada] Expose symmetry between Known_ and Unknown_ query routines gcc/ada/ * einfo-utils.adb (Unknown_Alignment): Simply negate the Known_ counterpart. (Unknown_Component_Bit_Offset): Likewise. (Unknown_Esize): Likewise. (Unknown_Normalized_First_Bit): Likewise. (Unknown_Normalized_Position): Likewise. (Unknown_Normalized_Position_Max): Likewise. (Unknown_RM_Size): Likewise. --- gcc/ada/einfo-utils.adb | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 02ccef1..6e8a772 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -593,13 +593,12 @@ package body Einfo.Utils is function Unknown_Alignment (E : Entity_Id) return B is begin - return Alignment (E) = Uint_0 - or else Alignment (E) = No_Uint; + return not Known_Alignment (E); end Unknown_Alignment; function Unknown_Component_Bit_Offset (E : Entity_Id) return B is begin - return Component_Bit_Offset (E) = No_Uint; + return not Known_Component_Bit_Offset (E); end Unknown_Component_Bit_Offset; function Unknown_Component_Size (E : Entity_Id) return B is @@ -609,32 +608,27 @@ package body Einfo.Utils is function Unknown_Esize (E : Entity_Id) return B is begin - return Esize (E) = No_Uint - or else - Esize (E) = Uint_0; + return not Known_Esize (E); end Unknown_Esize; function Unknown_Normalized_First_Bit (E : Entity_Id) return B is begin - return Normalized_First_Bit (E) = No_Uint; + return not Known_Normalized_First_Bit (E); end Unknown_Normalized_First_Bit; function Unknown_Normalized_Position (E : Entity_Id) return B is begin - return Normalized_Position (E) = No_Uint; + return not Known_Normalized_Position (E); end Unknown_Normalized_Position; function Unknown_Normalized_Position_Max (E : Entity_Id) return B is begin - return Normalized_Position_Max (E) = No_Uint; + return not Known_Normalized_Position_Max (E); end Unknown_Normalized_Position_Max; function Unknown_RM_Size (E : Entity_Id) return B is begin - return (RM_Size (E) = Uint_0 - and then not Is_Discrete_Type (E) - and then not Is_Fixed_Point_Type (E)) - or else RM_Size (E) = No_Uint; + return not Known_RM_Size (E); end Unknown_RM_Size; -------------------- -- cgit v1.1 From 9a2c557b8ba4e33452a27219af1db83ec0cb7e0a Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 21 Apr 2021 08:35:24 -0400 Subject: [Ada] Make copies of entities being declared when copying block gcc/ada/ * sem_util.adb (Visit_Node): Add handling for N_Block_Statement with declarations. --- gcc/ada/sem_util.adb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0d50952..a543268 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -24344,6 +24344,26 @@ package body Sem_Util is EWA_Inner_Scope_Level := EWA_Inner_Scope_Level + 1; end if; + -- If the node is a block, we need to process all declarations + -- in the block and make new entities for each. + + if Nkind (N) = N_Block_Statement and then Present (Declarations (N)) + then + declare + Decl : Node_Id := First (Declarations (N)); + + begin + while Present (Decl) loop + if Nkind (Decl) = N_Object_Declaration then + Add_New_Entity (Defining_Identifier (Decl), + New_Copy (Defining_Identifier (Decl))); + end if; + + Next (Decl); + end loop; + end; + end if; + declare procedure Action (U : Union_Id); procedure Action (U : Union_Id) is -- cgit v1.1 From af9987e817f54806a18e45c5615b9a95b690e537 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 29 Jun 2021 16:35:42 +0200 Subject: gcc.c: Silence warning in check_offload_target_name gcc/ChangeLog: * gcc.c (check_offload_target_name): Cast len argument to %q.*s to 'int'; avoid -Wstringop-truncation warning. --- gcc/gcc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/gcc.c b/gcc/gcc.c index df9b219..9baa7d6 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -4004,13 +4004,15 @@ check_offload_target_name (const char *target, ptrdiff_t len) n = strchr (c, ','); if (n == NULL) n = strchr (c, '\0'); + if (n - c == 0) + break; strncpy (cand, c, n - c); cand[n - c] = '\0'; candidates.safe_push (cand); c = *n ? n + 1 : NULL; } error ("GCC is not configured to support %q.*s as offload target", - len, target); + (int) len, target); const char *hint = candidates_list_and_hint (target, s, candidates); if (hint) inform (UNKNOWN_LOCATION, -- cgit v1.1 From 7d510b21194e0c3150c4b6256c92efef7b1e373e Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 29 Jun 2021 15:10:17 +0000 Subject: bootstrap: Include memmodel.h in btfout.c and ctfout.c before tm_p.h This fixes a "use of enum 'memmodel' without previous declaration" error in sparc-protos.h. Minimally tested that this fixes the build-many-glibcs.py compilers build for sparc64-linux-gnu. * btfout.c, ctfout.c: Include "memmodel.h". --- gcc/btfout.c | 1 + gcc/ctfout.c | 1 + 2 files changed, 2 insertions(+) (limited to 'gcc') diff --git a/gcc/btfout.c b/gcc/btfout.c index 2316dea..e58c969 100644 --- a/gcc/btfout.c +++ b/gcc/btfout.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "target.h" +#include "memmodel.h" #include "tm_p.h" #include "output.h" #include "dwarf2asm.h" diff --git a/gcc/ctfout.c b/gcc/ctfout.c index 71d7a62..682d852 100644 --- a/gcc/ctfout.c +++ b/gcc/ctfout.c @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "target.h" +#include "memmodel.h" #include "tm_p.h" #include "output.h" #include "dwarf2asm.h" -- cgit v1.1 From 5c127c4cac308429cba483a2ac4e175c2ab26165 Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Mon, 28 Jun 2021 06:58:52 -0700 Subject: amdgcn: Mark s_mulk_i32 as clobbering SCC The s_mulk_i32 instruction sets the SCC status register according to whether the multiplication overflows, but that is not currently modelled in the GCN backend. AFAIK this is a latent bug and hasn't been noticed "in the wild", but it should be fixed. 2021-06-29 Julian Brown gcc/ * config/gcn/gcn.md (mulsi3): Make s_mulk_i32 variant clobber SCC. --- gcc/config/gcn/gcn.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index b5f895a..cca4552 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1371,10 +1371,13 @@ ; Vector multiply has vop3a encoding, but no corresponding vop2a, so no long ; immediate. +; The "s_mulk_i32" variant sets SCC to indicate overflow (which we don't care +; about here, but we need to indicate the clobbering). (define_insn "mulsi3" [(set (match_operand:SI 0 "register_operand" "= Sg,Sg, Sg, v") (mult:SI (match_operand:SI 1 "gcn_alu_operand" "%SgA, 0,SgA, v") - (match_operand:SI 2 "gcn_alu_operand" " SgA, J, B,vASv")))] + (match_operand:SI 2 "gcn_alu_operand" " SgA, J, B,vASv"))) + (clobber (match_scratch:BI 3 "=X,cs, X, X"))] "" "@ s_mul_i32\t%0, %1, %2 -- cgit v1.1 From 53b1d1691857a1d3e28566d05bb434fa555c4e8a Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Thu, 17 Jun 2021 11:02:55 -0700 Subject: amdgcn: Add [us]mulsi3_highpart SGPR alternatives This patch splits the mulsi3_highpart pattern into an expander and register/immediate alternatives (to avoid meaningless sign/zero_extends on constants), and adds alternatives for SGPR high-part multiply instructions on GCN5+. 2021-06-29 Julian Brown gcc/ * config/gcn/gcn.md (mulsi3_highpart): Change to expander. (mulsi3_highpart_reg, mulsi3_highpart_imm): New patterns. --- gcc/config/gcn/gcn.md | 62 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index cca4552..d1d4998 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1394,20 +1394,68 @@ (define_code_attr iu [(sign_extend "i") (zero_extend "u")]) (define_code_attr e [(sign_extend "e") (zero_extend "")]) -(define_insn "mulsi3_highpart" - [(set (match_operand:SI 0 "register_operand" "= v") +(define_expand "mulsi3_highpart" + [(set (match_operand:SI 0 "register_operand" "") (truncate:SI (lshiftrt:DI (mult:DI (any_extend:DI - (match_operand:SI 1 "register_operand" "% v")) + (match_operand:SI 1 "register_operand" "")) (any_extend:DI - (match_operand:SI 2 "register_operand" "vSv"))) + (match_operand:SI 2 "gcn_alu_operand" ""))) (const_int 32))))] "" - "v_mul_hi0\t%0, %2, %1" - [(set_attr "type" "vop3a") - (set_attr "length" "8")]) +{ + if (can_create_pseudo_p () + && !TARGET_GCN5 + && !gcn_inline_immediate_operand (operands[2], SImode)) + operands[2] = force_reg (SImode, operands[2]); + + if (REG_P (operands[2])) + emit_insn (gen_mulsi3_highpart_reg (operands[0], operands[1], + operands[2])); + else + emit_insn (gen_mulsi3_highpart_imm (operands[0], operands[1], + operands[2])); + + DONE; +}) + +(define_insn "mulsi3_highpart_reg" + [(set (match_operand:SI 0 "register_operand" "=Sg, v") + (truncate:SI + (lshiftrt:DI + (mult:DI + (any_extend:DI + (match_operand:SI 1 "register_operand" "%Sg, v")) + (any_extend:DI + (match_operand:SI 2 "register_operand" "Sg,vSv"))) + (const_int 32))))] + "" + "@ + s_mul_hi0\t%0, %1, %2 + v_mul_hi0\t%0, %2, %1" + [(set_attr "type" "sop2,vop3a") + (set_attr "length" "4,8") + (set_attr "gcn_version" "gcn5,*")]) + +(define_insn "mulsi3_highpart_imm" + [(set (match_operand:SI 0 "register_operand" "=Sg,Sg,v") + (truncate:SI + (lshiftrt:DI + (mult:DI + (any_extend:DI + (match_operand:SI 1 "register_operand" "Sg,Sg,v")) + (match_operand:DI 2 "gcn_32bit_immediate_operand" "A, B,A")) + (const_int 32))))] + "TARGET_GCN5 || gcn_inline_immediate_operand (operands[2], SImode)" + "@ + s_mul_hi0\t%0, %1, %2 + s_mul_hi0\t%0, %1, %2 + v_mul_hi0\t%0, %2, %1" + [(set_attr "type" "sop2,sop2,vop3a") + (set_attr "length" "4,8,8") + (set_attr "gcn_version" "gcn5,gcn5,*")]) (define_insn "mulhisi3" [(set (match_operand:SI 0 "register_operand" "=v") -- cgit v1.1 From 8f332122589f97b9c974b168ca5b0b186296f0e4 Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Tue, 29 Jun 2021 03:57:31 -0700 Subject: amdgcn: Add [us]mulsid3/muldi3 patterns This patch improves 64-bit multiplication for AMD GCN: patterns for unsigned and signed 32x32->64 bit multiplication have been added, and also 64x64->64 bit multiplication is now open-coded rather than calling a library function (which may be a win for code size as well as speed: the function calling sequence isn't particularly concise for GCN). This version of the patch uses define_insn_and_split in order to keep multiply operations together during RTL optimisations up to register allocation: this appears to produce more compact code via inspection on small test cases than the previous approach using an expander. The DImode multiply implementation is lost from libgcc if we build it for DImode/TImode rather than SImode/DImode, a change we make in a later patch in this series. 2021-06-29 Julian Brown gcc/ * config/gcn/gcn.md (mulsidi3, mulsidi3_reg, mulsidi3_imm, muldi3): Add patterns. --- gcc/config/gcn/gcn.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index d1d4998..82f7a46 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1457,6 +1457,100 @@ (set_attr "length" "4,8,8") (set_attr "gcn_version" "gcn5,gcn5,*")]) +(define_expand "mulsidi3" + [(set (match_operand:DI 0 "register_operand" "") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "")) + (any_extend:DI + (match_operand:SI 2 "nonmemory_operand" ""))))] + "" +{ + if (can_create_pseudo_p () + && !TARGET_GCN5 + && !gcn_inline_immediate_operand (operands[2], SImode)) + operands[2] = force_reg (SImode, operands[2]); + + if (REG_P (operands[2])) + emit_insn (gen_mulsidi3_reg (operands[0], operands[1], operands[2])); + else + emit_insn (gen_mulsidi3_imm (operands[0], operands[1], operands[2])); + + DONE; +}) + +(define_insn_and_split "mulsidi3_reg" + [(set (match_operand:DI 0 "register_operand" "=&Sg, &v") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "%Sg, v")) + (any_extend:DI + (match_operand:SI 2 "register_operand" "Sg,vSv"))))] + "" + "#" + "reload_completed" + [(const_int 0)] + { + rtx dstlo = gen_lowpart (SImode, operands[0]); + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + emit_insn (gen_mulsi3 (dstlo, operands[1], operands[2])); + emit_insn (gen_mulsi3_highpart (dsthi, operands[1], operands[2])); + DONE; + } + [(set_attr "gcn_version" "gcn5,*")]) + +(define_insn_and_split "mulsidi3_imm" + [(set (match_operand:DI 0 "register_operand" "=&Sg,&Sg,&v") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "Sg, Sg, v")) + (match_operand:DI 2 "gcn_32bit_immediate_operand" + "A, B, A")))] + "TARGET_GCN5 || gcn_inline_immediate_operand (operands[2], SImode)" + "#" + "&& reload_completed" + [(const_int 0)] + { + rtx dstlo = gen_lowpart (SImode, operands[0]); + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + emit_insn (gen_mulsi3 (dstlo, operands[1], operands[2])); + emit_insn (gen_mulsi3_highpart (dsthi, operands[1], operands[2])); + DONE; + } + [(set_attr "gcn_version" "gcn5,gcn5,*")]) + +(define_insn_and_split "muldi3" + [(set (match_operand:DI 0 "register_operand" "=&Sg,&Sg, &v,&v") + (mult:DI (match_operand:DI 1 "register_operand" "%Sg, Sg, v, v") + (match_operand:DI 2 "nonmemory_operand" "Sg, i,vSv, A"))) + (clobber (match_scratch:SI 3 "=&Sg,&Sg,&v,&v")) + (clobber (match_scratch:BI 4 "=cs, cs, X, X")) + (clobber (match_scratch:DI 5 "=X, X,cV,cV"))] + "" + "#" + "reload_completed" + [(const_int 0)] + { + rtx tmp = operands[3]; + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + rtx op1lo = gcn_operand_part (DImode, operands[1], 0); + rtx op1hi = gcn_operand_part (DImode, operands[1], 1); + rtx op2lo = gcn_operand_part (DImode, operands[2], 0); + rtx op2hi = gcn_operand_part (DImode, operands[2], 1); + emit_insn (gen_umulsidi3 (operands[0], op1lo, op2lo)); + emit_insn (gen_mulsi3 (tmp, op1lo, op2hi)); + rtx add = gen_rtx_SET (dsthi, gen_rtx_PLUS (SImode, dsthi, tmp)); + rtx clob1 = gen_rtx_CLOBBER (VOIDmode, operands[4]); + rtx clob2 = gen_rtx_CLOBBER (VOIDmode, operands[5]); + add = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (3, add, clob1, clob2)); + emit_insn (add); + emit_insn (gen_mulsi3 (tmp, op1hi, op2lo)); + add = gen_rtx_SET (dsthi, gen_rtx_PLUS (SImode, dsthi, tmp)); + clob1 = gen_rtx_CLOBBER (VOIDmode, operands[4]); + clob2 = gen_rtx_CLOBBER (VOIDmode, operands[5]); + add = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (3, add, clob1, clob2)); + emit_insn (add); + DONE; + } + [(set_attr "gcn_version" "gcn5,gcn5,*,*")]) + (define_insn "mulhisi3" [(set (match_operand:SI 0 "register_operand" "=v") (mult:SI -- cgit v1.1 From 0c06e46a81d86d70d788ca1a93d27b6902bd4dc1 Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Thu, 17 Jun 2021 10:52:51 -0700 Subject: amdgcn: Add clrsbsi2/clrsbdi2 implementation This patch adds an open-coded implementation of the clrsb2 (count leading redundant sign bit) standard names using the GCN flbit_i* instructions for SImode and DImode. Those don't count exactly as we need, so we need a couple of other instructions to fix up the result afterwards. These patterns are lost from libgcc if we build it for DImode/TImode rather than SImode/DImode, a change we make in a later patch in this series. 2021-06-18 Julian Brown gcc/ * config/gcn/gcn.md (UNSPEC_FLBIT_INT): New unspec constant. (s_mnemonic): Add clrsb. (gcn_flbit_int): Add insn pattern for SImode/DImode. (clrsb2): Add expander for SImode/DImode. --- gcc/config/gcn/gcn.md | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 82f7a46..ae7249a 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -81,7 +81,8 @@ UNSPEC_MOV_FROM_LANE63 UNSPEC_GATHER UNSPEC_SCATTER - UNSPEC_RCP]) + UNSPEC_RCP + UNSPEC_FLBIT_INT]) ;; }}} ;; {{{ Attributes @@ -338,7 +339,8 @@ [(not "not%b") (popcount "bcnt1_i32%b") (clz "flbit_i32%b") - (ctz "ff1_i32%b")]) + (ctz "ff1_i32%b") + (clrsb "flbit_i32%i")]) (define_code_attr revmnemonic [(minus "subrev%i") @@ -1611,6 +1613,40 @@ [(set_attr "type" "sop1") (set_attr "length" "4,8")]) +(define_insn "gcn_flbit_int" + [(set (match_operand:SI 0 "register_operand" "=Sg,Sg") + (unspec:SI [(match_operand:SIDI 1 "gcn_alu_operand" "SgA, B")] + UNSPEC_FLBIT_INT))] + "" + { + if (mode == SImode) + return "s_flbit_i32\t%0, %1"; + else + return "s_flbit_i32_i64\t%0, %1"; + } + [(set_attr "type" "sop1") + (set_attr "length" "4,8")]) + +(define_expand "clrsb2" + [(set (match_operand:SI 0 "register_operand" "") + (clrsb:SI (match_operand:SIDI 1 "gcn_alu_operand" "")))] + "" + { + rtx tmp = gen_reg_rtx (SImode); + /* FLBIT_I* counts sign or zero bits at the most-significant end of the + input register (and returns -1 for 0/-1 inputs). We want the number of + *redundant* bits (i.e. that value minus one), and an answer of 31/63 for + 0/-1 inputs. We can do that in three instructions... */ + emit_insn (gen_gcn_flbit_int (tmp, operands[1])); + emit_insn (gen_uminsi3 (tmp, tmp, + gen_int_mode (GET_MODE_BITSIZE (mode), + SImode))); + /* If we put this last, it can potentially be folded into a subsequent + arithmetic operation. */ + emit_insn (gen_subsi3 (operands[0], tmp, const1_rtx)); + DONE; + }) + ;; }}} ;; {{{ ALU: generic 32-bit binop -- cgit v1.1 From a8a730cd99184e62c4d026b8c775b96589a9c262 Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Wed, 9 Jun 2021 06:18:23 -0700 Subject: amdgcn: Enable support for TImode for AMD GCN This patch enables support for TImode for AMD GCN, the lack of which is currently causing a number of test failures for the target and which is also needed to support "omp_depend_kind" for OpenMP 5.0, since that is implemented as a 128-bit integer. Several libgcc support routines are built by default for the "word size" of a machine, and also for "2 * word size" of the machine. The libgcc build for AMD GCN is changed so that it builds for a "word size" of 64 bits, in order to better match the (64-bit) host compiler. However it isn't really true that we have 64-bit words -- GCN has 32-bit registers, so changing UNITS_PER_WORD unconditionally would be the wrong thing to do. Changing this setting for libgcc (only) means that support routines are built for "single word" operations that are DImode (64 bits), and those for "double word" operations are built for TImode (128 bits). That leaves some gaps regarding previous operations that were built for a "single word" size of 32 bits and a "double word" size of 64 bits (generic code doesn't cover both alternatives for all operations that might be needed). Those gaps are filled in by this patch, or by the preceding patches in the series. 2021-06-18 Julian Brown gcc/ * config/gcn/gcn.c (gcn_init_libfuncs): New function. (TARGET_INIT_LIBFUNCS): Define target hook using above function. * config/gcn/gcn.h (UNITS_PER_WORD): Define to 8 for IN_LIBGCC2, 4 otherwise. (LIBGCC2_UNITS_PER_WORD, BITS_PER_WORD): Remove definitions. (MAX_FIXED_MODE_SIZE): Change to 128. libgcc/ * config/gcn/lib2-bswapti2.c: New file. * config/gcn/lib2-divmod-di.c: New file. * config/gcn/lib2-gcn.h (DItype, UDItype, TItype, UTItype): Add typedefs. (__divdi3, __moddi3, __udivdi3, __umoddi3): Add prototypes. * config/gcn/t-amdgcn (LIB2ADD): Add lib2-divmod-di.c and lib2-bswapti2.c. --- gcc/config/gcn/gcn.c | 30 ++++++++++++++++++++++++++++++ gcc/config/gcn/gcn.h | 11 +++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 54a1c0b..aa9d455 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -3610,6 +3610,34 @@ gcn_init_builtins (void) #endif } +/* Implement TARGET_INIT_LIBFUNCS. */ + +static void +gcn_init_libfuncs (void) +{ + /* BITS_PER_UNIT * 2 is 64 bits, which causes + optabs-libfuncs.c:gen_int_libfunc to omit TImode (i.e 128 bits) + libcalls that we need to support operations for that type. Initialise + them here instead. */ + set_optab_libfunc (udiv_optab, TImode, "__udivti3"); + set_optab_libfunc (umod_optab, TImode, "__umodti3"); + set_optab_libfunc (sdiv_optab, TImode, "__divti3"); + set_optab_libfunc (smod_optab, TImode, "__modti3"); + set_optab_libfunc (smul_optab, TImode, "__multi3"); + set_optab_libfunc (addv_optab, TImode, "__addvti3"); + set_optab_libfunc (subv_optab, TImode, "__subvti3"); + set_optab_libfunc (negv_optab, TImode, "__negvti2"); + set_optab_libfunc (absv_optab, TImode, "__absvti2"); + set_optab_libfunc (smulv_optab, TImode, "__mulvti3"); + set_optab_libfunc (ffs_optab, TImode, "__ffsti2"); + set_optab_libfunc (clz_optab, TImode, "__clzti2"); + set_optab_libfunc (ctz_optab, TImode, "__ctzti2"); + set_optab_libfunc (clrsb_optab, TImode, "__clrsbti2"); + set_optab_libfunc (popcount_optab, TImode, "__popcountti2"); + set_optab_libfunc (parity_optab, TImode, "__parityti2"); + set_optab_libfunc (bswap_optab, TImode, "__bswapti2"); +} + /* Expand the CMP_SWAP GCN builtins. We have our own versions that do not require taking the address of any object, other than the memory cell being operated on. @@ -6345,6 +6373,8 @@ gcn_dwarf_register_span (rtx rtl) #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS gcn_init_builtins +#undef TARGET_INIT_LIBFUNCS +#define TARGET_INIT_LIBFUNCS gcn_init_libfuncs #undef TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS #define TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS \ gcn_ira_change_pseudo_allocno_class diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h index eba4646..540835b 100644 --- a/gcc/config/gcn/gcn.h +++ b/gcc/config/gcn/gcn.h @@ -46,9 +46,12 @@ #define BYTES_BIG_ENDIAN 0 #define WORDS_BIG_ENDIAN 0 -#define BITS_PER_WORD 32 -#define UNITS_PER_WORD (BITS_PER_WORD/BITS_PER_UNIT) -#define LIBGCC2_UNITS_PER_WORD 4 +#ifdef IN_LIBGCC2 +/* We want DImode and TImode helpers. */ +#define UNITS_PER_WORD 8 +#else +#define UNITS_PER_WORD 4 +#endif #define POINTER_SIZE 64 #define PARM_BOUNDARY 64 @@ -56,7 +59,7 @@ #define FUNCTION_BOUNDARY 32 #define BIGGEST_ALIGNMENT 64 #define EMPTY_FIELD_BOUNDARY 32 -#define MAX_FIXED_MODE_SIZE 64 +#define MAX_FIXED_MODE_SIZE 128 #define MAX_REGS_PER_ADDRESS 2 #define STACK_SIZE_MODE DImode #define Pmode DImode -- cgit v1.1 From c60d9160b4d966dbea5b1bbea4f817c64d0bee2d Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 29 Jun 2021 19:14:35 +0200 Subject: i386: Add V2SFmode vec_addsub pattern [PR95046] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc/ 2021-06-21 Uroš Bizjak PR target/95046 * config/i386/mmx.md (vec_addsubv2sf3): New insn pattern. gcc/testsuite/ 2021-06-21 Uroš Bizjak PR target/95046 * gcc.target/i386/pr95046-9.c: New test. --- gcc/config/i386/mmx.md | 18 ++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr95046-9.c | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr95046-9.c (limited to 'gcc') diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index e887f034..5f105727 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -788,6 +788,24 @@ (set_attr "prefix_extra" "1") (set_attr "mode" "V2SF")]) +(define_insn "vec_addsubv2sf3" + [(set (match_operand:V2SF 0 "register_operand" "=x,x") + (vec_merge:V2SF + (minus:V2SF + (match_operand:V2SF 1 "register_operand" "0,x") + (match_operand:V2SF 2 "register_operand" "x,x")) + (plus:V2SF (match_dup 1) (match_dup 2)) + (const_int 1)))] + "TARGET_SSE3 && TARGET_MMX_WITH_SSE" + "@ + addsubps\t{%2, %0|%0, %2} + vaddsubps\t{%2, %1, %0|%0, %1, %2}" + [(set_attr "isa" "noavx,avx") + (set_attr "type" "sseadd") + (set_attr "prefix" "orig,vex") + (set_attr "prefix_rep" "1,*") + (set_attr "mode" "V4SF")]) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel single-precision floating point comparisons diff --git a/gcc/testsuite/gcc.target/i386/pr95046-9.c b/gcc/testsuite/gcc.target/i386/pr95046-9.c new file mode 100644 index 0000000..54e948c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr95046-9.c @@ -0,0 +1,14 @@ +/* PR target/95046 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O3 -msse3" } */ + +float r[2], a[2], b[2]; + +void +test (void) +{ + r[0] = a[0] - b[0]; + r[1] = a[1] + b[1]; +} + +/* { dg-final { scan-assembler "\tv?addsubps" } } */ -- cgit v1.1 From 8a8a7d332d5d01db5aea7336a36d9fd71a679fb1 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 28 Jun 2021 16:47:55 -0700 Subject: compiler: in composite literals use temps only for interfaces For a composite literal we only need to introduce a temporary variable if we may be converting to an interface type, so only do it then. This saves over 80% of compilation time when using gccgo to compile cmd/internal/obj/x86, as the GCC middle-end spends a lot of time pointlessly computing interactions between temporary variables. For PR debug/101064 For golang/go#46600 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331513 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'gcc') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index f16fb9f..f7bcc8c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -bcafcb3c39530bb325514d6377747eb3127d1a03 +cad187fe3aceb2a7d964b64c70dfa8c8ad24ce65 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5d45e4b..94342b2 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -15148,7 +15148,7 @@ Struct_construction_expression::do_copy() } // Flatten a struct construction expression. Store the values into -// temporaries in case they need interface conversion. +// temporaries if they may need interface conversion. Expression* Struct_construction_expression::do_flatten(Gogo*, Named_object*, @@ -15162,10 +15162,13 @@ Struct_construction_expression::do_flatten(Gogo*, Named_object*, return this; Location loc = this->location(); + const Struct_field_list* fields = this->type_->struct_type()->fields(); + Struct_field_list::const_iterator pf = fields->begin(); for (Expression_list::iterator pv = this->vals()->begin(); pv != this->vals()->end(); - ++pv) + ++pv, ++pf) { + go_assert(pf != fields->end()); if (*pv != NULL) { if ((*pv)->is_error_expression() || (*pv)->type()->is_error_type()) @@ -15173,7 +15176,8 @@ Struct_construction_expression::do_flatten(Gogo*, Named_object*, go_assert(saw_errors()); return Expression::make_error(loc); } - if (!(*pv)->is_multi_eval_safe()) + if (pf->type()->interface_type() != NULL + && !(*pv)->is_multi_eval_safe()) { Temporary_statement* temp = Statement::make_temporary(NULL, *pv, loc); @@ -15448,7 +15452,7 @@ Array_construction_expression::do_check_types(Gogo*) } // Flatten an array construction expression. Store the values into -// temporaries in case they need interface conversion. +// temporaries if they may need interface conversion. Expression* Array_construction_expression::do_flatten(Gogo*, Named_object*, @@ -15467,6 +15471,11 @@ Array_construction_expression::do_flatten(Gogo*, Named_object*, if (this->is_constant_array() || this->is_static_initializer()) return this; + // If the array element type is not an interface type, we don't need + // temporaries. + if (this->type_->array_type()->element_type()->interface_type() == NULL) + return this; + Location loc = this->location(); for (Expression_list::iterator pv = this->vals()->begin(); pv != this->vals()->end(); -- cgit v1.1 From a7e655ae4016eaf04e261ff32fc67a14ebb0e329 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 25 Jun 2021 11:24:30 -0400 Subject: Add stmt context in simplify_using_ranges. There were places simplify_using_ranges was not utilzing the stmt context. * vr-values.c (vr_values::vrp_stmt_computes_nonzero): Use stmt. (simplify_using_ranges::op_with_boolean_value_range_p): Add a statement for location context. (check_for_binary_op_overflow): Ditto. (simplify_using_ranges::get_vr_for_comparison): Ditto. (simplify_using_ranges::compare_name_with_value): Ditto. (simplify_using_ranges::compare_names): Ditto. (vrp_evaluate_conditional_warnv_with_ops_using_ranges): Ditto. (simplify_using_ranges::simplify_truth_ops_using_ranges): Ditto. (simplify_using_ranges::simplify_min_or_max_using_ranges): Ditto. (simplify_using_ranges::simplify_internal_call_using_ranges): Ditto. (simplify_using_ranges::two_valued_val_range_p): Ditto. (simplify_using_ranges::simplify): Ditto. * vr-values.h: Adjust prototypes. --- gcc/vr-values.c | 71 ++++++++++++++++++++++++++++++--------------------------- gcc/vr-values.h | 14 +++++++----- 2 files changed, 46 insertions(+), 39 deletions(-) (limited to 'gcc') diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 3ae2c68..190676d 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -429,7 +429,7 @@ vr_values::vrp_stmt_computes_nonzero (gimple *stmt) && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr)))) { const value_range_equiv *vr - = get_value_range (TREE_OPERAND (base, 0)); + = get_value_range (TREE_OPERAND (base, 0), stmt); if (!range_includes_zero_p (vr)) return true; } @@ -486,7 +486,7 @@ vr_values::op_with_constant_singleton_value_range (tree op) /* Return true if op is in a boolean [0, 1] value-range. */ bool -simplify_using_ranges::op_with_boolean_value_range_p (tree op) +simplify_using_ranges::op_with_boolean_value_range_p (tree op, gimple *s) { if (TYPE_PRECISION (TREE_TYPE (op)) == 1) return true; @@ -500,7 +500,7 @@ simplify_using_ranges::op_with_boolean_value_range_p (tree op) /* ?? Errr, this should probably check for [0,0] and [1,1] as well as [0,1]. */ - const value_range *vr = query->get_value_range (op); + const value_range *vr = query->get_value_range (op, s); return *vr == value_range (build_zero_cst (TREE_TYPE (op)), build_one_cst (TREE_TYPE (op))); } @@ -1057,18 +1057,18 @@ vr_values::extract_range_from_comparison (value_range_equiv *vr, static bool check_for_binary_op_overflow (range_query *query, enum tree_code subcode, tree type, - tree op0, tree op1, bool *ovf) + tree op0, tree op1, bool *ovf, gimple *s = NULL) { value_range vr0, vr1; if (TREE_CODE (op0) == SSA_NAME) - vr0 = *query->get_value_range (op0); + vr0 = *query->get_value_range (op0, s); else if (TREE_CODE (op0) == INTEGER_CST) vr0.set (op0); else vr0.set_varying (TREE_TYPE (op0)); if (TREE_CODE (op1) == SSA_NAME) - vr1 = *query->get_value_range (op1); + vr1 = *query->get_value_range (op1, s); else if (TREE_CODE (op1) == INTEGER_CST) vr1.set (op1); else @@ -1980,10 +1980,11 @@ vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p, is varying or undefined. Uses TEM as storage for the alternate range. */ const value_range_equiv * -simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem) +simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem, + gimple *s) { /* Shallow-copy equiv bitmap. */ - const value_range_equiv *vr = query->get_value_range (ssa_name (i)); + const value_range_equiv *vr = query->get_value_range (ssa_name (i), s); /* If name N_i does not have a valid range, use N_i as its own range. This allows us to compare against names that may @@ -2005,10 +2006,11 @@ simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem) tree simplify_using_ranges::compare_name_with_value (enum tree_code comp, tree var, tree val, - bool *strict_overflow_p, bool use_equiv_p) + bool *strict_overflow_p, bool use_equiv_p, + gimple *s) { /* Get the set of equivalences for VAR. */ - bitmap e = query->get_value_range (var)->equiv (); + bitmap e = query->get_value_range (var, s)->equiv (); /* Start at -1. Set it to 0 if we do a comparison without relying on overflow, or 1 if all comparisons rely on overflow. */ @@ -2017,7 +2019,7 @@ simplify_using_ranges::compare_name_with_value /* Compare vars' value range with val. */ value_range_equiv tem_vr; const value_range_equiv *equiv_vr - = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr); + = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr, s); bool sop = false; tree retval = compare_range_with_value (comp, equiv_vr, val, &sop); if (retval) @@ -2044,7 +2046,7 @@ simplify_using_ranges::compare_name_with_value && prop_simulate_again_p (SSA_NAME_DEF_STMT (name))) continue; - equiv_vr = get_vr_for_comparison (i, &tem_vr); + equiv_vr = get_vr_for_comparison (i, &tem_vr, s); sop = false; tree t = compare_range_with_value (comp, equiv_vr, val, &sop); if (t) @@ -2084,12 +2086,12 @@ simplify_using_ranges::compare_name_with_value tree simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, - bool *strict_overflow_p) + bool *strict_overflow_p, gimple *s) { /* Compare the ranges of every name equivalent to N1 against the ranges of every name equivalent to N2. */ - bitmap e1 = query->get_value_range (n1)->equiv (); - bitmap e2 = query->get_value_range (n2)->equiv (); + bitmap e1 = query->get_value_range (n1, s)->equiv (); + bitmap e2 = query->get_value_range (n2, s)->equiv (); /* Use the fake bitmaps if e1 or e2 are not available. */ static bitmap s_e1 = NULL, s_e2 = NULL; @@ -2139,7 +2141,7 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, continue; value_range_equiv tem_vr1; - const value_range_equiv *vr1 = get_vr_for_comparison (i1, &tem_vr1); + const value_range_equiv *vr1 = get_vr_for_comparison (i1, &tem_vr1, s); tree t = NULL_TREE, retval = NULL_TREE; bitmap_iterator bi2; @@ -2152,7 +2154,8 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, bool sop = false; value_range_equiv tem_vr2; - const value_range_equiv *vr2 = get_vr_for_comparison (i2, &tem_vr2); + const value_range_equiv *vr2 = get_vr_for_comparison (i2, &tem_vr2, + s); t = compare_ranges (comp, vr1, vr2, &sop); if (t) @@ -2198,11 +2201,12 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, tree simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops_using_ranges - (enum tree_code code, tree op0, tree op1, bool * strict_overflow_p) + (enum tree_code code, tree op0, tree op1, bool * strict_overflow_p, + gimple *s) { const value_range_equiv *vr0, *vr1; - vr0 = (TREE_CODE (op0) == SSA_NAME) ? query->get_value_range (op0) : NULL; - vr1 = (TREE_CODE (op1) == SSA_NAME) ? query->get_value_range (op1) : NULL; + vr0 = (TREE_CODE (op0) == SSA_NAME) ? query->get_value_range (op0, s) : NULL; + vr1 = (TREE_CODE (op1) == SSA_NAME) ? query->get_value_range (op1, s) : NULL; tree res = NULL_TREE; if (vr0 && vr1) @@ -2302,20 +2306,20 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops } if ((ret = vrp_evaluate_conditional_warnv_with_ops_using_ranges - (code, op0, op1, strict_overflow_p))) + (code, op0, op1, strict_overflow_p, stmt))) return ret; if (only_ranges) *only_ranges = false; /* Do not use compare_names during propagation, it's quadratic. */ if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME && use_equiv_p) - return compare_names (code, op0, op1, strict_overflow_p); + return compare_names (code, op0, op1, strict_overflow_p, stmt); else if (TREE_CODE (op0) == SSA_NAME) return compare_name_with_value (code, op0, op1, - strict_overflow_p, use_equiv_p); + strict_overflow_p, use_equiv_p, stmt); else if (TREE_CODE (op1) == SSA_NAME) return compare_name_with_value (swap_tree_comparison (code), op1, op0, - strict_overflow_p, use_equiv_p); + strict_overflow_p, use_equiv_p, stmt); return NULL_TREE; } @@ -2929,11 +2933,11 @@ simplify_using_ranges::simplify_truth_ops_using_ranges gcc_assert (rhs_code == EQ_EXPR || rhs_code == NE_EXPR); op0 = gimple_assign_rhs1 (stmt); - if (!op_with_boolean_value_range_p (op0)) + if (!op_with_boolean_value_range_p (op0, stmt)) return false; op1 = gimple_assign_rhs2 (stmt); - if (!op_with_boolean_value_range_p (op1)) + if (!op_with_boolean_value_range_p (op1, stmt)) return false; /* Reduce number of cases to handle to NE_EXPR. As there is no @@ -3131,12 +3135,12 @@ simplify_using_ranges::simplify_min_or_max_using_ranges tree val; val = (vrp_evaluate_conditional_warnv_with_ops_using_ranges - (LE_EXPR, op0, op1, &sop)); + (LE_EXPR, op0, op1, &sop, stmt)); if (!val) { sop = false; val = (vrp_evaluate_conditional_warnv_with_ops_using_ranges - (LT_EXPR, op0, op1, &sop)); + (LT_EXPR, op0, op1, &sop, stmt)); } if (val) @@ -4000,7 +4004,7 @@ simplify_using_ranges::simplify_internal_call_using_ranges return false; else type = TREE_TYPE (TREE_TYPE (gimple_call_lhs (stmt))); - if (!check_for_binary_op_overflow (query, subcode, type, op0, op1, &ovf) + if (!check_for_binary_op_overflow (query, subcode, type, op0, op1, &ovf, stmt) || (is_ubsan && ovf)) return false; @@ -4057,9 +4061,10 @@ simplify_using_ranges::simplify_internal_call_using_ranges two-values when it is true. Return false otherwise. */ bool -simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b) +simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b, + gimple *s) { - value_range vr = *query->get_value_range (var); + value_range vr = *query->get_value_range (var, s); vr.normalize_symbolics (); if (vr.varying_p () || vr.undefined_p ()) return false; @@ -4133,7 +4138,7 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi) tree cmp_var = NULL_TREE; if (TREE_CODE (rhs2) == SSA_NAME - && two_valued_val_range_p (rhs2, &val1, &val2)) + && two_valued_val_range_p (rhs2, &val1, &val2, stmt)) { /* Optimize RHS1 OP [VAL1, VAL2]. */ new_rhs1 = int_const_binop (rhs_code, rhs1, val1); @@ -4141,7 +4146,7 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi) cmp_var = rhs2; } else if (TREE_CODE (rhs1) == SSA_NAME - && two_valued_val_range_p (rhs1, &val1, &val2)) + && two_valued_val_range_p (rhs1, &val1, &val2, stmt)) { /* Optimize [VAL1, VAL2] OP RHS2. */ new_rhs1 = int_const_binop (rhs_code, val1, rhs2); diff --git a/gcc/vr-values.h b/gcc/vr-values.h index 81b9131..7fdefef 100644 --- a/gcc/vr-values.h +++ b/gcc/vr-values.h @@ -56,14 +56,16 @@ private: gimple *); bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *); - bool two_valued_val_range_p (tree, tree *, tree *); - bool op_with_boolean_value_range_p (tree); - tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool); - tree compare_names (enum tree_code, tree, tree, bool *); - const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *); + bool two_valued_val_range_p (tree, tree *, tree *, gimple *); + bool op_with_boolean_value_range_p (tree, gimple *); + tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool, + gimple *); + tree compare_names (enum tree_code, tree, tree, bool *, gimple *s); + const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *, + gimple *s); tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code, tree, tree, - bool *); + bool *, gimple *s); void cleanup_edges_and_switches (void); /* Vectors of edges that need removing and switch statements that -- cgit v1.1 From 604dce2d74d3417970e23e7ad38322d1adbca2e2 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 25 Jun 2021 15:31:39 -0400 Subject: Allow PHIs to pick up global values. We can also apply known global values to PHI nodes in EVRP. * value-query.cc (gimple_range_global): Allow phis. --- gcc/value-query.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 17dfdb1..730a214 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -419,7 +419,8 @@ gimple_range_global (tree name) gcc_checking_assert (gimple_range_ssa_p (name)); tree type = TREE_TYPE (name); - if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining)) + if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining) + || is_a (SSA_NAME_DEF_STMT (name))) { value_range vr; get_range_global (vr, name); -- cgit v1.1 From a96d8d67d0073a7031c0712bc3fb7759417b2125 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 29 Jun 2021 10:52:58 -0400 Subject: Fix MINUS_EXPR relations. Flesh out and correct relations for both wrapping and non-wrapping values. gcc/ PR tree-optimization/101254 * range-op.cc (operator_minus::op1_op2_relation_effect): Check for wrapping/non-wrapping when setting the result range. gcc/testsuite * gcc.dg/pr101254.c: New. --- gcc/range-op.cc | 64 ++++++++++++++++++++++++++++++----------- gcc/testsuite/gcc.dg/pr101254.c | 27 +++++++++++++++++ 2 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr101254.c (limited to 'gcc') diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 29ee9e0..97b9843 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1314,24 +1314,54 @@ operator_minus::op1_op2_relation_effect (irange &lhs_range, tree type, unsigned prec = TYPE_PRECISION (type); signop sgn = TYPE_SIGN (type); - switch (rel) + // == and != produce [0,0] and ~[0,0] regardless of wrapping. + if (rel == EQ_EXPR) + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec)); + else if (rel == NE_EXPR) + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec), + VR_ANTI_RANGE); + else if (TYPE_OVERFLOW_WRAPS (type)) { - // op1 > op2, op1 - op2 can be restricted to [1, max] - case GT_EXPR: - rel_range = int_range<2> (type, wi::one (prec), - wi::max_value (prec, sgn)); - break; - // op1 >= op2, op1 - op2 can be restricted to [0, max] - case GE_EXPR: - rel_range = int_range<2> (type, wi::zero (prec), - wi::max_value (prec, sgn)); - break; - // op1 == op2, op1 - op2 can be restricted to [0, 0] - case EQ_EXPR: - rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec)); - break; - default: - return false; + switch (rel) + { + // For wrapping signed values and unsigned, if op1 > op2 or + // op1 < op2, then op1 - op2 can be restricted to ~[0, 0]. + case GT_EXPR: + case LT_EXPR: + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec), + VR_ANTI_RANGE); + break; + default: + return false; + } + } + else + { + switch (rel) + { + // op1 > op2, op1 - op2 can be restricted to [1, +INF] + case GT_EXPR: + rel_range = int_range<2> (type, wi::one (prec), + wi::max_value (prec, sgn)); + break; + // op1 >= op2, op1 - op2 can be restricted to [0, +INF] + case GE_EXPR: + rel_range = int_range<2> (type, wi::zero (prec), + wi::max_value (prec, sgn)); + break; + // op1 < op2, op1 - op2 can be restricted to [-INF, -1] + case LT_EXPR: + rel_range = int_range<2> (type, wi::min_value (prec, sgn), + wi::minus_one (prec)); + break; + // op1 <= op2, op1 - op2 can be restricted to [-INF, 0] + case LE_EXPR: + rel_range = int_range<2> (type, wi::min_value (prec, sgn), + wi::zero (prec)); + break; + default: + return false; + } } lhs_range.intersect (rel_range); return true; diff --git a/gcc/testsuite/gcc.dg/pr101254.c b/gcc/testsuite/gcc.dg/pr101254.c new file mode 100644 index 0000000..b2460ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101254.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/101254 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +int +foo (long long imin, long long imax) +{ + if (imin > imax) + return 0; + else if (imax - imin < 0 || (imax - imin) + 1 < 0) + return 0; + return 1; +} + +int +main () +{ + long long imax = __LONG_LONG_MAX__; + long long imin = -imax - 1; + if (!foo (-10, 10)) + __builtin_abort (); + if (foo (-10, imax)) + __builtin_abort (); + if (foo (imin, imax)) + __builtin_abort (); + return 0; +} -- cgit v1.1 From cca7eb8f7cc157ed1b351cbaa10a4066f8065c3a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 29 Jun 2021 12:12:16 -0700 Subject: go-gcc: set DECL_NAMELESS for temporary variables * go-gcc.cc (Gcc_backend::static_chain_variable): Set DECL_NAMELESS on the new decl. (Gcc_backend::temporary_variable): Likewise. (Gcc_backend::function): Set DECL_NAMELESS on the result decl. --- gcc/go/go-gcc.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc') diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 41f309e..f812796 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2853,6 +2853,7 @@ Gcc_backend::static_chain_variable(Bfunction* function, const std::string& name, TREE_USED(decl) = 1; DECL_ARTIFICIAL(decl) = 1; DECL_IGNORED_P(decl) = 1; + DECL_NAMELESS(decl) = 1; TREE_READONLY(decl) = 1; struct function *f = DECL_STRUCT_FUNCTION(fndecl); @@ -2912,6 +2913,7 @@ Gcc_backend::temporary_variable(Bfunction* function, Bblock* bblock, type_tree); DECL_ARTIFICIAL(var) = 1; DECL_IGNORED_P(var) = 1; + DECL_NAMELESS(var) = 1; TREE_USED(var) = 1; DECL_CONTEXT(var) = decl; @@ -3290,6 +3292,7 @@ Gcc_backend::function(Btype* fntype, const std::string& name, build_decl(location.gcc_location(), RESULT_DECL, NULL_TREE, restype); DECL_ARTIFICIAL(resdecl) = 1; DECL_IGNORED_P(resdecl) = 1; + DECL_NAMELESS(resdecl) = 1; DECL_CONTEXT(resdecl) = decl; DECL_RESULT(decl) = resdecl; } -- cgit v1.1 From 13c906f43f473ee9ff16d80590789d719f2190a4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 29 Jun 2021 12:53:02 -0700 Subject: compiler: don't generate temporaries for composite literals We were generating temporaries for composite literals when a conversion to interface type was required. However, Cherry's https://golang.org/cl/176459 changed the compiler to insert explicit type conversions. And those explicit type conversions insert the required temporaries in Type_conversion_expression::do_flatten. So in practice the composite literal do_flatten methods would never insert temporaries, as the values they see would always be multi_eval_safe. So just remove the unnecessary do_flatten methods. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331691 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 103 +++------------------------------------ gcc/go/gofrontend/expressions.h | 6 --- 3 files changed, 7 insertions(+), 104 deletions(-) (limited to 'gcc') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index f7bcc8c..ab1384d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -cad187fe3aceb2a7d964b64c70dfa8c8ad24ce65 +01cb2b5e69a2d08ef3cc1ea023c22ed9b79f5114 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 94342b2..a0472ac 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -15147,48 +15147,6 @@ Struct_construction_expression::do_copy() return ret; } -// Flatten a struct construction expression. Store the values into -// temporaries if they may need interface conversion. - -Expression* -Struct_construction_expression::do_flatten(Gogo*, Named_object*, - Statement_inserter* inserter) -{ - if (this->vals() == NULL) - return this; - - // If this is a constant struct, we don't need temporaries. - if (this->is_constant_struct() || this->is_static_initializer()) - return this; - - Location loc = this->location(); - const Struct_field_list* fields = this->type_->struct_type()->fields(); - Struct_field_list::const_iterator pf = fields->begin(); - for (Expression_list::iterator pv = this->vals()->begin(); - pv != this->vals()->end(); - ++pv, ++pf) - { - go_assert(pf != fields->end()); - if (*pv != NULL) - { - if ((*pv)->is_error_expression() || (*pv)->type()->is_error_type()) - { - go_assert(saw_errors()); - return Expression::make_error(loc); - } - if (pf->type()->interface_type() != NULL - && !(*pv)->is_multi_eval_safe()) - { - Temporary_statement* temp = - Statement::make_temporary(NULL, *pv, loc); - inserter->insert(temp); - *pv = Expression::make_temporary_reference(temp, loc); - } - } - } - return this; -} - // Make implicit type conversions explicit. void @@ -15451,55 +15409,6 @@ Array_construction_expression::do_check_types(Gogo*) } } -// Flatten an array construction expression. Store the values into -// temporaries if they may need interface conversion. - -Expression* -Array_construction_expression::do_flatten(Gogo*, Named_object*, - Statement_inserter* inserter) -{ - if (this->is_error_expression()) - { - go_assert(saw_errors()); - return this; - } - - if (this->vals() == NULL) - return this; - - // If this is a constant array, we don't need temporaries. - if (this->is_constant_array() || this->is_static_initializer()) - return this; - - // If the array element type is not an interface type, we don't need - // temporaries. - if (this->type_->array_type()->element_type()->interface_type() == NULL) - return this; - - Location loc = this->location(); - for (Expression_list::iterator pv = this->vals()->begin(); - pv != this->vals()->end(); - ++pv) - { - if (*pv != NULL) - { - if ((*pv)->is_error_expression() || (*pv)->type()->is_error_type()) - { - go_assert(saw_errors()); - return Expression::make_error(loc); - } - if (!(*pv)->is_multi_eval_safe()) - { - Temporary_statement* temp = - Statement::make_temporary(NULL, *pv, loc); - inserter->insert(temp); - *pv = Expression::make_temporary_reference(temp, loc); - } - } - } - return this; -} - // Make implicit type conversions explicit. void @@ -15768,14 +15677,14 @@ Slice_construction_expression::create_array_val() // the new temp statement. Expression* -Slice_construction_expression::do_flatten(Gogo* gogo, Named_object* no, +Slice_construction_expression::do_flatten(Gogo*, Named_object*, Statement_inserter* inserter) { if (this->type()->array_type() == NULL) - return NULL; - - // Base class flattening first - this->Array_construction_expression::do_flatten(gogo, no, inserter); + { + go_assert(saw_errors()); + return Expression::make_error(this->location()); + } // Create a stack-allocated storage temp if storage won't escape if (!this->storage_escapes_ @@ -15784,7 +15693,7 @@ Slice_construction_expression::do_flatten(Gogo* gogo, Named_object* no, { Location loc = this->location(); this->array_val_ = this->create_array_val(); - go_assert(this->array_val_); + go_assert(this->array_val_ != NULL); Temporary_statement* temp = Statement::make_temporary(this->valtype_, this->array_val_, loc); inserter->insert(temp); diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index e3747cc..57c974d 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -3806,9 +3806,6 @@ class Struct_construction_expression : public Expression, Expression* do_copy(); - Expression* - do_flatten(Gogo*, Named_object*, Statement_inserter*); - Bexpression* do_get_backend(Translate_context*); @@ -3881,9 +3878,6 @@ protected: indexes() { return this->indexes_; } - Expression* - do_flatten(Gogo*, Named_object*, Statement_inserter*); - // Get the backend constructor for the array values. Bexpression* get_constructor(Translate_context* context, Btype* btype); -- cgit v1.1 From 362347c5a4e56d48c9af7ed7d9cc3feff0c2d219 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 29 Jun 2021 15:11:25 -0400 Subject: c++: don't treat member var as var template While looking at a partial instantiation issue I noticed that we were wrongly hitting the partial instantiation code when instantiating a static data member of a class template. I don't think this broke anything, but we don't need to do that (small) extra work. gcc/cp/ChangeLog: * pt.c (instantiate_decl): Only consider partial specializations of actual variable templates. --- gcc/cp/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f2039e0..d2936c1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26003,7 +26003,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) td = template_for_substitution (d); args = gen_args; - if (VAR_P (d)) + if (variable_template_specialization_p (d)) { /* Look up an explicit specialization, if any. */ tree tid = lookup_template_variable (gen_tmpl, gen_args); -- cgit v1.1 From 1cb5e50f9845466f0aaeb35f620bf9e25d8246c1 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 29 Jun 2021 22:11:39 +0100 Subject: docs: Fix s/net yet/not yet/ typo gcc/ChangeLog: * doc/generic.texi: Fix s/net yet/not yet/ typo. --- gcc/doc/generic.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index 642cbc8..d317f65 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -33,7 +33,7 @@ before handing off to @code{tree_rest_of_compilation}, but this seems inelegant. @menu -* Deficiencies:: Topics net yet covered in this document. +* Deficiencies:: Topics not yet covered in this document. * Tree overview:: All about @code{tree}s. * Types:: Fundamental and aggregate types. * Declarations:: Type declarations and variables. -- cgit v1.1 From 6bc18203dd2a696cdfcd9d45eae3b9cce7b08822 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 30 Jun 2021 00:16:52 +0000 Subject: Daily bump. --- gcc/ChangeLog | 139 ++++++++++++++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/ada/ChangeLog | 241 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/cp/ChangeLog | 5 + gcc/go/ChangeLog | 7 ++ gcc/testsuite/ChangeLog | 25 +++++ 6 files changed, 418 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8e3401..52d2397 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,142 @@ +2021-06-29 Sergei Trofimovich + + * doc/generic.texi: Fix s/net yet/not yet/ typo. + +2021-06-29 Andrew MacLeod + + PR tree-optimization/101254 + * range-op.cc (operator_minus::op1_op2_relation_effect): Check for + wrapping/non-wrapping when setting the result range. + +2021-06-29 Andrew MacLeod + + * value-query.cc (gimple_range_global): Allow phis. + +2021-06-29 Andrew MacLeod + + * vr-values.c (vr_values::vrp_stmt_computes_nonzero): Use stmt. + (simplify_using_ranges::op_with_boolean_value_range_p): Add a + statement for location context. + (check_for_binary_op_overflow): Ditto. + (simplify_using_ranges::get_vr_for_comparison): Ditto. + (simplify_using_ranges::compare_name_with_value): Ditto. + (simplify_using_ranges::compare_names): Ditto. + (vrp_evaluate_conditional_warnv_with_ops_using_ranges): Ditto. + (simplify_using_ranges::simplify_truth_ops_using_ranges): Ditto. + (simplify_using_ranges::simplify_min_or_max_using_ranges): Ditto. + (simplify_using_ranges::simplify_internal_call_using_ranges): Ditto. + (simplify_using_ranges::two_valued_val_range_p): Ditto. + (simplify_using_ranges::simplify): Ditto. + * vr-values.h: Adjust prototypes. + +2021-06-29 Uroš Bizjak + + PR target/95046 + * config/i386/mmx.md (vec_addsubv2sf3): New insn pattern. + +2021-06-29 Julian Brown + + * config/gcn/gcn.c (gcn_init_libfuncs): New function. + (TARGET_INIT_LIBFUNCS): Define target hook using above function. + * config/gcn/gcn.h (UNITS_PER_WORD): Define to 8 for IN_LIBGCC2, 4 + otherwise. + (LIBGCC2_UNITS_PER_WORD, BITS_PER_WORD): Remove definitions. + (MAX_FIXED_MODE_SIZE): Change to 128. + +2021-06-29 Julian Brown + + * config/gcn/gcn.md (UNSPEC_FLBIT_INT): New unspec constant. + (s_mnemonic): Add clrsb. + (gcn_flbit_int): Add insn pattern for SImode/DImode. + (clrsb2): Add expander for SImode/DImode. + +2021-06-29 Julian Brown + + * config/gcn/gcn.md (mulsidi3, mulsidi3_reg, mulsidi3_imm, + muldi3): Add patterns. + +2021-06-29 Julian Brown + + * config/gcn/gcn.md (mulsi3_highpart): Change to expander. + (mulsi3_highpart_reg, mulsi3_highpart_imm): New patterns. + +2021-06-29 Julian Brown + + * config/gcn/gcn.md (mulsi3): Make s_mulk_i32 variant clobber SCC. + +2021-06-29 Joseph Myers + + * btfout.c, ctfout.c: Include "memmodel.h". + +2021-06-29 Tobias Burnus + + * gcc.c (check_offload_target_name): Cast len argument to + %q.*s to 'int'; avoid -Wstringop-truncation warning. + +2021-06-29 Richard Biener + + * tree-vect-slp.c (vect_optimize_slp): Forward propagate + to "any" permute nodes and relax "any" permute proapgation + during iterative backward propagation. + +2021-06-29 Tobias Burnus + + PR other/67300 + * common.opt (-foffload=): Update description. + (-foffload-options=): New. + * doc/invoke.texi (C Language Options): Document + -foffload and -foffload-options. + * gcc.c (check_offload_target_name): New, split off from + handle_foffload_option. + (check_foffload_target_names): New. + (handle_foffload_option): Handle -foffload=default. + (driver_handle_option): Update for -foffload-options. + * lto-opts.c (lto_write_options): Use -foffload-options + instead of -foffload. + * lto-wrapper.c (merge_and_complain, append_offload_options): + Likewise. + * opts.c (common_handle_option): Likewise. + +2021-06-29 Tobias Burnus + + * doc/invoke.texi (C Language Options): Sort options + alphabetically in optlist and also the description itself. + Remove leftover -fallow-single-precision from and add missing + -fgnu-tm to the optlist. + +2021-06-29 Richard Biener + + * tree-vect-slp.c (slpg_vertex::visited): Remove. + (vect_slp_perms_eq): Handle -1 permutes. + (vect_optimize_slp): Rewrite permute propagation. + +2021-06-29 Jakub Jelinek + + PR c++/101210 + * match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't + perform the optimization in GENERIC when sanitizing and x has a + reference type. + +2021-06-29 Richard Biener + + PR tree-optimization/101242 + * tree-vect-slp.c (vect_slp_build_vertices): Force-add + PHIs with not represented initial values as leafs. + +2021-06-29 Jan-Benedict Glaw + + * config/pdp11/pdp11.h (ASM_OUTPUT_SKIP): Fix signedness warning. + * config/pdp11/pdp11.c (pdp11_asm_print_operand_punct_valid_p): Remove + "register" keyword. + (pdp11_initial_elimination_offset) Remove unused variable. + (pdp11_cmp_length) Ditto. + (pdp11_insn_cost): Ditto, and fix signedness warning. + +2021-06-29 David Edelsohn + + * btfout.c: Include tm_p.h. + * ctfout.c: Same. + 2021-06-28 Indu Bhagat * config/bpf/bpf.c (bpf_expand_prologue): Do not mark insns as diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index f814e09..80bc3a6 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20210629 +20210630 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0841a93..f07cc96 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,244 @@ +2021-06-29 Richard Kenner + + * sem_util.adb (Visit_Node): Add handling for N_Block_Statement + with declarations. + +2021-06-29 Piotr Trojanek + + * einfo-utils.adb + (Unknown_Alignment): Simply negate the Known_ counterpart. + (Unknown_Component_Bit_Offset): Likewise. + (Unknown_Esize): Likewise. + (Unknown_Normalized_First_Bit): Likewise. + (Unknown_Normalized_Position): Likewise. + (Unknown_Normalized_Position_Max): Likewise. + (Unknown_RM_Size): Likewise. + +2021-06-29 Boris Yakobowski + + * exp_ch4.adb (Expand_N_Op_Mod): Remove special case for mod -1 + in CodePeer_Mode. + +2021-06-29 Aleksandra Pasek + + * libgnat/s-objrea.adb (EM_AARCH64): New Constant. + (Initialize): Handle EM_AARCH64 case. + (Read_Address): Handle AARCH64 case. + * libgnat/s-objrea.ads (Object_Arch): Add AARCH64 record + component. + +2021-06-29 Bob Duff + + * sem_ch13.adb (Analyze_Record_Representation_Clause): Call + Set_Entity_With_Checks instead of Set_Entity, so we perform the + check for correct casing. + * style.adb (Check_Identifier): Minor comment improvement. + Cleanup overly complicated code. + +2021-06-29 Ed Schonberg + + * exp_aggr.adb (Convert_Aggr_In_Object_Decl): After expansion of + the aggregate, the expression can be removed from the + declaration, except if the object is class-wide, in which case + the aggregate provides the actual type. In other cases the + presence of the expression may lead to spurious freezing issue. + * exp_ch3.adb (Expand_N_Object_Declaration): If the expression + in the declaration is an aggregate with delayed expansion (as is + the case for objects of a limited type, or a subsequent address + specification) the aggregate must be resolved at this point. + This resolution must not include expansion, because the + expansion of the enclosing declaration will construct the + necessary aggregate expansion. + +2021-06-29 Piotr Trojanek + + * errout.ads (Adjust_Name_Case): Remove obsolete and now unused + variant. + * errout.adb (Adjust_Name_Case): Likewise; fix variant that uses + a custom buffer to also use it for names in Standard_Location. + +2021-06-29 Eric Botcazou + + * sem_ch12.adb (Freeze_Subprogram_Body): Add missing "freeze". + (Install_Body): Likewise. + +2021-06-29 Piotr Trojanek + + * adaint.c (__gnat_portable_spawn): Revert change that + introduced setting of __gnat_in_child_after_fork. + +2021-06-29 Patrick Bernardi + + * libgnarl/s-tasdeb.ads (Known_Tasks): Add Atomic_Components + aspect. + +2021-06-29 Doug Rupp + + * Makefile.rtl (x86_64-vx7r2) [EXTRA_GNATRTL_TASKING_OBJS]: Move + i-vxinco.o out of RTP runtime. + +2021-06-29 Claire Dross + + * libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable + pre and postconditions. + * libgnat/a-cfhama.ads: Likewise. + * libgnat/a-cfhase.ads: Likewise. + * libgnat/a-cfinve.ads: Likewise. + * libgnat/a-cforma.ads: Likewise. + * libgnat/a-cforse.ads: Likewise. + * libgnat/a-cofove.ads: Likewise. + +2021-06-29 Piotr Trojanek + + * sem_util.ads (Get_Fullest_View): Refill comment; remove extra + extra after period. + * sem_util.adb (Get_Fullest_View): Fix style. + +2021-06-29 Piotr Trojanek + + * sem_ch3.adb (Analyze_Declarations): Remove explicit check for + missing, because a subsequent call to Is_Empty_List will detect + them anyway. + +2021-06-29 Piotr Trojanek + + * freeze.adb (Freeze_All): Simplify by reusing + Is_Subprogram_Or_Entry. + * sem_ch11.adb (Analyze_Handled_Statement): Likewise. + +2021-06-29 Piotr Trojanek + + * sem_warn.adb (Warn_On_Overlapping_Actuals): Prevent cascaded + errors once for the subprogram call, not for every pair of + actual parameters. + +2021-06-29 Piotr Trojanek + + * sem_ch3.adb (Is_Local_Type): Simplify by reusing Scope_Within. + +2021-06-29 Gary Dismukes + + * sem_ch6.ads (Can_Override_Operator): Function declaration + moved from package body to package spec. + * sem_ch6.adb (Check_Overriding_Indicator): Now use test of + whether the subprogram's Chars is an operator name, to handle + cases of function instances whose entity is + N_Defining_Identifier rather than N_Defining_Operator_Symbol. + (Can_Override_Operator): Function declaration moved to package + spec. Now use test of whether the subprogram's Chars is an + operator name, to handle cases of function instances whose + entity is N_Defining_Identifier rather than + N_Defining_Operator_Symbol. + * sem_ch8.adb (Analyze_Renamed_Subprogram): Check for + possibility of an overridden predefined operator, and suppress + the "not overriding" message in that case. + +2021-06-29 Doug Rupp + + * Makefile.rtl: Add a new ifeq for vx7r2 shared gnatlib. + +2021-06-29 Piotr Trojanek + + * exp_attr.adb (Build_Array_VS_Func): Restore uses of + Validated_View. + (Build_Record_VS_Func): Likewise. + (Expand_N_Attribute_Reference): Likewise. + * sem_util.adb (Validated_View): Behave as an identity function + for arrays and scalars. + +2021-06-29 Bob Duff + + * atree.adb, atree.ads (Parent, Set_Parent): Assert node is + Present. + (Copy_Parent, Parent_Kind): New helper routines. + * gen_il-gen.adb: Add with clause. + * nlists.adb (Parent): Assert Parent of list is Present. + * aspects.adb, checks.adb, exp_aggr.adb, exp_ch6.adb, + exp_util.adb, lib-xref-spark_specific.adb, osint.ads, + sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb, + sem_dim.adb, sem_prag.adb, sem_res.adb, sem_util.adb, + treepr.adb: Do not call Parent and Set_Parent on the Empty node. + * libgnat/a-stwiun__shared.adb, libgnat/a-stzunb__shared.adb: + Minor: Fix typos in comments. + * einfo.ads: Minor comment update. + * sinfo-utils.ads, sinfo-utils.adb (Parent_Kind, Copy_Parent): + New functions. + +2021-06-29 Eric Botcazou + + * repinfo-input.adb (Read_JSON_Stream): Fix typo. + +2021-06-29 Eric Botcazou + + * rtsfind.ads (RE_Id): Change RE_Valid_Enumeration_Value_NN into + RE_Valid_Value_Enumeration_NN. + (RE_Unit_Table): Adjust to above renaming. + * exp_imgv.adb (Expand_Valid_Value_Attribute): Likewise. + * libgnat/s-valuen.ads (Invalid): Remove. + (Value_Enumeration_Pos): Move to... + * libgnat/s-valuen.adb (Value_Enumeration_Pos): ...here. + Return -1 instead of Invalid. + (Value_Enumeration): Compare against 0 instead of Invalid. + (Valid_Enumeration_Value): Likewise. Rename to... + (Valid_Value_Enumeration): ...this. + * libgnat/s-vaenu8.ads (Valid_Enumeration_Value_8): Rename into... + (Valid_Value_Enumeration_8): ...this. + * libgnat/s-vaen16.ads (Valid_Enumeration_Value_16): Rename into... + (Valid_Value_Enumeration_16): ...this. + * libgnat/s-vaen32.ads (Valid_Enumeration_Value_32): Rename into... + (Valid_Value_Enumeration_32): ...this. + +2021-06-29 Bob Duff + + * einfo.ads (Component_Bit_Offset, Component_Size): Update + documentation: Repinfo is the package where these negative + values are documented. + * einfo-utils.adb (Known_Component_Size, + Known_Static_Component_Size, Unknown_Component_Size): Remove + calls to Implementation_Base_Type, because Component_Size is an + Impl_Base_Type_Only field (see Gen_Entities). + * sem_ch13.ads, sem_ch13.adb (Check_Size): Do not set Esize and + RM_Size. This is unnecessary in the case of Size. For + Component_Size, it is wrong, because we would be setting the + Esize and RM_Size of the component type. + +2021-06-29 Pascal Obry + + * s-oscons-tmplt.c: Add some OS constants. + +2021-06-29 Piotr Trojanek + + * sem_util.ads (Validated_View): Fix style in comment. + * sem_util.adb (Validated_View): Rewrite in recursive style. + +2021-06-29 Eric Botcazou + + * Make-generated.in (ada/stamp-gen_il): Ignore errors from + running gen_il-main. + +2021-06-29 Richard Kenner + + * gen_il-gen-gen_entities.adb (Record_Field_Kind, + Allocatable_Kind): Add new abstract kinds. + (Constant_Or_Variable_Kind): Likewise. + (E_Constant, E_Variable, E_Loop_Parameter): Use them. + (E_Discriminant, E_Component): Likewise. + * gen_il-types.ads (type Opt_Type_Enum): Add them. + +2021-06-29 Bob Duff + + * gen_il-gen.adb (Put_C_Type_And_Subtypes): Put the correct + numbers. + * gen_il-internals.ads, gen_il-internals.adb: (Pos): Remove this + function. It was assuming that the order of the enumeration + literals in Type_Enum is the same as the order of the generated + types Node_Kind and Entity_Kind, which is not true. + +2021-06-29 Piotr Trojanek + + * exp_attr.adb (Expand_N_Attribute_Reference): Explicitly use + Validated_View for record objects. + 2021-06-28 Martin Sebor * gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3791ac4..01b29b1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2021-06-29 Jason Merrill + + * pt.c (instantiate_decl): Only consider partial specializations of + actual variable templates. + 2021-06-26 Patrick Palka PR c++/96204 diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index b6ec83c..60ebb89 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,10 @@ +2021-06-29 Ian Lance Taylor + + * go-gcc.cc (Gcc_backend::static_chain_variable): Set + DECL_NAMELESS on the new decl. + (Gcc_backend::temporary_variable): Likewise. + (Gcc_backend::function): Set DECL_NAMELESS on the result decl. + 2021-05-27 Ian Lance Taylor * gccgo.texi (Function Names): Don't HTML quote ampersand. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a80c438..51fc7ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,28 @@ +2021-06-29 Andrew MacLeod + + * gcc.dg/pr101254.c: New. + +2021-06-29 Uroš Bizjak + + PR target/95046 + * gcc.target/i386/pr95046-9.c: New test. + +2021-06-29 Richard Biener + + * gcc.dg/vect/pr67790.c: Un-XFAIL. + * gcc.dg/vect/bb-slp-71.c: New testcase. + +2021-06-29 Jakub Jelinek + + PR c++/101210 + * g++.dg/ubsan/pr101210.C: New test. + +2021-06-29 Richard Biener + + PR tree-optimization/101242 + * gcc.dg/vect/bb-slp-pr101242.c: New testcase. + * gcc.dg/vect/pr67790.c: XFAIL scan for zero VEC_PERM_EXPR. + 2021-06-28 Martin Sebor * g++.dg/uninit-pr74762.C: New test. -- cgit v1.1 From 652abe22205f268c90b3b15f28c56c030ef68a34 Mon Sep 17 00:00:00 2001 From: David Edelsohn Date: Tue, 11 May 2021 21:07:19 -0400 Subject: aix: align text CSECTs to at least 32 bytes. gcc/ChangeLog: * config/rs6000/rs6000.c (rs6000_xcoff_section_type_flags): Increase code CSECT alignment to at least 32 bytes. * config/rs6000/xcoff.h (TEXT_SECTION_ASM_OP): Add 32 byte alignment designation. --- gcc/config/rs6000/rs6000.c | 6 +++++- gcc/config/rs6000/xcoff.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 2c249e1..075c156 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-or-later /* Subroutines used for code generation on IBM RS/6000. Copyright (C) 1991-2021 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) @@ -21361,8 +21362,11 @@ rs6000_xcoff_section_type_flags (tree decl, const char *name, int reloc) flags |= SECTION_BSS; /* Align to at least UNIT size. */ - if ((flags & SECTION_CODE) != 0 || !decl || !DECL_P (decl)) + if (!decl || !DECL_P (decl)) align = MIN_UNITS_PER_WORD; + /* Align code CSECT to at least 32 bytes. */ + else if ((flags & SECTION_CODE) != 0) + align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), 32); else /* Increase alignment of large objects if not already stricter. */ align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 5ba565f..f3546fa 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-or-later /* Definitions of target machine for GNU compiler, for some generic XCOFF file format Copyright (C) 2001-2021 Free Software Foundation, Inc. @@ -249,7 +250,7 @@ #define DOUBLE_INT_ASM_OP "\t.llong\t" /* Output before instructions. */ -#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]" +#define TEXT_SECTION_ASM_OP "\t.csect .text[PR],5" /* Output before writable data. */ #define DATA_SECTION_ASM_OP \ -- cgit v1.1 From ed392e9db434898eccec81edd85323d21d555fe9 Mon Sep 17 00:00:00 2001 From: liuhongt Date: Mon, 28 Jun 2021 19:27:23 +0800 Subject: The upper bits of FIXUPIMMS{S,D} should come from src1 not dest. gcc/ChangeLog: PR target/101248 * config/i386/sse.md (avx512f_sfixupimm): Refined to .. (avx512f_sfixupimm): this. (avx512f_sfixupimm_mask"): Refined. * config/i386/subst.md (maskz_scalar): New define_subst. (maskz_scalar_name): New subst_attr. (maskz_scalar_op5): Ditto. (round_saeonly_maskz_scalar_op5): Ditto. (round_saeonly_maskz_scalar_operand5): Ditto. gcc/testsuite/ChangeLog PR target/101248 * gcc.target/i386/pr101248.c: New test. --- gcc/config/i386/sse.md | 8 +- gcc/config/i386/subst.md | 21 ++++++ gcc/testsuite/gcc.target/i386/pr101248.c | 123 +++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr101248.c (limited to 'gcc') diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index ffcc0c8..d3f5a74 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -9942,7 +9942,7 @@ DONE; }) -(define_insn "avx512f_sfixupimm" +(define_insn "avx512f_sfixupimm" [(set (match_operand:VF_128 0 "register_operand" "=v") (vec_merge:VF_128 (unspec:VF_128 @@ -9951,10 +9951,10 @@ (match_operand: 3 "" "") (match_operand:SI 4 "const_0_to_255_operand")] UNSPEC_FIXUPIMM) - (match_dup 1) + (match_dup 2) (const_int 1)))] "TARGET_AVX512F" - "vfixupimm\t{%4, %3, %2, %0|%0, %2, %3, %4}"; + "vfixupimm\t{%4, %3, %2, %0|%0, %2, %3, %4}"; [(set_attr "prefix" "evex") (set_attr "mode" "")]) @@ -9968,7 +9968,7 @@ (match_operand: 3 "" "") (match_operand:SI 4 "const_0_to_255_operand")] UNSPEC_FIXUPIMM) - (match_dup 1) + (match_dup 2) (const_int 1)) (match_dup 1) (match_operand: 5 "register_operand" "Yk")))] diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 477a898..6614e04 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -117,6 +117,25 @@ (match_operand: 3 "register_operand" "Yk"))) ]) +(define_subst_attr "maskz_scalar_name" "maskz_scalar" "" "_maskz_1") +(define_subst_attr "maskz_scalar_op5" "maskz_scalar" "" "%{%6%}%N5") + +(define_subst "maskz_scalar" + [(set (match_operand:SUBST_V 0) + (vec_merge:SUBST_V + (match_operand:SUBST_V 1) + (match_operand:SUBST_V 2) + (const_int 1)))] + "TARGET_AVX512F" + [(set (match_dup 0) + (vec_merge:SUBST_V + (vec_merge:SUBST_V + (match_dup 1) + (match_operand:SUBST_V 3 "const0_operand" "C") + (match_operand: 4 "register_operand" "Yk")) + (match_dup 2) + (const_int 1)))]) + (define_subst_attr "round_name" "round" "" "_round") (define_subst_attr "round_mask_operand2" "mask" "%R2" "%R4") (define_subst_attr "round_mask_operand3" "mask" "%R3" "%R5") @@ -163,6 +182,7 @@ (define_subst_attr "round_saeonly_mask_operand3" "mask" "%r3" "%r5") (define_subst_attr "round_saeonly_mask_operand4" "mask" "%r4" "%r6") (define_subst_attr "round_saeonly_mask_scalar_merge_operand4" "mask_scalar_merge" "%r4" "%r5") +(define_subst_attr "round_saeonly_maskz_scalar_operand5" "maskz_scalar" "%r5" "%r7") (define_subst_attr "round_saeonly_sd_mask_operand5" "sd" "%r5" "%r7") (define_subst_attr "round_saeonly_op2" "round_saeonly" "" "%r2") (define_subst_attr "round_saeonly_op3" "round_saeonly" "" "%r3") @@ -175,6 +195,7 @@ (define_subst_attr "round_saeonly_mask_op4" "round_saeonly" "" "") (define_subst_attr "round_saeonly_mask_scalar_merge_op4" "round_saeonly" "" "") (define_subst_attr "round_saeonly_sd_mask_op5" "round_saeonly" "" "") +(define_subst_attr "round_saeonly_maskz_scalar_op5" "round_saeonly" "" "") (define_subst_attr "round_saeonly_mask_arg3" "round_saeonly" "" ", operands[]") (define_subst_attr "round_saeonly_constraint" "round_saeonly" "vm" "v") (define_subst_attr "round_saeonly_constraint2" "round_saeonly" "m" "v") diff --git a/gcc/testsuite/gcc.target/i386/pr101248.c b/gcc/testsuite/gcc.target/i386/pr101248.c new file mode 100644 index 0000000..f5ac94f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101248.c @@ -0,0 +1,123 @@ +/* PR target/101248 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512vl -std=gnu99" } */ +/* { dg-require-effective-target avx512vl } */ +/* { dg-require-effective-target c99_runtime } */ + +#define AVX512VL +#define AVX512F_LEN 128 +#define AVX512F_LEN_HALF 128 + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" +#include "math_m_pi.h" +#include "float.h" + + +static void +CALC (double *r, double dest, double src, long long tbl) +{ + switch (tbl & 0xf) + { + case 0: + *r = dest; + break; + case 1: + *r = src; + break; + case 2: + *r = signbit (src) ? -NAN : NAN; + break; + case 3: + *r = -NAN; + break; + case 4: + *r = -INFINITY; + break; + case 5: + *r = INFINITY; + break; + case 6: + *r = signbit (src) ? -INFINITY : INFINITY; + break; + case 7: + *r = 1.0 / -INFINITY; + break; + case 8: + *r = 0.0; + break; + case 9: + *r = -1.0; + break; + case 10: + *r = 1.0; + break; + case 11: + *r = 1.0 / 2.0; + break; + case 12: + *r = 90.0; + break; + case 13: + *r = M_PI_2; + break; + case 14: + *r = DBL_MAX; + break; + case 15: + *r = -DBL_MAX; + break; + default: + abort (); + } +} + +void +TEST (void) +{ + int i, j; + UNION_TYPE (AVX512F_LEN, d) res1, res2, res3, s1; + UNION_TYPE (AVX512F_LEN, i_q) s2; + double res_ref[SIZE]; + + + float vals[2] = { -10, 10 }; + int controls[8] = {0, 0x11111111, 0x77777777, 0x88888888, + 0x99999999, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc}; + + MASK_TYPE mask = 1; + + for (i = 0; i < 2; i++) + { + for (j = 0; j < SIZE; j++) + { + s1.a[j] = vals[i]; + s2.a[j] = controls[j]; + res1.a[j] = DEFAULT_VALUE; + res2.a[j] = DEFAULT_VALUE; + res3.a[j] = DEFAULT_VALUE; + + CALC (&res_ref[j], res1.a[j], s1.a[j], s2.a[j]); + } + + res1.x = INTRINSIC (_fixupimm_pd) (res1.x, s1.x, s2.x, 0); + res2.x = INTRINSIC (_mask_fixupimm_pd) (res2.x, mask, s1.x, s2.x, 0); + res3.x = INTRINSIC (_maskz_fixupimm_pd) (mask, res3.x, s1.x, s2.x, 0); + + if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref)) + abort (); + + MASK_MERGE(d) (res_ref, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref)) + abort (); + MASK_ZERO(d) (res_ref, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref)) + abort (); + } +} + +void +test_256 (void) +{} -- cgit v1.1