Commit 5c972fb6 by Jakub Jelinek Committed by Jakub Jelinek

tsan.c (instrument_expr): If expr_ptr isn't a gimple val, first store it into a SSA_NAME.

	* tsan.c (instrument_expr): If expr_ptr isn't a gimple val, first
	store it into a SSA_NAME.

From-SVN: r194135
parent dfc84007
2012-12-03 Jakub Jelinek <jakub@redhat.com> 2012-12-04 Jakub Jelinek <jakub@redhat.com>
* tsan.c (instrument_expr): If expr_ptr isn't a gimple val, first
store it into a SSA_NAME.
PR sanitizer/55439 PR sanitizer/55439
* Makefile.in (tsan.o): Depend on tree-ssa-propagate.h. * Makefile.in (tsan.o): Depend on tree-ssa-propagate.h.
...@@ -93,10 +93,11 @@ is_vptr_store (gimple stmt, tree expr, bool is_write) ...@@ -93,10 +93,11 @@ is_vptr_store (gimple stmt, tree expr, bool is_write)
static bool static bool
instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write)
{ {
tree base, rhs, expr_type, expr_ptr, builtin_decl; tree base, rhs, expr_ptr, builtin_decl;
basic_block bb; basic_block bb;
HOST_WIDE_INT size; HOST_WIDE_INT size;
gimple stmt, g; gimple stmt, g;
gimple_seq seq;
location_t loc; location_t loc;
size = int_size_in_bytes (TREE_TYPE (expr)); size = int_size_in_bytes (TREE_TYPE (expr));
...@@ -139,21 +140,25 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) ...@@ -139,21 +140,25 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write)
rhs = is_vptr_store (stmt, expr, is_write); rhs = is_vptr_store (stmt, expr, is_write);
gcc_checking_assert (rhs != NULL || is_gimple_addressable (expr)); gcc_checking_assert (rhs != NULL || is_gimple_addressable (expr));
expr_ptr = build_fold_addr_expr (unshare_expr (expr)); expr_ptr = build_fold_addr_expr (unshare_expr (expr));
if (rhs == NULL) seq = NULL;
if (!is_gimple_val (expr_ptr))
{ {
expr_type = TREE_TYPE (expr); g = gimple_build_assign (make_ssa_name (TREE_TYPE (expr_ptr), NULL),
while (TREE_CODE (expr_type) == ARRAY_TYPE) expr_ptr);
expr_type = TREE_TYPE (expr_type); expr_ptr = gimple_assign_lhs (g);
size = int_size_in_bytes (expr_type); gimple_set_location (g, loc);
g = gimple_build_call (get_memory_access_decl (is_write, size), gimple_seq_add_stmt_without_update (&seq, g);
1, expr_ptr);
} }
if (rhs == NULL)
g = gimple_build_call (get_memory_access_decl (is_write, size),
1, expr_ptr);
else else
{ {
builtin_decl = builtin_decl_implicit (BUILT_IN_TSAN_VPTR_UPDATE); builtin_decl = builtin_decl_implicit (BUILT_IN_TSAN_VPTR_UPDATE);
g = gimple_build_call (builtin_decl, 1, expr_ptr); g = gimple_build_call (builtin_decl, 1, expr_ptr);
} }
gimple_set_location (g, loc); gimple_set_location (g, loc);
gimple_seq_add_stmt_without_update (&seq, g);
/* Instrumentation for assignment of a function result /* Instrumentation for assignment of a function result
must be inserted after the call. Instrumentation for must be inserted after the call. Instrumentation for
reads of function arguments must be inserted before the call. reads of function arguments must be inserted before the call.
...@@ -170,13 +175,13 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) ...@@ -170,13 +175,13 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write)
bb = gsi_bb (gsi); bb = gsi_bb (gsi);
e = find_fallthru_edge (bb->succs); e = find_fallthru_edge (bb->succs);
if (e) if (e)
gsi_insert_seq_on_edge_immediate (e, g); gsi_insert_seq_on_edge_immediate (e, seq);
} }
else else
gsi_insert_after (&gsi, g, GSI_NEW_STMT); gsi_insert_seq_after (&gsi, seq, GSI_NEW_STMT);
} }
else else
gsi_insert_before (&gsi, g, GSI_SAME_STMT); gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment