On Tue, Jun 11, 2013 at 10:18:17AM -0700, Richard Henderson wrote: > > 2) DECL_COMMON with non-default visibility - the old version would return > > true, now it returns false unless linker plugin tells us the current > > common was used > > > > Or do you think we should just do what we did before and just > > handle the 1) and 2) cases explicitly in the decl_binds_to_current_def_p > > function? > > This (2) sounds like something that we could handle in d_b_t_c_d_p without > having to duplicate all of binds_local_p.
Ok, here are all the changes to d_b_t_c_d_p. Any holes in this? Untested so far. 2013-06-11 Jakub Jelinek <ja...@redhat.com> PR target/56564 * varasm.c (decl_binds_to_current_def_p): Call binds_local_p target hook even for !TREE_PUBLIC decls. If no resolution info is available, return false for common and external decls. --- gcc/varasm.c.jj 2013-06-11 20:11:34.000000000 +0200 +++ gcc/varasm.c 2013-06-11 20:15:15.729363893 +0200 @@ -6781,10 +6781,10 @@ bool decl_binds_to_current_def_p (tree decl) { gcc_assert (DECL_P (decl)); - if (!TREE_PUBLIC (decl)) - return true; if (!targetm.binds_local_p (decl)) return false; + if (!TREE_PUBLIC (decl)) + return true; /* When resolution is available, just use it. */ if (TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) @@ -6802,10 +6802,20 @@ decl_binds_to_current_def_p (tree decl) return resolution_to_local_definition_p (node->symbol.resolution); } /* Otherwise we have to assume the worst for DECL_WEAK (hidden weaks - binds locally but still can be overwritten). + binds locally but still can be overwritten), DECL_COMMON (can be merged + with a non-common definition somewhere in the same module) or + DECL_EXTERNAL. This rely on fact that binds_local_p behave as decl_replaceable_p for all other declaration types. */ - return !DECL_WEAK (decl); + if (DECL_WEAK (decl)) + return false; + if (DECL_COMMON (decl) + && (DECL_INITIAL (decl) == NULL + || DECL_INITIAL (decl) == error_mark_node)) + return false; + if (DECL_EXTERNAL (decl)) + return false; + return true; } /* A replaceable function or variable is one which may be replaced Jakub