]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ipa-prop.h
* include/bits/shared_ptr_base.h (__shared_ptr::_Deleter): Fix
[thirdparty/gcc.git] / gcc / ipa-prop.h
CommitLineData
3b22db66 1/* Interprocedural analyses.
3aea1f79 2 Copyright (C) 2005-2014 Free Software Foundation, Inc.
3b22db66 3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8c4c00c1 8Software Foundation; either version 3, or (at your option) any later
3b22db66 9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
8c4c00c1 17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
3b22db66 19
20#ifndef IPA_PROP_H
21#define IPA_PROP_H
22
545eff8f 23#include "vec.h"
f8daee9b 24#include "cgraph.h"
821d0e0f 25#include "alloc-pool.h"
3b22db66 26
27/* The following definitions and interfaces are used by
ba3a7ba0 28 interprocedural analyses or parameters. */
29
096295f6 30#define IPA_UNDESCRIBED_USE -1
31
ba3a7ba0 32/* ipa-prop.c stuff (ipa-cp, indirect inlining): */
3b22db66 33
1917e945 34/* A jump function for a callsite represents the values passed as actual
821d0e0f 35 arguments of the callsite. They were originally proposed in a paper called
36 "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
37 Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
38 types of values :
5215027d 39
40 Pass-through - the caller's formal parameter is passed as an actual
41 argument, possibly one simple operation performed on it.
42 Constant - a constant (is_gimple_ip_invariant)is passed as an actual
43 argument.
44 Unknown - neither of the above.
45
6378ffb3 46 IPA_JF_ANCESTOR is a special pass-through jump function, which means that
47 the result is an address of a part of the object pointed to by the formal
48 parameter to which the function refers. It is mainly intended to represent
49 getting addresses of of ancestor fields in C++
50 (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
51 NULL, ancestor jump function must behave like a simple pass-through.
52
53 Other pass-through functions can either simply pass on an unchanged formal
54 parameter or can apply one simple binary operation to it (such jump
55 functions are called polynomial).
56
57 IPA_JF_KNOWN_TYPE is a special type of an "unknown" function that applies
58 only to pointer parameters. It means that even though we cannot prove that
59 the passed value is an interprocedural constant, we still know the exact
60 type of the containing object which may be valuable for devirtualization.
61
62 Jump functions are computed in ipa-prop.c by function
63 update_call_notes_after_inlining. Some information can be lost and jump
64 functions degraded accordingly when inlining, see
65 update_call_notes_after_inlining in the same file. */
5215027d 66
3b22db66 67enum jump_func_type
68{
ba3a7ba0 69 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
ee4fcf24 70 IPA_JF_KNOWN_TYPE, /* represented by field known_type */
6378ffb3 71 IPA_JF_CONST, /* represented by field costant */
6378ffb3 72 IPA_JF_PASS_THROUGH, /* represented by field pass_through */
73 IPA_JF_ANCESTOR /* represented by field ancestor */
3b22db66 74};
75
ee4fcf24 76/* Structure holding data required to describe a known type jump function. */
77struct GTY(()) ipa_known_type_data
78{
79 /* Offset of the component of the base_type being described. */
80 HOST_WIDE_INT offset;
81 /* Type of the whole object. */
82 tree base_type;
83 /* Type of the component of the object that is being described. */
84 tree component_type;
85};
86
096295f6 87struct ipa_cst_ref_desc;
88
89/* Structure holding data required to describe a constant jump function. */
90struct GTY(()) ipa_constant_data
91{
92 /* THe value of the constant. */
93 tree value;
94 /* Pointer to the structure that describes the reference. */
95 struct ipa_cst_ref_desc GTY((skip)) *rdesc;
96};
97
5215027d 98/* Structure holding data required to describe a pass-through jump function. */
99
8867b500 100struct GTY(()) ipa_pass_through_data
5215027d 101{
102 /* If an operation is to be performed on the original parameter, this is the
103 second (constant) operand. */
104 tree operand;
105 /* Number of the caller's formal parameter being passed. */
106 int formal_id;
107 /* Operation that is performed on the argument before it is passed on.
108 NOP_EXPR means no operation. Otherwise oper must be a simple binary
109 arithmetic operation where the caller's parameter is the first operand and
110 operand field from this structure is the second one. */
111 enum tree_code operation;
0d491188 112 /* When the passed value is a pointer, it is set to true only when we are
113 certain that no write to the object it points to has occurred since the
114 caller functions started execution, except for changes noted in the
115 aggregate part of the jump function (see description of
116 ipa_agg_jump_function). The flag is used only when the operation is
117 NOP_EXPR. */
ad4a8b28 118 unsigned agg_preserved : 1;
119
120 /* When set to true, we guarantee that, if there is a C++ object pointed to
121 by this object, it does not undergo dynamic type change in the course of
122 functions decribed by this jump function. */
123 unsigned type_preserved : 1;
5215027d 124};
125
6378ffb3 126/* Structure holding data required to describe an ancestor pass-through
127 jump function. */
5215027d 128
8867b500 129struct GTY(()) ipa_ancestor_jf_data
5215027d 130{
131 /* Offset of the field representing the ancestor. */
132 HOST_WIDE_INT offset;
0daac096 133 /* Type of the result.
134 When TYPE_PRESERVED is false, TYPE is NULL, since it is only
135 relevant for the devirtualization machinery. */
5215027d 136 tree type;
137 /* Number of the caller's formal parameter being passed. */
138 int formal_id;
0d491188 139 /* Flag with the same meaning like agg_preserve in ipa_pass_through_data. */
ad4a8b28 140 unsigned agg_preserved : 1;
141 /* When set to true, we guarantee that, if there is a C++ object pointed to
142 by this object, it does not undergo dynamic type change in the course of
143 functions decribed by this jump function. */
144 unsigned type_preserved : 1;
5215027d 145};
146
0d491188 147/* An element in an aggegate part of a jump function describing a known value
148 at a given offset. When it is part of a pass-through jump function with
149 agg_preserved set or an ancestor jump function with agg_preserved set, all
150 unlisted positions are assumed to be preserved but the value can be a type
151 node, which means that the particular piece (starting at offset and having
152 the size of the type) is clobbered with an unknown value. When
153 agg_preserved is false or the type of the containing jump function is
154 different, all unlisted parts are assumed to be unknown and all values must
a04e8d62 155 fulfill is_gimple_ip_invariant. */
0d491188 156
b3e7c666 157struct GTY(()) ipa_agg_jf_item
0d491188 158{
159 /* The offset at which the known value is located within the aggregate. */
160 HOST_WIDE_INT offset;
161
162 /* The known constant or type if this is a clobber. */
163 tree value;
b3e7c666 164};
0d491188 165
0d491188 166
167/* Aggregate jump function - i.e. description of contents of aggregates passed
168 either by reference or value. */
169
170struct GTY(()) ipa_agg_jump_function
f8daee9b 171{
0d491188 172 /* Description of the individual items. */
b3e7c666 173 vec<ipa_agg_jf_item, va_gc> *items;
0d491188 174 /* True if the data was passed by reference (as opposed to by value). */
175 bool by_ref;
f8daee9b 176};
177
0d491188 178typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
0d491188 179
1917e945 180/* A jump function for a callsite represents the values passed as actual
181 arguments of the callsite. See enum jump_func_type for the various
3b22db66 182 types of jump functions supported. */
b3e7c666 183struct GTY (()) ipa_jump_func
3b22db66 184{
0d491188 185 /* Aggregate contants description. See struct ipa_agg_jump_function and its
186 description. */
187 struct ipa_agg_jump_function agg;
188
3b22db66 189 enum jump_func_type type;
8867b500 190 /* Represents a value of a jump function. pass_through is used only in jump
191 function context. constant represents the actual constant in constant jump
192 functions and member_cst holds constant c++ member functions. */
193 union jump_func_value
194 {
ee4fcf24 195 struct ipa_known_type_data GTY ((tag ("IPA_JF_KNOWN_TYPE"))) known_type;
096295f6 196 struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
8867b500 197 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
198 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
8867b500 199 } GTY ((desc ("%1.type"))) value;
b3e7c666 200};
b22832dc 201
3b22db66 202
a04e8d62 203/* Return the offset of the component that is described by a known type jump
4fa83f96 204 function JFUNC. */
205
206static inline HOST_WIDE_INT
207ipa_get_jf_known_type_offset (struct ipa_jump_func *jfunc)
208{
209 gcc_checking_assert (jfunc->type == IPA_JF_KNOWN_TYPE);
210 return jfunc->value.known_type.offset;
211}
212
213/* Return the base type of a known type jump function JFUNC. */
214
215static inline tree
216ipa_get_jf_known_type_base_type (struct ipa_jump_func *jfunc)
217{
218 gcc_checking_assert (jfunc->type == IPA_JF_KNOWN_TYPE);
219 return jfunc->value.known_type.base_type;
220}
221
222/* Return the component type of a known type jump function JFUNC. */
223
224static inline tree
225ipa_get_jf_known_type_component_type (struct ipa_jump_func *jfunc)
226{
227 gcc_checking_assert (jfunc->type == IPA_JF_KNOWN_TYPE);
228 return jfunc->value.known_type.component_type;
229}
230
231/* Return the constant stored in a constant jump functin JFUNC. */
232
233static inline tree
234ipa_get_jf_constant (struct ipa_jump_func *jfunc)
235{
236 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
096295f6 237 return jfunc->value.constant.value;
238}
239
240static inline struct ipa_cst_ref_desc *
241ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
242{
243 gcc_checking_assert (jfunc->type == IPA_JF_CONST);
244 return jfunc->value.constant.rdesc;
4fa83f96 245}
246
247/* Return the operand of a pass through jmp function JFUNC. */
248
249static inline tree
250ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
251{
252 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
253 return jfunc->value.pass_through.operand;
254}
255
256/* Return the number of the caller's formal parameter that a pass through jump
257 function JFUNC refers to. */
258
259static inline int
260ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
261{
262 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
263 return jfunc->value.pass_through.formal_id;
264}
265
266/* Return operation of a pass through jump function JFUNC. */
267
268static inline enum tree_code
269ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
270{
271 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
272 return jfunc->value.pass_through.operation;
273}
274
ad4a8b28 275/* Return the agg_preserved flag of a pass through jump function JFUNC. */
0d491188 276
277static inline bool
278ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
279{
280 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
281 return jfunc->value.pass_through.agg_preserved;
282}
283
ad4a8b28 284/* Return the type_preserved flag of a pass through jump function JFUNC. */
285
286static inline bool
287ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
288{
289 gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
290 return jfunc->value.pass_through.type_preserved;
291}
292
4fa83f96 293/* Return the offset of an ancestor jump function JFUNC. */
294
295static inline HOST_WIDE_INT
296ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
297{
298 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
299 return jfunc->value.ancestor.offset;
300}
301
302/* Return the result type of an ancestor jump function JFUNC. */
303
304static inline tree
305ipa_get_jf_ancestor_type (struct ipa_jump_func *jfunc)
306{
307 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
308 return jfunc->value.ancestor.type;
309}
310
311/* Return the number of the caller's formal parameter that an ancestor jump
312 function JFUNC refers to. */
313
314static inline int
315ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
316{
317 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
318 return jfunc->value.ancestor.formal_id;
319}
320
ad4a8b28 321/* Return the agg_preserved flag of an ancestor jump function JFUNC. */
4fa83f96 322
0d491188 323static inline bool
324ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
4fa83f96 325{
0d491188 326 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
327 return jfunc->value.ancestor.agg_preserved;
4fa83f96 328}
329
ad4a8b28 330/* Return the type_preserved flag of an ancestor jump function JFUNC. */
331
332static inline bool
333ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
334{
335 gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
336 return jfunc->value.ancestor.type_preserved;
337}
338
821d0e0f 339/* Summary describing a single formal parameter. */
6378ffb3 340
3f2ff969 341struct ipa_param_descriptor
342{
3f2ff969 343 /* PARAM_DECL of this parameter. */
344 tree decl;
096295f6 345 /* If all uses of the parameter are described by ipa-prop structures, this
346 says how many there are. If any use could not be described by means of
347 ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
348 int controlled_uses;
09ab6335 349 unsigned int move_cost : 31;
bc1b408a 350 /* The parameter is used. */
351 unsigned used : 1;
3f2ff969 352};
353
821d0e0f 354struct ipcp_lattice;
355
3889f2e2 356/* ipa_node_params stores information related to formal parameters of functions
357 and some other information for interprocedural passes that operate on
358 parameters (such as ipa-cp). */
821d0e0f 359
3889f2e2 360struct ipa_node_params
3b22db66 361{
821d0e0f 362 /* Information about individual formal parameters that are gathered when
363 summaries are generated. */
b3e7c666 364 vec<ipa_param_descriptor> descriptors;
821d0e0f 365 /* Pointer to an array of structures describing individual formal
366 parameters. */
803a7988 367 struct ipcp_param_lattices *lattices;
821d0e0f 368 /* Only for versioned nodes this field would not be NULL,
369 it points to the node that IPA cp cloned from. */
370 struct cgraph_node *ipcp_orig_node;
371 /* If this node is an ipa-cp clone, these are the known values that describe
372 what it has been specialized for. */
f1f41a6c 373 vec<tree> known_vals;
24430d08 374 /* Whether the param uses analysis and jump function computation has already
375 been performed. */
376 unsigned analysis_done : 1;
821d0e0f 377 /* Whether the function is enqueued in ipa-cp propagation stack. */
609c710b 378 unsigned node_enqueued : 1;
821d0e0f 379 /* Whether we should create a specialized version based on values that are
380 known to be constant in all contexts. */
87228246 381 unsigned do_clone_for_all_contexts : 1;
382 /* Set if this is an IPA-CP clone for all contexts. */
383 unsigned is_all_contexts_clone : 1;
821d0e0f 384 /* Node has been completely replaced by clones and will be removed after
385 ipa-cp is finished. */
386 unsigned node_dead : 1;
3b22db66 387};
388
3889f2e2 389/* ipa_node_params access functions. Please use these to access fields that
390 are or will be shared among various passes. */
391
3889f2e2 392/* Return the number of formal parameters. */
1917e945 393
3889f2e2 394static inline int
395ipa_get_param_count (struct ipa_node_params *info)
396{
f1f41a6c 397 return info->descriptors.length ();
3889f2e2 398}
399
3f2ff969 400/* Return the declaration of Ith formal parameter of the function corresponding
401 to INFO. Note there is no setter function as this array is built just once
402 using ipa_initialize_node_params. */
1917e945 403
3889f2e2 404static inline tree
3f2ff969 405ipa_get_param (struct ipa_node_params *info, int i)
3889f2e2 406{
09ab6335 407 gcc_checking_assert (!flag_wpa);
f1f41a6c 408 return info->descriptors[i].decl;
bc1b408a 409}
410
09ab6335 411/* Return the move cost of Ith formal parameter of the function corresponding
412 to INFO. */
413
414static inline int
415ipa_get_param_move_cost (struct ipa_node_params *info, int i)
416{
417 return info->descriptors[i].move_cost;
418}
419
821d0e0f 420/* Set the used flag corresponding to the Ith formal parameter of the function
421 associated with INFO to VAL. */
1caef38b 422
821d0e0f 423static inline void
424ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
1caef38b 425{
f1f41a6c 426 info->descriptors[i].used = val;
1caef38b 427}
428
096295f6 429/* Return how many uses described by ipa-prop a parameter has or
430 IPA_UNDESCRIBED_USE if there is a use that is not described by these
431 structures. */
432static inline int
433ipa_get_controlled_uses (struct ipa_node_params *info, int i)
434{
435 return info->descriptors[i].controlled_uses;
436}
437
438/* Set the controlled counter of a given parameter. */
439
440static inline void
441ipa_set_controlled_uses (struct ipa_node_params *info, int i, int val)
442{
443 info->descriptors[i].controlled_uses = val;
444}
445
821d0e0f 446/* Return the used flag corresponding to the Ith formal parameter of the
447 function associated with INFO. */
1caef38b 448
449static inline bool
821d0e0f 450ipa_is_param_used (struct ipa_node_params *info, int i)
1caef38b 451{
f1f41a6c 452 return info->descriptors[i].used;
1caef38b 453}
454
803a7988 455/* Information about replacements done in aggregates for a given node (each
456 node has its linked list). */
457struct GTY(()) ipa_agg_replacement_value
458{
459 /* Next item in the linked list. */
460 struct ipa_agg_replacement_value *next;
461 /* Offset within the aggregate. */
462 HOST_WIDE_INT offset;
463 /* The constant value. */
464 tree value;
465 /* The paramter index. */
466 int index;
c42e4f2e 467 /* Whether the value was passed by reference. */
468 bool by_ref;
803a7988 469};
470
471typedef struct ipa_agg_replacement_value *ipa_agg_replacement_value_p;
803a7988 472
473void ipa_set_node_agg_value_chain (struct cgraph_node *node,
474 struct ipa_agg_replacement_value *aggvals);
475
10d560f3 476/* ipa_edge_args stores information related to a callsite and particularly its
477 arguments. It can be accessed by the IPA_EDGE_REF macro. */
b3e7c666 478struct GTY(()) ipa_edge_args
3b22db66 479{
b22832dc 480 /* Vector of the callsite's jump function of each parameter. */
b3e7c666 481 vec<ipa_jump_func, va_gc> *jump_functions;
482};
3b22db66 483
3889f2e2 484/* ipa_edge_args access functions. Please use these to access fields that
485 are or will be shared among various passes. */
486
3889f2e2 487/* Return the number of actual arguments. */
1917e945 488
3889f2e2 489static inline int
490ipa_get_cs_argument_count (struct ipa_edge_args *args)
491{
f1f41a6c 492 return vec_safe_length (args->jump_functions);
3889f2e2 493}
494
495/* Returns a pointer to the jump function for the ith argument. Please note
496 there is no setter function as jump functions are all set up in
497 ipa_compute_jump_functions. */
1917e945 498
3889f2e2 499static inline struct ipa_jump_func *
500ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
501{
f1f41a6c 502 return &(*args->jump_functions)[i];
3889f2e2 503}
504
1917e945 505/* Types of vectors holding the infos. */
545eff8f 506
507/* Vector where the parameter infos are actually stored. */
b3e7c666 508extern vec<ipa_node_params> ipa_node_params_vector;
803a7988 509/* Vector of known aggregate values in cloned nodes. */
f1f41a6c 510extern GTY(()) vec<ipa_agg_replacement_value_p, va_gc> *ipa_node_agg_replacements;
545eff8f 511/* Vector where the parameter infos are actually stored. */
b3e7c666 512extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
545eff8f 513
514/* Return the associated parameter/argument info corresponding to the given
515 node/edge. */
f1f41a6c 516#define IPA_NODE_REF(NODE) (&ipa_node_params_vector[(NODE)->uid])
517#define IPA_EDGE_REF(EDGE) (&(*ipa_edge_args_vector)[(EDGE)->uid])
545eff8f 518/* This macro checks validity of index returned by
519 ipa_get_param_decl_index function. */
520#define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
521
522/* Creating and freeing ipa_node_params and ipa_edge_args. */
523void ipa_create_all_node_params (void);
524void ipa_create_all_edge_args (void);
525void ipa_free_edge_args_substructures (struct ipa_edge_args *);
526void ipa_free_node_params_substructures (struct ipa_node_params *);
527void ipa_free_all_node_params (void);
528void ipa_free_all_edge_args (void);
799c8711 529void ipa_free_all_structures_after_ipa_cp (void);
530void ipa_free_all_structures_after_iinln (void);
545eff8f 531void ipa_register_cgraph_hooks (void);
532
533/* This function ensures the array of node param infos is big enough to
1917e945 534 accommodate a structure for all nodes and reallocates it if not. */
535
545eff8f 536static inline void
537ipa_check_create_node_params (void)
538{
f1f41a6c 539 if (!ipa_node_params_vector.exists ())
540 ipa_node_params_vector.create (cgraph_max_uid);
545eff8f 541
f1f41a6c 542 if (ipa_node_params_vector.length () <= (unsigned) cgraph_max_uid)
543 ipa_node_params_vector.safe_grow_cleared (cgraph_max_uid + 1);
545eff8f 544}
545
1917e945 546/* This function ensures the array of edge arguments infos is big enough to
547 accommodate a structure for all edges and reallocates it if not. */
548
545eff8f 549static inline void
550ipa_check_create_edge_args (void)
551{
f1f41a6c 552 if (vec_safe_length (ipa_edge_args_vector) <= (unsigned) cgraph_edge_max_uid)
553 vec_safe_grow_cleared (ipa_edge_args_vector, cgraph_edge_max_uid + 1);
545eff8f 554}
555
1917e945 556/* Returns true if the array of edge infos is large enough to accommodate an
86c96e3a 557 info for EDGE. The main purpose of this function is that debug dumping
558 function can check info availability without causing reallocations. */
1917e945 559
86c96e3a 560static inline bool
561ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
562{
f1f41a6c 563 return ((unsigned) edge->uid < vec_safe_length (ipa_edge_args_vector));
86c96e3a 564}
565
803a7988 566/* Return the aggregate replacements for NODE, if there are any. */
567
568static inline struct ipa_agg_replacement_value *
569ipa_get_agg_replacements_for_node (struct cgraph_node *node)
570{
f1f41a6c 571 if ((unsigned) node->uid >= vec_safe_length (ipa_node_agg_replacements))
803a7988 572 return NULL;
f1f41a6c 573 return (*ipa_node_agg_replacements)[node->uid];
803a7988 574}
575
3f2ff969 576/* Function formal parameters related computations. */
577void ipa_initialize_node_params (struct cgraph_node *node);
3f2ff969 578bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
f1f41a6c 579 vec<cgraph_edge_p> *new_edges);
3b22db66 580
1caef38b 581/* Indirect edge and binfo processing. */
20da2013 582tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
f1f41a6c 583 vec<tree> ,
584 vec<tree> ,
585 vec<ipa_agg_jump_function_p> );
d4e80e2b 586struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree);
bee52153 587tree ipa_binfo_from_known_type_jfunc (struct ipa_jump_func *);
588tree ipa_intraprocedural_devirtualization (gimple);
1caef38b 589
821d0e0f 590/* Functions related to both. */
591void ipa_analyze_node (struct cgraph_node *);
1caef38b 592
0d491188 593/* Aggregate jump function related functions. */
594tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *, HOST_WIDE_INT,
595 bool);
596bool ipa_load_from_parm_agg (struct ipa_node_params *, gimple, tree, int *,
597 HOST_WIDE_INT *, bool *);
598
3b22db66 599/* Debugging interface. */
11b73810 600void ipa_print_node_params (FILE *, struct cgraph_node *node);
601void ipa_print_all_params (FILE *);
f8daee9b 602void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
603void ipa_print_all_jump_functions (FILE * f);
821d0e0f 604void ipcp_verify_propagated_values (void);
605
606extern alloc_pool ipcp_values_pool;
607extern alloc_pool ipcp_sources_pool;
803a7988 608extern alloc_pool ipcp_agg_lattice_pool;
3b22db66 609
6bcfabf2 610/* Operation to be performed for the parameter in ipa_parm_adjustment
611 below. */
612enum ipa_parm_op {
613 IPA_PARM_OP_NONE,
614
615 /* This describes a brand new parameter.
616
617 The field `type' should be set to the new type, `arg_prefix'
618 should be set to the string prefix for the new DECL_NAME, and
619 `new_decl' will ultimately hold the newly created argument. */
620 IPA_PARM_OP_NEW,
621
622 /* This new parameter is an unmodified parameter at index base_index. */
623 IPA_PARM_OP_COPY,
624
625 /* This adjustment describes a parameter that is about to be removed
626 completely. Most users will probably need to book keep those so that they
627 don't leave behinfd any non default def ssa names belonging to them. */
628 IPA_PARM_OP_REMOVE
629};
630
547f1802 631/* Structure to describe transformations of formal parameters and actual
632 arguments. Each instance describes one new parameter and they are meant to
633 be stored in a vector. Additionally, most users will probably want to store
634 adjustments about parameters that are being removed altogether so that SSA
635 names belonging to them can be replaced by SSA names of an artificial
636 variable. */
637struct ipa_parm_adjustment
638{
639 /* The original PARM_DECL itself, helpful for processing of the body of the
640 function itself. Intended for traversing function bodies.
641 ipa_modify_formal_parameters, ipa_modify_call_arguments and
642 ipa_combine_adjustments ignore this and use base_index.
643 ipa_modify_formal_parameters actually sets this. */
644 tree base;
645
646 /* Type of the new parameter. However, if by_ref is true, the real type will
647 be a pointer to this type. */
648 tree type;
649
14c9496e 650 /* Alias refrerence type to be used in MEM_REFs when adjusting caller
651 arguments. */
652 tree alias_ptr_type;
653
6bcfabf2 654 /* The new declaration when creating/replacing a parameter. Created
655 by ipa_modify_formal_parameters, useful for functions modifying
656 the body accordingly. For brand new arguments, this is the newly
657 created argument. */
658 tree new_decl;
547f1802 659
660 /* New declaration of a substitute variable that we may use to replace all
661 non-default-def ssa names when a parm decl is going away. */
662 tree new_ssa_base;
663
664 /* If non-NULL and the original parameter is to be removed (copy_param below
665 is NULL), this is going to be its nonlocalized vars value. */
666 tree nonlocal_value;
667
6bcfabf2 668 /* This holds the prefix to be used for the new DECL_NAME. */
669 const char *arg_prefix;
670
547f1802 671 /* Offset into the original parameter (for the cases when the new parameter
672 is a component of an original one). */
673 HOST_WIDE_INT offset;
674
6bcfabf2 675 /* Zero based index of the original parameter this one is based on. */
547f1802 676 int base_index;
677
6bcfabf2 678 /* Whether this parameter is a new parameter, a copy of an old one,
679 or one about to be removed. */
680 enum ipa_parm_op op;
547f1802 681
682 /* The parameter is to be passed by reference. */
683 unsigned by_ref : 1;
684};
685
b3e7c666 686typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
547f1802 687
f1f41a6c 688vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
6bcfabf2 689vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
690void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
547f1802 691void ipa_modify_call_arguments (struct cgraph_edge *, gimple,
692 ipa_parm_adjustment_vec);
693ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
694 ipa_parm_adjustment_vec);
695void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
803a7988 696void ipa_dump_agg_replacement_values (FILE *f,
697 struct ipa_agg_replacement_value *av);
eab36a5a 698void ipa_prop_write_jump_functions (void);
8867b500 699void ipa_prop_read_jump_functions (void);
803a7988 700void ipa_prop_write_all_agg_replacement (void);
701void ipa_prop_read_all_agg_replacement (void);
8867b500 702void ipa_update_after_lto_read (void);
a41f2a28 703int ipa_get_param_decl_index (struct ipa_node_params *, tree);
20da2013 704tree ipa_value_from_jfunc (struct ipa_node_params *info,
705 struct ipa_jump_func *jfunc);
803a7988 706unsigned int ipcp_transform_function (struct cgraph_node *node);
09ab6335 707void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
6bcfabf2 708bool ipa_modify_expr (tree *, bool, ipa_parm_adjustment_vec);
709ipa_parm_adjustment *ipa_get_adjustment_candidate (tree **, bool *,
710 ipa_parm_adjustment_vec,
711 bool);
93f713da 712
8867b500 713
547f1802 714/* From tree-sra.c: */
a60aac35 715tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,
716 gimple_stmt_iterator *, bool);
547f1802 717
3b22db66 718#endif /* IPA_PROP_H */