I've encountered another case where the assumption that only a bind vars and its block vars may share a common chain -- for -finstrument-functions or TSAN the gimplifier violates this, making the chain shared between different binds vars and block.
This can cause BLOCK_VARs to be dropped (I experienced different fallout though with unrelated "enhancement" at that spot). I tracked down this "change" to the merge of the tuples branch (for -finstrument-functions, TSAN simply copied existing practice). Obviously not documented. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2016-10-14 Richard Biener <rguent...@suse.de> * gimplify.c (gimplify_function_tree): Do not move the outer binds block. Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 241102) +++ gcc/gimplify.c (working copy) @@ -12373,10 +12376,7 @@ gimplify_function_tree (tree fndecl) tmp_var); gimplify_seq_add_stmt (&body, call); gimplify_seq_add_stmt (&body, tf); - new_bind = gimple_build_bind (NULL, body, 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); + new_bind = gimple_build_bind (NULL, body, NULL); /* Replace the current function body with the body wrapped in the try/finally TF. */ @@ -12391,10 +12391,7 @@ gimplify_function_tree (tree fndecl) { 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); + gbind *new_bind = gimple_build_bind (NULL, tf, NULL); /* Replace the current function body with the body wrapped in the try/finally TF. */ seq = NULL;