aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c85
1 files changed, 81 insertions, 4 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 5daea448500..91b08a65c69 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -268,7 +268,7 @@ cgraph_mark_needed_node (struct cgraph_node *node)
cgraph_mark_reachable_node (node);
}
-/* Record call from CALLER to CALLEE */
+/* Record call from CALLER to CALLEE. */
struct cgraph_edge *
cgraph_record_call (tree caller, tree callee)
@@ -428,8 +428,6 @@ cgraph_varpool_node (tree decl)
if (!cgraph_varpool_hash)
cgraph_varpool_hash = htab_create_ggc (10, cgraph_varpool_hash_node,
eq_cgraph_varpool_node, NULL);
-
-
slot = (struct cgraph_varpool_node **)
htab_find_slot_with_hash (cgraph_varpool_hash, DECL_ASSEMBLER_NAME (decl),
IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME (decl)),
@@ -444,6 +442,85 @@ cgraph_varpool_node (tree decl)
return node;
}
+/* Set the DECL_ASSEMBLER_NAME and update cgraph hashtables. */
+void
+change_decl_assembler_name (tree decl, tree name)
+{
+ struct cgraph_node *node = NULL;
+ struct cgraph_varpool_node *vnode = NULL;
+ void **slot;
+
+ if (!DECL_ASSEMBLER_NAME_SET_P (decl))
+ {
+ SET_DECL_ASSEMBLER_NAME (decl, name);
+ return;
+ }
+ if (name == DECL_ASSEMBLER_NAME (decl))
+ return;
+
+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
+ && DECL_RTL_SET_P (decl))
+ warning ("%D renamed after being referenced in assembly", decl);
+
+ if (TREE_CODE (decl) == FUNCTION_DECL && cgraph_hash)
+ {
+ /* Take a look whether declaration is in the cgraph structure. */
+ slot =
+ htab_find_slot_with_hash (cgraph_hash, DECL_ASSEMBLER_NAME (decl),
+ IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+ (decl)), NO_INSERT);
+ if (slot)
+ node = *slot;
+
+ /* It is, verify that we are the canonical node for this decl. */
+ if (node && node->decl == decl)
+ {
+ node = *slot;
+ htab_clear_slot (cgraph_hash, slot);
+ }
+ else
+ node = NULL;
+ }
+ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) && cgraph_varpool_hash)
+ {
+ /* Take a look whether declaration is in the cgraph structure. */
+ slot =
+ htab_find_slot_with_hash (cgraph_varpool_hash, DECL_ASSEMBLER_NAME (decl),
+ IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+ (decl)), NO_INSERT);
+ if (slot)
+ vnode = *slot;
+
+ /* It is, verify that we are the canonical vnode for this decl. */
+ if (vnode && vnode->decl == decl)
+ {
+ vnode = *slot;
+ htab_clear_slot (cgraph_varpool_hash, slot);
+ }
+ else
+ vnode = NULL;
+ }
+ SET_DECL_ASSEMBLER_NAME (decl, name);
+ if (node)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_hash, name,
+ IDENTIFIER_HASH_VALUE (name), INSERT);
+ if (*slot)
+ abort ();
+ *slot = node;
+ }
+ if (vnode)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_varpool_hash, name,
+ IDENTIFIER_HASH_VALUE (name), INSERT);
+ if (*slot)
+ abort ();
+ *slot = vnode;
+ }
+}
+
/* Try to find existing function for identifier ID. */
struct cgraph_varpool_node *
cgraph_varpool_node_for_identifier (tree id)
@@ -536,7 +613,7 @@ bool
cgraph_function_possibly_inlined_p (tree decl)
{
if (!cgraph_global_info_ready)
- return (DECL_INLINE (decl) && !flag_no_inline);
+ return (DECL_INLINE (decl) && !flag_really_no_inline);
return cgraph_node (decl)->global.inlined;
}