aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-05-22 20:54:54 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-05-22 20:54:54 +0200
commit655e52652b2af93ae6508dfc2026c6903bf391de (patch)
treef78ceed96325d47d3bf86d478392268ca65be633 /gcc/omp-low.c
parente9e2ef9f2f1e037e0f3bc4990947e242106e43b9 (diff)
downloadgcc-655e52652b2af93ae6508dfc2026c6903bf391de.zip
gcc-655e52652b2af93ae6508dfc2026c6903bf391de.tar.gz
gcc-655e52652b2af93ae6508dfc2026c6903bf391de.tar.bz2
re PR middle-end/80809 (Multi-free error for variable size array used within OpenMP task)
PR middle-end/80809 * omp-low.c (finish_taskreg_remap): New function. (finish_taskreg_scan): If unit size of ctx->record_type is non-constant, unshare the size expression and replace decls in it with possible outer var refs. * testsuite/libgomp.c/pr80809-2.c: New test. * testsuite/libgomp.c/pr80809-3.c: New test. From-SVN: r248346
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 26e6586..968075c 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1913,6 +1913,29 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
}
}
+/* Helper function for finish_taskreg_scan, called through walk_tree.
+ If maybe_lookup_decl_in_outer_context returns non-NULL for some
+ tree, replace it in the expression. */
+
+static tree
+finish_taskreg_remap (tree *tp, int *walk_subtrees, void *data)
+{
+ if (VAR_P (*tp))
+ {
+ omp_context *ctx = (omp_context *) data;
+ tree t = maybe_lookup_decl_in_outer_ctx (*tp, ctx);
+ if (t != *tp)
+ {
+ if (DECL_HAS_VALUE_EXPR_P (t))
+ t = unshare_expr (DECL_VALUE_EXPR (t));
+ *tp = t;
+ }
+ *walk_subtrees = 0;
+ }
+ else if (IS_TYPE_OR_DECL_P (*tp))
+ *walk_subtrees = 0;
+ return NULL_TREE;
+}
/* If any decls have been made addressable during scan_omp,
adjust their fields if needed, and layout record types
@@ -2033,6 +2056,11 @@ finish_taskreg_scan (omp_context *ctx)
layout_type (ctx->srecord_type);
tree t = fold_convert_loc (loc, long_integer_type_node,
TYPE_SIZE_UNIT (ctx->record_type));
+ if (TREE_CODE (t) != INTEGER_CST)
+ {
+ t = unshare_expr (t);
+ walk_tree (&t, finish_taskreg_remap, ctx, NULL);
+ }
gimple_omp_task_set_arg_size (ctx->stmt, t);
t = build_int_cst (long_integer_type_node,
TYPE_ALIGN_UNIT (ctx->record_type));