From 710ee218547fc4ecbcba7a0f1dff73ce51fffb7b Mon Sep 17 00:00:00 2001 From: Cesar Philippidis Date: Fri, 24 Jul 2015 07:38:43 -0700 Subject: [PATCH] re PR libgomp/66714 (ICE in loc_list_from_tree with -g) PR 66714 gcc/ * tree-cfg.c (struct replace_decls_d): New struct. (replace_block_vars_by_duplicates_1): New function. (replace_block_vars_by_duplicates): Use it to replace the decls in the value exprs by duplicates. libgomp/ * testsuite/libgomp.c/pr66714.c: New test. From-SVN: r226160 --- gcc/ChangeLog | 8 ++++++ gcc/tree-cfg.c | 39 ++++++++++++++++++++++++++- libgomp/ChangeLog | 4 +++ libgomp/testsuite/libgomp.c/pr66714.c | 17 ++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 libgomp/testsuite/libgomp.c/pr66714.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dac9e4a3afd..87375082ca0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-07-24 Cesar Philippidis + + PR 66714 + * tree-cfg.c (struct replace_decls_d): New struct. + (replace_block_vars_by_duplicates_1): New function. + (replace_block_vars_by_duplicates): Use it to replace the decls + in the value exprs by duplicates. + 2015-07-24 Szabolcs Nagy * config/aarch64/aarch64-elf-raw.h (LINK_SPEC): Handle -h, -static, diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 66f999e3c42..e26454a617d 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -71,6 +71,7 @@ along with GCC; see the file COPYING3. If not see #include "omp-low.h" #include "tree-cfgcleanup.h" #include "wide-int-print.h" +#include "gimplify.h" /* This file contains functions for building the Control Flow Graph (CFG) for a function tree. */ @@ -109,6 +110,13 @@ struct cfg_stats_d static struct cfg_stats_d cfg_stats; +/* Data to pass to replace_block_vars_by_duplicates_1. */ +struct replace_decls_d +{ + hash_map *vars_map; + tree to_context; +}; + /* Hash table to store last discriminator assigned for each locus. */ struct locus_discrim_map { @@ -6853,6 +6861,31 @@ new_label_mapper (tree decl, void *data) return m->to; } +/* Tree walker to replace the decls used inside value expressions by + duplicates. */ + +static tree +replace_block_vars_by_duplicates_1 (tree *tp, int *walk_subtrees, void *data) +{ + struct replace_decls_d *rd = (struct replace_decls_d *)data; + + switch (TREE_CODE (*tp)) + { + case VAR_DECL: + case PARM_DECL: + case RESULT_DECL: + replace_by_duplicate_decl (tp, rd->vars_map, rd->to_context); + break; + default: + break; + } + + if (IS_TYPE_OR_DECL_P (*tp)) + *walk_subtrees = false; + + return NULL; +} + /* Change DECL_CONTEXT of all BLOCK_VARS in block, including subblocks. */ @@ -6872,7 +6905,11 @@ replace_block_vars_by_duplicates (tree block, hash_map *vars_map, { if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*tp)) { - SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (*tp)); + tree x = DECL_VALUE_EXPR (*tp); + struct replace_decls_d rd = { vars_map, to_context }; + unshare_expr (x); + walk_tree (&x, replace_block_vars_by_duplicates_1, &rd, NULL); + SET_DECL_VALUE_EXPR (t, x); DECL_HAS_VALUE_EXPR_P (t) = 1; } DECL_CHAIN (t) = DECL_CHAIN (*tp); diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index d8d37cf7329..d2189928577 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2015-07-24 Cesar Philippidis + + * testsuite/libgomp.c/pr66714.c: New test. + 2015-07-22 Maxim Blumenthal PR libgomp/66950 diff --git a/libgomp/testsuite/libgomp.c/pr66714.c b/libgomp/testsuite/libgomp.c/pr66714.c new file mode 100644 index 00000000000..c9af4a9b4a2 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr66714.c @@ -0,0 +1,17 @@ +/* { dg-do "compile" } */ +/* { dg-additional-options "--param ggc-min-expand=0" } */ +/* { dg-additional-options "--param ggc-min-heapsize=0" } */ +/* { dg-additional-options "-g" } */ + +/* Minimized from on target-2.c. */ + +void +fn3 (int x) +{ + double b[3 * x]; + int i; +#pragma omp target +#pragma omp parallel for + for (i = 0; i < x; i++) + b[i] += 1; +}