123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770 |
- #ifndef IPA_PROP_H
- #define IPA_PROP_H
- #define IPA_UNDESCRIBED_USE -1
- enum jump_func_type
- {
- IPA_JF_UNKNOWN = 0,
- IPA_JF_CONST,
- IPA_JF_PASS_THROUGH,
- IPA_JF_ANCESTOR
- };
- struct ipa_cst_ref_desc;
- struct GTY(()) ipa_constant_data
- {
-
- tree value;
-
- struct ipa_cst_ref_desc GTY((skip)) *rdesc;
- };
- struct GTY(()) ipa_pass_through_data
- {
-
- tree operand;
-
- int formal_id;
-
- enum tree_code operation;
-
- unsigned agg_preserved : 1;
- };
- struct GTY(()) ipa_ancestor_jf_data
- {
-
- HOST_WIDE_INT offset;
-
- int formal_id;
-
- unsigned agg_preserved : 1;
- };
- struct GTY(()) ipa_agg_jf_item
- {
-
- HOST_WIDE_INT offset;
-
- tree value;
- };
- struct GTY(()) ipa_agg_jump_function
- {
-
- vec<ipa_agg_jf_item, va_gc> *items;
-
- bool by_ref;
- };
- typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
- struct GTY(()) ipa_alignment
- {
-
- bool known;
-
- unsigned align;
- unsigned misalign;
- };
- struct GTY (()) ipa_jump_func
- {
-
- struct ipa_agg_jump_function agg;
-
- struct ipa_alignment alignment;
- enum jump_func_type type;
-
- union jump_func_value
- {
- struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
- struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
- struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
- } GTY ((desc ("%1.type"))) value;
- };
- static inline tree
- ipa_get_jf_constant (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_CONST);
- return jfunc->value.constant.value;
- }
- static inline struct ipa_cst_ref_desc *
- ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_CONST);
- return jfunc->value.constant.rdesc;
- }
- static inline tree
- ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
- return jfunc->value.pass_through.operand;
- }
- static inline int
- ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
- return jfunc->value.pass_through.formal_id;
- }
- static inline enum tree_code
- ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
- return jfunc->value.pass_through.operation;
- }
- static inline bool
- ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
- return jfunc->value.pass_through.agg_preserved;
- }
- static inline bool
- ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
- return jfunc->value.pass_through.agg_preserved;
- }
- static inline HOST_WIDE_INT
- ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
- return jfunc->value.ancestor.offset;
- }
- static inline int
- ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
- return jfunc->value.ancestor.formal_id;
- }
- static inline bool
- ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
- return jfunc->value.ancestor.agg_preserved;
- }
- static inline bool
- ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
- {
- gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
- return jfunc->value.ancestor.agg_preserved;
- }
- struct ipa_param_descriptor
- {
-
- tree decl;
-
- int controlled_uses;
- unsigned int move_cost : 31;
-
- unsigned used : 1;
- };
- struct ipa_node_params
- {
- ~ipa_node_params ();
-
- vec<ipa_param_descriptor> descriptors;
-
- struct ipcp_param_lattices *lattices;
-
- struct cgraph_node *ipcp_orig_node;
-
- vec<tree> known_csts;
-
- vec<ipa_polymorphic_call_context> known_contexts;
-
- unsigned analysis_done : 1;
-
- unsigned node_enqueued : 1;
-
- unsigned do_clone_for_all_contexts : 1;
-
- unsigned is_all_contexts_clone : 1;
-
- unsigned node_dead : 1;
-
- unsigned node_within_scc : 1;
-
- unsigned node_calling_single_call : 1;
- };
- struct ipa_param_aa_status
- {
-
- bool valid;
-
- bool parm_modified, ref_modified, pt_modified;
- };
- struct ipa_bb_info
- {
-
- vec<cgraph_edge *> cg_edges;
-
- vec<ipa_param_aa_status> param_aa_statuses;
- };
- struct ipa_func_body_info
- {
-
- cgraph_node *node;
-
- struct ipa_node_params *info;
-
- vec<ipa_bb_info> bb_infos;
-
- int param_count;
-
- unsigned int aa_walked;
- };
- static inline int
- ipa_get_param_count (struct ipa_node_params *info)
- {
- return info->descriptors.length ();
- }
- static inline tree
- ipa_get_param (struct ipa_node_params *info, int i)
- {
- gcc_checking_assert (!flag_wpa);
- return info->descriptors[i].decl;
- }
- static inline int
- ipa_get_param_move_cost (struct ipa_node_params *info, int i)
- {
- return info->descriptors[i].move_cost;
- }
- static inline void
- ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
- {
- info->descriptors[i].used = val;
- }
- static inline int
- ipa_get_controlled_uses (struct ipa_node_params *info, int i)
- {
-
- if (info->descriptors.length () > (unsigned)i)
- return info->descriptors[i].controlled_uses;
- return IPA_UNDESCRIBED_USE;
- }
- static inline void
- ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
- {
- info->descriptors[i].controlled_uses = val;
- }
- static inline bool
- ipa_is_param_used (struct ipa_node_params *info, int i)
- {
- return info->descriptors[i].used;
- }
- struct GTY(()) ipa_agg_replacement_value
- {
-
- struct ipa_agg_replacement_value *next;
-
- HOST_WIDE_INT offset;
-
- tree value;
-
- int index;
-
- bool by_ref;
- };
- struct GTY(()) ipcp_transformation_summary
- {
-
- ipa_agg_replacement_value *agg_values;
-
- vec<ipa_alignment, va_gc> *alignments;
- };
- void ipa_set_node_agg_value_chain (struct cgraph_node *node,
- struct ipa_agg_replacement_value *aggvals);
- void ipcp_grow_transformations_if_necessary (void);
- struct GTY(()) ipa_edge_args
- {
-
- vec<ipa_jump_func, va_gc> *jump_functions;
- vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
- };
- static inline int
- ipa_get_cs_argument_count (struct ipa_edge_args *args)
- {
- return vec_safe_length (args->jump_functions);
- }
- static inline struct ipa_jump_func *
- ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
- {
- return &(*args->jump_functions)[i];
- }
- static inline struct ipa_polymorphic_call_context *
- ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
- {
- if (!args->polymorphic_call_contexts)
- return NULL;
- return &(*args->polymorphic_call_contexts)[i];
- }
- class ipa_node_params_t: public function_summary <ipa_node_params *>
- {
- public:
- ipa_node_params_t (symbol_table *table):
- function_summary<ipa_node_params *> (table) { }
-
- virtual void duplicate (cgraph_node *node,
- cgraph_node *node2,
- ipa_node_params *data,
- ipa_node_params *data2);
- };
- extern ipa_node_params_t *ipa_node_params_sum;
- extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations;
- extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
- #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE))
- #define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
- #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
- void ipa_create_all_node_params (void);
- void ipa_create_all_edge_args (void);
- void ipa_free_edge_args_substructures (struct ipa_edge_args *);
- void ipa_free_all_node_params (void);
- void ipa_free_all_edge_args (void);
- void ipa_free_all_structures_after_ipa_cp (void);
- void ipa_free_all_structures_after_iinln (void);
- void ipa_register_cgraph_hooks (void);
- int count_formal_params (tree fndecl);
- static inline void
- ipa_check_create_node_params (void)
- {
- if (!ipa_node_params_sum)
- ipa_node_params_sum = new ipa_node_params_t (symtab);
- }
- static inline void
- ipa_check_create_edge_args (void)
- {
- if (vec_safe_length (ipa_edge_args_vector)
- <= (unsigned) symtab->edges_max_uid)
- vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
- }
- static inline bool
- ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
- {
- return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
- }
- static inline ipcp_transformation_summary *
- ipcp_get_transformation_summary (cgraph_node *node)
- {
- if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations))
- return NULL;
- return &(*ipcp_transformations)[node->uid];
- }
- static inline struct ipa_agg_replacement_value *
- ipa_get_agg_replacements_for_node (cgraph_node *node)
- {
- ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
- return ts ? ts->agg_values : NULL;
- }
- void ipa_initialize_node_params (struct cgraph_node *node);
- bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
- vec<cgraph_edge *> *new_edges);
- tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
- vec<tree> ,
- vec<ipa_polymorphic_call_context>,
- vec<ipa_agg_jump_function_p>,
- bool *);
- struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
- bool speculative = false);
- tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
- void ipa_analyze_node (struct cgraph_node *);
- tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *, HOST_WIDE_INT,
- bool);
- bool ipa_load_from_parm_agg (struct ipa_func_body_info *,
- vec<ipa_param_descriptor>, gimple, tree, int *,
- HOST_WIDE_INT *, HOST_WIDE_INT *, bool *);
- void ipa_print_node_params (FILE *, struct cgraph_node *node);
- void ipa_print_all_params (FILE *);
- void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
- void ipa_print_all_jump_functions (FILE * f);
- void ipcp_verify_propagated_values (void);
- extern alloc_pool ipcp_cst_values_pool;
- extern alloc_pool ipcp_poly_ctx_values_pool;
- extern alloc_pool ipcp_sources_pool;
- extern alloc_pool ipcp_agg_lattice_pool;
- enum ipa_parm_op {
- IPA_PARM_OP_NONE,
-
- IPA_PARM_OP_NEW,
-
- IPA_PARM_OP_COPY,
-
- IPA_PARM_OP_REMOVE
- };
- struct ipa_parm_adjustment
- {
-
- tree base;
-
- tree type;
-
- tree alias_ptr_type;
-
- tree new_decl;
-
- tree new_ssa_base;
-
- tree nonlocal_value;
-
- const char *arg_prefix;
-
- HOST_WIDE_INT offset;
-
- int base_index;
-
- enum ipa_parm_op op;
-
- unsigned by_ref : 1;
- };
- typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
- vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
- vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
- void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
- void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
- ipa_parm_adjustment_vec);
- ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
- ipa_parm_adjustment_vec);
- void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
- void ipa_dump_agg_replacement_values (FILE *f,
- struct ipa_agg_replacement_value *av);
- void ipa_prop_write_jump_functions (void);
- void ipa_prop_read_jump_functions (void);
- void ipcp_write_transformation_summaries (void);
- void ipcp_read_transformation_summaries (void);
- void ipa_update_after_lto_read (void);
- int ipa_get_param_decl_index (struct ipa_node_params *, tree);
- tree ipa_value_from_jfunc (struct ipa_node_params *info,
- struct ipa_jump_func *jfunc);
- unsigned int ipcp_transform_function (struct cgraph_node *node);
- ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
- cgraph_edge *,
- int,
- ipa_jump_func *);
- void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
- bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
- ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
- ipa_parm_adjustment_vec,
- bool);
- tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,
- gimple_stmt_iterator *, bool);
- void ipa_cp_c_finalize (void);
- #endif
|