aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-10-23 21:44:23 +0200
committerJan Hubicka <jh@suse.cz>2020-10-23 21:44:23 +0200
commit67f3791f7d133214b112bd831ff2876822c665d0 (patch)
tree48c1ccff315d09fcce1ec1e9f2b998367140e45a /gcc/lto-cgraph.c
parent83f83ddfe0fe41c9b553850d4ababd5089df8332 (diff)
downloadgcc-67f3791f7d133214b112bd831ff2876822c665d0.zip
gcc-67f3791f7d133214b112bd831ff2876822c665d0.tar.gz
gcc-67f3791f7d133214b112bd831ff2876822c665d0.tar.bz2
Move thunks out of cgraph_node
this patch moves thunk_info out of cgraph_node into a symbol summary. I also moved it to separate hearder file since cgraph.h became really too fat. I plan to contiue with similar breakup in order to cleanup interfaces and reduce WPA memory footprint (symbol table now consumes more memory than trees) gcc/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * Makefile.in: Add symtab-thunks.o (GTFILES): Add symtab-thunks.h and symtab-thunks.cc; remove cgraphunit.c * cgraph.c: Include symtab-thunks.h. (cgraph_node::create_thunk): Update (symbol_table::create_edge): Update (cgraph_node::dump): Update (cgraph_node::call_for_symbol_thunks_and_aliases): Update (set_nothrow_flag_1): Update (set_malloc_flag_1): Update (set_const_flag_1): Update (collect_callers_of_node_1): Update (clone_of_p): Update (cgraph_node::verify_node): Update (cgraph_node::function_symbol): Update (cgraph_c_finalize): Call thunk_info::release. (cgraph_node::has_thunk_p): Update (cgraph_node::former_thunk_p): Move here from cgraph.h; reimplement. * cgraph.h (struct cgraph_thunk_info): Rename to symtab-thunks.h. (cgraph_node): Remove thunk field; add thunk bitfield. (cgraph_node::expand_thunk): Move to symtab-thunks.h (symtab_thunks_cc_finalize): Declare. (cgraph_node::has_gimple_body_p): Update. (cgraph_node::former_thunk_p): Update. * cgraphclones.c: Include symtab-thunks.h. (duplicate_thunk_for_node): Update. (cgraph_edge::redirect_callee_duplicating_thunks): Update. (cgraph_node::expand_all_artificial_thunks): Update. (cgraph_node::create_edge_including_clones): Update. * cgraphunit.c: Include symtab-thunks.h. (vtable_entry_type): Move to symtab-thunks.c. (cgraph_node::analyze): Update. (analyze_functions): Update. (mark_functions_to_output): Update. (thunk_adjust): Move to symtab-thunks.c (cgraph_node::expand_thunk): Move to symtab-thunks.c (cgraph_node::assemble_thunks_and_aliases): Update. (output_in_order): Update. (cgraphunit_c_finalize): Do not clear vtable_entry_type. (cgraph_node::create_wrapper): Update. * gengtype.c (open_base_files): Add symtab-thunks.h * ipa-comdats.c (propagate_comdat_group): UPdate. (ipa_comdats): Update. * ipa-cp.c (determine_versionability): UPdate. (gather_caller_stats): Update. (count_callers): Update (set_single_call_flag): Update (initialize_node_lattices): Update (call_passes_through_thunk_p): Update (call_passes_through_thunk): Update (propagate_constants_across_call): Update (find_more_scalar_values_for_callers_subset): Update (has_undead_caller_from_outside_scc_p): Update * ipa-fnsummary.c (evaluate_properties_for_edge): Update. (compute_fn_summary): Update. (inline_analyze_function): Update. * ipa-icf.c: Include symtab-thunks.h. (sem_function::equals_wpa): Update. (redirect_all_callers): Update. (sem_function::init): Update. (sem_function::parse): Update. * ipa-inline-transform.c: Include symtab-thunks.h. (inline_call): Update. (save_inline_function_body): Update. (preserve_function_body_p): Update. * ipa-inline.c (inline_small_functions): Update. * ipa-polymorphic-call.c: Include alloc-pool.h, symbol-summary.h, symtab-thunks.h (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Update. * ipa-pure-const.c: Include symtab-thunks.h. (analyze_function): Update. * ipa-sra.c (check_for_caller_issues): Update. * ipa-utils.c (ipa_reverse_postorder): Update. (ipa_merge_profiles): Update. * ipa-visibility.c (non_local_p): Update. (cgraph_node::local_p): Update. (function_and_variable_visibility): Update. * ipa.c (symbol_table::remove_unreachable_nodes): Update. * lto-cgraph.c: Include alloc-pool.h, symbol-summary.h and symtab-thunks.h (lto_output_edge): Update. (lto_output_node): Update. (compute_ltrans_boundary): Update. (output_symtab): Update. (verify_node_partition): Update. (input_overwrite_node): Update. (input_node): Update. * lto-streamer-in.c (fixup_call_stmt_edges): Update. * symtab-thunks.cc: New file. * symtab-thunks.h: New file. * toplev.c (toplev::finalize): Call symtab_thunks_cc_finalize. * trans-mem.c (ipa_tm_mayenterirr_function): Update. (ipa_tm_execute): Update. * tree-inline.c (expand_call_inline): Update. * tree-nested.c (create_nesting_tree): Update. (convert_all_function_calls): Update. (gimplify_all_functions): Update. * tree-profile.c (tree_profiling): Update. * tree-ssa-structalias.c (associate_varinfo_to_alias): Update. * tree.c (free_lang_data_in_decl): Update. * value-prof.c (init_node_map): Update. gcc/c-family/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * c-common.c (c_common_finalize_early_debug): Update for new thunk api. gcc/d/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * decl.cc (finish_thunk): Update for new thunk api. gcc/lto/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * lto-partition.c (add_symbol_to_partition_1): Update for new thunk api.
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r--gcc/lto-cgraph.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 93a99f3..19d4ca5 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -39,6 +39,9 @@ along with GCC; see the file COPYING3. If not see
#include "omp-offload.h"
#include "stringpool.h"
#include "attribs.h"
+#include "alloc-pool.h"
+#include "symbol-summary.h"
+#include "symtab-thunks.h"
/* True when asm nodes has been output. */
bool asm_nodes_output = false;
@@ -261,7 +264,7 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
: gimple_uid (edge->call_stmt) + 1;
bp_pack_enum (&bp, cgraph_inline_failed_t,
CIF_N_REASONS, edge->inline_failed);
- gcc_checking_assert (uid || edge->caller->thunk.thunk_p);
+ gcc_checking_assert (uid || edge->caller->thunk);
bp_pack_var_len_unsigned (&bp, uid);
bp_pack_value (&bp, edge->speculative_id, 16);
bp_pack_value (&bp, edge->indirect_inlining_edge, 1);
@@ -393,7 +396,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
boundary_p = !lto_symtab_encoder_in_partition_p (encoder, node);
if (node->analyzed && (!boundary_p || node->alias
- || (node->thunk.thunk_p && !node->inlined_to)))
+ || (node->thunk && !node->inlined_to)))
tag = LTO_symtab_analyzed_node;
else
tag = LTO_symtab_unavail_node;
@@ -533,10 +536,19 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
bp_pack_value (&bp, node->nonfreeing_fn, 1);
bp_pack_value (&bp, node->merged_comdat, 1);
bp_pack_value (&bp, node->merged_extern_inline, 1);
- bp_pack_value (&bp, node->thunk.thunk_p, 1);
+ bp_pack_value (&bp, node->thunk, 1);
bp_pack_value (&bp, node->parallelized_function, 1);
bp_pack_value (&bp, node->declare_variant_alt, 1);
bp_pack_value (&bp, node->calls_declare_variant_alt, 1);
+
+ /* Stream thunk info always because we use it in
+ ipa_polymorphic_call_context::ipa_polymorphic_call_context
+ to properly interpret THIS pointers for thunks that has been converted
+ to Gimple. */
+ struct thunk_info *thunk = node->definition ? thunk_info::get (node) : NULL;
+
+ bp_pack_value (&bp, thunk != NULL, 1);
+
bp_pack_enum (&bp, ld_plugin_symbol_resolution,
LDPR_NUM_KNOWN,
/* When doing incremental link, we will get new resolution
@@ -546,26 +558,15 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
streamer_write_bitpack (&bp);
streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);
- /* Stream thunk info always because we use it in
- ipa_polymorphic_call_context::ipa_polymorphic_call_context
- to properly interpret THIS pointers for thunks that has been converted
- to Gimple. */
- if (node->definition)
- {
- streamer_write_uhwi_stream
- (ob->main_stream,
- 1 + (node->thunk.this_adjusting != 0) * 2
- + (node->thunk.virtual_offset_p != 0) * 4);
- streamer_write_uhwi_stream (ob->main_stream, node->thunk.fixed_offset);
- streamer_write_uhwi_stream (ob->main_stream, node->thunk.virtual_value);
- streamer_write_uhwi_stream (ob->main_stream, node->thunk.indirect_offset);
- }
streamer_write_hwi_stream (ob->main_stream, node->profile_id);
streamer_write_hwi_stream (ob->main_stream, node->unit_id);
if (DECL_STATIC_CONSTRUCTOR (node->decl))
streamer_write_hwi_stream (ob->main_stream, node->get_init_priority ());
if (DECL_STATIC_DESTRUCTOR (node->decl))
streamer_write_hwi_stream (ob->main_stream, node->get_fini_priority ());
+
+ if (thunk)
+ thunk_info::get (node)->stream_out (ob);
}
/* Output the varpool NODE to OB.
@@ -931,7 +932,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
if (node->alias && node->analyzed)
create_references (encoder, node);
if (cnode
- && cnode->thunk.thunk_p && !cnode->inlined_to)
+ && cnode->thunk && !cnode->inlined_to)
add_node_to (encoder, cnode->callees->callee, false);
while (node->transparent_alias && node->analyzed)
{
@@ -987,7 +988,7 @@ output_symtab (void)
{
node = dyn_cast <cgraph_node *> (lto_symtab_encoder_deref (encoder, i));
if (node
- && ((node->thunk.thunk_p && !node->inlined_to)
+ && ((node->thunk && !node->inlined_to)
|| lto_symtab_encoder_in_partition_p (encoder, node)))
{
output_outgoing_cgraph_edges (node->callees, ob, encoder);
@@ -1139,13 +1140,14 @@ verify_node_partition (symtab_node *node)
NODE or to replace the values in it, for instance because the first
time we saw it, the function body was not available but now it
is. BP is a bitpack with all the bitflags for NODE read from the
- stream. */
+ stream. Initialize HAS_THUNK_INFO to indicate if thunk info should
+ be streamed in. */
static void
input_overwrite_node (struct lto_file_decl_data *file_data,
struct cgraph_node *node,
enum LTO_symtab_tags tag,
- struct bitpack_d *bp)
+ struct bitpack_d *bp, bool *has_thunk_info)
{
node->aux = (void *) tag;
node->lto_file_data = file_data;
@@ -1194,10 +1196,11 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
node->nonfreeing_fn = bp_unpack_value (bp, 1);
node->merged_comdat = bp_unpack_value (bp, 1);
node->merged_extern_inline = bp_unpack_value (bp, 1);
- node->thunk.thunk_p = bp_unpack_value (bp, 1);
+ node->thunk = bp_unpack_value (bp, 1);
node->parallelized_function = bp_unpack_value (bp, 1);
node->declare_variant_alt = bp_unpack_value (bp, 1);
node->calls_declare_variant_alt = bp_unpack_value (bp, 1);
+ *has_thunk_info = bp_unpack_value (bp, 1);
node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution,
LDPR_NUM_KNOWN);
node->split_part = bp_unpack_value (bp, 1);
@@ -1235,6 +1238,7 @@ input_node (struct lto_file_decl_data *file_data,
const char *section;
order = streamer_read_hwi (ib) + file_data->order_base;
clone_ref = streamer_read_hwi (ib);
+ bool has_thunk_info;
fn_decl = lto_input_fn_decl_ref (ib, file_data);
@@ -1294,7 +1298,7 @@ input_node (struct lto_file_decl_data *file_data,
bp = streamer_read_bitpack (ib);
- input_overwrite_node (file_data, node, tag, &bp);
+ input_overwrite_node (file_data, node, tag, &bp, &has_thunk_info);
/* Store a reference for now, and fix up later to be a pointer. */
node->inlined_to = (cgraph_node *) (intptr_t) ref;
@@ -1311,19 +1315,6 @@ input_node (struct lto_file_decl_data *file_data,
if (section)
node->set_section_for_node (section);
- if (node->definition)
- {
- int type = streamer_read_uhwi (ib);
- HOST_WIDE_INT fixed_offset = streamer_read_uhwi (ib);
- HOST_WIDE_INT virtual_value = streamer_read_uhwi (ib);
- HOST_WIDE_INT indirect_offset = streamer_read_uhwi (ib);
-
- node->thunk.fixed_offset = fixed_offset;
- node->thunk.virtual_value = virtual_value;
- node->thunk.indirect_offset = indirect_offset;
- node->thunk.this_adjusting = (type & 2);
- node->thunk.virtual_offset_p = (type & 4);
- }
if (node->alias && !node->analyzed && node->weakref)
node->alias_target = get_alias_symbol (node->decl);
node->profile_id = streamer_read_hwi (ib);
@@ -1335,6 +1326,9 @@ input_node (struct lto_file_decl_data *file_data,
if (DECL_STATIC_DESTRUCTOR (node->decl))
node->set_fini_priority (streamer_read_hwi (ib));
+ if (has_thunk_info)
+ thunk_info::get_create (node)->stream_in (ib);
+
return node;
}