1 /* Interprocedural constant propagation
2 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Contributed by Razya Ladelsky <RAZYA@il.ibm.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* Interprocedural constant propagation. The aim of interprocedural constant
23 propagation (IPCP) is to find which function's argument has the same
24 constant value in each invocation throughout the whole program. For example,
25 consider the following program:
29 printf ("value is %d",y);
49 The IPCP algorithm will find that g's formal argument y is always called
52 The algorithm used is based on "Interprocedural Constant Propagation", by
53 Challahan David, Keith D Cooper, Ken Kennedy, Linda Torczon, Comp86, pg
56 The optimization is divided into three stages:
58 First stage - intraprocedural analysis
59 =======================================
60 This phase computes jump_function and modification flags.
62 A jump function for a callsite represents the values passed as an actual
63 arguments of a given callsite. There are three types of values:
64 Pass through - the caller's formal parameter is passed as an actual argument.
65 Constant - a constant is passed as an actual argument.
66 Unknown - neither of the above.
68 The jump function info, ipa_jump_func, is stored in ipa_edge_args
69 structure (defined in ipa_prop.h and pointed to by cgraph_node->aux)
70 modified_flags are defined in ipa_node_params structure
71 (defined in ipa_prop.h and pointed to by cgraph_edge->aux).
73 -ipcp_generate_summary() is the first stage driver.
75 Second stage - interprocedural analysis
76 ========================================
77 This phase does the interprocedural constant propagation.
78 It computes lattices for all formal parameters in the program
79 and their value that may be:
81 BOTTOM - non constant.
82 CONSTANT - constant value.
84 Lattice describing a formal parameter p will have a constant value if all
85 callsites invoking this function have the same constant value passed to p.
87 The lattices are stored in ipcp_lattice which is itself in ipa_node_params
88 structure (defined in ipa_prop.h and pointed to by cgraph_edge->aux).
90 -ipcp_iterate_stage() is the second stage driver.
92 Third phase - transformation of function code
93 ============================================
94 Propagates the constant-valued formals into the function.
95 For each function whose parameters are constants, we create its clone.
97 Then we process the clone in two ways:
98 1. We insert an assignment statement 'parameter = const' at the beginning
99 of the cloned function.
100 2. For read-only parameters that do not live in memory, we replace all their
101 uses with the constant.
103 We also need to modify some callsites to call the cloned functions instead
104 of the original ones. For a callsite passing an argument found to be a
105 constant by IPCP, there are two different cases to handle:
106 1. A constant is passed as an argument. In this case the callsite in the
107 should be redirected to call the cloned callee.
108 2. A parameter (of the caller) passed as an argument (pass through
109 argument). In such cases both the caller and the callee have clones and
110 only the callsite in the cloned caller is redirected to call to the
113 This update is done in two steps: First all cloned functions are created
114 during a traversal of the call graph, during which all callsites are
115 redirected to call the cloned function. Then the callsites are traversed
116 and many calls redirected back to fit the description above.
118 -ipcp_insert_stage() is the third phase driver.
121 This pass also performs devirtualization - turns virtual calls into direct
122 ones if it can prove that all invocations of the function call the same
123 callee. This is achieved by building a list of all base types (actually,
124 their BINFOs) that individual parameters can have in an iterative matter
125 just like propagating scalar constants and then examining whether virtual
126 calls which take a parameter as their object fold to the same target for all
127 these types. If we cannot enumerate all types or there is a type which does
128 not have any BINFO associated with it, cannot_devirtualize of the associated
129 parameter descriptor is set which is an equivalent of BOTTOM lattice value
130 in standard IPA constant propagation.
135 #include "coretypes.h"
140 #include "ipa-prop.h"
141 #include "tree-flow.h"
142 #include "tree-pass.h"
145 #include "diagnostic.h"
146 #include "tree-pretty-print.h"
147 #include "tree-dump.h"
148 #include "tree-inline.h"
152 /* Number of functions identified as candidates for cloning. When not cloning
153 we can simplify iterate stage not forcing it to go through the decision
154 on what is profitable and what not. */
155 static int n_cloning_candidates
;
157 /* Maximal count found in program. */
158 static gcov_type max_count
;
160 /* Cgraph nodes that has been completely replaced by cloning during iterate
161 * stage and will be removed after ipcp is finished. */
162 static bitmap dead_nodes
;
164 static void ipcp_print_profile_data (FILE *);
165 static void ipcp_function_scale_print (FILE *);
167 /* Get the original node field of ipa_node_params associated with node NODE. */
168 static inline struct cgraph_node
*
169 ipcp_get_orig_node (struct cgraph_node
*node
)
171 return IPA_NODE_REF (node
)->ipcp_orig_node
;
174 /* Return true if NODE describes a cloned/versioned function. */
176 ipcp_node_is_clone (struct cgraph_node
*node
)
178 return (ipcp_get_orig_node (node
) != NULL
);
181 /* Create ipa_node_params and its data structures for NEW_NODE. Set ORIG_NODE
182 as the ipcp_orig_node field in ipa_node_params. */
184 ipcp_init_cloned_node (struct cgraph_node
*orig_node
,
185 struct cgraph_node
*new_node
)
187 gcc_checking_assert (ipa_node_params_vector
188 && (VEC_length (ipa_node_params_t
,
189 ipa_node_params_vector
)
190 > (unsigned) cgraph_max_uid
));
191 gcc_checking_assert (IPA_NODE_REF (new_node
)->params
);
192 IPA_NODE_REF (new_node
)->ipcp_orig_node
= orig_node
;
195 /* Return scale for NODE. */
196 static inline gcov_type
197 ipcp_get_node_scale (struct cgraph_node
*node
)
199 return IPA_NODE_REF (node
)->count_scale
;
202 /* Set COUNT as scale for NODE. */
204 ipcp_set_node_scale (struct cgraph_node
*node
, gcov_type count
)
206 IPA_NODE_REF (node
)->count_scale
= count
;
209 /* Return whether LAT is a constant lattice. */
211 ipcp_lat_is_const (struct ipcp_lattice
*lat
)
213 if (lat
->type
== IPA_CONST_VALUE
)
219 /* Return whether LAT is a constant lattice that ipa-cp can actually insert
220 into the code (i.e. constants excluding member pointers and pointers). */
222 ipcp_lat_is_insertable (struct ipcp_lattice
*lat
)
224 return lat
->type
== IPA_CONST_VALUE
;
227 /* Return true if LAT1 and LAT2 are equal. */
229 ipcp_lats_are_equal (struct ipcp_lattice
*lat1
, struct ipcp_lattice
*lat2
)
231 gcc_assert (ipcp_lat_is_const (lat1
) && ipcp_lat_is_const (lat2
));
232 if (lat1
->type
!= lat2
->type
)
235 if (TREE_CODE (lat1
->constant
) == ADDR_EXPR
236 && TREE_CODE (lat2
->constant
) == ADDR_EXPR
237 && TREE_CODE (TREE_OPERAND (lat1
->constant
, 0)) == CONST_DECL
238 && TREE_CODE (TREE_OPERAND (lat2
->constant
, 0)) == CONST_DECL
)
239 return operand_equal_p (DECL_INITIAL (TREE_OPERAND (lat1
->constant
, 0)),
240 DECL_INITIAL (TREE_OPERAND (lat2
->constant
, 0)), 0);
242 return operand_equal_p (lat1
->constant
, lat2
->constant
, 0);
245 /* Compute Meet arithmetics:
246 Meet (IPA_BOTTOM, x) = IPA_BOTTOM
248 Meet (const_a,const_b) = IPA_BOTTOM, if const_a != const_b.
249 MEET (const_a,const_b) = const_a, if const_a == const_b.*/
251 ipa_lattice_meet (struct ipcp_lattice
*res
, struct ipcp_lattice
*lat1
,
252 struct ipcp_lattice
*lat2
)
254 if (lat1
->type
== IPA_BOTTOM
|| lat2
->type
== IPA_BOTTOM
)
256 res
->type
= IPA_BOTTOM
;
259 if (lat1
->type
== IPA_TOP
)
261 res
->type
= lat2
->type
;
262 res
->constant
= lat2
->constant
;
265 if (lat2
->type
== IPA_TOP
)
267 res
->type
= lat1
->type
;
268 res
->constant
= lat1
->constant
;
271 if (!ipcp_lats_are_equal (lat1
, lat2
))
273 res
->type
= IPA_BOTTOM
;
276 res
->type
= lat1
->type
;
277 res
->constant
= lat1
->constant
;
280 /* Return the lattice corresponding to the Ith formal parameter of the function
281 described by INFO. */
282 static inline struct ipcp_lattice
*
283 ipcp_get_lattice (struct ipa_node_params
*info
, int i
)
285 return &(info
->params
[i
].ipcp_lattice
);
288 /* Given the jump function JFUNC, compute the lattice LAT that describes the
289 value coming down the callsite. INFO describes the caller node so that
290 pass-through jump functions can be evaluated. */
292 ipcp_lattice_from_jfunc (struct ipa_node_params
*info
, struct ipcp_lattice
*lat
,
293 struct ipa_jump_func
*jfunc
)
295 if (jfunc
->type
== IPA_JF_CONST
)
297 lat
->type
= IPA_CONST_VALUE
;
298 lat
->constant
= jfunc
->value
.constant
;
300 else if (jfunc
->type
== IPA_JF_PASS_THROUGH
)
302 struct ipcp_lattice
*caller_lat
;
305 caller_lat
= ipcp_get_lattice (info
, jfunc
->value
.pass_through
.formal_id
);
306 lat
->type
= caller_lat
->type
;
307 if (caller_lat
->type
!= IPA_CONST_VALUE
)
309 cst
= caller_lat
->constant
;
311 if (jfunc
->value
.pass_through
.operation
!= NOP_EXPR
)
314 if (TREE_CODE_CLASS (jfunc
->value
.pass_through
.operation
)
316 restype
= boolean_type_node
;
318 restype
= TREE_TYPE (cst
);
319 cst
= fold_binary (jfunc
->value
.pass_through
.operation
,
320 restype
, cst
, jfunc
->value
.pass_through
.operand
);
322 if (!cst
|| !is_gimple_ip_invariant (cst
))
323 lat
->type
= IPA_BOTTOM
;
326 else if (jfunc
->type
== IPA_JF_ANCESTOR
)
328 struct ipcp_lattice
*caller_lat
;
331 caller_lat
= ipcp_get_lattice (info
, jfunc
->value
.ancestor
.formal_id
);
332 lat
->type
= caller_lat
->type
;
333 if (caller_lat
->type
!= IPA_CONST_VALUE
)
335 if (TREE_CODE (caller_lat
->constant
) != ADDR_EXPR
)
337 /* This can happen when the constant is a NULL pointer. */
338 lat
->type
= IPA_BOTTOM
;
341 t
= TREE_OPERAND (caller_lat
->constant
, 0);
342 t
= build_ref_for_offset (EXPR_LOCATION (t
), t
,
343 jfunc
->value
.ancestor
.offset
,
344 jfunc
->value
.ancestor
.type
, NULL
, false);
345 lat
->constant
= build_fold_addr_expr (t
);
348 lat
->type
= IPA_BOTTOM
;
351 /* True when OLD_LAT and NEW_LAT values are not the same. */
354 ipcp_lattice_changed (struct ipcp_lattice
*old_lat
,
355 struct ipcp_lattice
*new_lat
)
357 if (old_lat
->type
== new_lat
->type
)
359 if (!ipcp_lat_is_const (old_lat
))
361 if (ipcp_lats_are_equal (old_lat
, new_lat
))
367 /* Print all ipcp_lattices of all functions to F. */
369 ipcp_print_all_lattices (FILE * f
)
371 struct cgraph_node
*node
;
374 fprintf (f
, "\nLattice:\n");
375 for (node
= cgraph_nodes
; node
; node
= node
->next
)
377 struct ipa_node_params
*info
;
381 info
= IPA_NODE_REF (node
);
382 fprintf (f
, " Node: %s:\n", cgraph_node_name (node
));
383 count
= ipa_get_param_count (info
);
384 for (i
= 0; i
< count
; i
++)
386 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
388 fprintf (f
, " param [%d]: ", i
);
389 if (lat
->type
== IPA_CONST_VALUE
)
391 tree cst
= lat
->constant
;
392 fprintf (f
, "type is CONST ");
393 print_generic_expr (f
, cst
, 0);
394 if (TREE_CODE (cst
) == ADDR_EXPR
395 && TREE_CODE (TREE_OPERAND (cst
, 0)) == CONST_DECL
)
398 print_generic_expr (f
, DECL_INITIAL (TREE_OPERAND (cst
, 0)),
402 else if (lat
->type
== IPA_TOP
)
403 fprintf (f
, "type is TOP");
405 fprintf (f
, "type is BOTTOM");
406 if (ipa_param_cannot_devirtualize_p (info
, i
))
407 fprintf (f
, " - cannot_devirtualize set\n");
408 else if (ipa_param_types_vec_empty (info
, i
))
409 fprintf (f
, " - type list empty\n");
416 /* Return true if ipcp algorithms would allow cloning NODE. */
419 ipcp_versionable_function_p (struct cgraph_node
*node
)
421 struct cgraph_edge
*edge
;
423 /* There are a number of generic reasons functions cannot be versioned. We
424 also cannot remove parameters if there are type attributes such as fnspec
426 if (!node
->local
.versionable
427 || TYPE_ATTRIBUTES (TREE_TYPE (node
->decl
)))
430 /* Removing arguments doesn't work if the function takes varargs
431 or use __builtin_apply_args. */
432 for (edge
= node
->callees
; edge
; edge
= edge
->next_callee
)
434 tree t
= edge
->callee
->decl
;
435 if (DECL_BUILT_IN_CLASS (t
) == BUILT_IN_NORMAL
436 && (DECL_FUNCTION_CODE (t
) == BUILT_IN_APPLY_ARGS
437 || DECL_FUNCTION_CODE (t
) == BUILT_IN_VA_START
))
444 /* Return true if this NODE is viable candidate for cloning. */
446 ipcp_cloning_candidate_p (struct cgraph_node
*node
)
450 gcov_type direct_call_sum
= 0;
451 struct cgraph_edge
*e
;
453 /* We never clone functions that are not visible from outside.
454 FIXME: in future we should clone such functions when they are called with
455 different constants, but current ipcp implementation is not good on this.
457 if (cgraph_only_called_directly_p (node
) || !node
->analyzed
)
460 /* When function address is taken, we are pretty sure it will be called in hidden way. */
461 if (node
->address_taken
)
464 fprintf (dump_file
, "Not considering %s for cloning; address is taken.\n",
465 cgraph_node_name (node
));
469 if (cgraph_function_body_availability (node
) <= AVAIL_OVERWRITABLE
)
472 fprintf (dump_file
, "Not considering %s for cloning; body is overwrittable.\n",
473 cgraph_node_name (node
));
476 if (!ipcp_versionable_function_p (node
))
479 fprintf (dump_file
, "Not considering %s for cloning; body is not versionable.\n",
480 cgraph_node_name (node
));
483 for (e
= node
->callers
; e
; e
= e
->next_caller
)
485 direct_call_sum
+= e
->count
;
487 if (cgraph_maybe_hot_edge_p (e
))
494 fprintf (dump_file
, "Not considering %s for cloning; no direct calls.\n",
495 cgraph_node_name (node
));
498 if (node
->local
.inline_summary
.self_size
< n_calls
)
501 fprintf (dump_file
, "Considering %s for cloning; code would shrink.\n",
502 cgraph_node_name (node
));
506 if (!flag_ipa_cp_clone
)
509 fprintf (dump_file
, "Not considering %s for cloning; -fipa-cp-clone disabled.\n",
510 cgraph_node_name (node
));
514 if (!optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node
->decl
)))
517 fprintf (dump_file
, "Not considering %s for cloning; optimizing it for size.\n",
518 cgraph_node_name (node
));
522 /* When profile is available and function is hot, propagate into it even if
523 calls seems cold; constant propagation can improve function's speed
527 if (direct_call_sum
> node
->count
* 90 / 100)
530 fprintf (dump_file
, "Considering %s for cloning; usually called directly.\n",
531 cgraph_node_name (node
));
538 fprintf (dump_file
, "Not considering %s for cloning; no hot calls.\n",
539 cgraph_node_name (node
));
543 fprintf (dump_file
, "Considering %s for cloning.\n",
544 cgraph_node_name (node
));
548 /* Mark parameter with index I of function described by INFO as unsuitable for
549 devirtualization. Return true if it has already been marked so. */
552 ipa_set_param_cannot_devirtualize (struct ipa_node_params
*info
, int i
)
554 bool ret
= info
->params
[i
].cannot_devirtualize
;
555 info
->params
[i
].cannot_devirtualize
= true;
556 if (info
->params
[i
].types
)
557 VEC_free (tree
, heap
, info
->params
[i
].types
);
561 /* Initialize ipcp_lattices array. The lattices corresponding to supported
562 types (integers, real types and Fortran constants defined as const_decls)
563 are initialized to IPA_TOP, the rest of them to IPA_BOTTOM. */
565 ipcp_initialize_node_lattices (struct cgraph_node
*node
)
568 struct ipa_node_params
*info
= IPA_NODE_REF (node
);
569 enum ipa_lattice_type type
;
571 if (ipa_is_called_with_var_arguments (info
))
573 else if (node
->local
.local
)
575 /* When cloning is allowed, we can assume that externally visible functions
576 are not called. We will compensate this by cloning later. */
577 else if (ipcp_cloning_candidate_p (node
))
578 type
= IPA_TOP
, n_cloning_candidates
++;
582 for (i
= 0; i
< ipa_get_param_count (info
) ; i
++)
584 ipcp_get_lattice (info
, i
)->type
= type
;
585 if (type
== IPA_BOTTOM
)
586 ipa_set_param_cannot_devirtualize (info
, i
);
590 /* build INTEGER_CST tree with type TREE_TYPE and value according to LAT.
593 build_const_val (struct ipcp_lattice
*lat
, tree tree_type
)
597 gcc_assert (ipcp_lat_is_const (lat
));
600 if (!useless_type_conversion_p (tree_type
, TREE_TYPE (val
)))
602 if (fold_convertible_p (tree_type
, val
))
603 return fold_build1 (NOP_EXPR
, tree_type
, val
);
605 return fold_build1 (VIEW_CONVERT_EXPR
, tree_type
, val
);
610 /* Compute the proper scale for NODE. It is the ratio between the number of
611 direct calls (represented on the incoming cgraph_edges) and sum of all
612 invocations of NODE (represented as count in cgraph_node).
614 FIXME: This code is wrong. Since the callers can be also clones and
615 the clones are not scaled yet, the sums gets unrealistically high.
616 To properly compute the counts, we would need to do propagation across
617 callgraph (as external call to A might imply call to non-clonned B
618 if A's clone calls clonned B). */
620 ipcp_compute_node_scale (struct cgraph_node
*node
)
623 struct cgraph_edge
*cs
;
626 /* Compute sum of all counts of callers. */
627 for (cs
= node
->callers
; cs
!= NULL
; cs
= cs
->next_caller
)
629 /* Work around the unrealistically high sum problem. We just don't want
630 the non-cloned body to have negative or very low frequency. Since
631 majority of execution time will be spent in clones anyway, this should
632 give good enough profile. */
633 if (sum
> node
->count
* 9 / 10)
634 sum
= node
->count
* 9 / 10;
635 if (node
->count
== 0)
636 ipcp_set_node_scale (node
, 0);
638 ipcp_set_node_scale (node
, sum
* REG_BR_PROB_BASE
/ node
->count
);
641 /* Return true if there are some formal parameters whose value is IPA_TOP (in
642 the whole compilation unit). Change their values to IPA_BOTTOM, since they
643 most probably get their values from outside of this compilation unit. */
645 ipcp_change_tops_to_bottom (void)
648 struct cgraph_node
*node
;
652 for (node
= cgraph_nodes
; node
; node
= node
->next
)
654 struct ipa_node_params
*info
= IPA_NODE_REF (node
);
655 count
= ipa_get_param_count (info
);
656 for (i
= 0; i
< count
; i
++)
658 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
659 if (lat
->type
== IPA_TOP
)
664 fprintf (dump_file
, "Forcing param ");
665 print_generic_expr (dump_file
, ipa_get_param (info
, i
), 0);
666 fprintf (dump_file
, " of node %s to bottom.\n",
667 cgraph_node_name (node
));
669 lat
->type
= IPA_BOTTOM
;
671 if (!ipa_param_cannot_devirtualize_p (info
, i
)
672 && ipa_param_types_vec_empty (info
, i
))
675 ipa_set_param_cannot_devirtualize (info
, i
);
678 fprintf (dump_file
, "Marking param ");
679 print_generic_expr (dump_file
, ipa_get_param (info
, i
), 0);
680 fprintf (dump_file
, " of node %s as unusable for "
681 "devirtualization.\n",
682 cgraph_node_name (node
));
690 /* Insert BINFO to the list of known types of parameter number I of the
691 function described by CALLEE_INFO. Return true iff the type information
692 associated with the callee parameter changed in any way. */
695 ipcp_add_param_type (struct ipa_node_params
*callee_info
, int i
, tree binfo
)
699 if (ipa_param_cannot_devirtualize_p (callee_info
, i
))
702 if (callee_info
->params
[i
].types
)
704 count
= VEC_length (tree
, callee_info
->params
[i
].types
);
705 for (j
= 0; j
< count
; j
++)
706 if (VEC_index (tree
, callee_info
->params
[i
].types
, j
) == binfo
)
710 if (VEC_length (tree
, callee_info
->params
[i
].types
)
711 == (unsigned) PARAM_VALUE (PARAM_DEVIRT_TYPE_LIST_SIZE
))
712 return !ipa_set_param_cannot_devirtualize (callee_info
, i
);
714 VEC_safe_push (tree
, heap
, callee_info
->params
[i
].types
, binfo
);
718 /* Copy known types information for parameter number CALLEE_IDX of CALLEE_INFO
719 from a parameter of CALLER_INFO as described by JF. Return true iff the
720 type information changed in any way. JF must be a pass-through or an
721 ancestor jump function. */
724 ipcp_copy_types (struct ipa_node_params
*caller_info
,
725 struct ipa_node_params
*callee_info
,
726 int callee_idx
, struct ipa_jump_func
*jf
)
728 int caller_idx
, j
, count
;
731 if (ipa_param_cannot_devirtualize_p (callee_info
, callee_idx
))
734 if (jf
->type
== IPA_JF_PASS_THROUGH
)
736 if (jf
->value
.pass_through
.operation
!= NOP_EXPR
)
738 ipa_set_param_cannot_devirtualize (callee_info
, callee_idx
);
741 caller_idx
= jf
->value
.pass_through
.formal_id
;
744 caller_idx
= jf
->value
.ancestor
.formal_id
;
746 if (ipa_param_cannot_devirtualize_p (caller_info
, caller_idx
))
748 ipa_set_param_cannot_devirtualize (callee_info
, callee_idx
);
752 if (!caller_info
->params
[caller_idx
].types
)
756 count
= VEC_length (tree
, caller_info
->params
[caller_idx
].types
);
757 for (j
= 0; j
< count
; j
++)
759 tree binfo
= VEC_index (tree
, caller_info
->params
[caller_idx
].types
, j
);
760 if (jf
->type
== IPA_JF_ANCESTOR
)
762 binfo
= get_binfo_at_offset (binfo
, jf
->value
.ancestor
.offset
,
763 jf
->value
.ancestor
.type
);
766 ipa_set_param_cannot_devirtualize (callee_info
, callee_idx
);
770 res
|= ipcp_add_param_type (callee_info
, callee_idx
, binfo
);
775 /* Propagate type information for parameter of CALLEE_INFO number I as
776 described by JF. CALLER_INFO describes the caller. Return true iff the
777 type information changed in any way. */
780 ipcp_propagate_types (struct ipa_node_params
*caller_info
,
781 struct ipa_node_params
*callee_info
,
782 struct ipa_jump_func
*jf
, int i
)
787 case IPA_JF_CONST_MEMBER_PTR
:
791 case IPA_JF_KNOWN_TYPE
:
792 return ipcp_add_param_type (callee_info
, i
, jf
->value
.base_binfo
);
794 case IPA_JF_PASS_THROUGH
:
795 case IPA_JF_ANCESTOR
:
796 return ipcp_copy_types (caller_info
, callee_info
, i
, jf
);
799 /* If we reach this we cannot use this parameter for devirtualization. */
800 return !ipa_set_param_cannot_devirtualize (callee_info
, i
);
803 /* Interprocedural analysis. The algorithm propagates constants from the
804 caller's parameters to the callee's arguments. */
806 ipcp_propagate_stage (void)
809 struct ipcp_lattice inc_lat
= { IPA_BOTTOM
, NULL
};
810 struct ipcp_lattice new_lat
= { IPA_BOTTOM
, NULL
};
811 struct ipcp_lattice
*dest_lat
;
812 struct cgraph_edge
*cs
;
813 struct ipa_jump_func
*jump_func
;
814 struct ipa_func_list
*wl
;
817 ipa_check_create_node_params ();
818 ipa_check_create_edge_args ();
820 /* Initialize worklist to contain all functions. */
821 wl
= ipa_init_func_list ();
824 struct cgraph_node
*node
= ipa_pop_func_from_list (&wl
);
825 struct ipa_node_params
*info
= IPA_NODE_REF (node
);
827 for (cs
= node
->callees
; cs
; cs
= cs
->next_callee
)
829 struct ipa_node_params
*callee_info
= IPA_NODE_REF (cs
->callee
);
830 struct ipa_edge_args
*args
= IPA_EDGE_REF (cs
);
832 if (ipa_is_called_with_var_arguments (callee_info
)
833 || !cs
->callee
->analyzed
834 || ipa_is_called_with_var_arguments (callee_info
))
837 count
= ipa_get_cs_argument_count (args
);
838 for (i
= 0; i
< count
; i
++)
840 jump_func
= ipa_get_ith_jump_func (args
, i
);
841 ipcp_lattice_from_jfunc (info
, &inc_lat
, jump_func
);
842 dest_lat
= ipcp_get_lattice (callee_info
, i
);
843 ipa_lattice_meet (&new_lat
, &inc_lat
, dest_lat
);
844 if (ipcp_lattice_changed (&new_lat
, dest_lat
))
846 dest_lat
->type
= new_lat
.type
;
847 dest_lat
->constant
= new_lat
.constant
;
848 ipa_push_func_to_list (&wl
, cs
->callee
);
851 if (ipcp_propagate_types (info
, callee_info
, jump_func
, i
))
852 ipa_push_func_to_list (&wl
, cs
->callee
);
858 /* Call the constant propagation algorithm and re-call it if necessary
859 (if there are undetermined values left). */
861 ipcp_iterate_stage (void)
863 struct cgraph_node
*node
;
864 n_cloning_candidates
= 0;
867 fprintf (dump_file
, "\nIPA iterate stage:\n\n");
870 ipa_update_after_lto_read ();
872 for (node
= cgraph_nodes
; node
; node
= node
->next
)
874 ipcp_initialize_node_lattices (node
);
875 ipcp_compute_node_scale (node
);
877 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
879 ipcp_print_all_lattices (dump_file
);
880 ipcp_function_scale_print (dump_file
);
883 ipcp_propagate_stage ();
884 if (ipcp_change_tops_to_bottom ())
885 /* Some lattices have changed from IPA_TOP to IPA_BOTTOM.
886 This change should be propagated. */
888 gcc_assert (n_cloning_candidates
);
889 ipcp_propagate_stage ();
893 fprintf (dump_file
, "\nIPA lattices after propagation:\n");
894 ipcp_print_all_lattices (dump_file
);
895 if (dump_flags
& TDF_DETAILS
)
896 ipcp_print_profile_data (dump_file
);
900 /* Check conditions to forbid constant insertion to function described by
903 ipcp_node_modifiable_p (struct cgraph_node
*node
)
905 /* Once we will be able to do in-place replacement, we can be more
907 return ipcp_versionable_function_p (node
);
910 /* Print count scale data structures. */
912 ipcp_function_scale_print (FILE * f
)
914 struct cgraph_node
*node
;
916 for (node
= cgraph_nodes
; node
; node
= node
->next
)
920 fprintf (f
, "printing scale for %s: ", cgraph_node_name (node
));
921 fprintf (f
, "value is " HOST_WIDE_INT_PRINT_DEC
922 " \n", (HOST_WIDE_INT
) ipcp_get_node_scale (node
));
926 /* Print counts of all cgraph nodes. */
928 ipcp_print_func_profile_counts (FILE * f
)
930 struct cgraph_node
*node
;
932 for (node
= cgraph_nodes
; node
; node
= node
->next
)
934 fprintf (f
, "function %s: ", cgraph_node_name (node
));
935 fprintf (f
, "count is " HOST_WIDE_INT_PRINT_DEC
936 " \n", (HOST_WIDE_INT
) node
->count
);
940 /* Print counts of all cgraph edges. */
942 ipcp_print_call_profile_counts (FILE * f
)
944 struct cgraph_node
*node
;
945 struct cgraph_edge
*cs
;
947 for (node
= cgraph_nodes
; node
; node
= node
->next
)
949 for (cs
= node
->callees
; cs
; cs
= cs
->next_callee
)
951 fprintf (f
, "%s -> %s ", cgraph_node_name (cs
->caller
),
952 cgraph_node_name (cs
->callee
));
953 fprintf (f
, "count is " HOST_WIDE_INT_PRINT_DEC
" \n",
954 (HOST_WIDE_INT
) cs
->count
);
959 /* Print profile info for all functions. */
961 ipcp_print_profile_data (FILE * f
)
963 fprintf (f
, "\nNODE COUNTS :\n");
964 ipcp_print_func_profile_counts (f
);
965 fprintf (f
, "\nCS COUNTS stage:\n");
966 ipcp_print_call_profile_counts (f
);
969 /* Build and initialize ipa_replace_map struct according to LAT. This struct is
970 processed by versioning, which operates according to the flags set.
971 PARM_TREE is the formal parameter found to be constant. LAT represents the
973 static struct ipa_replace_map
*
974 ipcp_create_replace_map (tree parm_tree
, struct ipcp_lattice
*lat
)
976 struct ipa_replace_map
*replace_map
;
979 replace_map
= ggc_alloc_ipa_replace_map ();
980 const_val
= build_const_val (lat
, TREE_TYPE (parm_tree
));
983 fprintf (dump_file
, " replacing param ");
984 print_generic_expr (dump_file
, parm_tree
, 0);
985 fprintf (dump_file
, " with const ");
986 print_generic_expr (dump_file
, const_val
, 0);
987 fprintf (dump_file
, "\n");
989 replace_map
->old_tree
= parm_tree
;
990 replace_map
->new_tree
= const_val
;
991 replace_map
->replace_p
= true;
992 replace_map
->ref_p
= false;
997 /* Return true if this callsite should be redirected to the original callee
998 (instead of the cloned one). */
1000 ipcp_need_redirect_p (struct cgraph_edge
*cs
)
1002 struct ipa_node_params
*orig_callee_info
;
1004 struct cgraph_node
*node
= cs
->callee
, *orig
;
1006 if (!n_cloning_candidates
)
1009 if ((orig
= ipcp_get_orig_node (node
)) != NULL
)
1011 if (ipcp_get_orig_node (cs
->caller
))
1014 orig_callee_info
= IPA_NODE_REF (node
);
1015 count
= ipa_get_param_count (orig_callee_info
);
1016 for (i
= 0; i
< count
; i
++)
1018 struct ipcp_lattice
*lat
= ipcp_get_lattice (orig_callee_info
, i
);
1019 struct ipa_jump_func
*jump_func
;
1021 jump_func
= ipa_get_ith_jump_func (IPA_EDGE_REF (cs
), i
);
1022 if ((ipcp_lat_is_const (lat
)
1023 && jump_func
->type
!= IPA_JF_CONST
)
1024 || (!ipa_param_cannot_devirtualize_p (orig_callee_info
, i
)
1025 && !ipa_param_types_vec_empty (orig_callee_info
, i
)
1026 && jump_func
->type
!= IPA_JF_CONST
1027 && jump_func
->type
!= IPA_JF_KNOWN_TYPE
))
1034 /* Fix the callsites and the call graph after function cloning was done. */
1036 ipcp_update_callgraph (void)
1038 struct cgraph_node
*node
;
1040 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1041 if (node
->analyzed
&& ipcp_node_is_clone (node
))
1043 bitmap args_to_skip
= NULL
;
1044 struct cgraph_node
*orig_node
= ipcp_get_orig_node (node
);
1045 struct ipa_node_params
*info
= IPA_NODE_REF (orig_node
);
1046 int i
, count
= ipa_get_param_count (info
);
1047 struct cgraph_edge
*cs
, *next
;
1049 if (node
->local
.can_change_signature
)
1051 args_to_skip
= BITMAP_ALLOC (NULL
);
1052 for (i
= 0; i
< count
; i
++)
1054 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
1056 /* We can proactively remove obviously unused arguments. */
1057 if (!ipa_is_param_used (info
, i
))
1059 bitmap_set_bit (args_to_skip
, i
);
1063 if (lat
->type
== IPA_CONST_VALUE
)
1064 bitmap_set_bit (args_to_skip
, i
);
1067 for (cs
= node
->callers
; cs
; cs
= next
)
1069 next
= cs
->next_caller
;
1070 if (!ipcp_node_is_clone (cs
->caller
) && ipcp_need_redirect_p (cs
))
1073 fprintf (dump_file
, "Redirecting edge %s/%i -> %s/%i "
1075 cgraph_node_name (cs
->caller
), cs
->caller
->uid
,
1076 cgraph_node_name (cs
->callee
), cs
->callee
->uid
,
1077 cgraph_node_name (orig_node
), orig_node
->uid
);
1078 cgraph_redirect_edge_callee (cs
, orig_node
);
1084 /* Update profiling info for versioned functions and the functions they were
1087 ipcp_update_profiling (void)
1089 struct cgraph_node
*node
, *orig_node
;
1090 gcov_type scale
, scale_complement
;
1091 struct cgraph_edge
*cs
;
1093 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1095 if (ipcp_node_is_clone (node
))
1097 orig_node
= ipcp_get_orig_node (node
);
1098 scale
= ipcp_get_node_scale (orig_node
);
1099 node
->count
= orig_node
->count
* scale
/ REG_BR_PROB_BASE
;
1100 scale_complement
= REG_BR_PROB_BASE
- scale
;
1102 orig_node
->count
* scale_complement
/ REG_BR_PROB_BASE
;
1103 for (cs
= node
->callees
; cs
; cs
= cs
->next_callee
)
1104 cs
->count
= cs
->count
* scale
/ REG_BR_PROB_BASE
;
1105 for (cs
= orig_node
->callees
; cs
; cs
= cs
->next_callee
)
1106 cs
->count
= cs
->count
* scale_complement
/ REG_BR_PROB_BASE
;
1111 /* If NODE was cloned, how much would program grow? */
1113 ipcp_estimate_growth (struct cgraph_node
*node
)
1115 struct cgraph_edge
*cs
;
1116 int redirectable_node_callers
= 0;
1117 int removable_args
= 0;
1119 = !cgraph_will_be_removed_from_program_if_no_direct_calls (node
);
1120 struct ipa_node_params
*info
;
1124 for (cs
= node
->callers
; cs
!= NULL
; cs
= cs
->next_caller
)
1125 if (cs
->caller
== node
|| !ipcp_need_redirect_p (cs
))
1126 redirectable_node_callers
++;
1128 need_original
= true;
1130 /* If we will be able to fully replace orignal node, we never increase
1135 info
= IPA_NODE_REF (node
);
1136 count
= ipa_get_param_count (info
);
1137 if (node
->local
.can_change_signature
)
1138 for (i
= 0; i
< count
; i
++)
1140 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
1142 /* We can proactively remove obviously unused arguments. */
1143 if (!ipa_is_param_used (info
, i
))
1146 if (lat
->type
== IPA_CONST_VALUE
)
1150 /* We make just very simple estimate of savings for removal of operand from
1151 call site. Precise cost is dificult to get, as our size metric counts
1152 constants and moves as free. Generally we are looking for cases that
1153 small function is called very many times. */
1154 growth
= node
->local
.inline_summary
.self_size
1155 - removable_args
* redirectable_node_callers
;
1162 /* Estimate cost of cloning NODE. */
1164 ipcp_estimate_cloning_cost (struct cgraph_node
*node
)
1167 gcov_type count_sum
= 1;
1168 struct cgraph_edge
*e
;
1171 cost
= ipcp_estimate_growth (node
) * 1000;
1175 fprintf (dump_file
, "Versioning of %s will save code size\n",
1176 cgraph_node_name (node
));
1180 for (e
= node
->callers
; e
; e
= e
->next_caller
)
1181 if (!bitmap_bit_p (dead_nodes
, e
->caller
->uid
)
1182 && !ipcp_need_redirect_p (e
))
1184 count_sum
+= e
->count
;
1185 freq_sum
+= e
->frequency
+ 1;
1189 cost
/= count_sum
* 1000 / max_count
+ 1;
1191 cost
/= freq_sum
* 1000 / REG_BR_PROB_BASE
+ 1;
1193 fprintf (dump_file
, "Cost of versioning %s is %i, (size: %i, freq: %i)\n",
1194 cgraph_node_name (node
), cost
, node
->local
.inline_summary
.self_size
,
1199 /* Walk indirect calls of NODE and if any polymorphic can be turned into a
1200 direct one now, do so. */
1203 ipcp_process_devirtualization_opportunities (struct cgraph_node
*node
)
1205 struct ipa_node_params
*info
= IPA_NODE_REF (node
);
1206 struct cgraph_edge
*ie
, *next_ie
;
1208 for (ie
= node
->indirect_calls
; ie
; ie
= next_ie
)
1210 int param_index
, types_count
, j
;
1211 HOST_WIDE_INT token
;
1214 next_ie
= ie
->next_callee
;
1215 if (!ie
->indirect_info
->polymorphic
)
1217 param_index
= ie
->indirect_info
->param_index
;
1218 if (param_index
== -1
1219 || ipa_param_cannot_devirtualize_p (info
, param_index
)
1220 || ipa_param_types_vec_empty (info
, param_index
))
1223 token
= ie
->indirect_info
->otr_token
;
1225 types_count
= VEC_length (tree
, info
->params
[param_index
].types
);
1226 for (j
= 0; j
< types_count
; j
++)
1228 tree binfo
= VEC_index (tree
, info
->params
[param_index
].types
, j
);
1230 tree t
= gimple_get_virt_mehtod_for_binfo (token
, binfo
, &d
, true);
1242 else if (target
!= t
|| !tree_int_cst_equal (delta
, d
))
1250 ipa_make_edge_direct_to_target (ie
, target
, delta
);
1254 /* Return number of live constant parameters. */
1256 ipcp_const_param_count (struct cgraph_node
*node
)
1258 int const_param
= 0;
1259 struct ipa_node_params
*info
= IPA_NODE_REF (node
);
1260 int count
= ipa_get_param_count (info
);
1263 for (i
= 0; i
< count
; i
++)
1265 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
1266 if ((ipcp_lat_is_insertable (lat
)
1267 /* Do not count obviously unused arguments. */
1268 && ipa_is_param_used (info
, i
))
1269 || (!ipa_param_cannot_devirtualize_p (info
, i
)
1270 && !ipa_param_types_vec_empty (info
, i
)))
1276 /* Given that a formal parameter of NODE given by INDEX is known to be constant
1277 CST, try to find any indirect edges that can be made direct and make them
1278 so. Note that INDEX is the number the parameter at the time of analyzing
1279 parameter uses and parameter removals should not be considered for it. (In
1280 fact, the parameter itself has just been removed.) */
1283 ipcp_discover_new_direct_edges (struct cgraph_node
*node
, int index
, tree cst
)
1285 struct cgraph_edge
*ie
, *next_ie
;
1287 for (ie
= node
->indirect_calls
; ie
; ie
= next_ie
)
1289 struct cgraph_indirect_call_info
*ici
= ie
->indirect_info
;
1291 next_ie
= ie
->next_callee
;
1292 if (ici
->param_index
!= index
1293 || ici
->polymorphic
)
1296 ipa_make_edge_direct_to_target (ie
, cst
, NULL_TREE
);
1301 /* Propagate the constant parameters found by ipcp_iterate_stage()
1302 to the function's code. */
1304 ipcp_insert_stage (void)
1306 struct cgraph_node
*node
, *node1
= NULL
;
1308 VEC (cgraph_edge_p
, heap
) * redirect_callers
;
1309 VEC (ipa_replace_map_p
,gc
)* replace_trees
;
1310 int node_callers
, count
;
1312 struct ipa_replace_map
*replace_param
;
1314 long overall_size
= 0, new_size
= 0;
1317 ipa_check_create_node_params ();
1318 ipa_check_create_edge_args ();
1320 fprintf (dump_file
, "\nIPA insert stage:\n\n");
1322 dead_nodes
= BITMAP_ALLOC (NULL
);
1324 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1327 if (node
->count
> max_count
)
1328 max_count
= node
->count
;
1329 overall_size
+= node
->local
.inline_summary
.self_size
;
1332 max_new_size
= overall_size
;
1333 if (max_new_size
< PARAM_VALUE (PARAM_LARGE_UNIT_INSNS
))
1334 max_new_size
= PARAM_VALUE (PARAM_LARGE_UNIT_INSNS
);
1335 max_new_size
= max_new_size
* PARAM_VALUE (PARAM_IPCP_UNIT_GROWTH
) / 100 + 1;
1337 /* First collect all functions we proved to have constant arguments to
1339 heap
= fibheap_new ();
1340 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1342 struct ipa_node_params
*info
;
1343 /* Propagation of the constant is forbidden in certain conditions. */
1344 if (!node
->analyzed
|| !ipcp_node_modifiable_p (node
))
1346 info
= IPA_NODE_REF (node
);
1347 if (ipa_is_called_with_var_arguments (info
))
1349 if (ipcp_const_param_count (node
))
1350 node
->aux
= fibheap_insert (heap
, ipcp_estimate_cloning_cost (node
),
1354 /* Now clone in priority order until code size growth limits are met or
1356 while (!fibheap_empty (heap
))
1358 struct ipa_node_params
*info
;
1360 bitmap args_to_skip
;
1361 struct cgraph_edge
*cs
;
1363 node
= (struct cgraph_node
*)fibheap_extract_min (heap
);
1366 fprintf (dump_file
, "considering function %s\n",
1367 cgraph_node_name (node
));
1369 growth
= ipcp_estimate_growth (node
);
1371 if (new_size
+ growth
> max_new_size
)
1374 && optimize_function_for_size_p (DECL_STRUCT_FUNCTION (node
->decl
)))
1377 fprintf (dump_file
, "Not versioning, cold code would grow");
1383 /* Look if original function becomes dead after clonning. */
1384 for (cs
= node
->callers
; cs
!= NULL
; cs
= cs
->next_caller
)
1385 if (cs
->caller
== node
|| ipcp_need_redirect_p (cs
))
1387 if (!cs
&& cgraph_will_be_removed_from_program_if_no_direct_calls (node
))
1388 bitmap_set_bit (dead_nodes
, node
->uid
);
1390 info
= IPA_NODE_REF (node
);
1391 count
= ipa_get_param_count (info
);
1393 replace_trees
= VEC_alloc (ipa_replace_map_p
, gc
, 1);
1395 if (node
->local
.can_change_signature
)
1396 args_to_skip
= BITMAP_GGC_ALLOC ();
1398 args_to_skip
= NULL
;
1399 for (i
= 0; i
< count
; i
++)
1401 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
1402 parm_tree
= ipa_get_param (info
, i
);
1404 /* We can proactively remove obviously unused arguments. */
1405 if (!ipa_is_param_used (info
, i
))
1408 bitmap_set_bit (args_to_skip
, i
);
1412 if (lat
->type
== IPA_CONST_VALUE
)
1415 ipcp_create_replace_map (parm_tree
, lat
);
1416 VEC_safe_push (ipa_replace_map_p
, gc
, replace_trees
, replace_param
);
1418 bitmap_set_bit (args_to_skip
, i
);
1422 /* Compute how many callers node has. */
1424 for (cs
= node
->callers
; cs
!= NULL
; cs
= cs
->next_caller
)
1426 redirect_callers
= VEC_alloc (cgraph_edge_p
, heap
, node_callers
);
1427 for (cs
= node
->callers
; cs
!= NULL
; cs
= cs
->next_caller
)
1428 if (!cs
->indirect_inlining_edge
)
1429 VEC_quick_push (cgraph_edge_p
, redirect_callers
, cs
);
1431 /* Redirecting all the callers of the node to the
1432 new versioned node. */
1434 cgraph_create_virtual_clone (node
, redirect_callers
, replace_trees
,
1435 args_to_skip
, "constprop");
1436 args_to_skip
= NULL
;
1437 VEC_free (cgraph_edge_p
, heap
, redirect_callers
);
1438 replace_trees
= NULL
;
1442 ipcp_process_devirtualization_opportunities (node1
);
1445 fprintf (dump_file
, "versioned function %s with growth %i, overall %i\n",
1446 cgraph_node_name (node
), (int)growth
, (int)new_size
);
1447 ipcp_init_cloned_node (node
, node1
);
1449 info
= IPA_NODE_REF (node
);
1450 for (i
= 0; i
< count
; i
++)
1452 struct ipcp_lattice
*lat
= ipcp_get_lattice (info
, i
);
1453 if (lat
->type
== IPA_CONST_VALUE
)
1454 ipcp_discover_new_direct_edges (node1
, i
, lat
->constant
);
1458 dump_function_to_file (node1
->decl
, dump_file
, dump_flags
);
1460 for (cs
= node
->callees
; cs
; cs
= cs
->next_callee
)
1461 if (cs
->callee
->aux
)
1463 fibheap_delete_node (heap
, (fibnode_t
) cs
->callee
->aux
);
1464 cs
->callee
->aux
= fibheap_insert (heap
,
1465 ipcp_estimate_cloning_cost (cs
->callee
),
1470 while (!fibheap_empty (heap
))
1473 fprintf (dump_file
, "skipping function %s\n",
1474 cgraph_node_name (node
));
1475 node
= (struct cgraph_node
*) fibheap_extract_min (heap
);
1478 fibheap_delete (heap
);
1479 BITMAP_FREE (dead_nodes
);
1480 ipcp_update_callgraph ();
1481 ipcp_update_profiling ();
1484 /* The IPCP driver. */
1488 cgraph_remove_unreachable_nodes (true,dump_file
);
1491 fprintf (dump_file
, "\nIPA structures before propagation:\n");
1492 if (dump_flags
& TDF_DETAILS
)
1493 ipa_print_all_params (dump_file
);
1494 ipa_print_all_jump_functions (dump_file
);
1496 /* 2. Do the interprocedural propagation. */
1497 ipcp_iterate_stage ();
1498 /* 3. Insert the constants found to the functions. */
1499 ipcp_insert_stage ();
1500 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1502 fprintf (dump_file
, "\nProfiling info after insert stage:\n");
1503 ipcp_print_profile_data (dump_file
);
1505 /* Free all IPCP structures. */
1506 ipa_free_all_structures_after_ipa_cp ();
1508 fprintf (dump_file
, "\nIPA constant propagation end\n");
1512 /* Initialization and computation of IPCP data structures. This is the initial
1513 intraprocedural analysis of functions, which gathers information to be
1514 propagated later on. */
1517 ipcp_generate_summary (void)
1519 struct cgraph_node
*node
;
1522 fprintf (dump_file
, "\nIPA constant propagation start:\n");
1523 ipa_check_create_node_params ();
1524 ipa_check_create_edge_args ();
1525 ipa_register_cgraph_hooks ();
1527 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1530 /* Unreachable nodes should have been eliminated before ipcp. */
1531 gcc_assert (node
->needed
|| node
->reachable
);
1533 node
->local
.versionable
= tree_versionable_function_p (node
->decl
);
1534 ipa_analyze_node (node
);
1538 /* Write ipcp summary for nodes in SET. */
1540 ipcp_write_summary (cgraph_node_set set
,
1541 varpool_node_set vset ATTRIBUTE_UNUSED
)
1543 ipa_prop_write_jump_functions (set
);
1546 /* Read ipcp summary. */
1548 ipcp_read_summary (void)
1550 ipa_prop_read_jump_functions ();
1553 /* Gate for IPCP optimization. */
1555 cgraph_gate_cp (void)
1557 /* FIXME: We should remove the optimize check after we ensure we never run
1558 IPA passes when not optimizng. */
1559 return flag_ipa_cp
&& optimize
;
1562 struct ipa_opt_pass_d pass_ipa_cp
=
1567 cgraph_gate_cp
, /* gate */
1568 ipcp_driver
, /* execute */
1571 0, /* static_pass_number */
1572 TV_IPA_CONSTANT_PROP
, /* tv_id */
1573 0, /* properties_required */
1574 0, /* properties_provided */
1575 0, /* properties_destroyed */
1576 0, /* todo_flags_start */
1577 TODO_dump_cgraph
| TODO_dump_func
|
1578 TODO_remove_functions
| TODO_ggc_collect
/* todo_flags_finish */
1580 ipcp_generate_summary
, /* generate_summary */
1581 ipcp_write_summary
, /* write_summary */
1582 ipcp_read_summary
, /* read_summary */
1583 NULL
, /* write_optimization_summary */
1584 NULL
, /* read_optimization_summary */
1585 NULL
, /* stmt_fixup */
1587 NULL
, /* function_transform */
1588 NULL
, /* variable_transform */