aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 470fb5a..7293b6d 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -555,24 +555,29 @@ cgraph_same_body_alias_1 (tree alias, tree decl)
return alias_node;
}
-/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
+/* Attempt to mark ALIAS as an alias to DECL. Return alias node if successful
+ and NULL otherwise.
Same body aliases are output whenever the body of DECL is output,
and cgraph_node (ALIAS) transparently returns cgraph_node (DECL). */
-bool
+struct cgraph_node *
cgraph_same_body_alias (tree alias, tree decl)
{
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */
- return false;
+ return NULL;
#endif
/*gcc_assert (!assembler_name_hash);*/
- return cgraph_same_body_alias_1 (alias, decl) != NULL;
+ return cgraph_same_body_alias_1 (alias, decl);
}
-void
+/* Add thunk alias into callgraph. The alias declaration is ALIAS and it
+ alises DECL with an adjustments made into the first parameter.
+ See comments in thunk_adjust for detail on the parameters. */
+
+struct cgraph_node *
cgraph_add_thunk (tree alias, tree decl, bool this_adjusting,
HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value,
tree virtual_offset,
@@ -599,13 +604,14 @@ cgraph_add_thunk (tree alias, tree decl, bool this_adjusting,
node->thunk.virtual_offset_p = virtual_offset != NULL;
node->thunk.alias = real_alias;
node->thunk.thunk_p = true;
+ return node;
}
/* Returns the cgraph node assigned to DECL or NULL if no cgraph node
is assigned. */
struct cgraph_node *
-cgraph_get_node_or_alias (tree decl)
+cgraph_get_node_or_alias (const_tree decl)
{
struct cgraph_node key, *node = NULL, **slot;
@@ -614,7 +620,7 @@ cgraph_get_node_or_alias (tree decl)
if (!cgraph_hash)
return NULL;
- key.decl = decl;
+ key.decl = CONST_CAST2 (tree, const_tree, decl);
slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key,
NO_INSERT);
@@ -628,7 +634,7 @@ cgraph_get_node_or_alias (tree decl)
is assigned. */
struct cgraph_node *
-cgraph_get_node (tree decl)
+cgraph_get_node (const_tree decl)
{
struct cgraph_node key, *node = NULL, **slot;
@@ -637,7 +643,7 @@ cgraph_get_node (tree decl)
if (!cgraph_hash)
return NULL;
- key.decl = decl;
+ key.decl = CONST_CAST2 (tree, const_tree, decl);
slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key,
NO_INSERT);
@@ -1849,8 +1855,6 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node)
fprintf (f, " local");
if (node->local.externally_visible)
fprintf (f, " externally_visible");
- if (node->local.used_from_object_file)
- fprintf (f, " used_from_object_file");
if (node->local.finalized)
fprintf (f, " finalized");
if (node->local.disregard_inline_limits)
@@ -2124,7 +2128,6 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
new_node->analyzed = n->analyzed;
new_node->local = n->local;
new_node->local.externally_visible = false;
- new_node->local.used_from_object_file = false;
new_node->local.local = true;
new_node->local.vtable_method = false;
new_node->global = n->global;
@@ -2318,7 +2321,6 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
else
new_node->clone.combined_args_to_skip = args_to_skip;
new_node->local.externally_visible = 0;
- new_node->local.used_from_object_file = 0;
new_node->local.local = 1;
new_node->lowered = true;
new_node->reachable = true;
@@ -2369,7 +2371,7 @@ cgraph_function_body_availability (struct cgraph_node *node)
AVAIL_AVAILABLE here? That would be good reason to preserve this
bit. */
- else if (DECL_REPLACEABLE_P (node->decl) && !DECL_EXTERNAL (node->decl))
+ else if (decl_replaceable_p (node->decl) && !DECL_EXTERNAL (node->decl))
avail = AVAIL_OVERWRITABLE;
else avail = AVAIL_AVAILABLE;
@@ -2556,6 +2558,7 @@ cgraph_make_node_local (struct cgraph_node *node)
node->local.externally_visible = false;
node->local.local = true;
+ node->resolution = LDPR_PREVAILING_DEF_IRONLY;
gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);
}
}
@@ -2720,7 +2723,8 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node)
return false;
/* Only COMDAT functions can be removed if externally visible. */
if (node->local.externally_visible
- && (!DECL_COMDAT (node->decl) || node->local.used_from_object_file))
+ && (!DECL_COMDAT (node->decl)
+ || cgraph_used_from_object_file_p (node)))
return false;
/* Constructors and destructors are executed by the runtime, however
we can get rid of all pure constructors and destructors. */
@@ -2753,7 +2757,7 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node)
bool
cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node)
{
- if (node->local.used_from_object_file)
+ if (cgraph_used_from_object_file_p (node))
return false;
if (!in_lto_p && !flag_whole_program)
return cgraph_only_called_directly_p (node);
@@ -2761,4 +2765,35 @@ cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node
return cgraph_can_remove_if_no_direct_calls_p (node);
}
+/* Return true when RESOLUTION indicate that linker will use
+ the symbol from non-LTo object files. */
+
+bool
+resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
+{
+ return (resolution == LDPR_PREVAILING_DEF
+ || resolution == LDPR_PREEMPTED_REG
+ || resolution == LDPR_RESOLVED_EXEC
+ || resolution == LDPR_RESOLVED_DYN);
+}
+
+/* Return true when NODE is known to be used from other (non-LTO) object file.
+ Known only when doing LTO via linker plugin. */
+
+bool
+cgraph_used_from_object_file_p (struct cgraph_node *node)
+{
+ struct cgraph_node *alias;
+
+ if (!TREE_PUBLIC (node->decl))
+ return false;
+ if (resolution_used_from_other_file_p (node->resolution))
+ return true;
+ for (alias = node->same_body; alias; alias = alias->next)
+ if (TREE_PUBLIC (alias->decl)
+ && resolution_used_from_other_file_p (alias->resolution))
+ return true;
+ return false;
+}
+
#include "gt-cgraph.h"