This fixes the weak alias regression FAIL: gcc.dg/attr-weakref-1.c. I tracked it down to the fact that this has both DECL_EXTERNAL and TREE_STATIC (and RTL) set but the trunk code differs from the 4.7 code in that it has an additional !DECL_EXTERNAL check (for no apparent reason, that is, no testcase or comment).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2012-12-13 Richard Biener <rguent...@suse.de> PR middle-end/53476 * varpool.c (varpool_remove_unreferenced_decls): Revert to 4.7 behavior. Index: gcc/varpool.c =================================================================== --- gcc/varpool.c (revision 194473) +++ gcc/varpool.c (working copy) @@ -358,8 +358,7 @@ varpool_remove_unreferenced_decls (void) && (!varpool_can_remove_if_no_refs (node) /* We just expanded all function bodies. See if any of them needed the variable. */ - || (!DECL_EXTERNAL (node->symbol.decl) - && DECL_RTL_SET_P (node->symbol.decl)))) + || DECL_RTL_SET_P (node->symbol.decl))) { enqueue_node (node, &first); if (cgraph_dump_file)