cgraph.c (cgraph_node::make_local): No name is unique during incremental linking.
authorJan Hubicka <hubicka@ucw.cz>
Sun, 29 Nov 2015 22:33:23 +0000 (23:33 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 29 Nov 2015 22:33:23 +0000 (22:33 +0000)
* cgraph.c (cgraph_node::make_local): No name is unique during
incremental linking.
* cgraph.h (can_be_discarded_p): Update comment; also common and
WEAK in named sections can be discarded; when doing incremental
link do not rely on resolution being the final one.
* varasm.c (default_binds_local_p_3, decl_binds_to_current_def_p):
When symbol can be discarded, do not rely on resolution info.
* symtab.c (symtab_node::nonzero_address): Take into account that
symbol can be discarded.
* ipa-visibility.c (update_visibility_by_resolution_info): Handle
definition correctly.
(function_and_variable_visibility): Do not set unique_name when
incrementally linking.

From-SVN: r231050

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/ipa-visibility.c
gcc/symtab.c
gcc/varasm.c

index e49fd7af15c3b75acd6358f186e32ac6ecfda6df..3f6024ee3aef63c20fbb3e43308bb890668bc58b 100644 (file)
@@ -1,3 +1,19 @@
+2015-11-29  Jan Hubicka  <hubicka@ucw.cz>
+
+       * cgraph.c (cgraph_node::make_local): No name is unique during
+       incremental linking.
+       * cgraph.h (can_be_discarded_p): Update comment; also common and
+       WEAK in named sections can be discarded; when doing incremental
+       link do not rely on resolution being the final one.
+       * varasm.c (default_binds_local_p_3, decl_binds_to_current_def_p):
+       When symbol can be discarded, do not rely on resolution info.
+       * symtab.c (symtab_node::nonzero_address): Take into account that
+       symbol can be discarded.
+       * ipa-visibility.c (update_visibility_by_resolution_info): Handle
+       definition correctly.
+       (function_and_variable_visibility): Do not set unique_name when
+       incrementally linking.
+
 2015-11-29  Nathan Sidwell  <nathan@acm.org>
 
        * config/nvptx/nvptx.md (const_0_operand, global_mem_operand,
index b1228a2d5de36fa08eaffb83432d789e33e9cf22..3ee1907c33569a89f606b8a29e99e7b3f9ed9afa 100644 (file)
@@ -2253,8 +2253,9 @@ cgraph_node::make_local (cgraph_node *node, void *)
       node->forced_by_abi = false;
       node->local.local = true;
       node->set_section (NULL);
-      node->unique_name = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
-                                 || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
+      node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
+                          || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
+                          && !flag_incremental_link);
       node->resolution = LDPR_PREVAILING_DEF_IRONLY;
       gcc_assert (node->get_availability () == AVAIL_LOCAL);
     }
index b6390995ab939f530f805f9ceb2e388f9b43cd23..6cff4468cc0b09c71f79b8c862f9d218f06c9046 100644 (file)
@@ -319,15 +319,23 @@ public:
   /* Return true when there are references to the node.  */
   bool referred_to_p (bool include_self = true);
 
-  /* Return true if NODE can be discarded by linker from the binary.  */
+  /* Return true if symbol can be discarded by linker from the binary.
+     Assume that symbol is used (so there is no need to take into account
+     garbage collecting linkers)
+
+     This can happen for comdats, commons and weaks when they are previaled
+     by other definition at static linking time.  */
   inline bool
   can_be_discarded_p (void)
   {
     return (DECL_EXTERNAL (decl)
-           || (get_comdat_group ()
-               && resolution != LDPR_PREVAILING_DEF
-               && resolution != LDPR_PREVAILING_DEF_IRONLY
-               && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP));
+           || ((get_comdat_group ()
+                || DECL_COMMON (decl)
+                || (DECL_SECTION_NAME (decl) && DECL_WEAK (decl)))
+               && ((resolution != LDPR_PREVAILING_DEF
+                    && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP)
+                   || flag_incremental_link)
+               && resolution != LDPR_PREVAILING_DEF_IRONLY));
   }
 
   /* Return true if NODE is local to a particular COMDAT group, and must not
index 41ed4db67459d4fcc0ededa4b8ed3ab3929d7719..2eab214243e94dd446f657e56f729ee539f500d3 100644 (file)
@@ -413,10 +413,10 @@ update_visibility_by_resolution_info (symtab_node * node)
            DECL_WEAK (next->decl) = false;
            next->set_comdat_group (NULL);
          }
-       if (next->externally_visible
-           && !define)
+       if (!define)
          {
-           DECL_EXTERNAL (next->decl) = true;
+           if (next->externally_visible)
+             DECL_EXTERNAL (next->decl) = true;
            next->set_comdat_group (NULL);
          }
       }
@@ -513,10 +513,10 @@ function_and_variable_visibility (bool whole_program)
        {
          gcc_assert (whole_program || in_lto_p
                      || !TREE_PUBLIC (node->decl));
-         node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
-                               || node->unique_name
-                               || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
-                               && TREE_PUBLIC (node->decl));
+         node->unique_name |= ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
+                                || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
+                               && TREE_PUBLIC (node->decl)
+                               && !flag_incremental_link);
          node->resolution = LDPR_PREVAILING_DEF_IRONLY;
          if (node->same_comdat_group && TREE_PUBLIC (node->decl))
            {
@@ -532,10 +532,10 @@ function_and_variable_visibility (bool whole_program)
                  if (!next->alias)
                    next->set_section (NULL);
                  next->make_decl_local ();
-                 next->unique_name = ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
-                                       || next->unique_name
-                                       || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
-                                      && TREE_PUBLIC (next->decl));
+                 next->unique_name |= ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
+                                        || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
+                                       && TREE_PUBLIC (next->decl)
+                                       && !flag_incremental_link);
                }
              /* cgraph_externally_visible_p has already checked all other nodes
                 in the group and they will all be made local.  We need to
@@ -657,10 +657,11 @@ function_and_variable_visibility (bool whole_program)
          && !vnode->weakref)
        {
          gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->decl));
-         vnode->unique_name = ((vnode->resolution == LDPR_PREVAILING_DEF_IRONLY
-                                || vnode->resolution
+         vnode->unique_name |= ((vnode->resolution == LDPR_PREVAILING_DEF_IRONLY
+                                 || vnode->resolution
                                      == LDPR_PREVAILING_DEF_IRONLY_EXP)
-                               && TREE_PUBLIC (vnode->decl));
+                                && TREE_PUBLIC (vnode->decl)
+                                && !flag_incremental_link);
          if (vnode->same_comdat_group && TREE_PUBLIC (vnode->decl))
            {
              symtab_node *next = vnode;
@@ -675,10 +676,10 @@ function_and_variable_visibility (bool whole_program)
                  if (!next->alias)
                    next->set_section (NULL);
                  next->make_decl_local ();
-                 next->unique_name = ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
-                                       || next->unique_name
-                                       || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
-                                      && TREE_PUBLIC (next->decl));
+                 next->unique_name |= ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
+                                        || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
+                                       && TREE_PUBLIC (next->decl)
+                                       && !flag_incremental_link);
                }
              vnode->dissolve_same_comdat_group_list ();
            }
index 9677131562815478b8c139be31a37ef0db7e4919..c188710ea92af35e4654fd0910b3459d91e68a13 100644 (file)
@@ -1713,6 +1713,7 @@ symtab_node::nonzero_address ()
              return true;
          if (target->resolution != LDPR_UNKNOWN
              && target->resolution != LDPR_UNDEF
+             && !target->can_be_discarded_p ()
              && flag_delete_null_pointer_checks)
            return true;
          return false;
@@ -1751,6 +1752,7 @@ symtab_node::nonzero_address ()
   /* As the last resort, check the resolution info.  */
   if (resolution != LDPR_UNKNOWN
       && resolution != LDPR_UNDEF
+      && !can_be_discarded_p ()
       && flag_delete_null_pointer_checks)
     return true;
   return false;
index a2adcdba09219975a10c2e2a1d5758bbbf847f0a..c4c55e7cd06fd1cec6d3664ffe9cacd007a58a6d 100644 (file)
@@ -6837,7 +6837,9 @@ default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
     {
       if (node->in_other_partition)
        defined_locally = true;
-      if (resolution_to_local_definition_p (node->resolution))
+      if (node->can_be_discarded_p ())
+       ;
+      else if (resolution_to_local_definition_p (node->resolution))
        defined_locally = resolved_locally = true;
       else if (resolution_local_p (node->resolution))
        resolved_locally = true;
@@ -6930,7 +6932,8 @@ decl_binds_to_current_def_p (const_tree decl)
   /* When resolution is available, just use it.  */
   if (symtab_node *node = symtab_node::get (decl))
     {
-      if (node->resolution != LDPR_UNKNOWN)
+      if (node->resolution != LDPR_UNKNOWN
+         && !node->can_be_discarded_p ())
        return resolution_to_local_definition_p (node->resolution);
     }