]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ipa-prop.h
ipa-fnsummary.c (ipa_call_context::duplicate_from): New member function.
[thirdparty/gcc.git] / gcc / ipa-prop.h
1 /* Interprocedural analyses.
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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.
10
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.
15
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/>. */
19
20 #ifndef IPA_PROP_H
21 #define IPA_PROP_H
22
23 /* The following definitions and interfaces are used by
24 interprocedural analyses or parameters. */
25
26 #define IPA_UNDESCRIBED_USE -1
27
28 /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
29
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 :
35
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.
41
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.
48
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).
52
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. */
57
58 enum jump_func_type
59 {
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 */
64 };
65
66 struct ipa_cst_ref_desc;
67
68 /* Structure holding data required to describe a constant jump function. */
69 struct GTY(()) ipa_constant_data
70 {
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;
75 };
76
77 /* Structure holding data required to describe a pass-through jump function. */
78
79 struct GTY(()) ipa_pass_through_data
80 {
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;
98 };
99
100 /* Structure holding data required to describe an ancestor pass-through
101 jump function. */
102
103 struct GTY(()) ipa_ancestor_jf_data
104 {
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;
111 };
112
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. */
122
123 struct GTY(()) ipa_agg_jf_item
124 {
125 /* The offset at which the known value is located within the aggregate. */
126 HOST_WIDE_INT offset;
127
128 /* The known constant or type if this is a clobber. */
129 tree value;
130
131 /* Return true if OTHER describes same agg item. */
132 bool equal_to (const ipa_agg_jf_item &other);
133 };
134
135
136 /* Aggregate jump function - i.e. description of contents of aggregates passed
137 either by reference or value. */
138
139 struct GTY(()) ipa_agg_jump_function
140 {
141 /* Description of the individual items. */
142 vec<ipa_agg_jf_item, va_gc> *items;
143 /* True if the data was passed by reference (as opposed to by value). */
144 bool by_ref;
145
146 /* Return true if OTHER describes same agg items. */
147 bool equal_to (const ipa_agg_jump_function &other)
148 {
149 if (by_ref != other.by_ref)
150 return false;
151 if (items != NULL && other.items == NULL)
152 return false;
153 if (!items)
154 return other.items == NULL;
155 if (items->length () != other.items->length ())
156 return false;
157 for (unsigned int i = 0; i < items->length (); i++)
158 if (!(*items)[i].equal_to ((*other.items)[i]))
159 return false;
160 return true;
161 }
162 };
163
164 typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
165
166 /* Information about zero/non-zero bits. */
167 class GTY(()) ipa_bits
168 {
169 public:
170 /* The propagated value. */
171 widest_int value;
172 /* Mask corresponding to the value.
173 Similar to ccp_lattice_t, if xth bit of mask is 0,
174 implies xth bit of value is constant. */
175 widest_int mask;
176 };
177
178 /* Info about value ranges. */
179
180 class GTY(()) ipa_vr
181 {
182 public:
183 /* The data fields below are valid only if known is true. */
184 bool known;
185 enum value_range_kind type;
186 wide_int min;
187 wide_int max;
188 bool nonzero_p (tree) const;
189 };
190
191 /* A jump function for a callsite represents the values passed as actual
192 arguments of the callsite. See enum jump_func_type for the various
193 types of jump functions supported. */
194 struct GTY (()) ipa_jump_func
195 {
196 /* Aggregate contants description. See struct ipa_agg_jump_function and its
197 description. */
198 struct ipa_agg_jump_function agg;
199
200 /* Information about zero/non-zero bits. The pointed to structure is shared
201 betweed different jump functions. Use ipa_set_jfunc_bits to set this
202 field. */
203 class ipa_bits *bits;
204
205 /* Information about value range, containing valid data only when vr_known is
206 true. The pointed to structure is shared betweed different jump
207 functions. Use ipa_set_jfunc_vr to set this field. */
208 class value_range_base *m_vr;
209
210 enum jump_func_type type;
211 /* Represents a value of a jump function. pass_through is used only in jump
212 function context. constant represents the actual constant in constant jump
213 functions and member_cst holds constant c++ member functions. */
214 union jump_func_value
215 {
216 struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
217 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
218 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
219 } GTY ((desc ("%1.type"))) value;
220 };
221
222
223 /* Return the constant stored in a constant jump functin JFUNC. */
224
225 static inline tree
226 ipa_get_jf_constant (struct ipa_jump_func *jfunc)
227 {
228 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
229 return jfunc->value.constant.value;
230 }
231
232 static inline struct ipa_cst_ref_desc *
233 ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
234 {
235 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
236 return jfunc->value.constant.rdesc;
237 }
238
239 /* Return the operand of a pass through jmp function JFUNC. */
240
241 static inline tree
242 ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
243 {
244 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
245 return jfunc->value.pass_through.operand;
246 }
247
248 /* Return the number of the caller's formal parameter that a pass through jump
249 function JFUNC refers to. */
250
251 static inline int
252 ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
253 {
254 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
255 return jfunc->value.pass_through.formal_id;
256 }
257
258 /* Return operation of a pass through jump function JFUNC. */
259
260 static inline enum tree_code
261 ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
262 {
263 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
264 return jfunc->value.pass_through.operation;
265 }
266
267 /* Return the agg_preserved flag of a pass through jump function JFUNC. */
268
269 static inline bool
270 ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
271 {
272 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
273 return jfunc->value.pass_through.agg_preserved;
274 }
275
276 /* Return true if pass through jump function JFUNC preserves type
277 information. */
278
279 static inline bool
280 ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
281 {
282 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
283 return jfunc->value.pass_through.agg_preserved;
284 }
285
286 /* Return the offset of an ancestor jump function JFUNC. */
287
288 static inline HOST_WIDE_INT
289 ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
290 {
291 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
292 return jfunc->value.ancestor.offset;
293 }
294
295 /* Return the number of the caller's formal parameter that an ancestor jump
296 function JFUNC refers to. */
297
298 static inline int
299 ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
300 {
301 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
302 return jfunc->value.ancestor.formal_id;
303 }
304
305 /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
306
307 static inline bool
308 ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
309 {
310 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
311 return jfunc->value.ancestor.agg_preserved;
312 }
313
314 /* Return true if ancestor jump function JFUNC presrves type information. */
315
316 static inline bool
317 ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
318 {
319 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
320 return jfunc->value.ancestor.agg_preserved;
321 }
322
323 /* Summary describing a single formal parameter. */
324
325 struct GTY(()) ipa_param_descriptor
326 {
327 /* In analysis and modification phase, this is the PARAM_DECL of this
328 parameter, in IPA LTO phase, this is the type of the the described
329 parameter or NULL if not known. Do not read this field directly but
330 through ipa_get_param and ipa_get_type as appropriate. */
331 tree decl_or_type;
332 /* If all uses of the parameter are described by ipa-prop structures, this
333 says how many there are. If any use could not be described by means of
334 ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
335 int controlled_uses;
336 unsigned int move_cost : 31;
337 /* The parameter is used. */
338 unsigned used : 1;
339 };
340
341 /* ipa_node_params stores information related to formal parameters of functions
342 and some other information for interprocedural passes that operate on
343 parameters (such as ipa-cp). */
344
345 class GTY((for_user)) ipa_node_params
346 {
347 public:
348 /* Default constructor. */
349 ipa_node_params ();
350
351 /* Default destructor. */
352 ~ipa_node_params ();
353
354 /* Information about individual formal parameters that are gathered when
355 summaries are generated. */
356 vec<ipa_param_descriptor, va_gc> *descriptors;
357 /* Pointer to an array of structures describing individual formal
358 parameters. */
359 class ipcp_param_lattices * GTY((skip)) lattices;
360 /* Only for versioned nodes this field would not be NULL,
361 it points to the node that IPA cp cloned from. */
362 struct cgraph_node * GTY((skip)) ipcp_orig_node;
363 /* If this node is an ipa-cp clone, these are the known constants that
364 describe what it has been specialized for. */
365 vec<tree> GTY((skip)) known_csts;
366 /* If this node is an ipa-cp clone, these are the known polymorphic contexts
367 that describe what it has been specialized for. */
368 vec<ipa_polymorphic_call_context> GTY((skip)) known_contexts;
369 /* Whether the param uses analysis and jump function computation has already
370 been performed. */
371 unsigned analysis_done : 1;
372 /* Whether the function is enqueued in ipa-cp propagation stack. */
373 unsigned node_enqueued : 1;
374 /* Whether we should create a specialized version based on values that are
375 known to be constant in all contexts. */
376 unsigned do_clone_for_all_contexts : 1;
377 /* Set if this is an IPA-CP clone for all contexts. */
378 unsigned is_all_contexts_clone : 1;
379 /* Node has been completely replaced by clones and will be removed after
380 ipa-cp is finished. */
381 unsigned node_dead : 1;
382 /* Node is involved in a recursion, potentionally indirect. */
383 unsigned node_within_scc : 1;
384 /* Node is calling a private function called only once. */
385 unsigned node_calling_single_call : 1;
386 /* False when there is something makes versioning impossible. */
387 unsigned versionable : 1;
388 };
389
390 inline
391 ipa_node_params::ipa_node_params ()
392 : descriptors (NULL), lattices (NULL), ipcp_orig_node (NULL),
393 known_csts (vNULL), known_contexts (vNULL), analysis_done (0),
394 node_enqueued (0), do_clone_for_all_contexts (0), is_all_contexts_clone (0),
395 node_dead (0), node_within_scc (0), node_calling_single_call (0),
396 versionable (0)
397 {
398 }
399
400 inline
401 ipa_node_params::~ipa_node_params ()
402 {
403 free (lattices);
404 known_csts.release ();
405 known_contexts.release ();
406 }
407
408 /* Intermediate information that we get from alias analysis about a particular
409 parameter in a particular basic_block. When a parameter or the memory it
410 references is marked modified, we use that information in all dominated
411 blocks without consulting alias analysis oracle. */
412
413 struct ipa_param_aa_status
414 {
415 /* Set when this structure contains meaningful information. If not, the
416 structure describing a dominating BB should be used instead. */
417 bool valid;
418
419 /* Whether we have seen something which might have modified the data in
420 question. PARM is for the parameter itself, REF is for data it points to
421 but using the alias type of individual accesses and PT is the same thing
422 but for computing aggregate pass-through functions using a very inclusive
423 ao_ref. */
424 bool parm_modified, ref_modified, pt_modified;
425 };
426
427 /* Information related to a given BB that used only when looking at function
428 body. */
429
430 struct ipa_bb_info
431 {
432 /* Call graph edges going out of this BB. */
433 vec<cgraph_edge *> cg_edges;
434 /* Alias analysis statuses of each formal parameter at this bb. */
435 vec<ipa_param_aa_status> param_aa_statuses;
436 };
437
438 /* Structure with global information that is only used when looking at function
439 body. */
440
441 struct ipa_func_body_info
442 {
443 /* The node that is being analyzed. */
444 cgraph_node *node;
445
446 /* Its info. */
447 class ipa_node_params *info;
448
449 /* Information about individual BBs. */
450 vec<ipa_bb_info> bb_infos;
451
452 /* Number of parameters. */
453 int param_count;
454
455 /* Number of statements we are still allowed to walked by when analyzing this
456 function. */
457 unsigned int aa_walk_budget;
458 };
459
460 /* ipa_node_params access functions. Please use these to access fields that
461 are or will be shared among various passes. */
462
463 /* Return the number of formal parameters. */
464
465 static inline int
466 ipa_get_param_count (class ipa_node_params *info)
467 {
468 return vec_safe_length (info->descriptors);
469 }
470
471 /* Return the declaration of Ith formal parameter of the function corresponding
472 to INFO. Note there is no setter function as this array is built just once
473 using ipa_initialize_node_params. This function should not be called in
474 WPA. */
475
476 static inline tree
477 ipa_get_param (class ipa_node_params *info, int i)
478 {
479 gcc_checking_assert (info->descriptors);
480 tree t = (*info->descriptors)[i].decl_or_type;
481 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
482 return t;
483 }
484
485 /* Return the type of Ith formal parameter of the function corresponding
486 to INFO if it is known or NULL if not. */
487
488 static inline tree
489 ipa_get_type (class ipa_node_params *info, int i)
490 {
491 if (vec_safe_length (info->descriptors) <= (unsigned) i)
492 return NULL;
493 tree t = (*info->descriptors)[i].decl_or_type;
494 if (!t)
495 return NULL;
496 if (TYPE_P (t))
497 return t;
498 gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
499 return TREE_TYPE (t);
500 }
501
502 /* Return the move cost of Ith formal parameter of the function corresponding
503 to INFO. */
504
505 static inline int
506 ipa_get_param_move_cost (class ipa_node_params *info, int i)
507 {
508 gcc_checking_assert (info->descriptors);
509 return (*info->descriptors)[i].move_cost;
510 }
511
512 /* Set the used flag corresponding to the Ith formal parameter of the function
513 associated with INFO to VAL. */
514
515 static inline void
516 ipa_set_param_used (class ipa_node_params *info, int i, bool val)
517 {
518 gcc_checking_assert (info->descriptors);
519 (*info->descriptors)[i].used = val;
520 }
521
522 /* Return how many uses described by ipa-prop a parameter has or
523 IPA_UNDESCRIBED_USE if there is a use that is not described by these
524 structures. */
525 static inline int
526 ipa_get_controlled_uses (class ipa_node_params *info, int i)
527 {
528 /* FIXME: introducing speculation causes out of bounds access here. */
529 if (vec_safe_length (info->descriptors) > (unsigned)i)
530 return (*info->descriptors)[i].controlled_uses;
531 return IPA_UNDESCRIBED_USE;
532 }
533
534 /* Set the controlled counter of a given parameter. */
535
536 static inline void
537 ipa_set_controlled_uses (class ipa_node_params *info, int i, int val)
538 {
539 gcc_checking_assert (info->descriptors);
540 (*info->descriptors)[i].controlled_uses = val;
541 }
542
543 /* Return the used flag corresponding to the Ith formal parameter of the
544 function associated with INFO. */
545
546 static inline bool
547 ipa_is_param_used (class ipa_node_params *info, int i)
548 {
549 gcc_checking_assert (info->descriptors);
550 return (*info->descriptors)[i].used;
551 }
552
553 /* Information about replacements done in aggregates for a given node (each
554 node has its linked list). */
555 struct GTY(()) ipa_agg_replacement_value
556 {
557 /* Next item in the linked list. */
558 struct ipa_agg_replacement_value *next;
559 /* Offset within the aggregate. */
560 HOST_WIDE_INT offset;
561 /* The constant value. */
562 tree value;
563 /* The paramter index. */
564 int index;
565 /* Whether the value was passed by reference. */
566 bool by_ref;
567 };
568
569 /* Structure holding information for the transformation phase of IPA-CP. */
570
571 struct GTY(()) ipcp_transformation
572 {
573 /* Linked list of known aggregate values. */
574 ipa_agg_replacement_value *agg_values;
575 /* Known bits information. */
576 vec<ipa_bits *, va_gc> *bits;
577 /* Value range information. */
578 vec<ipa_vr, va_gc> *m_vr;
579 };
580
581 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
582 struct ipa_agg_replacement_value *aggvals);
583 void ipcp_transformation_initialize (void);
584 void ipcp_free_transformation_sum (void);
585
586 /* ipa_edge_args stores information related to a callsite and particularly its
587 arguments. It can be accessed by the IPA_EDGE_REF macro. */
588
589 class GTY((for_user)) ipa_edge_args
590 {
591 public:
592
593 /* Default constructor. */
594 ipa_edge_args () : jump_functions (NULL), polymorphic_call_contexts (NULL)
595 {}
596
597 /* Destructor. */
598 ~ipa_edge_args ()
599 {
600 vec_free (jump_functions);
601 vec_free (polymorphic_call_contexts);
602 }
603
604 /* Vectors of the callsite's jump function and polymorphic context
605 information of each parameter. */
606 vec<ipa_jump_func, va_gc> *jump_functions;
607 vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
608 };
609
610 /* ipa_edge_args access functions. Please use these to access fields that
611 are or will be shared among various passes. */
612
613 /* Return the number of actual arguments. */
614
615 static inline int
616 ipa_get_cs_argument_count (class ipa_edge_args *args)
617 {
618 return vec_safe_length (args->jump_functions);
619 }
620
621 /* Returns a pointer to the jump function for the ith argument. Please note
622 there is no setter function as jump functions are all set up in
623 ipa_compute_jump_functions. */
624
625 static inline struct ipa_jump_func *
626 ipa_get_ith_jump_func (class ipa_edge_args *args, int i)
627 {
628 return &(*args->jump_functions)[i];
629 }
630
631 /* Returns a pointer to the polymorphic call context for the ith argument.
632 NULL if contexts are not computed. */
633 static inline class ipa_polymorphic_call_context *
634 ipa_get_ith_polymorhic_call_context (class ipa_edge_args *args, int i)
635 {
636 if (!args->polymorphic_call_contexts)
637 return NULL;
638 return &(*args->polymorphic_call_contexts)[i];
639 }
640
641 /* Function summary for ipa_node_params. */
642 class GTY((user)) ipa_node_params_t: public function_summary <ipa_node_params *>
643 {
644 public:
645 ipa_node_params_t (symbol_table *table, bool ggc):
646 function_summary<ipa_node_params *> (table, ggc) { }
647
648 /* Hook that is called by summary when a node is duplicated. */
649 virtual void duplicate (cgraph_node *node,
650 cgraph_node *node2,
651 ipa_node_params *data,
652 ipa_node_params *data2);
653 };
654
655 /* Summary to manange ipa_edge_args structures. */
656
657 class GTY((user)) ipa_edge_args_sum_t : public call_summary <ipa_edge_args *>
658 {
659 public:
660 ipa_edge_args_sum_t (symbol_table *table, bool ggc)
661 : call_summary<ipa_edge_args *> (table, ggc) { }
662
663 void remove (cgraph_edge *edge)
664 {
665 call_summary <ipa_edge_args *>::remove (edge);
666 }
667
668 /* Hook that is called by summary when an edge is removed. */
669 virtual void remove (cgraph_edge *cs, ipa_edge_args *args);
670 /* Hook that is called by summary when an edge is duplicated. */
671 virtual void duplicate (cgraph_edge *src,
672 cgraph_edge *dst,
673 ipa_edge_args *old_args,
674 ipa_edge_args *new_args);
675 };
676
677 /* Function summary where the parameter infos are actually stored. */
678 extern GTY(()) ipa_node_params_t * ipa_node_params_sum;
679 /* Call summary to store information about edges such as jump functions. */
680 extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum;
681
682 /* Function summary for IPA-CP transformation. */
683 class ipcp_transformation_t
684 : public function_summary<ipcp_transformation *>
685 {
686 public:
687 ipcp_transformation_t (symbol_table *table, bool ggc):
688 function_summary<ipcp_transformation *> (table, ggc) {}
689
690 ~ipcp_transformation_t () {}
691
692 static ipcp_transformation_t *create_ggc (symbol_table *symtab)
693 {
694 ipcp_transformation_t *summary
695 = new (ggc_alloc_no_dtor <ipcp_transformation_t> ())
696 ipcp_transformation_t (symtab, true);
697 return summary;
698 }
699 };
700
701 /* Function summary where the IPA CP transformations are actually stored. */
702 extern GTY(()) function_summary <ipcp_transformation *> *ipcp_transformation_sum;
703
704 /* Return the associated parameter/argument info corresponding to the given
705 node/edge. */
706 #define IPA_NODE_REF(NODE) (ipa_node_params_sum->get_create (NODE))
707 #define IPA_EDGE_REF(EDGE) (ipa_edge_args_sum->get (EDGE))
708 #define IPA_EDGE_REF_GET_CREATE(EDGE) (ipa_edge_args_sum->get_create (EDGE))
709 /* This macro checks validity of index returned by
710 ipa_get_param_decl_index function. */
711 #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
712
713 /* Creating and freeing ipa_node_params and ipa_edge_args. */
714 void ipa_create_all_node_params (void);
715 void ipa_create_all_edge_args (void);
716 void ipa_check_create_edge_args (void);
717 void ipa_free_all_node_params (void);
718 void ipa_free_all_edge_args (void);
719 void ipa_free_all_structures_after_ipa_cp (void);
720 void ipa_free_all_structures_after_iinln (void);
721
722 void ipa_register_cgraph_hooks (void);
723 int count_formal_params (tree fndecl);
724
725 /* This function ensures the array of node param infos is big enough to
726 accommodate a structure for all nodes and reallocates it if not. */
727
728 static inline void
729 ipa_check_create_node_params (void)
730 {
731 if (!ipa_node_params_sum)
732 ipa_node_params_sum
733 = (new (ggc_alloc_no_dtor <ipa_node_params_t> ())
734 ipa_node_params_t (symtab, true));
735 }
736
737 /* Returns true if edge summary contains a record for EDGE. The main purpose
738 of this function is that debug dumping function can check info availability
739 without causing allocations. */
740
741 static inline bool
742 ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
743 {
744 return ipa_edge_args_sum->exists (edge);
745 }
746
747 static inline ipcp_transformation *
748 ipcp_get_transformation_summary (cgraph_node *node)
749 {
750 if (ipcp_transformation_sum == NULL)
751 return NULL;
752
753 return ipcp_transformation_sum->get (node);
754 }
755
756 /* Return the aggregate replacements for NODE, if there are any. */
757
758 static inline struct ipa_agg_replacement_value *
759 ipa_get_agg_replacements_for_node (cgraph_node *node)
760 {
761 ipcp_transformation *ts = ipcp_get_transformation_summary (node);
762 return ts ? ts->agg_values : NULL;
763 }
764
765 /* Function formal parameters related computations. */
766 void ipa_initialize_node_params (struct cgraph_node *node);
767 bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
768 vec<cgraph_edge *> *new_edges);
769
770 /* Indirect edge and binfo processing. */
771 tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
772 vec<tree> ,
773 vec<ipa_polymorphic_call_context>,
774 vec<ipa_agg_jump_function_p>,
775 bool *);
776 struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
777 bool speculative = false);
778 tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
779 ipa_bits *ipa_get_ipa_bits_for_value (const widest_int &value,
780 const widest_int &mask);
781
782
783 /* Functions related to both. */
784 void ipa_analyze_node (struct cgraph_node *);
785
786 /* Aggregate jump function related functions. */
787 tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg, tree scalar,
788 HOST_WIDE_INT offset, bool by_ref,
789 bool *from_global_constant = NULL);
790 bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
791 vec<ipa_param_descriptor, va_gc> *descriptors,
792 gimple *stmt, tree op, int *index_p,
793 HOST_WIDE_INT *offset_p, poly_int64 *size_p,
794 bool *by_ref, bool *guaranteed_unmodified = NULL);
795
796 /* Debugging interface. */
797 void ipa_print_node_params (FILE *, struct cgraph_node *node);
798 void ipa_print_all_params (FILE *);
799 void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
800 void ipa_print_all_jump_functions (FILE * f);
801 void ipcp_verify_propagated_values (void);
802
803 template <typename value>
804 class ipcp_value;
805
806 extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
807 extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
808 ipcp_poly_ctx_values_pool;
809
810 template <typename valtype>
811 struct ipcp_value_source;
812
813 extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
814
815 struct ipcp_agg_lattice;
816
817 extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
818
819 void ipa_dump_agg_replacement_values (FILE *f,
820 struct ipa_agg_replacement_value *av);
821 void ipa_prop_write_jump_functions (void);
822 void ipa_prop_read_jump_functions (void);
823 void ipcp_write_transformation_summaries (void);
824 void ipcp_read_transformation_summaries (void);
825 int ipa_get_param_decl_index (class ipa_node_params *, tree);
826 tree ipa_value_from_jfunc (class ipa_node_params *info,
827 struct ipa_jump_func *jfunc, tree type);
828 unsigned int ipcp_transform_function (struct cgraph_node *node);
829 ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
830 cgraph_edge *,
831 int,
832 ipa_jump_func *);
833 void ipa_dump_param (FILE *, class ipa_node_params *info, int i);
834 void ipa_release_body_info (struct ipa_func_body_info *);
835 tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
836
837 /* From tree-sra.c: */
838 tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree,
839 gimple_stmt_iterator *, bool);
840
841 /* In ipa-cp.c */
842 void ipa_cp_c_finalize (void);
843
844 #endif /* IPA_PROP_H */