Line data Source code
1 : /* Interprocedural analyses.
2 : Copyright (C) 2005-2026 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 : /* Index identifying an actualargument or a formal parameter may have only this
29 : many bits. */
30 :
31 : #define IPA_PROP_ARG_INDEX_LIMIT_BITS 16
32 :
33 : /* ipa-prop.cc stuff (ipa-cp, indirect inlining): */
34 :
35 : /* A jump function for a callsite represents the values passed as actual
36 : arguments of the callsite. They were originally proposed in a paper called
37 : "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
38 : Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
39 : types of values :
40 :
41 : Pass-through - the caller's formal parameter is passed as an actual
42 : argument, possibly one simple operation performed on it.
43 : Constant - a constant (is_gimple_ip_invariant)is passed as an actual
44 : argument.
45 : Unknown - neither of the above.
46 :
47 : IPA_JF_LOAD_AGG is a compound pass-through jump function, in which primary
48 : operation on formal parameter is memory dereference that loads a value from
49 : a part of an aggregate, which is represented or pointed to by the formal
50 : parameter. Moreover, an additional unary/binary operation can be applied on
51 : the loaded value, and final result is passed as actual argument of callee
52 : (e.g. *(param_1(D) + 4) op 24 ). It is meant to describe usage of aggregate
53 : parameter or by-reference parameter referenced in argument passing, commonly
54 : found in C++ and Fortran.
55 :
56 : IPA_JF_ANCESTOR is a special pass-through jump function, which means that
57 : the result is an address of a part of the object pointed to by the formal
58 : parameter to which the function refers. It is mainly intended to represent
59 : getting addresses of ancestor fields in C++
60 : (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
61 : NULL, ancestor jump function must behave like a simple pass-through.
62 :
63 : Other pass-through functions can either simply pass on an unchanged formal
64 : parameter or can apply one simple binary operation to it (such jump
65 : functions are called polynomial).
66 :
67 : Jump functions are computed in ipa-prop.cc by function
68 : update_call_notes_after_inlining. Some information can be lost and jump
69 : functions degraded accordingly when inlining, see
70 : update_call_notes_after_inlining in the same file. */
71 :
72 : enum jump_func_type
73 : {
74 : IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
75 : IPA_JF_CONST, /* represented by field constant */
76 : IPA_JF_PASS_THROUGH, /* represented by field pass_through */
77 : IPA_JF_LOAD_AGG, /* represented by field load_agg */
78 : IPA_JF_ANCESTOR /* represented by field ancestor */
79 : };
80 :
81 : struct ipa_cst_ref_desc;
82 :
83 : /* Structure holding data required to describe a constant jump function. */
84 : struct GTY(()) ipa_constant_data
85 : {
86 : /* The value of the constant. */
87 : tree value;
88 : /* Pointer to the structure that describes the reference. */
89 : struct ipa_cst_ref_desc GTY((skip)) *rdesc;
90 : };
91 :
92 : /* Structure holding data required to describe a pass-through jump function. */
93 :
94 : struct GTY(()) ipa_pass_through_data
95 : {
96 : /* If an operation is to be performed on the original parameter, this is the
97 : second (constant) operand. */
98 : tree operand;
99 : /* The result type of the operation. In case of no operation (represented by
100 : NOP_EXPR) it should be NULL_TREE. */
101 : tree op_type;
102 : /* Number of the caller's formal parameter being passed. */
103 : int formal_id;
104 : /* Operation that is performed on the argument before it is passed on.
105 : Special values which have other meaning than in normal contexts:
106 : - NOP_EXPR means no operation, not even type conversion.
107 : - ASSERT_EXPR means that only the value in operand is allowed to pass
108 : through (without any change), for all other values the result is
109 : unknown.
110 : Otherwise operation must be a simple binary or unary arithmetic operation
111 : where the caller's parameter is the first operand and (for binary
112 : operations) the operand field from this structure is the second one. */
113 : enum tree_code operation;
114 : /* When the passed value is a pointer, it is set to true only when we are
115 : certain that no write to the object it points to has occurred since the
116 : caller functions started execution, except for changes noted in the
117 : aggregate part of the jump function (see description of
118 : ipa_agg_jump_function). The flag is used only when the operation is
119 : NOP_EXPR. */
120 : unsigned agg_preserved : 1;
121 : /* Set when the edge has already been used to decrement an appropriate
122 : reference description counter and should not be decremented again. */
123 : unsigned refdesc_decremented : 1;
124 : };
125 :
126 : /* Structure holding data required to describe a load-value-from-aggregate
127 : jump function. */
128 :
129 : struct GTY(()) ipa_load_agg_data
130 : {
131 : /* Inherit from pass through jump function, describing unary/binary
132 : operation on the value loaded from aggregate that is represented or
133 : pointed to by the formal parameter, specified by formal_id in this
134 : pass_through jump function data structure. */
135 : struct ipa_pass_through_data pass_through;
136 : /* Type of the value loaded from the aggregate. */
137 : tree type;
138 : /* Offset at which the value is located within the aggregate. */
139 : HOST_WIDE_INT offset;
140 : /* True if loaded by reference (the aggregate is pointed to by the formal
141 : parameter) or false if loaded by value (the aggregate is represented
142 : by the formal parameter). */
143 : bool by_ref;
144 : };
145 :
146 : /* Structure holding data required to describe an ancestor pass-through
147 : jump function. */
148 :
149 : struct GTY(()) ipa_ancestor_jf_data
150 : {
151 : /* Offset of the field representing the ancestor. */
152 : HOST_WIDE_INT offset;
153 : /* Number of the caller's formal parameter being passed. */
154 : int formal_id;
155 : /* Flag with the same meaning like agg_preserve in ipa_pass_through_data. */
156 : unsigned agg_preserved : 1;
157 : /* When set, the operation should not have any effect on NULL pointers. */
158 : unsigned keep_null : 1;
159 : };
160 :
161 : /* A jump function for an aggregate part at a given offset, which describes how
162 : it content value is generated. All unlisted positions are assumed to have a
163 : value defined in an unknown way. */
164 :
165 : struct GTY(()) ipa_agg_jf_item
166 : {
167 : /* The offset for the aggregate part. */
168 : HOST_WIDE_INT offset;
169 :
170 : /* Data type of the aggregate part. */
171 : tree type;
172 :
173 : /* Jump function type. */
174 : enum jump_func_type jftype;
175 :
176 : /* Represents a value of jump function. constant represents the actual constant
177 : in constant jump function content. pass_through is used only in simple pass
178 : through jump function context. load_agg is for load-value-from-aggregate
179 : jump function context. */
180 : union jump_func_agg_value
181 : {
182 : tree GTY ((tag ("IPA_JF_CONST"))) constant;
183 : struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
184 : struct ipa_load_agg_data GTY ((tag ("IPA_JF_LOAD_AGG"))) load_agg;
185 : } GTY ((desc ("%1.jftype"))) value;
186 : };
187 :
188 : /* Jump functions describing a set of aggregate contents. */
189 :
190 : struct GTY(()) ipa_agg_jump_function
191 : {
192 : /* Description of the individual jump function item. */
193 : vec<ipa_agg_jf_item, va_gc> *items;
194 : /* True if the data was passed by reference (as opposed to by value). */
195 : bool by_ref;
196 : };
197 :
198 : class ipcp_transformation;
199 : class ipa_auto_call_arg_values;
200 : class ipa_call_arg_values;
201 :
202 : /* Element of a vector describing aggregate values for a number of arguments in
203 : a particular context, be it a call or the aggregate constants that a node is
204 : specialized for. */
205 :
206 : struct GTY(()) ipa_argagg_value
207 : {
208 : /* The constant value. In the contexts where the list of known values is
209 : being pruned, NULL means a variable value. */
210 : tree value;
211 : /* Unit offset within the aggregate. */
212 : unsigned unit_offset;
213 : /* Index of the parameter, as it was in the original function (i.e. needs
214 : remapping after parameter modification is carried out as part of clone
215 : materialization). */
216 : unsigned index : IPA_PROP_ARG_INDEX_LIMIT_BITS;
217 : /* Whether the value was passed by reference. */
218 : unsigned by_ref : 1;
219 : /* Set if the value should not be used after materialization in
220 : value_numbering. It is kept around just so that clone materialization can
221 : distinguish a combined IPA-CP and IPA-SRA from a deleted argument. */
222 : unsigned killed : 1;
223 : };
224 :
225 : /* A view into a sorted list of aggregate values in a particular context, be it
226 : a call or the aggregate constants that a node is specialized for. The
227 : actual data is stored in the vector this has been constructed from. */
228 :
229 : class ipa_argagg_value_list
230 : {
231 : public:
232 : ipa_argagg_value_list () = delete;
233 3445 : ipa_argagg_value_list (const vec<ipa_argagg_value, va_gc> *values,
234 : array_slice<const tree> known_vals = {})
235 6781 : : m_elts (values), m_known_vals (known_vals)
236 : {}
237 56788 : ipa_argagg_value_list (const vec<ipa_argagg_value> *values,
238 : array_slice<const tree> known_vals = {})
239 113576 : : m_elts (*values), m_known_vals (known_vals)
240 : {}
241 : ipa_argagg_value_list (const ipa_auto_call_arg_values *aavals);
242 : ipa_argagg_value_list (const ipa_call_arg_values *gavals);
243 : ipa_argagg_value_list (const ipcp_transformation *tinfo);
244 :
245 : /* Return the aggregate constant stored for INDEX at UNIT_OFFSET, if it is
246 : passed by reference or not according to BY_REF (and if MAYBE_MODIFIED is
247 : true, only when the memory passed by reference is read-only), or
248 : NULL_TREE otherwise. */
249 :
250 : tree get_value (int index, unsigned unit_offset, bool by_ref,
251 : bool maybe_modified = false) const;
252 :
253 : /* Return the aggregate constant stored for INDEX at UNIT_OFFSET, not
254 : performing any check of whether value is passed by reference. Return
255 : NULL_TREE if there is no such constant. */
256 :
257 : tree get_value (int index, unsigned unit_offset) const;
258 :
259 : /* Return the item describing a constant stored for INDEX at UNIT_OFFSET or
260 : NULL if there is no such constant. */
261 :
262 : const ipa_argagg_value *get_elt (int index, unsigned unit_offset) const;
263 :
264 :
265 : /* Return the first item describing a constant stored for parameter with
266 : INDEX, regardless of offset or reference, or NULL if there is no such
267 : constant. */
268 :
269 : const ipa_argagg_value *get_elt_for_index (int index) const;
270 :
271 : /* Return true if there is an aggregate constant referring to a value passed
272 : in or by parameter with INDEX (at any offset, whether by reference or
273 : not). */
274 :
275 249958 : bool value_for_index_p (int index) const
276 : {
277 249958 : return !!get_elt_for_index (index);
278 : }
279 :
280 : /* Return true if all elements present in OTHER are also present in this
281 : list. */
282 :
283 : bool superset_of_p (const ipa_argagg_value_list &other) const;
284 :
285 : /* Push all items in this list that describe parameter SRC_INDEX into RES as
286 : ones describing DST_INDEX while subtracting UNIT_DELTA from their unit
287 : offsets but skip those which would end up with a negative offset. */
288 :
289 : void push_adjusted_values (unsigned src_index, unsigned dest_index,
290 : unsigned unit_delta,
291 : vec<ipa_argagg_value> *res) const;
292 :
293 : /* Dump aggregate constants to FILE. */
294 :
295 : void dump (FILE *f);
296 :
297 : /* Dump aggregate constants to stderr. */
298 :
299 : void DEBUG_FUNCTION debug ();
300 :
301 : /* Array slice pointing to the actual storage. */
302 :
303 : array_slice<const ipa_argagg_value> m_elts;
304 :
305 : /* Array slice of known scalar values of arguments, if available. */
306 :
307 : array_slice<const tree> m_known_vals;
308 : };
309 :
310 : /* Info about value ranges. */
311 :
312 : class GTY(()) ipa_vr
313 : {
314 : public:
315 : ipa_vr ();
316 : ipa_vr (const vrange &);
317 : void set_unknown ();
318 10427073 : bool known_p () const { return m_storage != NULL; }
319 10024193 : tree type () const { return m_type; }
320 : void get_vrange (value_range &) const;
321 : bool equal_p (const vrange &) const;
322 : bool equal_p (const ipa_vr &) const;
323 : const vrange_storage *storage () const { return m_storage; }
324 : void streamer_read (lto_input_block *, class data_in *);
325 : void streamer_write (output_block *) const;
326 : void dump (FILE *) const;
327 :
328 : private:
329 : friend void gt_pch_nx (struct ipa_vr &);
330 : friend void gt_ggc_mx (struct ipa_vr &);
331 : friend void gt_pch_nx (struct ipa_vr *, gt_pointer_operator, void *);
332 : friend void gt_ggc_mx_ipa_vr (void *);
333 : friend void gt_pch_nx_ipa_vr (void*);
334 : friend void gt_pch_p_6ipa_vr(void*, void*, gt_pointer_operator, void*);
335 :
336 : vrange_storage *m_storage;
337 : tree m_type;
338 : };
339 :
340 : /* A jump function for a callsite represents the values passed as actual
341 : arguments of the callsite. See enum jump_func_type for the various
342 : types of jump functions supported. */
343 : struct GTY (()) ipa_jump_func
344 : {
345 : /* Aggregate jump function description. See struct ipa_agg_jump_function
346 : and its description. */
347 : struct ipa_agg_jump_function agg;
348 :
349 : /* Information about value range, containing valid data only when vr_known is
350 : true. The pointed to structure is shared between different jump
351 : functions. Use ipa_set_jfunc_vr to set this field. */
352 : ipa_vr *m_vr;
353 :
354 : enum jump_func_type type;
355 : /* Represents a value of a jump function. pass_through is used only in jump
356 : function context. constant represents the actual constant in constant jump
357 : functions and member_cst holds constant c++ member functions. */
358 : union jump_func_value
359 : {
360 : struct ipa_constant_data GTY ((tag ("IPA_JF_CONST"))) constant;
361 : struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
362 : struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
363 : } GTY ((desc ("%1.type"))) value;
364 : };
365 :
366 :
367 : /* Return the constant stored in a constant jump function JFUNC. */
368 :
369 : inline tree
370 5022443 : ipa_get_jf_constant (struct ipa_jump_func *jfunc)
371 : {
372 5022443 : gcc_checking_assert (jfunc->type == IPA_JF_CONST);
373 5022443 : return jfunc->value.constant.value;
374 : }
375 :
376 : inline struct ipa_cst_ref_desc *
377 1658145 : ipa_get_jf_constant_rdesc (struct ipa_jump_func *jfunc)
378 : {
379 1658145 : gcc_checking_assert (jfunc->type == IPA_JF_CONST);
380 1658145 : return jfunc->value.constant.rdesc;
381 : }
382 :
383 : /* Make JFUNC not participate in any further reference counting. */
384 :
385 : inline void
386 1719 : ipa_zap_jf_refdesc (ipa_jump_func *jfunc)
387 : {
388 1719 : gcc_checking_assert (jfunc->type == IPA_JF_CONST);
389 1719 : jfunc->value.constant.rdesc = NULL;
390 1719 : }
391 :
392 : /* Return the operand of a pass through jmp function JFUNC. */
393 :
394 : inline tree
395 120031 : ipa_get_jf_pass_through_operand (struct ipa_jump_func *jfunc)
396 : {
397 120031 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
398 120031 : return jfunc->value.pass_through.operand;
399 : }
400 :
401 : /* Return the type of the operation in a non-NOP pass through jmp function
402 : JFUNC. */
403 :
404 : inline tree
405 8540 : ipa_get_jf_pass_through_op_type (struct ipa_jump_func *jfunc)
406 : {
407 8540 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH
408 : && jfunc->value.pass_through.operation != NOP_EXPR);
409 :
410 8540 : return jfunc->value.pass_through.op_type;
411 : }
412 :
413 : /* Return the number of the caller's formal parameter that a pass through jump
414 : function JFUNC refers to. */
415 :
416 : inline int
417 6534236 : ipa_get_jf_pass_through_formal_id (struct ipa_jump_func *jfunc)
418 : {
419 6534236 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
420 6534236 : return jfunc->value.pass_through.formal_id;
421 : }
422 :
423 : /* Return operation of a pass through jump function JFUNC. */
424 :
425 : inline enum tree_code
426 2529839 : ipa_get_jf_pass_through_operation (struct ipa_jump_func *jfunc)
427 : {
428 2529839 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
429 2529839 : return jfunc->value.pass_through.operation;
430 : }
431 :
432 : /* Return the agg_preserved flag of a pass through jump function JFUNC. */
433 :
434 : inline bool
435 2402327 : ipa_get_jf_pass_through_agg_preserved (struct ipa_jump_func *jfunc)
436 : {
437 2402327 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
438 2402327 : return jfunc->value.pass_through.agg_preserved;
439 : }
440 :
441 : /* Return the refdesc_decremented flag of a pass through jump function
442 : JFUNC. */
443 :
444 : inline bool
445 509753 : ipa_get_jf_pass_through_refdesc_decremented (struct ipa_jump_func *jfunc)
446 : {
447 509753 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
448 509753 : return jfunc->value.pass_through.refdesc_decremented;
449 : }
450 :
451 : /* Set the refdesc_decremented flag of a pass through jump function JFUNC to
452 : VALUE. */
453 :
454 : inline void
455 21 : ipa_set_jf_pass_through_refdesc_decremented (ipa_jump_func *jfunc, bool value)
456 : {
457 21 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
458 21 : jfunc->value.pass_through.refdesc_decremented = value;
459 21 : }
460 :
461 : /* Return true if pass through jump function JFUNC preserves type
462 : information. */
463 :
464 : inline bool
465 353119 : ipa_get_jf_pass_through_type_preserved (struct ipa_jump_func *jfunc)
466 : {
467 353119 : gcc_checking_assert (jfunc->type == IPA_JF_PASS_THROUGH);
468 353119 : return jfunc->value.pass_through.agg_preserved;
469 : }
470 :
471 : /* Return the offset of an ancestor jump function JFUNC. */
472 :
473 : inline HOST_WIDE_INT
474 255847 : ipa_get_jf_ancestor_offset (struct ipa_jump_func *jfunc)
475 : {
476 255847 : gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
477 255847 : return jfunc->value.ancestor.offset;
478 : }
479 :
480 : /* Return the number of the caller's formal parameter that an ancestor jump
481 : function JFUNC refers to. */
482 :
483 : inline int
484 1248460 : ipa_get_jf_ancestor_formal_id (struct ipa_jump_func *jfunc)
485 : {
486 1248460 : gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
487 1248460 : return jfunc->value.ancestor.formal_id;
488 : }
489 :
490 : /* Return the agg_preserved flag of an ancestor jump function JFUNC. */
491 :
492 : inline bool
493 292227 : ipa_get_jf_ancestor_agg_preserved (struct ipa_jump_func *jfunc)
494 : {
495 292227 : gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
496 292227 : return jfunc->value.ancestor.agg_preserved;
497 : }
498 :
499 : /* Return true if ancestor jump function JFUNC presrves type information. */
500 :
501 : inline bool
502 59806 : ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
503 : {
504 59806 : gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
505 59806 : return jfunc->value.ancestor.agg_preserved;
506 : }
507 :
508 : /* Return if jfunc represents an operation whether we first check the formal
509 : parameter for non-NULLness unless it does not matter because the offset is
510 : zero anyway. */
511 :
512 : inline bool
513 28956 : ipa_get_jf_ancestor_keep_null (struct ipa_jump_func *jfunc)
514 : {
515 28956 : gcc_checking_assert (jfunc->type == IPA_JF_ANCESTOR);
516 28956 : return jfunc->value.ancestor.keep_null;
517 : }
518 :
519 : /* Class for allocating a bundle of various potentially known properties about
520 : actual arguments of a particular call on stack for the usual case and on
521 : heap only if there are unusually many arguments. The data is deallocated
522 : when the instance of this class goes out of scope or is otherwise
523 : destructed. */
524 :
525 23996643 : class ipa_auto_call_arg_values
526 : {
527 : public:
528 : /* If m_known_vals (vector of known "scalar" values) is sufficiently long,
529 : return its element at INDEX, otherwise return NULL. */
530 69912426 : tree safe_sval_at (int index)
531 : {
532 69912426 : if ((unsigned) index < m_known_vals.length ())
533 42776690 : return m_known_vals[index];
534 : return NULL;
535 : }
536 :
537 : /* Vector describing known values of parameters. */
538 : auto_vec<tree, 32> m_known_vals;
539 :
540 : /* Vector describing known polymorphic call contexts. */
541 : auto_vec<ipa_polymorphic_call_context, 32> m_known_contexts;
542 :
543 : /* Vector describing known aggregate values. */
544 : auto_vec<ipa_argagg_value, 32> m_known_aggs;
545 :
546 : /* Vector describing known value ranges of arguments. */
547 : auto_vec<value_range, 32> m_known_value_ranges;
548 : };
549 :
550 : inline
551 41895546 : ipa_argagg_value_list
552 : ::ipa_argagg_value_list (const ipa_auto_call_arg_values *aavals)
553 83791092 : : m_elts (aavals->m_known_aggs), m_known_vals (aavals->m_known_vals)
554 41895546 : {}
555 :
556 : /* Class bundling the various potentially known properties about actual
557 : arguments of a particular call. This variant does not deallocate the
558 : bundled data in any way as the vectors can either be pointing to vectors in
559 : ipa_auto_call_arg_values or be allocated independently. */
560 :
561 : class ipa_call_arg_values
562 : {
563 : public:
564 : /* Default constructor, setting the vectors to empty ones. */
565 1248448 : ipa_call_arg_values ()
566 0 : {}
567 :
568 : /* Construct this general variant of the bundle from the variant which uses
569 : auto_vecs to hold the vectors. This means that vectors of objects
570 : constructed with this constructor should not be changed because if they
571 : get reallocated, the member vectors and the underlying auto_vecs would get
572 : out of sync. */
573 19884287 : ipa_call_arg_values (ipa_auto_call_arg_values *aavals)
574 19884287 : : m_known_vals (aavals->m_known_vals.to_vec_legacy ()),
575 19884287 : m_known_contexts (aavals->m_known_contexts.to_vec_legacy ()),
576 19884287 : m_known_aggs (aavals->m_known_aggs.to_vec_legacy ()),
577 19884287 : m_known_value_ranges (aavals->m_known_value_ranges.to_vec_legacy ())
578 : {}
579 :
580 : /* If m_known_vals (vector of known "scalar" values) is sufficiently long,
581 : return its element at INDEX, otherwise return NULL. */
582 281561 : tree safe_sval_at (int index)
583 : {
584 281561 : if ((unsigned) index < m_known_vals.length ())
585 126878 : return m_known_vals[index];
586 : return NULL;
587 : }
588 :
589 : /* Vector describing known values of parameters. */
590 : vec<tree> m_known_vals = vNULL;
591 :
592 : /* Vector describing known polymorphic call contexts. */
593 : vec<ipa_polymorphic_call_context> m_known_contexts = vNULL;
594 :
595 : /* Vector describing known aggregate values. */
596 : vec<ipa_argagg_value> m_known_aggs = vNULL;
597 :
598 : /* Vector describing known value ranges of arguments. */
599 : vec<value_range> m_known_value_ranges = vNULL;
600 : };
601 :
602 : inline
603 3684874 : ipa_argagg_value_list
604 : ::ipa_argagg_value_list (const ipa_call_arg_values *gavals)
605 7369748 : : m_elts (gavals->m_known_aggs), m_known_vals (gavals->m_known_vals)
606 3684874 : {}
607 :
608 : /* Summary describing a single formal parameter. */
609 :
610 : struct GTY(()) ipa_param_descriptor
611 : {
612 : /* In analysis and modification phase, this is the PARAM_DECL of this
613 : parameter, in IPA LTO phase, this is the type of the described
614 : parameter or NULL if not known. Do not read this field directly but
615 : through ipa_get_param and ipa_get_type as appropriate. */
616 : tree decl_or_type;
617 : /* If all uses of the parameter are described by ipa-prop structures, this
618 : says how many there are. If any use could not be described by means of
619 : ipa-prop structures (which include flag dereferenced below), this is
620 : IPA_UNDESCRIBED_USE. */
621 : int controlled_uses;
622 : unsigned int move_cost : 27;
623 : /* The parameter is used. */
624 : unsigned used : 1;
625 : unsigned used_by_ipa_predicates : 1;
626 : unsigned used_by_indirect_call : 1;
627 : unsigned used_by_polymorphic_call : 1;
628 : /* Set to true when in addition to being used in call statements, the
629 : parameter has also been used for loads (but not for writes, does not
630 : escape, etc.). This allows us to identify parameters p which are only
631 : used as *p, and so when we propagate a constant to them, we can generate a
632 : LOAD and not ADDR reference to them. */
633 : unsigned load_dereferenced : 1;
634 : };
635 :
636 : /* ipa_node_params stores information related to formal parameters of functions
637 : and some other information for interprocedural passes that operate on
638 : parameters (such as ipa-cp). */
639 :
640 : class GTY((for_user)) ipa_node_params
641 : {
642 : public:
643 : /* Default constructor. */
644 : ipa_node_params ();
645 :
646 : /* Default destructor. */
647 : ~ipa_node_params ();
648 :
649 : /* Information about individual formal parameters that are gathered when
650 : summaries are generated. */
651 : vec<ipa_param_descriptor, va_gc> *descriptors;
652 : /* Pointer to an array of structures describing individual formal
653 : parameters. */
654 : vec<ipcp_param_lattices> GTY((skip)) lattices;
655 : /* Only for versioned nodes this field would not be NULL,
656 : it points to the node that IPA cp cloned from. */
657 : struct cgraph_node * GTY((skip)) ipcp_orig_node;
658 : /* If this node is an ipa-cp clone, these are the known constants that
659 : describe what it has been specialized for. */
660 : vec<tree> GTY((skip)) known_csts;
661 : /* If this node is an ipa-cp clone, these are the known polymorphic contexts
662 : that describe what it has been specialized for. */
663 : vec<ipa_polymorphic_call_context> GTY((skip)) known_contexts;
664 : /* Whether the param uses analysis and jump function computation has already
665 : been performed. */
666 : unsigned analysis_done : 1;
667 : /* Whether the function is enqueued in ipa-cp propagation stack. */
668 : unsigned node_enqueued : 1;
669 : /* Set if this is an IPA-CP clone for all contexts. */
670 : unsigned is_all_contexts_clone : 1;
671 : /* Node has been completely replaced by clones and will be removed after
672 : ipa-cp is finished. */
673 : unsigned node_dead : 1;
674 : /* Node is involved in a recursion, potentially indirect. */
675 : unsigned node_within_scc : 1;
676 : /* Node contains only direct recursion. */
677 : unsigned node_is_self_scc : 1;
678 : /* Node is calling a private function called only once. */
679 : unsigned node_calling_single_call : 1;
680 : /* False when there is something makes versioning impossible. */
681 : unsigned versionable : 1;
682 : };
683 :
684 : inline
685 7388191 : ipa_node_params::ipa_node_params ()
686 7388191 : : descriptors (NULL), lattices (vNULL), ipcp_orig_node (NULL),
687 7388191 : known_csts (vNULL), known_contexts (vNULL), analysis_done (0),
688 7388191 : node_enqueued (0), is_all_contexts_clone (0),
689 7388191 : node_dead (0), node_within_scc (0), node_is_self_scc (0),
690 7388191 : node_calling_single_call (0), versionable (0)
691 : {
692 : }
693 :
694 : inline
695 7388190 : ipa_node_params::~ipa_node_params ()
696 : {
697 7388190 : vec_free (descriptors);
698 7388190 : lattices.release ();
699 7388190 : known_csts.release ();
700 7388190 : known_contexts.release ();
701 7388190 : }
702 :
703 : /* Intermediate information that we get from alias analysis about a particular
704 : parameter in a particular basic_block. When a parameter or the memory it
705 : references is marked modified, we use that information in all dominated
706 : blocks without consulting alias analysis oracle. */
707 :
708 : struct ipa_param_aa_status
709 : {
710 : /* Set when this structure contains meaningful information. If not, the
711 : structure describing a dominating BB should be used instead. */
712 : bool valid;
713 :
714 : /* Whether we have seen something which might have modified the data in
715 : question. PARM is for the parameter itself, REF is for data it points to
716 : but using the alias type of individual accesses and PT is the same thing
717 : but for computing aggregate pass-through functions using a very inclusive
718 : ao_ref. */
719 : bool parm_modified, ref_modified, pt_modified;
720 : };
721 :
722 : /* Information related to a given BB that used only when looking at function
723 : body. */
724 :
725 : struct ipa_bb_info
726 : {
727 : /* Call graph edges going out of this BB. */
728 : vec<cgraph_edge *> cg_edges;
729 : /* Alias analysis statuses of each formal parameter at this bb. */
730 : vec<ipa_param_aa_status> param_aa_statuses;
731 : };
732 :
733 : /* Structure with global information that is only used when looking at function
734 : body. */
735 :
736 : struct ipa_func_body_info
737 : {
738 : /* The node that is being analyzed. */
739 : cgraph_node *node;
740 :
741 : /* Its info. */
742 : class ipa_node_params *info;
743 :
744 : /* Information about individual BBs. */
745 : vec<ipa_bb_info> bb_infos;
746 :
747 : /* Number of parameters. */
748 : int param_count;
749 :
750 : /* Number of statements we are still allowed to walked by when analyzing this
751 : function. */
752 : unsigned int aa_walk_budget;
753 : };
754 :
755 : /* ipa_node_params access functions. Please use these to access fields that
756 : are or will be shared among various passes. */
757 :
758 : /* Return the number of formal parameters. */
759 :
760 : inline int
761 83214589 : ipa_get_param_count (class ipa_node_params *info)
762 : {
763 161543832 : return vec_safe_length (info->descriptors);
764 : }
765 :
766 : /* Return the parameter declaration in DESCRIPTORS at index I and assert it is
767 : indeed a PARM_DECL. */
768 :
769 : inline tree
770 2556761 : ipa_get_param (const vec<ipa_param_descriptor, va_gc> &descriptors, int i)
771 : {
772 2556761 : tree t = descriptors[i].decl_or_type;
773 2556761 : gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
774 2556761 : return t;
775 : }
776 :
777 : /* Return the declaration of Ith formal parameter of the function corresponding
778 : to INFO. Note there is no setter function as this array is built just once
779 : using ipa_initialize_node_params. This function should not be called in
780 : WPA. */
781 :
782 : inline tree
783 2556761 : ipa_get_param (class ipa_node_params *info, int i)
784 : {
785 2556761 : gcc_checking_assert (info->descriptors);
786 2556761 : return ipa_get_param (*info->descriptors, i);
787 : }
788 :
789 : /* Return the type of Ith formal parameter of the function corresponding
790 : to INFO if it is known or NULL if not. */
791 :
792 : inline tree
793 26212577 : ipa_get_type (class ipa_node_params *info, int i)
794 : {
795 26212577 : if (vec_safe_length (info->descriptors) <= (unsigned) i)
796 : return NULL;
797 25969831 : tree t = (*info->descriptors)[i].decl_or_type;
798 25969831 : if (!t)
799 : return NULL;
800 25969831 : if (TYPE_P (t))
801 : return t;
802 24547530 : gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
803 24547530 : return TREE_TYPE (t);
804 : }
805 :
806 : /* Return the move cost of Ith formal parameter of the function corresponding
807 : to INFO. */
808 :
809 : inline int
810 349302 : ipa_get_param_move_cost (class ipa_node_params *info, int i)
811 : {
812 349302 : gcc_checking_assert (info->descriptors);
813 349302 : return (*info->descriptors)[i].move_cost;
814 : }
815 :
816 : /* Set the used flag corresponding to the Ith formal parameter of the function
817 : associated with INFO to VAL. */
818 :
819 : inline void
820 2590484 : ipa_set_param_used (class ipa_node_params *info, int i, bool val)
821 : {
822 2590484 : gcc_checking_assert (info->descriptors);
823 2590484 : (*info->descriptors)[i].used = val;
824 2590484 : }
825 :
826 : /* Set the used_by_ipa_predicates flag corresponding to the Ith formal
827 : parameter of the function associated with INFO to VAL. */
828 :
829 : inline void
830 11668622 : ipa_set_param_used_by_ipa_predicates (class ipa_node_params *info, int i, bool val)
831 : {
832 11668622 : gcc_checking_assert (info->descriptors);
833 11668622 : (*info->descriptors)[i].used_by_ipa_predicates = val;
834 11668622 : }
835 :
836 : /* Set the used_by_indirect_call flag corresponding to the Ith formal
837 : parameter of the function associated with INFO to VAL. */
838 :
839 : inline void
840 22240 : ipa_set_param_used_by_indirect_call (class ipa_node_params *info, int i, bool val)
841 : {
842 22240 : gcc_checking_assert (info->descriptors);
843 22240 : (*info->descriptors)[i].used_by_indirect_call = val;
844 22240 : }
845 :
846 : /* Set the .used_by_polymorphic_call flag corresponding to the Ith formal
847 : parameter of the function associated with INFO to VAL. */
848 :
849 : inline void
850 13603 : ipa_set_param_used_by_polymorphic_call (class ipa_node_params *info, int i, bool val)
851 : {
852 13603 : gcc_checking_assert (info->descriptors);
853 13603 : (*info->descriptors)[i].used_by_polymorphic_call = val;
854 13603 : }
855 :
856 : /* Return how many uses described by ipa-prop a parameter has or
857 : IPA_UNDESCRIBED_USE if there is a use that is not described by these
858 : structures. */
859 : inline int
860 1187831 : ipa_get_controlled_uses (class ipa_node_params *info, int i)
861 : {
862 : /* FIXME: introducing speculation causes out of bounds access here. */
863 1187831 : if (vec_safe_length (info->descriptors) > (unsigned)i)
864 1187813 : return (*info->descriptors)[i].controlled_uses;
865 : return IPA_UNDESCRIBED_USE;
866 : }
867 :
868 : /* Set the controlled counter of a given parameter. */
869 :
870 : inline void
871 2990121 : ipa_set_controlled_uses (class ipa_node_params *info, int i, int val)
872 : {
873 2990121 : gcc_checking_assert (info->descriptors);
874 2990121 : (*info->descriptors)[i].controlled_uses = val;
875 2990121 : }
876 :
877 : /* Assuming a parameter does not have IPA_UNDESCRIBED_USE controlled uses,
878 : return flag which indicates it has been dereferenced but only in a load. */
879 : inline int
880 207634 : ipa_get_param_load_dereferenced (class ipa_node_params *info, int i)
881 : {
882 207634 : gcc_assert (ipa_get_controlled_uses (info, i) != IPA_UNDESCRIBED_USE);
883 207634 : return (*info->descriptors)[i].load_dereferenced;
884 : }
885 :
886 : /* Set the load_dereferenced flag of a given parameter. */
887 :
888 : inline void
889 2732754 : ipa_set_param_load_dereferenced (class ipa_node_params *info, int i, bool val)
890 : {
891 2732754 : gcc_checking_assert (info->descriptors);
892 2732754 : (*info->descriptors)[i].load_dereferenced = val;
893 2732754 : }
894 :
895 : /* Return the used flag corresponding to the Ith formal parameter of the
896 : function associated with INFO. */
897 :
898 : inline bool
899 13839177 : ipa_is_param_used (class ipa_node_params *info, int i)
900 : {
901 13839177 : gcc_checking_assert (info->descriptors);
902 13839177 : return (*info->descriptors)[i].used;
903 : }
904 :
905 : /* Return the used_by_ipa_predicates flag corresponding to the Ith formal
906 : parameter of the function associated with INFO. */
907 :
908 : inline bool
909 47648215 : ipa_is_param_used_by_ipa_predicates (class ipa_node_params *info, int i)
910 : {
911 47648215 : gcc_checking_assert (info->descriptors);
912 47648215 : return (*info->descriptors)[i].used_by_ipa_predicates;
913 : }
914 :
915 : /* Return the used_by_indirect_call flag corresponding to the Ith formal
916 : parameter of the function associated with INFO. */
917 :
918 : inline bool
919 50165981 : ipa_is_param_used_by_indirect_call (class ipa_node_params *info, int i)
920 : {
921 50165981 : gcc_checking_assert (info->descriptors);
922 50165981 : return (*info->descriptors)[i].used_by_indirect_call;
923 : }
924 :
925 : /* Return the used_by_polymorphic_call flag corresponding to the Ith formal
926 : parameter of the function associated with INFO. */
927 :
928 : inline bool
929 40025751 : ipa_is_param_used_by_polymorphic_call (class ipa_node_params *info, int i)
930 : {
931 40025751 : gcc_checking_assert (info->descriptors);
932 40025751 : return (*info->descriptors)[i].used_by_polymorphic_call;
933 : }
934 :
935 : /* GTY-marked structure used to map DECL_UIDs of APRAMs to their indices in
936 : their DECL_ARGUMENTs chain. */
937 : struct GTY(()) ipa_uid_to_idx_map_elt
938 : {
939 : /* DECL_UID of the PARAM. */
940 : unsigned uid;
941 : /* Its index in the DECL_ARGUMETs chain. */
942 : unsigned index;
943 : };
944 :
945 : /* Structure holding information for the transformation phase of IPA-CP. */
946 :
947 : struct GTY(()) ipcp_transformation
948 : {
949 : /* Default constructor. */
950 123921 : ipcp_transformation ()
951 123921 : : m_agg_values (nullptr), m_vr (nullptr), m_uid_to_idx (nullptr)
952 : { }
953 :
954 : /* Default destructor. */
955 123901 : ~ipcp_transformation ()
956 : {
957 123901 : vec_free (m_agg_values);
958 123901 : vec_free (m_vr);
959 123901 : }
960 :
961 : /* Given PARAM which must be a parameter of function FNDECL described by
962 : THIS, return its index in the DECL_ARGUMENTS chain, using a pre-computed
963 : DECL_UID-sorted vector if available (which is pre-computed only if there
964 : are many parameters). Can return -1 if param is static chain not
965 : represented among DECL_ARGUMENTS. */
966 :
967 : int get_param_index (const_tree fndecl, const_tree param) const;
968 :
969 : /* Assuming THIS describes FNDECL and it has sufficiently many parameters to
970 : justify the overhead, create a DECL_UID-sorted vector to speed up mapping
971 : from parameters to their indices in DECL_ARGUMENTS chain. */
972 :
973 : void maybe_create_parm_idx_map (tree fndecl);
974 :
975 : /* Remove all elements in m_agg_values on which PREDICATE returns true. */
976 :
977 : template<typename pred_function>
978 9938 : void remove_argaggs_if (pred_function &&predicate)
979 : {
980 9938 : unsigned ts_len = vec_safe_length (m_agg_values);
981 4395 : if (ts_len == 0)
982 : return;
983 :
984 : bool removed_item = false;
985 : unsigned dst_index = 0;
986 :
987 26014 : for (unsigned i = 0; i < ts_len; i++)
988 : {
989 21619 : ipa_argagg_value *v = &(*m_agg_values)[i];
990 21619 : if (!predicate (*v))
991 : {
992 21473 : if (removed_item)
993 82 : (*m_agg_values)[dst_index] = *v;
994 21473 : dst_index++;
995 : }
996 : else
997 : removed_item = true;
998 : }
999 4395 : if (dst_index == 0)
1000 : {
1001 38 : ggc_free (m_agg_values);
1002 38 : m_agg_values = NULL;
1003 : }
1004 4357 : else if (removed_item)
1005 26 : m_agg_values->truncate (dst_index);
1006 : }
1007 :
1008 : /* Known aggregate values. */
1009 : vec<ipa_argagg_value, va_gc> *m_agg_values;
1010 : /* Value range information. */
1011 : vec<ipa_vr, va_gc> *m_vr;
1012 : /* If there are many parameters, this is a vector sorted by their DECL_UIDs
1013 : to map them to their indices in the DECL_ARGUMENT chain. */
1014 : vec<ipa_uid_to_idx_map_elt, va_gc> *m_uid_to_idx;
1015 : };
1016 :
1017 : inline
1018 73621 : ipa_argagg_value_list::ipa_argagg_value_list (const ipcp_transformation *tinfo)
1019 147242 : : m_elts (tinfo->m_agg_values)
1020 : {}
1021 :
1022 : void ipa_set_node_agg_value_chain (struct cgraph_node *node,
1023 : vec<ipa_argagg_value, va_gc> *aggs);
1024 : void ipcp_transformation_initialize (void);
1025 : void ipcp_free_transformation_sum (void);
1026 :
1027 : /* ipa_edge_args stores information related to a callsite and particularly its
1028 : arguments. It can be accessed by the IPA_EDGE_REF macro. */
1029 :
1030 : class GTY((for_user)) ipa_edge_args
1031 : {
1032 : public:
1033 :
1034 : /* Default constructor. */
1035 4672326 : ipa_edge_args () : jump_functions (NULL), polymorphic_call_contexts (NULL)
1036 : {}
1037 :
1038 : /* Destructor. */
1039 4672326 : ~ipa_edge_args ()
1040 : {
1041 4672326 : unsigned int i;
1042 4672326 : ipa_jump_func *jf;
1043 14704470 : FOR_EACH_VEC_SAFE_ELT (jump_functions, i, jf)
1044 10519368 : vec_free (jf->agg.items);
1045 4672326 : vec_free (jump_functions);
1046 4672326 : vec_free (polymorphic_call_contexts);
1047 4672326 : }
1048 :
1049 : /* Vectors of the callsite's jump function and polymorphic context
1050 : information of each parameter. */
1051 : vec<ipa_jump_func, va_gc> *jump_functions;
1052 : vec<ipa_polymorphic_call_context, va_gc> *polymorphic_call_contexts;
1053 : };
1054 :
1055 : /* ipa_edge_args access functions. Please use these to access fields that
1056 : are or will be shared among various passes. */
1057 :
1058 : /* Return the number of actual arguments. */
1059 :
1060 : inline int
1061 27084939 : ipa_get_cs_argument_count (class ipa_edge_args *args)
1062 : {
1063 52845706 : return vec_safe_length (args->jump_functions);
1064 : }
1065 :
1066 : /* Returns a pointer to the jump function for the ith argument. Please note
1067 : there is no setter function as jump functions are all set up in
1068 : ipa_compute_jump_functions. */
1069 :
1070 : inline struct ipa_jump_func *
1071 56287920 : ipa_get_ith_jump_func (class ipa_edge_args *args, int i)
1072 : {
1073 53233955 : return &(*args->jump_functions)[i];
1074 : }
1075 :
1076 : /* Returns a pointer to the polymorphic call context for the ith argument.
1077 : NULL if contexts are not computed. */
1078 : inline class ipa_polymorphic_call_context *
1079 9296254 : ipa_get_ith_polymorhic_call_context (class ipa_edge_args *args, int i)
1080 : {
1081 9292421 : if (!args->polymorphic_call_contexts)
1082 : return NULL;
1083 4334397 : return &(*args->polymorphic_call_contexts)[i];
1084 : }
1085 :
1086 : /* Function summary for ipa_node_params. */
1087 : class GTY((user)) ipa_node_params_t: public function_summary <ipa_node_params *>
1088 : {
1089 : public:
1090 5363490 : ipa_node_params_t (symbol_table *table, bool ggc):
1091 5363490 : function_summary<ipa_node_params *> (table, ggc)
1092 : {
1093 5363490 : disable_insertion_hook ();
1094 5363490 : }
1095 :
1096 : /* Hook that is called by summary when a node is duplicated. */
1097 : void duplicate (cgraph_node *node,
1098 : cgraph_node *node2,
1099 : ipa_node_params *data,
1100 : ipa_node_params *data2) final override;
1101 : };
1102 :
1103 : /* Summary to manage ipa_edge_args structures. */
1104 :
1105 : class GTY((user)) ipa_edge_args_sum_t : public call_summary <ipa_edge_args *>
1106 : {
1107 : public:
1108 256903 : ipa_edge_args_sum_t (symbol_table *table, bool ggc)
1109 256903 : : call_summary<ipa_edge_args *> (table, ggc) { }
1110 :
1111 908552 : void remove (cgraph_edge *edge)
1112 : {
1113 908552 : call_summary <ipa_edge_args *>::remove (edge);
1114 : }
1115 :
1116 : /* Hook that is called by summary when an edge is removed. */
1117 : void remove (cgraph_edge *cs, ipa_edge_args *args) final override;
1118 : /* Hook that is called by summary when an edge is duplicated. */
1119 : void duplicate (cgraph_edge *src,
1120 : cgraph_edge *dst,
1121 : ipa_edge_args *old_args,
1122 : ipa_edge_args *new_args) final override;
1123 : };
1124 :
1125 : /* Function summary where the parameter infos are actually stored. */
1126 : extern GTY(()) ipa_node_params_t * ipa_node_params_sum;
1127 : /* Call summary to store information about edges such as jump functions. */
1128 : extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum;
1129 :
1130 : /* Function summary for IPA-CP transformation. */
1131 : class ipcp_transformation_t
1132 : : public function_summary<ipcp_transformation *>
1133 : {
1134 : public:
1135 18574 : ipcp_transformation_t (symbol_table *table, bool ggc):
1136 37148 : function_summary<ipcp_transformation *> (table, ggc) {}
1137 :
1138 18565 : ~ipcp_transformation_t () {}
1139 :
1140 18574 : static ipcp_transformation_t *create_ggc (symbol_table *symtab)
1141 : {
1142 18574 : ipcp_transformation_t *summary
1143 18574 : = new (ggc_alloc_no_dtor <ipcp_transformation_t> ())
1144 18574 : ipcp_transformation_t (symtab, true);
1145 18574 : return summary;
1146 : }
1147 : /* Hook that is called by summary when a node is duplicated. */
1148 : void duplicate (cgraph_node *node,
1149 : cgraph_node *node2,
1150 : ipcp_transformation *data,
1151 : ipcp_transformation *data2) final override;
1152 : };
1153 :
1154 : /* Function summary where the IPA CP transformations are actually stored. */
1155 : extern GTY(()) function_summary <ipcp_transformation *> *ipcp_transformation_sum;
1156 :
1157 : /* Creating and freeing ipa_node_params and ipa_edge_args. */
1158 : void ipa_create_all_node_params (void);
1159 : void ipa_create_all_edge_args (void);
1160 : void ipa_check_create_edge_args (void);
1161 : void ipa_free_all_node_params (void);
1162 : void ipa_free_all_edge_args (void);
1163 : void ipa_free_all_structures_after_ipa_cp (void);
1164 : void ipa_free_all_structures_after_iinln (void);
1165 :
1166 : void ipa_register_cgraph_hooks (void);
1167 : int count_formal_params (tree fndecl);
1168 :
1169 : /* This function ensures the array of node param infos is big enough to
1170 : accommodate a structure for all nodes and reallocates it if not. */
1171 :
1172 : inline void
1173 8410304 : ipa_check_create_node_params (void)
1174 : {
1175 8410304 : if (!ipa_node_params_sum)
1176 5363490 : ipa_node_params_sum
1177 10726980 : = (new (ggc_alloc_no_dtor <ipa_node_params_t> ())
1178 5363490 : ipa_node_params_t (symtab, true));
1179 8410304 : }
1180 :
1181 : /* Returns true if edge summary contains a record for EDGE. The main purpose
1182 : of this function is that debug dumping function can check info availability
1183 : without causing allocations. */
1184 :
1185 : inline bool
1186 1426 : ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
1187 : {
1188 1426 : return ipa_edge_args_sum->exists (edge);
1189 : }
1190 :
1191 : inline ipcp_transformation *
1192 19091313 : ipcp_get_transformation_summary (cgraph_node *node)
1193 : {
1194 19091313 : if (ipcp_transformation_sum == NULL)
1195 : return NULL;
1196 :
1197 6387766 : return ipcp_transformation_sum->get (node);
1198 : }
1199 :
1200 : /* Function formal parameters related computations. */
1201 : void ipa_initialize_node_params (struct cgraph_node *node);
1202 : void ipa_print_constant_value (FILE *f, tree val);
1203 : bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
1204 : vec<cgraph_edge *> *new_edges);
1205 :
1206 : /* Indirect edge processing and target discovery. */
1207 : tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
1208 : ipa_call_arg_values *avals,
1209 : bool *speculative);
1210 : struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
1211 : bool speculative = false);
1212 : tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
1213 :
1214 :
1215 : /* Functions related to both. */
1216 : void ipa_analyze_node (struct cgraph_node *);
1217 : void ipa_analyze_var_static_initializer (varpool_node *node);
1218 :
1219 : /* Aggregate jump function related functions. */
1220 : tree ipa_find_agg_cst_from_init (tree scalar, HOST_WIDE_INT offset,
1221 : bool by_ref, tree type = NULL);
1222 : bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
1223 : vec<ipa_param_descriptor, va_gc> *descriptors,
1224 : gimple *stmt, tree op, int *index_p,
1225 : HOST_WIDE_INT *offset_p, poly_int64 *size_p,
1226 : bool *by_ref, bool *guaranteed_unmodified = NULL,
1227 : bool *unknown_offset_p = NULL);
1228 :
1229 : /* Debugging interface. */
1230 : void ipa_print_node_params (FILE *, struct cgraph_node *node);
1231 : void ipa_print_all_params (FILE *);
1232 : void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
1233 : void ipa_print_all_jump_functions (FILE * f);
1234 : void ipcp_verify_propagated_values (void);
1235 :
1236 : template <typename value>
1237 : class ipcp_value;
1238 :
1239 : extern object_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
1240 : extern object_allocator<ipcp_value<ipa_polymorphic_call_context> >
1241 : ipcp_poly_ctx_values_pool;
1242 :
1243 : template <typename valtype>
1244 : struct ipcp_value_source;
1245 :
1246 : extern object_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
1247 :
1248 : struct ipcp_agg_lattice;
1249 :
1250 : extern object_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
1251 :
1252 : void ipa_prop_write_jump_functions (void);
1253 : void ipa_prop_read_jump_functions (void);
1254 : void ipcp_write_transformation_summaries (void);
1255 : void ipcp_read_transformation_summaries (void);
1256 : int ipa_get_param_decl_index (class ipa_node_params *, tree);
1257 : tree ipa_value_from_jfunc (class ipa_node_params *info,
1258 : struct ipa_jump_func *jfunc, tree type);
1259 : tree ipa_agg_value_from_jfunc (ipa_node_params *info, cgraph_node *node,
1260 : const ipa_agg_jf_item *item);
1261 : unsigned int ipcp_transform_function (struct cgraph_node *node);
1262 : ipa_polymorphic_call_context ipa_context_from_jfunc (ipa_node_params *,
1263 : cgraph_edge *,
1264 : int,
1265 : ipa_jump_func *);
1266 : void ipa_value_range_from_jfunc (vrange &, ipa_node_params *, cgraph_edge *,
1267 : ipa_jump_func *, tree);
1268 : void ipa_push_agg_values_from_jfunc (ipa_node_params *info, cgraph_node *node,
1269 : ipa_agg_jump_function *agg_jfunc,
1270 : unsigned dst_index,
1271 : vec<ipa_argagg_value> *res);
1272 : void ipa_dump_param (FILE *, class ipa_node_params *info, int i);
1273 : void ipa_dump_jump_function (FILE *f, ipa_jump_func *jfunc,
1274 : class ipa_polymorphic_call_context *ctx = NULL);
1275 : void ipa_dump_noted_record_fnptrs (FILE *f);
1276 : void ipa_debug_noted_record_fnptrs (void);
1277 : void ipa_release_body_info (struct ipa_func_body_info *);
1278 : tree ipa_get_callee_param_type (struct cgraph_edge *e, int i);
1279 : bool ipcp_get_parm_bits (tree, tree *, widest_int *);
1280 : tree ipcp_get_aggregate_const (struct function *func, tree parm, bool by_ref,
1281 : HOST_WIDE_INT bit_offset,
1282 : HOST_WIDE_INT bit_size);
1283 : bool unadjusted_ptr_and_unit_offset (tree op, tree *ret,
1284 : poly_int64 *offset_ret);
1285 : void ipa_get_range_from_ip_invariant (vrange &r, tree val, cgraph_node *node);
1286 : tree ipa_single_noted_fnptr_in_record (tree rectype, unsigned offset);
1287 : void ipa_prop_cc_finalize (void);
1288 : void ipa_free_noted_fnptr_calls ();
1289 :
1290 : /* In ipa-cp.cc */
1291 : void ipa_cp_cc_finalize (void);
1292 : bool ipa_return_value_range (value_range &range, tree decl);
1293 : void ipa_record_return_value_range (value_range val);
1294 : bool ipa_jump_functions_equivalent_p (ipa_jump_func *jf1, ipa_jump_func *jf2);
1295 : tree ipa_get_jf_arith_result (enum tree_code, tree, tree, tree);
1296 : tree ipa_get_jf_ancestor_result (struct ipa_jump_func *, tree);
1297 :
1298 :
1299 : #endif /* IPA_PROP_H */
|