aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto/lto-partition.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/lto/lto-partition.c')
-rw-r--r--gcc/lto/lto-partition.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 5c931e68..602173d 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -83,6 +83,7 @@ add_references_to_partition (ltrans_partition part, struct ipa_ref_list *refs)
else
if (symtab_variable_p (ref->referred)
&& (DECL_COMDAT (ipa_ref_varpool_node (ref)->symbol.decl)
+ || DECL_EXTERNAL (ipa_ref_varpool_node (ref)->symbol.decl)
|| (ref->use == IPA_REF_ALIAS
&& lookup_attribute
("weakref",
@@ -287,6 +288,7 @@ partition_varpool_node_p (struct varpool_node *vnode)
return false;
/* Constant pool and comdat are always only in partitions they are needed. */
if (DECL_IN_CONSTANT_POOL (vnode->symbol.decl)
+ || DECL_EXTERNAL (vnode->symbol.decl)
|| (DECL_COMDAT (vnode->symbol.decl)
&& !vnode->symbol.force_output
&& !symtab_used_from_object_file_p ((symtab_node) vnode)))
@@ -843,6 +845,7 @@ lto_promote_cross_file_statics (void)
be made global. It is sensible to keep those ltrans local to
allow better optimization. */
if (!DECL_IN_CONSTANT_POOL (vnode->symbol.decl)
+ && !DECL_EXTERNAL (vnode->symbol.decl)
&& !DECL_COMDAT (vnode->symbol.decl)
&& !vnode->symbol.externally_visible && vnode->analyzed
&& referenced_from_other_partition_p (&vnode->symbol.ref_list,
@@ -893,8 +896,11 @@ lto_promote_cross_file_statics (void)
/* Constant pool references use internal labels and thus
cannot be made global. It is sensible to keep those
- ltrans local to allow better optimization. */
- if (DECL_IN_CONSTANT_POOL (v->symbol.decl))
+ ltrans local to allow better optimization.
+ Similarly we ship external vars initializers into
+ every ltrans unit possibly referring to it. */
+ if (DECL_IN_CONSTANT_POOL (v->symbol.decl)
+ || DECL_EXTERNAL (v->symbol.decl))
{
if (!pointer_set_insert (inserted, vnode))
VEC_safe_push (varpool_node_ptr, heap,