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
This commit is contained in:
parent
5ca8e74464
commit
6724f8a61d
6 changed files with 91 additions and 10 deletions
|
@ -1,5 +1,11 @@
|
|||
2018-02-10 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
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.
|
||||
|
||||
PR rtl-optimization/84308
|
||||
* shrink-wrap.c (spread_components): Release todo vector.
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2018-02-10 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR sanitizer/83987
|
||||
* tree.c (cp_free_lang_data): Revert 2018-01-23 change.
|
||||
|
||||
2018-02-09 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/81917 - ICE with void_t and partial specialization.
|
||||
|
|
|
@ -5273,16 +5273,6 @@ cp_free_lang_data (tree t)
|
|||
/* We do not need the leftover chaining of namespaces from the
|
||||
binding level. */
|
||||
DECL_CHAIN (t) = NULL_TREE;
|
||||
/* Set DECL_VALUE_EXPRs of OpenMP privatized member artificial
|
||||
decls to error_mark_node. These are DECL_IGNORED_P and after
|
||||
OpenMP lowering they aren't useful anymore. Clearing DECL_VALUE_EXPR
|
||||
doesn't work, as expansion could then consider them as something
|
||||
to be expanded. */
|
||||
if (VAR_P (t)
|
||||
&& DECL_LANG_SPECIFIC (t)
|
||||
&& DECL_OMP_PRIVATIZED_MEMBER (t)
|
||||
&& DECL_IGNORED_P (t))
|
||||
SET_DECL_VALUE_EXPR (t, error_mark_node);
|
||||
}
|
||||
|
||||
/* Stub for c-common. Please keep in sync with c-decl.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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2018-02-10 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR sanitizer/83987
|
||||
* g++.dg/ubsan/pr83987-2.C: New test.
|
||||
|
||||
2018-02-09 Peter Bergner <bergner@vnet.ibm.com>
|
||||
|
||||
PR target/83926
|
||||
|
|
24
gcc/testsuite/g++.dg/ubsan/pr83987-2.C
Normal file
24
gcc/testsuite/g++.dg/ubsan/pr83987-2.C
Normal file
|
@ -0,0 +1,24 @@
|
|||
// PR sanitizer/83987
|
||||
// { dg-do compile { target fopenmp } }
|
||||
// { dg-options "-fopenmp -fsanitize=vptr" }
|
||||
|
||||
struct A
|
||||
{
|
||||
int i;
|
||||
};
|
||||
|
||||
struct B : virtual A
|
||||
{
|
||||
void foo();
|
||||
};
|
||||
|
||||
void B::foo()
|
||||
{
|
||||
#pragma omp parallel
|
||||
{
|
||||
#pragma omp sections lastprivate (i)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue