aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-02-10 00:22:43 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-02-10 00:22:43 +0100
commit6724f8a61d49dfdfaa11995765b85ee170e48ac7 (patch)
tree1bcb77e081a3462478d62cb53e68a5a3c07df260 /gcc/omp-low.c
parent5ca8e744641e1b03cc6e4cdbc46e7ece0750240d (diff)
downloadgcc-6724f8a61d49dfdfaa11995765b85ee170e48ac7.zip
gcc-6724f8a61d49dfdfaa11995765b85ee170e48ac7.tar.gz
gcc-6724f8a61d49dfdfaa11995765b85ee170e48ac7.tar.bz2
re PR sanitizer/83987 (ICE with OpenMP, sanitizer and virtual bases)
PR sanitizer/83987 * omp-low.c (maybe_remove_omp_member_access_dummy_vars, remove_member_access_dummy_vars): New functions. (lower_omp_for, lower_omp_taskreg, lower_omp_target, lower_omp_1, execute_lower_omp): Use them. * tree.c (cp_free_lang_data): Revert 2018-01-23 change. * g++.dg/ubsan/pr83987-2.C: New test. From-SVN: r257545
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ebbf88e..d8588b9 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3208,6 +3208,43 @@ scan_omp (gimple_seq *body_p, omp_context *ctx)
/* Re-gimplification and code generation routines. */
+/* Remove omp_member_access_dummy_var variables from gimple_bind_vars
+ of BIND if in a method. */
+
+static void
+maybe_remove_omp_member_access_dummy_vars (gbind *bind)
+{
+ if (DECL_ARGUMENTS (current_function_decl)
+ && DECL_ARTIFICIAL (DECL_ARGUMENTS (current_function_decl))
+ && (TREE_CODE (TREE_TYPE (DECL_ARGUMENTS (current_function_decl)))
+ == POINTER_TYPE))
+ {
+ tree vars = gimple_bind_vars (bind);
+ for (tree *pvar = &vars; *pvar; )
+ if (omp_member_access_dummy_var (*pvar))
+ *pvar = DECL_CHAIN (*pvar);
+ else
+ pvar = &DECL_CHAIN (*pvar);
+ gimple_bind_set_vars (bind, vars);
+ }
+}
+
+/* Remove omp_member_access_dummy_var variables from BLOCK_VARS of
+ block and its subblocks. */
+
+static void
+remove_member_access_dummy_vars (tree block)
+{
+ for (tree *pvar = &BLOCK_VARS (block); *pvar; )
+ if (omp_member_access_dummy_var (*pvar))
+ *pvar = DECL_CHAIN (*pvar);
+ else
+ pvar = &DECL_CHAIN (*pvar);
+
+ for (block = BLOCK_SUBBLOCKS (block); block; block = BLOCK_CHAIN (block))
+ remove_member_access_dummy_vars (block);
+}
+
/* If a context was created for STMT when it was scanned, return it. */
static omp_context *
@@ -6961,6 +6998,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
pop_gimplify_context (new_stmt);
gimple_bind_append_vars (new_stmt, ctx->block_vars);
+ maybe_remove_omp_member_access_dummy_vars (new_stmt);
BLOCK_VARS (block) = gimple_bind_vars (new_stmt);
if (BLOCK_VARS (block))
TREE_USED (block) = 1;
@@ -7413,6 +7451,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
/* Declare all the variables created by mapping and the variables
declared in the scope of the parallel body. */
record_vars_into (ctx->block_vars, child_fn);
+ maybe_remove_omp_member_access_dummy_vars (par_bind);
record_vars_into (gimple_bind_vars (par_bind), child_fn);
if (ctx->record_type)
@@ -7781,6 +7820,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
/* Declare all the variables created by mapping and the variables
declared in the scope of the target body. */
record_vars_into (ctx->block_vars, child_fn);
+ maybe_remove_omp_member_access_dummy_vars (tgt_bind);
record_vars_into (gimple_bind_vars (tgt_bind), child_fn);
}
@@ -8772,6 +8812,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
break;
case GIMPLE_BIND:
lower_omp (gimple_bind_body_ptr (as_a <gbind *> (stmt)), ctx);
+ maybe_remove_omp_member_access_dummy_vars (as_a <gbind *> (stmt));
break;
case GIMPLE_OMP_PARALLEL:
case GIMPLE_OMP_TASK:
@@ -8976,6 +9017,16 @@ execute_lower_omp (void)
all_contexts = NULL;
}
BITMAP_FREE (task_shared_vars);
+
+ /* If current function is a method, remove artificial dummy VAR_DECL created
+ for non-static data member privatization, they aren't needed for
+ debuginfo nor anything else, have been already replaced everywhere in the
+ IL and cause problems with LTO. */
+ if (DECL_ARGUMENTS (current_function_decl)
+ && DECL_ARTIFICIAL (DECL_ARGUMENTS (current_function_decl))
+ && (TREE_CODE (TREE_TYPE (DECL_ARGUMENTS (current_function_decl)))
+ == POINTER_TYPE))
+ remove_member_access_dummy_vars (DECL_INITIAL (current_function_decl));
return 0;
}