The following patch makes sure to clear DECL_CHAIN of gimple_bind_vars once we dissolve that (but makes sure to preserve the BLOCK_VARS tail). This should allow better GC in the face of remove-unused-locals eventually removing the last reference to a decl (and not keep it live via DECL_CHAIN of some others).
I ran into the /* Ugh */ comment during libsubc++ build; rather than trying to nail that down I papered over it ... Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2016-10-06 Richard Biener <rguent...@suse.de> * gimple-low.c (lower_gimple_bind): Clear DECL_CHAIN of vars in gimple_bind_vars but not in BLOCK_VARS. Index: gcc/gimple-low.c =================================================================== --- gcc/gimple-low.c (revision 240831) +++ gcc/gimple-low.c (working copy) @@ -416,6 +416,23 @@ lower_gimple_bind (gimple_stmt_iterator } record_vars (gimple_bind_vars (stmt)); + + /* Scrap DECL_CHAIN up to BLOCK_VARS to ease GC after we no longer + need gimple_bind_vars. */ + tree next; + tree end = NULL_TREE; + if (gimple_bind_block (stmt)) + end = BLOCK_VARS (gimple_bind_block (stmt)); + for (tree var = gimple_bind_vars (stmt); var != end; var = next) + { + /* Ugh, something is violating the constraint that BLOCK_VARS + is a sub-chain of gimple_bind_vars. */ + if (! var) + break; + next = DECL_CHAIN (var); + DECL_CHAIN (var) = NULL_TREE; + } + lower_sequence (gimple_bind_body_ptr (stmt), data); if (new_block)