+/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
+ Extra name aliases are output whenever DECL is output. */
+
+struct varpool_node *
+varpool_create_variable_alias (tree alias, tree decl)
+{
+ struct varpool_node *alias_node;
+
+ gcc_assert (TREE_CODE (decl) == VAR_DECL);
+ gcc_assert (TREE_CODE (alias) == VAR_DECL);
+ alias_node = varpool_node (alias);
+ alias_node->alias = 1;
+ if (!DECL_EXTERNAL (alias))
+ alias_node->finalized = 1;
+ alias_node->alias_of = decl;
+ if ((!DECL_EXTERNAL (alias)
+ && decide_is_variable_needed (alias_node, alias))
+ || alias_node->needed)
+ varpool_mark_needed_node (alias_node);
+ return alias_node;
+}
+
+/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
+ Extra name aliases are output whenever DECL is output. */
+
+struct varpool_node *
+varpool_extra_name_alias (tree alias, tree decl)
+{
+ struct varpool_node *alias_node;
+
+#ifndef ASM_OUTPUT_DEF
+ /* If aliases aren't supported by the assembler, fail. */
+ return NULL;
+#endif
+ alias_node = varpool_create_variable_alias (alias, decl);
+ alias_node->extra_name_alias = true;
+ return alias_node;
+}
+
+/* Return true when NODE is known to be used from other (non-LTO) object file.
+ Known only when doing LTO via linker plugin. */
+
+bool
+varpool_used_from_object_file_p (struct varpool_node *node)
+{
+ if (!TREE_PUBLIC (node->decl))
+ return false;
+ if (resolution_used_from_other_file_p (node->resolution))
+ return true;
+ return false;
+}
+
+/* Call calback on NODE and aliases asociated to NODE.
+ When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
+ skipped. */
+
+bool
+varpool_for_node_and_aliases (struct varpool_node *node,
+ bool (*callback) (struct varpool_node *, void *),
+ void *data,
+ bool include_overwritable)
+{
+ int i;
+ struct ipa_ref *ref;
+
+ if (callback (node, data))
+ return true;
+ for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref); i++)
+ if (ref->use == IPA_REF_ALIAS)
+ {
+ struct varpool_node *alias = ipa_ref_refering_varpool_node (ref);
+ if (include_overwritable
+ || cgraph_variable_initializer_availability (alias) > AVAIL_OVERWRITABLE)
+ if (varpool_for_node_and_aliases (alias, callback, data,
+ include_overwritable))
+ return true;
+ }
+ return false;
+}