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