From: Richard Biener Date: Fri, 12 Jul 2019 14:42:14 +0000 (+0000) Subject: Backport PRs 90369, 90900, 90914, 90972, 90982, 91004, 91062, 91063 X-Git-Tag: releases/gcc-9.2.0~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f2cfe108f75de49a331ba27f01d509e2c8c1c70;p=thirdparty%2Fgcc.git Backport PRs 90369, 90900, 90914, 90972, 90982, 91004, 91062, 91063 2019-07-12 Richard Biener Backport from mainline 2019-07-04 Jakub Jelinek PR tree-optimization/91063 * tree-vect-stmts.c (vect_init_vector): Call gsi_remove to remove stmt from stmts sequence before calling vect_init_vector_1. Formatting fix. * gcc.dg/gomp/pr91063.c: New test. 2019-07-04 Richard Biener PR ipa/91062 * tree-pass.h (execute_all_ipa_transforms): Add a flag parameter whether to disable GC collection. * passes.c (execute_one_ipa_transform_pass): Likewise, and honor it. (execute_all_ipa_transforms): Likewise and pass it down. * cgraph.c (cgraph_node::get_body): Do not invoke garbage collection from applying IPA transforms. * cgraphunit.c (cgraph_node::expand): Allow garbage collection from applying IPA transforms. 2019-06-27 Richard Biener PR testsuite/91004 * g++.dg/torture/pr34850.C: Fix overly reduced testcase. 2019-06-26 Richard Biener PR ipa/90982 * tree-inline.c (remap_ssa_name): Copy SSA range info. * g++.dg/torture/pr90982.C: New testcase. 2019-06-24 Richard Biener PR tree-optimization/90972 * tree-vect-stmts.c (vect_init_vector): Handle CONSTANT_CLASS_P in common code, dealing with STRING_CST properly. * gcc.dg/torture/pr90972.c: New testcase. 2019-06-21 Richard Biener PR debug/90914 * dwarf2out.c (prune_unused_types_walk): Always consider function-local extern declarations as used. * g++.dg/debug/pr90914.C: New testcase. 2019-06-18 Richard Biener PR debug/90900 * cfgexpand.c (expand_debug_expr): Treat NOTE_P DECL_RTL as if optimized away. * gcc.dg/gomp/pr90900.c: New testcase. 2019-05-07 Richard Biener PR lto/90369 * lto-wrapper.c (debug_objcopy): Use the original filename including archive offset for the filename used for -save-temps. From-SVN: r273446 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8539770b5436..782ab90f5574 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,55 @@ +2019-07-12 Richard Biener + + Backport from mainline + 2019-07-04 Jakub Jelinek + + PR tree-optimization/91063 + * tree-vect-stmts.c (vect_init_vector): Call gsi_remove to remove + stmt from stmts sequence before calling vect_init_vector_1. + Formatting fix. + + 2019-07-04 Richard Biener + + PR ipa/91062 + * tree-pass.h (execute_all_ipa_transforms): Add a flag + parameter whether to disable GC collection. + * passes.c (execute_one_ipa_transform_pass): Likewise, and + honor it. + (execute_all_ipa_transforms): Likewise and pass it down. + * cgraph.c (cgraph_node::get_body): Do not invoke garbage + collection from applying IPA transforms. + * cgraphunit.c (cgraph_node::expand): Allow garbage collection + from applying IPA transforms. + + 2019-06-26 Richard Biener + + PR ipa/90982 + * tree-inline.c (remap_ssa_name): Copy SSA range info. + + 2019-06-24 Richard Biener + + PR tree-optimization/90972 + * tree-vect-stmts.c (vect_init_vector): Handle CONSTANT_CLASS_P + in common code, dealing with STRING_CST properly. + + 2019-06-21 Richard Biener + + PR debug/90914 + * dwarf2out.c (prune_unused_types_walk): Always consider + function-local extern declarations as used. + + 2019-06-18 Richard Biener + + PR debug/90900 + * cfgexpand.c (expand_debug_expr): Treat NOTE_P DECL_RTL + as if optimized away. + + 2019-05-07 Richard Biener + + PR lto/90369 + * lto-wrapper.c (debug_objcopy): Use the original filename + including archive offset for the filename used for -save-temps. + 2019-07-12 Eric Botcazou PR rtl-optimization/91136 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 518d71c74c82..e252975f546c 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4369,7 +4369,11 @@ expand_debug_expr (tree exp) op0 = DECL_RTL_IF_SET (exp); /* This decl was probably optimized away. */ - if (!op0) + if (!op0 + /* At least label RTXen are sometimes replaced by + NOTE_INSN_DELETED_LABEL. Any notes here are not + handled by copy_rtx. */ + || NOTE_P (op0)) { if (!VAR_P (exp) || DECL_EXTERNAL (exp) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index b1b0b4c42d5c..db4c9c747b9e 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3607,7 +3607,7 @@ cgraph_node::get_body (void) set_dump_file (NULL); push_cfun (DECL_STRUCT_FUNCTION (decl)); - execute_all_ipa_transforms (); + execute_all_ipa_transforms (true); cgraph_edge::rebuild_edges (); free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 8bfbd0bb12f3..4a27867b82cb 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2188,7 +2188,7 @@ cgraph_node::expand (void) bitmap_obstack_initialize (®_obstack); /* FIXME, only at RTL generation*/ - execute_all_ipa_transforms (); + execute_all_ipa_transforms (false); /* Perform all tree transforms and optimizations. */ diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 54390ea533f8..1cec00f2b857 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -29419,9 +29419,16 @@ prune_unused_types_walk (dw_die_ref die) break; /* premark_used_variables marks external variables --- don't mark - them here. */ + them here. But function-local externals are always considered + used. */ if (get_AT (die, DW_AT_external)) - return; + { + for (c = die->die_parent; c; c = c->die_parent) + if (c->die_tag == DW_TAG_subprogram) + break; + if (!c) + return; + } } /* FALLTHROUGH */ diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 56eea90ac8c1..ac9714940549 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1044,6 +1044,7 @@ debug_objcopy (const char *infile, bool rename) int err; const char *p; + const char *orig_infile = infile; off_t inoff = 0; long loffset; int consumed; @@ -1080,9 +1081,9 @@ debug_objcopy (const char *infile, bool rename) if (save_temps) { - outfile = (char *) xmalloc (strlen (infile) + outfile = (char *) xmalloc (strlen (orig_infile) + sizeof (".debug.temp.o") + 1); - strcpy (outfile, infile); + strcpy (outfile, orig_infile); strcat (outfile, ".debug.temp.o"); } else diff --git a/gcc/passes.c b/gcc/passes.c index 02561f8bf189..d8d479a1c17a 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2196,7 +2196,7 @@ execute_ipa_summary_passes (ipa_opt_pass_d *ipa_pass) static void execute_one_ipa_transform_pass (struct cgraph_node *node, - ipa_opt_pass_d *ipa_pass) + ipa_opt_pass_d *ipa_pass, bool do_not_collect) { opt_pass *pass = ipa_pass; unsigned int todo_after = 0; @@ -2242,14 +2242,14 @@ execute_one_ipa_transform_pass (struct cgraph_node *node, redirect_edge_var_map_empty (); /* Signal this is a suitable GC collection point. */ - if (!(todo_after & TODO_do_not_ggc_collect)) + if (!do_not_collect && !(todo_after & TODO_do_not_ggc_collect)) ggc_collect (); } /* For the current function, execute all ipa transforms. */ void -execute_all_ipa_transforms (void) +execute_all_ipa_transforms (bool do_not_collect) { struct cgraph_node *node; if (!cfun) @@ -2261,7 +2261,8 @@ execute_all_ipa_transforms (void) unsigned int i; for (i = 0; i < node->ipa_transforms_to_apply.length (); i++) - execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i]); + execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i], + do_not_collect); node->ipa_transforms_to_apply.release (); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c0f3a215a554..7510eb2ef994 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,36 @@ +2019-07-12 Richard Biener + + Backport from mainline + 2019-07-04 Jakub Jelinek + + PR tree-optimization/91063 + * gcc.dg/gomp/pr91063.c: New test. + + 2019-06-27 Richard Biener + + PR testsuite/91004 + * g++.dg/torture/pr34850.C: Fix overly reduced testcase. + + 2019-06-26 Richard Biener + + PR ipa/90982 + * g++.dg/torture/pr90982.C: New testcase. + + 2019-06-24 Richard Biener + + PR tree-optimization/90972 + * gcc.dg/torture/pr90972.c: New testcase. + + 2019-06-21 Richard Biener + + PR debug/90914 + * g++.dg/debug/pr90914.C: New testcase. + + 2019-06-18 Richard Biener + + PR debug/90900 + * gcc.dg/gomp/pr90900.c: New testcase. + 2019-07-11 UroÅ¡ Bizjak Backported from mainline diff --git a/gcc/testsuite/g++.dg/debug/pr90914.C b/gcc/testsuite/g++.dg/debug/pr90914.C new file mode 100644 index 000000000000..3681d58cdf34 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr90914.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// { dg-additional-options "-feliminate-unused-debug-symbols" } + +template class A; +void f () +{ + extern A b; +} diff --git a/gcc/testsuite/g++.dg/torture/pr34850.C b/gcc/testsuite/g++.dg/torture/pr34850.C index e41620b739d7..60a6c6ae57dc 100644 --- a/gcc/testsuite/g++.dg/torture/pr34850.C +++ b/gcc/testsuite/g++.dg/torture/pr34850.C @@ -13,7 +13,8 @@ extern "C" { extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) void * memset (void *__dest, int __ch, size_t __len) throw () { if (__builtin_constant_p (__len) && __len == 0) - __warn_memset_zero_len (); + __warn_memset_zero_len (); + return __dest; } } inline void clear_mem(void* ptr, u32bit n) { diff --git a/gcc/testsuite/g++.dg/torture/pr90982.C b/gcc/testsuite/g++.dg/torture/pr90982.C new file mode 100644 index 000000000000..8edbb7ca6c06 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr90982.C @@ -0,0 +1,23 @@ +// { dg-do compile } + +template struct S +{ + long c[n]; + void f (S d) + { + for (int i = 2;; i++) + c[i] &= d.c[i]; + } +}; + +template struct T:S +{ + void operator &= (T d) + { this -> f (d); } +}; + +void g (T<192> &d) +{ + T<192> v; + d &= v; +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr90900.c b/gcc/testsuite/gcc.dg/gomp/pr90900.c new file mode 100644 index 000000000000..d4c5d7d5bef3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr90900.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp -g" } */ + +void f (int a) +{ + void *x = &&lab; +#pragma omp parallel + if (a) + { lab: __builtin_unreachable(); } + x; +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr91063.c b/gcc/testsuite/gcc.dg/gomp/pr91063.c new file mode 100644 index 000000000000..32938f301b32 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr91063.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/91063 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp-simd" } */ +/* { dg-additional-options "-mavx512f" { target { i?86-*-* x86_64-*-* } } } */ + +struct S { void *s; }; + +int +foo (struct S *x) +{ + int r = 0; + int i; +#pragma omp simd reduction (+ : r) + for (i = 0; i < 64; ++i) + r += (int) (x->s != 0); + return r; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr90972.c b/gcc/testsuite/gcc.dg/torture/pr90972.c new file mode 100644 index 000000000000..24f99b0ebb7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr90972.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mcpu=power8" { target powerpc*-*-* } } */ + +long f; +void a(); +void *g() +{ + char h[] = {}, j[] = {}, k[] = {}, l[] = {}, m[] = {}, n[] = {}, o[] = {}, + q[] = {}, r[] = {}; + static const char i[] = {6, 0}; + const char *nops[] = {h, i, j, k, l, m, n, o, q, r}; + long s = 2; + void *fill = a; + char *p = fill; + while (f) { + void *b = p; + const void *c = nops[1]; + long d = s, e = __builtin_object_size(b, 0); + __builtin___memcpy_chk(b, c, d, e); + p += s; + f -= s; + } + return fill; +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 7b62ff8a566e..9fe8f26a7719 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -258,6 +258,11 @@ remap_ssa_name (tree name, copy_body_data *id) struct ptr_info_def *new_pi = get_ptr_info (new_tree); new_pi->pt = pi->pt; } + /* So can range-info. */ + if (!POINTER_TYPE_P (TREE_TYPE (name)) + && SSA_NAME_RANGE_INFO (name)) + duplicate_ssa_name_range_info (new_tree, SSA_NAME_RANGE_TYPE (name), + SSA_NAME_RANGE_INFO (name)); return new_tree; } @@ -291,6 +296,11 @@ remap_ssa_name (tree name, copy_body_data *id) struct ptr_info_def *new_pi = get_ptr_info (new_tree); new_pi->pt = pi->pt; } + /* So can range-info. */ + if (!POINTER_TYPE_P (TREE_TYPE (name)) + && SSA_NAME_RANGE_INFO (name)) + duplicate_ssa_name_range_info (new_tree, SSA_NAME_RANGE_TYPE (name), + SSA_NAME_RANGE_INFO (name)); if (SSA_NAME_IS_DEFAULT_DEF (name)) { /* By inlining function having uninitialized variable, we might diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 3a0b3805d24d..b27dbdd0cb7d 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -632,7 +632,7 @@ extern bool execute_one_pass (opt_pass *); extern void execute_pass_list (function *, opt_pass *); extern void execute_ipa_pass_list (opt_pass *); extern void execute_ipa_summary_passes (ipa_opt_pass_d *); -extern void execute_all_ipa_transforms (void); +extern void execute_all_ipa_transforms (bool); extern void execute_all_ipa_stmt_fixups (struct cgraph_node *, gimple **); extern bool pass_init_dump_file (opt_pass *); extern void pass_fini_dump_file (opt_pass *); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index a5fa8ec3a86f..17769c88b6a0 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1480,27 +1480,30 @@ vect_init_vector (stmt_vec_info stmt_info, tree val, tree type, val = new_temp; } } - else if (CONSTANT_CLASS_P (val)) - val = fold_convert (TREE_TYPE (type), val); else { - new_temp = make_ssa_name (TREE_TYPE (type)); + gimple_seq stmts = NULL; if (! INTEGRAL_TYPE_P (TREE_TYPE (val))) - init_stmt = gimple_build_assign (new_temp, - fold_build1 (VIEW_CONVERT_EXPR, - TREE_TYPE (type), - val)); + val = gimple_build (&stmts, VIEW_CONVERT_EXPR, + TREE_TYPE (type), val); else - init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val); - vect_init_vector_1 (stmt_info, init_stmt, gsi); - val = new_temp; + /* ??? Condition vectorization expects us to do + promotion of invariant/external defs. */ + val = gimple_convert (&stmts, TREE_TYPE (type), val); + for (gimple_stmt_iterator gsi2 = gsi_start (stmts); + !gsi_end_p (gsi2); ) + { + init_stmt = gsi_stmt (gsi2); + gsi_remove (&gsi2, false); + vect_init_vector_1 (stmt_info, init_stmt, gsi); + } } } val = build_vector_from_val (type, val); } new_temp = vect_get_new_ssa_name (type, vect_simple_var, "cst_"); - init_stmt = gimple_build_assign (new_temp, val); + init_stmt = gimple_build_assign (new_temp, val); vect_init_vector_1 (stmt_info, init_stmt, gsi); return new_temp; }