Mercurial > hg > CbC > CbC_gcc
comparison gcc/ipa-prop.h @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
1 /* Interprocedural analyses. | 1 /* Interprocedural analyses. |
2 Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. | 2 Copyright (C) 2005, 2007, 2008, 2009 |
3 Free Software Foundation, Inc. | |
3 | 4 |
4 This file is part of GCC. | 5 This file is part of GCC. |
5 | 6 |
6 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
36 argument, possibly one simple operation performed on it. | 37 argument, possibly one simple operation performed on it. |
37 Constant - a constant (is_gimple_ip_invariant)is passed as an actual | 38 Constant - a constant (is_gimple_ip_invariant)is passed as an actual |
38 argument. | 39 argument. |
39 Unknown - neither of the above. | 40 Unknown - neither of the above. |
40 | 41 |
41 IPA_JF_CONST_MEMBER_PTR stands for C++ member pointers, other constants are | 42 IPA_JF_CONST_MEMBER_PTR stands for C++ member pointers, it is a special |
42 represented with IPA_JF_CONST. | 43 constant in this regard. Other constants are represented with IPA_JF_CONST. |
43 | 44 |
44 In addition to "ordinary" pass through functions represented by | 45 IPA_JF_ANCESTOR is a special pass-through jump function, which means that |
45 IPA_JF_PASS_THROUGH, IPA_JF_ANCESTOR represents getting addresses of of | 46 the result is an address of a part of the object pointed to by the formal |
46 ancestor fields in C++ (e.g. &this_1(D)->D.1766.D.1756). */ | 47 parameter to which the function refers. It is mainly intended to represent |
48 getting addresses of of ancestor fields in C++ | |
49 (e.g. &this_1(D)->D.1766.D.1756). Note that if the original pointer is | |
50 NULL, ancestor jump function must behave like a simple pass-through. | |
51 | |
52 Other pass-through functions can either simply pass on an unchanged formal | |
53 parameter or can apply one simple binary operation to it (such jump | |
54 functions are called polynomial). | |
55 | |
56 IPA_JF_KNOWN_TYPE is a special type of an "unknown" function that applies | |
57 only to pointer parameters. It means that even though we cannot prove that | |
58 the passed value is an interprocedural constant, we still know the exact | |
59 type of the containing object which may be valuable for devirtualization. | |
60 | |
61 Jump functions are computed in ipa-prop.c by function | |
62 update_call_notes_after_inlining. Some information can be lost and jump | |
63 functions degraded accordingly when inlining, see | |
64 update_call_notes_after_inlining in the same file. */ | |
65 | |
47 enum jump_func_type | 66 enum jump_func_type |
48 { | 67 { |
49 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */ | 68 IPA_JF_UNKNOWN = 0, /* newly allocated and zeroed jump functions default */ |
50 IPA_JF_CONST, | 69 IPA_JF_KNOWN_TYPE, /* represented by field base_binfo */ |
51 IPA_JF_CONST_MEMBER_PTR, | 70 IPA_JF_CONST, /* represented by field costant */ |
52 IPA_JF_PASS_THROUGH, | 71 IPA_JF_CONST_MEMBER_PTR, /* represented by field member_cst */ |
53 IPA_JF_ANCESTOR | 72 IPA_JF_PASS_THROUGH, /* represented by field pass_through */ |
73 IPA_JF_ANCESTOR /* represented by field ancestor */ | |
74 }; | |
75 | |
76 /* Structure holding data required to describe a pass-through jump function. */ | |
77 | |
78 struct GTY(()) ipa_pass_through_data | |
79 { | |
80 /* If an operation is to be performed on the original parameter, this is the | |
81 second (constant) operand. */ | |
82 tree operand; | |
83 /* Number of the caller's formal parameter being passed. */ | |
84 int formal_id; | |
85 /* Operation that is performed on the argument before it is passed on. | |
86 NOP_EXPR means no operation. Otherwise oper must be a simple binary | |
87 arithmetic operation where the caller's parameter is the first operand and | |
88 operand field from this structure is the second one. */ | |
89 enum tree_code operation; | |
90 }; | |
91 | |
92 /* Structure holding data required to describe an ancestor pass-through | |
93 jump function. */ | |
94 | |
95 struct GTY(()) ipa_ancestor_jf_data | |
96 { | |
97 /* Offset of the field representing the ancestor. */ | |
98 HOST_WIDE_INT offset; | |
99 /* TYpe of the result. */ | |
100 tree type; | |
101 /* Number of the caller's formal parameter being passed. */ | |
102 int formal_id; | |
103 }; | |
104 | |
105 /* Structure holding a C++ member pointer constant. Holds a pointer to the | |
106 method and delta offset. */ | |
107 struct GTY(()) ipa_member_ptr_cst | |
108 { | |
109 tree pfn; | |
110 tree delta; | |
111 }; | |
112 | |
113 /* A jump function for a callsite represents the values passed as actual | |
114 arguments of the callsite. See enum jump_func_type for the various | |
115 types of jump functions supported. */ | |
116 struct GTY (()) ipa_jump_func | |
117 { | |
118 enum jump_func_type type; | |
119 /* Represents a value of a jump function. pass_through is used only in jump | |
120 function context. constant represents the actual constant in constant jump | |
121 functions and member_cst holds constant c++ member functions. */ | |
122 union jump_func_value | |
123 { | |
124 tree GTY ((tag ("IPA_JF_KNOWN_TYPE"))) base_binfo; | |
125 tree GTY ((tag ("IPA_JF_CONST"))) constant; | |
126 struct ipa_member_ptr_cst GTY ((tag ("IPA_JF_CONST_MEMBER_PTR"))) member_cst; | |
127 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through; | |
128 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor; | |
129 } GTY ((desc ("%1.type"))) value; | |
54 }; | 130 }; |
55 | 131 |
56 /* All formal parameters in the program have a lattice associated with it | 132 /* All formal parameters in the program have a lattice associated with it |
57 computed by the interprocedural stage of IPCP. | 133 computed by the interprocedural stage of IPCP. |
58 There are three main values of the lattice: | 134 There are three main values of the lattice: |
67 IPA_BOTTOM, | 143 IPA_BOTTOM, |
68 IPA_CONST_VALUE, | 144 IPA_CONST_VALUE, |
69 IPA_TOP | 145 IPA_TOP |
70 }; | 146 }; |
71 | 147 |
72 | |
73 /* Structure holding data required to describe a pass-through jump function. */ | |
74 | |
75 struct GTY(()) ipa_pass_through_data | |
76 { | |
77 /* If an operation is to be performed on the original parameter, this is the | |
78 second (constant) operand. */ | |
79 tree operand; | |
80 /* Number of the caller's formal parameter being passed. */ | |
81 int formal_id; | |
82 /* Operation that is performed on the argument before it is passed on. | |
83 NOP_EXPR means no operation. Otherwise oper must be a simple binary | |
84 arithmetic operation where the caller's parameter is the first operand and | |
85 operand field from this structure is the second one. */ | |
86 enum tree_code operation; | |
87 }; | |
88 | |
89 /* Structure holding data required to describe and ancestor pass throu | |
90 funkci. */ | |
91 | |
92 struct GTY(()) ipa_ancestor_jf_data | |
93 { | |
94 /* Offset of the field representing the ancestor. */ | |
95 HOST_WIDE_INT offset; | |
96 /* TYpe of the result. */ | |
97 tree type; | |
98 /* Number of the caller's formal parameter being passed. */ | |
99 int formal_id; | |
100 }; | |
101 | |
102 /* Structure holding a C++ member pointer constant. Holds a pointer to the | |
103 method and delta offset. */ | |
104 struct GTY(()) ipa_member_ptr_cst | |
105 { | |
106 tree pfn; | |
107 tree delta; | |
108 }; | |
109 | |
110 /* A jump function for a callsite represents the values passed as actual | |
111 arguments of the callsite. See enum jump_func_type for the various | |
112 types of jump functions supported. */ | |
113 struct GTY (()) ipa_jump_func | |
114 { | |
115 enum jump_func_type type; | |
116 /* Represents a value of a jump function. pass_through is used only in jump | |
117 function context. constant represents the actual constant in constant jump | |
118 functions and member_cst holds constant c++ member functions. */ | |
119 union jump_func_value | |
120 { | |
121 tree GTY ((tag ("IPA_JF_CONST"))) constant; | |
122 struct ipa_pass_through_data GTY ((tag ("IPA_JF_PASS_THROUGH"))) pass_through; | |
123 struct ipa_ancestor_jf_data GTY ((tag ("IPA_JF_ANCESTOR"))) ancestor; | |
124 struct ipa_member_ptr_cst GTY ((tag ("IPA_JF_CONST_MEMBER_PTR"))) member_cst; | |
125 } GTY ((desc ("%1.type"))) value; | |
126 }; | |
127 | |
128 /* All formal parameters in the program have a cval computed by | 148 /* All formal parameters in the program have a cval computed by |
129 the interprocedural stage of IPCP. See enum ipa_lattice_type for | 149 the interprocedural stage of IPCP. See enum ipa_lattice_type for |
130 the various types of lattices supported */ | 150 the various types of lattices supported */ |
131 struct ipcp_lattice | 151 struct ipcp_lattice |
132 { | 152 { |
133 enum ipa_lattice_type type; | 153 enum ipa_lattice_type type; |
134 tree constant; | 154 tree constant; |
135 }; | |
136 | |
137 /* Each instance of the following structure describes a statement that calls a | |
138 function parameter. Those referring to statements within the same function | |
139 are linked in a list. */ | |
140 struct ipa_param_call_note | |
141 { | |
142 /* Expected number of executions: calculated in profile.c. */ | |
143 gcov_type count; | |
144 /* Linked list's next */ | |
145 struct ipa_param_call_note *next; | |
146 /* Statement that contains the call to the parameter above. */ | |
147 gimple stmt; | |
148 /* When in LTO, we the above stmt will be NULL and we need an uid. */ | |
149 unsigned int lto_stmt_uid; | |
150 /* Index of the parameter that is called. */ | |
151 int formal_id; | |
152 /* Expected frequency of executions within the function. see cgraph_edge in | |
153 cgraph.h for more on this. */ | |
154 int frequency; | |
155 /* Depth of loop nest, 1 means no loop nest. */ | |
156 unsigned short int loop_nest; | |
157 /* Set when we have already found the target to be a compile time constant | |
158 and turned this into an edge or when the note was found unusable for some | |
159 reason. */ | |
160 bool processed; | |
161 }; | 155 }; |
162 | 156 |
163 /* Structure describing a single formal parameter. */ | 157 /* Structure describing a single formal parameter. */ |
164 struct ipa_param_descriptor | 158 struct ipa_param_descriptor |
165 { | 159 { |
167 struct ipcp_lattice ipcp_lattice; | 161 struct ipcp_lattice ipcp_lattice; |
168 /* PARAM_DECL of this parameter. */ | 162 /* PARAM_DECL of this parameter. */ |
169 tree decl; | 163 tree decl; |
170 /* Whether the value parameter has been modified within the function. */ | 164 /* Whether the value parameter has been modified within the function. */ |
171 unsigned modified : 1; | 165 unsigned modified : 1; |
172 /* Whether the parameter has been used as a call destination. */ | 166 /* The parameter is used. */ |
173 unsigned called : 1; | 167 unsigned used : 1; |
174 }; | 168 }; |
175 | 169 |
176 /* ipa_node_params stores information related to formal parameters of functions | 170 /* ipa_node_params stores information related to formal parameters of functions |
177 and some other information for interprocedural passes that operate on | 171 and some other information for interprocedural passes that operate on |
178 parameters (such as ipa-cp). */ | 172 parameters (such as ipa-cp). */ |
180 { | 174 { |
181 /* Number of formal parameters of this function. When set to 0, | 175 /* Number of formal parameters of this function. When set to 0, |
182 this function's parameters would not be analyzed by the different | 176 this function's parameters would not be analyzed by the different |
183 stages of IPA CP. */ | 177 stages of IPA CP. */ |
184 int param_count; | 178 int param_count; |
179 /* Whether this function is called with variable number of actual | |
180 arguments. */ | |
181 unsigned called_with_var_arguments : 1; | |
182 /* Whether the modification analysis has already been performed. */ | |
183 unsigned modification_analysis_done : 1; | |
184 /* Whether the param uses analysis has already been performed. */ | |
185 unsigned uses_analysis_done : 1; | |
186 /* Whether the function is enqueued in an ipa_func_list. */ | |
187 unsigned node_enqueued : 1; | |
185 /* Pointer to an array of structures describing individual formal | 188 /* Pointer to an array of structures describing individual formal |
186 parameters. */ | 189 parameters. */ |
187 struct ipa_param_descriptor *params; | 190 struct ipa_param_descriptor *params; |
188 /* List of structures enumerating calls to a formal parameter. */ | |
189 struct ipa_param_call_note *param_calls; | |
190 /* Only for versioned nodes this field would not be NULL, | 191 /* Only for versioned nodes this field would not be NULL, |
191 it points to the node that IPA cp cloned from. */ | 192 it points to the node that IPA cp cloned from. */ |
192 struct cgraph_node *ipcp_orig_node; | 193 struct cgraph_node *ipcp_orig_node; |
193 /* Meaningful only for original functions. Expresses the | 194 /* Meaningful only for original functions. Expresses the |
194 ratio between the direct calls and sum of all invocations of | 195 ratio between the direct calls and sum of all invocations of |
195 this function (given by profiling info). It is used to calculate | 196 this function (given by profiling info). It is used to calculate |
196 the profiling information of the original function and the versioned | 197 the profiling information of the original function and the versioned |
197 one. */ | 198 one. */ |
198 gcov_type count_scale; | 199 gcov_type count_scale; |
199 | |
200 /* Whether this function is called with variable number of actual | |
201 arguments. */ | |
202 unsigned called_with_var_arguments : 1; | |
203 /* Whether the modification analysis has already been performed. */ | |
204 unsigned modification_analysis_done : 1; | |
205 /* Whether the param uses analysis has already been performed. */ | |
206 unsigned uses_analysis_done : 1; | |
207 /* Whether the function is enqueued in an ipa_func_list. */ | |
208 unsigned node_enqueued : 1; | |
209 }; | 200 }; |
210 | 201 |
211 /* ipa_node_params access functions. Please use these to access fields that | 202 /* ipa_node_params access functions. Please use these to access fields that |
212 are or will be shared among various passes. */ | 203 are or will be shared among various passes. */ |
213 | 204 |
246 ipa_is_param_modified (struct ipa_node_params *info, int i) | 237 ipa_is_param_modified (struct ipa_node_params *info, int i) |
247 { | 238 { |
248 return info->params[i].modified; | 239 return info->params[i].modified; |
249 } | 240 } |
250 | 241 |
251 /* Return the called flag corresponding to the Ith formal parameter of the | 242 /* Return the used flag corresponding to the Ith formal parameter of |
252 function associated with INFO. Note that there is no setter method as the | 243 the function associated with INFO. */ |
253 goal is to set all flags when building the array in | |
254 ipa_detect_called_params. */ | |
255 | 244 |
256 static inline bool | 245 static inline bool |
257 ipa_is_param_called (struct ipa_node_params *info, int i) | 246 ipa_is_param_used (struct ipa_node_params *info, int i) |
258 { | 247 { |
259 return info->params[i].called; | 248 return info->params[i].used; |
260 } | 249 } |
261 | 250 |
262 /* Flag this node as having callers with variable number of arguments. */ | 251 /* Flag this node as having callers with variable number of arguments. */ |
263 | 252 |
264 static inline void | 253 static inline void |
348 void ipa_create_all_edge_args (void); | 337 void ipa_create_all_edge_args (void); |
349 void ipa_free_edge_args_substructures (struct ipa_edge_args *); | 338 void ipa_free_edge_args_substructures (struct ipa_edge_args *); |
350 void ipa_free_node_params_substructures (struct ipa_node_params *); | 339 void ipa_free_node_params_substructures (struct ipa_node_params *); |
351 void ipa_free_all_node_params (void); | 340 void ipa_free_all_node_params (void); |
352 void ipa_free_all_edge_args (void); | 341 void ipa_free_all_edge_args (void); |
353 void free_all_ipa_structures_after_ipa_cp (void); | 342 void ipa_create_all_structures_for_iinln (void); |
354 void free_all_ipa_structures_after_iinln (void); | 343 void ipa_free_all_structures_after_ipa_cp (void); |
344 void ipa_free_all_structures_after_iinln (void); | |
355 void ipa_register_cgraph_hooks (void); | 345 void ipa_register_cgraph_hooks (void); |
356 | 346 |
357 /* This function ensures the array of node param infos is big enough to | 347 /* This function ensures the array of node param infos is big enough to |
358 accommodate a structure for all nodes and reallocates it if not. */ | 348 accommodate a structure for all nodes and reallocates it if not. */ |
359 | 349 |
421 if (!info->node_enqueued) | 411 if (!info->node_enqueued) |
422 ipa_push_func_to_list_1 (wl, node, info); | 412 ipa_push_func_to_list_1 (wl, node, info); |
423 } | 413 } |
424 | 414 |
425 /* Callsite related calculations. */ | 415 /* Callsite related calculations. */ |
426 void ipa_compute_jump_functions (struct cgraph_edge *); | 416 void ipa_compute_jump_functions (struct cgraph_node *); |
427 void ipa_count_arguments (struct cgraph_edge *); | 417 void ipa_count_arguments (struct cgraph_edge *); |
428 | 418 |
429 /* Function formal parameters related computations. */ | 419 /* Function formal parameters related computations. */ |
430 void ipa_initialize_node_params (struct cgraph_node *node); | 420 void ipa_initialize_node_params (struct cgraph_node *node); |
431 void ipa_detect_param_modifications (struct cgraph_node *); | 421 void ipa_detect_param_modifications (struct cgraph_node *); |
508 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree); | 498 void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree); |
509 | 499 |
510 void ipa_prop_write_jump_functions (cgraph_node_set set); | 500 void ipa_prop_write_jump_functions (cgraph_node_set set); |
511 void ipa_prop_read_jump_functions (void); | 501 void ipa_prop_read_jump_functions (void); |
512 void ipa_update_after_lto_read (void); | 502 void ipa_update_after_lto_read (void); |
513 void lto_ipa_fixup_call_notes (struct cgraph_node *, gimple *); | |
514 | 503 |
515 /* From tree-sra.c: */ | 504 /* From tree-sra.c: */ |
516 bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool); | 505 bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool); |
517 | 506 |
518 #endif /* IPA_PROP_H */ | 507 #endif /* IPA_PROP_H */ |