PR ipa/59469
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Feb 2014 02:28:33 +0000 (02:28 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Feb 2014 02:28:33 +0000 (02:28 +0000)
* lto-cgraph.c (lto_output_node): Use
symtab_get_symbol_partitioning_class.
(lto_output_varpool_node): likewise.
(symtab_get_symbol_partitioning_class): Move here from
lto/lto-partition.c
* cgraph.h (symbol_partitioning_class): Likewise.
(symtab_get_symbol_partitioning_class): Declare.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207591 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/symtab.c

index a7312f5..5d69803 100644 (file)
@@ -1267,4 +1267,55 @@ symtab_semantically_equivalent_p (symtab_node *a,
     bb = b;
   return bb == ba;
 }
+
+/* Classify symbol NODE for partitioning.  */
+
+enum symbol_partitioning_class
+symtab_get_symbol_partitioning_class (symtab_node *node)
+{
+  /* Inline clones are always duplicated.
+     This include external delcarations.   */
+  cgraph_node *cnode = dyn_cast <cgraph_node> (node);
+
+  if (DECL_ABSTRACT (node->decl))
+    return SYMBOL_EXTERNAL;
+
+  if (cnode && cnode->global.inlined_to)
+    return SYMBOL_DUPLICATE;
+
+  /* Weakref aliases are always duplicated.  */
+  if (node->weakref)
+    return SYMBOL_DUPLICATE;
+
+  /* External declarations are external.  */
+  if (DECL_EXTERNAL (node->decl))
+    return SYMBOL_EXTERNAL;
+
+  if (varpool_node *vnode = dyn_cast <varpool_node> (node))
+    {
+      /* Constant pool references use local symbol names that can not
+         be promoted global.  We should never put into a constant pool
+         objects that can not be duplicated across partitions.  */
+      if (DECL_IN_CONSTANT_POOL (node->decl))
+       return SYMBOL_DUPLICATE;
+      gcc_checking_assert (vnode->definition);
+    }
+  /* Functions that are cloned may stay in callgraph even if they are unused.
+     Handle them as external; compute_ltrans_boundary take care to make
+     proper things to happen (i.e. to make them appear in the boundary but
+     with body streamed, so clone can me materialized).  */
+  else if (!cgraph (node)->definition)
+    return SYMBOL_EXTERNAL;
+
+  /* Linker discardable symbols are duplicated to every use unless they are
+     keyed.
+     Keyed symbols or those.  */
+  if (DECL_ONE_ONLY (node->decl)
+      && !node->force_output
+      && !node->forced_by_abi
+      && !symtab_used_from_object_file_p (node))
+    return SYMBOL_DUPLICATE;
+
+  return SYMBOL_PARTITION;
+}
 #include "gt-symtab.h"