diff options
author | Jan Hubicka <jh@suse.cz> | 2009-11-29 11:32:08 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2009-11-29 10:32:08 +0000 |
commit | 6744a6abc335d55f98ba226f4ff169a55cf3fb94 (patch) | |
tree | 2260e6f71c9022e13476588b282bc487939fa1e4 /gcc/cgraph.c | |
parent | e55690913ecef32cb80d5f169a9aa50fd5ae4a98 (diff) | |
download | gcc-6744a6abc335d55f98ba226f4ff169a55cf3fb94.zip gcc-6744a6abc335d55f98ba226f4ff169a55cf3fb94.tar.gz gcc-6744a6abc335d55f98ba226f4ff169a55cf3fb94.tar.bz2 |
cgraph.c (same_body_alias_1): Break out of
* cgraph.c (same_body_alias_1): Break out of
(same_body_alias): ... here; remove comdat check; it is handled
in cp already.
(cgraph_add_thunk): New.
(dump_cgraph_node): Dump aliases and thunks.
* cgraph.h (cgraph_thunk_info): New structure.
(struct cgraph_node): Add thunk info.
(cgraph_add_thunk): New.
* cgraphunit.c (cgraph_emit_thunks): Remove.
(cgraph_finalize_compilation_unit): Do not call cgraph_emit_thunks.
(assemble_thunk): New function.
(cgraph_expand_function): Handle thunks.
(thunk_adjust): New.
(init_lowered_empty_function): New.
* optimize.c (maybe_clone_body): Emit thunks associated to alias.
* Make-lang.in (method.o): Add dependency on gimple.h.
* method.c: Include gimple.h
(make_alias_for_thunk): Use same body alias instead of assemble_alias.
(use_thunk): Drop codegen; use cgraph_add_thunk; gimplify
generic thunks.
* semantics.c (expand_or_defer_fn): Emit associated thunks.
* cp-objcp-common.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove.
* lto-cgraph.c (lto_output_node): Stream thunk info.
(input_node): Likewise.
* langhooks.h (lang_hooks_for_callgraph): Remove emit_associated_thunks.
* langhooks-def.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove.
(LANG_HOOKS_CALLGRAPH_INITIALIZER): Update.
* i386.c (x86_output_mi_thunk): Make output prettier.
From-SVN: r154736
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 93 |
1 files changed, 74 insertions, 19 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 8fd5e7f..651618c 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -85,6 +85,7 @@ The callgraph: #include "tree-flow.h" #include "value-prof.h" #include "except.h" +#include "diagnostic.h" static void cgraph_node_remove_callers (struct cgraph_node *node); static inline void cgraph_edge_remove_caller (struct cgraph_edge *e); @@ -507,29 +508,15 @@ cgraph_node (tree decl) return node; } -/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful. - Same body aliases are output whenever the body of DECL is output, - and cgraph_node (ALIAS) transparently returns cgraph_node (DECL). */ +/* Mark ALIAS as an alias to DECL. */ -bool -cgraph_same_body_alias (tree alias, tree decl) +static struct cgraph_node * +cgraph_same_body_alias_1 (tree alias, tree decl) { struct cgraph_node key, *alias_node, *decl_node, **slot; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); gcc_assert (TREE_CODE (alias) == FUNCTION_DECL); - gcc_assert (!assembler_name_hash); - -#ifndef ASM_OUTPUT_DEF - /* If aliases aren't supported by the assembler, fail. */ - return false; -#endif - - /* Comdat same body aliases are only supported when comdat groups - are supported and the symbols are weak. */ - if (DECL_ONE_ONLY (decl) && (!HAVE_COMDAT_GROUP || !DECL_WEAK (decl))) - return false; - decl_node = cgraph_node (decl); key.decl = alias; @@ -538,7 +525,7 @@ cgraph_same_body_alias (tree alias, tree decl) /* If the cgraph_node has been already created, fail. */ if (*slot) - return false; + return NULL; alias_node = cgraph_allocate_node (); alias_node->decl = alias; @@ -548,9 +535,56 @@ cgraph_same_body_alias (tree alias, tree decl) if (decl_node->same_body) decl_node->same_body->previous = alias_node; alias_node->next = decl_node->same_body; + alias_node->thunk.alias = decl; decl_node->same_body = alias_node; *slot = alias_node; - return true; + return alias_node; +} + +/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful. + Same body aliases are output whenever the body of DECL is output, + and cgraph_node (ALIAS) transparently returns cgraph_node (DECL). */ + +bool +cgraph_same_body_alias (tree alias, tree decl) +{ +#ifndef ASM_OUTPUT_DEF + /* If aliases aren't supported by the assembler, fail. */ + return false; +#endif + + /*gcc_assert (!assembler_name_hash);*/ + + return cgraph_same_body_alias_1 (alias, decl) != NULL; +} + +void +cgraph_add_thunk (tree alias, tree decl, bool this_adjusting, + HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, + tree virtual_offset, + tree real_alias) +{ + struct cgraph_node *node = cgraph_get_node (alias); + + if (node) + { + gcc_assert (node->local.finalized); + gcc_assert (!node->same_body); + cgraph_remove_node (node); + } + + node = cgraph_same_body_alias_1 (alias, decl); + gcc_assert (node); +#ifdef ENABLE_CHECKING + gcc_assert (!virtual_offset + || tree_int_cst_equal (virtual_offset, size_int (virtual_value))); +#endif + node->thunk.fixed_offset = fixed_offset; + node->thunk.this_adjusting = this_adjusting; + node->thunk.virtual_value = virtual_value; + node->thunk.virtual_offset_p = virtual_offset != NULL; + node->thunk.alias = real_alias; + node->thunk.thunk_p = true; } /* Returns the cgraph node assigned to DECL or NULL if no cgraph node @@ -1646,6 +1680,27 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) fprintf(f, "(can throw external) "); } fprintf (f, "\n"); + + if (node->same_body) + { + struct cgraph_node *n; + fprintf (f, " aliases & thunks:"); + for (n = node->same_body; n; n = n->next) + { + fprintf (f, " %s/%i", cgraph_node_name (n), n->uid); + if (n->thunk.thunk_p) + { + fprintf (f, " (thunk of %s fixed ofset %i virtual value %i has " + "virtual offset %i", + lang_hooks.decl_printable_name (n->thunk.alias, 2), + (int)n->thunk.fixed_offset, + (int)n->thunk.virtual_value, + (int)n->thunk.virtual_offset_p); + fprintf (f, ")"); + } + } + fprintf (f, "\n"); + } } |