aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2011-05-06 23:00:49 +0000
committerJan Hubicka <jh@suse.cz>2011-05-06 23:00:49 +0000
commita5c4e82d53e153a01a69eae1695ee8328b141c5e (patch)
tree00b435c7373736adc2b2930493aa86fc6e9c0b31 /gcc/lto-cgraph.c
parentcc5e4f6c6dc5a15579b866c129fa4e0189ddb910 (diff)
* cgraph.c (cgraph_add_thunk): Create real function node instead
of alias node; finalize it and mark needed/reachale; arrange visibility to be right and add it into the corresponding same comdat group list. (dump_cgraph_node): Dump thunks. * cgraph.h (cgraph_first_defined_function, cgraph_next_defined_function, cgraph_function_with_gimple_body_p, cgraph_first_function_with_gimple_body, cgraph_next_function_with_gimple_body): New functions. (FOR_EACH_FUNCTION_WITH_GIMPLE_BODY, FOR_EACH_DEFINED_FUNCTION): New macros. * ipa-cp.c (ipcp_need_redirect_p): Thunks can't be redirected. (ipcp_generate_summary): Use FOR_EACH_FUNCTION_WITH_GIMPLE_BODY. * cgraphunit.c (cgraph_finalize_function): Only look into possible devirtualization when optimizing. (verify_cgraph_node): Verify thunks. (cgraph_analyze_function): Analyze thunks. (cgraph_mark_functions_to_output): Output thunks only in combination with function they are assigned to. (assemble_thunk): Turn thunk into non-thunk; don't try to turn alias into normal node. (assemble_thunks): New functoin. (cgraph_expand_function): Use it. * lto-cgraph.c (lto_output_node): Stream thunks. (input_overwrite_node): Stream in thunks. * ipa-pure-const.c (analyze_function): Thunks do nothing interesting. * lto-streamer-out.c (lto_output): Do not try to output thunk's body. * ipa-inline.c (inline_small_functions): Use FOR_EACH_DEFINED_FUNCTION. * ipa-inline-analysis.c (compute_inline_parameters): "Analyze" thunks. (inline_analyze_function): Do not care about thunk jump functions. (inline_generate_summary):Use FOR_EACH_DEFINED_FUNCTION. * ipa-prop.c (ipa_prop_write_jump_functions): Use cgraph_function_with_gimple_body_p. * passes.c (do_per_function_toporder): Use cgraph_function_with_gimple_body_p. (execute_one_pass);Use FOR_EACH_FUNCTION_WITH_GIMPLE_BODY. (ipa_write_summaries): Use cgraph_function_with_gimple_body_p. (function_called_by_processed_nodes_p): Likewise. * lto.c (lto_materialize_function): Use cgraph_function_with_gimple_body_p. (add_cgraph_node_to_partition): Do not re-add items to partition; handle thunks. (add_varpool_node_to_partition): Do not re-add items to partition. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@173517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r--gcc/lto-cgraph.c80
1 files changed, 39 insertions, 41 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 73911f32b83..f4fd2a3b7c4 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -502,9 +502,24 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
bp_pack_value (&bp, node->frequency, 2);
bp_pack_value (&bp, node->only_called_at_startup, 1);
bp_pack_value (&bp, node->only_called_at_exit, 1);
+ bp_pack_value (&bp, node->thunk.thunk_p && !boundary_p, 1);
lto_output_bitpack (&bp);
lto_output_uleb128_stream (ob->main_stream, node->resolution);
+ if (node->thunk.thunk_p && !boundary_p)
+ {
+ lto_output_uleb128_stream
+ (ob->main_stream,
+ 1 + (node->thunk.this_adjusting != 0) * 2
+ + (node->thunk.virtual_offset_p != 0) * 4);
+ lto_output_uleb128_stream (ob->main_stream,
+ node->thunk.fixed_offset);
+ lto_output_uleb128_stream (ob->main_stream,
+ node->thunk.virtual_value);
+ lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
+ node->thunk.alias);
+ }
+
if (node->same_body)
{
struct cgraph_node *alias;
@@ -516,25 +531,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
{
lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
alias->decl);
- if (alias->thunk.thunk_p)
- {
- lto_output_uleb128_stream
- (ob->main_stream,
- 1 + (alias->thunk.this_adjusting != 0) * 2
- + (alias->thunk.virtual_offset_p != 0) * 4);
- lto_output_uleb128_stream (ob->main_stream,
- alias->thunk.fixed_offset);
- lto_output_uleb128_stream (ob->main_stream,
- alias->thunk.virtual_value);
- lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
- alias->thunk.alias);
- }
- else
- {
- lto_output_uleb128_stream (ob->main_stream, 0);
- lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
- alias->thunk.alias);
- }
+ lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
+ alias->thunk.alias);
gcc_assert (cgraph_get_node (alias->thunk.alias) == node);
lto_output_uleb128_stream (ob->main_stream, alias->resolution);
alias = alias->previous;
@@ -947,6 +945,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
node->frequency = (enum node_frequency)bp_unpack_value (bp, 2);
node->only_called_at_startup = bp_unpack_value (bp, 1);
node->only_called_at_exit = bp_unpack_value (bp, 1);
+ node->thunk.thunk_p = bp_unpack_value (bp, 1);
node->resolution = resolution;
}
@@ -1031,34 +1030,33 @@ input_node (struct lto_file_decl_data *file_data,
/* Store a reference for now, and fix up later to be a pointer. */
node->same_comdat_group = (cgraph_node_ptr) (intptr_t) ref2;
+ if (node->thunk.thunk_p)
+ {
+ int type = lto_input_uleb128 (ib);
+ HOST_WIDE_INT fixed_offset = lto_input_uleb128 (ib);
+ HOST_WIDE_INT virtual_value = lto_input_uleb128 (ib);
+ tree real_alias;
+
+ decl_index = lto_input_uleb128 (ib);
+ real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index);
+ node->thunk.fixed_offset = fixed_offset;
+ node->thunk.this_adjusting = (type & 2);
+ node->thunk.virtual_value = virtual_value;
+ node->thunk.virtual_offset_p = (type & 4);
+ node->thunk.alias = real_alias;
+ }
+
same_body_count = lto_input_uleb128 (ib);
while (same_body_count-- > 0)
{
- tree alias_decl;
- int type;
+ tree alias_decl, real_alias;
struct cgraph_node *alias;
+
decl_index = lto_input_uleb128 (ib);
alias_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index);
- type = lto_input_uleb128 (ib);
- if (!type)
- {
- tree real_alias;
- decl_index = lto_input_uleb128 (ib);
- real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index);
- alias = cgraph_same_body_alias (node, alias_decl, real_alias);
- }
- else
- {
- HOST_WIDE_INT fixed_offset = lto_input_uleb128 (ib);
- HOST_WIDE_INT virtual_value = lto_input_uleb128 (ib);
- tree real_alias;
- decl_index = lto_input_uleb128 (ib);
- real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index);
- alias = cgraph_add_thunk (node, alias_decl, fn_decl, type & 2, fixed_offset,
- virtual_value,
- (type & 4) ? size_int (virtual_value) : NULL_TREE,
- real_alias);
- }
+ decl_index = lto_input_uleb128 (ib);
+ real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index);
+ alias = cgraph_same_body_alias (node, alias_decl, real_alias);
gcc_assert (alias);
alias->resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib);
}