{
int ref;
void **slot;
-
+
slot = pointer_map_contains (encoder->map, node);
if (!slot)
{
if (ref == LCC_NOT_FOUND)
return NULL;
- return VEC_index (cgraph_node_ptr, encoder->nodes, ref);
+ return VEC_index (cgraph_node_ptr, encoder->nodes, ref);
}
lto_output_uleb128_stream (ob->main_stream, LTO_cgraph_edge);
ref = lto_cgraph_encoder_lookup (encoder, edge->caller);
- gcc_assert (ref != LCC_NOT_FOUND);
+ gcc_assert (ref != LCC_NOT_FOUND);
lto_output_sleb128_stream (ob->main_stream, ref);
ref = lto_cgraph_encoder_lookup (encoder, edge->callee);
- gcc_assert (ref != LCC_NOT_FOUND);
+ gcc_assert (ref != LCC_NOT_FOUND);
lto_output_sleb128_stream (ob->main_stream, ref);
lto_output_sleb128_stream (ob->main_stream, edge->count);
bitpack_delete (bp);
}
+/* Return true when node is reachable from other partition. */
+
+static bool
+reachable_from_other_partition_p (struct cgraph_node *node, cgraph_node_set set)
+{
+ struct cgraph_edge *e;
+ if (node->needed)
+ return true;
+ if (!node->analyzed)
+ return false;
+ if (node->global.inlined_to)
+ return false;
+ for (e = node->callers; e; e = e->next_caller)
+ if (!cgraph_node_in_set_p (e->caller, set))
+ return true;
+ return false;
+}
/* Output the cgraph NODE to OB. ENCODER is used to find the
reference number of NODE->inlined_to. SET is the set of nodes we
unsigned local, externally_visible, inlinable, analyzed;
bool boundary_p, wrote_decl_p;
intptr_t ref;
+ bool in_other_partition = false;
boundary_p = !cgraph_node_in_set_p (node, set);
wrote_decl_p = bitmap_bit_p (written_decls, DECL_UID (node->decl));
case AVAIL_LOCAL:
tag = LTO_cgraph_avail_node;
break;
-
+
case AVAIL_OVERWRITABLE:
tag = LTO_cgraph_overwritable_node;
break;
-
+
default:
gcc_unreachable ();
}
-
+
if (boundary_p)
tag = LTO_cgraph_unavail_node;
Boundary nodes: There are nodes that are not part of SET but are
called from within SET. We artificially make them look like
- externally visible nodes with no function body.
+ externally visible nodes with no function body.
Cherry-picked nodes: These are nodes we pulled from other
translation units into SET during IPA-inlining. We make them as
local static nodes to prevent clashes with other local statics. */
if (boundary_p)
{
- /* Inline clones can not be part of boundary. */
- gcc_assert (!node->global.inlined_to);
- local = 0;
- externally_visible = 1;
- inlinable = 0;
+ /* Inline clones can not be part of boundary.
+ gcc_assert (!node->global.inlined_to);
+
+ FIXME: At the moment they can be, when partition contains an inline
+ clone that is clone of inline clone from outside partition. We can
+ reshape the clone tree and make other tree to be the root, but it
+ needs a bit extra work and will be promplty done by cgraph_remove_node
+ after reading back. */
+ in_other_partition = 1;
analyzed = 0;
}
- else if (lto_forced_extern_inline_p (node->decl))
- {
- local = 1;
- externally_visible = 0;
- inlinable = 1;
- }
lto_output_uleb128_stream (ob->main_stream, wrote_decl_p);
bp_pack_value (bp, node->address_taken, 1);
bp_pack_value (bp, node->abstract_and_needed, 1);
bp_pack_value (bp, node->reachable, 1);
+ bp_pack_value (bp, analyzed && reachable_from_other_partition_p (node, set), 1);
bp_pack_value (bp, node->lowered, 1);
bp_pack_value (bp, analyzed, 1);
+ bp_pack_value (bp, in_other_partition, 1);
bp_pack_value (bp, node->process, 1);
bp_pack_value (bp, node->alias, 1);
bp_pack_value (bp, node->finalized_by_frontend, 1);
+ bp_pack_value (bp, node->frequency, 2);
lto_output_bitpack (ob->main_stream, bp);
bitpack_delete (bp);
if (tag != LTO_cgraph_unavail_node)
{
- lto_output_sleb128_stream (ob->main_stream,
+ lto_output_sleb128_stream (ob->main_stream,
node->local.inline_summary.estimated_self_stack_size);
- lto_output_sleb128_stream (ob->main_stream,
+ lto_output_sleb128_stream (ob->main_stream,
node->local.inline_summary.self_size);
- lto_output_sleb128_stream (ob->main_stream,
+ lto_output_sleb128_stream (ob->main_stream,
node->local.inline_summary.size_inlining_benefit);
- lto_output_sleb128_stream (ob->main_stream,
+ lto_output_sleb128_stream (ob->main_stream,
node->local.inline_summary.self_time);
- lto_output_sleb128_stream (ob->main_stream,
+ lto_output_sleb128_stream (ob->main_stream,
node->local.inline_summary.time_inlining_benefit);
}
lto_output_sleb128_stream (ob->main_stream,
node->global.estimated_growth);
lto_output_uleb128_stream (ob->main_stream, node->global.inlined);
+ if (node->same_comdat_group && !boundary_p)
+ {
+ ref = lto_cgraph_encoder_lookup (encoder, node->same_comdat_group);
+ gcc_assert (ref != LCC_NOT_FOUND);
+ }
+ else
+ ref = LCC_NOT_FOUND;
+ lto_output_sleb128_stream (ob->main_stream, ref);
+
+ if (node->same_body)
+ {
+ struct cgraph_node *alias;
+ unsigned long alias_count = 1;
+ for (alias = node->same_body; alias->next; alias = alias->next)
+ alias_count++;
+ lto_output_uleb128_stream (ob->main_stream, alias_count);
+ do
+ {
+ 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);
+ }
+ alias = alias->previous;
+ }
+ while (alias);
+ }
+ else
+ lto_output_uleb128_stream (ob->main_stream, 0);
}
/* Stream out profile_summary to OB. */
lto_output_uleb128_stream (ob->main_stream, 0);
}
+/* Add NODE into encoder as well as nodes it is cloned from.
+ Do it in a way so clones appear first. */
+static void
+add_node_to (lto_cgraph_encoder_t encoder, struct cgraph_node *node)
+{
+ if (node->clone_of)
+ add_node_to (encoder, node->clone_of);
+ lto_cgraph_encoder_encode (encoder, node);
+}
/* Output the part of the cgraph in SET. */
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
{
node = csi_node (csi);
- lto_cgraph_encoder_encode (encoder, node);
+ add_node_to (encoder, node);
}
/* Go over all the nodes again to include callees that are not in
{
/* We should have moved all the inlines. */
gcc_assert (!callee->global.inlined_to);
- lto_cgraph_encoder_encode (encoder, callee);
+ add_node_to (encoder, callee);
}
}
}
- /* Write out the nodes. */
+ /* Write out the nodes. We must first output a node and then its clones,
+ otherwise at a time reading back the node there would be nothing to clone
+ from. */
n_nodes = lto_cgraph_encoder_size (encoder);
for (i = 0; i < n_nodes; i++)
{
node->address_taken = bp_unpack_value (bp, 1);
node->abstract_and_needed = bp_unpack_value (bp, 1);
node->reachable = bp_unpack_value (bp, 1);
+ node->reachable_from_other_partition = bp_unpack_value (bp, 1);
node->lowered = bp_unpack_value (bp, 1);
node->analyzed = bp_unpack_value (bp, 1);
+ node->in_other_partition = bp_unpack_value (bp, 1);
node->process = bp_unpack_value (bp, 1);
node->alias = bp_unpack_value (bp, 1);
node->finalized_by_frontend = bp_unpack_value (bp, 1);
+ node->frequency = (enum node_frequency)bp_unpack_value (bp, 2);
}
-/* Read a node from input_block IB. TAG is the node's tag just read.
+/* Read a node from input_block IB. TAG is the node's tag just read.
Return the node read or overwriten. */
-
+
static struct cgraph_node *
input_node (struct lto_file_decl_data *file_data,
struct lto_input_block *ib,
bool clone_p;
int estimated_stack_size = 0;
int stack_frame_offset = 0;
- int ref = LCC_NOT_FOUND;
+ int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
int estimated_growth = 0;
int time = 0;
int size = 0;
int self_size = 0;
int time_inlining_benefit = 0;
int size_inlining_benefit = 0;
+ unsigned long same_body_count = 0;
bool inlined = false;
clone_p = (lto_input_uleb128 (ib) != 0);
node->count = lto_input_sleb128 (ib);
bp = lto_input_bitpack (ib);
-
+
if (tag != LTO_cgraph_unavail_node)
{
stack_size = lto_input_sleb128 (ib);
size = lto_input_sleb128 (ib);
estimated_growth = lto_input_sleb128 (ib);
inlined = lto_input_uleb128 (ib);
+ ref2 = lto_input_sleb128 (ib);
+ same_body_count = lto_input_uleb128 (ib);
/* Make sure that we have not read this node before. Nodes that
have already been read will have their tag stored in the 'aux'
node->global.estimated_growth = estimated_growth;
node->global.inlined = inlined;
+ /* Store a reference for now, and fix up later to be a pointer. */
+ node->same_comdat_group = (cgraph_node_ptr) (intptr_t) ref2;
+
+ while (same_body_count-- > 0)
+ {
+ tree alias_decl;
+ int type;
+ 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);
+ cgraph_same_body_alias (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);
+ cgraph_add_thunk (alias_decl, fn_decl, type & 2, fixed_offset,
+ virtual_value,
+ (type & 4) ? size_int (virtual_value) : NULL_TREE,
+ real_alias);
+ }
+ }
return node;
}
{
if (tag == LTO_cgraph_edge)
input_edge (ib, nodes);
- else
+ else
{
node = input_node (file_data, ib, tag);
if (node == NULL || node->decl == NULL_TREE)
for (i = 0; VEC_iterate (cgraph_node_ptr, nodes, i, node); i++)
{
- const int ref = (int) (intptr_t) node->global.inlined_to;
+ int ref = (int) (intptr_t) node->global.inlined_to;
/* Fixup inlined_to from reference to pointer. */
if (ref != LCC_NOT_FOUND)
node->global.inlined_to = VEC_index (cgraph_node_ptr, nodes, ref);
else
node->global.inlined_to = NULL;
+
+ ref = (int) (intptr_t) node->same_comdat_group;
+
+ /* Fixup same_comdat_group from reference to pointer. */
+ if (ref != LCC_NOT_FOUND)
+ node->same_comdat_group = VEC_index (cgraph_node_ptr, nodes, ref);
+ else
+ node->same_comdat_group = NULL;
}
VEC_free (cgraph_node_ptr, heap, nodes);
size_t len;
struct lto_input_block *ib;
- ib = lto_create_simple_input_block (file_data, LTO_section_cgraph,
+ ib = lto_create_simple_input_block (file_data, LTO_section_cgraph,
&data, &len);
input_profile_summary (ib);
file_data->cgraph_node_encoder = lto_cgraph_encoder_new ();
input_cgraph_1 (file_data, ib);
- lto_destroy_simple_input_block (file_data, LTO_section_cgraph,
+ lto_destroy_simple_input_block (file_data, LTO_section_cgraph,
ib, data, len);
-
+
/* Assume that every file read needs to be processed by LTRANS. */
if (flag_wpa)
lto_mark_file_for_ltrans (file_data);
- }
+ }
/* Clear out the aux field that was used to store enough state to
tell which nodes should be overwritten. */