aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-01-05 22:47:51 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-01-05 22:47:51 +0100
commitfca4adf2095dfcd453ab32250984d85ff66bbd32 (patch)
tree71684c10bc82a08750e567f3a2526c6817160a6b /gcc/gimplify.c
parente534110031564716a1e495a38bf8d893b23a5993 (diff)
downloadgcc-fca4adf2095dfcd453ab32250984d85ff66bbd32.zip
gcc-fca4adf2095dfcd453ab32250984d85ff66bbd32.tar.gz
gcc-fca4adf2095dfcd453ab32250984d85ff66bbd32.tar.bz2
re PR sanitizer/64265 (r217669 broke tsan)
PR sanitizer/64265 * gimplify.c (gimplify_function_tree): Add TSAN_FUNC_EXIT internal call as cleanup of the whole body. * internal-fn.def (TSAN_FUNC_EXIT): New internal call. * tsan.c (replace_func_exit): New function. (instrument_func_exit): Moved earlier. (instrument_memory_accesses): Adjust TSAN_FUNC_EXIT internal calls. Call instrument_func_exit if no TSAN_FUNC_EXIT internal calls have been found. (tsan_pass): Don't call instrument_func_exit. * internal-fn.c (expand_TSAN_FUNC_EXIT): New function. * tree-inline.c (copy_bb): Drop TSAN_FUNC_EXIT internal calls during inlining. From-SVN: r219202
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d35734f..b237cbf 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9049,6 +9049,22 @@ gimplify_function_tree (tree fndecl)
seq = NULL;
gimple_seq_add_stmt (&seq, new_bind);
gimple_set_body (fndecl, seq);
+ bind = new_bind;
+ }
+
+ if (flag_sanitize & SANITIZE_THREAD)
+ {
+ gcall *call = gimple_build_call_internal (IFN_TSAN_FUNC_EXIT, 0);
+ gimple tf = gimple_build_try (seq, call, GIMPLE_TRY_FINALLY);
+ gbind *new_bind = gimple_build_bind (NULL, tf, gimple_bind_block (bind));
+ /* Clear the block for BIND, since it is no longer directly inside
+ the function, but within a try block. */
+ gimple_bind_set_block (bind, NULL);
+ /* Replace the current function body with the body
+ wrapped in the try/finally TF. */
+ seq = NULL;
+ gimple_seq_add_stmt (&seq, new_bind);
+ gimple_set_body (fndecl, seq);
}
DECL_SAVED_TREE (fndecl) = NULL_TREE;