Mercurial > hg > CbC > CbC_gcc
annotate gcc/passes.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | d34655255c78 1830386684a0 |
rev | line source |
---|---|
0 | 1 /* Top level of GCC compilers (cc1, cc1plus, etc.) |
131 | 2 Copyright (C) 1987-2018 Free Software Foundation, Inc. |
0 | 3 |
4 This file is part of GCC. | |
5 | |
6 GCC is free software; you can redistribute it and/or modify it under | |
7 the terms of the GNU General Public License as published by the Free | |
8 Software Foundation; either version 3, or (at your option) any later | |
9 version. | |
10 | |
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GCC; see the file COPYING3. If not see | |
18 <http://www.gnu.org/licenses/>. */ | |
19 | |
20 /* This is the top level of cc1/c++. | |
21 It parses command args, opens files, invokes the various passes | |
22 in the proper order, and counts the time used by each. | |
23 Error messages and low-level interface to malloc also handled here. */ | |
24 | |
25 #include "config.h" | |
26 #include "system.h" | |
27 #include "coretypes.h" | |
111 | 28 #include "backend.h" |
0 | 29 #include "target.h" |
111 | 30 #include "rtl.h" |
31 #include "tree.h" | |
32 #include "gimple.h" | |
33 #include "cfghooks.h" | |
34 #include "df.h" | |
35 #include "memmodel.h" | |
36 #include "tm_p.h" | |
37 #include "ssa.h" | |
38 #include "emit-rtl.h" | |
39 #include "cgraph.h" | |
40 #include "lto-streamer.h" | |
41 #include "fold-const.h" | |
42 #include "varasm.h" | |
43 #include "output.h" | |
44 #include "graph.h" | |
45 #include "debug.h" | |
0 | 46 #include "cfgloop.h" |
47 #include "value-prof.h" | |
111 | 48 #include "tree-cfg.h" |
49 #include "tree-ssa-loop-manip.h" | |
50 #include "tree-into-ssa.h" | |
51 #include "tree-dfa.h" | |
52 #include "tree-ssa.h" | |
0 | 53 #include "tree-pass.h" |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
54 #include "plugin.h" |
111 | 55 #include "ipa-utils.h" |
56 #include "tree-pretty-print.h" /* for dump_function_header */ | |
57 #include "context.h" | |
58 #include "pass_manager.h" | |
59 #include "cfgrtl.h" | |
60 #include "tree-ssa-live.h" /* For remove_unused_locals. */ | |
61 #include "tree-cfgcleanup.h" | |
62 #include "insn-addr.h" /* for INSN_ADDRESSES_ALLOC. */ | |
63 #include "diagnostic-core.h" /* for fnotice */ | |
64 #include "stringpool.h" | |
65 #include "attribs.h" | |
66 | |
67 using namespace gcc; | |
0 | 68 |
69 /* This is used for debugging. It allows the current pass to printed | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
70 from anywhere in compilation. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
71 The variable current_pass is also used for statistics and plugins. */ |
111 | 72 opt_pass *current_pass; |
73 | |
74 /* Most passes are single-instance (within their context) and thus don't | |
75 need to implement cloning, but passes that support multiple instances | |
76 *must* provide their own implementation of the clone method. | |
77 | |
78 Handle this by providing a default implemenation, but make it a fatal | |
79 error to call it. */ | |
80 | |
81 opt_pass * | |
82 opt_pass::clone () | |
83 { | |
84 internal_error ("pass %s does not support cloning", name); | |
85 } | |
86 | |
87 void | |
88 opt_pass::set_pass_param (unsigned int, bool) | |
89 { | |
90 internal_error ("pass %s needs a set_pass_param implementation to handle the" | |
91 " extra argument in NEXT_PASS", name); | |
92 } | |
93 | |
94 bool | |
95 opt_pass::gate (function *) | |
96 { | |
97 return true; | |
98 } | |
99 | |
100 unsigned int | |
101 opt_pass::execute (function *) | |
102 { | |
103 return 0; | |
104 } | |
105 | |
106 opt_pass::opt_pass (const pass_data &data, context *ctxt) | |
107 : pass_data (data), | |
108 sub (NULL), | |
109 next (NULL), | |
110 static_pass_number (0), | |
111 m_ctxt (ctxt) | |
112 { | |
113 } | |
114 | |
115 | |
116 void | |
117 pass_manager::execute_early_local_passes () | |
118 { | |
119 execute_pass_list (cfun, pass_build_ssa_passes_1->sub); | |
120 execute_pass_list (cfun, pass_local_optimization_passes_1->sub); | |
121 } | |
122 | |
123 unsigned int | |
124 pass_manager::execute_pass_mode_switching () | |
125 { | |
126 return pass_mode_switching_1->execute (cfun); | |
127 } | |
128 | |
0 | 129 |
130 /* Call from anywhere to find out what pass this is. Useful for | |
131 printing out debugging information deep inside an service | |
132 routine. */ | |
133 void | |
134 print_current_pass (FILE *file) | |
135 { | |
136 if (current_pass) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
137 fprintf (file, "current pass = %s (%d)\n", |
0 | 138 current_pass->name, current_pass->static_pass_number); |
139 else | |
140 fprintf (file, "no current pass.\n"); | |
141 } | |
142 | |
143 | |
144 /* Call from the debugger to get the current pass name. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
145 DEBUG_FUNCTION void |
0 | 146 debug_pass (void) |
147 { | |
148 print_current_pass (stderr); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
149 } |
0 | 150 |
151 | |
152 | |
153 /* Global variables used to communicate with passes. */ | |
154 bool in_gimple_form; | |
155 | |
156 | |
157 /* This is called from various places for FUNCTION_DECL, VAR_DECL, | |
158 and TYPE_DECL nodes. | |
159 | |
160 This does nothing for local (non-static) variables, unless the | |
161 variable is a register variable with DECL_ASSEMBLER_NAME set. In | |
162 that case, or if the variable is not an automatic, it sets up the | |
163 RTL and outputs any assembler code (label definition, storage | |
164 allocation and initialization). | |
165 | |
166 DECL is the declaration. TOP_LEVEL is nonzero | |
167 if this declaration is not within a function. */ | |
168 | |
169 void | |
170 rest_of_decl_compilation (tree decl, | |
171 int top_level, | |
172 int at_end) | |
173 { | |
111 | 174 bool finalize = true; |
175 | |
0 | 176 /* We deferred calling assemble_alias so that we could collect |
177 other attributes such as visibility. Emit the alias now. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
178 if (!in_lto_p) |
0 | 179 { |
180 tree alias; | |
181 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl)); | |
182 if (alias) | |
183 { | |
184 alias = TREE_VALUE (TREE_VALUE (alias)); | |
185 alias = get_identifier (TREE_STRING_POINTER (alias)); | |
111 | 186 /* A quirk of the initial implementation of aliases required that the |
187 user add "extern" to all of them. Which is silly, but now | |
188 historical. Do note that the symbol is in fact locally defined. */ | |
189 DECL_EXTERNAL (decl) = 0; | |
190 TREE_STATIC (decl) = 1; | |
0 | 191 assemble_alias (decl, alias); |
111 | 192 finalize = false; |
0 | 193 } |
194 } | |
195 | |
196 /* Can't defer this, because it needs to happen before any | |
197 later function definitions are processed. */ | |
111 | 198 if (HAS_DECL_ASSEMBLER_NAME_P (decl) |
199 && DECL_ASSEMBLER_NAME_SET_P (decl) | |
200 && DECL_REGISTER (decl)) | |
0 | 201 make_decl_rtl (decl); |
202 | |
203 /* Forward declarations for nested functions are not "external", | |
204 but we need to treat them as if they were. */ | |
205 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) | |
206 || TREE_CODE (decl) == FUNCTION_DECL) | |
207 { | |
208 timevar_push (TV_VARCONST); | |
209 | |
210 /* Don't output anything when a tentative file-scope definition | |
211 is seen. But at end of compilation, do output code for them. | |
212 | |
213 We do output all variables and rely on | |
214 callgraph code to defer them except for forward declarations | |
215 (see gcc.c-torture/compile/920624-1.c) */ | |
216 if ((at_end | |
217 || !DECL_DEFER_OUTPUT (decl) | |
218 || DECL_INITIAL (decl)) | |
111 | 219 && (!VAR_P (decl) || !DECL_HAS_VALUE_EXPR_P (decl)) |
0 | 220 && !DECL_EXTERNAL (decl)) |
221 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
222 /* When reading LTO unit, we also read varpool, so do not |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
223 rebuild it. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
224 if (in_lto_p && !at_end) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
225 ; |
111 | 226 else if (finalize && TREE_CODE (decl) != FUNCTION_DECL) |
227 varpool_node::finalize_decl (decl); | |
0 | 228 } |
229 | |
230 #ifdef ASM_FINISH_DECLARE_OBJECT | |
231 if (decl == last_assemble_variable_decl) | |
232 { | |
233 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, | |
234 top_level, at_end); | |
235 } | |
236 #endif | |
237 | |
111 | 238 /* Now that we have activated any function-specific attributes |
239 that might affect function decl, particularly align, relayout it. */ | |
240 if (TREE_CODE (decl) == FUNCTION_DECL) | |
241 targetm.target_option.relayout_function (decl); | |
242 | |
0 | 243 timevar_pop (TV_VARCONST); |
244 } | |
245 else if (TREE_CODE (decl) == TYPE_DECL | |
246 /* Like in rest_of_type_compilation, avoid confusing the debug | |
247 information machinery when there are errors. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
248 && !seen_error ()) |
0 | 249 { |
250 timevar_push (TV_SYMOUT); | |
251 debug_hooks->type_decl (decl, !top_level); | |
252 timevar_pop (TV_SYMOUT); | |
253 } | |
254 | |
255 /* Let cgraph know about the existence of variables. */ | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
256 if (in_lto_p && !at_end) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
257 ; |
111 | 258 else if (VAR_P (decl) && !DECL_EXTERNAL (decl) |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
259 && TREE_STATIC (decl)) |
111 | 260 varpool_node::get_create (decl); |
261 | |
262 /* Generate early debug for global variables. Any local variables will | |
263 be handled by either handling reachable functions from | |
264 finalize_compilation_unit (and by consequence, locally scoped | |
265 symbols), or by rest_of_type_compilation below. | |
266 | |
267 For Go's hijack of the debug_hooks to implement -fdump-go-spec, pick up | |
268 function prototypes. Go's debug_hooks will not forward them to the | |
269 wrapped hooks. */ | |
270 if (!in_lto_p | |
271 && (TREE_CODE (decl) != FUNCTION_DECL | |
272 /* This will pick up function prototypes with no bodies, | |
273 which are not visible in finalize_compilation_unit() | |
274 while iterating with FOR_EACH_*_FUNCTION through the | |
275 symbol table. */ | |
276 || (flag_dump_go_spec != NULL | |
277 && !DECL_SAVED_TREE (decl) | |
278 && DECL_STRUCT_FUNCTION (decl) == NULL)) | |
279 | |
280 /* We need to check both decl_function_context and | |
281 current_function_decl here to make sure local extern | |
282 declarations end up with the correct context. | |
283 | |
284 For local extern declarations, decl_function_context is | |
285 empty, but current_function_decl is set to the function where | |
286 the extern was declared . Without the check for | |
287 !current_function_decl below, the local extern ends up | |
288 incorrectly with a top-level context. | |
289 | |
290 For example: | |
291 | |
292 namespace S | |
293 { | |
294 int | |
295 f() | |
296 { | |
297 { | |
298 int i = 42; | |
299 { | |
300 extern int i; // Local extern declaration. | |
301 return i; | |
302 } | |
303 } | |
304 } | |
305 } | |
306 */ | |
307 && !decl_function_context (decl) | |
308 && !current_function_decl | |
309 && DECL_SOURCE_LOCATION (decl) != BUILTINS_LOCATION | |
310 && (!decl_type_context (decl) | |
311 /* If we created a varpool node for the decl make sure to | |
312 call early_global_decl. Otherwise we miss changes | |
313 introduced by member definitions like | |
314 struct A { static int staticdatamember; }; | |
315 int A::staticdatamember; | |
316 and thus have incomplete early debug and late debug | |
317 called from varpool node removal fails to handle it | |
318 properly. */ | |
319 || (finalize | |
320 && VAR_P (decl) | |
321 && TREE_STATIC (decl) && !DECL_EXTERNAL (decl))) | |
322 /* Avoid confusing the debug information machinery when there are | |
323 errors. */ | |
324 && !seen_error ()) | |
325 (*debug_hooks->early_global_decl) (decl); | |
0 | 326 } |
327 | |
328 /* Called after finishing a record, union or enumeral type. */ | |
329 | |
330 void | |
331 rest_of_type_compilation (tree type, int toplev) | |
332 { | |
333 /* Avoid confusing the debug information machinery when there are | |
334 errors. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
335 if (seen_error ()) |
0 | 336 return; |
337 | |
338 timevar_push (TV_SYMOUT); | |
339 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev); | |
340 timevar_pop (TV_SYMOUT); | |
341 } | |
342 | |
343 | |
344 | |
345 void | |
111 | 346 pass_manager:: |
0 | 347 finish_optimization_passes (void) |
348 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
349 int i; |
0 | 350 struct dump_file_info *dfi; |
351 char *name; | |
111 | 352 gcc::dump_manager *dumps = m_ctxt->get_dumps (); |
0 | 353 |
354 timevar_push (TV_DUMP); | |
355 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) | |
356 { | |
111 | 357 dumps->dump_start (pass_profile_1->static_pass_number, NULL); |
0 | 358 end_branch_prob (); |
111 | 359 dumps->dump_finish (pass_profile_1->static_pass_number); |
0 | 360 } |
361 | |
362 if (optimize > 0) | |
363 { | |
111 | 364 dumps->dump_start (pass_profile_1->static_pass_number, NULL); |
365 print_combine_total_stats (); | |
366 dumps->dump_finish (pass_profile_1->static_pass_number); | |
0 | 367 } |
368 | |
369 /* Do whatever is necessary to finish printing the graphs. */ | |
111 | 370 for (i = TDI_end; (dfi = dumps->get_dump_file_info (i)) != NULL; ++i) |
371 if (dfi->graph_dump_initialized) | |
372 { | |
373 name = dumps->get_dump_file_name (dfi); | |
374 finish_graph_dump_file (name); | |
375 free (name); | |
376 } | |
0 | 377 |
378 timevar_pop (TV_DUMP); | |
379 } | |
380 | |
111 | 381 static unsigned int |
382 execute_build_ssa_passes (void) | |
383 { | |
384 /* Once this pass (and its sub-passes) are complete, all functions | |
385 will be in SSA form. Technically this state change is happening | |
386 a tad early, since the sub-passes have not yet run, but since | |
387 none of the sub-passes are IPA passes and do not create new | |
388 functions, this is ok. We're setting this value for the benefit | |
389 of IPA passes that follow. */ | |
390 if (symtab->state < IPA_SSA) | |
391 symtab->state = IPA_SSA; | |
392 return 0; | |
393 } | |
394 | |
395 namespace { | |
396 | |
397 const pass_data pass_data_build_ssa_passes = | |
398 { | |
399 SIMPLE_IPA_PASS, /* type */ | |
400 "build_ssa_passes", /* name */ | |
401 OPTGROUP_NONE, /* optinfo_flags */ | |
402 TV_EARLY_LOCAL, /* tv_id */ | |
403 0, /* properties_required */ | |
404 0, /* properties_provided */ | |
405 0, /* properties_destroyed */ | |
406 0, /* todo_flags_start */ | |
407 /* todo_flags_finish is executed before subpases. For this reason | |
408 it makes no sense to remove unreachable functions here. */ | |
409 0, /* todo_flags_finish */ | |
410 }; | |
411 | |
412 class pass_build_ssa_passes : public simple_ipa_opt_pass | |
0 | 413 { |
111 | 414 public: |
415 pass_build_ssa_passes (gcc::context *ctxt) | |
416 : simple_ipa_opt_pass (pass_data_build_ssa_passes, ctxt) | |
417 {} | |
418 | |
419 /* opt_pass methods: */ | |
420 virtual bool gate (function *) | |
421 { | |
422 /* Don't bother doing anything if the program has errors. */ | |
423 return (!seen_error () && !in_lto_p); | |
424 } | |
425 | |
426 virtual unsigned int execute (function *) | |
427 { | |
428 return execute_build_ssa_passes (); | |
429 } | |
430 | |
431 }; // class pass_build_ssa_passes | |
432 | |
433 const pass_data pass_data_local_optimization_passes = | |
0 | 434 { |
111 | 435 SIMPLE_IPA_PASS, /* type */ |
436 "opt_local_passes", /* name */ | |
437 OPTGROUP_NONE, /* optinfo_flags */ | |
438 TV_NONE, /* tv_id */ | |
439 0, /* properties_required */ | |
440 0, /* properties_provided */ | |
441 0, /* properties_destroyed */ | |
442 0, /* todo_flags_start */ | |
443 0, /* todo_flags_finish */ | |
0 | 444 }; |
445 | |
111 | 446 class pass_local_optimization_passes : public simple_ipa_opt_pass |
447 { | |
448 public: | |
449 pass_local_optimization_passes (gcc::context *ctxt) | |
450 : simple_ipa_opt_pass (pass_data_local_optimization_passes, ctxt) | |
451 {} | |
452 | |
453 /* opt_pass methods: */ | |
454 virtual bool gate (function *) | |
455 { | |
456 /* Don't bother doing anything if the program has errors. */ | |
457 return (!seen_error () && !in_lto_p); | |
458 } | |
459 | |
460 }; // class pass_local_optimization_passes | |
461 | |
462 } // anon namespace | |
463 | |
464 simple_ipa_opt_pass * | |
465 make_pass_build_ssa_passes (gcc::context *ctxt) | |
466 { | |
467 return new pass_build_ssa_passes (ctxt); | |
468 } | |
469 | |
470 simple_ipa_opt_pass * | |
471 make_pass_local_optimization_passes (gcc::context *ctxt) | |
0 | 472 { |
111 | 473 return new pass_local_optimization_passes (ctxt); |
474 } | |
475 | |
476 namespace { | |
477 | |
478 const pass_data pass_data_all_early_optimizations = | |
479 { | |
480 GIMPLE_PASS, /* type */ | |
481 "early_optimizations", /* name */ | |
482 OPTGROUP_NONE, /* optinfo_flags */ | |
483 TV_NONE, /* tv_id */ | |
484 0, /* properties_required */ | |
485 0, /* properties_provided */ | |
486 0, /* properties_destroyed */ | |
487 0, /* todo_flags_start */ | |
488 0, /* todo_flags_finish */ | |
489 }; | |
490 | |
491 class pass_all_early_optimizations : public gimple_opt_pass | |
492 { | |
493 public: | |
494 pass_all_early_optimizations (gcc::context *ctxt) | |
495 : gimple_opt_pass (pass_data_all_early_optimizations, ctxt) | |
496 {} | |
497 | |
498 /* opt_pass methods: */ | |
499 virtual bool gate (function *) | |
500 { | |
501 return (optimize >= 1 | |
502 /* Don't bother doing anything if the program has errors. */ | |
503 && !seen_error ()); | |
504 } | |
505 | |
506 }; // class pass_all_early_optimizations | |
507 | |
508 } // anon namespace | |
509 | |
510 static gimple_opt_pass * | |
511 make_pass_all_early_optimizations (gcc::context *ctxt) | |
512 { | |
513 return new pass_all_early_optimizations (ctxt); | |
0 | 514 } |
515 | |
111 | 516 namespace { |
517 | |
518 const pass_data pass_data_all_optimizations = | |
519 { | |
520 GIMPLE_PASS, /* type */ | |
521 "*all_optimizations", /* name */ | |
522 OPTGROUP_NONE, /* optinfo_flags */ | |
523 TV_OPTIMIZE, /* tv_id */ | |
524 0, /* properties_required */ | |
525 0, /* properties_provided */ | |
526 0, /* properties_destroyed */ | |
527 0, /* todo_flags_start */ | |
528 0, /* todo_flags_finish */ | |
529 }; | |
530 | |
531 class pass_all_optimizations : public gimple_opt_pass | |
532 { | |
533 public: | |
534 pass_all_optimizations (gcc::context *ctxt) | |
535 : gimple_opt_pass (pass_data_all_optimizations, ctxt) | |
536 {} | |
537 | |
538 /* opt_pass methods: */ | |
539 virtual bool gate (function *) { return optimize >= 1 && !optimize_debug; } | |
540 | |
541 }; // class pass_all_optimizations | |
542 | |
543 } // anon namespace | |
544 | |
545 static gimple_opt_pass * | |
546 make_pass_all_optimizations (gcc::context *ctxt) | |
547 { | |
548 return new pass_all_optimizations (ctxt); | |
549 } | |
550 | |
551 namespace { | |
552 | |
553 const pass_data pass_data_all_optimizations_g = | |
554 { | |
555 GIMPLE_PASS, /* type */ | |
556 "*all_optimizations_g", /* name */ | |
557 OPTGROUP_NONE, /* optinfo_flags */ | |
558 TV_OPTIMIZE, /* tv_id */ | |
559 0, /* properties_required */ | |
560 0, /* properties_provided */ | |
561 0, /* properties_destroyed */ | |
562 0, /* todo_flags_start */ | |
563 0, /* todo_flags_finish */ | |
564 }; | |
565 | |
566 class pass_all_optimizations_g : public gimple_opt_pass | |
567 { | |
568 public: | |
569 pass_all_optimizations_g (gcc::context *ctxt) | |
570 : gimple_opt_pass (pass_data_all_optimizations_g, ctxt) | |
571 {} | |
572 | |
573 /* opt_pass methods: */ | |
574 virtual bool gate (function *) { return optimize >= 1 && optimize_debug; } | |
575 | |
576 }; // class pass_all_optimizations_g | |
577 | |
578 } // anon namespace | |
579 | |
580 static gimple_opt_pass * | |
581 make_pass_all_optimizations_g (gcc::context *ctxt) | |
582 { | |
583 return new pass_all_optimizations_g (ctxt); | |
584 } | |
585 | |
586 namespace { | |
587 | |
588 const pass_data pass_data_rest_of_compilation = | |
589 { | |
590 RTL_PASS, /* type */ | |
591 "*rest_of_compilation", /* name */ | |
592 OPTGROUP_NONE, /* optinfo_flags */ | |
593 TV_REST_OF_COMPILATION, /* tv_id */ | |
594 PROP_rtl, /* properties_required */ | |
595 0, /* properties_provided */ | |
596 0, /* properties_destroyed */ | |
597 0, /* todo_flags_start */ | |
598 0, /* todo_flags_finish */ | |
599 }; | |
600 | |
601 class pass_rest_of_compilation : public rtl_opt_pass | |
0 | 602 { |
111 | 603 public: |
604 pass_rest_of_compilation (gcc::context *ctxt) | |
605 : rtl_opt_pass (pass_data_rest_of_compilation, ctxt) | |
606 {} | |
607 | |
608 /* opt_pass methods: */ | |
609 virtual bool gate (function *) | |
610 { | |
611 /* Early return if there were errors. We can run afoul of our | |
612 consistency checks, and there's not really much point in fixing them. */ | |
613 return !(rtl_dump_and_exit || flag_syntax_only || seen_error ()); | |
614 } | |
615 | |
616 }; // class pass_rest_of_compilation | |
617 | |
618 } // anon namespace | |
619 | |
620 static rtl_opt_pass * | |
621 make_pass_rest_of_compilation (gcc::context *ctxt) | |
622 { | |
623 return new pass_rest_of_compilation (ctxt); | |
624 } | |
625 | |
626 namespace { | |
627 | |
628 const pass_data pass_data_postreload = | |
629 { | |
630 RTL_PASS, /* type */ | |
631 "*all-postreload", /* name */ | |
632 OPTGROUP_NONE, /* optinfo_flags */ | |
633 TV_POSTRELOAD, /* tv_id */ | |
634 PROP_rtl, /* properties_required */ | |
635 0, /* properties_provided */ | |
636 0, /* properties_destroyed */ | |
637 0, /* todo_flags_start */ | |
638 0, /* todo_flags_finish */ | |
0 | 639 }; |
640 | |
111 | 641 class pass_postreload : public rtl_opt_pass |
642 { | |
643 public: | |
644 pass_postreload (gcc::context *ctxt) | |
645 : rtl_opt_pass (pass_data_postreload, ctxt) | |
646 {} | |
647 | |
648 /* opt_pass methods: */ | |
649 virtual bool gate (function *) { return reload_completed; } | |
650 | |
651 }; // class pass_postreload | |
652 | |
653 } // anon namespace | |
654 | |
655 static rtl_opt_pass * | |
656 make_pass_postreload (gcc::context *ctxt) | |
657 { | |
658 return new pass_postreload (ctxt); | |
659 } | |
660 | |
661 namespace { | |
662 | |
663 const pass_data pass_data_late_compilation = | |
664 { | |
665 RTL_PASS, /* type */ | |
666 "*all-late_compilation", /* name */ | |
667 OPTGROUP_NONE, /* optinfo_flags */ | |
668 TV_LATE_COMPILATION, /* tv_id */ | |
669 PROP_rtl, /* properties_required */ | |
670 0, /* properties_provided */ | |
671 0, /* properties_destroyed */ | |
672 0, /* todo_flags_start */ | |
673 0, /* todo_flags_finish */ | |
674 }; | |
675 | |
676 class pass_late_compilation : public rtl_opt_pass | |
677 { | |
678 public: | |
679 pass_late_compilation (gcc::context *ctxt) | |
680 : rtl_opt_pass (pass_data_late_compilation, ctxt) | |
681 {} | |
682 | |
683 /* opt_pass methods: */ | |
684 virtual bool gate (function *) | |
685 { | |
686 return reload_completed || targetm.no_register_allocation; | |
687 } | |
688 | |
689 }; // class pass_late_compilation | |
690 | |
691 } // anon namespace | |
692 | |
693 static rtl_opt_pass * | |
694 make_pass_late_compilation (gcc::context *ctxt) | |
695 { | |
696 return new pass_late_compilation (ctxt); | |
697 } | |
698 | |
699 | |
0 | 700 |
701 /* Set the static pass number of pass PASS to ID and record that | |
702 in the mapping from static pass number to pass. */ | |
703 | |
111 | 704 void |
705 pass_manager:: | |
706 set_pass_for_id (int id, opt_pass *pass) | |
0 | 707 { |
708 pass->static_pass_number = id; | |
709 if (passes_by_id_size <= id) | |
710 { | |
111 | 711 passes_by_id = XRESIZEVEC (opt_pass *, passes_by_id, id + 1); |
0 | 712 memset (passes_by_id + passes_by_id_size, 0, |
713 (id + 1 - passes_by_id_size) * sizeof (void *)); | |
714 passes_by_id_size = id + 1; | |
715 } | |
716 passes_by_id[id] = pass; | |
717 } | |
718 | |
719 /* Return the pass with the static pass number ID. */ | |
720 | |
111 | 721 opt_pass * |
722 pass_manager::get_pass_for_id (int id) const | |
0 | 723 { |
724 if (id >= passes_by_id_size) | |
725 return NULL; | |
726 return passes_by_id[id]; | |
727 } | |
728 | |
729 /* Iterate over the pass tree allocating dump file numbers. We want | |
730 to do this depth first, and independent of whether the pass is | |
731 enabled or not. */ | |
732 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
733 void |
111 | 734 register_one_dump_file (opt_pass *pass) |
735 { | |
736 g->get_passes ()->register_one_dump_file (pass); | |
737 } | |
738 | |
739 void | |
740 pass_manager::register_one_dump_file (opt_pass *pass) | |
0 | 741 { |
742 char *dot_name, *flag_name, *glob_name; | |
111 | 743 const char *name, *full_name, *prefix; |
744 | |
745 /* Buffer big enough to format a 32-bit UINT_MAX into. */ | |
746 char num[11]; | |
747 dump_kind dkind; | |
748 int id; | |
131 | 749 optgroup_flags_t optgroup_flags = OPTGROUP_NONE; |
111 | 750 gcc::dump_manager *dumps = m_ctxt->get_dumps (); |
0 | 751 |
752 /* See below in next_pass_1. */ | |
753 num[0] = '\0'; | |
754 if (pass->static_pass_number != -1) | |
111 | 755 sprintf (num, "%u", ((int) pass->static_pass_number < 0 |
0 | 756 ? 1 : pass->static_pass_number)); |
757 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
758 /* The name is both used to identify the pass for the purposes of plugins, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
759 and to specify dump file name and option. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
760 The latter two might want something short which is not quite unique; for |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
761 that reason, we may have a disambiguating prefix, followed by a space |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
762 to mark the start of the following dump file name / option string. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
763 name = strchr (pass->name, ' '); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
764 name = name ? name + 1 : pass->name; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
765 dot_name = concat (".", name, num, NULL); |
0 | 766 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) |
111 | 767 { |
768 prefix = "ipa-"; | |
769 dkind = DK_ipa; | |
770 optgroup_flags |= OPTGROUP_IPA; | |
771 } | |
0 | 772 else if (pass->type == GIMPLE_PASS) |
111 | 773 { |
774 prefix = "tree-"; | |
775 dkind = DK_tree; | |
776 } | |
0 | 777 else |
111 | 778 { |
779 prefix = "rtl-"; | |
780 dkind = DK_rtl; | |
781 } | |
0 | 782 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
783 flag_name = concat (prefix, name, num, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
784 glob_name = concat (prefix, name, NULL); |
111 | 785 optgroup_flags |= pass->optinfo_flags; |
786 /* For any passes that do not have an optgroup set, and which are not | |
787 IPA passes setup above, set the optgroup to OPTGROUP_OTHER so that | |
788 any dump messages are emitted properly under -fopt-info(-optall). */ | |
789 if (optgroup_flags == OPTGROUP_NONE) | |
790 optgroup_flags = OPTGROUP_OTHER; | |
791 id = dumps->dump_register (dot_name, flag_name, glob_name, dkind, | |
792 optgroup_flags, | |
793 true); | |
0 | 794 set_pass_for_id (id, pass); |
111 | 795 full_name = concat (prefix, pass->name, num, NULL); |
796 register_pass_name (pass, full_name); | |
797 free (CONST_CAST (char *, full_name)); | |
0 | 798 } |
799 | |
111 | 800 /* Register the dump files for the pass_manager starting at PASS. */ |
801 | |
802 void | |
803 pass_manager::register_dump_files (opt_pass *pass) | |
0 | 804 { |
805 do | |
806 { | |
807 if (pass->name && pass->name[0] != '*') | |
808 register_one_dump_file (pass); | |
809 | |
810 if (pass->sub) | |
111 | 811 register_dump_files (pass->sub); |
0 | 812 |
813 pass = pass->next; | |
814 } | |
815 while (pass); | |
111 | 816 } |
817 | |
818 /* Register PASS with NAME. */ | |
819 | |
820 void | |
821 pass_manager::register_pass_name (opt_pass *pass, const char *name) | |
822 { | |
823 if (!m_name_to_pass_map) | |
824 m_name_to_pass_map = new hash_map<nofree_string_hash, opt_pass *> (256); | |
825 | |
826 if (m_name_to_pass_map->get (name)) | |
827 return; /* Ignore plugin passes. */ | |
828 | |
829 const char *unique_name = xstrdup (name); | |
830 m_name_to_pass_map->put (unique_name, pass); | |
831 } | |
832 | |
833 /* Map from pass id to canonicalized pass name. */ | |
834 | |
835 typedef const char *char_ptr; | |
836 static vec<char_ptr> pass_tab; | |
837 | |
838 /* Callback function for traversing NAME_TO_PASS_MAP. */ | |
839 | |
840 bool | |
841 passes_pass_traverse (const char *const &name, opt_pass *const &pass, void *) | |
842 { | |
843 gcc_assert (pass->static_pass_number > 0); | |
844 gcc_assert (pass_tab.exists ()); | |
845 | |
846 pass_tab[pass->static_pass_number] = name; | |
847 | |
848 return 1; | |
849 } | |
850 | |
851 /* The function traverses NAME_TO_PASS_MAP and creates a pass info | |
852 table for dumping purpose. */ | |
853 | |
854 void | |
855 pass_manager::create_pass_tab (void) const | |
856 { | |
857 if (!flag_dump_passes) | |
858 return; | |
859 | |
860 pass_tab.safe_grow_cleared (passes_by_id_size + 1); | |
861 m_name_to_pass_map->traverse <void *, passes_pass_traverse> (NULL); | |
862 } | |
863 | |
864 static bool override_gate_status (opt_pass *, tree, bool); | |
865 | |
866 /* Dump the instantiated name for PASS. IS_ON indicates if PASS | |
867 is turned on or not. */ | |
868 | |
869 static void | |
870 dump_one_pass (opt_pass *pass, int pass_indent) | |
871 { | |
872 int indent = 3 * pass_indent; | |
873 const char *pn; | |
874 bool is_on, is_really_on; | |
875 | |
876 is_on = pass->gate (cfun); | |
877 is_really_on = override_gate_status (pass, current_function_decl, is_on); | |
878 | |
879 if (pass->static_pass_number <= 0) | |
880 pn = pass->name; | |
881 else | |
882 pn = pass_tab[pass->static_pass_number]; | |
883 | |
884 fprintf (stderr, "%*s%-40s%*s:%s%s\n", indent, " ", pn, | |
885 (15 - indent < 0 ? 0 : 15 - indent), " ", | |
886 is_on ? " ON" : " OFF", | |
887 ((!is_on) == (!is_really_on) ? "" | |
888 : (is_really_on ? " (FORCED_ON)" : " (FORCED_OFF)"))); | |
0 | 889 } |
890 | |
111 | 891 /* Dump pass list PASS with indentation INDENT. */ |
892 | |
893 static void | |
894 dump_pass_list (opt_pass *pass, int indent) | |
895 { | |
896 do | |
897 { | |
898 dump_one_pass (pass, indent); | |
899 if (pass->sub) | |
900 dump_pass_list (pass->sub, indent + 1); | |
901 pass = pass->next; | |
902 } | |
903 while (pass); | |
904 } | |
905 | |
906 /* Dump all optimization passes. */ | |
907 | |
908 void | |
909 dump_passes (void) | |
910 { | |
911 g->get_passes ()->dump_passes (); | |
912 } | |
913 | |
914 void | |
915 pass_manager::dump_passes () const | |
916 { | |
917 push_dummy_function (true); | |
918 | |
919 create_pass_tab (); | |
920 | |
921 dump_pass_list (all_lowering_passes, 1); | |
922 dump_pass_list (all_small_ipa_passes, 1); | |
923 dump_pass_list (all_regular_ipa_passes, 1); | |
924 dump_pass_list (all_late_ipa_passes, 1); | |
925 dump_pass_list (all_passes, 1); | |
926 | |
927 pop_dummy_function (); | |
928 } | |
929 | |
930 /* Returns the pass with NAME. */ | |
931 | |
932 opt_pass * | |
933 pass_manager::get_pass_by_name (const char *name) | |
934 { | |
935 opt_pass **p = m_name_to_pass_map->get (name); | |
936 if (p) | |
937 return *p; | |
938 | |
939 return NULL; | |
940 } | |
941 | |
942 | |
943 /* Range [start, last]. */ | |
944 | |
945 struct uid_range | |
946 { | |
947 unsigned int start; | |
948 unsigned int last; | |
949 const char *assem_name; | |
950 struct uid_range *next; | |
951 }; | |
952 | |
953 typedef struct uid_range *uid_range_p; | |
954 | |
955 | |
956 static vec<uid_range_p> enabled_pass_uid_range_tab; | |
957 static vec<uid_range_p> disabled_pass_uid_range_tab; | |
958 | |
959 | |
960 /* Parse option string for -fdisable- and -fenable- | |
961 The syntax of the options: | |
962 | |
963 -fenable-<pass_name> | |
964 -fdisable-<pass_name> | |
965 | |
966 -fenable-<pass_name>=s1:e1,s2:e2,... | |
967 -fdisable-<pass_name>=s1:e1,s2:e2,... | |
968 */ | |
0 | 969 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
970 static void |
111 | 971 enable_disable_pass (const char *arg, bool is_enable) |
0 | 972 { |
111 | 973 opt_pass *pass; |
974 char *range_str, *phase_name; | |
975 char *argstr = xstrdup (arg); | |
976 vec<uid_range_p> *tab = 0; | |
977 | |
978 range_str = strchr (argstr,'='); | |
979 if (range_str) | |
980 { | |
981 *range_str = '\0'; | |
982 range_str++; | |
983 } | |
984 | |
985 phase_name = argstr; | |
986 if (!*phase_name) | |
987 { | |
988 if (is_enable) | |
989 error ("unrecognized option -fenable"); | |
990 else | |
991 error ("unrecognized option -fdisable"); | |
992 free (argstr); | |
993 return; | |
994 } | |
995 pass = g->get_passes ()->get_pass_by_name (phase_name); | |
996 if (!pass || pass->static_pass_number == -1) | |
997 { | |
998 if (is_enable) | |
999 error ("unknown pass %s specified in -fenable", phase_name); | |
1000 else | |
1001 error ("unknown pass %s specified in -fdisable", phase_name); | |
1002 free (argstr); | |
1003 return; | |
1004 } | |
1005 | |
1006 if (is_enable) | |
1007 tab = &enabled_pass_uid_range_tab; | |
1008 else | |
1009 tab = &disabled_pass_uid_range_tab; | |
1010 | |
1011 if ((unsigned) pass->static_pass_number >= tab->length ()) | |
1012 tab->safe_grow_cleared (pass->static_pass_number + 1); | |
1013 | |
1014 if (!range_str) | |
1015 { | |
1016 uid_range_p slot; | |
1017 uid_range_p new_range = XCNEW (struct uid_range); | |
1018 | |
1019 new_range->start = 0; | |
1020 new_range->last = (unsigned)-1; | |
1021 | |
1022 slot = (*tab)[pass->static_pass_number]; | |
1023 new_range->next = slot; | |
1024 (*tab)[pass->static_pass_number] = new_range; | |
1025 if (is_enable) | |
1026 inform (UNKNOWN_LOCATION, "enable pass %s for functions in the range " | |
1027 "of [%u, %u]", phase_name, new_range->start, new_range->last); | |
1028 else | |
1029 inform (UNKNOWN_LOCATION, "disable pass %s for functions in the range " | |
1030 "of [%u, %u]", phase_name, new_range->start, new_range->last); | |
1031 } | |
1032 else | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1033 { |
111 | 1034 char *next_range = NULL; |
1035 char *one_range = range_str; | |
1036 char *end_val = NULL; | |
1037 | |
1038 do | |
1039 { | |
1040 uid_range_p slot; | |
1041 uid_range_p new_range; | |
1042 char *invalid = NULL; | |
1043 long start; | |
1044 char *func_name = NULL; | |
1045 | |
1046 next_range = strchr (one_range, ','); | |
1047 if (next_range) | |
1048 { | |
1049 *next_range = '\0'; | |
1050 next_range++; | |
1051 } | |
1052 | |
1053 end_val = strchr (one_range, ':'); | |
1054 if (end_val) | |
1055 { | |
1056 *end_val = '\0'; | |
1057 end_val++; | |
1058 } | |
1059 start = strtol (one_range, &invalid, 10); | |
1060 if (*invalid || start < 0) | |
1061 { | |
1062 if (end_val || (one_range[0] >= '0' | |
1063 && one_range[0] <= '9')) | |
1064 { | |
1065 error ("Invalid range %s in option %s", | |
1066 one_range, | |
1067 is_enable ? "-fenable" : "-fdisable"); | |
1068 free (argstr); | |
1069 return; | |
1070 } | |
1071 func_name = one_range; | |
1072 } | |
1073 if (!end_val) | |
1074 { | |
1075 new_range = XCNEW (struct uid_range); | |
1076 if (!func_name) | |
1077 { | |
1078 new_range->start = (unsigned) start; | |
1079 new_range->last = (unsigned) start; | |
1080 } | |
1081 else | |
1082 { | |
1083 new_range->start = (unsigned) -1; | |
1084 new_range->last = (unsigned) -1; | |
1085 new_range->assem_name = xstrdup (func_name); | |
1086 } | |
1087 } | |
1088 else | |
1089 { | |
1090 long last = strtol (end_val, &invalid, 10); | |
1091 if (*invalid || last < start) | |
1092 { | |
1093 error ("Invalid range %s in option %s", | |
1094 end_val, | |
1095 is_enable ? "-fenable" : "-fdisable"); | |
1096 free (argstr); | |
1097 return; | |
1098 } | |
1099 new_range = XCNEW (struct uid_range); | |
1100 new_range->start = (unsigned) start; | |
1101 new_range->last = (unsigned) last; | |
1102 } | |
1103 | |
1104 slot = (*tab)[pass->static_pass_number]; | |
1105 new_range->next = slot; | |
1106 (*tab)[pass->static_pass_number] = new_range; | |
1107 if (is_enable) | |
1108 { | |
1109 if (new_range->assem_name) | |
1110 inform (UNKNOWN_LOCATION, | |
1111 "enable pass %s for function %s", | |
1112 phase_name, new_range->assem_name); | |
1113 else | |
1114 inform (UNKNOWN_LOCATION, | |
1115 "enable pass %s for functions in the range of [%u, %u]", | |
1116 phase_name, new_range->start, new_range->last); | |
1117 } | |
1118 else | |
1119 { | |
1120 if (new_range->assem_name) | |
1121 inform (UNKNOWN_LOCATION, | |
1122 "disable pass %s for function %s", | |
1123 phase_name, new_range->assem_name); | |
1124 else | |
1125 inform (UNKNOWN_LOCATION, | |
1126 "disable pass %s for functions in the range of [%u, %u]", | |
1127 phase_name, new_range->start, new_range->last); | |
1128 } | |
1129 | |
1130 one_range = next_range; | |
1131 } while (next_range); | |
1132 } | |
1133 | |
1134 free (argstr); | |
1135 } | |
1136 | |
1137 /* Enable pass specified by ARG. */ | |
1138 | |
1139 void | |
1140 enable_pass (const char *arg) | |
1141 { | |
1142 enable_disable_pass (arg, true); | |
1143 } | |
1144 | |
1145 /* Disable pass specified by ARG. */ | |
1146 | |
1147 void | |
1148 disable_pass (const char *arg) | |
1149 { | |
1150 enable_disable_pass (arg, false); | |
1151 } | |
1152 | |
1153 /* Returns true if PASS is explicitly enabled/disabled for FUNC. */ | |
1154 | |
1155 static bool | |
1156 is_pass_explicitly_enabled_or_disabled (opt_pass *pass, | |
1157 tree func, | |
1158 vec<uid_range_p> tab) | |
1159 { | |
1160 uid_range_p slot, range; | |
1161 int cgraph_uid; | |
1162 const char *aname = NULL; | |
1163 | |
1164 if (!tab.exists () | |
1165 || (unsigned) pass->static_pass_number >= tab.length () | |
1166 || pass->static_pass_number == -1) | |
1167 return false; | |
1168 | |
1169 slot = tab[pass->static_pass_number]; | |
1170 if (!slot) | |
1171 return false; | |
1172 | |
131 | 1173 cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0; |
111 | 1174 if (func && DECL_ASSEMBLER_NAME_SET_P (func)) |
1175 aname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func)); | |
1176 | |
1177 range = slot; | |
1178 while (range) | |
1179 { | |
1180 if ((unsigned) cgraph_uid >= range->start | |
1181 && (unsigned) cgraph_uid <= range->last) | |
1182 return true; | |
1183 if (range->assem_name && aname | |
1184 && !strcmp (range->assem_name, aname)) | |
1185 return true; | |
1186 range = range->next; | |
1187 } | |
1188 | |
1189 return false; | |
1190 } | |
1191 | |
1192 | |
1193 /* Update static_pass_number for passes (and the flag | |
1194 TODO_mark_first_instance). | |
1195 | |
1196 Passes are constructed with static_pass_number preinitialized to 0 | |
1197 | |
1198 This field is used in two different ways: initially as instance numbers | |
1199 of their kind, and then as ids within the entire pass manager. | |
1200 | |
1201 Within pass_manager::pass_manager: | |
1202 | |
1203 * In add_pass_instance(), as called by next_pass_1 in | |
1204 NEXT_PASS in init_optimization_passes | |
1205 | |
1206 * When the initial instance of a pass within a pass manager is seen, | |
1207 it is flagged, and its static_pass_number is set to -1 | |
1208 | |
1209 * On subsequent times that it is seen, the static pass number | |
1210 is decremented each time, so that if there are e.g. 4 dups, | |
1211 they have static_pass_number -4, 2, 3, 4 respectively (note | |
1212 how the initial one is negative and gives the count); these | |
1213 can be thought of as instance numbers of the specific pass | |
1214 | |
1215 * Within the register_dump_files () traversal, set_pass_for_id() | |
1216 is called on each pass, using these instance numbers to create | |
1217 dumpfile switches, and then overwriting them with a pass id, | |
1218 which are global to the whole pass manager (based on | |
1219 (TDI_end + current value of extra_dump_files_in_use) ) */ | |
1220 | |
1221 static void | |
1222 add_pass_instance (opt_pass *new_pass, bool track_duplicates, | |
1223 opt_pass *initial_pass) | |
1224 { | |
1225 /* Are we dealing with the first pass of its kind, or a clone? */ | |
1226 if (new_pass != initial_pass) | |
1227 { | |
1228 /* We're dealing with a clone. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1229 new_pass->todo_flags_start &= ~TODO_mark_first_instance; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1230 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1231 /* Indicate to register_dump_files that this pass has duplicates, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1232 and so it should rename the dump file. The first instance will |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1233 be -1, and be number of duplicates = -static_pass_number - 1. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1234 Subsequent instances will be > 0 and just the duplicate number. */ |
111 | 1235 if ((new_pass->name && new_pass->name[0] != '*') || track_duplicates) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1236 { |
111 | 1237 initial_pass->static_pass_number -= 1; |
1238 new_pass->static_pass_number = -initial_pass->static_pass_number; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1239 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1240 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1241 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1242 { |
111 | 1243 /* We're dealing with the first pass of its kind. */ |
1244 new_pass->todo_flags_start |= TODO_mark_first_instance; | |
1245 new_pass->static_pass_number = -1; | |
1246 | |
1247 invoke_plugin_callbacks (PLUGIN_NEW_PASS, new_pass); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1248 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1249 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1250 |
0 | 1251 /* Add a pass to the pass list. Duplicate the pass if it's already |
1252 in the list. */ | |
1253 | |
111 | 1254 static opt_pass ** |
1255 next_pass_1 (opt_pass **list, opt_pass *pass, opt_pass *initial_pass) | |
0 | 1256 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1257 /* Every pass should have a name so that plugins can refer to them. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1258 gcc_assert (pass->name != NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1259 |
111 | 1260 add_pass_instance (pass, false, initial_pass); |
1261 *list = pass; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1262 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1263 return &(*list)->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1264 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1265 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1266 /* List node for an inserted pass instance. We need to keep track of all |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1267 the newly-added pass instances (with 'added_pass_nodes' defined below) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1268 so that we can register their dump files after pass-positioning is finished. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1269 Registering dumping files needs to be post-processed or the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1270 static_pass_number of the opt_pass object would be modified and mess up |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1271 the dump file names of future pass instances to be added. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1272 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1273 struct pass_list_node |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1274 { |
111 | 1275 opt_pass *pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1276 struct pass_list_node *next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1277 }; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1278 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1279 static struct pass_list_node *added_pass_nodes = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1280 static struct pass_list_node *prev_added_pass_node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1281 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1282 /* Insert the pass at the proper position. Return true if the pass |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1283 is successfully added. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1284 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1285 NEW_PASS_INFO - new pass to be inserted |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1286 PASS_LIST - root of the pass list to insert the new pass to */ |
0 | 1287 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1288 static bool |
111 | 1289 position_pass (struct register_pass_info *new_pass_info, opt_pass **pass_list) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1290 { |
111 | 1291 opt_pass *pass = *pass_list, *prev_pass = NULL; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1292 bool success = false; |
0 | 1293 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1294 for ( ; pass; prev_pass = pass, pass = pass->next) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1295 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1296 /* Check if the current pass is of the same type as the new pass and |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1297 matches the name and the instance number of the reference pass. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1298 if (pass->type == new_pass_info->pass->type |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1299 && pass->name |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1300 && !strcmp (pass->name, new_pass_info->reference_pass_name) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1301 && ((new_pass_info->ref_pass_instance_number == 0) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1302 || (new_pass_info->ref_pass_instance_number == |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1303 pass->static_pass_number) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1304 || (new_pass_info->ref_pass_instance_number == 1 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1305 && pass->todo_flags_start & TODO_mark_first_instance))) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1306 { |
111 | 1307 opt_pass *new_pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1308 struct pass_list_node *new_pass_node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1309 |
111 | 1310 if (new_pass_info->ref_pass_instance_number == 0) |
1311 { | |
1312 new_pass = new_pass_info->pass->clone (); | |
1313 add_pass_instance (new_pass, true, new_pass_info->pass); | |
1314 } | |
1315 else | |
1316 { | |
1317 new_pass = new_pass_info->pass; | |
1318 add_pass_instance (new_pass, true, new_pass); | |
1319 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1320 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1321 /* Insert the new pass instance based on the positioning op. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1322 switch (new_pass_info->pos_op) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1323 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1324 case PASS_POS_INSERT_AFTER: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1325 new_pass->next = pass->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1326 pass->next = new_pass; |
0 | 1327 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1328 /* Skip newly inserted pass to avoid repeated |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1329 insertions in the case where the new pass and the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1330 existing one have the same name. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1331 pass = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1332 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1333 case PASS_POS_INSERT_BEFORE: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1334 new_pass->next = pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1335 if (prev_pass) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1336 prev_pass->next = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1337 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1338 *pass_list = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1339 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1340 case PASS_POS_REPLACE: |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1341 new_pass->next = pass->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1342 if (prev_pass) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1343 prev_pass->next = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1344 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1345 *pass_list = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1346 new_pass->sub = pass->sub; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1347 new_pass->tv_id = pass->tv_id; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1348 pass = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1349 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1350 default: |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1351 error ("invalid pass positioning operation"); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1352 return false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1353 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1354 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1355 /* Save the newly added pass (instance) in the added_pass_nodes |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1356 list so that we can register its dump file later. Note that |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1357 we cannot register the dump file now because doing so will modify |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1358 the static_pass_number of the opt_pass object and therefore |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1359 mess up the dump file name of future instances. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1360 new_pass_node = XCNEW (struct pass_list_node); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1361 new_pass_node->pass = new_pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1362 if (!added_pass_nodes) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1363 added_pass_nodes = new_pass_node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1364 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1365 prev_added_pass_node->next = new_pass_node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1366 prev_added_pass_node = new_pass_node; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1367 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1368 success = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1369 } |
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 if (pass->sub && position_pass (new_pass_info, &pass->sub)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1372 success = true; |
0 | 1373 } |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1374 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1375 return success; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1376 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1377 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1378 /* Hooks a new pass into the pass lists. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1379 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1380 PASS_INFO - pass information that specifies the opt_pass object, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1381 reference pass, instance number, and how to position |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1382 the pass */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1383 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1384 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1385 register_pass (struct register_pass_info *pass_info) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1386 { |
111 | 1387 g->get_passes ()->register_pass (pass_info); |
1388 } | |
1389 | |
1390 void | |
1391 register_pass (opt_pass* pass, pass_positioning_ops pos, | |
1392 const char* ref_pass_name, int ref_pass_inst_number) | |
1393 { | |
1394 register_pass_info i; | |
1395 i.pass = pass; | |
1396 i.reference_pass_name = ref_pass_name; | |
1397 i.ref_pass_instance_number = ref_pass_inst_number; | |
1398 i.pos_op = pos; | |
1399 | |
1400 g->get_passes ()->register_pass (&i); | |
1401 } | |
1402 | |
1403 void | |
1404 pass_manager::register_pass (struct register_pass_info *pass_info) | |
1405 { | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1406 bool all_instances, success; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1407 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1408 /* The checks below could fail in buggy plugins. Existing GCC |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1409 passes should never fail these checks, so we mention plugin in |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1410 the messages. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1411 if (!pass_info->pass) |
111 | 1412 fatal_error (input_location, "plugin cannot register a missing pass"); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1413 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1414 if (!pass_info->pass->name) |
111 | 1415 fatal_error (input_location, "plugin cannot register an unnamed pass"); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1416 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1417 if (!pass_info->reference_pass_name) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1418 fatal_error |
111 | 1419 (input_location, |
1420 "plugin cannot register pass %qs without reference pass name", | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1421 pass_info->pass->name); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1422 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1423 /* Try to insert the new pass to the pass lists. We need to check |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1424 all five lists as the reference pass could be in one (or all) of |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1425 them. */ |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1426 all_instances = pass_info->ref_pass_instance_number == 0; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1427 success = position_pass (pass_info, &all_lowering_passes); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1428 if (!success || all_instances) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1429 success |= position_pass (pass_info, &all_small_ipa_passes); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1430 if (!success || all_instances) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1431 success |= position_pass (pass_info, &all_regular_ipa_passes); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1432 if (!success || all_instances) |
111 | 1433 success |= position_pass (pass_info, &all_late_ipa_passes); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1434 if (!success || all_instances) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1435 success |= position_pass (pass_info, &all_passes); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1436 if (!success) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1437 fatal_error |
111 | 1438 (input_location, |
1439 "pass %qs not found but is referenced by new pass %qs", | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1440 pass_info->reference_pass_name, pass_info->pass->name); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1441 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1442 /* OK, we have successfully inserted the new pass. We need to register |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1443 the dump files for the newly added pass and its duplicates (if any). |
131 | 1444 While doing so, we also delete the pass_list_node |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1445 objects created during pass positioning. */ |
131 | 1446 gcc::dump_manager *dumps = m_ctxt->get_dumps (); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1447 while (added_pass_nodes) |
0 | 1448 { |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1449 struct pass_list_node *next_node = added_pass_nodes->next; |
131 | 1450 |
1451 /* Handle -fdump-* and -fopt-info. */ | |
1452 dumps->register_pass (added_pass_nodes->pass); | |
1453 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1454 XDELETE (added_pass_nodes); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
1455 added_pass_nodes = next_node; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1456 } |
0 | 1457 } |
1458 | |
1459 /* Construct the pass tree. The sequencing of passes is driven by | |
1460 the cgraph routines: | |
1461 | |
111 | 1462 finalize_compilation_unit () |
0 | 1463 for each node N in the cgraph |
1464 cgraph_analyze_function (N) | |
1465 cgraph_lower_function (N) -> all_lowering_passes | |
1466 | |
111 | 1467 If we are optimizing, compile is then invoked: |
1468 | |
1469 compile () | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1470 ipa_passes () -> all_small_ipa_passes |
111 | 1471 -> Analysis of all_regular_ipa_passes |
1472 * possible LTO streaming at copmilation time * | |
1473 -> Execution of all_regular_ipa_passes | |
1474 * possible LTO streaming at link time * | |
1475 -> all_late_ipa_passes | |
1476 expand_all_functions () | |
0 | 1477 for each node N in the cgraph |
111 | 1478 expand_function (N) -> Transformation of all_regular_ipa_passes |
1479 -> all_passes | |
0 | 1480 */ |
1481 | |
111 | 1482 pass_manager::pass_manager (context *ctxt) |
1483 : all_passes (NULL), all_small_ipa_passes (NULL), all_lowering_passes (NULL), | |
1484 all_regular_ipa_passes (NULL), | |
1485 all_late_ipa_passes (NULL), passes_by_id (NULL), passes_by_id_size (0), | |
1486 m_ctxt (ctxt), m_name_to_pass_map (NULL) | |
0 | 1487 { |
111 | 1488 opt_pass **p; |
1489 | |
1490 /* Zero-initialize pass members. */ | |
1491 #define INSERT_PASSES_AFTER(PASS) | |
1492 #define PUSH_INSERT_PASSES_WITHIN(PASS) | |
1493 #define POP_INSERT_PASSES() | |
1494 #define NEXT_PASS(PASS, NUM) PASS ## _ ## NUM = NULL | |
1495 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM) | |
1496 #define TERMINATE_PASS_LIST(PASS) | |
1497 #include "pass-instances.def" | |
1498 #undef INSERT_PASSES_AFTER | |
1499 #undef PUSH_INSERT_PASSES_WITHIN | |
1500 #undef POP_INSERT_PASSES | |
0 | 1501 #undef NEXT_PASS |
111 | 1502 #undef NEXT_PASS_WITH_ARG |
1503 #undef TERMINATE_PASS_LIST | |
1504 | |
1505 /* Initialize the pass_lists array. */ | |
1506 #define DEF_PASS_LIST(LIST) pass_lists[PASS_LIST_NO_##LIST] = &LIST; | |
1507 GCC_PASS_LISTS | |
1508 #undef DEF_PASS_LIST | |
1509 | |
1510 /* Build the tree of passes. */ | |
1511 | |
1512 #define INSERT_PASSES_AFTER(PASS) \ | |
1513 { \ | |
1514 opt_pass **p_start; \ | |
1515 p_start = p = &(PASS); | |
1516 | |
1517 #define TERMINATE_PASS_LIST(PASS) \ | |
1518 gcc_assert (p_start == &PASS); \ | |
1519 *p = NULL; \ | |
1520 } | |
1521 | |
1522 #define PUSH_INSERT_PASSES_WITHIN(PASS) \ | |
1523 { \ | |
1524 opt_pass **p = &(PASS ## _1)->sub; | |
1525 | |
1526 #define POP_INSERT_PASSES() \ | |
1527 } | |
1528 | |
1529 #define NEXT_PASS(PASS, NUM) \ | |
1530 do { \ | |
131 | 1531 gcc_assert (PASS ## _ ## NUM == NULL); \ |
111 | 1532 if ((NUM) == 1) \ |
1533 PASS ## _1 = make_##PASS (m_ctxt); \ | |
1534 else \ | |
1535 { \ | |
1536 gcc_assert (PASS ## _1); \ | |
1537 PASS ## _ ## NUM = PASS ## _1->clone (); \ | |
1538 } \ | |
1539 p = next_pass_1 (p, PASS ## _ ## NUM, PASS ## _1); \ | |
1540 } while (0) | |
1541 | |
1542 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) \ | |
1543 do { \ | |
1544 NEXT_PASS (PASS, NUM); \ | |
1545 PASS ## _ ## NUM->set_pass_param (0, ARG); \ | |
1546 } while (0) | |
1547 | |
1548 #include "pass-instances.def" | |
1549 | |
1550 #undef INSERT_PASSES_AFTER | |
1551 #undef PUSH_INSERT_PASSES_WITHIN | |
1552 #undef POP_INSERT_PASSES | |
1553 #undef NEXT_PASS | |
1554 #undef NEXT_PASS_WITH_ARG | |
1555 #undef TERMINATE_PASS_LIST | |
0 | 1556 |
1557 /* Register the passes with the tree dump code. */ | |
111 | 1558 register_dump_files (all_lowering_passes); |
1559 register_dump_files (all_small_ipa_passes); | |
1560 register_dump_files (all_regular_ipa_passes); | |
1561 register_dump_files (all_late_ipa_passes); | |
1562 register_dump_files (all_passes); | |
1563 } | |
1564 | |
1565 static void | |
1566 delete_pass_tree (opt_pass *pass) | |
1567 { | |
1568 while (pass) | |
1569 { | |
1570 /* Recurse into child passes. */ | |
1571 delete_pass_tree (pass->sub); | |
1572 | |
1573 opt_pass *next = pass->next; | |
1574 | |
1575 /* Delete this pass. */ | |
1576 delete pass; | |
1577 | |
1578 /* Iterate onto sibling passes. */ | |
1579 pass = next; | |
1580 } | |
1581 } | |
1582 | |
1583 pass_manager::~pass_manager () | |
1584 { | |
1585 XDELETEVEC (passes_by_id); | |
1586 | |
1587 /* Call delete_pass_tree on each of the pass_lists. */ | |
1588 #define DEF_PASS_LIST(LIST) \ | |
1589 delete_pass_tree (*pass_lists[PASS_LIST_NO_##LIST]); | |
1590 GCC_PASS_LISTS | |
1591 #undef DEF_PASS_LIST | |
1592 | |
0 | 1593 } |
1594 | |
1595 /* If we are in IPA mode (i.e., current_function_decl is NULL), call | |
1596 function CALLBACK for every function in the call graph. Otherwise, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1597 call CALLBACK on the current function. */ |
0 | 1598 |
1599 static void | |
111 | 1600 do_per_function (void (*callback) (function *, void *data), void *data) |
0 | 1601 { |
1602 if (current_function_decl) | |
111 | 1603 callback (cfun, data); |
0 | 1604 else |
1605 { | |
1606 struct cgraph_node *node; | |
111 | 1607 FOR_EACH_DEFINED_FUNCTION (node) |
1608 if (node->analyzed && (gimple_has_body_p (node->decl) && !in_lto_p) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1609 && (!node->clone_of || node->decl != node->clone_of->decl)) |
111 | 1610 callback (DECL_STRUCT_FUNCTION (node->decl), data); |
0 | 1611 } |
1612 } | |
1613 | |
1614 /* Because inlining might remove no-longer reachable nodes, we need to | |
1615 keep the array visible to garbage collector to avoid reading collected | |
1616 out nodes. */ | |
1617 static int nnodes; | |
111 | 1618 static GTY ((length ("nnodes"))) cgraph_node **order; |
1619 | |
131 | 1620 #define uid_hash_t hash_set<int_hash <int, 0, -1> > |
1621 | |
111 | 1622 /* Hook called when NODE is removed and therefore should be |
131 | 1623 excluded from order vector. DATA is a hash set with removed nodes. */ |
1624 | |
111 | 1625 static void |
1626 remove_cgraph_node_from_order (cgraph_node *node, void *data) | |
1627 { | |
131 | 1628 uid_hash_t *removed_nodes = (uid_hash_t *)data; |
1629 removed_nodes->add (node->get_uid ()); | |
111 | 1630 } |
0 | 1631 |
1632 /* If we are in IPA mode (i.e., current_function_decl is NULL), call | |
1633 function CALLBACK for every function in the call graph. Otherwise, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1634 call CALLBACK on the current function. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1635 This function is global so that plugins can use it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1636 void |
111 | 1637 do_per_function_toporder (void (*callback) (function *, void *data), void *data) |
0 | 1638 { |
1639 int i; | |
1640 | |
1641 if (current_function_decl) | |
111 | 1642 callback (cfun, data); |
0 | 1643 else |
1644 { | |
111 | 1645 cgraph_node_hook_list *hook; |
131 | 1646 uid_hash_t removed_nodes; |
0 | 1647 gcc_assert (!order); |
111 | 1648 order = ggc_vec_alloc<cgraph_node *> (symtab->cgraph_count); |
1649 | |
1650 nnodes = ipa_reverse_postorder (order); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1651 for (i = nnodes - 1; i >= 0; i--) |
131 | 1652 order[i]->process = 1; |
111 | 1653 hook = symtab->add_cgraph_removal_hook (remove_cgraph_node_from_order, |
131 | 1654 &removed_nodes); |
111 | 1655 for (i = nnodes - 1; i >= 0; i--) |
1656 { | |
131 | 1657 cgraph_node *node = order[i]; |
1658 | |
111 | 1659 /* Function could be inlined and removed as unreachable. */ |
131 | 1660 if (node == NULL || removed_nodes.contains (node->get_uid ())) |
111 | 1661 continue; |
1662 | |
0 | 1663 /* Allow possibly removed nodes to be garbage collected. */ |
1664 order[i] = NULL; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1665 node->process = 0; |
111 | 1666 if (node->has_gimple_body_p ()) |
0 | 1667 { |
111 | 1668 struct function *fn = DECL_STRUCT_FUNCTION (node->decl); |
1669 push_cfun (fn); | |
1670 callback (fn, data); | |
0 | 1671 pop_cfun (); |
1672 } | |
1673 } | |
111 | 1674 symtab->remove_cgraph_removal_hook (hook); |
0 | 1675 } |
1676 ggc_free (order); | |
1677 order = NULL; | |
1678 nnodes = 0; | |
1679 } | |
1680 | |
111 | 1681 /* Helper function to perform function body dump. */ |
1682 | |
1683 static void | |
1684 execute_function_dump (function *fn, void *data) | |
1685 { | |
1686 opt_pass *pass = (opt_pass *)data; | |
1687 | |
1688 if (dump_file) | |
1689 { | |
1690 push_cfun (fn); | |
1691 | |
1692 if (fn->curr_properties & PROP_trees) | |
1693 dump_function_to_file (fn->decl, dump_file, dump_flags); | |
1694 else | |
1695 print_rtl_with_bb (dump_file, get_insns (), dump_flags); | |
1696 | |
1697 /* Flush the file. If verification fails, we won't be able to | |
1698 close the file before aborting. */ | |
1699 fflush (dump_file); | |
1700 | |
1701 if ((fn->curr_properties & PROP_cfg) | |
1702 && (dump_flags & TDF_GRAPH)) | |
1703 { | |
1704 gcc::dump_manager *dumps = g->get_dumps (); | |
1705 struct dump_file_info *dfi | |
1706 = dumps->get_dump_file_info (pass->static_pass_number); | |
1707 if (!dfi->graph_dump_initialized) | |
1708 { | |
1709 clean_graph_dump_file (dump_file_name); | |
1710 dfi->graph_dump_initialized = true; | |
1711 } | |
1712 print_graph_cfg (dump_file_name, fn); | |
1713 } | |
1714 | |
1715 pop_cfun (); | |
1716 } | |
1717 } | |
1718 | |
1719 /* This function is called when an internal compiler error is encountered. | |
1720 Ensure that function dump is made available before compiler is aborted. */ | |
1721 | |
1722 void | |
1723 emergency_dump_function () | |
1724 { | |
1725 if (!current_pass) | |
1726 return; | |
1727 enum opt_pass_type pt = current_pass->type; | |
1728 fnotice (stderr, "during %s pass: %s\n", | |
1729 pt == GIMPLE_PASS ? "GIMPLE" : pt == RTL_PASS ? "RTL" : "IPA", | |
1730 current_pass->name); | |
1731 if (!dump_file || !cfun) | |
1732 return; | |
1733 fnotice (stderr, "dump file: %s\n", dump_file_name); | |
1734 fprintf (dump_file, "\n\n\nEMERGENCY DUMP:\n\n"); | |
1735 execute_function_dump (cfun, current_pass); | |
1736 } | |
1737 | |
1738 static struct profile_record *profile_record; | |
1739 | |
1740 /* Do profile consistency book-keeping for the pass with static number INDEX. | |
1741 If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then | |
1742 we run _after_ the pass. RUN is true if the pass really runs, or FALSE | |
1743 if we are only book-keeping on passes that may have selectively disabled | |
1744 themselves on a given function. */ | |
1745 static void | |
1746 check_profile_consistency (int index, int subpass, bool run) | |
1747 { | |
1748 pass_manager *passes = g->get_passes (); | |
1749 if (index == -1) | |
1750 return; | |
1751 if (!profile_record) | |
1752 profile_record = XCNEWVEC (struct profile_record, | |
1753 passes->passes_by_id_size); | |
1754 gcc_assert (index < passes->passes_by_id_size && index >= 0); | |
1755 gcc_assert (subpass < 2); | |
1756 profile_record[index].run |= run; | |
1757 account_profile_record (&profile_record[index], subpass); | |
1758 } | |
1759 | |
1760 /* Output profile consistency. */ | |
1761 | |
1762 void | |
1763 dump_profile_report (void) | |
1764 { | |
1765 g->get_passes ()->dump_profile_report (); | |
1766 } | |
1767 | |
1768 void | |
1769 pass_manager::dump_profile_report () const | |
1770 { | |
1771 int i, j; | |
1772 int last_freq_in = 0, last_count_in = 0, last_freq_out = 0, last_count_out = 0; | |
1773 gcov_type last_time = 0, last_size = 0; | |
1774 double rel_time_change, rel_size_change; | |
1775 int last_reported = 0; | |
1776 | |
1777 if (!profile_record) | |
1778 return; | |
1779 fprintf (stderr, "\nProfile consistency report:\n\n"); | |
1780 fprintf (stderr, "Pass name |mismatch in |mismated out|Overall\n"); | |
1781 fprintf (stderr, " |freq count |freq count |size time\n"); | |
1782 | |
1783 for (i = 0; i < passes_by_id_size; i++) | |
1784 for (j = 0 ; j < 2; j++) | |
1785 if (profile_record[i].run) | |
1786 { | |
1787 if (last_time) | |
1788 rel_time_change = (profile_record[i].time[j] | |
1789 - (double)last_time) * 100 / (double)last_time; | |
1790 else | |
1791 rel_time_change = 0; | |
1792 if (last_size) | |
1793 rel_size_change = (profile_record[i].size[j] | |
1794 - (double)last_size) * 100 / (double)last_size; | |
1795 else | |
1796 rel_size_change = 0; | |
1797 | |
1798 if (profile_record[i].num_mismatched_freq_in[j] != last_freq_in | |
1799 || profile_record[i].num_mismatched_freq_out[j] != last_freq_out | |
1800 || profile_record[i].num_mismatched_count_in[j] != last_count_in | |
1801 || profile_record[i].num_mismatched_count_out[j] != last_count_out | |
1802 || rel_time_change || rel_size_change) | |
1803 { | |
1804 last_reported = i; | |
1805 fprintf (stderr, "%-20s %s", | |
1806 passes_by_id [i]->name, | |
1807 j ? "(after TODO)" : " "); | |
1808 if (profile_record[i].num_mismatched_freq_in[j] != last_freq_in) | |
1809 fprintf (stderr, "| %+5i", | |
1810 profile_record[i].num_mismatched_freq_in[j] | |
1811 - last_freq_in); | |
1812 else | |
1813 fprintf (stderr, "| "); | |
1814 if (profile_record[i].num_mismatched_count_in[j] != last_count_in) | |
1815 fprintf (stderr, " %+5i", | |
1816 profile_record[i].num_mismatched_count_in[j] | |
1817 - last_count_in); | |
1818 else | |
1819 fprintf (stderr, " "); | |
1820 if (profile_record[i].num_mismatched_freq_out[j] != last_freq_out) | |
1821 fprintf (stderr, "| %+5i", | |
1822 profile_record[i].num_mismatched_freq_out[j] | |
1823 - last_freq_out); | |
1824 else | |
1825 fprintf (stderr, "| "); | |
1826 if (profile_record[i].num_mismatched_count_out[j] != last_count_out) | |
1827 fprintf (stderr, " %+5i", | |
1828 profile_record[i].num_mismatched_count_out[j] | |
1829 - last_count_out); | |
1830 else | |
1831 fprintf (stderr, " "); | |
1832 | |
1833 /* Size/time units change across gimple and RTL. */ | |
1834 if (i == pass_expand_1->static_pass_number) | |
1835 fprintf (stderr, "|----------"); | |
1836 else | |
1837 { | |
1838 if (rel_size_change) | |
1839 fprintf (stderr, "| %+8.4f%%", rel_size_change); | |
1840 else | |
1841 fprintf (stderr, "| "); | |
1842 if (rel_time_change) | |
1843 fprintf (stderr, " %+8.4f%%", rel_time_change); | |
1844 } | |
1845 fprintf (stderr, "\n"); | |
1846 last_freq_in = profile_record[i].num_mismatched_freq_in[j]; | |
1847 last_freq_out = profile_record[i].num_mismatched_freq_out[j]; | |
1848 last_count_in = profile_record[i].num_mismatched_count_in[j]; | |
1849 last_count_out = profile_record[i].num_mismatched_count_out[j]; | |
1850 } | |
1851 else if (j && last_reported != i) | |
1852 { | |
1853 last_reported = i; | |
1854 fprintf (stderr, "%-20s ------------| | |\n", | |
1855 passes_by_id [i]->name); | |
1856 } | |
1857 last_time = profile_record[i].time[j]; | |
1858 last_size = profile_record[i].size[j]; | |
1859 } | |
1860 } | |
1861 | |
0 | 1862 /* Perform all TODO actions that ought to be done on each function. */ |
1863 | |
1864 static void | |
111 | 1865 execute_function_todo (function *fn, void *data) |
0 | 1866 { |
111 | 1867 bool from_ipa_pass = (cfun == NULL); |
0 | 1868 unsigned int flags = (size_t)data; |
111 | 1869 flags &= ~fn->last_verified; |
0 | 1870 if (!flags) |
1871 return; | |
1872 | |
111 | 1873 push_cfun (fn); |
1874 | |
0 | 1875 /* Always cleanup the CFG before trying to update SSA. */ |
1876 if (flags & TODO_cleanup_cfg) | |
1877 { | |
111 | 1878 cleanup_tree_cfg (); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1879 |
0 | 1880 /* When cleanup_tree_cfg merges consecutive blocks, it may |
1881 perform some simplistic propagation when removing single | |
1882 valued PHI nodes. This propagation may, in turn, cause the | |
1883 SSA form to become out-of-date (see PR 22037). So, even | |
1884 if the parent pass had not scheduled an SSA update, we may | |
1885 still need to do one. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1886 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun)) |
0 | 1887 flags |= TODO_update_ssa; |
1888 } | |
1889 | |
1890 if (flags & TODO_update_ssa_any) | |
1891 { | |
1892 unsigned update_flags = flags & TODO_update_ssa_any; | |
1893 update_ssa (update_flags); | |
1894 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1895 |
111 | 1896 if (flag_tree_pta && (flags & TODO_rebuild_alias)) |
1897 compute_may_aliases (); | |
1898 | |
1899 if (optimize && (flags & TODO_update_address_taken)) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1900 execute_update_addresses_taken (); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1901 |
0 | 1902 if (flags & TODO_remove_unused_locals) |
1903 remove_unused_locals (); | |
1904 | |
1905 if (flags & TODO_rebuild_frequencies) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1906 rebuild_frequencies (); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1907 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1908 if (flags & TODO_rebuild_cgraph_edges) |
111 | 1909 cgraph_edge::rebuild_edges (); |
1910 | |
1911 gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == DOM_NONE); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1912 /* If we've seen errors do not bother running any verifiers. */ |
111 | 1913 if (flag_checking && !seen_error ()) |
1914 { | |
1915 dom_state pre_verify_state = dom_info_state (fn, CDI_DOMINATORS); | |
1916 dom_state pre_verify_pstate = dom_info_state (fn, CDI_POST_DOMINATORS); | |
1917 | |
1918 if (flags & TODO_verify_il) | |
1919 { | |
1920 if (cfun->curr_properties & PROP_trees) | |
1921 { | |
1922 if (cfun->curr_properties & PROP_cfg) | |
1923 /* IPA passes leave stmts to be fixed up, so make sure to | |
1924 not verify stmts really throw. */ | |
1925 verify_gimple_in_cfg (cfun, !from_ipa_pass); | |
1926 else | |
1927 verify_gimple_in_seq (gimple_body (cfun->decl)); | |
1928 } | |
1929 if (cfun->curr_properties & PROP_ssa) | |
1930 /* IPA passes leave stmts to be fixed up, so make sure to | |
1931 not verify SSA operands whose verifier will choke on that. */ | |
1932 verify_ssa (true, !from_ipa_pass); | |
1933 /* IPA passes leave basic-blocks unsplit, so make sure to | |
1934 not trip on that. */ | |
1935 if ((cfun->curr_properties & PROP_cfg) | |
1936 && !from_ipa_pass) | |
1937 verify_flow_info (); | |
1938 if (current_loops | |
1939 && ! loops_state_satisfies_p (LOOPS_NEED_FIXUP)) | |
1940 { | |
1941 verify_loop_structure (); | |
1942 if (loops_state_satisfies_p (LOOP_CLOSED_SSA)) | |
1943 verify_loop_closed_ssa (false); | |
1944 } | |
1945 if (cfun->curr_properties & PROP_rtl) | |
1946 verify_rtl_sharing (); | |
1947 } | |
1948 | |
1949 /* Make sure verifiers don't change dominator state. */ | |
1950 gcc_assert (dom_info_state (fn, CDI_DOMINATORS) == pre_verify_state); | |
1951 gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == pre_verify_pstate); | |
1952 } | |
1953 | |
1954 fn->last_verified = flags & TODO_verify_all; | |
1955 | |
1956 pop_cfun (); | |
1957 | |
1958 /* For IPA passes make sure to release dominator info, it can be | |
1959 computed by non-verifying TODOs. */ | |
1960 if (from_ipa_pass) | |
1961 { | |
1962 free_dominance_info (fn, CDI_DOMINATORS); | |
1963 free_dominance_info (fn, CDI_POST_DOMINATORS); | |
1964 } | |
0 | 1965 } |
1966 | |
1967 /* Perform all TODO actions. */ | |
1968 static void | |
1969 execute_todo (unsigned int flags) | |
1970 { | |
111 | 1971 if (flag_checking |
1972 && cfun | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1973 && need_ssa_update_p (cfun)) |
0 | 1974 gcc_assert (flags & TODO_update_ssa_any); |
1975 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1976 statistics_fini_pass (); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1977 |
111 | 1978 if (flags) |
1979 do_per_function (execute_function_todo, (void *)(size_t) flags); | |
1980 | |
1981 /* At this point we should not have any unreachable code in the | |
1982 CFG, so it is safe to flush the pending freelist for SSA_NAMES. */ | |
1983 if (cfun && cfun->gimple_df) | |
1984 flush_ssaname_freelist (); | |
0 | 1985 |
1986 /* Always remove functions just as before inlining: IPA passes might be | |
1987 interested to see bodies of extern inline functions that are not inlined | |
1988 to analyze side effects. The full removal is done just at the end | |
1989 of IPA pass queue. */ | |
1990 if (flags & TODO_remove_functions) | |
1991 { | |
1992 gcc_assert (!cfun); | |
111 | 1993 symtab->remove_unreachable_nodes (dump_file); |
0 | 1994 } |
1995 | |
111 | 1996 if ((flags & TODO_dump_symtab) && dump_file && !current_function_decl) |
0 | 1997 { |
1998 gcc_assert (!cfun); | |
111 | 1999 symtab->dump (dump_file); |
0 | 2000 /* Flush the file. If verification fails, we won't be able to |
2001 close the file before aborting. */ | |
2002 fflush (dump_file); | |
2003 } | |
2004 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2005 /* Now that the dumping has been done, we can get rid of the optional |
0 | 2006 df problems. */ |
2007 if (flags & TODO_df_finish) | |
2008 df_finish_pass ((flags & TODO_df_verify) != 0); | |
2009 } | |
2010 | |
2011 /* Verify invariants that should hold between passes. This is a place | |
2012 to put simple sanity checks. */ | |
2013 | |
2014 static void | |
2015 verify_interpass_invariants (void) | |
2016 { | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2017 gcc_checking_assert (!fold_deferring_overflow_warnings_p ()); |
0 | 2018 } |
2019 | |
2020 /* Clear the last verified flag. */ | |
2021 | |
2022 static void | |
111 | 2023 clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED) |
0 | 2024 { |
111 | 2025 fn->last_verified = 0; |
0 | 2026 } |
2027 | |
2028 /* Helper function. Verify that the properties has been turn into the | |
2029 properties expected by the pass. */ | |
2030 | |
2031 static void | |
111 | 2032 verify_curr_properties (function *fn, void *data) |
0 | 2033 { |
2034 unsigned int props = (size_t)data; | |
111 | 2035 gcc_assert ((fn->curr_properties & props) == props); |
0 | 2036 } |
111 | 2037 |
2038 /* Release dump file name if set. */ | |
2039 | |
2040 static void | |
2041 release_dump_file_name (void) | |
2042 { | |
2043 if (dump_file_name) | |
2044 { | |
2045 free (CONST_CAST (char *, dump_file_name)); | |
2046 dump_file_name = NULL; | |
2047 } | |
2048 } | |
0 | 2049 |
2050 /* Initialize pass 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
|
2051 /* This is non-static so that the plugins can use it. */ |
0 | 2052 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2053 bool |
111 | 2054 pass_init_dump_file (opt_pass *pass) |
0 | 2055 { |
2056 /* If a dump file name is present, open it if enabled. */ | |
2057 if (pass->static_pass_number != -1) | |
2058 { | |
111 | 2059 timevar_push (TV_DUMP); |
2060 gcc::dump_manager *dumps = g->get_dumps (); | |
2061 bool initializing_dump = | |
2062 !dumps->dump_initialized_p (pass->static_pass_number); | |
2063 release_dump_file_name (); | |
2064 dump_file_name = dumps->get_dump_file_name (pass->static_pass_number); | |
2065 dumps->dump_start (pass->static_pass_number, &dump_flags); | |
2066 if (dump_file && current_function_decl && ! (dump_flags & TDF_GIMPLE)) | |
2067 dump_function_header (dump_file, current_function_decl, dump_flags); | |
2068 if (initializing_dump | |
2069 && dump_file && (dump_flags & TDF_GRAPH) | |
2070 && cfun && (cfun->curr_properties & PROP_cfg)) | |
0 | 2071 { |
111 | 2072 clean_graph_dump_file (dump_file_name); |
2073 struct dump_file_info *dfi | |
2074 = dumps->get_dump_file_info (pass->static_pass_number); | |
2075 dfi->graph_dump_initialized = true; | |
0 | 2076 } |
111 | 2077 timevar_pop (TV_DUMP); |
0 | 2078 return initializing_dump; |
2079 } | |
2080 else | |
2081 return false; | |
2082 } | |
2083 | |
2084 /* Flush PASS 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
|
2085 /* This is non-static so that plugins can use it. */ |
0 | 2086 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2087 void |
111 | 2088 pass_fini_dump_file (opt_pass *pass) |
0 | 2089 { |
111 | 2090 timevar_push (TV_DUMP); |
2091 | |
0 | 2092 /* Flush and close dump file. */ |
111 | 2093 release_dump_file_name (); |
2094 | |
2095 g->get_dumps ()->dump_finish (pass->static_pass_number); | |
2096 timevar_pop (TV_DUMP); | |
0 | 2097 } |
2098 | |
2099 /* After executing the pass, apply expected changes to the function | |
2100 properties. */ | |
2101 | |
2102 static void | |
111 | 2103 update_properties_after_pass (function *fn, void *data) |
0 | 2104 { |
111 | 2105 opt_pass *pass = (opt_pass *) data; |
2106 fn->curr_properties = (fn->curr_properties | pass->properties_provided) | |
2107 & ~pass->properties_destroyed; | |
0 | 2108 } |
2109 | |
2110 /* Execute summary generation for all of the passes in IPA_PASS. */ | |
2111 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2112 void |
111 | 2113 execute_ipa_summary_passes (ipa_opt_pass_d *ipa_pass) |
0 | 2114 { |
2115 while (ipa_pass) | |
2116 { | |
111 | 2117 opt_pass *pass = ipa_pass; |
0 | 2118 |
2119 /* Execute all of the IPA_PASSes in the list. */ | |
111 | 2120 if (ipa_pass->type == IPA_PASS |
2121 && pass->gate (cfun) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2122 && ipa_pass->generate_summary) |
0 | 2123 { |
2124 pass_init_dump_file (pass); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2125 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2126 /* If a timevar is present, start it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2127 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2128 timevar_push (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2129 |
111 | 2130 current_pass = pass; |
0 | 2131 ipa_pass->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
|
2132 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2133 /* Stop timevar. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2134 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2135 timevar_pop (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2136 |
0 | 2137 pass_fini_dump_file (pass); |
2138 } | |
111 | 2139 ipa_pass = (ipa_opt_pass_d *)ipa_pass->next; |
0 | 2140 } |
2141 } | |
2142 | |
2143 /* Execute IPA_PASS function transform on NODE. */ | |
2144 | |
2145 static void | |
2146 execute_one_ipa_transform_pass (struct cgraph_node *node, | |
111 | 2147 ipa_opt_pass_d *ipa_pass) |
0 | 2148 { |
111 | 2149 opt_pass *pass = ipa_pass; |
0 | 2150 unsigned int todo_after = 0; |
2151 | |
2152 current_pass = pass; | |
2153 if (!ipa_pass->function_transform) | |
2154 return; | |
2155 | |
2156 /* Note that the folders should only create gimple expressions. | |
2157 This is a hack until the new folder is ready. */ | |
2158 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; | |
2159 | |
2160 pass_init_dump_file (pass); | |
2161 | |
2162 /* If a timevar is present, start it. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2163 if (pass->tv_id != TV_NONE) |
0 | 2164 timevar_push (pass->tv_id); |
2165 | |
111 | 2166 /* Run pre-pass verification. */ |
2167 execute_todo (ipa_pass->function_transform_todo_flags_start); | |
2168 | |
0 | 2169 /* Do it! */ |
2170 todo_after = ipa_pass->function_transform (node); | |
2171 | |
111 | 2172 if (profile_report && cfun && (cfun->curr_properties & PROP_cfg)) |
2173 check_profile_consistency (pass->static_pass_number, 0, true); | |
2174 | |
2175 /* Run post-pass cleanup and verification. */ | |
2176 execute_todo (todo_after); | |
2177 verify_interpass_invariants (); | |
2178 if (profile_report && cfun && (cfun->curr_properties & PROP_cfg)) | |
2179 check_profile_consistency (pass->static_pass_number, 1, true); | |
2180 | |
0 | 2181 /* Stop timevar. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2182 if (pass->tv_id != TV_NONE) |
0 | 2183 timevar_pop (pass->tv_id); |
2184 | |
111 | 2185 if (dump_file) |
2186 do_per_function (execute_function_dump, pass); | |
0 | 2187 pass_fini_dump_file (pass); |
2188 | |
2189 current_pass = NULL; | |
111 | 2190 redirect_edge_var_map_empty (); |
2191 | |
2192 /* Signal this is a suitable GC collection point. */ | |
2193 if (!(todo_after & TODO_do_not_ggc_collect)) | |
2194 ggc_collect (); | |
0 | 2195 } |
2196 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2197 /* For the current function, execute all ipa transforms. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2198 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2199 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2200 execute_all_ipa_transforms (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2201 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2202 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
|
2203 if (!cfun) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2204 return; |
111 | 2205 node = cgraph_node::get (current_function_decl); |
2206 | |
2207 if (node->ipa_transforms_to_apply.exists ()) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2208 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2209 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
|
2210 |
111 | 2211 for (i = 0; i < node->ipa_transforms_to_apply.length (); i++) |
2212 execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i]); | |
2213 node->ipa_transforms_to_apply.release (); | |
2214 } | |
2215 } | |
2216 | |
2217 /* Check if PASS is explicitly disabled or enabled and return | |
2218 the gate status. FUNC is the function to be processed, and | |
2219 GATE_STATUS is the gate status determined by pass manager by | |
2220 default. */ | |
2221 | |
2222 static bool | |
2223 override_gate_status (opt_pass *pass, tree func, bool gate_status) | |
2224 { | |
2225 bool explicitly_enabled = false; | |
2226 bool explicitly_disabled = false; | |
2227 | |
2228 explicitly_enabled | |
2229 = is_pass_explicitly_enabled_or_disabled (pass, func, | |
2230 enabled_pass_uid_range_tab); | |
2231 explicitly_disabled | |
2232 = is_pass_explicitly_enabled_or_disabled (pass, func, | |
2233 disabled_pass_uid_range_tab); | |
2234 | |
2235 gate_status = !explicitly_disabled && (gate_status || explicitly_enabled); | |
2236 | |
2237 return gate_status; | |
2238 } | |
2239 | |
2240 /* Determine if PASS_NAME matches CRITERION. | |
2241 Not a pure predicate, since it can update CRITERION, to support | |
2242 matching the Nth invocation of a pass. | |
2243 Subroutine of should_skip_pass_p. */ | |
2244 | |
2245 static bool | |
2246 determine_pass_name_match (const char *pass_name, char *criterion) | |
2247 { | |
2248 size_t namelen = strlen (pass_name); | |
2249 if (! strncmp (pass_name, criterion, namelen)) | |
2250 { | |
2251 /* The following supports starting with the Nth invocation | |
2252 of a pass (where N does not necessarily is equal to the | |
2253 dump file suffix). */ | |
2254 if (criterion[namelen] == '\0' | |
2255 || (criterion[namelen] == '1' | |
2256 && criterion[namelen + 1] == '\0')) | |
2257 return true; | |
2258 else | |
2259 { | |
2260 if (criterion[namelen + 1] == '\0') | |
2261 --criterion[namelen]; | |
2262 return false; | |
2263 } | |
2264 } | |
2265 else | |
2266 return false; | |
2267 } | |
2268 | |
2269 /* For skipping passes until "startwith" pass. | |
2270 Return true iff PASS should be skipped. | |
2271 Clear cfun->pass_startwith when encountering the "startwith" pass, | |
2272 so that all subsequent passes are run. */ | |
2273 | |
2274 static bool | |
2275 should_skip_pass_p (opt_pass *pass) | |
2276 { | |
2277 if (!cfun) | |
2278 return false; | |
2279 if (!cfun->pass_startwith) | |
2280 return false; | |
2281 | |
2282 /* For __GIMPLE functions, we have to at least start when we leave | |
2283 SSA. Hence, we need to detect the "expand" pass, and stop skipping | |
2284 when we encounter it. A cheap way to identify "expand" is it to | |
2285 detect the destruction of PROP_ssa. | |
2286 For __RTL functions, we invoke "rest_of_compilation" directly, which | |
2287 is after "expand", and hence we don't reach this conditional. */ | |
2288 if (pass->properties_destroyed & PROP_ssa) | |
2289 { | |
2290 if (!quiet_flag) | |
2291 fprintf (stderr, "starting anyway when leaving SSA: %s\n", pass->name); | |
2292 cfun->pass_startwith = NULL; | |
2293 return false; | |
2294 } | |
2295 | |
2296 if (determine_pass_name_match (pass->name, cfun->pass_startwith)) | |
2297 { | |
2298 if (!quiet_flag) | |
2299 fprintf (stderr, "found starting pass: %s\n", pass->name); | |
2300 cfun->pass_startwith = NULL; | |
2301 return false; | |
2302 } | |
2303 | |
2304 /* For GIMPLE passes, run any property provider (but continue skipping | |
2305 afterwards). | |
2306 We don't want to force running RTL passes that are property providers: | |
2307 "expand" is covered above, and the only pass other than "expand" that | |
2308 provides a property is "into_cfglayout" (PROP_cfglayout), which does | |
2309 too much for a dumped __RTL function. */ | |
2310 if (pass->type == GIMPLE_PASS | |
2311 && pass->properties_provided != 0) | |
2312 return false; | |
2313 | |
2314 /* Don't skip df init; later RTL passes need it. */ | |
2315 if (strstr (pass->name, "dfinit") != NULL) | |
2316 return false; | |
2317 | |
2318 if (!quiet_flag) | |
2319 fprintf (stderr, "skipping pass: %s\n", pass->name); | |
2320 | |
2321 /* If we get here, then we have a "startwith" that we haven't seen yet; | |
2322 skip the pass. */ | |
2323 return true; | |
2324 } | |
2325 | |
2326 /* Skip the given pass, for handling passes before "startwith" | |
2327 in __GIMPLE and__RTL-marked functions. | |
2328 In theory, this ought to be a no-op, but some of the RTL passes | |
2329 need additional processing here. */ | |
2330 | |
2331 static void | |
2332 skip_pass (opt_pass *pass) | |
2333 { | |
2334 /* Pass "reload" sets the global "reload_completed", and many | |
2335 things depend on this (e.g. instructions in .md files). */ | |
2336 if (strcmp (pass->name, "reload") == 0) | |
2337 reload_completed = 1; | |
2338 | |
2339 /* The INSN_ADDRESSES vec is normally set up by | |
2340 shorten_branches; set it up for the benefit of passes that | |
2341 run after this. */ | |
2342 if (strcmp (pass->name, "shorten") == 0) | |
2343 INSN_ADDRESSES_ALLOC (get_max_uid ()); | |
2344 | |
2345 /* Update the cfg hooks as appropriate. */ | |
2346 if (strcmp (pass->name, "into_cfglayout") == 0) | |
2347 { | |
2348 cfg_layout_rtl_register_cfg_hooks (); | |
2349 cfun->curr_properties |= PROP_cfglayout; | |
2350 } | |
2351 if (strcmp (pass->name, "outof_cfglayout") == 0) | |
2352 { | |
2353 rtl_register_cfg_hooks (); | |
2354 cfun->curr_properties &= ~PROP_cfglayout; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2355 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2356 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2357 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2358 /* Execute PASS. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2359 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2360 bool |
111 | 2361 execute_one_pass (opt_pass *pass) |
0 | 2362 { |
2363 unsigned int todo_after = 0; | |
2364 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2365 bool gate_status; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2366 |
0 | 2367 /* IPA passes are executed on whole program, so cfun should be NULL. |
2368 Other passes need function context set. */ | |
2369 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) | |
2370 gcc_assert (!cfun && !current_function_decl); | |
2371 else | |
2372 gcc_assert (cfun && current_function_decl); | |
2373 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2374 current_pass = pass; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2375 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2376 /* Check whether gate check should be avoided. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2377 User controls the value of the gate through the parameter "gate_status". */ |
111 | 2378 gate_status = pass->gate (cfun); |
2379 gate_status = override_gate_status (pass, current_function_decl, gate_status); | |
0 | 2380 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2381 /* Override gate with plugin. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2382 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2383 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2384 if (!gate_status) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2385 { |
111 | 2386 /* Run so passes selectively disabling themselves on a given function |
2387 are not miscounted. */ | |
2388 if (profile_report && cfun && (cfun->curr_properties & PROP_cfg)) | |
2389 { | |
2390 check_profile_consistency (pass->static_pass_number, 0, false); | |
2391 check_profile_consistency (pass->static_pass_number, 1, false); | |
2392 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2393 current_pass = NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2394 return false; |
0 | 2395 } |
2396 | |
111 | 2397 if (should_skip_pass_p (pass)) |
2398 { | |
2399 skip_pass (pass); | |
2400 return true; | |
2401 } | |
2402 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2403 /* Pass execution event trigger: useful to identify passes being |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2404 executed. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2405 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass); |
0 | 2406 |
2407 if (!quiet_flag && !cfun) | |
2408 fprintf (stderr, " <%s>", pass->name ? pass->name : ""); | |
2409 | |
2410 /* Note that the folders should only create gimple expressions. | |
2411 This is a hack until the new folder is ready. */ | |
2412 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; | |
2413 | |
111 | 2414 pass_init_dump_file (pass); |
0 | 2415 |
2416 /* If a timevar is present, start it. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2417 if (pass->tv_id != TV_NONE) |
0 | 2418 timevar_push (pass->tv_id); |
2419 | |
111 | 2420 /* Run pre-pass verification. */ |
2421 execute_todo (pass->todo_flags_start); | |
2422 | |
2423 if (flag_checking) | |
2424 do_per_function (verify_curr_properties, | |
2425 (void *)(size_t)pass->properties_required); | |
2426 | |
0 | 2427 /* Do it! */ |
111 | 2428 todo_after = pass->execute (cfun); |
2429 | |
2430 if (todo_after & TODO_discard_function) | |
0 | 2431 { |
111 | 2432 /* Stop timevar. */ |
2433 if (pass->tv_id != TV_NONE) | |
2434 timevar_pop (pass->tv_id); | |
2435 | |
2436 pass_fini_dump_file (pass); | |
2437 | |
2438 gcc_assert (cfun); | |
2439 /* As cgraph_node::release_body expects release dominators info, | |
2440 we have to release it. */ | |
2441 if (dom_info_available_p (CDI_DOMINATORS)) | |
2442 free_dominance_info (CDI_DOMINATORS); | |
2443 | |
2444 if (dom_info_available_p (CDI_POST_DOMINATORS)) | |
2445 free_dominance_info (CDI_POST_DOMINATORS); | |
2446 | |
2447 tree fn = cfun->decl; | |
2448 pop_cfun (); | |
2449 gcc_assert (!cfun); | |
2450 cgraph_node::get (fn)->release_body (); | |
2451 | |
2452 current_pass = NULL; | |
2453 redirect_edge_var_map_empty (); | |
2454 | |
2455 ggc_collect (); | |
2456 | |
2457 return true; | |
0 | 2458 } |
2459 | |
111 | 2460 do_per_function (clear_last_verified, NULL); |
2461 | |
2462 do_per_function (update_properties_after_pass, pass); | |
2463 | |
2464 if (profile_report && cfun && (cfun->curr_properties & PROP_cfg)) | |
2465 check_profile_consistency (pass->static_pass_number, 0, true); | |
2466 | |
2467 /* Run post-pass cleanup and verification. */ | |
2468 execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il); | |
2469 if (profile_report && cfun && (cfun->curr_properties & PROP_cfg)) | |
2470 check_profile_consistency (pass->static_pass_number, 1, true); | |
2471 | |
2472 verify_interpass_invariants (); | |
2473 | |
0 | 2474 /* Stop timevar. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2475 if (pass->tv_id != TV_NONE) |
0 | 2476 timevar_pop (pass->tv_id); |
2477 | |
111 | 2478 if (pass->type == IPA_PASS |
2479 && ((ipa_opt_pass_d *)pass)->function_transform) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2480 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2481 struct cgraph_node *node; |
111 | 2482 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) |
2483 node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *)pass); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2484 } |
111 | 2485 else if (dump_file) |
2486 do_per_function (execute_function_dump, pass); | |
0 | 2487 |
2488 if (!current_function_decl) | |
111 | 2489 symtab->process_new_functions (); |
0 | 2490 |
2491 pass_fini_dump_file (pass); | |
2492 | |
2493 if (pass->type != SIMPLE_IPA_PASS && pass->type != IPA_PASS) | |
2494 gcc_assert (!(cfun->curr_properties & PROP_trees) | |
2495 || pass->type != RTL_PASS); | |
2496 | |
2497 current_pass = NULL; | |
111 | 2498 redirect_edge_var_map_empty (); |
2499 | |
2500 /* Signal this is a suitable GC collection point. */ | |
2501 if (!((todo_after | pass->todo_flags_finish) & TODO_do_not_ggc_collect)) | |
2502 ggc_collect (); | |
0 | 2503 |
2504 return true; | |
2505 } | |
2506 | |
111 | 2507 static void |
2508 execute_pass_list_1 (opt_pass *pass) | |
0 | 2509 { |
2510 do | |
2511 { | |
2512 gcc_assert (pass->type == GIMPLE_PASS | |
2513 || pass->type == RTL_PASS); | |
111 | 2514 |
2515 if (cfun == NULL) | |
2516 return; | |
0 | 2517 if (execute_one_pass (pass) && pass->sub) |
111 | 2518 execute_pass_list_1 (pass->sub); |
0 | 2519 pass = pass->next; |
2520 } | |
2521 while (pass); | |
2522 } | |
2523 | |
111 | 2524 void |
2525 execute_pass_list (function *fn, opt_pass *pass) | |
2526 { | |
2527 gcc_assert (fn == cfun); | |
2528 execute_pass_list_1 (pass); | |
2529 if (cfun && fn->cfg) | |
2530 { | |
2531 free_dominance_info (CDI_DOMINATORS); | |
2532 free_dominance_info (CDI_POST_DOMINATORS); | |
2533 } | |
2534 } | |
2535 | |
2536 /* Write out all LTO data. */ | |
2537 static void | |
2538 write_lto (void) | |
2539 { | |
2540 timevar_push (TV_IPA_LTO_GIMPLE_OUT); | |
2541 lto_output (); | |
2542 timevar_pop (TV_IPA_LTO_GIMPLE_OUT); | |
2543 timevar_push (TV_IPA_LTO_DECL_OUT); | |
2544 produce_asm_for_decls (); | |
2545 timevar_pop (TV_IPA_LTO_DECL_OUT); | |
2546 } | |
2547 | |
0 | 2548 /* Same as execute_pass_list but assume that subpasses of IPA passes |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2549 are local passes. If SET is not NULL, write out summaries of only |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2550 those node in SET. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2551 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2552 static void |
111 | 2553 ipa_write_summaries_2 (opt_pass *pass, struct lto_out_decl_state *state) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2554 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2555 while (pass) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2556 { |
111 | 2557 ipa_opt_pass_d *ipa_pass = (ipa_opt_pass_d *)pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2558 gcc_assert (!current_function_decl); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2559 gcc_assert (!cfun); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2560 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2561 if (pass->type == IPA_PASS |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2562 && ipa_pass->write_summary |
111 | 2563 && pass->gate (cfun)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2564 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2565 /* If a timevar is present, start it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2566 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2567 timevar_push (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2568 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2569 pass_init_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2570 |
111 | 2571 current_pass = pass; |
2572 ipa_pass->write_summary (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2573 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2574 pass_fini_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2575 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2576 /* If a timevar is present, start it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2577 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2578 timevar_pop (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2579 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2580 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2581 if (pass->sub && pass->sub->type != GIMPLE_PASS) |
111 | 2582 ipa_write_summaries_2 (pass->sub, state); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2583 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2584 pass = pass->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2585 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2586 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2587 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2588 /* Helper function of ipa_write_summaries. Creates and destroys the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2589 decl state and calls ipa_write_summaries_2 for all passes that have |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2590 summaries. SET is the set of nodes to be written. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2591 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2592 static void |
111 | 2593 ipa_write_summaries_1 (lto_symtab_encoder_t encoder) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2594 { |
111 | 2595 pass_manager *passes = g->get_passes (); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2596 struct lto_out_decl_state *state = lto_new_out_decl_state (); |
111 | 2597 state->symtab_node_encoder = encoder; |
2598 | |
2599 lto_output_init_mode_table (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2600 lto_push_out_decl_state (state); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2601 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2602 gcc_assert (!flag_wpa); |
111 | 2603 ipa_write_summaries_2 (passes->all_regular_ipa_passes, state); |
2604 | |
2605 write_lto (); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2606 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2607 gcc_assert (lto_get_out_decl_state () == state); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2608 lto_pop_out_decl_state (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2609 lto_delete_out_decl_state (state); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2610 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2611 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2612 /* Write out summaries for all the nodes in the callgraph. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2613 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2614 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2615 ipa_write_summaries (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2616 { |
111 | 2617 lto_symtab_encoder_t encoder; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2618 int i, order_pos; |
111 | 2619 varpool_node *vnode; |
2620 struct cgraph_node *node; | |
2621 struct cgraph_node **order; | |
2622 | |
2623 if ((!flag_generate_lto && !flag_generate_offload) || seen_error ()) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2624 return; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2625 |
131 | 2626 gcc_assert (!dump_file); |
2627 streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL); | |
2628 | |
111 | 2629 select_what_to_stream (); |
2630 | |
2631 encoder = lto_symtab_encoder_new (false); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2632 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2633 /* Create the callgraph set in the same order used in |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2634 cgraph_expand_all_functions. This mostly facilitates debugging, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2635 since it causes the gimple file to be processed in the same order |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2636 as the source code. */ |
111 | 2637 order = XCNEWVEC (struct cgraph_node *, symtab->cgraph_count); |
2638 order_pos = ipa_reverse_postorder (order); | |
2639 gcc_assert (order_pos == symtab->cgraph_count); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2640 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2641 for (i = order_pos - 1; i >= 0; i--) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2642 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2643 struct cgraph_node *node = order[i]; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2644 |
131 | 2645 if (gimple_has_body_p (node->decl)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2646 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2647 /* When streaming out references to statements as part of some IPA |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2648 pass summary, the statements need to have uids assigned and the |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2649 following does that for all the IPA passes here. Naturally, this |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2650 ordering then matches the one IPA-passes get in their stmt_fixup |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2651 hooks. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2652 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2653 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2654 renumber_gimple_stmt_uids (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2655 pop_cfun (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2656 } |
111 | 2657 if (node->definition && node->need_lto_streaming) |
2658 lto_set_symtab_encoder_in_partition (encoder, node); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2659 } |
111 | 2660 |
2661 FOR_EACH_DEFINED_FUNCTION (node) | |
2662 if (node->alias && node->need_lto_streaming) | |
2663 lto_set_symtab_encoder_in_partition (encoder, node); | |
2664 FOR_EACH_DEFINED_VARIABLE (vnode) | |
2665 if (vnode->need_lto_streaming) | |
2666 lto_set_symtab_encoder_in_partition (encoder, vnode); | |
2667 | |
2668 ipa_write_summaries_1 (compute_ltrans_boundary (encoder)); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2669 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2670 free (order); |
131 | 2671 if (streamer_dump_file) |
2672 { | |
2673 dump_end (TDI_lto_stream_out, streamer_dump_file); | |
2674 streamer_dump_file = NULL; | |
2675 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2676 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2677 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2678 /* Same as execute_pass_list but assume that subpasses of IPA passes |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2679 are local passes. If SET is not NULL, write out optimization summaries of |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2680 only those node in SET. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2681 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2682 static void |
111 | 2683 ipa_write_optimization_summaries_1 (opt_pass *pass, |
2684 struct lto_out_decl_state *state) | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2685 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2686 while (pass) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2687 { |
111 | 2688 ipa_opt_pass_d *ipa_pass = (ipa_opt_pass_d *)pass; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2689 gcc_assert (!current_function_decl); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2690 gcc_assert (!cfun); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2691 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2692 if (pass->type == IPA_PASS |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2693 && ipa_pass->write_optimization_summary |
111 | 2694 && pass->gate (cfun)) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2695 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2696 /* If a timevar is present, start it. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2697 if (pass->tv_id) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2698 timevar_push (pass->tv_id); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2699 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2700 pass_init_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2701 |
111 | 2702 current_pass = pass; |
2703 ipa_pass->write_optimization_summary (); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2704 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2705 pass_fini_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2706 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2707 /* If a timevar is present, start it. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2708 if (pass->tv_id) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2709 timevar_pop (pass->tv_id); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2710 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2711 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2712 if (pass->sub && pass->sub->type != GIMPLE_PASS) |
111 | 2713 ipa_write_optimization_summaries_1 (pass->sub, state); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2714 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2715 pass = pass->next; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2716 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2717 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2718 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2719 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2720 NULL, write out all summaries of all nodes. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2721 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2722 void |
111 | 2723 ipa_write_optimization_summaries (lto_symtab_encoder_t encoder) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2724 { |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2725 struct lto_out_decl_state *state = lto_new_out_decl_state (); |
111 | 2726 lto_symtab_encoder_iterator lsei; |
2727 state->symtab_node_encoder = encoder; | |
2728 | |
2729 lto_output_init_mode_table (); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2730 lto_push_out_decl_state (state); |
111 | 2731 for (lsei = lsei_start_function_in_partition (encoder); |
2732 !lsei_end_p (lsei); lsei_next_function_in_partition (&lsei)) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2733 { |
111 | 2734 struct cgraph_node *node = lsei_cgraph_node (lsei); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2735 /* When streaming out references to statements as part of some IPA |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2736 pass summary, the statements need to have uids assigned. |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2737 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2738 For functions newly born at WPA stage we need to initialize |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2739 the uids here. */ |
111 | 2740 if (node->definition |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2741 && gimple_has_body_p (node->decl)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2742 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2743 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2744 renumber_gimple_stmt_uids (); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2745 pop_cfun (); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2746 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2747 } |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2748 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2749 gcc_assert (flag_wpa); |
111 | 2750 pass_manager *passes = g->get_passes (); |
2751 ipa_write_optimization_summaries_1 (passes->all_regular_ipa_passes, state); | |
2752 | |
2753 write_lto (); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2754 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2755 gcc_assert (lto_get_out_decl_state () == state); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2756 lto_pop_out_decl_state (); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2757 lto_delete_out_decl_state (state); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2758 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2759 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2760 /* Same as execute_pass_list but assume that subpasses of IPA passes |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2761 are local passes. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2762 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2763 static void |
111 | 2764 ipa_read_summaries_1 (opt_pass *pass) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2765 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2766 while (pass) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2767 { |
111 | 2768 ipa_opt_pass_d *ipa_pass = (ipa_opt_pass_d *) pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2769 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2770 gcc_assert (!current_function_decl); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2771 gcc_assert (!cfun); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2772 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2773 |
111 | 2774 if (pass->gate (cfun)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2775 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2776 if (pass->type == IPA_PASS && ipa_pass->read_summary) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2777 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2778 /* If a timevar is present, start it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2779 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2780 timevar_push (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2781 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2782 pass_init_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2783 |
111 | 2784 current_pass = pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2785 ipa_pass->read_summary (); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2786 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2787 pass_fini_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2788 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2789 /* Stop timevar. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2790 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2791 timevar_pop (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2792 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2793 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2794 if (pass->sub && pass->sub->type != GIMPLE_PASS) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2795 ipa_read_summaries_1 (pass->sub); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2796 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2797 pass = pass->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2798 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2799 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2800 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2801 |
111 | 2802 /* Read all the summaries for all_regular_ipa_passes. */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2803 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2804 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2805 ipa_read_summaries (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2806 { |
111 | 2807 pass_manager *passes = g->get_passes (); |
2808 ipa_read_summaries_1 (passes->all_regular_ipa_passes); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2809 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2810 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2811 /* Same as execute_pass_list but assume that subpasses of IPA passes |
0 | 2812 are local passes. */ |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2813 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2814 static void |
111 | 2815 ipa_read_optimization_summaries_1 (opt_pass *pass) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2816 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2817 while (pass) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2818 { |
111 | 2819 ipa_opt_pass_d *ipa_pass = (ipa_opt_pass_d *) pass; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2820 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2821 gcc_assert (!current_function_decl); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2822 gcc_assert (!cfun); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2823 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2824 |
111 | 2825 if (pass->gate (cfun)) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2826 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2827 if (pass->type == IPA_PASS && ipa_pass->read_optimization_summary) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2828 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2829 /* If a timevar is present, start it. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2830 if (pass->tv_id) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2831 timevar_push (pass->tv_id); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2832 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2833 pass_init_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2834 |
111 | 2835 current_pass = pass; |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2836 ipa_pass->read_optimization_summary (); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2837 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2838 pass_fini_dump_file (pass); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2839 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2840 /* Stop timevar. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2841 if (pass->tv_id) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2842 timevar_pop (pass->tv_id); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2843 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2844 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2845 if (pass->sub && pass->sub->type != GIMPLE_PASS) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2846 ipa_read_optimization_summaries_1 (pass->sub); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2847 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2848 pass = pass->next; |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2849 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2850 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2851 |
111 | 2852 /* Read all the summaries for all_regular_ipa_passes. */ |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2853 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2854 void |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2855 ipa_read_optimization_summaries (void) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2856 { |
111 | 2857 pass_manager *passes = g->get_passes (); |
2858 ipa_read_optimization_summaries_1 (passes->all_regular_ipa_passes); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2859 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2860 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2861 /* Same as execute_pass_list but assume that subpasses of IPA passes |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2862 are local passes. */ |
0 | 2863 void |
111 | 2864 execute_ipa_pass_list (opt_pass *pass) |
0 | 2865 { |
2866 do | |
2867 { | |
2868 gcc_assert (!current_function_decl); | |
2869 gcc_assert (!cfun); | |
2870 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | |
2871 if (execute_one_pass (pass) && pass->sub) | |
2872 { | |
2873 if (pass->sub->type == GIMPLE_PASS) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2874 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2875 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL); |
111 | 2876 do_per_function_toporder ((void (*)(function *, void *)) |
2877 execute_pass_list, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2878 pass->sub); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2879 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2880 } |
0 | 2881 else if (pass->sub->type == SIMPLE_IPA_PASS |
2882 || pass->sub->type == IPA_PASS) | |
2883 execute_ipa_pass_list (pass->sub); | |
2884 else | |
2885 gcc_unreachable (); | |
2886 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2887 gcc_assert (!current_function_decl); |
111 | 2888 symtab->process_new_functions (); |
0 | 2889 pass = pass->next; |
2890 } | |
2891 while (pass); | |
2892 } | |
2893 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2894 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2895 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2896 static void |
111 | 2897 execute_ipa_stmt_fixups (opt_pass *pass, |
2898 struct cgraph_node *node, gimple **stmts) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2899 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2900 while (pass) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2901 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2902 /* Execute all of the IPA_PASSes in the list. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2903 if (pass->type == IPA_PASS |
111 | 2904 && pass->gate (cfun)) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2905 { |
111 | 2906 ipa_opt_pass_d *ipa_pass = (ipa_opt_pass_d *) pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2907 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2908 if (ipa_pass->stmt_fixup) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2909 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2910 pass_init_dump_file (pass); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2911 /* If a timevar is present, start it. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2912 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2913 timevar_push (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2914 |
111 | 2915 current_pass = pass; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2916 ipa_pass->stmt_fixup (node, stmts); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2917 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2918 /* Stop timevar. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2919 if (pass->tv_id) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2920 timevar_pop (pass->tv_id); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2921 pass_fini_dump_file (pass); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2922 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2923 if (pass->sub) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2924 execute_ipa_stmt_fixups (pass->sub, node, stmts); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2925 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2926 pass = pass->next; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2927 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2928 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2929 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2930 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2931 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2932 void |
111 | 2933 execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple **stmts) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2934 { |
111 | 2935 pass_manager *passes = g->get_passes (); |
2936 execute_ipa_stmt_fixups (passes->all_regular_ipa_passes, node, stmts); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2937 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2938 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2939 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2940 extern void debug_properties (unsigned int); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2941 extern void dump_properties (FILE *, unsigned int); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2942 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2943 DEBUG_FUNCTION void |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2944 dump_properties (FILE *dump, unsigned int props) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2945 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2946 fprintf (dump, "Properties:\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2947 if (props & PROP_gimple_any) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2948 fprintf (dump, "PROP_gimple_any\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2949 if (props & PROP_gimple_lcf) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2950 fprintf (dump, "PROP_gimple_lcf\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2951 if (props & PROP_gimple_leh) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2952 fprintf (dump, "PROP_gimple_leh\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2953 if (props & PROP_cfg) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2954 fprintf (dump, "PROP_cfg\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2955 if (props & PROP_ssa) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2956 fprintf (dump, "PROP_ssa\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2957 if (props & PROP_no_crit_edges) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2958 fprintf (dump, "PROP_no_crit_edges\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2959 if (props & PROP_rtl) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2960 fprintf (dump, "PROP_rtl\n"); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2961 if (props & PROP_gimple_lomp) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2962 fprintf (dump, "PROP_gimple_lomp\n"); |
111 | 2963 if (props & PROP_gimple_lomp_dev) |
2964 fprintf (dump, "PROP_gimple_lomp_dev\n"); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2965 if (props & PROP_gimple_lcx) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2966 fprintf (dump, "PROP_gimple_lcx\n"); |
111 | 2967 if (props & PROP_gimple_lvec) |
2968 fprintf (dump, "PROP_gimple_lvec\n"); | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2969 if (props & PROP_cfglayout) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2970 fprintf (dump, "PROP_cfglayout\n"); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2971 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2972 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2973 DEBUG_FUNCTION void |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2974 debug_properties (unsigned int props) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2975 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2976 dump_properties (stderr, props); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2977 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2978 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2979 /* Called by local passes to see if function is called by already processed nodes. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2980 Because we process nodes in topological order, this means that function is |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2981 in recursive cycle or we introduced new direct calls. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2982 bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2983 function_called_by_processed_nodes_p (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2984 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2985 struct cgraph_edge *e; |
111 | 2986 for (e = cgraph_node::get (current_function_decl)->callers; |
2987 e; | |
2988 e = e->next_caller) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2989 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2990 if (e->caller->decl == current_function_decl) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2991 continue; |
111 | 2992 if (!e->caller->has_gimple_body_p ()) |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2993 continue; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2994 if (TREE_ASM_WRITTEN (e->caller->decl)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2995 continue; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2996 if (!e->caller->process && !e->caller->global.inlined_to) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2997 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2998 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2999 if (dump_file && e) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
3000 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
3001 fprintf (dump_file, "Already processed call to:\n"); |
111 | 3002 e->caller->dump (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
|
3003 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
3004 return e != NULL; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
3005 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
3006 |
0 | 3007 #include "gt-passes.h" |