+
+/* Return a heap allocated vector containing formal parameters of FNDECL. */
+
+VEC(tree, heap) *
+ipa_get_vector_of_formal_parms (tree fndecl)
+{
+ VEC(tree, heap) *args;
+ int count;
+ tree parm;
+
+ count = count_formal_params_1 (fndecl);
+ args = VEC_alloc (tree, heap, count);
+ for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
+ VEC_quick_push (tree, args, parm);
+
+ return args;
+}
+
+/* Return a heap allocated vector containing types of formal parameters of
+ function type FNTYPE. */
+
+static inline VEC(tree, heap) *
+get_vector_of_formal_parm_types (tree fntype)
+{
+ VEC(tree, heap) *types;
+ int count = 0;
+ tree t;
+
+ for (t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
+ count++;
+
+ types = VEC_alloc (tree, heap, count);
+ for (t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
+ VEC_quick_push (tree, types, TREE_VALUE (t));
+
+ return types;
+}
+
+/* Modify the function declaration FNDECL and its type according to the plan in
+ ADJUSTMENTS. It also sets base fields of individual adjustments structures
+ to reflect the actual parameters being modified which are determined by the
+ base_index field. */
+
+void
+ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments,
+ const char *synth_parm_prefix)
+{
+ VEC(tree, heap) *oparms, *otypes;
+ tree orig_type, new_type = NULL;
+ tree old_arg_types, t, new_arg_types = NULL;
+ tree parm, *link = &DECL_ARGUMENTS (fndecl);
+ int i, len = VEC_length (ipa_parm_adjustment_t, adjustments);
+ tree new_reversed = NULL;
+ bool care_for_types, last_parm_void;
+
+ if (!synth_parm_prefix)
+ synth_parm_prefix = "SYNTH";
+
+ oparms = ipa_get_vector_of_formal_parms (fndecl);
+ orig_type = TREE_TYPE (fndecl);
+ old_arg_types = TYPE_ARG_TYPES (orig_type);
+
+ /* The following test is an ugly hack, some functions simply don't have any
+ arguments in their type. This is probably a bug but well... */
+ care_for_types = (old_arg_types != NULL_TREE);
+ if (care_for_types)
+ {
+ last_parm_void = (TREE_VALUE (tree_last (old_arg_types))
+ == void_type_node);
+ otypes = get_vector_of_formal_parm_types (orig_type);
+ if (last_parm_void)
+ gcc_assert (VEC_length (tree, oparms) + 1 == VEC_length (tree, otypes));
+ else
+ gcc_assert (VEC_length (tree, oparms) == VEC_length (tree, otypes));
+ }
+ else
+ {
+ last_parm_void = false;
+ otypes = NULL;
+ }
+
+ for (i = 0; i < len; i++)
+ {
+ struct ipa_parm_adjustment *adj;
+ gcc_assert (link);
+
+ adj = VEC_index (ipa_parm_adjustment_t, adjustments, i);
+ parm = VEC_index (tree, oparms, adj->base_index);
+ adj->base = parm;
+
+ if (adj->copy_param)
+ {
+ if (care_for_types)
+ new_arg_types = tree_cons (NULL_TREE, VEC_index (tree, otypes,
+ adj->base_index),
+ new_arg_types);
+ *link = parm;
+ link = &DECL_CHAIN (parm);
+ }
+ else if (!adj->remove_param)
+ {
+ tree new_parm;
+ tree ptype;
+
+ if (adj->by_ref)
+ ptype = build_pointer_type (adj->type);
+ else
+ ptype = adj->type;
+
+ if (care_for_types)
+ new_arg_types = tree_cons (NULL_TREE, ptype, new_arg_types);
+
+ new_parm = build_decl (UNKNOWN_LOCATION, PARM_DECL, NULL_TREE,
+ ptype);
+ DECL_NAME (new_parm) = create_tmp_var_name (synth_parm_prefix);
+
+ DECL_ARTIFICIAL (new_parm) = 1;
+ DECL_ARG_TYPE (new_parm) = ptype;
+ DECL_CONTEXT (new_parm) = fndecl;
+ TREE_USED (new_parm) = 1;
+ DECL_IGNORED_P (new_parm) = 1;
+ layout_decl (new_parm, 0);
+
+ add_referenced_var (new_parm);
+ mark_sym_for_renaming (new_parm);
+ adj->base = parm;
+ adj->reduction = new_parm;
+
+ *link = new_parm;
+
+ link = &DECL_CHAIN (new_parm);
+ }
+ }
+
+ *link = NULL_TREE;
+
+ if (care_for_types)
+ {
+ new_reversed = nreverse (new_arg_types);
+ if (last_parm_void)
+ {
+ if (new_reversed)
+ TREE_CHAIN (new_arg_types) = void_list_node;
+ else
+ new_reversed = void_list_node;
+ }
+ }
+
+ /* Use copy_node to preserve as much as possible from original type
+ (debug info, attribute lists etc.)
+ Exception is METHOD_TYPEs must have THIS argument.
+ When we are asked to remove it, we need to build new FUNCTION_TYPE
+ instead. */
+ if (TREE_CODE (orig_type) != METHOD_TYPE
+ || (VEC_index (ipa_parm_adjustment_t, adjustments, 0)->copy_param
+ && VEC_index (ipa_parm_adjustment_t, adjustments, 0)->base_index == 0))
+ {
+ new_type = build_distinct_type_copy (orig_type);
+ TYPE_ARG_TYPES (new_type) = new_reversed;
+ }
+ else
+ {
+ new_type
+ = build_distinct_type_copy (build_function_type (TREE_TYPE (orig_type),
+ new_reversed));
+ TYPE_CONTEXT (new_type) = TYPE_CONTEXT (orig_type);
+ DECL_VINDEX (fndecl) = NULL_TREE;
+ }
+
+ /* When signature changes, we need to clear builtin info. */
+ if (DECL_BUILT_IN (fndecl))
+ {
+ DECL_BUILT_IN_CLASS (fndecl) = NOT_BUILT_IN;
+ DECL_FUNCTION_CODE (fndecl) = (enum built_in_function) 0;
+ }
+
+ /* This is a new type, not a copy of an old type. Need to reassociate
+ variants. We can handle everything except the main variant lazily. */
+ t = TYPE_MAIN_VARIANT (orig_type);
+ if (orig_type != t)
+ {
+ TYPE_MAIN_VARIANT (new_type) = t;
+ TYPE_NEXT_VARIANT (new_type) = TYPE_NEXT_VARIANT (t);
+ TYPE_NEXT_VARIANT (t) = new_type;
+ }
+ else
+ {
+ TYPE_MAIN_VARIANT (new_type) = new_type;
+ TYPE_NEXT_VARIANT (new_type) = NULL;
+ }
+
+ TREE_TYPE (fndecl) = new_type;
+ DECL_VIRTUAL_P (fndecl) = 0;
+ if (otypes)
+ VEC_free (tree, heap, otypes);
+ VEC_free (tree, heap, oparms);
+}
+
+/* Modify actual arguments of a function call CS as indicated in ADJUSTMENTS.
+ If this is a directly recursive call, CS must be NULL. Otherwise it must
+ contain the corresponding call graph edge. */
+
+void
+ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
+ ipa_parm_adjustment_vec adjustments)
+{
+ VEC(tree, heap) *vargs;
+ gimple new_stmt;
+ gimple_stmt_iterator gsi;
+ tree callee_decl;
+ int i, len;
+
+ len = VEC_length (ipa_parm_adjustment_t, adjustments);
+ vargs = VEC_alloc (tree, heap, len);
+
+ gsi = gsi_for_stmt (stmt);
+ for (i = 0; i < len; i++)
+ {
+ struct ipa_parm_adjustment *adj;
+
+ adj = VEC_index (ipa_parm_adjustment_t, adjustments, i);
+
+ if (adj->copy_param)
+ {
+ tree arg = gimple_call_arg (stmt, adj->base_index);
+
+ VEC_quick_push (tree, vargs, arg);
+ }
+ else if (!adj->remove_param)
+ {
+ tree expr, base, off;
+ location_t loc;
+
+ /* We create a new parameter out of the value of the old one, we can
+ do the following kind of transformations:
+
+ - A scalar passed by reference is converted to a scalar passed by
+ value. (adj->by_ref is false and the type of the original
+ actual argument is a pointer to a scalar).
+
+ - A part of an aggregate is passed instead of the whole aggregate.
+ The part can be passed either by value or by reference, this is
+ determined by value of adj->by_ref. Moreover, the code below
+ handles both situations when the original aggregate is passed by
+ value (its type is not a pointer) and when it is passed by
+ reference (it is a pointer to an aggregate).
+
+ When the new argument is passed by reference (adj->by_ref is true)
+ it must be a part of an aggregate and therefore we form it by
+ simply taking the address of a reference inside the original
+ aggregate. */
+
+ gcc_checking_assert (adj->offset % BITS_PER_UNIT == 0);
+ base = gimple_call_arg (stmt, adj->base_index);
+ loc = EXPR_LOCATION (base);
+
+ if (TREE_CODE (base) != ADDR_EXPR
+ && POINTER_TYPE_P (TREE_TYPE (base)))
+ off = build_int_cst (adj->alias_ptr_type,
+ adj->offset / BITS_PER_UNIT);
+ else
+ {
+ HOST_WIDE_INT base_offset;
+ tree prev_base;
+
+ if (TREE_CODE (base) == ADDR_EXPR)
+ base = TREE_OPERAND (base, 0);
+ prev_base = base;
+ base = get_addr_base_and_unit_offset (base, &base_offset);
+ /* Aggregate arguments can have non-invariant addresses. */
+ if (!base)
+ {
+ base = build_fold_addr_expr (prev_base);
+ off = build_int_cst (adj->alias_ptr_type,
+ adj->offset / BITS_PER_UNIT);
+ }
+ else if (TREE_CODE (base) == MEM_REF)
+ {
+ off = build_int_cst (adj->alias_ptr_type,
+ base_offset
+ + adj->offset / BITS_PER_UNIT);
+ off = int_const_binop (PLUS_EXPR, TREE_OPERAND (base, 1),
+ off, 0);
+ base = TREE_OPERAND (base, 0);
+ }
+ else
+ {
+ off = build_int_cst (adj->alias_ptr_type,
+ base_offset
+ + adj->offset / BITS_PER_UNIT);
+ base = build_fold_addr_expr (base);
+ }
+ }
+
+ expr = fold_build2_loc (loc, MEM_REF, adj->type, base, off);
+ if (adj->by_ref)
+ expr = build_fold_addr_expr (expr);
+
+ expr = force_gimple_operand_gsi (&gsi, expr,
+ adj->by_ref
+ || is_gimple_reg_type (adj->type),
+ NULL, true, GSI_SAME_STMT);
+ VEC_quick_push (tree, vargs, expr);
+ }
+ }
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "replacing stmt:");
+ print_gimple_stmt (dump_file, gsi_stmt (gsi), 0, 0);
+ }
+
+ callee_decl = !cs ? gimple_call_fndecl (stmt) : cs->callee->decl;
+ new_stmt = gimple_build_call_vec (callee_decl, vargs);
+ VEC_free (tree, heap, vargs);
+ if (gimple_call_lhs (stmt))
+ gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
+
+ gimple_set_block (new_stmt, gimple_block (stmt));
+ if (gimple_has_location (stmt))
+ gimple_set_location (new_stmt, gimple_location (stmt));
+ gimple_call_copy_flags (new_stmt, stmt);
+ gimple_call_set_chain (new_stmt, gimple_call_chain (stmt));
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "with stmt:");
+ print_gimple_stmt (dump_file, new_stmt, 0, 0);
+ fprintf (dump_file, "\n");
+ }
+ gsi_replace (&gsi, new_stmt, true);
+ if (cs)
+ cgraph_set_call_stmt (cs, new_stmt);
+ update_ssa (TODO_update_ssa);
+ free_dominance_info (CDI_DOMINATORS);
+}
+
+/* Return true iff BASE_INDEX is in ADJUSTMENTS more than once. */
+
+static bool
+index_in_adjustments_multiple_times_p (int base_index,
+ ipa_parm_adjustment_vec adjustments)
+{
+ int i, len = VEC_length (ipa_parm_adjustment_t, adjustments);
+ bool one = false;
+
+ for (i = 0; i < len; i++)
+ {
+ struct ipa_parm_adjustment *adj;
+ adj = VEC_index (ipa_parm_adjustment_t, adjustments, i);
+
+ if (adj->base_index == base_index)
+ {
+ if (one)
+ return true;
+ else
+ one = true;
+ }
+ }
+ return false;
+}
+
+
+/* Return adjustments that should have the same effect on function parameters
+ and call arguments as if they were first changed according to adjustments in
+ INNER and then by adjustments in OUTER. */
+
+ipa_parm_adjustment_vec
+ipa_combine_adjustments (ipa_parm_adjustment_vec inner,
+ ipa_parm_adjustment_vec outer)
+{
+ int i, outlen = VEC_length (ipa_parm_adjustment_t, outer);
+ int inlen = VEC_length (ipa_parm_adjustment_t, inner);
+ int removals = 0;
+ ipa_parm_adjustment_vec adjustments, tmp;
+
+ tmp = VEC_alloc (ipa_parm_adjustment_t, heap, inlen);
+ for (i = 0; i < inlen; i++)
+ {
+ struct ipa_parm_adjustment *n;
+ n = VEC_index (ipa_parm_adjustment_t, inner, i);
+
+ if (n->remove_param)
+ removals++;
+ else
+ VEC_quick_push (ipa_parm_adjustment_t, tmp, n);
+ }
+
+ adjustments = VEC_alloc (ipa_parm_adjustment_t, heap, outlen + removals);
+ for (i = 0; i < outlen; i++)
+ {
+ struct ipa_parm_adjustment *r;
+ struct ipa_parm_adjustment *out = VEC_index (ipa_parm_adjustment_t,
+ outer, i);
+ struct ipa_parm_adjustment *in = VEC_index (ipa_parm_adjustment_t, tmp,
+ out->base_index);
+
+ gcc_assert (!in->remove_param);
+ if (out->remove_param)
+ {
+ if (!index_in_adjustments_multiple_times_p (in->base_index, tmp))
+ {
+ r = VEC_quick_push (ipa_parm_adjustment_t, adjustments, NULL);
+ memset (r, 0, sizeof (*r));
+ r->remove_param = true;
+ }
+ continue;
+ }
+
+ r = VEC_quick_push (ipa_parm_adjustment_t, adjustments, NULL);
+ memset (r, 0, sizeof (*r));
+ r->base_index = in->base_index;
+ r->type = out->type;
+
+ /* FIXME: Create nonlocal value too. */
+
+ if (in->copy_param && out->copy_param)
+ r->copy_param = true;
+ else if (in->copy_param)
+ r->offset = out->offset;
+ else if (out->copy_param)
+ r->offset = in->offset;
+ else
+ r->offset = in->offset + out->offset;
+ }
+
+ for (i = 0; i < inlen; i++)
+ {
+ struct ipa_parm_adjustment *n = VEC_index (ipa_parm_adjustment_t,
+ inner, i);
+
+ if (n->remove_param)
+ VEC_quick_push (ipa_parm_adjustment_t, adjustments, n);
+ }
+
+ VEC_free (ipa_parm_adjustment_t, heap, tmp);
+ return adjustments;
+}
+
+/* Dump the adjustments in the vector ADJUSTMENTS to dump_file in a human
+ friendly way, assuming they are meant to be applied to FNDECL. */
+
+void
+ipa_dump_param_adjustments (FILE *file, ipa_parm_adjustment_vec adjustments,
+ tree fndecl)
+{
+ int i, len = VEC_length (ipa_parm_adjustment_t, adjustments);
+ bool first = true;
+ VEC(tree, heap) *parms = ipa_get_vector_of_formal_parms (fndecl);
+
+ fprintf (file, "IPA param adjustments: ");
+ for (i = 0; i < len; i++)
+ {
+ struct ipa_parm_adjustment *adj;
+ adj = VEC_index (ipa_parm_adjustment_t, adjustments, i);
+
+ if (!first)
+ fprintf (file, " ");
+ else
+ first = false;
+
+ fprintf (file, "%i. base_index: %i - ", i, adj->base_index);
+ print_generic_expr (file, VEC_index (tree, parms, adj->base_index), 0);
+ if (adj->base)
+ {
+ fprintf (file, ", base: ");
+ print_generic_expr (file, adj->base, 0);
+ }
+ if (adj->reduction)
+ {
+ fprintf (file, ", reduction: ");
+ print_generic_expr (file, adj->reduction, 0);
+ }
+ if (adj->new_ssa_base)
+ {
+ fprintf (file, ", new_ssa_base: ");
+ print_generic_expr (file, adj->new_ssa_base, 0);
+ }
+
+ if (adj->copy_param)
+ fprintf (file, ", copy_param");
+ else if (adj->remove_param)
+ fprintf (file, ", remove_param");
+ else
+ fprintf (file, ", offset %li", (long) adj->offset);
+ if (adj->by_ref)
+ fprintf (file, ", by_ref");
+ print_node_brief (file, ", type: ", adj->type, 0);
+ fprintf (file, "\n");
+ }
+ VEC_free (tree, heap, parms);
+}
+
+/* Stream out jump function JUMP_FUNC to OB. */
+
+static void
+ipa_write_jump_function (struct output_block *ob,
+ struct ipa_jump_func *jump_func)
+{
+ lto_output_uleb128_stream (ob->main_stream,
+ jump_func->type);
+
+ switch (jump_func->type)
+ {
+ case IPA_JF_UNKNOWN:
+ break;
+ case IPA_JF_KNOWN_TYPE:
+ lto_output_tree (ob, jump_func->value.base_binfo, true);
+ break;
+ case IPA_JF_CONST:
+ lto_output_tree (ob, jump_func->value.constant, true);
+ break;
+ case IPA_JF_PASS_THROUGH:
+ lto_output_tree (ob, jump_func->value.pass_through.operand, true);
+ lto_output_uleb128_stream (ob->main_stream,
+ jump_func->value.pass_through.formal_id);
+ lto_output_uleb128_stream (ob->main_stream,
+ jump_func->value.pass_through.operation);
+ break;
+ case IPA_JF_ANCESTOR:
+ lto_output_uleb128_stream (ob->main_stream,
+ jump_func->value.ancestor.offset);
+ lto_output_tree (ob, jump_func->value.ancestor.type, true);
+ lto_output_uleb128_stream (ob->main_stream,
+ jump_func->value.ancestor.formal_id);
+ break;
+ case IPA_JF_CONST_MEMBER_PTR:
+ lto_output_tree (ob, jump_func->value.member_cst.pfn, true);
+ lto_output_tree (ob, jump_func->value.member_cst.delta, false);
+ break;
+ }
+}
+
+/* Read in jump function JUMP_FUNC from IB. */
+
+static void
+ipa_read_jump_function (struct lto_input_block *ib,
+ struct ipa_jump_func *jump_func,
+ struct data_in *data_in)
+{
+ jump_func->type = (enum jump_func_type) lto_input_uleb128 (ib);
+
+ switch (jump_func->type)
+ {
+ case IPA_JF_UNKNOWN:
+ break;
+ case IPA_JF_KNOWN_TYPE:
+ jump_func->value.base_binfo = lto_input_tree (ib, data_in);
+ break;
+ case IPA_JF_CONST:
+ jump_func->value.constant = lto_input_tree (ib, data_in);
+ break;
+ case IPA_JF_PASS_THROUGH:
+ jump_func->value.pass_through.operand = lto_input_tree (ib, data_in);
+ jump_func->value.pass_through.formal_id = lto_input_uleb128 (ib);
+ jump_func->value.pass_through.operation = (enum tree_code) lto_input_uleb128 (ib);
+ break;
+ case IPA_JF_ANCESTOR:
+ jump_func->value.ancestor.offset = lto_input_uleb128 (ib);
+ jump_func->value.ancestor.type = lto_input_tree (ib, data_in);
+ jump_func->value.ancestor.formal_id = lto_input_uleb128 (ib);
+ break;
+ case IPA_JF_CONST_MEMBER_PTR:
+ jump_func->value.member_cst.pfn = lto_input_tree (ib, data_in);
+ jump_func->value.member_cst.delta = lto_input_tree (ib, data_in);
+ break;
+ }
+}
+
+/* Stream out parts of cgraph_indirect_call_info corresponding to CS that are
+ relevant to indirect inlining to OB. */
+
+static void
+ipa_write_indirect_edge_info (struct output_block *ob,
+ struct cgraph_edge *cs)
+{
+ struct cgraph_indirect_call_info *ii = cs->indirect_info;
+ struct bitpack_d bp;
+
+ lto_output_sleb128_stream (ob->main_stream, ii->param_index);
+ lto_output_sleb128_stream (ob->main_stream, ii->anc_offset);
+ bp = bitpack_create (ob->main_stream);
+ bp_pack_value (&bp, ii->polymorphic, 1);
+ lto_output_bitpack (&bp);
+
+ if (ii->polymorphic)
+ {
+ lto_output_sleb128_stream (ob->main_stream, ii->otr_token);
+ lto_output_tree (ob, ii->otr_type, true);
+ }
+}
+
+/* Read in parts of cgraph_indirect_call_info corresponding to CS that are
+ relevant to indirect inlining from IB. */
+
+static void
+ipa_read_indirect_edge_info (struct lto_input_block *ib,
+ struct data_in *data_in ATTRIBUTE_UNUSED,
+ struct cgraph_edge *cs)
+{
+ struct cgraph_indirect_call_info *ii = cs->indirect_info;
+ struct bitpack_d bp;
+
+ ii->param_index = (int) lto_input_sleb128 (ib);
+ ii->anc_offset = (HOST_WIDE_INT) lto_input_sleb128 (ib);
+ bp = lto_input_bitpack (ib);
+ ii->polymorphic = bp_unpack_value (&bp, 1);
+ if (ii->polymorphic)
+ {
+ ii->otr_token = (HOST_WIDE_INT) lto_input_sleb128 (ib);
+ ii->otr_type = lto_input_tree (ib, data_in);
+ }
+}
+
+/* Stream out NODE info to OB. */
+
+static void
+ipa_write_node_info (struct output_block *ob, struct cgraph_node *node)
+{
+ int node_ref;
+ lto_cgraph_encoder_t encoder;
+ struct ipa_node_params *info = IPA_NODE_REF (node);
+ int j;
+ struct cgraph_edge *e;
+ struct bitpack_d bp;
+
+ encoder = ob->decl_state->cgraph_node_encoder;
+ node_ref = lto_cgraph_encoder_encode (encoder, node);
+ lto_output_uleb128_stream (ob->main_stream, node_ref);
+
+ bp = bitpack_create (ob->main_stream);
+ bp_pack_value (&bp, info->called_with_var_arguments, 1);
+ gcc_assert (info->uses_analysis_done
+ || ipa_get_param_count (info) == 0);
+ gcc_assert (!info->node_enqueued);
+ gcc_assert (!info->ipcp_orig_node);
+ for (j = 0; j < ipa_get_param_count (info); j++)
+ bp_pack_value (&bp, info->params[j].used, 1);
+ lto_output_bitpack (&bp);
+ for (e = node->callees; e; e = e->next_callee)
+ {
+ struct ipa_edge_args *args = IPA_EDGE_REF (e);
+
+ lto_output_uleb128_stream (ob->main_stream,
+ ipa_get_cs_argument_count (args));
+ for (j = 0; j < ipa_get_cs_argument_count (args); j++)
+ ipa_write_jump_function (ob, ipa_get_ith_jump_func (args, j));
+ }
+ for (e = node->indirect_calls; e; e = e->next_callee)
+ ipa_write_indirect_edge_info (ob, e);
+}
+
+/* Stream in NODE info from IB. */
+
+static void
+ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
+ struct data_in *data_in)
+{
+ struct ipa_node_params *info = IPA_NODE_REF (node);
+ int k;
+ struct cgraph_edge *e;
+ struct bitpack_d bp;
+
+ ipa_initialize_node_params (node);
+
+ bp = lto_input_bitpack (ib);
+ info->called_with_var_arguments = bp_unpack_value (&bp, 1);
+ if (ipa_get_param_count (info) != 0)
+ info->uses_analysis_done = true;
+ info->node_enqueued = false;
+ for (k = 0; k < ipa_get_param_count (info); k++)
+ info->params[k].used = bp_unpack_value (&bp, 1);
+ for (e = node->callees; e; e = e->next_callee)
+ {
+ struct ipa_edge_args *args = IPA_EDGE_REF (e);
+ int count = lto_input_uleb128 (ib);
+
+ ipa_set_cs_argument_count (args, count);
+ if (!count)
+ continue;
+
+ args->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func
+ (ipa_get_cs_argument_count (args));
+ for (k = 0; k < ipa_get_cs_argument_count (args); k++)
+ ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k), data_in);
+ }
+ for (e = node->indirect_calls; e; e = e->next_callee)
+ ipa_read_indirect_edge_info (ib, data_in, e);
+}
+
+/* Write jump functions for nodes in SET. */
+
+void
+ipa_prop_write_jump_functions (cgraph_node_set set)
+{
+ struct cgraph_node *node;
+ struct output_block *ob = create_output_block (LTO_section_jump_functions);
+ unsigned int count = 0;
+ cgraph_node_set_iterator csi;
+
+ ob->cgraph_node = NULL;
+
+ for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
+ {
+ node = csi_node (csi);
+ if (node->analyzed && IPA_NODE_REF (node) != NULL)
+ count++;
+ }
+
+ lto_output_uleb128_stream (ob->main_stream, count);
+
+ /* Process all of the functions. */
+ for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
+ {
+ node = csi_node (csi);
+ if (node->analyzed && IPA_NODE_REF (node) != NULL)
+ ipa_write_node_info (ob, node);
+ }
+ lto_output_1_stream (ob->main_stream, 0);
+ produce_asm (ob, NULL);
+ destroy_output_block (ob);
+}
+
+/* Read section in file FILE_DATA of length LEN with data DATA. */
+
+static void
+ipa_prop_read_section (struct lto_file_decl_data *file_data, const char *data,
+ size_t len)
+{
+ const struct lto_function_header *header =
+ (const struct lto_function_header *) data;
+ const int32_t cfg_offset = sizeof (struct lto_function_header);
+ const int32_t main_offset = cfg_offset + header->cfg_size;
+ const int32_t string_offset = main_offset + header->main_size;
+ struct data_in *data_in;
+ struct lto_input_block ib_main;
+ unsigned int i;
+ unsigned int count;
+
+ LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0,
+ header->main_size);
+
+ data_in =
+ lto_data_in_create (file_data, (const char *) data + string_offset,
+ header->string_size, NULL);
+ count = lto_input_uleb128 (&ib_main);
+
+ for (i = 0; i < count; i++)
+ {
+ unsigned int index;
+ struct cgraph_node *node;
+ lto_cgraph_encoder_t encoder;
+
+ index = lto_input_uleb128 (&ib_main);
+ encoder = file_data->cgraph_node_encoder;
+ node = lto_cgraph_encoder_deref (encoder, index);
+ gcc_assert (node->analyzed);
+ ipa_read_node_info (&ib_main, node, data_in);
+ }
+ lto_free_section_data (file_data, LTO_section_jump_functions, NULL, data,
+ len);
+ lto_data_in_delete (data_in);
+}
+
+/* Read ipcp jump functions. */
+
+void
+ipa_prop_read_jump_functions (void)
+{
+ struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
+ struct lto_file_decl_data *file_data;
+ unsigned int j = 0;
+
+ ipa_check_create_node_params ();
+ ipa_check_create_edge_args ();
+ ipa_register_cgraph_hooks ();
+
+ while ((file_data = file_data_vec[j++]))
+ {
+ size_t len;
+ const char *data = lto_get_section_data (file_data, LTO_section_jump_functions, NULL, &len);
+
+ if (data)
+ ipa_prop_read_section (file_data, data, len);
+ }
+}
+
+/* After merging units, we can get mismatch in argument counts.
+ Also decl merging might've rendered parameter lists obsolete.
+ Also compute called_with_variable_arg info. */
+
+void
+ipa_update_after_lto_read (void)
+{
+ struct cgraph_node *node;
+ struct cgraph_edge *cs;
+
+ ipa_check_create_node_params ();
+ ipa_check_create_edge_args ();
+
+ for (node = cgraph_nodes; node; node = node->next)
+ if (node->analyzed)
+ ipa_initialize_node_params (node);
+
+ for (node = cgraph_nodes; node; node = node->next)
+ if (node->analyzed)
+ for (cs = node->callees; cs; cs = cs->next_callee)
+ {
+ if (ipa_get_cs_argument_count (IPA_EDGE_REF (cs))
+ != ipa_get_param_count (IPA_NODE_REF (cs->callee)))
+ ipa_set_called_with_variable_arg (IPA_NODE_REF (cs->callee));
+ }
+}