Mercurial > hg > CbC > CbC_gcc
annotate gcc/ipa-reference.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
rev | line source |
---|---|
0 | 1 /* Callgraph based analysis of static variables. |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2 Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
0 | 3 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> |
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 /* This file gathers information about how variables whose scope is | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
22 confined to the compilation unit are used. |
0 | 23 |
24 There are two categories of information produced by this pass: | |
25 | |
26 1) The addressable (TREE_ADDRESSABLE) bit and readonly | |
27 (TREE_READONLY) bit associated with these variables is properly set | |
28 based on scanning all of the code withing the compilation unit. | |
29 | |
30 2) The transitive call site specific clobber effects are computed | |
31 for the variables whose scope is contained within this compilation | |
32 unit. | |
33 | |
34 First each function and static variable initialization is analyzed | |
35 to determine which local static variables are either read, written, | |
36 or have their address taken. Any local static that has its address | |
37 taken is removed from consideration. Once the local read and | |
38 writes are determined, a transitive closure of this information is | |
39 performed over the call graph to determine the worst case set of | |
40 side effects of each call. In later parts of the compiler, these | |
41 local and global sets are examined to make the call clobbering less | |
42 traumatic, promote some statics to registers, and improve aliasing | |
43 information. | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 |
0 | 45 Currently must be run after inlining decisions have been made since |
46 otherwise, the local sets will not contain information that is | |
47 consistent with post inlined state. The global sets are not prone | |
48 to this problem since they are by definition transitive. */ | |
49 | |
50 #include "config.h" | |
51 #include "system.h" | |
52 #include "coretypes.h" | |
53 #include "tm.h" | |
54 #include "tree.h" | |
55 #include "tree-flow.h" | |
56 #include "tree-inline.h" | |
57 #include "tree-pass.h" | |
58 #include "langhooks.h" | |
59 #include "pointer-set.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
60 #include "splay-tree.h" |
0 | 61 #include "ggc.h" |
62 #include "ipa-utils.h" | |
63 #include "ipa-reference.h" | |
64 #include "gimple.h" | |
65 #include "cgraph.h" | |
66 #include "output.h" | |
67 #include "flags.h" | |
68 #include "timevar.h" | |
69 #include "diagnostic.h" | |
70 #include "langhooks.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
71 #include "lto-streamer.h" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
72 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
73 static void add_new_function (struct cgraph_node *node, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
74 void *data ATTRIBUTE_UNUSED); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
75 static void remove_node_data (struct cgraph_node *node, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
76 void *data ATTRIBUTE_UNUSED); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
77 static void duplicate_node_data (struct cgraph_node *src, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
78 struct cgraph_node *dst, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
79 void *data ATTRIBUTE_UNUSED); |
0 | 80 |
81 /* The static variables defined within the compilation unit that are | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
82 loaded or stored directly by function that owns this structure. */ |
0 | 83 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
84 struct ipa_reference_local_vars_info_d |
0 | 85 { |
86 bitmap statics_read; | |
87 bitmap statics_written; | |
88 | |
89 /* Set when this function calls another function external to the | |
90 compilation unit or if the function has a asm clobber of memory. | |
91 In general, such calls are modeled as reading and writing all | |
92 variables (both bits on) but sometime there are attributes on the | |
93 called function so we can do better. */ | |
94 bool calls_read_all; | |
95 bool calls_write_all; | |
96 }; | |
97 | |
98 /* Statics that are read and written by some set of functions. The | |
99 local ones are based on the loads and stores local to the function. | |
100 The global ones are based on the local info as well as the | |
101 transitive closure of the functions that are called. The | |
102 structures are separated to allow the global structures to be | |
103 shared between several functions since every function within a | |
104 strongly connected component will have the same information. This | |
105 sharing saves both time and space in the computation of the vectors | |
106 as well as their translation from decl_uid form to ann_uid | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
107 form. */ |
0 | 108 |
109 struct ipa_reference_global_vars_info_d | |
110 { | |
111 bitmap statics_read; | |
112 bitmap statics_written; | |
113 bitmap statics_not_read; | |
114 bitmap statics_not_written; | |
115 }; | |
116 | |
117 typedef struct ipa_reference_local_vars_info_d *ipa_reference_local_vars_info_t; | |
118 typedef struct ipa_reference_global_vars_info_d *ipa_reference_global_vars_info_t; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
119 struct ipa_reference_vars_info_d |
0 | 120 { |
121 ipa_reference_local_vars_info_t local; | |
122 ipa_reference_global_vars_info_t global; | |
123 }; | |
124 | |
125 typedef struct ipa_reference_vars_info_d *ipa_reference_vars_info_t; | |
126 | |
127 /* This splay tree contains all of the static variables that are | |
128 being considered by the compilation level alias analysis. For | |
129 module_at_a_time compilation, this is the set of static but not | |
130 public variables. Any variables that either have their address | |
131 taken or participate in otherwise unsavory operations are deleted | |
132 from this list. */ | |
133 static GTY((param1_is(int), param2_is(tree))) | |
134 splay_tree reference_vars_to_consider; | |
135 | |
136 /* This bitmap is used to knock out the module static variables whose | |
137 addresses have been taken and passed around. */ | |
138 static bitmap module_statics_escape; | |
139 | |
140 /* This bitmap is used to knock out the module static variables that | |
141 are not readonly. */ | |
142 static bitmap module_statics_written; | |
143 | |
144 /* A bit is set for every module static we are considering. This is | |
145 ored into the local info when asm code is found that clobbers all | |
146 memory. */ | |
147 static bitmap all_module_statics; | |
148 | |
149 static struct pointer_set_t *visited_nodes; | |
150 | |
151 /* Obstack holding bitmaps of local analysis (live from analysis to | |
152 propagation) */ | |
153 static bitmap_obstack local_info_obstack; | |
154 /* Obstack holding global analysis live forever. */ | |
155 static bitmap_obstack global_info_obstack; | |
156 | |
157 /* Holders of ipa cgraph hooks: */ | |
158 static struct cgraph_node_hook_list *function_insertion_hook_holder; | |
159 static struct cgraph_2node_hook_list *node_duplication_hook_holder; | |
160 static struct cgraph_node_hook_list *node_removal_hook_holder; | |
161 | |
162 enum initialization_status_t | |
163 { | |
164 UNINITIALIZED, | |
165 RUNNING, | |
166 FINISHED | |
167 }; | |
168 | |
169 tree memory_identifier_string; | |
170 | |
171 /* Vector where the reference var infos are actually stored. */ | |
172 DEF_VEC_P (ipa_reference_vars_info_t); | |
173 DEF_VEC_ALLOC_P (ipa_reference_vars_info_t, heap); | |
174 static VEC (ipa_reference_vars_info_t, heap) *ipa_reference_vars_vector; | |
175 | |
176 /* Return the ipa_reference_vars structure starting from the cgraph NODE. */ | |
177 static inline ipa_reference_vars_info_t | |
178 get_reference_vars_info (struct cgraph_node *node) | |
179 { | |
180 if (!ipa_reference_vars_vector | |
181 || VEC_length (ipa_reference_vars_info_t, ipa_reference_vars_vector) <= (unsigned int)node->uid) | |
182 return NULL; | |
183 return VEC_index (ipa_reference_vars_info_t, ipa_reference_vars_vector, node->uid); | |
184 } | |
185 | |
186 /* Return the ipa_reference_vars structure starting from the cgraph NODE. */ | |
187 static inline void | |
188 set_reference_vars_info (struct cgraph_node *node, ipa_reference_vars_info_t info) | |
189 { | |
190 if (!ipa_reference_vars_vector | |
191 || VEC_length (ipa_reference_vars_info_t, ipa_reference_vars_vector) <= (unsigned int)node->uid) | |
192 VEC_safe_grow_cleared (ipa_reference_vars_info_t, heap, ipa_reference_vars_vector, node->uid + 1); | |
193 VEC_replace (ipa_reference_vars_info_t, ipa_reference_vars_vector, node->uid, info); | |
194 } | |
195 | |
196 /* Get a bitmap that contains all of the locally referenced static | |
197 variables for function FN. */ | |
198 static ipa_reference_local_vars_info_t | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
199 get_local_reference_vars_info (struct cgraph_node *fn) |
0 | 200 { |
201 ipa_reference_vars_info_t info = get_reference_vars_info (fn); | |
202 | |
203 if (info) | |
204 return info->local; | |
205 else | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
206 /* This phase was not run. */ |
0 | 207 return NULL; |
208 } | |
209 | |
210 /* Get a bitmap that contains all of the globally referenced static | |
211 variables for function FN. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
212 |
0 | 213 static ipa_reference_global_vars_info_t |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
214 get_global_reference_vars_info (struct cgraph_node *fn) |
0 | 215 { |
216 ipa_reference_vars_info_t info = get_reference_vars_info (fn); | |
217 | |
218 if (info) | |
219 return info->global; | |
220 else | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
221 /* This phase was not run. */ |
0 | 222 return NULL; |
223 } | |
224 | |
225 /* Return a bitmap indexed by VAR_DECL uid for the static variables | |
226 that are read during the execution of the function FN. Returns | |
227 NULL if no data is available. */ | |
228 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
229 bitmap |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
230 ipa_reference_get_read_global (struct cgraph_node *fn) |
0 | 231 { |
232 ipa_reference_global_vars_info_t g = get_global_reference_vars_info (fn); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
233 if (g) |
0 | 234 return g->statics_read; |
235 else | |
236 return NULL; | |
237 } | |
238 | |
239 /* Return a bitmap indexed by VAR_DECL uid for the static variables | |
240 that are written during the execution of the function FN. Note | |
241 that variables written may or may not be read during the function | |
242 call. Returns NULL if no data is available. */ | |
243 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
244 bitmap |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
245 ipa_reference_get_written_global (struct cgraph_node *fn) |
0 | 246 { |
247 ipa_reference_global_vars_info_t g = get_global_reference_vars_info (fn); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
248 if (g) |
0 | 249 return g->statics_written; |
250 else | |
251 return NULL; | |
252 } | |
253 | |
254 /* Return a bitmap indexed by_DECL_UID uid for the static variables | |
255 that are not read during the execution of the function FN. Returns | |
256 NULL if no data is available. */ | |
257 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
258 bitmap |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
259 ipa_reference_get_not_read_global (struct cgraph_node *fn) |
0 | 260 { |
261 ipa_reference_global_vars_info_t g = get_global_reference_vars_info (fn); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
262 if (g) |
0 | 263 return g->statics_not_read; |
264 else | |
265 return NULL; | |
266 } | |
267 | |
268 /* Return a bitmap indexed by DECL_UID uid for the static variables | |
269 that are not written during the execution of the function FN. Note | |
270 that variables written may or may not be read during the function | |
271 call. Returns NULL if no data is available. */ | |
272 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
273 bitmap |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
274 ipa_reference_get_not_written_global (struct cgraph_node *fn) |
0 | 275 { |
276 ipa_reference_global_vars_info_t g = get_global_reference_vars_info (fn); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
277 if (g) |
0 | 278 return g->statics_not_written; |
279 else | |
280 return NULL; | |
281 } | |
282 | |
283 | |
284 | |
285 /* Add VAR to all_module_statics and the two | |
286 reference_vars_to_consider* sets. */ | |
287 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
288 static inline void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
289 add_static_var (tree var) |
0 | 290 { |
291 int uid = DECL_UID (var); | |
292 gcc_assert (TREE_CODE (var) == VAR_DECL); | |
293 if (!bitmap_bit_p (all_module_statics, uid)) | |
294 { | |
295 splay_tree_insert (reference_vars_to_consider, | |
296 uid, (splay_tree_value)var); | |
297 bitmap_set_bit (all_module_statics, uid); | |
298 } | |
299 } | |
300 | |
301 /* Return true if the variable T is the right kind of static variable to | |
302 perform compilation unit scope escape analysis. */ | |
303 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
304 static inline bool |
0 | 305 has_proper_scope_for_analysis (tree t) |
306 { | |
307 /* If the variable has the "used" attribute, treat it as if it had a | |
308 been touched by the devil. */ | |
309 if (lookup_attribute ("used", DECL_ATTRIBUTES (t))) | |
310 return false; | |
311 | |
312 /* Do not want to do anything with volatile except mark any | |
313 function that uses one to be not const or pure. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
314 if (TREE_THIS_VOLATILE (t)) |
0 | 315 return false; |
316 | |
317 /* Do not care about a local automatic that is not static. */ | |
318 if (!TREE_STATIC (t) && !DECL_EXTERNAL (t)) | |
319 return false; | |
320 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
321 /* FIXME: for LTO we should include PUBLIC vars too. This is bit difficult |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
322 as summarie would need unsharing. */ |
0 | 323 if (DECL_EXTERNAL (t) || TREE_PUBLIC (t)) |
324 return false; | |
325 | |
326 /* We cannot touch decls where the type needs constructing. */ | |
327 if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (t))) | |
328 return false; | |
329 | |
330 /* This is a variable we care about. Check if we have seen it | |
331 before, and if not add it the set of variables we care about. */ | |
332 if (!bitmap_bit_p (all_module_statics, DECL_UID (t))) | |
333 add_static_var (t); | |
334 | |
335 return true; | |
336 } | |
337 | |
338 /* Mark tree T as having address taken. */ | |
339 | |
340 static void | |
341 mark_address_taken (tree x) | |
342 { | |
343 if (TREE_CODE (x) == VAR_DECL | |
344 && module_statics_escape && has_proper_scope_for_analysis (x)) | |
345 bitmap_set_bit (module_statics_escape, DECL_UID (x)); | |
346 } | |
347 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
348 /* Wrapper around mark_address_taken for the stmt walker. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
349 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
350 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
351 mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
352 void *data ATTRIBUTE_UNUSED) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
353 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
354 while (handled_component_p (addr)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
355 addr = TREE_OPERAND (addr, 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
356 mark_address_taken (addr); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
357 return false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
358 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
359 |
0 | 360 /* Mark load of T. */ |
361 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
362 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
363 mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data) |
0 | 364 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
365 ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data; |
0 | 366 if (TREE_CODE (t) == VAR_DECL |
367 && has_proper_scope_for_analysis (t)) | |
368 bitmap_set_bit (local->statics_read, DECL_UID (t)); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
369 return false; |
0 | 370 } |
371 | |
372 /* Mark store of T. */ | |
373 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
374 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
375 mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data) |
0 | 376 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
377 ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data; |
0 | 378 if (TREE_CODE (t) == VAR_DECL |
379 && has_proper_scope_for_analysis (t)) | |
380 { | |
381 if (local) | |
382 bitmap_set_bit (local->statics_written, DECL_UID (t)); | |
383 /* Mark the write so we can tell which statics are | |
384 readonly. */ | |
385 if (module_statics_written) | |
386 bitmap_set_bit (module_statics_written, DECL_UID (t)); | |
387 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
388 return false; |
0 | 389 } |
390 | |
391 /* Look for memory clobber and set read_all/write_all if present. */ | |
392 | |
393 static void | |
394 check_asm_memory_clobber (ipa_reference_local_vars_info_t local, gimple stmt) | |
395 { | |
396 size_t i; | |
397 tree op; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
398 |
0 | 399 for (i = 0; i < gimple_asm_nclobbers (stmt); i++) |
400 { | |
401 op = gimple_asm_clobber_op (stmt, i); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
402 if (simple_cst_equal(TREE_VALUE (op), memory_identifier_string) == 1) |
0 | 403 { |
404 /* Abandon all hope, ye who enter here. */ | |
405 local->calls_read_all = true; | |
406 local->calls_write_all = true; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
407 } |
0 | 408 } |
409 } | |
410 | |
411 /* Look for external calls and set read_all/write_all correspondingly. */ | |
412 | |
413 static void | |
414 check_call (ipa_reference_local_vars_info_t local, gimple stmt) | |
415 { | |
416 int flags = gimple_call_flags (stmt); | |
417 tree callee_t = gimple_call_fndecl (stmt); | |
418 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
419 /* Process indirect calls. All direct calles are handled at propagation |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
420 time. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
421 if (!callee_t) |
0 | 422 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
423 if (flags & ECF_CONST) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
424 ; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
425 else if (flags & ECF_PURE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
426 local->calls_read_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
427 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
428 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
429 local->calls_read_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
430 /* When function does not reutrn, it is safe to ignore anythign it writes |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
431 to, because the effect will never happen. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
432 if ((flags & (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
433 != (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
434 local->calls_write_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
435 } |
0 | 436 } |
437 } | |
438 | |
439 /* TP is the part of the tree currently under the microscope. | |
440 WALK_SUBTREES is part of the walk_tree api but is unused here. | |
441 DATA is cgraph_node of the function being walked. */ | |
442 | |
443 static tree | |
444 scan_stmt_for_static_refs (gimple_stmt_iterator *gsip, | |
445 struct cgraph_node *fn) | |
446 { | |
447 gimple stmt = gsi_stmt (*gsip); | |
448 ipa_reference_local_vars_info_t local = NULL; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
449 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
450 if (is_gimple_debug (stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
451 return NULL; |
0 | 452 |
453 if (fn) | |
454 local = get_reference_vars_info (fn)->local; | |
455 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
456 /* Look for direct loads and stores. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
457 walk_stmt_load_store_addr_ops (stmt, local, mark_load, mark_store, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
458 mark_address); |
0 | 459 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
460 if (is_gimple_call (stmt)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
461 check_call (local, stmt); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
462 else if (gimple_code (stmt) == GIMPLE_ASM) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
463 check_asm_memory_clobber (local, stmt); |
0 | 464 |
465 return NULL; | |
466 } | |
467 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
468 /* Call-back to scan variable initializers for static references. |
0 | 469 Called using walk_tree. */ |
470 | |
471 static tree | |
472 scan_initializer_for_static_refs (tree *tp, int *walk_subtrees, | |
473 void *data ATTRIBUTE_UNUSED) | |
474 { | |
475 tree t = *tp; | |
476 | |
477 if (TREE_CODE (t) == ADDR_EXPR) | |
478 { | |
479 mark_address_taken (get_base_var (t)); | |
480 *walk_subtrees = 0; | |
481 } | |
482 /* Save some cycles by not walking types and declaration as we | |
483 won't find anything useful there anyway. */ | |
484 else if (IS_TYPE_OR_DECL_P (*tp)) | |
485 *walk_subtrees = 0; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
486 |
0 | 487 return NULL; |
488 } | |
489 | |
490 /* Lookup the tree node for the static variable that has UID. */ | |
491 static tree | |
492 get_static_decl (int index) | |
493 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
494 splay_tree_node stn = |
0 | 495 splay_tree_lookup (reference_vars_to_consider, index); |
496 if (stn) | |
497 return (tree)stn->value; | |
498 return NULL; | |
499 } | |
500 | |
501 /* Lookup the tree node for the static variable that has UID and | |
502 convert the name to a string for debugging. */ | |
503 | |
504 static const char * | |
505 get_static_name (int index) | |
506 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
507 splay_tree_node stn = |
0 | 508 splay_tree_lookup (reference_vars_to_consider, index); |
509 if (stn) | |
510 return lang_hooks.decl_printable_name ((tree)(stn->value), 2); | |
511 return NULL; | |
512 } | |
513 | |
514 /* Or in all of the bits from every callee of X into X_GLOBAL, the caller's cycle, | |
515 bit vector. There are several cases to check to avoid the sparse | |
516 bitmap oring. */ | |
517 | |
518 static void | |
519 propagate_bits (ipa_reference_global_vars_info_t x_global, struct cgraph_node *x) | |
520 { | |
521 struct cgraph_edge *e; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
522 for (e = x->callees; e; e = e->next_callee) |
0 | 523 { |
524 struct cgraph_node *y = e->callee; | |
525 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
526 /* Only look into nodes we can propagate something. */ |
0 | 527 if (cgraph_function_body_availability (e->callee) > AVAIL_OVERWRITABLE) |
528 { | |
529 if (get_reference_vars_info (y)) | |
530 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
531 ipa_reference_vars_info_t y_info |
0 | 532 = get_reference_vars_info (y); |
533 ipa_reference_global_vars_info_t y_global = y_info->global; | |
534 | |
535 /* Calls in current cycle do not have global computed yet. */ | |
536 if (!y_info->global) | |
537 continue; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
538 |
0 | 539 if (x_global->statics_read |
540 != all_module_statics) | |
541 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
542 if (y_global->statics_read |
0 | 543 == all_module_statics) |
544 { | |
545 BITMAP_FREE (x_global->statics_read); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
546 x_global->statics_read |
0 | 547 = all_module_statics; |
548 } | |
549 /* Skip bitmaps that are pointer equal to node's bitmap | |
550 (no reason to spin within the cycle). */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
551 else if (x_global->statics_read |
0 | 552 != y_global->statics_read) |
553 bitmap_ior_into (x_global->statics_read, | |
554 y_global->statics_read); | |
555 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
556 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
557 if (x_global->statics_written |
0 | 558 != all_module_statics) |
559 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
560 if (y_global->statics_written |
0 | 561 == all_module_statics) |
562 { | |
563 BITMAP_FREE (x_global->statics_written); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
564 x_global->statics_written |
0 | 565 = all_module_statics; |
566 } | |
567 /* Skip bitmaps that are pointer equal to node's bitmap | |
568 (no reason to spin within the cycle). */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
569 else if (x_global->statics_written |
0 | 570 != y_global->statics_written) |
571 bitmap_ior_into (x_global->statics_written, | |
572 y_global->statics_written); | |
573 } | |
574 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
575 else |
0 | 576 gcc_unreachable (); |
577 } | |
578 } | |
579 } | |
580 | |
581 /* The init routine for analyzing global static variable usage. See | |
582 comments at top for description. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
583 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
584 ipa_init (void) |
0 | 585 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
586 static bool init_p = false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
587 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
588 if (init_p) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
589 return; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
590 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
591 init_p = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
592 |
0 | 593 memory_identifier_string = build_string(7, "memory"); |
594 | |
595 reference_vars_to_consider = | |
596 splay_tree_new_ggc (splay_tree_compare_ints); | |
597 | |
598 bitmap_obstack_initialize (&local_info_obstack); | |
599 bitmap_obstack_initialize (&global_info_obstack); | |
600 module_statics_escape = BITMAP_ALLOC (&local_info_obstack); | |
601 module_statics_written = BITMAP_ALLOC (&local_info_obstack); | |
602 all_module_statics = BITMAP_ALLOC (&global_info_obstack); | |
603 | |
604 /* There are some shared nodes, in particular the initializers on | |
605 static declarations. We do not need to scan them more than once | |
606 since all we would be interested in are the addressof | |
607 operations. */ | |
608 visited_nodes = pointer_set_create (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
609 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
610 function_insertion_hook_holder = |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
611 cgraph_add_function_insertion_hook (&add_new_function, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
612 node_removal_hook_holder = |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
613 cgraph_add_node_removal_hook (&remove_node_data, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
614 node_duplication_hook_holder = |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
615 cgraph_add_node_duplication_hook (&duplicate_node_data, NULL); |
0 | 616 } |
617 | |
618 /* Check out the rhs of a static or global initialization VNODE to see | |
619 if any of them contain addressof operations. Note that some of | |
620 these variables may not even be referenced in the code in this | |
621 compilation unit but their right hand sides may contain references | |
622 to variables defined within this unit. */ | |
623 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
624 static void |
0 | 625 analyze_variable (struct varpool_node *vnode) |
626 { | |
627 struct walk_stmt_info wi; | |
628 tree global = vnode->decl; | |
629 | |
630 memset (&wi, 0, sizeof (wi)); | |
631 wi.pset = visited_nodes; | |
632 walk_tree (&DECL_INITIAL (global), scan_initializer_for_static_refs, | |
633 &wi, wi.pset); | |
634 } | |
635 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
636 |
0 | 637 /* Set up the persistent info for FN. */ |
638 | |
639 static ipa_reference_local_vars_info_t | |
640 init_function_info (struct cgraph_node *fn) | |
641 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
642 ipa_reference_vars_info_t info |
0 | 643 = XCNEW (struct ipa_reference_vars_info_d); |
644 ipa_reference_local_vars_info_t l | |
645 = XCNEW (struct ipa_reference_local_vars_info_d); | |
646 | |
647 /* Add the info to the tree's annotation. */ | |
648 set_reference_vars_info (fn, info); | |
649 | |
650 info->local = l; | |
651 l->statics_read = BITMAP_ALLOC (&local_info_obstack); | |
652 l->statics_written = BITMAP_ALLOC (&local_info_obstack); | |
653 | |
654 return l; | |
655 } | |
656 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
657 |
0 | 658 /* This is the main routine for finding the reference patterns for |
659 global variables within a function FN. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
660 |
0 | 661 static void |
662 analyze_function (struct cgraph_node *fn) | |
663 { | |
664 tree decl = fn->decl; | |
665 struct function *this_cfun = DECL_STRUCT_FUNCTION (decl); | |
666 basic_block this_block; | |
667 #ifdef ENABLE_CHECKING | |
668 tree step; | |
669 #endif | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
670 ipa_reference_local_vars_info_t local; |
0 | 671 |
672 if (dump_file) | |
673 fprintf (dump_file, "\n local analysis of %s\n", cgraph_node_name (fn)); | |
674 | |
675 push_cfun (DECL_STRUCT_FUNCTION (decl)); | |
676 current_function_decl = decl; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
677 |
0 | 678 init_function_info (fn); |
679 FOR_EACH_BB_FN (this_block, this_cfun) | |
680 { | |
681 gimple_stmt_iterator gsi; | |
682 gimple phi; | |
683 tree op; | |
684 use_operand_p use; | |
685 ssa_op_iter iter; | |
686 | |
687 /* Find the addresses taken in phi node arguments. */ | |
688 for (gsi = gsi_start_phis (this_block); | |
689 !gsi_end_p (gsi); | |
690 gsi_next (&gsi)) | |
691 { | |
692 phi = gsi_stmt (gsi); | |
693 FOR_EACH_PHI_ARG (use, phi, iter, SSA_OP_USE) | |
694 { | |
695 op = USE_FROM_PTR (use); | |
696 if (TREE_CODE (op) == ADDR_EXPR) | |
697 mark_address_taken (get_base_var (op)); | |
698 } | |
699 } | |
700 | |
701 for (gsi = gsi_start_bb (this_block); !gsi_end_p (gsi); gsi_next (&gsi)) | |
702 scan_stmt_for_static_refs (&gsi, fn); | |
703 } | |
704 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
705 local = get_reference_vars_info (fn)->local; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
706 if ((flags_from_decl_or_type (decl) & (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
707 == (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
708 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
709 local->calls_write_all = false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
710 bitmap_clear (local->statics_written); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
711 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
712 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
713 /* Free bitmaps of direct references if we can not use them anyway. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
714 if (local->calls_write_all) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
715 BITMAP_FREE (local->statics_written); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
716 if (local->calls_read_all) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
717 BITMAP_FREE (local->statics_read); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
718 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
719 |
0 | 720 #ifdef ENABLE_CHECKING |
721 /* Verify that all local initializers was expanded by gimplifier. */ | |
722 for (step = DECL_STRUCT_FUNCTION (decl)->local_decls; | |
723 step; | |
724 step = TREE_CHAIN (step)) | |
725 { | |
726 tree var = TREE_VALUE (step); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
727 if (TREE_CODE (var) == VAR_DECL |
0 | 728 && DECL_INITIAL (var) |
729 && !TREE_STATIC (var)) | |
730 gcc_unreachable (); | |
731 } | |
732 #endif | |
733 pop_cfun (); | |
734 current_function_decl = NULL; | |
735 } | |
736 | |
737 /* Remove local data associated with function FN. */ | |
738 static void | |
739 clean_function_local_data (struct cgraph_node *fn) | |
740 { | |
741 ipa_reference_vars_info_t info = get_reference_vars_info (fn); | |
742 ipa_reference_local_vars_info_t l = info->local; | |
743 if (l) | |
744 { | |
745 if (l->statics_read | |
746 && l->statics_read != all_module_statics) | |
747 BITMAP_FREE (l->statics_read); | |
748 if (l->statics_written | |
749 &&l->statics_written != all_module_statics) | |
750 BITMAP_FREE (l->statics_written); | |
751 free (l); | |
752 info->local = NULL; | |
753 } | |
754 } | |
755 | |
756 /* Remove all data associated with function FN. */ | |
757 | |
758 static void | |
759 clean_function (struct cgraph_node *fn) | |
760 { | |
761 ipa_reference_vars_info_t info = get_reference_vars_info (fn); | |
762 ipa_reference_global_vars_info_t g = info->global; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
763 |
0 | 764 clean_function_local_data (fn); |
765 if (g) | |
766 { | |
767 if (g->statics_read | |
768 && g->statics_read != all_module_statics) | |
769 BITMAP_FREE (g->statics_read); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
770 |
0 | 771 if (g->statics_written |
772 && g->statics_written != all_module_statics) | |
773 BITMAP_FREE (g->statics_written); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
774 |
0 | 775 if (g->statics_not_read |
776 && g->statics_not_read != all_module_statics) | |
777 BITMAP_FREE (g->statics_not_read); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
778 |
0 | 779 if (g->statics_not_written |
780 && g->statics_not_written != all_module_statics) | |
781 BITMAP_FREE (g->statics_not_written); | |
782 free (g); | |
783 info->global = NULL; | |
784 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
785 |
0 | 786 free (get_reference_vars_info (fn)); |
787 set_reference_vars_info (fn, NULL); | |
788 } | |
789 | |
790 /* Called when new function is inserted to callgraph late. */ | |
791 static void | |
792 add_new_function (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) | |
793 { | |
794 /* There are some shared nodes, in particular the initializers on | |
795 static declarations. We do not need to scan them more than once | |
796 since all we would be interested in are the addressof | |
797 operations. */ | |
798 analyze_function (node); | |
799 visited_nodes = NULL; | |
800 } | |
801 | |
802 static bitmap | |
803 copy_local_bitmap (bitmap src) | |
804 { | |
805 bitmap dst; | |
806 if (!src) | |
807 return NULL; | |
808 if (src == all_module_statics) | |
809 return all_module_statics; | |
810 dst = BITMAP_ALLOC (&local_info_obstack); | |
811 bitmap_copy (dst, src); | |
812 return dst; | |
813 } | |
814 | |
815 static bitmap | |
816 copy_global_bitmap (bitmap src) | |
817 { | |
818 bitmap dst; | |
819 if (!src) | |
820 return NULL; | |
821 if (src == all_module_statics) | |
822 return all_module_statics; | |
823 dst = BITMAP_ALLOC (&global_info_obstack); | |
824 bitmap_copy (dst, src); | |
825 return dst; | |
826 } | |
827 | |
828 /* Called when new clone is inserted to callgraph late. */ | |
829 | |
830 static void | |
831 duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst, | |
832 void *data ATTRIBUTE_UNUSED) | |
833 { | |
834 ipa_reference_global_vars_info_t ginfo; | |
835 ipa_reference_local_vars_info_t linfo; | |
836 ipa_reference_global_vars_info_t dst_ginfo; | |
837 ipa_reference_local_vars_info_t dst_linfo; | |
838 | |
839 ginfo = get_global_reference_vars_info (src); | |
840 linfo = get_local_reference_vars_info (src); | |
841 if (!linfo && !ginfo) | |
842 return; | |
843 init_function_info (dst); | |
844 if (linfo) | |
845 { | |
846 dst_linfo = get_local_reference_vars_info (dst); | |
847 dst_linfo->statics_read = copy_local_bitmap (linfo->statics_read); | |
848 dst_linfo->statics_written = copy_local_bitmap (linfo->statics_written); | |
849 dst_linfo->calls_read_all = linfo->calls_read_all; | |
850 dst_linfo->calls_write_all = linfo->calls_write_all; | |
851 } | |
852 if (ginfo) | |
853 { | |
854 get_reference_vars_info (dst)->global = XCNEW (struct ipa_reference_global_vars_info_d); | |
855 dst_ginfo = get_global_reference_vars_info (dst); | |
856 dst_ginfo->statics_read = copy_global_bitmap (ginfo->statics_read); | |
857 dst_ginfo->statics_written = copy_global_bitmap (ginfo->statics_written); | |
858 dst_ginfo->statics_not_read = copy_global_bitmap (ginfo->statics_not_read); | |
859 dst_ginfo->statics_not_written = copy_global_bitmap (ginfo->statics_not_written); | |
860 } | |
861 } | |
862 | |
863 /* Called when node is removed. */ | |
864 | |
865 static void | |
866 remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) | |
867 { | |
868 if (get_reference_vars_info (node)) | |
869 clean_function (node); | |
870 } | |
871 | |
872 /* Analyze each function in the cgraph to see which global or statics | |
873 are read or written. */ | |
874 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
875 static void |
0 | 876 generate_summary (void) |
877 { | |
878 struct cgraph_node *node; | |
879 struct varpool_node *vnode; | |
880 unsigned int index; | |
881 bitmap_iterator bi; | |
882 bitmap module_statics_readonly; | |
883 bitmap bm_temp; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
884 |
0 | 885 ipa_init (); |
886 module_statics_readonly = BITMAP_ALLOC (&local_info_obstack); | |
887 bm_temp = BITMAP_ALLOC (&local_info_obstack); | |
888 | |
889 /* Process all of the variables first. */ | |
890 FOR_EACH_STATIC_INITIALIZER (vnode) | |
891 analyze_variable (vnode); | |
892 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
893 /* Process all of the functions next. |
0 | 894 |
895 We do not want to process any of the clones so we check that this | |
896 is a master clone. However, we do need to process any | |
897 AVAIL_OVERWRITABLE functions (these are never clones) because | |
898 they may cause a static variable to escape. The code that can | |
899 overwrite such a function cannot access the statics because it | |
900 would not be in the same compilation unit. When the analysis is | |
901 finished, the computed information of these AVAIL_OVERWRITABLE is | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
902 replaced with worst case info. |
0 | 903 */ |
904 for (node = cgraph_nodes; node; node = node->next) | |
905 if (cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE) | |
906 analyze_function (node); | |
907 | |
908 pointer_set_destroy (visited_nodes); | |
909 visited_nodes = NULL; | |
910 | |
911 /* Prune out the variables that were found to behave badly | |
912 (i.e. have their address taken). */ | |
913 EXECUTE_IF_SET_IN_BITMAP (module_statics_escape, 0, index, bi) | |
914 { | |
915 splay_tree_remove (reference_vars_to_consider, index); | |
916 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
917 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
918 bitmap_and_compl_into (all_module_statics, |
0 | 919 module_statics_escape); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
920 |
0 | 921 bitmap_and_compl (module_statics_readonly, all_module_statics, |
922 module_statics_written); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
923 |
0 | 924 /* If the address is not taken, we can unset the addressable bit |
925 on this variable. */ | |
926 EXECUTE_IF_SET_IN_BITMAP (all_module_statics, 0, index, bi) | |
927 { | |
928 tree var = get_static_decl (index); | |
929 TREE_ADDRESSABLE (var) = 0; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
930 if (dump_file) |
0 | 931 fprintf (dump_file, "Not TREE_ADDRESSABLE var %s\n", |
932 get_static_name (index)); | |
933 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
934 |
0 | 935 /* If the variable is never written, we can set the TREE_READONLY |
936 flag. Additionally if it has a DECL_INITIAL that is made up of | |
937 constants we can treat the entire global as a constant. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
938 |
0 | 939 bitmap_and_compl (module_statics_readonly, all_module_statics, |
940 module_statics_written); | |
941 EXECUTE_IF_SET_IN_BITMAP (module_statics_readonly, 0, index, bi) | |
942 { | |
943 tree var = get_static_decl (index); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
944 |
0 | 945 /* Ignore variables in named sections - changing TREE_READONLY |
946 changes the section flags, potentially causing conflicts with | |
947 other variables in the same named section. */ | |
948 if (DECL_SECTION_NAME (var) == NULL_TREE) | |
949 { | |
950 TREE_READONLY (var) = 1; | |
951 if (dump_file) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
952 fprintf (dump_file, "read-only var %s\n", |
0 | 953 get_static_name (index)); |
954 } | |
955 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
956 |
0 | 957 BITMAP_FREE(module_statics_escape); |
958 BITMAP_FREE(module_statics_written); | |
959 module_statics_escape = NULL; | |
960 module_statics_written = NULL; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
961 |
0 | 962 if (dump_file) |
963 EXECUTE_IF_SET_IN_BITMAP (all_module_statics, 0, index, bi) | |
964 { | |
965 fprintf (dump_file, "\nPromotable global:%s", | |
966 get_static_name (index)); | |
967 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
968 |
0 | 969 for (node = cgraph_nodes; node; node = node->next) |
970 if (cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE) | |
971 { | |
972 ipa_reference_local_vars_info_t l; | |
973 l = get_reference_vars_info (node)->local; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
974 |
0 | 975 /* Any variables that are not in all_module_statics are |
976 removed from the local maps. This will include all of the | |
977 variables that were found to escape in the function | |
978 scanning. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
979 if (l->statics_read) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
980 bitmap_and_into (l->statics_read, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
981 all_module_statics); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
982 if (l->statics_written) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
983 bitmap_and_into (l->statics_written, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
984 all_module_statics); |
0 | 985 } |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
986 |
0 | 987 BITMAP_FREE(module_statics_readonly); |
988 BITMAP_FREE(bm_temp); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
989 |
0 | 990 if (dump_file) |
991 for (node = cgraph_nodes; node; node = node->next) | |
992 if (cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE) | |
993 { | |
994 ipa_reference_local_vars_info_t l; | |
995 unsigned int index; | |
996 bitmap_iterator bi; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
997 |
0 | 998 l = get_reference_vars_info (node)->local; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
999 fprintf (dump_file, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1000 "\nFunction name:%s/%i:", |
0 | 1001 cgraph_node_name (node), node->uid); |
1002 fprintf (dump_file, "\n locals read: "); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1003 if (l->statics_read) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1004 EXECUTE_IF_SET_IN_BITMAP (l->statics_read, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1005 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1006 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1007 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1008 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1009 } |
0 | 1010 fprintf (dump_file, "\n locals written: "); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1011 if (l->statics_written) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1012 EXECUTE_IF_SET_IN_BITMAP (l->statics_written, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1013 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1014 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1015 fprintf(dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1016 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1017 } |
0 | 1018 if (l->calls_read_all) |
1019 fprintf (dump_file, "\n calls read all: "); | |
1020 if (l->calls_write_all) | |
1021 fprintf (dump_file, "\n calls read all: "); | |
1022 } | |
1023 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1024 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1025 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1026 /* Return true if we need to write summary of NODE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1027 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1028 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1029 write_node_summary_p (struct cgraph_node *node) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1030 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1031 gcc_assert (node->global.inlined_to == NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1032 return (node->analyzed |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1033 && cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1034 && get_reference_vars_info (node) != NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1035 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1036 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1037 /* Serialize the ipa info for lto. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1038 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1039 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1040 ipa_reference_write_summary (cgraph_node_set set) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1041 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1042 struct cgraph_node *node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1043 struct lto_simple_output_block *ob |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1044 = lto_create_simple_output_block (LTO_section_ipa_reference); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1045 unsigned int count = 0; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1046 cgraph_node_set_iterator csi; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1047 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1048 for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1049 if (write_node_summary_p (csi_node (csi))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1050 count++; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1051 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1052 lto_output_uleb128_stream (ob->main_stream, count); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1053 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1054 /* Process all of the functions. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1055 for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1056 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1057 node = csi_node (csi); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1058 if (write_node_summary_p (node)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1059 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1060 ipa_reference_local_vars_info_t l |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1061 = get_reference_vars_info (node)->local; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1062 unsigned int index; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1063 bitmap_iterator bi; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1064 lto_cgraph_encoder_t encoder; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1065 int node_ref; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1066 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1067 encoder = ob->decl_state->cgraph_node_encoder; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1068 node_ref = lto_cgraph_encoder_encode (encoder, node); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1069 lto_output_uleb128_stream (ob->main_stream, node_ref); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1070 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1071 /* Stream out the statics read. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1072 if (l->calls_read_all) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1073 lto_output_sleb128_stream (ob->main_stream, -1); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1074 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1075 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1076 lto_output_sleb128_stream (ob->main_stream, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1077 bitmap_count_bits (l->statics_read)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1078 EXECUTE_IF_SET_IN_BITMAP (l->statics_read, 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1079 lto_output_var_decl_index(ob->decl_state, ob->main_stream, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1080 get_static_decl (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1081 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1082 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1083 /* Stream out the statics written. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1084 if (l->calls_write_all) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1085 lto_output_sleb128_stream (ob->main_stream, -1); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1086 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1087 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1088 lto_output_sleb128_stream (ob->main_stream, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1089 bitmap_count_bits (l->statics_written)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1090 EXECUTE_IF_SET_IN_BITMAP (l->statics_written, 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1091 lto_output_var_decl_index(ob->decl_state, ob->main_stream, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1092 get_static_decl (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1093 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1094 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1095 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1096 lto_destroy_simple_output_block (ob); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1097 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1098 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1099 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1100 /* Deserialize the ipa info for lto. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1101 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1102 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1103 ipa_reference_read_summary (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1104 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1105 struct lto_file_decl_data ** file_data_vec |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1106 = lto_get_file_decl_data (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1107 struct lto_file_decl_data * file_data; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1108 unsigned int j = 0; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1109 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1110 ipa_init (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1111 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1112 while ((file_data = file_data_vec[j++])) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1113 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1114 const char *data; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1115 size_t len; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1116 struct lto_input_block *ib |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1117 = lto_create_simple_input_block (file_data, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1118 LTO_section_ipa_reference, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1119 &data, &len); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1120 if (ib) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1121 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1122 unsigned int i; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1123 unsigned int f_count = lto_input_uleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1124 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1125 for (i = 0; i < f_count; i++) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1126 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1127 unsigned int j, index; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1128 struct cgraph_node *node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1129 ipa_reference_local_vars_info_t l; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1130 int v_count; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1131 lto_cgraph_encoder_t encoder; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1132 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1133 index = lto_input_uleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1134 encoder = file_data->cgraph_node_encoder; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1135 node = lto_cgraph_encoder_deref (encoder, index); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1136 l = init_function_info (node); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1137 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1138 /* Set the statics read. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1139 v_count = lto_input_sleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1140 if (v_count == -1) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1141 l->calls_read_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1142 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1143 for (j = 0; j < (unsigned int)v_count; j++) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1144 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1145 unsigned int var_index = lto_input_uleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1146 tree v_decl = lto_file_decl_data_get_var_decl (file_data, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1147 var_index); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1148 add_static_var (v_decl); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1149 bitmap_set_bit (l->statics_read, DECL_UID (v_decl)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1150 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1151 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1152 /* Set the statics written. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1153 v_count = lto_input_sleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1154 if (v_count == -1) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1155 l->calls_write_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1156 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1157 for (j = 0; j < (unsigned int)v_count; j++) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1158 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1159 unsigned int var_index = lto_input_uleb128 (ib); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1160 tree v_decl = lto_file_decl_data_get_var_decl (file_data, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1161 var_index); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1162 add_static_var (v_decl); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1163 bitmap_set_bit (l->statics_written, DECL_UID (v_decl)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1164 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1165 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1166 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1167 lto_destroy_simple_input_block (file_data, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1168 LTO_section_ipa_reference, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1169 ib, data, len); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1170 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1171 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1172 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1173 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1174 |
0 | 1175 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1176 /* Set READ_ALL/WRITE_ALL based on DECL flags. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1177 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1178 read_write_all_from_decl (tree decl, bool * read_all, bool * write_all) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1179 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1180 int flags = flags_from_decl_or_type (decl); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1181 if (flags & ECF_CONST) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1182 ; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1183 else if (flags & ECF_PURE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1184 *read_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1185 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1186 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1187 /* TODO: To be able to produce sane results, we should also handle |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1188 common builtins, in particular throw. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1189 Indirect calls hsould be only counted and as inliner is replacing them |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1190 by direct calls, we can conclude if any indirect calls are left in body */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1191 *read_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1192 /* When function does not reutrn, it is safe to ignore anythign it writes |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1193 to, because the effect will never happen. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1194 if ((flags & (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1195 != (ECF_NOTHROW | ECF_NORETURN)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1196 *write_all = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1197 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1198 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1199 |
0 | 1200 /* Produce the global information by preforming a transitive closure |
1201 on the local information that was produced by ipa_analyze_function | |
1202 and ipa_analyze_variable. */ | |
1203 | |
1204 static unsigned int | |
1205 propagate (void) | |
1206 { | |
1207 struct cgraph_node *node; | |
1208 struct cgraph_node *w; | |
1209 struct cgraph_node **order = | |
1210 XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1211 int order_pos = ipa_utils_reduced_inorder (order, false, true, NULL); |
0 | 1212 int i; |
1213 | |
1214 cgraph_remove_function_insertion_hook (function_insertion_hook_holder); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1215 if (dump_file) |
0 | 1216 dump_cgraph (dump_file); |
1217 | |
1218 /* Propagate the local information thru the call graph to produce | |
1219 the global information. All the nodes within a cycle will have | |
1220 the same info so we collapse cycles first. Then we can do the | |
1221 propagation in one pass from the leaves to the roots. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1222 order_pos = ipa_utils_reduced_inorder (order, true, true, NULL); |
0 | 1223 if (dump_file) |
1224 ipa_utils_print_order(dump_file, "reduced", order, order_pos); | |
1225 | |
1226 for (i = 0; i < order_pos; i++ ) | |
1227 { | |
1228 ipa_reference_vars_info_t node_info; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1229 ipa_reference_global_vars_info_t node_g = |
0 | 1230 XCNEW (struct ipa_reference_global_vars_info_d); |
1231 ipa_reference_local_vars_info_t node_l; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1232 struct cgraph_edge *e; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1233 |
0 | 1234 bool read_all; |
1235 bool write_all; | |
1236 struct ipa_dfs_info * w_info; | |
1237 | |
1238 node = order[i]; | |
1239 node_info = get_reference_vars_info (node); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1240 if (!node_info) |
0 | 1241 { |
1242 dump_cgraph_node (stderr, node); | |
1243 dump_cgraph (stderr); | |
1244 gcc_unreachable (); | |
1245 } | |
1246 | |
1247 gcc_assert (!node_info->global); | |
1248 node_l = node_info->local; | |
1249 | |
1250 read_all = node_l->calls_read_all; | |
1251 write_all = node_l->calls_write_all; | |
1252 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1253 /* When function is overwrittable, we can not assume anything. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1254 if (cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1255 read_write_all_from_decl (node->decl, &read_all, &write_all); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1256 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1257 for (e = node->callees; e; e = e->next_callee) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1258 if (cgraph_function_body_availability (e->callee) <= AVAIL_OVERWRITABLE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1259 read_write_all_from_decl (e->callee->decl, &read_all, &write_all); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1260 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1261 |
0 | 1262 /* If any node in a cycle is calls_read_all or calls_write_all |
1263 they all are. */ | |
1264 w_info = (struct ipa_dfs_info *) node->aux; | |
1265 w = w_info->next_cycle; | |
1266 while (w) | |
1267 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1268 ipa_reference_local_vars_info_t w_l = |
0 | 1269 get_reference_vars_info (w)->local; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1270 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1271 /* When function is overwrittable, we can not assume anything. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1272 if (cgraph_function_body_availability (w) <= AVAIL_OVERWRITABLE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1273 read_write_all_from_decl (w->decl, &read_all, &write_all); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1274 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1275 for (e = w->callees; e; e = e->next_callee) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1276 if (cgraph_function_body_availability (e->callee) <= AVAIL_OVERWRITABLE) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1277 read_write_all_from_decl (e->callee->decl, &read_all, &write_all); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1278 |
0 | 1279 read_all |= w_l->calls_read_all; |
1280 write_all |= w_l->calls_write_all; | |
1281 | |
1282 w_info = (struct ipa_dfs_info *) w->aux; | |
1283 w = w_info->next_cycle; | |
1284 } | |
1285 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1286 |
0 | 1287 /* Initialized the bitmaps for the reduced nodes */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1288 if (read_all) |
0 | 1289 node_g->statics_read = all_module_statics; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1290 else |
0 | 1291 { |
1292 node_g->statics_read = BITMAP_ALLOC (&global_info_obstack); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1293 bitmap_copy (node_g->statics_read, |
0 | 1294 node_l->statics_read); |
1295 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1296 if (write_all) |
0 | 1297 node_g->statics_written = all_module_statics; |
1298 else | |
1299 { | |
1300 node_g->statics_written = BITMAP_ALLOC (&global_info_obstack); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1301 bitmap_copy (node_g->statics_written, |
0 | 1302 node_l->statics_written); |
1303 } | |
1304 | |
1305 propagate_bits (node_g, node); | |
1306 w_info = (struct ipa_dfs_info *) node->aux; | |
1307 w = w_info->next_cycle; | |
1308 while (w) | |
1309 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1310 ipa_reference_vars_info_t w_ri = |
0 | 1311 get_reference_vars_info (w); |
1312 ipa_reference_local_vars_info_t w_l = w_ri->local; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1313 |
0 | 1314 /* These global bitmaps are initialized from the local info |
1315 of all of the nodes in the region. However there is no | |
1316 need to do any work if the bitmaps were set to | |
1317 all_module_statics. */ | |
1318 if (!read_all) | |
1319 bitmap_ior_into (node_g->statics_read, | |
1320 w_l->statics_read); | |
1321 if (!write_all) | |
1322 bitmap_ior_into (node_g->statics_written, | |
1323 w_l->statics_written); | |
1324 propagate_bits (node_g, w); | |
1325 w_info = (struct ipa_dfs_info *) w->aux; | |
1326 w = w_info->next_cycle; | |
1327 } | |
1328 | |
1329 /* All nodes within a cycle have the same global info bitmaps. */ | |
1330 node_info->global = node_g; | |
1331 w_info = (struct ipa_dfs_info *) node->aux; | |
1332 w = w_info->next_cycle; | |
1333 while (w) | |
1334 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1335 ipa_reference_vars_info_t w_ri = |
0 | 1336 get_reference_vars_info (w); |
1337 | |
1338 gcc_assert (!w_ri->global); | |
1339 w_ri->global = XCNEW (struct ipa_reference_global_vars_info_d); | |
1340 w_ri->global->statics_read = copy_global_bitmap (node_g->statics_read); | |
1341 w_ri->global->statics_written = copy_global_bitmap (node_g->statics_written); | |
1342 | |
1343 w_info = (struct ipa_dfs_info *) w->aux; | |
1344 w = w_info->next_cycle; | |
1345 } | |
1346 } | |
1347 | |
1348 if (dump_file) | |
1349 { | |
1350 for (i = 0; i < order_pos; i++ ) | |
1351 { | |
1352 ipa_reference_vars_info_t node_info; | |
1353 ipa_reference_global_vars_info_t node_g; | |
1354 ipa_reference_local_vars_info_t node_l; | |
1355 unsigned int index; | |
1356 bitmap_iterator bi; | |
1357 struct ipa_dfs_info * w_info; | |
1358 | |
1359 node = order[i]; | |
1360 node_info = get_reference_vars_info (node); | |
1361 node_g = node_info->global; | |
1362 node_l = node_info->local; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1363 fprintf (dump_file, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1364 "\nFunction name:%s/%i:", |
0 | 1365 cgraph_node_name (node), node->uid); |
1366 fprintf (dump_file, "\n locals read: "); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1367 if (node_l->statics_read) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1368 EXECUTE_IF_SET_IN_BITMAP (node_l->statics_read, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1369 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1370 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1371 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1372 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1373 } |
0 | 1374 fprintf (dump_file, "\n locals written: "); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1375 if (node_l->statics_written) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1376 EXECUTE_IF_SET_IN_BITMAP (node_l->statics_written, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1377 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1378 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1379 fprintf(dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1380 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1381 } |
0 | 1382 |
1383 w_info = (struct ipa_dfs_info *) node->aux; | |
1384 w = w_info->next_cycle; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1385 while (w) |
0 | 1386 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1387 ipa_reference_vars_info_t w_ri = |
0 | 1388 get_reference_vars_info (w); |
1389 ipa_reference_local_vars_info_t w_l = w_ri->local; | |
1390 fprintf (dump_file, "\n next cycle: %s/%i ", | |
1391 cgraph_node_name (w), w->uid); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1392 fprintf (dump_file, "\n locals read: "); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1393 if (w_l->statics_read) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1394 EXECUTE_IF_SET_IN_BITMAP (w_l->statics_read, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1395 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1396 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1397 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1398 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1399 } |
0 | 1400 |
1401 fprintf (dump_file, "\n locals written: "); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1402 if (w_l->statics_written) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1403 EXECUTE_IF_SET_IN_BITMAP (w_l->statics_written, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1404 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1405 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1406 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1407 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1408 } |
0 | 1409 |
1410 w_info = (struct ipa_dfs_info *) w->aux; | |
1411 w = w_info->next_cycle; | |
1412 } | |
1413 fprintf (dump_file, "\n globals read: "); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1414 if (node_g->statics_read == all_module_statics) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1415 fprintf (dump_file, "ALL"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1416 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1417 EXECUTE_IF_SET_IN_BITMAP (node_g->statics_read, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1418 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1419 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1420 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1421 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1422 } |
0 | 1423 fprintf (dump_file, "\n globals written: "); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1424 if (node_g->statics_written == all_module_statics) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1425 fprintf (dump_file, "ALL"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1426 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1427 EXECUTE_IF_SET_IN_BITMAP (node_g->statics_written, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1428 0, index, bi) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1429 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1430 fprintf (dump_file, "%s ", |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1431 get_static_name (index)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1432 } |
0 | 1433 } |
1434 } | |
1435 | |
1436 /* Cleanup. */ | |
1437 for (i = 0; i < order_pos; i++ ) | |
1438 { | |
1439 ipa_reference_vars_info_t node_info; | |
1440 ipa_reference_global_vars_info_t node_g; | |
1441 node = order[i]; | |
1442 node_info = get_reference_vars_info (node); | |
1443 node_g = node_info->global; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1444 |
0 | 1445 /* Create the complimentary sets. These are more useful for |
1446 certain apis. */ | |
1447 node_g->statics_not_read = BITMAP_ALLOC (&global_info_obstack); | |
1448 node_g->statics_not_written = BITMAP_ALLOC (&global_info_obstack); | |
1449 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1450 if (node_g->statics_read != all_module_statics) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1451 bitmap_and_compl (node_g->statics_not_read, |
0 | 1452 all_module_statics, |
1453 node_g->statics_read); | |
1454 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1455 if (node_g->statics_written |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1456 != all_module_statics) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1457 bitmap_and_compl (node_g->statics_not_written, |
0 | 1458 all_module_statics, |
1459 node_g->statics_written); | |
1460 } | |
1461 | |
1462 free (order); | |
1463 | |
1464 for (node = cgraph_nodes; node; node = node->next) | |
1465 { | |
1466 ipa_reference_vars_info_t node_info; | |
1467 node_info = get_reference_vars_info (node); | |
1468 /* Get rid of the aux information. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1469 |
0 | 1470 if (node->aux) |
1471 { | |
1472 free (node->aux); | |
1473 node->aux = NULL; | |
1474 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1475 |
0 | 1476 if (cgraph_function_body_availability (node) == AVAIL_OVERWRITABLE) |
1477 clean_function (node); | |
1478 else if (node_info) | |
1479 clean_function_local_data (node); | |
1480 } | |
1481 bitmap_obstack_release (&local_info_obstack); | |
1482 return 0; | |
1483 } | |
1484 | |
1485 | |
1486 static bool | |
1487 gate_reference (void) | |
1488 { | |
1489 return (flag_ipa_reference | |
1490 /* Don't bother doing anything if the program has errors. */ | |
1491 && !(errorcount || sorrycount)); | |
1492 } | |
1493 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1494 struct ipa_opt_pass_d pass_ipa_reference = |
0 | 1495 { |
1496 { | |
1497 IPA_PASS, | |
1498 "static-var", /* name */ | |
1499 gate_reference, /* gate */ | |
1500 propagate, /* execute */ | |
1501 NULL, /* sub */ | |
1502 NULL, /* next */ | |
1503 0, /* static_pass_number */ | |
1504 TV_IPA_REFERENCE, /* tv_id */ | |
1505 0, /* properties_required */ | |
1506 0, /* properties_provided */ | |
1507 0, /* properties_destroyed */ | |
1508 0, /* todo_flags_start */ | |
1509 0 /* todo_flags_finish */ | |
1510 }, | |
1511 generate_summary, /* generate_summary */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1512 ipa_reference_write_summary, /* write_summary */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1513 ipa_reference_read_summary, /* read_summary */ |
0 | 1514 NULL, /* function_read_summary */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1515 NULL, /* stmt_fixup */ |
0 | 1516 0, /* TODOs */ |
1517 NULL, /* function_transform */ | |
1518 NULL /* variable_transform */ | |
1519 }; | |
1520 | |
1521 #include "gt-ipa-reference.h" |