2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / ipa-prop.h
blob8f7eb088813dfb0c78cf26d12c10df7117938d39
1 /* Interprocedural analyses.
2 Copyright (C) 2005-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef IPA_PROP_H
21 #define IPA_PROP_H
23 /* The following definitions and interfaces are used by
24 interprocedural analyses or parameters. */
26 #define IPA_UNDESCRIBED_USE -1
28 /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
30 /* A jump function for a callsite represents the values passed as actual
31 arguments of the callsite. They were originally proposed in a paper called
32 "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
33 Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
34 types of values :
36 Pass-through - the caller's formal parameter is passed as an actual
37 argument, possibly one simple operation performed on it.
38 Constant - a constant (is_gimple_ip_invariant)is passed as an actual
39 argument.
40 Unknown - neither of the above.
42 IPA_JF_ANCESTOR is a special pass-through jump function, which means that
43 the result is an address of a part of the object pointed to by the formal
44 parameter to which the function refers. It is mainly intended to represent
45 getting addresses of ancestor fields in C++
46 (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
47 NULL, ancestor jump function must behave like a simple pass-through.
49 Other pass-through functions can either simply pass on an unchanged formal
50 parameter or can apply one simple binary operation to it (such jump
51 functions are called polynomial).
53 Jump functions are computed in ipa-prop.c by function
54 update_call_notes_after_inlining. Some information can be lost and jump
55 functions degraded accordingly when inlining, see
56 update_call_notes_after_inlining in the same file. */
58 enum jump_func_type
60 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
61 IPA_JF_CONST, /* represented by field costant */
62 IPA_JF_PASS_THROUGH, /* represented by field pass_through */
63 IPA_JF_ANCESTOR /* represented by field ancestor */
66 struct ipa_cst_ref_desc;
68 /* Structure holding data required to describe a constant jump function. */
69 struct GTY(()) ipa_constant_data
71 /* THe value of the constant. */
72 tree value;
73 /* Pointer to the structure that describes the reference. */
74 struct ipa_cst_ref_desc GTY((skip)) *rdesc;
77 /* Structure holding data required to describe a pass-through jump function. */
79 struct GTY(()) ipa_pass_through_data
81 /* If an operation is to be performed on the original parameter, this is the
82 second (constant) operand. */
83 tree operand;
84 /* Number of the caller's formal parameter being passed. */
85 int formal_id;
86 /* Operation that is performed on the argument before it is passed on.
87 NOP_EXPR means no operation. Otherwise oper must be a simple binary
88 arithmetic operation where the caller's parameter is the first operand and
89 operand field from this structure is the second one. */
90 enum tree_code operation;
91 /* When the passed value is a pointer, it is set to true only when we are
92 certain that no write to the object it points to has occurred since the
93 caller functions started execution, except for changes noted in the
94 aggregate part of the jump function (see description of
95 ipa_agg_jump_function). The flag is used only when the operation is
96 NOP_EXPR. */
97 unsigned agg_preserved : 1;
100 /* Structure holding data required to describe an ancestor pass-through
101 jump function. */
103 struct GTY(()) ipa_ancestor_jf_data
105 /* Offset of the field representing the ancestor. */
106 HOST_WIDE_INT offset;
107 /* Number of the caller's formal parameter being passed. */
108 int formal_id;
109 /* Flag with the same meaning like agg_preserve in ipa_pass_through_data. */
110 unsigned agg_preserved : 1;
113 /* An element in an aggegate part of a jump function describing a known value
114 at a given offset. When it is part of a pass-through jump function with
115 agg_preserved set or an ancestor jump function with agg_preserved set, all
116 unlisted positions are assumed to be preserved but the value can be a type
117 node, which means that the particular piece (starting at offset and having
118 the size of the type) is clobbered with an unknown value. When
119 agg_preserved is false or the type of the containing jump function is
120 different, all unlisted parts are assumed to be unknown and all values must
121 fulfill is_gimple_ip_invariant. */
123 struct GTY(()) ipa_agg_jf_item
125 /* The offset at which the known value is located within the aggregate. */
126 HOST_WIDE_INT offset;
128 /* The known constant or type if this is a clobber. */
129 tree value;
133 /* Aggregate jump function - i.e. description of contents of aggregates passed
134 either by reference or value. */
136 struct GTY(()) ipa_agg_jump_function
138 /* Description of the individual items. */
139 vec<ipa_agg_jf_item, va_gc> *items;
140 /* True if the data was passed by reference (as opposed to by value). */
141 bool by_ref;
144 typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
146 /* Information about zero/non-zero bits. */
147 struct GTY(()) ipa_bits
149 /* The propagated value. */
150 widest_int value;
151 /* Mask corresponding to the value.
152 Similar to ccp_lattice_t, if xth bit of mask is 0,
153 implies xth bit of value is constant. */
154 widest_int mask;
155 /* True if jump function is known. */
156 bool known;
159 /* Info about value ranges. */
160 struct GTY(()) ipa_vr
162 /* The data fields below are valid only if known is true. */
163 bool known;
164 enum value_range_type type;
165 wide_int min;
166 wide_int max;
169 /* A jump function for a callsite represents the values passed as actual
170 arguments of the callsite. See enum jump_func_type for the various
171 types of jump functions supported. */
172 struct GTY (()) ipa_jump_func
174 /* Aggregate contants description. See struct ipa_agg_jump_function and its
175 description. */
176 struct ipa_agg_jump_function agg;
178 /* Information about zero/non-zero bits. */
179 struct ipa_bits bits;
181 /* Information about value range, containing valid data only when vr_known is
182 true. */
183 value_range m_vr;
184 bool vr_known;
186 enum jump_func_type type;
187 /* Represents a value of a jump function. pass_through is used only in jump
188 function context. constant represents the actual constant in constant jump
189 functions and member_cst holds constant c++ member functions. */
190 union jump_func_value
192 struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
193 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
194 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
195 } GTY ((desc ("%1.type"))) value;
199 /* Return the constant stored in a constant jump functin JFUNC. */
201 static inline tree
202 ipa_get_jf_constant (struct ipa_jump_func *jfunc)
204 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
205 return jfunc->value.constant.value;
208 static inline struct ipa_cst_ref_desc *
209 ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
211 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
212 return jfunc->value.constant.rdesc;
215 /* Return the operand of a pass through jmp function JFUNC. */
217 static inline tree
218 ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
220 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
221 return jfunc->value.pass_through.operand;
224 /* Return the number of the caller's formal parameter that a pass through jump
225 function JFUNC refers to. */
227 static inline int
228 ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
230 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
231 return jfunc->value.pass_through.formal_id;
234 /* Return operation of a pass through jump function JFUNC. */
236 static inline enum tree_code
237 ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
239 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
240 return jfunc->value.pass_through.operation;
243 /* Return the agg_preserved flag of a pass through jump function JFUNC. */
245 static inline bool
246 ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
248 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
249 return jfunc->value.pass_through.agg_preserved;
252 /* Return true if pass through jump function JFUNC preserves type
253 information. */
255 static inline bool
256 ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
258 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
259 return jfunc->value.pass_through.agg_preserved;
262 /* Return the offset of an ancestor jump function JFUNC. */
264 static inline HOST_WIDE_INT
265 ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
267 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
268 return jfunc->value.ancestor.offset;
271 /* Return the number of the caller's formal parameter that an ancestor jump
272 function JFUNC refers to. */
274 static inline int
275 ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
277 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
278 return jfunc->value.ancestor.formal_id;
281 /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
283 static inline bool
284 ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
286 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
287 return jfunc->value.ancestor.agg_preserved;
290 /* Return true if ancestor jump function JFUNC presrves type information. */
292 static inline bool
293 ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
295 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
296 return jfunc->value.ancestor.agg_preserved;
299 /* Summary describing a single formal parameter. */
301 struct GTY(()) ipa_param_descriptor
303 /* In analysis and modification phase, this is the PARAM_DECL of this
304 parameter, in IPA LTO phase, this is the type of the the described
305 parameter or NULL if not known. Do not read this field directly but
306 through ipa_get_param and ipa_get_type as appropriate. */
307 tree decl_or_type;
308 /* If all uses of the parameter are described by ipa-prop structures, this
309 says how many there are. If any use could not be described by means of
310 ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
311 int controlled_uses;
312 unsigned int move_cost : 31;
313 /* The parameter is used. */
314 unsigned used : 1;
317 /* ipa_node_params stores information related to formal parameters of functions
318 and some other information for interprocedural passes that operate on
319 parameters (such as ipa-cp). */
321 struct GTY((for_user)) ipa_node_params
323 /* Default constructor. */
324 ipa_node_params ();
326 /* Default destructor. */
327 ~ipa_node_params ();
329 /* Information about individual formal parameters that are gathered when
330 summaries are generated. */
331 vec<ipa_param_descriptor, va_gc> *descriptors;
332 /* Pointer to an array of structures describing individual formal
333 parameters. */
334 struct ipcp_param_lattices * GTY((skip)) lattices;
335 /* Only for versioned nodes this field would not be NULL,
336 it points to the node that IPA cp cloned from. */
337 struct cgraph_node * GTY((skip)) ipcp_orig_node;
338 /* If this node is an ipa-cp clone, these are the known constants that
339 describe what it has been specialized for. */
340 vec<tree> GTY((skip)) known_csts;
341 /* If this node is an ipa-cp clone, these are the known polymorphic contexts
342 that describe what it has been specialized for. */
343 vec<ipa_polymorphic_call_context> GTY((skip)) known_contexts;
344 /* Whether the param uses analysis and jump function computation has already
345 been performed. */
346 unsigned analysis_done : 1;
347 /* Whether the function is enqueued in ipa-cp propagation stack. */
348 unsigned node_enqueued : 1;
349 /* Whether we should create a specialized version based on values that are
350 known to be constant in all contexts. */
351 unsigned do_clone_for_all_contexts : 1;
352 /* Set if this is an IPA-CP clone for all contexts. */
353 unsigned is_all_contexts_clone : 1;
354 /* Node has been completely replaced by clones and will be removed after
355 ipa-cp is finished. */
356 unsigned node_dead : 1;
357 /* Node is involved in a recursion, potentionally indirect. */
358 unsigned node_within_scc : 1;
359 /* Node is calling a private function called only once. */
360 unsigned node_calling_single_call : 1;
361 /* False when there is something makes versioning impossible. */
362 unsigned versionable : 1;
365 inline
366 ipa_node_params::ipa_node_params ()
367 : descriptors (NULL), lattices (NULL), ipcp_orig_node (NULL),
368 known_csts (vNULL), known_contexts (vNULL), analysis_done (0),
369 node_enqueued (0), do_clone_for_all_contexts (0), is_all_contexts_clone (0),
370 node_dead (0), node_within_scc (0), node_calling_single_call (0),
371 versionable (0)
375 inline
376 ipa_node_params::~ipa_node_params ()
378 free (lattices);
379 known_csts.release ();
380 known_contexts.release ();
383 /* Intermediate information that we get from alias analysis about a particular
384 parameter in a particular basic_block. When a parameter or the memory it
385 references is marked modified, we use that information in all dominated
386 blocks without consulting alias analysis oracle. */
388 struct ipa_param_aa_status
390 /* Set when this structure contains meaningful information. If not, the
391 structure describing a dominating BB should be used instead. */
392 bool valid;
394 /* Whether we have seen something which might have modified the data in
395 question. PARM is for the parameter itself, REF is for data it points to
396 but using the alias type of individual accesses and PT is the same thing
397 but for computing aggregate pass-through functions using a very inclusive
398 ao_ref. */
399 bool parm_modified, ref_modified, pt_modified;
402 /* Information related to a given BB that used only when looking at function
403 body. */
405 struct ipa_bb_info
407 /* Call graph edges going out of this BB. */
408 vec<cgraph_edge *> cg_edges;
409 /* Alias analysis statuses of each formal parameter at this bb. */
410 vec<ipa_param_aa_status> param_aa_statuses;
413 /* Structure with global information that is only used when looking at function
414 body. */
416 struct ipa_func_body_info
418 /* The node that is being analyzed. */
419 cgraph_node *node;
421 /* Its info. */
422 struct ipa_node_params *info;
424 /* Information about individual BBs. */
425 vec<ipa_bb_info> bb_infos;
427 /* Number of parameters. */
428 int param_count;
430 /* Number of statements already walked by when analyzing this function. */
431 unsigned int aa_walked;
434 /* ipa_node_params access functions. Please use these to access fields that
435 are or will be shared among various passes. */
437 /* Return the number of formal parameters. */
439 static inline int
440 ipa_get_param_count (struct ipa_node_params *info)
442 return vec_safe_length (info->descriptors);
445 /* Return the declaration of Ith formal parameter of the function corresponding
446 to INFO. Note there is no setter function as this array is built just once
447 using ipa_initialize_node_params. This function should not be called in
448 WPA. */
450 static inline tree
451 ipa_get_param (struct ipa_node_params *info, int i)
453 gcc_checking_assert (info->descriptors);
454 gcc_checking_assert (!flag_wpa);
455 tree t = (*info->descriptors)[i].decl_or_type;
456 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
457 return t;
460 /* Return the type of Ith formal parameter of the function corresponding
461 to INFO if it is known or NULL if not. */
463 static inline tree
464 ipa_get_type (struct ipa_node_params *info, int i)
466 gcc_checking_assert (info->descriptors);
467 tree t = (*info->descriptors)[i].decl_or_type;
468 if (!t)
469 return NULL;
470 if (TYPE_P (t))
471 return t;
472 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
473 return TREE_TYPE (t);
476 /* Return the move cost of Ith formal parameter of the function corresponding
477 to INFO. */
479 static inline int
480 ipa_get_param_move_cost (struct ipa_node_params *info, int i)
482 gcc_checking_assert (info->descriptors);
483 return (*info->descriptors)[i].move_cost;
486 /* Set the used flag corresponding to the Ith formal parameter of the function
487 associated with INFO to VAL. */
489 static inline void
490 ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
492 gcc_checking_assert (info->descriptors);
493 (*info->descriptors)[i].used = val;
496 /* Return how many uses described by ipa-prop a parameter has or
497 IPA_UNDESCRIBED_USE if there is a use that is not described by these
498 structures. */
499 static inline int
500 ipa_get_controlled_uses (struct ipa_node_params *info, int i)
502 /* FIXME: introducing speculation causes out of bounds access here. */
503 if (vec_safe_length (info->descriptors) > (unsigned)i)
504 return (*info->descriptors)[i].controlled_uses;
505 return IPA_UNDESCRIBED_USE;
508 /* Set the controlled counter of a given parameter. */
510 static inline void
511 ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
513 gcc_checking_assert (info->descriptors);
514 (*info->descriptors)[i].controlled_uses = val;
517 /* Return the used flag corresponding to the Ith formal parameter of the
518 function associated with INFO. */
520 static inline bool
521 ipa_is_param_used (struct ipa_node_params *info, int i)
523 gcc_checking_assert (info->descriptors);
524 return (*info->descriptors)[i].used;
527 /* Information about replacements done in aggregates for a given node (each
528 node has its linked list). */
529 struct GTY(()) ipa_agg_replacement_value
531 /* Next item in the linked list. */
532 struct ipa_agg_replacement_value *next;
533 /* Offset within the aggregate. */
534 HOST_WIDE_INT offset;
535 /* The constant value. */
536 tree value;
537 /* The paramter index. */
538 int index;
539 /* Whether the value was passed by reference. */
540 bool by_ref;
543 /* Structure holding information for the transformation phase of IPA-CP. */
545 struct GTY(()) ipcp_transformation_summary
547 /* Linked list of known aggregate values. */
548 ipa_agg_replacement_value *agg_values;
549 /* Known bits information. */
550 vec<ipa_bits, va_gc> *bits;
551 /* Value range information. */
552 vec<ipa_vr, va_gc> *m_vr;
555 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
556 struct ipa_agg_replacement_value *aggvals);
557 void ipcp_grow_transformations_if_necessary (void);
559 /* ipa_edge_args stores information related to a callsite and particularly its
560 arguments. It can be accessed by the IPA_EDGE_REF macro. */
561 struct GTY(()) ipa_edge_args
563 /* Vector of the callsite's jump function of each parameter. */
564 vec<ipa_jump_func, va_gc> *jump_functions;
565 vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
568 /* ipa_edge_args access functions. Please use these to access fields that
569 are or will be shared among various passes. */
571 /* Return the number of actual arguments. */
573 static inline int
574 ipa_get_cs_argument_count (struct ipa_edge_args *args)
576 return vec_safe_length (args->jump_functions);
579 /* Returns a pointer to the jump function for the ith argument. Please note
580 there is no setter function as jump functions are all set up in
581 ipa_compute_jump_functions. */
583 static inline struct ipa_jump_func *
584 ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
586 return &(*args->jump_functions)[i];
589 /* Returns a pointer to the polymorphic call context for the ith argument.
590 NULL if contexts are not computed. */
591 static inline struct ipa_polymorphic_call_context *
592 ipa_get_ith_polymorhic_call_context (struct ipa_edge_args *args, int i)
594 if (!args->polymorphic_call_contexts)
595 return NULL;
596 return &(*args->polymorphic_call_contexts)[i];
599 /* Function summary for ipa_node_params. */
600 class GTY((user)) ipa_node_params_t: public function_summary <ipa_node_params *>
602 public:
603 ipa_node_params_t (symbol_table *table, bool ggc):
604 function_summary<ipa_node_params *> (table, ggc) { }
606 /* Hook that is called by summary when a node is duplicated. */
607 virtual void duplicate (cgraph_node *node,
608 cgraph_node *node2,
609 ipa_node_params *data,
610 ipa_node_params *data2);
613 /* Function summary where the parameter infos are actually stored. */
614 extern GTY(()) ipa_node_params_t * ipa_node_params_sum;
616 /* Vector of IPA-CP transformation data for each clone. */
617 extern GTY(()) vec<ipcp_transformation_summary, va_gc> *ipcp_transformations;
618 /* Vector where the parameter infos are actually stored. */
619 extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
622 /* Return the associated parameter/argument info corresponding to the given
623 node/edge. */
624 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get (NODE))
625 #define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
626 /* This macro checks validity of index returned by
627 ipa_get_param_decl_index function. */
628 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
630 /* Creating and freeing ipa_node_params and ipa_edge_args. */
631 void ipa_create_all_node_params (void);
632 void ipa_create_all_edge_args (void);
633 void ipa_free_edge_args_substructures (struct ipa_edge_args *);
634 void ipa_free_all_node_params (void);
635 void ipa_free_all_edge_args (void);
636 void ipa_free_all_structures_after_ipa_cp (void);
637 void ipa_free_all_structures_after_iinln (void);
639 void ipa_register_cgraph_hooks (void);
640 int count_formal_params (tree fndecl);
642 /* This function ensures the array of node param infos is big enough to
643 accommodate a structure for all nodes and reallocates it if not. */
645 static inline void
646 ipa_check_create_node_params (void)
648 if (!ipa_node_params_sum)
649 ipa_node_params_sum
650 = (new (ggc_cleared_alloc <ipa_node_params_t> ())
651 ipa_node_params_t (symtab, true));
654 /* This function ensures the array of edge arguments infos is big enough to
655 accommodate a structure for all edges and reallocates it if not. */
657 static inline void
658 ipa_check_create_edge_args (void)
660 if (vec_safe_length (ipa_edge_args_vector)
661 <= (unsigned) symtab->edges_max_uid)
662 vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
665 /* Returns true if the array of edge infos is large enough to accommodate an
666 info for EDGE. The main purpose of this function is that debug dumping
667 function can check info availability without causing reallocations. */
669 static inline bool
670 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
672 return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
675 static inline ipcp_transformation_summary *
676 ipcp_get_transformation_summary (cgraph_node *node)
678 if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations))
679 return NULL;
680 return &(*ipcp_transformations)[node->uid];
683 /* Return the aggregate replacements for NODE, if there are any. */
685 static inline struct ipa_agg_replacement_value *
686 ipa_get_agg_replacements_for_node (cgraph_node *node)
688 ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
689 return ts ? ts->agg_values : NULL;
692 /* Function formal parameters related computations. */
693 void ipa_initialize_node_params (struct cgraph_node *node);
694 bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
695 vec<cgraph_edge *> *new_edges);
697 /* Indirect edge and binfo processing. */
698 tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
699 vec<tree> ,
700 vec<ipa_polymorphic_call_context>,
701 vec<ipa_agg_jump_function_p>,
702 bool *);
703 struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
704 bool speculative = false);
705 tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
707 /* Functions related to both. */
708 void ipa_analyze_node (struct cgraph_node *);
710 /* Aggregate jump function related functions. */
711 tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg, tree scalar,
712 HOST_WIDE_INT offset, bool by_ref,
713 bool *from_global_constant = NULL);
714 bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
715 vec<ipa_param_descriptor, va_gc> *descriptors,
716 gimple *stmt, tree op, int *index_p,
717 HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
718 bool *by_ref, bool *guaranteed_unmodified = NULL);
720 /* Debugging interface. */
721 void ipa_print_node_params (FILE *, struct cgraph_node *node);
722 void ipa_print_all_params (FILE *);
723 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
724 void ipa_print_all_jump_functions (FILE * f);
725 void ipcp_verify_propagated_values (void);
727 template <typename value>
728 class ipcp_value;
730 extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
731 extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
732 ipcp_poly_ctx_values_pool;
734 template <typename valtype>
735 class ipcp_value_source;
737 extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
739 class ipcp_agg_lattice;
741 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
743 /* Operation to be performed for the parameter in ipa_parm_adjustment
744 below. */
745 enum ipa_parm_op {
746 IPA_PARM_OP_NONE,
748 /* This describes a brand new parameter.
750 The field `type' should be set to the new type, `arg_prefix'
751 should be set to the string prefix for the new DECL_NAME, and
752 `new_decl' will ultimately hold the newly created argument. */
753 IPA_PARM_OP_NEW,
755 /* This new parameter is an unmodified parameter at index base_index. */
756 IPA_PARM_OP_COPY,
758 /* This adjustment describes a parameter that is about to be removed
759 completely. Most users will probably need to book keep those so that they
760 don't leave behinfd any non default def ssa names belonging to them. */
761 IPA_PARM_OP_REMOVE
764 /* Structure to describe transformations of formal parameters and actual
765 arguments. Each instance describes one new parameter and they are meant to
766 be stored in a vector. Additionally, most users will probably want to store
767 adjustments about parameters that are being removed altogether so that SSA
768 names belonging to them can be replaced by SSA names of an artificial
769 variable. */
770 struct ipa_parm_adjustment
772 /* The original PARM_DECL itself, helpful for processing of the body of the
773 function itself. Intended for traversing function bodies.
774 ipa_modify_formal_parameters, ipa_modify_call_arguments and
775 ipa_combine_adjustments ignore this and use base_index.
776 ipa_modify_formal_parameters actually sets this. */
777 tree base;
779 /* Type of the new parameter. However, if by_ref is true, the real type will
780 be a pointer to this type. */
781 tree type;
783 /* Alias refrerence type to be used in MEM_REFs when adjusting caller
784 arguments. */
785 tree alias_ptr_type;
787 /* The new declaration when creating/replacing a parameter. Created
788 by ipa_modify_formal_parameters, useful for functions modifying
789 the body accordingly. For brand new arguments, this is the newly
790 created argument. */
791 tree new_decl;
793 /* New declaration of a substitute variable that we may use to replace all
794 non-default-def ssa names when a parm decl is going away. */
795 tree new_ssa_base;
797 /* If non-NULL and the original parameter is to be removed (copy_param below
798 is NULL), this is going to be its nonlocalized vars value. */
799 tree nonlocal_value;
801 /* This holds the prefix to be used for the new DECL_NAME. */
802 const char *arg_prefix;
804 /* Offset into the original parameter (for the cases when the new parameter
805 is a component of an original one). */
806 HOST_WIDE_INT offset;
808 /* Zero based index of the original parameter this one is based on. */
809 int base_index;
811 /* Whether this parameter is a new parameter, a copy of an old one,
812 or one about to be removed. */
813 enum ipa_parm_op op;
815 /* Storage order of the original parameter (for the cases when the new
816 parameter is a component of an original one). */
817 unsigned reverse : 1;
819 /* The parameter is to be passed by reference. */
820 unsigned by_ref : 1;
823 typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
825 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
826 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
827 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
828 void ipa_modify_call_arguments (struct cgraph_edge *, gcall *,
829 ipa_parm_adjustment_vec);
830 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
831 ipa_parm_adjustment_vec);
832 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
833 void ipa_dump_agg_replacement_values (FILE *f,
834 struct ipa_agg_replacement_value *av);
835 void ipa_prop_write_jump_functions (void);
836 void ipa_prop_read_jump_functions (void);
837 void ipcp_write_transformation_summaries (void);
838 void ipcp_read_transformation_summaries (void);
839 void ipa_update_after_lto_read (void);
840 int ipa_get_param_decl_index (struct ipa_node_params *, tree);
841 tree ipa_value_from_jfunc (struct ipa_node_params *info,
842 struct ipa_jump_func *jfunc);
843 unsigned int ipcp_transform_function (struct cgraph_node *node);
844 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
845 cgraph_edge *,
846 int,
847 ipa_jump_func *);
848 void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
849 bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
850 ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
851 ipa_parm_adjustment_vec,
852 bool);
853 void ipa_release_body_info (struct ipa_func_body_info *);
854 tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
856 /* From tree-sra.c: */
857 tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree,
858 gimple_stmt_iterator *, bool);
860 /* In ipa-cp.c */
861 void ipa_cp_c_finalize (void);
863 #endif /* IPA_PROP_H */