1*e4b17023SJohn Marino /* Interprocedural analyses.
2*e4b17023SJohn Marino Copyright (C) 2005, 2007, 2008, 2009, 2010
3*e4b17023SJohn Marino Free Software Foundation, Inc.
4*e4b17023SJohn Marino
5*e4b17023SJohn Marino This file is part of GCC.
6*e4b17023SJohn Marino
7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
10*e4b17023SJohn Marino version.
11*e4b17023SJohn Marino
12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15*e4b17023SJohn Marino for more details.
16*e4b17023SJohn Marino
17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see
19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */
20*e4b17023SJohn Marino
21*e4b17023SJohn Marino #ifndef IPA_PROP_H
22*e4b17023SJohn Marino #define IPA_PROP_H
23*e4b17023SJohn Marino
24*e4b17023SJohn Marino #include "tree.h"
25*e4b17023SJohn Marino #include "vec.h"
26*e4b17023SJohn Marino #include "cgraph.h"
27*e4b17023SJohn Marino #include "gimple.h"
28*e4b17023SJohn Marino #include "alloc-pool.h"
29*e4b17023SJohn Marino
30*e4b17023SJohn Marino /* The following definitions and interfaces are used by
31*e4b17023SJohn Marino interprocedural analyses or parameters. */
32*e4b17023SJohn Marino
33*e4b17023SJohn Marino /* ipa-prop.c stuff (ipa-cp, indirect inlining): */
34*e4b17023SJohn Marino
35*e4b17023SJohn Marino /* A jump function for a callsite represents the values passed as actual
36*e4b17023SJohn Marino arguments of the callsite. They were originally proposed in a paper called
37*e4b17023SJohn Marino "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
38*e4b17023SJohn Marino Ken Kennedy, Linda Torczon in Comp86, pg 152-161. There are three main
39*e4b17023SJohn Marino types of values :
40*e4b17023SJohn Marino
41*e4b17023SJohn Marino Pass-through - the caller's formal parameter is passed as an actual
42*e4b17023SJohn Marino argument, possibly one simple operation performed on it.
43*e4b17023SJohn Marino Constant - a constant (is_gimple_ip_invariant)is passed as an actual
44*e4b17023SJohn Marino argument.
45*e4b17023SJohn Marino Unknown - neither of the above.
46*e4b17023SJohn Marino
47*e4b17023SJohn Marino IPA_JF_CONST_MEMBER_PTR stands for C++ member pointers, it is a special
48*e4b17023SJohn Marino constant in this regard because it is in fact a structure consisting of two
49*e4b17023SJohn Marino values. Other constants are represented with IPA_JF_CONST.
50*e4b17023SJohn Marino
51*e4b17023SJohn Marino IPA_JF_ANCESTOR is a special pass-through jump function, which means that
52*e4b17023SJohn Marino the result is an address of a part of the object pointed to by the formal
53*e4b17023SJohn Marino parameter to which the function refers. It is mainly intended to represent
54*e4b17023SJohn Marino getting addresses of of ancestor fields in C++
55*e4b17023SJohn Marino (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is
56*e4b17023SJohn Marino NULL, ancestor jump function must behave like a simple pass-through.
57*e4b17023SJohn Marino
58*e4b17023SJohn Marino Other pass-through functions can either simply pass on an unchanged formal
59*e4b17023SJohn Marino parameter or can apply one simple binary operation to it (such jump
60*e4b17023SJohn Marino functions are called polynomial).
61*e4b17023SJohn Marino
62*e4b17023SJohn Marino IPA_JF_KNOWN_TYPE is a special type of an "unknown" function that applies
63*e4b17023SJohn Marino only to pointer parameters. It means that even though we cannot prove that
64*e4b17023SJohn Marino the passed value is an interprocedural constant, we still know the exact
65*e4b17023SJohn Marino type of the containing object which may be valuable for devirtualization.
66*e4b17023SJohn Marino
67*e4b17023SJohn Marino Jump functions are computed in ipa-prop.c by function
68*e4b17023SJohn Marino update_call_notes_after_inlining. Some information can be lost and jump
69*e4b17023SJohn Marino functions degraded accordingly when inlining, see
70*e4b17023SJohn Marino update_call_notes_after_inlining in the same file. */
71*e4b17023SJohn Marino
72*e4b17023SJohn Marino enum jump_func_type
73*e4b17023SJohn Marino {
74*e4b17023SJohn Marino IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */
75*e4b17023SJohn Marino IPA_JF_KNOWN_TYPE, /* represented by field known_type */
76*e4b17023SJohn Marino IPA_JF_CONST, /* represented by field costant */
77*e4b17023SJohn Marino IPA_JF_CONST_MEMBER_PTR, /* represented by field member_cst */
78*e4b17023SJohn Marino IPA_JF_PASS_THROUGH, /* represented by field pass_through */
79*e4b17023SJohn Marino IPA_JF_ANCESTOR /* represented by field ancestor */
80*e4b17023SJohn Marino };
81*e4b17023SJohn Marino
82*e4b17023SJohn Marino /* Structure holding data required to describe a known type jump function. */
83*e4b17023SJohn Marino struct GTY(()) ipa_known_type_data
84*e4b17023SJohn Marino {
85*e4b17023SJohn Marino /* Offset of the component of the base_type being described. */
86*e4b17023SJohn Marino HOST_WIDE_INT offset;
87*e4b17023SJohn Marino /* Type of the whole object. */
88*e4b17023SJohn Marino tree base_type;
89*e4b17023SJohn Marino /* Type of the component of the object that is being described. */
90*e4b17023SJohn Marino tree component_type;
91*e4b17023SJohn Marino };
92*e4b17023SJohn Marino
93*e4b17023SJohn Marino /* Structure holding data required to describe a pass-through jump function. */
94*e4b17023SJohn Marino
95*e4b17023SJohn Marino struct GTY(()) ipa_pass_through_data
96*e4b17023SJohn Marino {
97*e4b17023SJohn Marino /* If an operation is to be performed on the original parameter, this is the
98*e4b17023SJohn Marino second (constant) operand. */
99*e4b17023SJohn Marino tree operand;
100*e4b17023SJohn Marino /* Number of the caller's formal parameter being passed. */
101*e4b17023SJohn Marino int formal_id;
102*e4b17023SJohn Marino /* Operation that is performed on the argument before it is passed on.
103*e4b17023SJohn Marino NOP_EXPR means no operation. Otherwise oper must be a simple binary
104*e4b17023SJohn Marino arithmetic operation where the caller's parameter is the first operand and
105*e4b17023SJohn Marino operand field from this structure is the second one. */
106*e4b17023SJohn Marino enum tree_code operation;
107*e4b17023SJohn Marino };
108*e4b17023SJohn Marino
109*e4b17023SJohn Marino /* Structure holding data required to describe an ancestor pass-through
110*e4b17023SJohn Marino jump function. */
111*e4b17023SJohn Marino
112*e4b17023SJohn Marino struct GTY(()) ipa_ancestor_jf_data
113*e4b17023SJohn Marino {
114*e4b17023SJohn Marino /* Offset of the field representing the ancestor. */
115*e4b17023SJohn Marino HOST_WIDE_INT offset;
116*e4b17023SJohn Marino /* TYpe of the result. */
117*e4b17023SJohn Marino tree type;
118*e4b17023SJohn Marino /* Number of the caller's formal parameter being passed. */
119*e4b17023SJohn Marino int formal_id;
120*e4b17023SJohn Marino };
121*e4b17023SJohn Marino
122*e4b17023SJohn Marino /* Structure holding a C++ member pointer constant. Holds a pointer to the
123*e4b17023SJohn Marino method and delta offset. */
124*e4b17023SJohn Marino struct GTY(()) ipa_member_ptr_cst
125*e4b17023SJohn Marino {
126*e4b17023SJohn Marino tree pfn;
127*e4b17023SJohn Marino tree delta;
128*e4b17023SJohn Marino };
129*e4b17023SJohn Marino
130*e4b17023SJohn Marino /* A jump function for a callsite represents the values passed as actual
131*e4b17023SJohn Marino arguments of the callsite. See enum jump_func_type for the various
132*e4b17023SJohn Marino types of jump functions supported. */
133*e4b17023SJohn Marino typedef struct GTY (()) ipa_jump_func
134*e4b17023SJohn Marino {
135*e4b17023SJohn Marino enum jump_func_type type;
136*e4b17023SJohn Marino /* Represents a value of a jump function. pass_through is used only in jump
137*e4b17023SJohn Marino function context. constant represents the actual constant in constant jump
138*e4b17023SJohn Marino functions and member_cst holds constant c++ member functions. */
139*e4b17023SJohn Marino union jump_func_value
140*e4b17023SJohn Marino {
141*e4b17023SJohn Marino struct ipa_known_type_data GTY ((tag ("IPA_JF_KNOWN_TYPE"))) known_type;
142*e4b17023SJohn Marino tree GTY ((tag ("IPA_JF_CONST"))) constant;
143*e4b17023SJohn Marino struct ipa_member_ptr_cst GTY ((tag ("IPA_JF_CONST_MEMBER_PTR"))) member_cst;
144*e4b17023SJohn Marino struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through;
145*e4b17023SJohn Marino struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor;
146*e4b17023SJohn Marino } GTY ((desc ("%1.type"))) value;
147*e4b17023SJohn Marino } ipa_jump_func_t;
148*e4b17023SJohn Marino
149*e4b17023SJohn Marino DEF_VEC_O (ipa_jump_func_t);
150*e4b17023SJohn Marino DEF_VEC_ALLOC_O (ipa_jump_func_t, gc);
151*e4b17023SJohn Marino
152*e4b17023SJohn Marino /* Summary describing a single formal parameter. */
153*e4b17023SJohn Marino
154*e4b17023SJohn Marino struct ipa_param_descriptor
155*e4b17023SJohn Marino {
156*e4b17023SJohn Marino /* PARAM_DECL of this parameter. */
157*e4b17023SJohn Marino tree decl;
158*e4b17023SJohn Marino /* The parameter is used. */
159*e4b17023SJohn Marino unsigned used : 1;
160*e4b17023SJohn Marino };
161*e4b17023SJohn Marino
162*e4b17023SJohn Marino typedef struct ipa_param_descriptor ipa_param_descriptor_t;
163*e4b17023SJohn Marino DEF_VEC_O (ipa_param_descriptor_t);
164*e4b17023SJohn Marino DEF_VEC_ALLOC_O (ipa_param_descriptor_t, heap);
165*e4b17023SJohn Marino struct ipcp_lattice;
166*e4b17023SJohn Marino
167*e4b17023SJohn Marino /* ipa_node_params stores information related to formal parameters of functions
168*e4b17023SJohn Marino and some other information for interprocedural passes that operate on
169*e4b17023SJohn Marino parameters (such as ipa-cp). */
170*e4b17023SJohn Marino
171*e4b17023SJohn Marino struct ipa_node_params
172*e4b17023SJohn Marino {
173*e4b17023SJohn Marino /* Information about individual formal parameters that are gathered when
174*e4b17023SJohn Marino summaries are generated. */
175*e4b17023SJohn Marino VEC (ipa_param_descriptor_t, heap) *descriptors;
176*e4b17023SJohn Marino /* Pointer to an array of structures describing individual formal
177*e4b17023SJohn Marino parameters. */
178*e4b17023SJohn Marino struct ipcp_lattice *lattices;
179*e4b17023SJohn Marino /* Only for versioned nodes this field would not be NULL,
180*e4b17023SJohn Marino it points to the node that IPA cp cloned from. */
181*e4b17023SJohn Marino struct cgraph_node *ipcp_orig_node;
182*e4b17023SJohn Marino /* If this node is an ipa-cp clone, these are the known values that describe
183*e4b17023SJohn Marino what it has been specialized for. */
184*e4b17023SJohn Marino VEC (tree, heap) *known_vals;
185*e4b17023SJohn Marino /* Whether the param uses analysis has already been performed. */
186*e4b17023SJohn Marino unsigned uses_analysis_done : 1;
187*e4b17023SJohn Marino /* Whether the function is enqueued in ipa-cp propagation stack. */
188*e4b17023SJohn Marino unsigned node_enqueued : 1;
189*e4b17023SJohn Marino /* Whether we should create a specialized version based on values that are
190*e4b17023SJohn Marino known to be constant in all contexts. */
191*e4b17023SJohn Marino unsigned clone_for_all_contexts : 1;
192*e4b17023SJohn Marino /* Node has been completely replaced by clones and will be removed after
193*e4b17023SJohn Marino ipa-cp is finished. */
194*e4b17023SJohn Marino unsigned node_dead : 1;
195*e4b17023SJohn Marino };
196*e4b17023SJohn Marino
197*e4b17023SJohn Marino /* ipa_node_params access functions. Please use these to access fields that
198*e4b17023SJohn Marino are or will be shared among various passes. */
199*e4b17023SJohn Marino
200*e4b17023SJohn Marino /* Return the number of formal parameters. */
201*e4b17023SJohn Marino
202*e4b17023SJohn Marino static inline int
ipa_get_param_count(struct ipa_node_params * info)203*e4b17023SJohn Marino ipa_get_param_count (struct ipa_node_params *info)
204*e4b17023SJohn Marino {
205*e4b17023SJohn Marino return VEC_length (ipa_param_descriptor_t, info->descriptors);
206*e4b17023SJohn Marino }
207*e4b17023SJohn Marino
208*e4b17023SJohn Marino /* Return the declaration of Ith formal parameter of the function corresponding
209*e4b17023SJohn Marino to INFO. Note there is no setter function as this array is built just once
210*e4b17023SJohn Marino using ipa_initialize_node_params. */
211*e4b17023SJohn Marino
212*e4b17023SJohn Marino static inline tree
ipa_get_param(struct ipa_node_params * info,int i)213*e4b17023SJohn Marino ipa_get_param (struct ipa_node_params *info, int i)
214*e4b17023SJohn Marino {
215*e4b17023SJohn Marino return VEC_index (ipa_param_descriptor_t, info->descriptors, i)->decl;
216*e4b17023SJohn Marino }
217*e4b17023SJohn Marino
218*e4b17023SJohn Marino /* Set the used flag corresponding to the Ith formal parameter of the function
219*e4b17023SJohn Marino associated with INFO to VAL. */
220*e4b17023SJohn Marino
221*e4b17023SJohn Marino static inline void
ipa_set_param_used(struct ipa_node_params * info,int i,bool val)222*e4b17023SJohn Marino ipa_set_param_used (struct ipa_node_params *info, int i, bool val)
223*e4b17023SJohn Marino {
224*e4b17023SJohn Marino VEC_index (ipa_param_descriptor_t, info->descriptors, i)->used = val;
225*e4b17023SJohn Marino }
226*e4b17023SJohn Marino
227*e4b17023SJohn Marino /* Return the used flag corresponding to the Ith formal parameter of the
228*e4b17023SJohn Marino function associated with INFO. */
229*e4b17023SJohn Marino
230*e4b17023SJohn Marino static inline bool
ipa_is_param_used(struct ipa_node_params * info,int i)231*e4b17023SJohn Marino ipa_is_param_used (struct ipa_node_params *info, int i)
232*e4b17023SJohn Marino {
233*e4b17023SJohn Marino return VEC_index (ipa_param_descriptor_t, info->descriptors, i)->used;
234*e4b17023SJohn Marino }
235*e4b17023SJohn Marino
236*e4b17023SJohn Marino /* ipa_edge_args stores information related to a callsite and particularly its
237*e4b17023SJohn Marino arguments. It can be accessed by the IPA_EDGE_REF macro. */
238*e4b17023SJohn Marino typedef struct GTY(()) ipa_edge_args
239*e4b17023SJohn Marino {
240*e4b17023SJohn Marino /* Vector of the callsite's jump function of each parameter. */
241*e4b17023SJohn Marino VEC (ipa_jump_func_t, gc) *jump_functions;
242*e4b17023SJohn Marino } ipa_edge_args_t;
243*e4b17023SJohn Marino
244*e4b17023SJohn Marino /* ipa_edge_args access functions. Please use these to access fields that
245*e4b17023SJohn Marino are or will be shared among various passes. */
246*e4b17023SJohn Marino
247*e4b17023SJohn Marino /* Return the number of actual arguments. */
248*e4b17023SJohn Marino
249*e4b17023SJohn Marino static inline int
ipa_get_cs_argument_count(struct ipa_edge_args * args)250*e4b17023SJohn Marino ipa_get_cs_argument_count (struct ipa_edge_args *args)
251*e4b17023SJohn Marino {
252*e4b17023SJohn Marino return VEC_length (ipa_jump_func_t, args->jump_functions);
253*e4b17023SJohn Marino }
254*e4b17023SJohn Marino
255*e4b17023SJohn Marino /* Returns a pointer to the jump function for the ith argument. Please note
256*e4b17023SJohn Marino there is no setter function as jump functions are all set up in
257*e4b17023SJohn Marino ipa_compute_jump_functions. */
258*e4b17023SJohn Marino
259*e4b17023SJohn Marino static inline struct ipa_jump_func *
ipa_get_ith_jump_func(struct ipa_edge_args * args,int i)260*e4b17023SJohn Marino ipa_get_ith_jump_func (struct ipa_edge_args *args, int i)
261*e4b17023SJohn Marino {
262*e4b17023SJohn Marino return VEC_index (ipa_jump_func_t, args->jump_functions, i);
263*e4b17023SJohn Marino }
264*e4b17023SJohn Marino
265*e4b17023SJohn Marino /* Vectors need to have typedefs of structures. */
266*e4b17023SJohn Marino typedef struct ipa_node_params ipa_node_params_t;
267*e4b17023SJohn Marino
268*e4b17023SJohn Marino /* Types of vectors holding the infos. */
269*e4b17023SJohn Marino DEF_VEC_O (ipa_node_params_t);
270*e4b17023SJohn Marino DEF_VEC_ALLOC_O (ipa_node_params_t, heap);
271*e4b17023SJohn Marino DEF_VEC_O (ipa_edge_args_t);
272*e4b17023SJohn Marino DEF_VEC_ALLOC_O (ipa_edge_args_t, gc);
273*e4b17023SJohn Marino
274*e4b17023SJohn Marino /* Vector where the parameter infos are actually stored. */
275*e4b17023SJohn Marino extern VEC (ipa_node_params_t, heap) *ipa_node_params_vector;
276*e4b17023SJohn Marino /* Vector where the parameter infos are actually stored. */
277*e4b17023SJohn Marino extern GTY(()) VEC (ipa_edge_args_t, gc) *ipa_edge_args_vector;
278*e4b17023SJohn Marino
279*e4b17023SJohn Marino /* Return the associated parameter/argument info corresponding to the given
280*e4b17023SJohn Marino node/edge. */
281*e4b17023SJohn Marino #define IPA_NODE_REF(NODE) (VEC_index (ipa_node_params_t, \
282*e4b17023SJohn Marino ipa_node_params_vector, (NODE)->uid))
283*e4b17023SJohn Marino #define IPA_EDGE_REF(EDGE) (VEC_index (ipa_edge_args_t, \
284*e4b17023SJohn Marino ipa_edge_args_vector, (EDGE)->uid))
285*e4b17023SJohn Marino /* This macro checks validity of index returned by
286*e4b17023SJohn Marino ipa_get_param_decl_index function. */
287*e4b17023SJohn Marino #define IS_VALID_JUMP_FUNC_INDEX(I) ((I) != -1)
288*e4b17023SJohn Marino
289*e4b17023SJohn Marino /* Creating and freeing ipa_node_params and ipa_edge_args. */
290*e4b17023SJohn Marino void ipa_create_all_node_params (void);
291*e4b17023SJohn Marino void ipa_create_all_edge_args (void);
292*e4b17023SJohn Marino void ipa_free_edge_args_substructures (struct ipa_edge_args *);
293*e4b17023SJohn Marino void ipa_free_node_params_substructures (struct ipa_node_params *);
294*e4b17023SJohn Marino void ipa_free_all_node_params (void);
295*e4b17023SJohn Marino void ipa_free_all_edge_args (void);
296*e4b17023SJohn Marino void ipa_free_all_structures_after_ipa_cp (void);
297*e4b17023SJohn Marino void ipa_free_all_structures_after_iinln (void);
298*e4b17023SJohn Marino void ipa_register_cgraph_hooks (void);
299*e4b17023SJohn Marino
300*e4b17023SJohn Marino /* This function ensures the array of node param infos is big enough to
301*e4b17023SJohn Marino accommodate a structure for all nodes and reallocates it if not. */
302*e4b17023SJohn Marino
303*e4b17023SJohn Marino static inline void
ipa_check_create_node_params(void)304*e4b17023SJohn Marino ipa_check_create_node_params (void)
305*e4b17023SJohn Marino {
306*e4b17023SJohn Marino if (!ipa_node_params_vector)
307*e4b17023SJohn Marino ipa_node_params_vector = VEC_alloc (ipa_node_params_t, heap,
308*e4b17023SJohn Marino cgraph_max_uid);
309*e4b17023SJohn Marino
310*e4b17023SJohn Marino if (VEC_length (ipa_node_params_t, ipa_node_params_vector)
311*e4b17023SJohn Marino <= (unsigned) cgraph_max_uid)
312*e4b17023SJohn Marino VEC_safe_grow_cleared (ipa_node_params_t, heap,
313*e4b17023SJohn Marino ipa_node_params_vector, cgraph_max_uid + 1);
314*e4b17023SJohn Marino }
315*e4b17023SJohn Marino
316*e4b17023SJohn Marino /* This function ensures the array of edge arguments infos is big enough to
317*e4b17023SJohn Marino accommodate a structure for all edges and reallocates it if not. */
318*e4b17023SJohn Marino
319*e4b17023SJohn Marino static inline void
ipa_check_create_edge_args(void)320*e4b17023SJohn Marino ipa_check_create_edge_args (void)
321*e4b17023SJohn Marino {
322*e4b17023SJohn Marino if (!ipa_edge_args_vector)
323*e4b17023SJohn Marino ipa_edge_args_vector = VEC_alloc (ipa_edge_args_t, gc,
324*e4b17023SJohn Marino cgraph_edge_max_uid);
325*e4b17023SJohn Marino
326*e4b17023SJohn Marino if (VEC_length (ipa_edge_args_t, ipa_edge_args_vector)
327*e4b17023SJohn Marino <= (unsigned) cgraph_edge_max_uid)
328*e4b17023SJohn Marino VEC_safe_grow_cleared (ipa_edge_args_t, gc, ipa_edge_args_vector,
329*e4b17023SJohn Marino cgraph_edge_max_uid + 1);
330*e4b17023SJohn Marino }
331*e4b17023SJohn Marino
332*e4b17023SJohn Marino /* Returns true if the array of edge infos is large enough to accommodate an
333*e4b17023SJohn Marino info for EDGE. The main purpose of this function is that debug dumping
334*e4b17023SJohn Marino function can check info availability without causing reallocations. */
335*e4b17023SJohn Marino
336*e4b17023SJohn Marino static inline bool
ipa_edge_args_info_available_for_edge_p(struct cgraph_edge * edge)337*e4b17023SJohn Marino ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge)
338*e4b17023SJohn Marino {
339*e4b17023SJohn Marino return ((unsigned) edge->uid < VEC_length (ipa_edge_args_t,
340*e4b17023SJohn Marino ipa_edge_args_vector));
341*e4b17023SJohn Marino }
342*e4b17023SJohn Marino
343*e4b17023SJohn Marino /* Function formal parameters related computations. */
344*e4b17023SJohn Marino void ipa_initialize_node_params (struct cgraph_node *node);
345*e4b17023SJohn Marino bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
346*e4b17023SJohn Marino VEC (cgraph_edge_p, heap) **new_edges);
347*e4b17023SJohn Marino
348*e4b17023SJohn Marino /* Indirect edge and binfo processing. */
349*e4b17023SJohn Marino tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
350*e4b17023SJohn Marino VEC (tree, heap) *known_csts,
351*e4b17023SJohn Marino VEC (tree, heap) *known_binfs);
352*e4b17023SJohn Marino struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree);
353*e4b17023SJohn Marino
354*e4b17023SJohn Marino /* Functions related to both. */
355*e4b17023SJohn Marino void ipa_analyze_node (struct cgraph_node *);
356*e4b17023SJohn Marino
357*e4b17023SJohn Marino /* Debugging interface. */
358*e4b17023SJohn Marino void ipa_print_node_params (FILE *, struct cgraph_node *node);
359*e4b17023SJohn Marino void ipa_print_all_params (FILE *);
360*e4b17023SJohn Marino void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
361*e4b17023SJohn Marino void ipa_print_all_jump_functions (FILE * f);
362*e4b17023SJohn Marino void ipcp_verify_propagated_values (void);
363*e4b17023SJohn Marino
364*e4b17023SJohn Marino extern alloc_pool ipcp_values_pool;
365*e4b17023SJohn Marino extern alloc_pool ipcp_sources_pool;
366*e4b17023SJohn Marino
367*e4b17023SJohn Marino /* Structure to describe transformations of formal parameters and actual
368*e4b17023SJohn Marino arguments. Each instance describes one new parameter and they are meant to
369*e4b17023SJohn Marino be stored in a vector. Additionally, most users will probably want to store
370*e4b17023SJohn Marino adjustments about parameters that are being removed altogether so that SSA
371*e4b17023SJohn Marino names belonging to them can be replaced by SSA names of an artificial
372*e4b17023SJohn Marino variable. */
373*e4b17023SJohn Marino struct ipa_parm_adjustment
374*e4b17023SJohn Marino {
375*e4b17023SJohn Marino /* The original PARM_DECL itself, helpful for processing of the body of the
376*e4b17023SJohn Marino function itself. Intended for traversing function bodies.
377*e4b17023SJohn Marino ipa_modify_formal_parameters, ipa_modify_call_arguments and
378*e4b17023SJohn Marino ipa_combine_adjustments ignore this and use base_index.
379*e4b17023SJohn Marino ipa_modify_formal_parameters actually sets this. */
380*e4b17023SJohn Marino tree base;
381*e4b17023SJohn Marino
382*e4b17023SJohn Marino /* Type of the new parameter. However, if by_ref is true, the real type will
383*e4b17023SJohn Marino be a pointer to this type. */
384*e4b17023SJohn Marino tree type;
385*e4b17023SJohn Marino
386*e4b17023SJohn Marino /* Alias refrerence type to be used in MEM_REFs when adjusting caller
387*e4b17023SJohn Marino arguments. */
388*e4b17023SJohn Marino tree alias_ptr_type;
389*e4b17023SJohn Marino
390*e4b17023SJohn Marino /* The new declaration when creating/replacing a parameter. Created by
391*e4b17023SJohn Marino ipa_modify_formal_parameters, useful for functions modifying the body
392*e4b17023SJohn Marino accordingly. */
393*e4b17023SJohn Marino tree reduction;
394*e4b17023SJohn Marino
395*e4b17023SJohn Marino /* New declaration of a substitute variable that we may use to replace all
396*e4b17023SJohn Marino non-default-def ssa names when a parm decl is going away. */
397*e4b17023SJohn Marino tree new_ssa_base;
398*e4b17023SJohn Marino
399*e4b17023SJohn Marino /* If non-NULL and the original parameter is to be removed (copy_param below
400*e4b17023SJohn Marino is NULL), this is going to be its nonlocalized vars value. */
401*e4b17023SJohn Marino tree nonlocal_value;
402*e4b17023SJohn Marino
403*e4b17023SJohn Marino /* Offset into the original parameter (for the cases when the new parameter
404*e4b17023SJohn Marino is a component of an original one). */
405*e4b17023SJohn Marino HOST_WIDE_INT offset;
406*e4b17023SJohn Marino
407*e4b17023SJohn Marino /* Zero based index of the original parameter this one is based on. (ATM
408*e4b17023SJohn Marino there is no way to insert a new parameter out of the blue because there is
409*e4b17023SJohn Marino no need but if it arises the code can be easily exteded to do so.) */
410*e4b17023SJohn Marino int base_index;
411*e4b17023SJohn Marino
412*e4b17023SJohn Marino /* This new parameter is an unmodified parameter at index base_index. */
413*e4b17023SJohn Marino unsigned copy_param : 1;
414*e4b17023SJohn Marino
415*e4b17023SJohn Marino /* This adjustment describes a parameter that is about to be removed
416*e4b17023SJohn Marino completely. Most users will probably need to book keep those so that they
417*e4b17023SJohn Marino don't leave behinfd any non default def ssa names belonging to them. */
418*e4b17023SJohn Marino unsigned remove_param : 1;
419*e4b17023SJohn Marino
420*e4b17023SJohn Marino /* The parameter is to be passed by reference. */
421*e4b17023SJohn Marino unsigned by_ref : 1;
422*e4b17023SJohn Marino };
423*e4b17023SJohn Marino
424*e4b17023SJohn Marino typedef struct ipa_parm_adjustment ipa_parm_adjustment_t;
425*e4b17023SJohn Marino DEF_VEC_O (ipa_parm_adjustment_t);
426*e4b17023SJohn Marino DEF_VEC_ALLOC_O (ipa_parm_adjustment_t, heap);
427*e4b17023SJohn Marino
428*e4b17023SJohn Marino typedef VEC (ipa_parm_adjustment_t, heap) *ipa_parm_adjustment_vec;
429*e4b17023SJohn Marino
430*e4b17023SJohn Marino VEC(tree, heap) *ipa_get_vector_of_formal_parms (tree fndecl);
431*e4b17023SJohn Marino void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec,
432*e4b17023SJohn Marino const char *);
433*e4b17023SJohn Marino void ipa_modify_call_arguments (struct cgraph_edge *, gimple,
434*e4b17023SJohn Marino ipa_parm_adjustment_vec);
435*e4b17023SJohn Marino ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
436*e4b17023SJohn Marino ipa_parm_adjustment_vec);
437*e4b17023SJohn Marino void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
438*e4b17023SJohn Marino
439*e4b17023SJohn Marino void ipa_prop_write_jump_functions (cgraph_node_set set);
440*e4b17023SJohn Marino void ipa_prop_read_jump_functions (void);
441*e4b17023SJohn Marino void ipa_update_after_lto_read (void);
442*e4b17023SJohn Marino int ipa_get_param_decl_index (struct ipa_node_params *, tree);
443*e4b17023SJohn Marino tree ipa_value_from_jfunc (struct ipa_node_params *info,
444*e4b17023SJohn Marino struct ipa_jump_func *jfunc);
445*e4b17023SJohn Marino
446*e4b17023SJohn Marino
447*e4b17023SJohn Marino /* From tree-sra.c: */
448*e4b17023SJohn Marino tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,
449*e4b17023SJohn Marino gimple_stmt_iterator *, bool);
450*e4b17023SJohn Marino
451*e4b17023SJohn Marino #endif /* IPA_PROP_H */
452